You could use Row
and ToString
:
Manipulate[
Row[{"f(", a, ") = ", a^2, " = ", ToString[a]^2}],
{a, 0, 10, 1}
]
The problem is that you are effectively multiplying some strings and some other expressions together. Mathematica tries to order expressions in a canonical order. You could try wrapping a list of the elements in Row
or you could convert the non-String items to strings using ToString
and then use StringJoin
(shorthand <>
) to put them together.
Another approach, probably better:
Manipulate[
TraditionalForm[ f[a] == a^2 == Superscript[a, 2] ],
{a, 1, 10, 1}
]
Note that since f
is a symbol here and not a string, it is evaluated and if it has a value, e.g. f=3
than this leads to something like $3(1)=1=1^2$. You can prevent this by using "f"[a]
instead, or to retain the ()
brackets and italic formatting of TraditionalForm you could use a baroque construct like this:
f[_] = "Fail!"; (* troublesome example definition *)
Manipulate[
With[{a = a},
TraditionalForm[HoldForm[f[a]] == a^2 == Superscript[a, 2]]
],
{a, 1, 10, 1}
]