0
|
5259 Views
|
4 Replies
|
2 Total Likes
View groups...
Share
GROUPS:

# Clearing fractions in an expression where an equality is asserted

Posted 9 years ago
 Hello It is quite elementary to transform by hand an expression like $\frac{m}{n}= \frac{p}{q}$ into $mq - n p = 0$ where $m, n, p, q$ can be much longer expressions and $p,q \ne 0$ However with Mathematica I find it far from easy. expr = m/n == p/q  Code instances such as below I do not like as it tells Mathematica exactly what to do Numerator[expr[]] Denominator[expr[]] - Numerator[expr[]] Denominator[expr[]] == 0 expr /.{ Equal[Times[a_,Power[b_,-1]],Times[c_,Power[d_,-1]]] :> Equal[Plus[Times[-1,a,b],Times[c,d]],0]  This is more promising: Map[Subtract[#, expr[]] &, expr] // Factor  But to get rid of the denominator in the answer I see no other way than to use a pattern transformation : % /. Equal[Times[Power[n_,-1],Power[q_,-1],Plus[Times[-1,n_,p_],Times[m_,q_]]],0] :> Equal[Plus[Times[-1,n,p],Times[m,q]],0]  What is the correct way to handle this simplification ?
4 Replies
Sort By:
Posted 9 years ago
 My approach is usually this: Numerator @ Together[equation /. Equal -> Subtract] == 0 
Posted 9 years ago
 Yes quite clever! It took me some time to understand that Together transfers the initial denominators to the new numerator.
Posted 9 years ago
 You could define your rules this way: In:= Clear["Global*"] In:= expr = m/n == p/q Out= m/n == p/q In:= % /. (x_/y_ == w_/z_) -> y z (x/y == w/z) Out= n q (m/n == p/q) In:= % /. (x_ (z_ == w_)) -> x z == x w Out= m q == n p In:= % /. x_ == y_ -> x - y == 0 Out= -n p + m q == 0 
Posted 9 years ago
 Thanks KayThis is OK for the case stritcly limited to m/n == p/q but m,n,p,q may represent much longer expressions. So unless I create four new variables, your solution does not work as in the example below : expr = (Cos[Pi/4] Power[3 x , (4)^-1])/x^3 == Log[var]/( x y z ) `One of the problem is that MMA will evaluate an expression unless held from it and a solution based on pattern matching to change any expression seems to me difficult to generalize.