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]

enter image description here

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.
  • 3
    $\begingroup$ Try to use 1/2 instead of 0.5 and apply FullSimplify after the integration. $\endgroup$ Jun 22 at 13:42
  • 1
    $\begingroup$ Please post the Mathematica code. $\endgroup$
    – cvgmt
    Jun 22 at 13:43
  • 2
    $\begingroup$ Hi @ShinsKarthikeyan, Welcome to Mathematica.SE, please consider taking the tour so you understand what is expected on this site and earn your first badge! Here it’s considered helpful to share your code in a well-formatted form instead of images or links to external files, so we can quickly Copy&Paste your code, test it, and see the problem you are facing. Please help us to help you and edit your question accordingly. This question in Meta could be useful. $\endgroup$
    – rhermans
    Jun 22 at 14:05

1 Answer 1


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)$$


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)$$

  • $\begingroup$ 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. $\endgroup$ Jun 22 at 16:54
  • 1
    $\begingroup$ You can accept the answer by clicking the check mark next to the answer. $\endgroup$
    – Syed
    Jun 22 at 16:59

Your Answer

Shins Karthikeyan is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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