How to fit with an infinite serie function ?
Show older comments
Hi all,
i am trying fit a complicated function involving an infinite sum. It looks like,

where M(t)/Meq is 'y', t is x. the variables are D and L, which are coefficient and thickness respectively. Is there anyway to do this in matlab?
I tried to write a script, but unfortunately it doesnot work for me.
% FID fitting procedure
plot(Time,Mass,'bs','markersize',6); hold on; %PLOT_1
xlabel('Time (m)','interpreter','latex','Fontsize',18); hold on;
ylabel ('Mt/Minf','interpreter','latex','Fontsize',18);hold on;
%Given parameters
coefficient = 0; coeff_lowerlimit = 0; coeff_upperlimit = 50;
thickness = 100; thickness_lower = 0; thickness_upper = 2000;
numIteration = 100;
d1 = coefficient;
d2 = thickness;
x1 = Time; %assign x experimental data
y1 = Mass; %assign y experimental data
%syms n
%f1 = 8/((2*n+1)^2*pi^2)*exp((-a1*x*(2*n+1)^2*pi^2./(4*a2^2));
%f2 = symsum(f1,n,1,inf);
syms n
data1 = 8/((2*n+1)^2*pi^2)*exp(-d1*x1*(2*n+1)^2*pi^2./(4*d2^2));
data2 = symsum (data1,n,1,inf);
%plot(TimeBase(START1:END1), data1,'r','LineWidth',3.0); hold on; %PLOT_2
d1l = coeff_lowerlimit+0.000001;
d1u = coeff_upperlimit+0.000001;
d2l = thickness_lower+0.000001;
d2u = thickness_upper+0.000001;
lb1 = [d1l d2l]; %lower limit for parameters matrix
ub1 = [d1u d2u]; %upper limit for parameters matrix
d01 = [d1 d2]; %initialise parameters matrix
options = optimset('Display', 'iter', 'TolFun',1e-25, 'TolX', 1e-25, 'MaxFunEvals', 1e10, 'MaxIter', numIteration);
[asym, resnorm, residual] = lsqcurvefit(@igsorp2,d01,x1,y1,lb1,ub1,options); %fitting procedure
display (asym);
d1sym = asym(1); d2sym = asym(2); %best fit parameters matrix
syms n
data1sym = 8/((2*n+1)^2*pi^2)*exp(-d1sym*x1*(2*n+1)^2*pi^2./(4*d2sym^2));
data2sym = symsum (data1sym,n,1,inf);
plot(time, data2sym,'r','LineWidth',3.0); hold on; %PLOT_3
coefficient = d1sym; %recalculate the parameters here
thickness = d2sym;
display (coefficient);
display (thickness);
Discrepancy1 = sqrt(sum(residual.*residual));
display (Discrepancy1);
Many thanks for your help!!!
Accepted Answer
More Answers (1)
Antonio Aguilera Miguel
on 24 Sep 2015
Edited: Antonio Aguilera Miguel
on 24 Sep 2015
0 votes
Hi Roger,
Thanks a lot for your answer to Eric. It is really useful for me but I am not able to find the same equality. I would be really grateful if you could correct me or tell me what is wrong!!
Turning back the integral from 0 to s of (1/(2*u))*log((1+u)/(1-u)) with respect u, and using an online integrator, the integral you proposed is equivalent to:
(1/2)*[-Li_2(-u)+Li_2(u)+ log(u)*(log((1-u)/(u+1))+log((u+1)/(1-u)))] being Li_2 Jonquière's functions.
Developing the down part, I got that log(u)*(log((1-u)/(u+1))+log((u+1)/(1-u))=0 so that means that the integral you proposed would result only (1/2)*[-Li_2(-u)+Li_2(u)].
Bearing in mind that Li_n(z)=sum(from k=0 to infinite)of (z^k)/(k^n); what it the definition of a Jonquière's function, I can develop these two terms in series and I got that:
[-Li_2(-u)+Li_2(u)]= 2*[u/1+(u^3)/(9)+(u^5)/(25)+(u^7)/(49)+....
So at the end, once I have applied the integral limits I got that the infinite sum would be in this way:
s/1+(s^3)/(9)+(s^5)/(25)+...
It still lacks me the numerator to elevate to the second power???
Could you or someone help me with this issue? I would be really grateful. Thanks you guys Wish you a very good day Antonio
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!