Collecting denominators together with Mathematica

  • Context: Mathematica 
  • Thread starter Thread starter anthony2005
  • Start date Start date
  • Tags Tags
    Mathematica
Click For Summary

Discussion Overview

The discussion revolves around the manipulation of rational functions in Mathematica, specifically focusing on how to combine fractions with different denominators into a simplified form. Participants explore methods to achieve this without resorting to a single common denominator, which can be computationally intensive for large expressions.

Discussion Character

  • Technical explanation
  • Mathematical reasoning

Main Points Raised

  • One participant presents a problem involving a long sum of rational functions and seeks a method to group terms by their denominators.
  • Another participant provides a solution using Mathematica's functions, specifically suggesting the use of Plus@@Map[Together[Select[f,Function[x, Denominator[x]==#]]]&,Union[Map[ Denominator,List@@f]]] to achieve the desired grouping.
  • A third participant expresses satisfaction with the solution and indicates a desire to understand the underlying mechanics of the provided method.
  • A fourth participant shares an alternative approach using Collect to format the expression, noting that while their method works, the mapping technique is more robust.

Areas of Agreement / Disagreement

Participants generally agree on the effectiveness of the provided solution, but there are multiple approaches discussed, indicating a lack of consensus on the best method.

Contextual Notes

Some participants express caution regarding the robustness of the solutions, suggesting that certain inputs may lead to unexpected results.

anthony2005
Messages
24
Reaction score
0
Hi all,
I have a very simple issue, but can't get round of it.

I have a long sum of rational functions, which is in the form for example

\frac{n_{1}}{d_{1}}+\frac{n_{2}}{d_{1}}+\frac{n_{3}}{d_{1}}+\frac{n_{4}}{d_{1}}+\frac{n_{5}}{d_{2}}+\frac{n_{6}}{d_{2}}+\frac{n_{7}}{d_{1}\cdot d_{2}}+\frac{n_{8}}{d_{1}\cdot d_{2}}+\frac{n_{9}}{d_{1}\cdot d_{2}}

and I would like to put it in the form

\frac{n_{1}+n_{2}+n_{3}+n_{4}}{d_{1}}+\frac{n_{5}+n_{6}}{d_{2}}+\frac{n_{7}+n_{8}+n_{9}}{d_{1}\cdot d_{2}}

If I use Factor or Simplify it would just put all over one single denominator d_{1}\cdot d_{2}, taking also so much time since my expression is huge.

Any help?
Thanks
 
Physics news on Phys.org
Figuring out how and why this works will be an educational experience.

In[1]:= f=n1/d1+n2/d1+n3/d1+n4/d1+n5/d2+n6/d2+n7/(d1 d2)+n8/(d1 d2)+n9/(d1 d2);

In[2]:= Plus@@Map[Together[Select[f,Function[x, Denominator[x]==#]]]&,Union[Map[ Denominator,List@@f]]]

Out[2]= (n1 + n2 + n3 + n4)/d1 + (n5 + n6)/d2 + (n7 + n8 + n9)/(d1*d2)

Be careful with that, just in case some oddball input breaks it.
 
Wow, it worked. Miracles are hidden in mathematica, but I'll figure out why it worked.
Thanks a lot.
 
I always find ways to use Collect and get it to look right myself.

Collect[f /. {1/(d1*d2) -> 1/d1d2}, {d1, d2, d1d2}] /. d1d2 -> d1 d2

but the way above with mapping is much better and more robust.
 

Similar threads

Replies
0
Views
2K
Replies
6
Views
1K
Replies
1
Views
2K
Replies
3
Views
3K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 21 ·
Replies
21
Views
1K
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K