I am studying an infinite square well in the context of quantum mechanics.
ClearAll["Global`*"];
(* Length of the well *)
L = 1;
(* The eigenfunctions, n=1,2,3,... *)
u[n_, x_] := Sqrt[2/L] Sin[n π x / L]
(* Probability density function, ρ[x] = |u[n,x]|^2 *)
ρ[n_, x_] := Simplify[u[n, x]\[Conjugate] u[n, x], {n ∈ Integers, x ∈ Reals}]
(* Plots of ρ[n,x] for various values of n *)
Table[ Plot[ρ[n, x], {x, 0, L}, PlotLabel -> "ρ[" <> ToString@n <> ",x]"], {n, 1, 4}]
And here is the output:

My questions is:
Can I use Mathematica pattern magic to rewrite PlotLabel -> "ρ[" <> ToString@n <> ",x]" ?
For instance, I tried (although I knew it wouldn't work): PlotLabel -> HoldForm@ρ[n,x], but that of course leaves n unevaluated as well, although I would like n to be evaluated and then the result to be held.





HoldForm[]instead ofDefer[]here ? I tried it and it works, but are there any caveats? – stathisk Nov 06 '13 at 23:29HoldFormis probably even safer asDefergets evaluated when given explicitly as input. – Ajasja Nov 06 '13 at 23:36