Another Taylor series question



On 05/14/2013 12:52 PM, Alasdair McAndrew wrote:
> OK, I've got maxima 5.30.0 up and running.  Nice.  What I want to do is
> define a function
>
> t(x) = f(a) + f'(a)(x-a) + f''(a)(x-a)^2/2 + f'''(a)(x-a)^3/6 + ...
>
> that is, a Taylor series, but so that t(b), for example, produces
>
> f(a) + f'(a)(b-a) + f''(a)(b-a)^2/2 + f'''(a)(b-a)^3/6 + ...
>
> with the derivatives still in terms of x.  This is what happens at the
> moment:
>
> (%i1) t(x):=taylor(f(x),x,a,6);
>
> (%i2) t(b);
>
> and the derivatives now are all in terms of b.  Any ideas?  (I'd still like
> to be able to differentiate and integrate t(x) in terms of x).
>
What about the following?

(%i1) display2d : false;

(%o1) false
(%i2) t(a,w,deg):=f(a)+sum(('at('diff(f(x),x,k),x = a))*(w-a)^k/k!,k,1,deg);

(%o2) t(a,w,deg):=f(a)+sum(('at('diff(f(x),x,k),x = a))*(w-a)^k/k!,k,1,deg)
(%i3) t(a,x,3);

(%o3) (x-a)^3*('at('diff(f(x),x,3),x = 
a))/6+(x-a)^2*('at('diff(f(x),x,2),x = 
a))/2+(x-a)*('at('diff(f(x),x,1),x = a))+f(a)
(%i4) t(a,b,3);

(%o4) (b-a)^3*('at('diff(f(x),x,3),x = 
a))/6+(b-a)^2*('at('diff(f(x),x,2),x = 
a))/2+(b-a)*('at('diff(f(x),x,1),x = a))+f(a)

Andre