Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to do integrals like the one shown here (please see question body)?

Hi.

I am a newcomer to Sage. I am trying to do integrals of the form shown below. This is from an introductory course in quantum mechanics.

$ \psi(x, t) = \int_{-\infty}^{+\infty} f(p) \psi_p(x - x_0, t) d\mathrm{p} $

where,

$ \psi_p(x, t) = \dfrac{1}{\sqrt{2\pi\hbar}}e^\left( -\dfrac{i}{\hbar}\left(\dfrac{p^2}{2m}t - px \right)\right) $

$ f(p) = \dfrac{1}{(2\pi)^{1/4} \sqrt{\sigma_p}}e^\left( -\dfrac{(p - p_0)^2}{4{\sigma_p}^2}\right) $

I have tried the following in sage thus far:

forget()
var('x,t,p,p_0, m,h,x_0,sigma_p')

psi_p(x, t) = 1/(2*pi*h)^(1/2)*exp(-i/h*(p^2*t/(2*m) - p*(x - x_0)))
f(p) = 1/(2*pi)^(1/4)*1/sqrt(sigma_p)*exp(-(p - p_0)^2/(4*sigma_p^2))

show(psi_p(x, t))
show(f(p))

assume(m, 'constant')
assume(m > 0)
assume(h, 'constant')
assume(h > 0)
assume(p_0, 'constant')
assume(p_0 > 0)
assume(sigma_p, 'constant')
assume(sigma_p > 0)
assume(x, 'real')
assume(t, 'real')

from sage.symbolic.integration.integral import definite_integral
definite_integral(f(p)*psi_p(x, t), p, -oo, +oo)

Sage keeps complaining about requiring assumptions that I can't easily provide. Here is a sample output:

ValueError: Computation failed since Maxima requested additional constraints; using the 'assume' command before evaluation *may* help (example of legal syntax is 'assume(2*sigma_p^2*t
>0)', see `assume?` for more details)
Is 2*sigma_p^2*t
    *sin(atan((2*sigma_p^2*t)/(h*m))
          /2)
    +h*m
                *cos(atan((2*sigma_p^2*t)
                           /(h*m))
                      /2) positive, negative or zero?

My question: how would you do integrals like this in Sage? Is my fundamental approach correct?

How to do integrals like the one shown here (please see question body)?

Hi.

I am a newcomer to Sage. I am trying to do integrals of the form shown below. This is from an introductory course in quantum mechanics.

$ \psi(x, t) = \int_{-\infty}^{+\infty} f(p) \psi_p(x - x_0, t) d\mathrm{p} $

where,

$ \psi_p(x, t) = \dfrac{1}{\sqrt{2\pi\hbar}}e^\left( -\dfrac{i}{\hbar}\left(\dfrac{p^2}{2m}t - px \right)\right) $

$ f(p) = \dfrac{1}{(2\pi)^{1/4} \sqrt{\sigma_p}}e^\left( -\dfrac{(p - p_0)^2}{4{\sigma_p}^2}\right) $

I have tried the following in sage thus far:

forget()
var('x,t,p,p_0, m,h,x_0,sigma_p')

psi_p(x, t) = 1/(2*pi*h)^(1/2)*exp(-i/h*(p^2*t/(2*m) - p*(x - x_0)))
f(p) = 1/(2*pi)^(1/4)*1/sqrt(sigma_p)*exp(-(p - p_0)^2/(4*sigma_p^2))

show(psi_p(x, t))
show(f(p))

assume(m, 'constant')
assume(m > 0)
assume(h, 'constant')
assume(h > 0)
assume(p_0, 'constant')
assume(p_0 > 0)
assume(sigma_p, 'constant')
assume(sigma_p > 0)
assume(x, 'real')
assume(t, 'real')

from sage.symbolic.integration.integral import definite_integral
definite_integral(f(p)*psi_p(x, t), p, -oo, +oo)

Sage keeps complaining about requiring assumptions that I can't easily provide. Here is a sample output:

ValueError: Computation failed since Maxima requested additional constraints; using the 'assume' command before evaluation *may* help (example of legal syntax is 'assume(2*sigma_p^2*t
>0)', see `assume?` for more details)
Is 2*sigma_p^2*t
    *sin(atan((2*sigma_p^2*t)/(h*m))
          /2)
    +h*m
                *cos(atan((2*sigma_p^2*t)
                           /(h*m))
                      /2) positive, negative or zero?

My question: how would you do integrals like this in Sage? Is my fundamental approach correct?