# How can I simplify the output after integration which is obtained in terms of hypergeometric function in Mathematica?

When I did the integration of the following function, I got the answer in terms of hypergeometric function. But when I did the same integration in MATLAB, a simplified form of expression is coming as the answer (Please see the attached images).

How can I simplify the output from Mathematica?

r1 = ((x^2) + (R - y)^2)^(0.5);
r2 = ((x^2) + (R + y)^2)^(0.5);
P = ((R - y) x^2/r1^4);
U = Integrate[P, x]


New contributor
Shins Karthikeyan is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
• Try to use 1/2 instead of 0.5 and apply FullSimplify after the integration. Jun 22 at 13:42
• Please post the Mathematica code. Jun 22 at 13:43

Use exact rational powers.

r1 = ((x^2) + (R - y)^2)^(1/2);
r2 = ((x^2) + (R + y)^2)^(1/2);
P = ((R - y) x^2/r1^4);
U = Integrate[P, x]


$$(R-y) \left(\frac{\tan ^{-1}\left(\frac{x}{R-y}\right)}{2 (R-y)}-\frac{x}{2 \left(R^2-2 R y+x^2+y^2\right)}\right)$$

EDIT

Or use Rationalize later.

r1 = ((x^2) + (R - y)^2)^0.5;
r2 = ((x^2) + (R + y)^2)^0.5;
P = ((R - y) x^2/r1^4);
U = Integrate[P, x] // Rationalize // FullSimplify


$$\frac{1}{2} \left(\frac{x (y-R)}{(R-y)^2+x^2}+\tan ^{-1}\left(\frac{x}{R-y}\right)\right)$$

• The problem is solved now. Thank you so much for the responses. Thank you @rhermans for your suggestion. I will do the needful when I post something next time. Jun 22 at 16:54
• You can accept the answer by clicking the check mark next to the answer.
– Syed
Jun 22 at 16:59