Wrong start of the curve in double integral

2 views (last 30 days)
Hi! I solve the double integral and it shows a right behavior of the curve, but it starts from different points at different parameters. But it should always start from the point (0,1). What is wrong?
n = 0.1 ;
t = 1;
r = 1;
s = 0:0.01:1;
b=sqrt(2*t)/r;
fun = @(x,z,k) exp(-2.*n.*t.*x.^2).*exp(-z.^2).*(erf(((z+x.*k./r)./(2.*b)))+erf(((z-x.*k./r)./(2.*b)))-z./(sqrt(pi).*b).*(exp(-((z+x.*k./r)./(2.*b)).^2)+exp(-((z-x.*k./r)./(2.*b)).^2)));
f3 = arrayfun(@(k)integral2(@(x,z)fun(x,z,k),0,Inf,0,1),s);
Cor = ((sqrt(2*n*t))/(erf(sqrt(2*n*t))*(atan(1/(2*b))-(b/(2*(b^2+0.25))))))*f3;
plot(s,Cor,'b-')

Accepted Answer

C B
C B on 29 Jan 2023
n = 0.1 ;
t = 1;
r = 1;
s = 0:0.01:1;
b=sqrt(2*t)/r;
fun = @(x,z,k) exp(-2.*n.*t.*x.^2).*exp(-z.^2).*(erf(((z+x.*k./r)./(2.*b)))+erf(((z-x.*k./r)./(2.*b)))-z./(sqrt(pi).*b).*(exp(-((z+x.*k./r)./(2.*b)).^2)+exp(-((z-x.*k./r)./(2.*b)).^2)));
f3 = arrayfun(@(k)integral2(@(x,z)fun(x,z,k),0,Inf,0,1),s);
Cor = ((sqrt(2*n*t))/(erf(sqrt(2*n*t))*(atan(1/(2*b))-(b/(2*(b^2+0.25))))))*f3;
plot(s,Cor,'b-')
n = 0.1 ;
t = 1;
r = 1;
s = 0:0.01:1;
b=sqrt(2*t)/r;
fun = @(x,z,k) exp(-2.*n.*t.*x.^2).*exp(-z.^2).*(erf(((z+x.*k./r)./(2.*b)))+erf(((z-x.*k./r)./(2.*b)))-z./(sqrt(pi).*b).*(exp(-((z+x.*k./r)./(2.*b)).^2)+exp(-((z-x.*k./r)./(2.*b)).^2)));
f3 = arrayfun(@(k)integral2(@(x,z)fun(x,z,k),0,1,0,1),s);
Cor = ((sqrt(2*n*t))/(erf(sqrt(2*n*t))*(atan(1/(2*b))-(b/(2*(b^2+0.25))))))*f3;
Cor = Cor + (1 - Cor(1));
plot(s,Cor,'b-')
  1 Comment
Hexe
Hexe on 29 Jan 2023
Dear Chetan Bhavsar!
Thank you very much. Now it works as it should.
Sincerely
Olha.

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!