The difference between the results of int function and numerical solution

1 次查看(过去 30 天)
Hi,
I have a problem with the integral of a function in symbolic matlab. The function is:
t = -(a*(b*c -(b^3*c^3/6)) + c*(1 - b^2*c^2/2))/(c^m*sin(m*pi/2));
And the symbolic MATLAB gives the integral of the function as:
f = int(t,c) = (c^2*(6*m + 6*b^2*c^2 - 24*a*b + 2*g*b^3*c^2 - 3*m*b^2*c^2 + 6*a*m*b - a*m*b^3*c^2 - 24))/(6*c^m*sin((pi*m)/2)*(m^2 - 6*m + 8))
The problem is that, for a definite integral, for example; the solution of:
int(t,c,x,y) and the numerical solution f(y)-f(x) does not match.
Anyone have any idea for this problem?
  6 个评论
Torsten
Torsten 2022-8-26
编辑:Torsten 2022-8-26
b and c are very far away from 0. You would have to include many more terms in the Taylor expansion to approximate f1 good enough for the integrals of f1 and f2 to approach each other. I suggest you use the numerical "integral" function to integrate matlabFunction(f1) - it's fast and precise.
John D'Errico
John D'Errico 2022-8-26
But a Taylor expansion is ONLY an approximation, and one that often is not even convergent. So why could you possibly be surprised if the results are different from A Taylor expansion?
For example, feel free to evaluate sin(20*pi) using a Taylor expansion in double precision arithmetic. You won't be able to do so, because the number of terms you would need before it converges will be too large, and then you will find massive subtractive cancellation kills any accuracy you would see anyway.
What is worse, you have stuff in the denominator. So that means you have essential singularities in your function. And Taylor series are notoriously poor when used to approximate singular functions, since a truncated Taylor series is just a polynomial. And polynomials have NO singularities in them.

请先登录,再进行评论。

采纳的回答

Torsten
Torsten 2022-8-26
移动:Matt J 2022-8-27

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by