5

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?

Karsten7
  • 27,448
  • 5
  • 73
  • 134
Mardymar
  • 219
  • 2
  • 5

3 Answers3

2
out = Reduce[{t*c == 50, t == 5}];
x = Cases[out, c == y_ :> y, -1][[1]]
10
Basheer Algohi
  • 19,917
  • 1
  • 31
  • 78
1

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}}

tortortor
  • 325
  • 1
  • 8
1

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]
Simon Rochester
  • 6,211
  • 1
  • 28
  • 40