#infinite square well solution:
# Watch out for this:
# https://ask.sagemath.org/question/33181/assume-that-n-is-positive-integer/
var('n L')
assume(n>0)
assume(n,'integer')
assume(L>0)
f(x)=sqrt(2/L)*sin(pi*n*x/L)
show(f(x))
ex_x =integrate(f(x)*x*f(x),x,0,L)
show("< x >=",ex_x.full_simplify())
ex_xsquared=integrate(f(x)*x*x*f(x),x,0,L)
show("< x^2 >=",ex_xsquared.full_simplify())
sigma_x=sqrt(ex_xsquared-ex_x^2)
show("sigma_x = ",sigma_x.full_simplify())
var('hbar')
assume(hbar>0)
ex_p = I*hbar*integrate(f(x)*diff(f(x),x),x,0,L)
show("< p >=",ex_p.full_simplify())
ex_psqrd = -hbar^2*integrate(f(x)*diff(f(x),x,2),x,0,L)
show("< p^2 >=",ex_psqrd.full_simplify())
sigma_p = sqrt(ex_psqrd-ex_p^2)
show("sigma_p = ",sigma_p.full_simplify())
product = sigma_p*sigma_x
show("sigma_x*sigma_p=",product.full_simplify())
Simplifying this by hand, the $L$'s cancel, we're left with: $$\Delta_x\Delta_p=\sqrt{\frac{\pi^2n^2}{12}-\frac 12}\ \hbar$$ The lowest possible product is for $n=1$, and in this case we have... $$\Delta_x\Delta_p=\sqrt{\frac{\pi^2}{12}-\frac 12}\ \hbar$$
N(sqrt(pi^2/12 -1/2))
0.567861808386612
The bottom line is that the minimum product of uncertainties is: $$\Delta_x\Delta_p=0.569\hbar,$$ and this just barely satisfies the Heisenberg uncertainty principle that: $$\Delta_x\Delta_p\geq \frac12\hbar.$$