calcul of Taylor approximation+ sum using syms
3 次查看(过去 30 天)
显示 更早的评论
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??
Thank you in advance!
Adam
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 using mupadmex
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)
tSym = mupadmex('symobj::taylor',f.s,x.s,a.s,options);
Error in reflexiontotale2 (line 19)
t1=taylor(R,kx,kx0,'Order', 1)
0 个评论
采纳的回答
Walter Oevel
2012-8-2
Hi Adam,
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
0 个评论
更多回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!