Why does symbolic integration return the wrong answer for this integral?

13 views (last 30 days)
Hello! I'm trying to integrate 1/(1-x)^2 with the bounds 0 to x.
Now, other sources (Like WolframAlpha) return the result as -x/(x-1). However, MATLAB returns inf.
Can anyone explain why this would be?
syms x
expr = 1/(1-x)^2
int(expr, 0, x)
ans =
Inf

Accepted Answer

Walter Roberson
Walter Roberson on 23 Feb 2021
syms x a
expr = 1/(1-x)^2
expr = 
F = int(expr, x, 0, a)
F = 
subs(F,a,x)
ans = 
  2 Comments
Gareth Fuller
Gareth Fuller on 23 Feb 2021
That works- All I've got to do to get the desired result is some shuffling around of terms.
I'm curious as to why the Subs step is needed, and why it can't get the piecewise function with int(expr,0,x).
Thanks for providing a solution- that certainly helped me out.
Have a wonderful day!
Walter Roberson
Walter Roberson on 23 Feb 2021
I am not sure. My expectation was that I would be able to control the output by adding in an assume() or tossing in an 'IgnoreAnalyticConstraints' option, but those did not work.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!