# calcul of Taylor approximation+ sum using syms

14 views (last 30 days)
Here below my program. I would like to calculate the taylor approximation of R near kx0. and woul like to calculate the sum of sigma power n.
It works well but for order more than3 doesn't work . Furthermore, for some values of theta doesn't work and displays the error you find here.( for a value of theta + 1.58, it dosn't displays this error).
Any one has an idea??
clear all;
lambda=3E-6;
k1=2*pi/lambda;
n=3.42;
theta=((asin(1/n))*180)/pi;
w0=10E-3;
k2=k1/n;
q=1;
syms kx sigma u
kx0=k1*sin(theta);
sigma=-(kx-k1.*sin(theta))./(k1.*cos(theta));
R=((k1^2-kx^2)^(1/2)-q*(k2^2-kx^2)^(1/2))/((k1^2-kx^2)^(1/2)+q*(k2^2-kx^2)^(1/2))% Reflectance R
syms kx sigma u clear
t1=taylor(R,kx,kx0,'Order', 1)
p=symsum(sigma^u, u, 0, 0)
Bn=t1./p
vall=subs(R,kx0)
val1=subs(t1,kx0)
val2=subs(p,kx0)
val3=subs(Bn,kx0)
val4=val1/val2
Error in MuPAD command: Cannot compute a Taylor expansion of -((1536119361583697/4096 - kx^2)^(1/2) -
(8983533250413779/2048 - kx^2)^(1/2))/((1536119361583697/4096 - kx^2)^(1/2) + (8983533250413779/2048 - kx^2)^(1/2)).
Try 'series' for a more general expansion. [taylor]
Error in sym/taylor (line 142)
Error in reflexiontotale2 (line 19)
t1=taylor(R,kx,kx0,'Order', 1)

Walter Oevel on 2 Aug 2012
this is about the error 'Cannot compute a Taylor expansion ...':
Note that you need to make sure that the expansion point kx0 for kx is small enough to ensure that the arguments of the square roots are positive for kx in a neighbourhood of the expansion point. Otherwise, you are trying to compute a Taylor expansion on the branch cut of the sqrt function (where no Taylor expansion exists). Since the system assumes that you work in the complex plane, the error is raised.
The underlying computer algebra has an option 'Real' to compute Taylor and generalized expansions that only hold along the real line. However, you would need to address MuPAD, directly.
Regards,
Walter Oevel