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?
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
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}}
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]
x = c /. ToRules @ Reduce[...]– wxffles Sep 09 '14 at 21:00