Why do I get this error in my Taylor Expansion?

3 visualizaciones (últimos 30 días)
Nathan Ord
Nathan Ord el 23 de Mzo. de 2020
Editada: John D'Errico el 23 de Mzo. de 2020
I have this code below:
clearvars
% Define Symbols
syms x f(x)
% Define Function
f(x) = sqrt(sin(x))+2;
% Taylor Expansion f(x)
T = taylor(sqrt(sin(x))+2, x, 'ExpansionPoint', 0, 'Order', 6)
And I get this error
Why am I getting this error?

Respuestas (1)

John D'Errico
John D'Errico el 23 de Mzo. de 2020
Editada: John D'Errico el 23 de Mzo. de 2020
It might seem a subtle point. But what is the shape of sqrt(sin(x)), where x is near zero? (I'll just disregard the +2, since that is just a translation upwards.)
Why not plot it, if you are not positive?
symx x
fplot(sqrt(sin(x)) + 2,[0,1])
That should work. What do you see? Think about it.
If you are still unsure, what does sin(x) look like near x==0? In fact, sin(x) is very much like x. FOr small x, the two are very close. So we should expect, that for x near zero, that sqrt(sin(x)) looks a lot like sqrt(x).
Still not getting the idea? Can you build a Taylor series around a function that has a singularity at the expansion point? In fact, no. Do you see why not?
We could write that expansion as simply
f(x0) + f'(x0)/2*(x-x0) + ...
The problem arises at f'(x0), where x0 is the expansion point. That function has a singularity in the first derivative at x==0.
So taylor gets upset. What can you expect?
Suppose however, we decided to form an expansion around a different point? As long as there is no singularity, no problem.
T = taylor(sqrt(sin(x)) + 2, x, 'ExpansionPoint', 1, 'Order', 6)
T =
sin(1)^(1/2) + ((x - 1)^5*((5*cos(1)*(sin(1)^(3/2)/2 + cos(1)^2/(4*sin(1)^(1/2))))/(24*sin(1)) - (cos(1)*sin(1)^(1/2))/24 + (7*cos(1)*(sin(1)^(3/2)/24 + (5*cos(1)^2)/(48*sin(1)^(1/2)) - (5*cos(1)*((cos(1)*sin(1)^(1/2))/4 - (3*cos(1)*(sin(1)^(3/2)/2 + cos(1)^2/(4*sin(1)^(1/2))))/(4*sin(1))))/(6*sin(1))))/(8*sin(1))))/(5*sin(1)) + (cos(1)*(x - 1))/(2*sin(1)^(1/2)) - (((cos(1)*sin(1)^(1/2))/4 - (3*cos(1)*(sin(1)^(3/2)/2 + cos(1)^2/(4*sin(1)^(1/2))))/(4*sin(1)))*(x - 1)^3)/(3*sin(1)) - ((x - 1)^4*(sin(1)^(3/2)/24 + (5*cos(1)^2)/(48*sin(1)^(1/2)) - (5*cos(1)*((cos(1)*sin(1)^(1/2))/4 - (3*cos(1)*(sin(1)^(3/2)/2 + cos(1)^2/(4*sin(1)^(1/2))))/(4*sin(1))))/(6*sin(1))))/(4*sin(1)) - ((sin(1)^(3/2)/2 + cos(1)^2/(4*sin(1)^(1/2)))*(x - 1)^2)/(2*sin(1)) + 2
Now taylor has absolutely no problem, since everything is well defined around x==1.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by