Find the integral of ;

2 views (last 30 days)
Newton
Newton on 23 Oct 2023
Commented: Walter Roberson on 25 Oct 2023
(X^2-29x+5)÷{(x-4)(x^2+3)}
  2 Comments
Dyuman Joshi
Dyuman Joshi on 23 Oct 2023
Never thought I'd see a day when someone named Newton would ask a calculus question, which is unrelated to the forum on which the question is asked.
Walter Roberson
Walter Roberson on 23 Oct 2023
The integral over what range? The symbolic integral has 3 distinct ranges (two discontinuities) and getting the phase right can be difficult.

Sign in to comment.

Answers (1)

Sam Chak
Sam Chak on 23 Oct 2023
Hello Sir @Newton
I feel honored to have the opportunity to solve this integral problem for you in the modern computational era.
% Plotting the rational function
x1 = -30:0.00001:4;
x2 = 4:0.00001:30;
f = @(x) (x.^2 - 29*x + 5)./((x - 4).*(x.^2 + 3));
plot(x1, f(x1), 'color', '#0d6ea3'), hold on
plot(x2, f(x2), 'color', '#0d6ea3'), ylim([-10 10])
xline(4, '-.r', 'x = 4'), grid on
xlabel('x'), ylabel('f(x)')
% defining the expression
syms x real
expr = (x^2 - 29*x + 5)/((x - 4)*(x^2 + 3))
expr = 
% performing partial fraction decomposition
expr = partfrac(expr, x)
expr = 
% finding the indefinite integral
F = int(expr)
F = 
  4 Comments
David Goodmanson
David Goodmanson on 25 Oct 2023
Actually the integral can be found even if the bounds cross 4, assuming the principal value is taken. From both Walter's result and SC's partial fraction expresson it's clear that the only part of the integrand that involves crossing 4 is
-5/(x-4)
whose itegral is
-5* [ log(UB-4) -log(LB-4) ]
If LB and UB are on opposite sides of 4, then the principal value is
-5* lim{eps-->0) [ Int{LB, 4-eps} 1/(x-4) dx + Int{4+eps, UB} 1/(x-4) dx ]
with the only consequence being that absolute values appear in the log terms:
-5* [ (log(abs(UB-4)) -log(abs(LB-4)) ]
If the principal value is always implied, the expression just above works no matter where UB, LB are. Same side, opposite sides, both positive, both negative, doesn't matter.
Walter Roberson
Walter Roberson on 25 Oct 2023
Testing to see what int() can do.
I find it interesting that taking the integral and substituting in bounds, gets a different representation of the result than if you take the integral supplying the bounds -- different enough that all my tests with rewrite() and simplify() were not able to get val2s - val4s to collapse to 0.
syms x LB UB real
assumeAlso(LB <= UB)
expr = (x^2 - 29*x + 5)/((x - 4)*(x^2 + 3))
expr = 
assumeAlso(LB < 4)
assumeAlso(4 < UB)
val1 = int(expr, x, LB, UB, 'PrincipalValue', false)
val1 = 
NaN
val2 = int(expr, x, LB, UB, 'PrincipalValue', true)
val2 = 
val2s = simplify(subs(val2, [LB, UB], [3 5]), 'steps', 10)
val2s = 
val3 = int(expr, x, 3, 5, 'PrincipalValue', false)
val3 = 
NaN
val4 = int(expr, x, 3, 5, 'PrincipalValue', true)
val4 = 
val4s = simplify(val4, 'steps', 10)
val4s = 
val2s - val4s
ans = 
simplify(ans, 'steps', 25)
ans = 
vpa(ans)
ans = 
3.6734198463196484624023016788195e-40

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!