# Manipulate code crashes V10.1

This code is working with Mathematica 9, but Mathematica 10.1 is becomes unresponsive when I try to evaluate it.

Manipulate[
co = 2.0*^8; ω =
2 Pi \[ScriptF] 10^6; τ = \[ScriptCapitalT] 10^-9; z0 = Z0;
t = ts*10^-9;
sol = Solve[{a + b ==
1, (a E^(-I ω τ) +
b E^(I ω τ)) == (a E^(-I ω τ) -
b E^(I ω τ))*RL/z0}, {a, b}];
Vi[t_, x_] := a E^(I ω (t - x/co)) /. sol[];
Vr[t_, x_] := b E^(I ω (t + x/co)) /. sol[];
Vx[t_, x_] := Vi[t, x] + Vr[t, x];
Ix[t_, x_] := (Vi[t, x] - Vr[t, x])/z0; Z = Vx[0, 0]/Ix[0, 0] // N;
maxI = Max[Abs[Ix[Range[0, τ, τ/100], 0]]];
maxV = Max[Abs[Vx[Range[0, τ, τ/100], 0]]];
Grid[{{Plot[{Re[Vi[t, x]], Abs[Vi[t, x]], -Abs[Vi[t, x]],
Re[Vr[t, x]]}, {x, 0, τ co},
PlotRange -> {{0, τ co}, All},
PlotLabel ->
"\!$$\*SubscriptBox[\(V$$, $$+$$]\),\!$$\*SubscriptBox[\(V$$, \
$$-$$]\)"],
Show[ParametricPlot[{Re[Ix[γ, 0]],
Re[Vx[γ, 0]]}, {γ, 0, 10^-6/\[ScriptF]},
AspectRatio -> Full, AxesLabel -> {"I(t)", "V(t)"}],
ListPlot[{{Re[Ix[t, 0]], Re[Vx[t, 0]]}}, PlotMarkers -> {"\!$$\* StyleBox[\"o\",\nFontSize->18]$$"}]]}, {Plot[{Re[Vx[t, x]],
Abs[Vx[t, x]], -Abs[Vx[t, x]]}, {x, 0, τ co},
PlotRange -> {{0, τ co}, All}, PlotLabel -> "V(x)"],
Plot[{Re[Ix[t, x]], Abs[Ix[t, x]], -Abs[Ix[t, x]]}, {x,
0, τ co}, PlotRange -> {{0, τ co}, All},
PlotLabel -> "I(x)"]}, {"Impedance Measured:",
Switch[Sign[Im[Z]], 1,
Row[{"r=", Re[Z], "Ohm", "  L=", Im[Z]/ω*10^9 // N,
" nH"}], -1,
Row[{"r=", 1/Re[1/Z], "Ohm", "  C=", Im[1/Z]/ω*10^12 // N,
" pF"}], 0, Row[{"r=", Re[Z], "Ohm"}]]}}], {{ts, 0,
"Time ns"}, 0, 1000/\[ScriptF],
ControlType -> Animator}, Delimiter, {{\[ScriptF], 100,
"Frequency MHz"}}, Delimiter, {{Z0, 50,
"Line Impedace Ohm"}}, Delimiter, {{RL, 100,
"Load Impedance Ohm"}}, Delimiter, {{\[ScriptCapitalT], 0.5,
"Line Delay nsec"}}, ControlPlacement -> Right]

