5
$\begingroup$

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?

$\endgroup$
1
  • 6
    $\begingroup$ x = c /. ToRules @ Reduce[...] $\endgroup$
    – wxffles
    Sep 9, 2014 at 21:00

3 Answers 3

2
$\begingroup$
out = Reduce[{t*c == 50, t == 5}];
x = Cases[out, c == y_ :> y, -1][[1]]
10
$\endgroup$
1
$\begingroup$

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]
$\endgroup$
1
$\begingroup$

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}}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.