The difference between the results of int function and numerical solution
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Erdal Cokmez
el 26 de Ag. de 2022
Comentada: Matt J
el 27 de Ag. de 2022
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 comentarios
Torsten
el 26 de Ag. de 2022
Editada: Torsten
el 26 de Ag. de 2022
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
el 26 de Ag. de 2022
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.
Respuesta aceptada
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!