# Solve inside of InputField is not dynamic

On the 7th line, I have an InputField that I want to dynamically change as I change the input. It solves an equation that is later used to determine the change in y intercept in the graph. However, the value (h) doesn't change as I change the other values. What am I doing wrong here?

I included a picture here. When I change the values in yellow, they should change the value in blue. Manipulate[
DynamicModule[{p = 0, c = 1, d = 1, f = 0, \[Theta] = 0, i = 1, j = 1, k = 2}, Deploy[Style[
Panel[Grid[Transpose[{{"P", "C", "D", "F", "\[Theta]", "h", "height", "left", "right"},
{InputField[Dynamic[p]], InputField[Dynamic[c]],
InputField[Dynamic[d]], InputField[Dynamic[f]],
InputField[Dynamic[\[Theta]]],
InputField[Dynamic[h = x /.Solve[2 == x*Cos[\[Theta]] - (p*x^2)/(6*c*d) (3 f + x) Sin[\[Theta]], x, Reals][]],
InputField[Dynamic[i]],
InputField[Dynamic[j]], InputField[Dynamic[k]]]}}],
Alignment -> Right], ImageMargins -> 10, DefaultOptions ->
{InputField -> {ContinuousAction -> True, FieldSize -> {{5, 30}, {1, Infinity}}}}]]] Dynamic[Show[
{Graphics[{Opacity[0.5], Red,
Rectangle[{1, 0}, {2, 1}]},
PlotRange -> {{-1, 2}, {-3, 3}}, Axes -> True,
AxesOrigin -> {0, 0}],
ParametricPlot[{x*Cos[\[Theta]] - (p*x^2)/(6*c*d) (3 f + x) Sin[\[Theta]],
x*Sin[\[Theta]] + (p*x^2)/(6*c*d) (3 f + x) Cos[\[Theta]] + h*Sin[\[Theta]] + (p*h^2)/(6*c*d) (3 f + h) Cos[\[Theta]] + i}, {x, 0, h}, Axes -> True]}]]]]


Thanks!

edit: small error in pasting

edit2: some changes, pasted below

    Manipulate[h = x /. Quiet@Solve[2 == x*Cos[\[Theta]] - (p*x^2)/(6*c*d) (3 f + x) Sin[\[Theta]], x, Reals][];
Text[h]
Show[{Graphics[{Opacity[0.5], Red, Rectangle[{1, 0}, {2, 1}]},
PlotRange -> {{-1, 2}, {-3, 3}},
Axes -> True, AxesOrigin -> {0, 0}],
ParametricPlot[{x*Cos[\[Theta]] - (p*x^2)/(6*c*d) (3 f + x) Sin[\[Theta]],x*Sin[\[Theta]] + (p*x^2)/(6*c*d) (3 f + x) Cos[\[Theta]] + h*Sin[\[Theta]] + (p*h^2)/(6*c*d) (3 f + h) Cos[\[Theta]] + i},
{x, 0, h}, Axes -> True]}],
{p, 0.2, 2, ControlType -> InputField}, {c, 0.2, 2, ControlType -> InputField},
{d, 0.2, 2, ControlType -> InputField}, {f, 0.2, 2, ControlType -> InputField},
{\[Theta], 0, \[Pi], ControlType -> InputField}, {i, 0.2, 2, ControlType -> InputField},
{j, 0.2, 2, ControlType -> InputField}, {k, 0.2, 2, ControlType -> InputField},
{l, 0.2, 2, ControlType -> InputField}]

• Why aren't you calling the variables to be changed in the second argument of Manipulate[]? – Feyre Jul 8 '16 at 12:51
• Would that be the correct way to do it? I'm new at this, so I'm just learning as I'm going. – rxc370 Jul 8 '16 at 13:01
• I just looked up Manipulate. I'm a bit confused about what you mean. Can you explain it a bit more? – rxc370 Jul 8 '16 at 13:02

