Group Abstract Group Abstract

Message Boards Message Boards

0
|
50 Views
|
7 Replies
|
2 Total Likes
View groups...
Share
Share this post:
GROUPS:

How to divide numerator and denominator by the numerator?

Posted 1 day ago

How to divide numerator and denominator by the numerator?

in = -((8 m^2)/(3 + 10 m^2 + 3 m^4))
Numerator[in]
in /. a_/b_ -> a/Numerator[in]/(b/Numerator[in])

enter image description here

Why is there no change in the result when using the code above?

I aim to derive this expression in fractional form via identical transformation:

-(1/(5/4 + 3/(8 m^2) + (3 m^2)/8))

enter image description here

POSTED BY: Bill Blair
7 Replies
POSTED BY: Michael Rogers
Posted 1 day ago

I think it's equivalent to dividing by 1, which Mathematica simplifies:

(n/n)/(d/n) -> 1/(d/n) -> n/d

POSTED BY: David Keith
Posted 42 minutes ago

Thank you for the excellent solution, Michael! Your 1/Expand[1/frac] approach is really elegant. I have a follow-up question: I modified your step-by-step method to divide both numerator and denominator by the parameter part of the numerator (excluding the sign and coefficient), and I came up with the following code:

sgn = Simplify[
  Sign[frac], (var = Variables[Numerator@frac][[1]]) \[Element] 
    Reals && var != 0](*wrestle Mma over the sign*)
Sign@(Cases[Numerator[frac] , _?NumericQ, Infinity][[1]])
fac = sgn/((Numerator[
       frac]/((Sign@(Cases[Numerator[frac] , _?NumericQ, 
             Infinity][[1]]))*(Cases[Numerator[frac] , _?NumericQ, 
           Infinity][[1]]))) // 
    Expand)(*construct factor for multiplying*)
newnd = fac*NumeratorDenominator[frac]; (*mult.num.& den.by fac*)
newnd = Expand /@ newnd; (*un-factor the product(s)*)
Divide @@ (newnd // Expand )(*construct new fraction*)

It works, but the code feels quite verbose and the nesting is a bit hard to follow. I was wondering if there's a more concise or optimized way to achieve the same result.

POSTED BY: Bill Blair
Posted 55 minutes ago

Thank you for the detailed explanation! The 1/Expand[1/frac] approach is elegant and exactly what I needed. I wasn't aware that Mathematica would auto-simplify (a b)/(a c) to b/c, which explains why my direct approach failed.

POSTED BY: Updating Name

A couple of ways:

in = -((8 m^2)/(3 + 10 m^2 + 3 m^4));
in /. a_/b_ :>
  -DisplayForm[FractionBox[a/Numerator[in],
     Expand[-b/Numerator[in]]]]
in /. a_/b_ :>
  -Inactive[Divide][a/Numerator[in],
    -Expand[b/Numerator[in]]]
POSTED BY: Gianluca Gorni
Posted 21 hours ago
POSTED BY: Bill Blair

This is one way to do it, but we must strip the formatting away if we need to reuse the result in further calculations:

in = -((8 m^2)/(3 + 10 m^2 + 3 m^4))
Numerator[in]
newForm = 
 in /. a_/b_ -> 
   DisplayForm[FractionBox[a/Numerator[in], (b/Numerator[in])]]
3*newForm
3*newForm /. {FractionBox -> Divide, 
   DisplayForm -> Identity} // Expand
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard