3
$\begingroup$

I wrote the following code:

Solve[{x == VIN/VOUT, VOUT == 5 VIN}, {x}]

Mathematica does not solve it. How can I get the result x=1/5?

Thank you so much for your willingness.

$\endgroup$
4
  • $\begingroup$ what if VIN = 0? or VOUT=0? $\endgroup$
    – Nasser
    Commented Jul 26, 2018 at 9:58
  • $\begingroup$ Hello @Nasser, maybe Mathematica assumes VIN and VOUT as non zero constant by default....but this must to be verify. $\endgroup$ Commented Jul 26, 2018 at 14:24
  • 1
    $\begingroup$ @Nasser - "Solve gives generic solutions only. Solutions that are valid only when continuous parameters satisfy equations are removed. Other solutions that are only conditionally valid are expressed as ConditionalExpression objects." $\endgroup$
    – Bob Hanlon
    Commented Jul 26, 2018 at 15:45
  • 1
    $\begingroup$ Another hack: Solve[Eliminate[{x == VIN/VOUT, VOUT == 5 VIN}, {VOUT}], {x}] giving {{x -> 1/5}} $\endgroup$
    – user1066
    Commented Jul 29, 2018 at 22:09

2 Answers 2

7
$\begingroup$
Solve[{x == VIN/VOUT, VOUT == 5 VIN}, {x, VOUT}]
(*{{x -> 1/5, VOUT -> 5 VIN}}*)
$\endgroup$
6
  • $\begingroup$ Hello @UlrichNeumann, your solution is very useful. Thanks. $\endgroup$ Commented Jul 26, 2018 at 9:44
  • 1
    $\begingroup$ In recent versions, you can also just use Solve[{x == VIN/VOUT, VOUT == 5 VIN}] $\endgroup$
    – Mark S.
    Commented Jul 26, 2018 at 12:17
  • $\begingroup$ ... also Solve[{x == VIN/VOUT, VOUT == 5 VIN}, {x}, MaxExtraConditions -> 1] $\endgroup$ Commented Jul 26, 2018 at 14:24
  • 2
    $\begingroup$ Or Solve[{x == VIN/VOUT, VOUT == 5 VIN}, x, {VOUT}] $\endgroup$
    – Bob Hanlon
    Commented Jul 26, 2018 at 15:38
  • 1
    $\begingroup$ @rhermans - This syntax was documented in earlier versions but the documentation stopped mentioning it. However, it appears to be kept for backward compatibility. The variables to be eliminated must be in list brackets, e.g., {VOUT}. If you were to enter just VOUT then Mma would first try to interpreted it as a domain resulting in the warning: Solve::bdomv: Warning: VOUT is not a valid domain specification. Assuming it is a variable to eliminate. and then give the correct output. $\endgroup$
    – Bob Hanlon
    Commented Jul 30, 2018 at 20:55
1
$\begingroup$
Reduce[
 {
  x == VIN/VOUT,
  VOUT == 5 VIN
  }, {x}
 ]
(* VIN == VOUT/5 && x == 1/5 && VOUT != 0 *)

Solve@Reduce[
  {
   x == VIN/VOUT,
   VOUT == 5 VIN
   }, {x}
  ]
(* {{VOUT -> 5 VIN, x -> 1/5}} *)
$\endgroup$

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