There's no need for all this dynamic stuff, you can use Solve[] in conjunction with Manipulate[], and let Manipulate[] handle the dynamic stuff.

Manipulate[
h = x /. Quiet@
Solve[2 ==
x*Cos[θ] - (p*x^2)/(6*c*d) (3 f + x) Sin[θ], x,
Reals][];
Show[{Graphics[{Opacity[0.5], Red, Rectangle[{1, 0}, {2, 1}]},
PlotRange -> {{-1, 2}, {-3, 3}}, Axes -> True,
AxesOrigin -> {0, 0}],
ParametricPlot[{x*
Cos[θ] - (p*x^2)/(6*c*d) (3 f + x) Sin[θ],
x*Sin[θ] + (p*x^2)/(6*c*d) (3 f + x) Cos[θ] +
h*Sin[θ] + (p*h^2)/(6*c*d) (3 f + h) Cos[θ] +
i}, {x, 0, h}, Axes -> True]}], {ρ, 0, 1, 0.1}, {c, 0.2, 2,
0.2}, {d, 0.2, 2, 0.2}, {f, 0, 2, 0.2}, {p, 0, 2, 0.2}, {θ,
0, π, 0.1 π}, {i, -2, 2, 0.5},ControlType -> InputField]

• Thanks, but this still isn't working the way it should be. The end of the curve isn't intersecting with the corner of the box. Also, what is the [Rho] for? And is there anyway to get InputFields back? Thanks again! – rxc370 Jul 8 '16 at 13:25
• @rxc370 I cannot account for the validity of your expressions, this code changes the value of h dynamically as you asked. As for the inputfield, just add ControlType -> InputField to the Manipulate[]. I mistook p for rho. – Feyre Jul 8 '16 at 13:28
• Sorry, last question. If I wanted to output the value of a variable as text somewhere, how would I do it? Before, I just made it a dynamic InputField. – rxc370 Jul 8 '16 at 13:49
• @rxc370 Text[] is a graphics directive – Feyre Jul 8 '16 at 13:57

Got everything working the way I want it to. Here is the code below if anyone ever wants to model a cantilever bending on a box.

Manipulate[h = x /. Quiet@Solve[k == x*Cos[\[Theta]] - (p*x^2)/(6*c*d) (3 f + x) Sin[\[Theta]], x, Reals][];
a = x /.Quiet@Solve[l == x*Cos[\[Theta]] - (p*x^2)/(6*c*d) (3 f + x) Sin[\[Theta]], x, Reals][];
b = a*Sin[\[Theta]] + (p*a^2)/(6*c*d) (3 f + a) Cos[\[Theta]] - h*Sin[\[Theta]] - (p*h^2)/(6*c*d) (3 f + h) Cos[\[Theta]];
Text[ h, b]
Show[{Graphics[{Opacity[0.5], Red, Rectangle[{j, 0}, {k, i}]},
PlotRange -> {{-1, 2}, {-3, 3}},
Axes -> True, AxesOrigin -> {0, 0}],
ParametricPlot[{x*Cos[\[Theta]] - (p*x^2)/(6*c*d) (3 f + x) Sin[\[Theta]],
x*Sin[\[Theta]] + (p*x^2)/(6*c*d) (3 f + x) Cos[\[Theta]] - h*Sin[\[Theta]] - (p*h^2)/(6*c*d) (3 f + h) Cos[\[Theta]] + i}, {x, 0, h}, Axes -> True]}],
{p, 0, 1, ControlType -> InputField}, {{c, 1}, 0, 10, ControlType -> InputField},
{{d, 1}, 0, 10, ControlType -> InputField}, {f, 0, 10, ControlType -> InputField},
{{\[Theta], 0}, -2 \[Pi], 2 \[Pi], ControlType -> InputField}, {{i, 1}, 0, 2, ControlType -> InputField},
{{j, 1}, 0, 2, ControlType -> InputField}, {{k, 2}, 0, 2, ControlType -> InputField},
{{l, 0}, , 0.2, 2, ControlType -> InputField}]