• Hell, should we read all of this and deduce what the problem is ?! Format your code properly, provide any additional (relevant) information and, please, keep it simple -- no need to post 40 lines of code if you can illustrate it in 5. – Sektor Jun 25 '15 at 21:34
• No crash for me on Windows 8.1 . Please tell which OS you use. – Rolf Mertig Jun 25 '15 at 22:23
• It ran fine on Windows 8.1 for me until I tried to close the window, when it hung. I had to kill it with Task Manager. This is reproducible. – bbgodfrey Jun 25 '15 at 22:55
• Manipulate continuously updates the argument. Add Grid[{{RandomReal}, { ... you will see the argument is updated even when the play button is paused. In V10 I am facing a lot of troubles with Manipulate and it is not know how it works internally. The memory keeps building up also. – Algohi Jun 26 '15 at 6:13
• @m_goldberg I ran it @ v 10.1 and its running smooth, no kernel crashes, no nothing. – Sektor Jun 27 '15 at 18:13

I received an answer from support that it's a Manipulate bug.

The following code is stable(it's working on Mathematica 10, Windows 7):

co = 2.0*^8; ω =
2 Pi \[ScriptF] 10^6; τ = \[ScriptCapitalT] 10^-9; t =
ts*10^-9; sol =
Solve[{a + b ==
1, (a E^(-I ω τ) +
b E^(I ω τ)) == (a E^(-I ω τ) -
b E^(I ω τ))*RL/Z0}, {a, b}];
Vi[ts_, x_, \[ScriptF]_, Z0_, RL_, \[ScriptCapitalT]_] :=
Evaluate[(a E^(I ω (t - x/co)) /. sol[])];
Vr[ts_, x_ , \[ScriptF]_, Z0_, RL_, \[ScriptCapitalT]_] :=
Evaluate[(b E^(I ω (t + x/co)) /. sol[])];
Vx[ts_, x_ , \[ScriptF]_, Z0_, RL_, \[ScriptCapitalT]_] :=
Vi[ts, x , \[ScriptF], Z0, RL, \[ScriptCapitalT]] +
Vr[ts, x, \[ScriptF], Z0, RL, \[ScriptCapitalT]];
Ix[ts_, x_, \[ScriptF]_, Z0_,
RL_, \[ScriptCapitalT]_] := (Vi[ts, x, \[ScriptF], Z0,
RL, \[ScriptCapitalT]] -
Vr[ts, x, \[ScriptF], Z0, RL, \[ScriptCapitalT]])/
Z0; xmax = \[ScriptCapitalT] 10^-9 co; tmax = 10^3/\[ScriptF];

Manipulate[
Z = Vx[0, 0, \[ScriptF], Z0, RL, \[ScriptCapitalT]]/
Ix[0, 0, \[ScriptF], Z0, RL, \[ScriptCapitalT]] // N;
maxI = Max[
Abs[Ix[Range[0, xmax, xmax/100], 0, \[ScriptF], Z0,
RL, \[ScriptCapitalT]]]];
maxV = Max[
Abs[Vx[Range[0, xmax, xmax/100], 0, \[ScriptF], Z0,
RL, \[ScriptCapitalT]]]];
Grid[{{Plot[{Re[Vi[ts, x, \[ScriptF], Z0, RL, \[ScriptCapitalT]]],
Abs[Vi[ts, x, \[ScriptF], Z0, RL, \[ScriptCapitalT]]], -Abs[
Vi[ts, x, \[ScriptF], Z0, RL, \[ScriptCapitalT]]],
Re[Vr[ts, x, \[ScriptF], Z0, RL, \[ScriptCapitalT]]]}, {x, 0,
xmax}, PlotRange -> {{0, xmax}, All},
PlotLabel ->
"\!$$\*SubscriptBox[\(V$$, $$+$$]\),\!$$\*SubscriptBox[\(V$$, \
$$-$$]\)"],
Show[ParametricPlot[{Re[
Ix[γ, 0, \[ScriptF], Z0, RL, \[ScriptCapitalT]]],
Re[Vx[γ, 0, \[ScriptF], Z0,
RL, \[ScriptCapitalT]]]}, {γ, 0, tmax},
PlotStyle -> {Red}, AspectRatio -> Full,
AxesLabel -> {"I(t)", "V(t)"}],
ListPlot[{{Re[Ix[ts, 0, \[ScriptF], Z0, RL, \[ScriptCapitalT]]],
Re[Vx[ts, 0, \[ScriptF], Z0, RL, \[ScriptCapitalT]]]}},
PlotMarkers -> {"\!$$\* StyleBox[\"o\",\nFontSize->18]$$"}]]}, {Plot[{Re[
Vx[ts, x, \[ScriptF], Z0, RL, \[ScriptCapitalT]]],
Abs[Vx[ts, x, \[ScriptF], Z0, RL, \[ScriptCapitalT]]], -Abs[
Vx[ts, x, \[ScriptF], Z0, RL, \[ScriptCapitalT]]]}, {x, 0,
xmax}, PlotRange -> {{0, xmax}, All}, PlotLabel -> "V(x)"],
Plot[{Re[Ix[ts, x, \[ScriptF], Z0, RL, \[ScriptCapitalT]]],
Abs[Ix[ts, x, \[ScriptF], Z0, RL, \[ScriptCapitalT]]], -Abs[
Ix[ts, x, \[ScriptF], Z0, RL, \[ScriptCapitalT]]]}, {x, 0,
xmax}, PlotRange -> {{0, xmax}, All},
PlotLabel -> "I(x)"]}, {"Impedance Measured:",
Switch[Sign[Im[Z]], 1,
Row[{"r=", Re[Z], "Ohm", "  L=",
Im[Z]/(2 Pi \[ScriptF] 10^6)*10^9 // N, " nH"}], -1,
Row[{"r=", 1/Re[1/Z], "Ohm", "  C=",
Im[1/Z]/(2 Pi \[ScriptF] 10^6)*10^12 // N, " pF"}], 0,
Row[{"r=", Re[Z], "Ohm"}]]}}], {{ts, 0, "Time ns"}, 0, tmax,
ControlType -> Animator}, Delimiter, {{\[ScriptF], 100,
"Frequency MHz"}}, Delimiter, {{Z0, 50,
"Line Impedace Ohm"}}, Delimiter, {{RL, 100,
"Load Impedance Ohm"}}, Delimiter, {{\[ScriptCapitalT], 0.5,
"Line Delay nsec"}}, ControlPlacement -> Right,
TrackedSymbols -> {ts, \[ScriptF], Z0, RL, \[ScriptCapitalT]},
SaveDefinitions -> True]

• Formatting your code is simple as pressing a button -- please, go to the help centre read more about it and use it in the future. Also Aligning your code is pretty important too. – Sektor Jun 27 '15 at 18:11