Say I have the following input:
Reduce[{t*c==50, t==5}]
the output:
t == 5. && c == 10.
Is there a way to create a variable x
that gets assigned the value of c
from the output without actually having to type x = 10
?
out = Reduce[{t*c == 50, t == 5}];
x = Cases[out, c == y_ :> y, -1][[1]]
10
With
eqs = {t*c == 50, t == 5};
then
x = Refine[c, Reduce[eqs]]
or (wxffles' comment)
x = c /. ToRules@Reduce[eqs]
or
x = c /. First@Solve[eqs]
From the documentation to Solve
(just ran into it):
Solve
with Method->"Reduce"
uses Reduce
to find solutions, but returns replacement rules:
Solve[{t*c == 50, t == 5}, {t, c}, Method -> Reduce]
{{t -> 5, c -> 10}}
x = c /. ToRules @ Reduce[...]
$\endgroup$