4

Suppose there is an equation like this (overly simplified example):

eqn1 = ui - ua r1 / (r1 + r2) == 0

How can I get Mathematica to "solve" the equation in terms of:

eqn2 = v == ua / ui

i.e. have Mathematica deliver v == 1 + r2 / r1 as a result? Despite googling I cannot find the proper way (tried equation system, Eliminate, LinearSolve, ...). Thanks in advance - Rob

Carl Woll
  • 130,679
  • 6
  • 243
  • 355

2 Answers2

5

You can combine Solve with Eliminate:

Solve[
    Eliminate[{ui-ua r1/(r1+r2)==0,v==ua/ui}, ua],
    v
]

{{v -> (r1 + r2)/r1}}

Carl Woll
  • 130,679
  • 6
  • 243
  • 355
5

Although not currently documented, you can include in Solve a list of variables to be eliminated.

Solve[{ui - ua r1/(r1 + r2) == 0, v == ua/ui}, v, {ua}][[1]] // Expand

(* {v -> 1 + r2/r1} *)
Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198
  • Thx, this works indeed - though I'm confused as the Language Reference designates Solve's 3rd parameter as "domain", e.g. Integers, Reals, Complexes - it never occured to me that "domain" could also be used for variable elimination. I guess not many folks are aware of this context - so kudos to you for pointing this out. I'd appreciate if you kindly comment on this "[ [1] ]" construct - what is it's meaning ? – Robert GID S. May 29 '19 at 23:56
  • @RobertGIDS. - As I stated, the use of a list of variable to be eliminated is not documented. It was a long time ago and presumably still functions to maintain backward compatibility. Consequently, the third argument here is not being used to specify a domain. The [[1]] takes the first element of a list (see Part). In this case it removes an extra set of list brackets. – Bob Hanlon May 30 '19 at 00:06