for i=3:k+1
T(i) = 2*t*T(i-1)-T(i-2);
c(i) = 2*int(subs(y,findsym(sym(y)),sym('t'))*T(i)/sqrt(1-t^2),t,-1,1)/2;
f = f + c(i)*T(i);
f = vpa(f,6);
if(i==k+1)
if(nargin == 3)
f = subs(f,'t',x0);
else
f = vpa(f,6);
end
end
end
调用时:
f = Chebyshev('1/(2-x)',6)
Warning: Explicit integral could not be found.
??? The following error occurred converting from sym to double:
Error using ==> mupadmex
Error in MuPAD command: DOUBLE cannot convert the input
expression into a double array.
If the input expression contains a symbolic variable, use the
VPA function instead.
Error in ==> Chebyshev at 7
c(1)=int(subs(y,findsym(sym(y)),sym('t'))*T(1)/sqrt(1-t^2),t,-1,1)/pi;