MATLAB: Taylor series expansion for acos(1-x)

Symbolic Math Toolboxtaylor acos

MatLab gave error messages for taylor(acos(1-x),x) (after syms x) while the expansion does exist?

Best Answer

Actually, the expansion you ask for does NOT exist. Why not? Because. I hope that is a good enough answer.. ;-)
Seriously, the expansion fails, because at x==0, there is a singularity, so you cannot write a Taylor series. Think about it. What is the first derivative of acos(1-x), evaluated at x==0?
fprime = diff(acos(1-x),x)
fprime =
1/(1 - (x - 1)^2)^(1/2)
>> subs(fprime,x,0)
Error using symengine
Division by zero.
Error in sym/subs>mupadsubs (line 160)
G = mupadmex('symobj::fullsubs',F.s,X2,Y2);
Error in sym/subs (line 145)
G = mupadsubs(F,X,Y);
So can you write a Taylor series, expanded around x==0? NO! NO! NO!
But does that mean no expansion exists? A Tsaylor series expansion DOES exist, as long as you use an expansion point where the function is not singular. The default expansion point for the function Taylor is at x==0. So, in one line, we can get a series expansion as you seem to want, as long as you override the default for the expansion point.
taylor(acos(1-x),x,'expansionpoint',0.5)
ans =
pi/3 + (2*3^(1/2)*(x - 1/2))/3 - (2*3^(1/2)*(x - 1/2)^2)/9 + (8*3^(1/2)*(x - 1/2)^3)/27 - (28*3^(1/2)*(x - 1/2)^4)/81 + (608*3^(1/2)*(x - 1/2)^5)/1215
Will the Taylor series give anything meaningful, if you then tried to use it at x==0? NO! It won't work well, not in trying to predict the value at x==0. But that just reflects the idea that trying to predict the value of a function with an infinite slope at the prediction point using a polynomial approximation is likely to be a really bad idea.
Not all functions are well approximated by Taylor series. (You might want to re-read your class notes about convergence of a series.)
Related Question