psi(r):=exp(-r)/sqrt(%pi);

A(x):=(1-exp(-2*x)*(1+x))/x;

B(x):=exp(-x)*(1+x);

S(x):=(x^2+3*x+3)*exp(-x)/3;

wxplot2d([A(x),B(x),S(x)], [x,0,200], [y,-0.1,1.1],
 [plot_format, gnuplot])$

H11(x):=-13.6*(1-2/x+2*A(x));

H12(x):=-13.6*((1-2/x)*S(x)+2*B(x));

Emas(x):=(H11(x)+H12(x))/(1+S(x));

Emenos(x):=(H11(x)-H12(x))/(1-S(x));

wxplot2d([Emas(x)], [x,0,5], [y,0,-16]);

wxplot2d([Emas(x)], [x,0,5], [y,-16,0]);

wxplot2d([Emenos(x)], [x,0,5], [y,-16,0]);

wxplot2d([Emenos(x)], [x,0,200], [y,-16,0]);

wxplot2d([Emenos(x)], [x,0,20], [y,-16,0]);

Cmas(x):=(Emas(x)-H11(x))/(H12(x)-Emas(x)*S(x));

Cmenos(x):=(Emenos(x)-H11(x))/(H12(x)-Emenos(x)*S(x));

lambda1mas(x):=1/(sqrt(1+Cmas(x)^2+2*Cmas(x)*S(x)));

lambda1menos(x):=1/(sqrt(1+Cmenos(x)^2+2*Cmenos(x)*S(x)));

lambda2mas(x):=Cmas(x)/(sqrt(1+Cmas(x)^2+2*Cmas(x)*S(x)));

lambda2menos(x):=Cmenos(x)/(sqrt(1+Cmenos(x)^2+2*Cmenos(x)*S(x)));

ang(y,z):= if (y>0 and z>0) then atan(z/y) elseif (y<0 and z>0) then %pi-atan(abs(z/y))
  elseif (y<0 and z<0) then %pi+atan(abs(z/y)) elseif (y>0 and z<0) then 2*%pi-atan(abs(z/y))
  else 0;

psimaspol(x,r,th):=lambda1mas(x)*psi(r)+lambda2mas(x)*psi(sqrt(r^2+x^2-2*x*r*cos(th)));

psimenospol(x,r,th):=lambda1menos(x)*psi(r)+lambda2menos(x)*psi(sqrt(r^2+x^2-2*x*r*cos(th)));

psimas(x,y,z):=psimaspol(x,sqrt(y^2+z^2),ang(y,z));

psimenos(x,y,z):=psimenospol(x,sqrt(y^2+z^2),ang(y,z));

plot3d(abs(psimas(2.5,y,z))^2, [y,-1.5,4.5], [z,-2,2], [plot_format,gnuplot],
 [grid,49,49],
 [gnuplot_pm3d,true],
 [gnuplot_preamble, "set terminal wxt"])$

plot3d(abs(psimas(2.5,y,z))^2, [y,-1.5,4.5], [z,-2,2],[grid,49,49],
 [gnuplot_pm3d,true],
 [gnuplot_preamble, "set terminal wxt; set pm3d map; unset surf;
  set palette defined ( 0 'green', 1 'blue', 2 'red', 3 'orange' ) "])$

plot3d(abs(psimas(2.5,y,z))^2, [y,-1.5,4.5], [z,-2,2],[grid,49,49],
 [gnuplot_pm3d,true],
 [gnuplot_preamble, "set terminal wxt; set pm3d map; unset surf;
  set palette model XYZ rgbformulae 7,5,15 "])$

plot3d(abs(psimenos(2.5,y,z))^2, [y,-1.5,4.5], [z,-2,2],[grid,49,49],
 [gnuplot_pm3d,true],
 [gnuplot_preamble, "set terminal wxt; set pm3d map; unset surf;
  set palette model XYZ rgbformulae 7,5,15 "])$