# Plotting a complicated function defined in terms of other defined quantities

Perhaps this question will be too broad or poorly asked since it is about some very simple problems and I apologize if that is the case.

So, I'm just trying to plot the curve of a complicated and long function. To do so, I defined several quantities which are part of the function (just like we did while doing the analytical calculations by hand) and then defined the function in terms of them and tried to plot with a manipulate. Here is what my notebook looks like (I hope the Subscripts and OversciptBoxes don't make it unreadable):

ClearAll;

(*\[Chi] is Subscript[v, \[Chi]]*)
(*c is Subscript[c, W]*)

Subscript[v, W] = 246;
Subscript[v, \[Rho]] = 150;

Subscript[
\!$$\*OverscriptBox[\(v$$, $$_$$]\), \[Rho]] = Subscript[
v, \[Rho]]/\[Chi];
Subscript[
\!$$\*OverscriptBox[\(v$$, $$_$$]\), W] = Subscript[v, W]/\[Chi];
t := (1 - c^2)^2/(1 - 4*(1 - c^2)^2);

(*t is, in fact, t^2*)

A = 1/3*(3*t*((Subscript[
\!$$\*OverscriptBox[\(v$$, $$_$$]\), \[Rho]])^2 + 1) + (Subscript[
\!$$\*OverscriptBox[\(v$$, $$_$$]\), W])^2 + 1);

R = Sqrt[(1 - 1/(3*A^2) (4*t + 1)*((Subscript[
\!$$\*OverscriptBox[\(v$$, $$_$$]\), W])^2*((Subscript[
\!$$\*OverscriptBox[\(v$$, $$_$$]\), \[Rho]])^2 + 1) - (Subscript[
\!$$\*OverscriptBox[\(v$$, $$_$$]\), \[Rho]])^4))];

Subscript[m, 1] := A*(1 - R);
Subscript[m, 2] := A*(1 + R);

(*Subscript[m, 1] and Subscript[m, 2] are, in fact Subscript[m, 1]^2 \
and Subscript[m, 2]^2*)

Subscript[N, 1] = (3*(2*Subscript[m, 2] + (Subscript[
\!$$\*OverscriptBox[\(v$$, $$_$$]\), \[Rho]])^2 - 4/3*(Subscript[
\!$$\*OverscriptBox[\(v$$, $$_$$]\), W])^2 - 1/3)^2 + ((Subscript[
\!$$\*OverscriptBox[\(v$$, $$_$$]\), \[Rho]])^2 - 1)^2*(4*t + 1))^-2;
Subscript[N, 2] = (3*(2*Subscript[m, 1] + (Subscript[
\!$$\*OverscriptBox[\(v$$, $$_$$]\), \[Rho]])^2 - 4/3*(Subscript[
\!$$\*OverscriptBox[\(v$$, $$_$$]\), W])^2 - 1/3)^2 + ((Subscript[
\!$$\*OverscriptBox[\(v$$, $$_$$]\), \[Rho]])^2 - 1)^2*(4*t + 1))^-2;

Subscript[g, V] = -Subscript[N, 1]*c/
3*(1 - 6*Subscript[m, 2] - 3*(Subscript[
\!$$\*OverscriptBox[\(v$$, $$_$$]\), \[Rho]])^2 + 4*(Subscript[
\!$$\*OverscriptBox[\(v$$, $$_$$]\), W])^2);

Manipulate[Plot[Subscript[g, V], {c, 0, 1}], {\[Chi], 1000, 2000}]


Which doesn't plot anything.

At first (as some comments in the code express) I defined the functions as squares (as they are in the work) but got problems from Mathematica interpretating superscripts as the power operation and not allowing me to mess with protected operations (but I would still like how to do that).

Also, the manipulate wasn't working while I was calling what became $$\chi$$ by $$v_{\chi}$$. I solved those problems by brute force (that is, renaming the quantities as clean symbols) but now I end up with no curve in the plot.

I suspect the problem is just that subscripts and superscripts in general don't work as simply as I would think, but I guess the direct question would be what is the most 'correct' and clean way to define a symbolic function (which is to be plotted) in terms of several other quantities which depend on themselves?

• This is so hard to read. Ditch the subscripts and Greek symbols for regular ASCII characters to start. That'll possibly fix the issue, and if not, make it easier for others to debug. – ktm Dec 5 '18 at 2:27

This works, which is your Subscript[g, V] function, except defined properly in Mathematica using :=:

f[c_, \[Chi]_] := -((c*(1 - 2*(1 + Sqrt[1 - (3*(1 + (4*(1 - c^2)^2)/(1 - 4*(1 - c^2)^2))*(-(506250000/\[Chi]^4) + (60516*(1 + 22500/\[Chi]^2))/\[Chi]^2))/(1 + (3*(1 - c^2)^2*(1 + 22500/\[Chi]^2))/(1 - 4*(1 - c^2)^2) + 60516/\[Chi]^2)^2])*
(1 + (3*(1 - c^2)^2*(1 + 22500/\[Chi]^2))/(1 - 4*(1 - c^2)^2) + 60516/\[Chi]^2) + 174564/\[Chi]^2))/
(3*(3*(-(1/3) + (2/3)*(1 + Sqrt[1 - (3*(1 + (4*(1 - c^2)^2)/(1 - 4*(1 - c^2)^2))*(-(506250000/\[Chi]^4) + (60516*(1 + 22500/\[Chi]^2))/\[Chi]^2))/(1 + (3*(1 - c^2)^2*(1 + 22500/\[Chi]^2))/(1 - 4*(1 - c^2)^2) + 60516/\[Chi]^2)^2])*
(1 + (3*(1 - c^2)^2*(1 + 22500/\[Chi]^2))/(1 - 4*(1 - c^2)^2) + 60516/\[Chi]^2) - 58188/\[Chi]^2)^2 + (1 + (4*(1 - c^2)^2)/(1 - 4*(1 - c^2)^2))*(-1 + 22500/\[Chi]^2)^2)^2))

Manipulate[Plot[f[c, \[Chi]], {c, 0, 1}], {\[Chi], 1000, 2000}] • Thank you so much for the answer and sorry about the awfull writing of the code (without the Mathematica symbols). Is there a way to do what you did but without pluging the explicit numerical values of my predefined quantities? – GaloisFan Dec 5 '18 at 2:39
• Try this: g[c_, \[Chi]_] := Evaluate[(-Subscript[N, 1])*(c/3)*(1 - 6*Subscript[m, 2] - 3*Subscript[OverBar[v], \[Rho]]^2 + 4*Subscript[OverBar[v], W]^2)], and then Manipulate[Plot[g[c, \[Chi]], {c, 0, 1}], {\[Chi], 1000, 2000}] – ktm Dec 5 '18 at 2:42
• If I had more time and it wasn't 2 in the morning I'd go into detail about everything you could/should do better, but unfortunately can't be doing that at the moment – ktm Dec 5 '18 at 2:42
• I'll try it. And no worries, you helped a lot, thanks! – GaloisFan Dec 5 '18 at 2:51