# What does FEa$$305…mean when trying to add PlotLegends to a very simple Manipulate I'm new at Mathematica and am playing with some simple calculus to try to understand about using Manipulate. Here's my code: Manipulate[ Plot[{a x^2 + b x + c, b + 2 a x, 2 a}, {x, -5, 5}, PlotRange -> {{-10, 10}, {-10, 10}}, PlotLegends -> "Expressions"], {a, -5, 5}, {b, -5, 5}, {c, -5, 5}]  When I execute the function, instead of getting the "a x^2 + b x + c" as an Expression label, I get FEa$$295 x^2 +...

I get similar expression labels for the other two functions.

What does this indicate and how should i code this to get actual labels for PlotLegends and not this garbage?

Thanks!

• Anything inside a DynamicModule-type construct (which Manipulate is) will scope all variables to protect them. This is how the FE does that. You can also supply PlotLegends -> {"a" x^2 + "b" x + c, "b" + 2 "a" x, 2 "a"} instead of Nasser's answer if you want to keep your variables protected / from messing with the global scope. – b3m2a1 Mar 2 '18 at 2:14

## 2 Answers

This seems due to localization. Here is a quick solution (I am sure there are other ways to handle this, but this seems the easiest now). Just add LocalizeVariables->False

Manipulate[
Plot[{a x^2+b x+c,b+2 a x,2 a},{x,-5,5},
PlotRange->{{-10,10},{-10,10}},
PlotLegends->"Expressions"],{a,-5,5},{b,-5,5},{c,-5,5},
LocalizeVariables->False] This will show the parametric formulas:

Manipulate[
Block[{a = a0, b = b0, c = c0},
Plot[{a x^2 + b x + c, b + 2 a x, 2 a}, {x, -5, 5},
PlotRange -> {{-10, 10}, {-10, 10}}, PlotLegends -> "Expressions"]
],
{{a0, -5, "a"}, -5, 5}, {{b0, -5, "b"}, -5, 5}, {{c0, -5, "c"}, -5, 5}] This will show the actual formulas:

Manipulate[
Block[{x},
Plot[#, {x, -5, 5}, PlotRange -> {{-10, 10}, {-10, 10}},
PlotLegends -> "Expressions"] &@{a x^2 + b x + c, b + 2 a x, 2 a}
],
{a, -5, 5}, {b, -5, 5}, {c, -5, 5}] Actually, I would normally do this one with Evaluate, but it was late and I was tired:

Manipulate[
Block[{x},
Plot[Evaluate@{a x^2 + b x + c, b + 2 a x, 2 a}, {x, -5, 5},
PlotRange -> {{-10, 10}, {-10, 10}}, PlotLegends -> "Expressions"]
],
{a, -5, 5}, {b, -5, 5}, {c, -5, 5}]


Some further explanation: As others have mentioned, the funny FE-$$ symbols are due to localization. The localization is accomplished first by Manipulate rewriting the literal instances of the Manipulate variables in the unevaluated code of the body (first argument) with symbols like CellContexta$$ for the user's a and so forth. Usually, instances of a etc. in other arguments are rewritten. Basic data and code for the Manipulate are stored in an output cell. The second step is when the output cell is displayed by the Front End ("typeset" in FE jargon). The local instances of the variables are actually created: The $CellContext is changed to FE and a unique number is added after the $\$ to create a (hopefully) unique symbol for the variable. If you copy and paste it, the cell expression is copied. When the new cell is typeset, this second step is repeated and new, unique localized variables are created, which let the two demos operate independently (unless variable localization has been turned off).

• why does the second example show the numbers while the first do not? what is the difference? – Alucard Mar 2 '18 at 4:13
• @Alucard The expressions are evaluated in the second one before Plot sees them, but not in the first....Should probably protect x` in the second one. -- updated – Michael E2 Mar 2 '18 at 4:15