Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to make an equation where the values adjust to my slider which I inserted with manipulate.

Well, I tried, but when I use the slider the equation starts to fall apart. quadratic equation in mathematica

Actually this should happen

quadratic equation steps

Is it possible to make an quadratic equation in mathematica where the variables and their results adjust themselves to a slider which has been inserted with manipulate?

share|improve this question
up vote 5 down vote accepted

You could use Row and ToString:

  Row[{"f(", a, ") = ", a^2, " = ", ToString[a]^2}],
  {a, 0, 10, 1}

Mathematica graphics

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:

 TraditionalForm[ f[a] == a^2 == Superscript[a, 2] ],
 {a, 1, 10, 1}

Mathematica graphics

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 *)

 With[{a = a},
  TraditionalForm[HoldForm[f[a]] == a^2 == Superscript[a, 2]]
 {a, 1, 10, 1}

Mathematica graphics

share|improve this answer
Hope you don’t mind the edit. I realise my draft wasn't different enough – Verbeia Sep 26 '12 at 11:32
@Verbeia much appreciated; my answer was incomplete but I'm getting sleepy. Time to quit I think. – Mr.Wizard Sep 26 '12 at 11:33
@Mr.Wizard How come Manipulate[ StringJoin["f(", a, ") = ", a^2, " = ", ToString[a]^2], {a, 1, 10, 1}] does not work ? – b.gatessucks Sep 26 '12 at 11:34
@b.gatessucks you would need to convert a, a^2, and ToString[a]^2 to strings as well. That's why I used Row. – Mr.Wizard Sep 26 '12 at 11:37
@Mr.Wizard Thanks. – b.gatessucks Sep 26 '12 at 11:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.