Taylor serie limitation??

Dear all I am blocked with a taylor serie. Sorry the code is not very nice, but to summarized it, all the parameter ngas, A, B ...depend of lam. Together they creat BETA, wich depends on lam too. I need to found the taylor serie of BETA, but I have this warning : "Warning: Cannot compute a Taylor expansion of : " I acn found the Taylor serie of ngas, or A, or k_0 etc but not BETA...et I need to finish with taylorBETA=taylor(taylorBETA,lam,'ExpansionPoint', 1030e-9); If someone have an idea...? Thanks
clc,
clf
clear all
close all
format long
n_g = 1.45 ; % clad index
c=300000000;
n=1e-6;
E=1e-9;
%%%%%%%%%%%%%%%%%%TO BE CHANGED%%%%%%%%%%%%%%%%
r=30;
T=840 ;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a=2.405*2.405; %coef pour les ordres de bessel
t=T*E;
rc=r*n;
dc=2*rc;
int=0.0001;
L_start=800 ;
L_stop= 1300 ;
x1=L_start * E;
x2=L_stop * E;
xx=(L_stop-L_start)/int;
lambda = (x1 : 5e-9 : x2)';
%syms variable
%subs (f,variable,ordre)
pgas = 150;
pgas=pgas *1e5;
pgas= pgas/101325;
syms lam
syms lamm
ngas= 1 + pgas.* ( (3.22869e-3 ./ (46.301-(lam.*1000).^-2) ) + (3.55393e-3 ./ (59.578-(lam.*1000).^-2) ) + (6.06764e-2 ./ (112.74-(lam.*1000).^-2) )); %XENON
k_0= 2*3.14./(lam);
phi = k_0.*t.* sqrt(n_g.^2-ngas.^2) ;
epsi= n_g.^2 ./ ngas.^2;
A=a./( 2.*ngas .*(k_0.*rc).^2);
B=a./ ( ngas(i,j).^2 .*(k_0(i,j).*rc).^3 );
C = epsi;
D = 0.5 .* (C+1) ./ sqrt(C-1);
neff2= ngas - A - B.*D.*cot(phi);
BETA= (ngas - A - B.*D.*cot(phi)).*k_0;
taylorBETA=taylor(BETA,lam,'ExpansionPoint', 1030e-9);

9 Comments

Torsten
Torsten on 25 Apr 2018
Edited: Torsten on 25 Apr 2018
k_0(i,j) and ngas(i,j) do not exist.
k_0 and ngas are created and are function of lam. I need to keep them in fonction of lam to be able to creat the Taylor serie of BETA.
Only k_0 and ngas are defined, but not k_0(i,j) and ngas(i,j).
Oh, I see, sorry, i=1 and j=1 are not usefull, I forget to remove them. They dond't play a role here
i and j were explicitly set to 1 for both of them. k_0 and ngas are scalars. The indexing is superfluous, but not a killer here.
The
syms lamm
seems superfluous, since lamm never appears.
Right, My problem is that Matlab can't found the taylor serie of BETA, the function of lam, which is composed by otehr funtion of lam. I am thinking that there is too much lam in BETA, and Matlab is not able to solve this. I was thinking of ading an other "variable", lamm, to replace lam in ngas by lamm. And then creats BETA(lam,lamm). But it was not working too. I forget to remove lamm
I don't think the problem is too much lam, as much as too highly nonlinear to ever have a chance off being convergent, no matter what.
We can find the first few coefficients of that Taylor series easily enough.
vpa(subs(BETA,lam,1.03e-6))
ans =
6096502.4190565957838395137805456
vpa(subs(diff(BETA,lam,1),lam,1.03e-6))
ans =
-5920135585248.8976060067604718056
vpa(subs(diff(BETA,lam,2),lam,1.03e-6))
ans =
11494640687453888043.683950132235
vpa(subs(diff(BETA,lam,3),lam,1.03e-6))
ans =
-33489337894938749515340200.941387
So those are the first 4 coefficients of (lam-1.03e-6)^n/factorial(n) in the Taylor series, starting from the zero'th order term.
At the same time, if we plot BETA in that vicinity, it seems to be huge, but at least smooth. Look carefully, because the y axis is multiplied by 1e10.
ezplot(BETA,[2e-7,2e-6])
grid on
So, around powers of (lam-1.03e-6)^n, here are the first few coefficients in that series:
vpa(subs(BETA,lam,1.03e-6))
ans =
6096502.4190565957838395137805456
for n = 1:5
vpa(subs(diff(BETA,lam,n),lam,1.03e-6)/factorial(n))
end
ans =
-5920135585248.8976060067604718056
ans =
5747320343726944021.8419750661176
ans =
-5581556315823124919223366.8235646
ans =
5429269510660844571193986936400.4
ans =
-5.3413066400589435608804519200757e36
Can you say non-convergent? It does not seem so. My guess is that a Taylor series is a waste of time. I suppose if you stay within a very tiny radius of convergence, it might be convergent.
Thanks for that answer, I will read it carefully later. I will discuss it with my collegue. On on the point to take care, is that each coeff from the taylor serie will determine a physical parameter used in the second parto of the code. But this first solution seem nice. THANKS
Note that
lim (x->0+) cot(x) = Inf.
Best wishes
Torsten.

Sign in to comment.

Answers (1)

John D'Errico
John D'Errico on 25 Apr 2018
Edited: John D'Errico on 25 Apr 2018
To make this into an answer, I'll compute the first few terms of a series, expanded around lam = 1.03e-6. n=8 is as far as I bothered to go, and that took a few minutes to get an answer on my computer.
C(1) = vpa(subs(BETA,lam,1.03e-6));
for n = 1:8,
C(n+1) = vpa(subs(diff(BETA,lam,n),lam,1.03e-6)/factorial(n));
end
C
C =
[ 6096502.4190565957838395137805456, -5920135585248.8976060067604718056, 5747320343726944021.8419750661176, -5581556315823124919223366.8235646, 5429269510660844571193986936400.4, -5.3413066400589435608804519200757e36, 5.6571437723662232853187257751051e42, -8.6696749577345104686166441304681e48, 2.981901322970591677439778972521e55]
So the Taylor series will be a polynomial in powers of (lam-1.03e-6)
C(1) + C(2)*(lam - 1.03e-6) + ...
with the general n'th term being:
C(n+1)*(lam - 1.03e-6)^(n)
MATLAB was bogging down for me to go past about the 6th terms or so, so I stopped it there.
As long as lam stays in the very near vicinity of 1.03e-6, this should be acceptably convergent. For example, if I plot that polynomial on top of BETA itself, we will see:
Cpol = flip(double(C));
ezplot(BETA,[2e-7,2e-6])
hold on
grid on
ezplot(@(x) polyval(Cpol,x - 1.03e-6),[2e-7,2e-6])
The green curve is the polynomial series, the blue is BETA. As you can see, even for small deviations from the expansion point, the series has insufficient terms to be convergent. But if you stay within a VERY small radius of convergence, the two curves do overlay reasonably well.

Asked:

on 25 Apr 2018

Edited:

on 25 Apr 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!