Hopefully a simple problem for the experts here.
I have a need many times to build a symbolic expression for an equation (say a PDE) to use for plot labels in a low level function inside Manipulate, and so I make a function that I call to build the pde in symbolic form, so I can use it for a plot label. I pass the PDE parameters to this function, and the function uses HoldForm to build it.
But when one of the parameters is 1 (or even zero), and because of HoldForm, these remain stuck there and do not simplify away, and I'd like to remove them.
Currently I use If statement to check for these cases. But I have a feeling there is a better way.
Here is the function (example)
f[c_] := Module[{},
HoldForm[c* D["u"["x", "t"], {"x", 2}] == "f"["x", "t"]]
]
now, when I call it like this
f[1]
it returns

So now I do
f[c_] := Module[{},
If[c == 1,
HoldForm[ D["u"["x", "t"], {"x", 2}] == "f"["x", "t"] ],
HoldForm[c* D["u"["x", "t"], {"x", 2}] == "f"["x", "t"] ],
]
]
and now f[1] returns

I tried many things, (Defer, Simplify, Evaluate, etc...) and nothing works, other than by doing this manual check before using HoldForm.
And about the use of strings there, I had to do it this way :). Too many problems if I use actual symbols. Long story. May be for another topic I can explain why, but for the above works ok for me now other than those extra checks I have to do manually.
question is: is there a trick to do what I am doing about without the If check (I have few parameters to check, and have to do many checks for 1's and 0's as well). Not a big problem for me to do the checks, just wondering if there is a trick I am overlooking.
thanks


Module[{}, ...]? – Mr.Wizard♦ Jan 19 '12 at 16:13foo[x_]:=Module[{},x^2]vs.foo[x_]:=x^2? thanks – Nasser Jan 19 '12 at 22:20