1

Well, I need a way to solve equations by another var got from other equation in Mathematica 8. Example:

a + b = 2c
c + 2 = d
d = 2b

It will chose the best equation for the given values and solve the rest. With some given values, like a = 1 and c = 3, it solves the system, getting the values for the respective variable. *Will use this for physics' formulas.

Nakilon
  • 34,866
  • 14
  • 107
  • 142
Odinfall
  • 11
  • 3

1 Answers1

1

Use the Solve or Reduce functions. The syntax is

Solve[{LIST OF EQUATIONS}, {Variables to solve for}]

So in this case:

Solve[{a + b == 2 c, c + 2 == d, d == 2 b}, {a, b, c, d}]
(*->
{{a -> -4 + (3 d)/2, b -> d/2, c -> -2 + d}}
*)

There are 4 variables and only 3 equations, so there are infinite solutions.
They lie on the 4-d line (-4 + (3 n)/2, n/2, n-2, n).

Dr. belisarius
  • 60,527
  • 15
  • 115
  • 190
Philip
  • 11
  • 1
  • Thanks, but when I put the Equation List in a Module or Block, it can´t solve the system. – Odinfall Jun 18 '12 at 22:03
  • @Odinfall could you explain what you mean by that? I'm not sure if I follow. – rcollyer Jun 19 '12 at 03:46
  • Running Solve or Reduce inside a module should work. For example: `solver[eqList_, varList_] := Module[{}, Reduce[eqList, varList]];` `solver[{a + b == 2 c, c + 2 == d, d == 2 b}, {a, b, c, d}]` This exact code, although it works, is pointless because it is simply wrapping Reduce. However, if you need the results of reduce in a module (as it sounds like), you could use this set-up and add more things to the module. (In particular, you'd likely want to capture the output of the Reduce call in new variables.) – Matthew Adams Jun 19 '12 at 18:21