Search code examples
symbolic-mathmaximawxmaxima

How would I find the numerical integral of this expression with maxima quad_qags


With maxima, im not able to figure out how to do this numerical integral:

quad_qags( -psi0(x, beta)*diff(psi0(x,beta), x,2 )/2 + V(x)*psi0(x,beta)**2, x, -inf,inf);

it gives back the noun form, is there a way to do this? maple gives back an answer of -0.60.... This is the context of the problem, which comes from the variational problem in QM, starting from a gaussian function psi0, and computing the energy:

V(x):= -1/sqrt(1+x**2) ;
psi0(x, beta):= (sqrt(beta)*%e^(-((beta^2*x^2)/2)))/%pi^(1/4);
Energy(beta):= integrate(-psi0(x, beta)*diff(psi0(x,beta), x,2 )/2 + V(x)*psi0(x,beta)**2, x,-inf,inf); 

This is not possible to do analytically, i think, so i tried the same with quad_qags.

EDIT Here is where i have reached with beta=1, and expand():

quad_qagi (  expand( %o28) , x, -inf, inf, 'epsrel=1d-8);
(%o35)  quad_qagi(-(integrate(psi0(x,1)*('diff(psi0(x,1),x,2))+(2*psi0(x,1)^2)/sqrt(x^2+1),x,-inf,inf)/2),x,-inf,inf,epsrel=1.0*10^-8,epsabs=0.0,limit=200)

Solution

  • Here's what I get after fixing the call to quad_qagi and working around the problem with -inf by replacing it with minf.

    (%i2) V(x):= -1/sqrt(1+x**2) ;
                                      - 1
    (%o2)                 V(x) := ------------
                                            2
                                  sqrt(1 + x )
    (%i3) psi0(x, beta):= (sqrt(beta)*%e^(-((beta^2*x^2)/2)))/%pi^(1/4);
                                                    2  2
                                                beta  x
                                              - --------
                                                   2
                                 sqrt(beta) %e
    (%o3)       psi0(x, beta) := -----------------------
                                            1/4
                                         %pi
    (%i4) Energy(beta):= quad_qagi (-psi0(x, beta)*diff(psi0(x,beta), x,2 )/2 + V(x)*psi0(x,beta)**2, x, minf, inf);
    (%o4) Energy(beta) := 
              - psi0(x, beta) diff(psi0(x, beta), x, 2)
    quad_qagi(-----------------------------------------
                                  2
                2
     + V(x) psi0 (x, beta), x, minf, inf)
    (%i5) Energy(1);
    (%o5) [- 0.6098866396410092, 4.3393502531511445e-9, 270, 0]
    

    which matches your previous result.