Time Complexity of Double Integration

1 view (last 30 days)
I'm trying to run the following code as
clc
%--------Define Constants all are in MKS-------%
q=1.602e-19;
h=8.85e-12;
Eox=3.9*h;
Esi=11.8*h;
Ni=1.1e16;
Na=1e16;
Vgs=0.4;
L=36e-9;
tox=3e-9;
tsi=10e-9;
Vds=1;
Q=-q*Na;
V=Vgs;
t1=0.02586;%thermal voltage in V%
Vbi=0.56;%source side potential%
phi=0;
d1=0;
syms x y;
for n=1:1:20
kn=n*pi/L;
X1=((cosh(kn*(tox+tsi-y)))+(cosh(kn*(tox-y))))/(sinh(kn*tsi));
d2=L*(V*(1-(-1)^n))/((cosh(kn*tox))*pi*n);
d4=1/(kn*Esi*tanh(kn*tsi))+1/(kn*Esi*sinh(kn*tsi))+tanh(kn*tox)/(kn*Eox) ;
d3=Vbi*(1-(- 1)^n)/kn+(Vds*(-1)^(n+1))/kn+Q*(1-(-1)^n)/(Esi*kn*kn*kn);;
for m=1:1:10
k1=(2*m-1)*pi/(2*tox);
A1=V/k1+(sin(k1*tox)*(Vbi-Vgs))/(tox*k1^2);
A2=(V)/k1+(sin(k1*tox)*(Vbi+Vds-Vgs))/(tox*k1^2);
d1=d1+(2*(sin(k1*(tox)))*kn*(A1+A2*((-1)^(n+1)))/(tox*(kn^2+k1^2)));
end
Dsf=((d1+d2-d3))/d4;
phi=phi+2*((sin(kn*x))*X1*Dsf)/(kn*Esi*L);
d1=0;
end
phi1=phi+Vbi+(x/L)*Vds+(Q*(x*L-(power(x,2))))/(2*Esi);
integration=double(int(1/(int(exp((phi1)/t1),y,tox,tox+tsi)),x,0,L));
but this is taking too much time to simulate as n goes higher for n=10 it will take some minutes after that time increases so much here also I tried to analyze the terms in Dsf which have d1,d2 d3,d4 a file attached as constants2.pdf I hope this will help. this shows the how different terms converges w.r.t n and m
what I observed that m=10 would be enough but for n I have doubt
If this is possible then kindly tell how much minimum n requires? for get a good answer my meaning is answer should not be change at least one place after decimal for example for n=10 if answer is 1.56e-8 then for n=20 if answer is 1.5e-8 then this is okay
if any other way possible to evaluate the integration then that would be great which take less time and answer is also correct currently I'm using Matlab-2015 version
  1 Comment
Walter Roberson
Walter Roberson on 29 Sep 2017
There is no general way to define the time complexity of integration to a given precision. It is necessary to use theoretical analysis of the function behaviour.
Consider for example the sum from n = 1 to infinity of 1/n . Clearly once n exceeds 2^53, 1/n is less than 2^(-53) and adding 2^(-53) cannot affect a floating point number whose value is at least 1 (because there are only 53 effective bits of precision for floating point numbers.) One could then guess that sum from n = 1 to infinity of 1/n should, to floating point precision, be the same as sum from n = 1 to 2^53 of 1/n. But that is not true. The sum to 2^53 is a finite number, but the sum to infinity of 1/n is infinity. All those "negligible" 1/n values turn out to add up to infinity under theoretical analysis: see https://en.wikipedia.org/wiki/Harmonic_series_(mathematics)

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 29 Sep 2017
Unless you need a symbolic integral, the Symbolic Math Toolbox is not the preferred method. I would do the integration using the integral function twice, since you integrate ‘1/’ the result of the first integration.
Substitute your current ‘integration’ assignment with these three lines:
phi1_fcn = matlabFunction(phi1);
int_y = @(x) 1./integral(@(y) exp(phi1_fcn(x,y)./t1), tox,tox+tsi, 'Array',true);
integration = integral(int_y, 0,L)
This first creates anonymous function ‘phi1_fcn’ from ‘phi1’, then uses two calls to the integral function to integrate it. Using tic,toc, this takes a bit less that 700 milliseconds on my laptop. I get the same result for both my numeric integration and the symbolic integration.
  2 Comments
NILESH PANDEY
NILESH PANDEY on 30 Sep 2017
Thanks a lot Sir, It's really saves so much time now I get the integration in few seconds thanks again for saving my time

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!