Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have browsed the web and found no information. I have two rational polynomials $f1(x,y)$ and $f2(x,y)$. When I perform f1 + f2, I always get two separate functions. However, I would like to combine them into one rational expression. How do I do that?

share|improve this question

closed as off-topic by m_goldberg, Öskå, ubpdqn, Yves Klett, Mr.Wizard Jul 21 at 14:24

This question appears to be off-topic. The users who voted to close gave these specific reasons:

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – Mr.Wizard
  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, Öskå, ubpdqn, Yves Klett
If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Use Together. –  Szabolcs Jul 21 at 3:51
    
Googling for "mathematica combine rational" gives this page which shows this command. –  Szabolcs Jul 21 at 3:52

2 Answers 2

It's really simple. Just use Together.

f1 = 1/x; f2 = x/(x^2 - 1);

f1 + f2
1/x + x/(-1 + x^2)
Together[f1 + f2]
(-1 + 2 x^2)/(x (-1 + x^2))
share|improve this answer

Try this:

f1[x_, y_] = (x + y)^5;
f2[x_, y_] := (x - 3 y)^5

Simplify[Expand /@ (f1[x, y] + f2[x, y])]

(*  2 (x^5 - 5 x^4 y + 50 x^3 y^2 - 130 x^2 y^3 + 205 x y^4 - 121 y^5) *)
share|improve this answer

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