1
$\begingroup$

how is it possible to divide two equations with Mathematica?

I have the following code:

eqn416 = a == Kp h (1 - E^(-ta/tau))
eqn417 = a/2 == Kp h (1 - E^(-ta2/tau))

Obviously one will get

2 E^(-(ta2/tau)) - E^(-(ta/tau)) == 1

by dividing them, but with

Eliminate[{eqn416, eqn417}, {Kp, h, a}]

I only get 'True'.

And if I try just to eliminate 2 of them and assuming afterwards 'a' is not zero

Eliminate[{eqn416, eqn417}, {Kp, h}];
%[[2]]
FullSimplify[%, a != 0]

I'm not getting rid of 'a'!

FullSimplify[a (1 + E^(-(ta/tau)) - 2 E^(-(ta2/tau))) == 0, 
 a != 0]
(* Out[434]= a (1 + E^(-(ta/tau)) - 2 E^(-(ta2/tau))) == 0 *)

Any suggestions?

$\endgroup$
5
  • $\begingroup$ Documentation Center told me that "Eliminate works primarily with linear and polynomial equations", so probably it's not the best solution here. $\endgroup$
    – Wojciech
    Commented Jan 13, 2014 at 12:28
  • $\begingroup$ right, that's what I read too, but is there a better way? $\endgroup$
    – Phab
    Commented Jan 13, 2014 at 12:32
  • 1
    $\begingroup$ When You try to eliminate only Kp and h You get 3 equations. When You apply FullSimplify to them assuming that a!=0, one of the results is the one You want. I copied the code block with %[[2]] from Your question and the result was the one You wanted. $\endgroup$
    – Wojciech
    Commented Jan 13, 2014 at 12:42
  • $\begingroup$ This is closely related to Why the inequality does not take into account the domain?, which points out some inconsistencies of equation-solving functionality. Having said that I recommend Reduce in such cases. $\endgroup$
    – Artes
    Commented Jan 13, 2014 at 13:24
  • $\begingroup$ @Wojciech I had this solution too, but in my book the author takes the other ;) ... in addition, i'll get a different plot for those two solutions!? $\endgroup$
    – Phab
    Commented Jan 13, 2014 at 13:54

2 Answers 2

3
$\begingroup$

Try the following. Here are your equations:

 eqn416 = a == Kp h (1 - E^(-ta/tau));
eqn417 = a/2 == Kp h (1 - E^(-ta2/tau));

and this divides one over another:

eq1=Inner[Divide, eqn416, eqn417, Equal]

(* 2 == (1 - E^(-(ta/tau)))/(1 - E^(-(ta2/tau)))  *)

Another approach:

 eq2=Equal @@ MapThread[#1/#2 &, {List @@ eqn416, List @@ eqn417}]

(*   2 == (1 - E^(-(ta/tau)))/(1 - E^(-(ta2/tau)))   *)

Have fun.

A later edit to address your question below: yes, it is easy:

  eq1A = Map[Subtract[#, eq1[[1]]] &, eq1]

(* 0 == -2 + (1 - E^(-(ta/tau)))/(1 - E^(-(ta2/tau))) *)

if you mean something of this sort.

$\endgroup$
2
  • $\begingroup$ is there a possibility to enforce a zero on lhs or rhs of an equation? $\endgroup$
    – Phab
    Commented Jan 13, 2014 at 14:53
  • 1
    $\begingroup$ To enforce zero: HomogenizeEquation[eq_]:=eq[[1]]-eq[[2]]==0 $\endgroup$ Commented Jan 14, 2014 at 16:46
2
$\begingroup$

Another suggestion:

eqn416 = a == Kp h (1 - E^(-ta/tau));
eqn417 = a/2 == Kp h (1 - E^(-ta2/tau));

DivideEquations[eq1_,eq2_]:=eq1[[1]]/eq2[[1]]==eq1[[2]]/eq2[[2]]

DivideEquations[eqn416,eqn417]

(* 2 == (1 - E^(-(ta/tau)))/(1 - E^(-(ta2/tau))) *)

Whenever you need to divide two equations then just call the DivideEquations function.

$\endgroup$
1
  • $\begingroup$ That's a good solution, more simple than the previous one. $\endgroup$ Commented Jan 15, 2014 at 8:28

Your Answer

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

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