# Using solution of an equation [duplicate]

I want to solve something like f(x)=0 and then have the real solution be set as the value of another variable. I can't figure out how to do it. I tried something like this as an example, but it didn't work.

a = Solve[x + 1 == 0, x, Reals]


added: Why won't my InputField dynamically update?

InputField[ Dynamic[G = x /. Solve[ 2 == x*Cos[\[Theta]] -(P*x^2)/(6*C*D) (3 F + x) Sin[\[Theta]], x, Reals]]]


second add: here's the rest of my code.

    Manipulate[
DynamicModule[{P = 0, C = 1, D = 1, F = 0, θ = 0},
Deploy[Style[
Panel[Grid[Transpose[{{"P", "C", "D", "F", "θ", "G"},
{InputField[Dynamic[P]], InputField[Dynamic[C]],
InputField[Dynamic[D]], InputField[Dynamic[F]],
InputField[Dynamic[θ]],
InputField[
Dynamic[
G = x /.
Solve[2 ==
x*Cos[θ] - (P*x^2)/(
6*C*D) (3 F + x) Sin[θ], x, Reals][[1]]]]}}],
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[θ] - (P*x^2)/(
6*C*D) (3 F + x) Sin[θ],
x*Sin[θ] + (P*x^2)/(6*C*D) (3 F + x) Cos[θ] +
G*Sin[θ] + (P*G^2)/(6*C*D) (3 F + G) Cos[θ] -
2}, {x, 0, B}, Axes -> True]}]]]]

• This appears to be a duplicate of (1819) or (6669) Jul 8 '16 at 1:53

a = x /. Solve[x + 1 == 0, x, Reals][[1]]

The [[1]] selects the first solution, and the x /. applies the solution to the expression x.
• I don't know which variables are symbolic and which are numerical, but the Solve is very slow. Also, don't use capital variables. I run: g = x /. Solve[ 2 == xCos[[Theta]] - (px^2)/(6*c*d) (3 f + x) Sin[[Theta]], x, Reals][[1]] InputField[Dynamic[g]] and this displays a result. If I set values for p, c, d, f, and theta, it gives numerics correctly. Jul 8 '16 at 2:24