In the folder matlib/integration
[→]
there are several functions to perform numerical integration. In
particular, the function quad.o8av
attempts to deal with
integrable singularities and infinite limits (in Csharp (positive)
infinity is System.Double.PositiveInfinity
). The general call to this routine is like this,
Func<double,double> f = (x) => Log(x)/Sqrt(x); double a=0,b=1,result; result=quad.o8av(f,a,b); /* or */ result=quad.o8av(f,a,b,acc:1e-6,eps:1e-6);where
acc
and
eps
are the absolute and relative accuracy requirements.
The function is not optimized in any way other than to be as simple as possible for the students to understand its workings.
∫01 dx (ln(x)/√x) =-4,
∫-∞∞ dx (exp(-x²)) = √(π),
∫01 dx (ln(1/x))p = Γ(p+1),(calculate the last integral for several different values of the parameter p).
In the variational method in quantum mechanics one calculates the expectation value E[ψ] of a Hamiltonian H,
E[ψ] ≡ ⟨ψ|H|ψ⟩/⟨ψ|ψ⟩ ,
Consider the Hamiltonian operator for one-dimensional oscillator,
Hos = - (1/2) (d²/dx²) + (1/2) x² ,
ψα(x) = exp(-αx²/2) ,
E(α) ≡ ⟨ψα|Hos|ψα⟩/⟨ψα|ψα⟩ .
Hints:
The norm-integral, ⟨ψα|ψα⟩, has the form (check it)
⟨ψα|ψα⟩ = ∫-∞∞ exp(-αx²) dx .
The Hamiltonian-integral, ⟨ψα|Hos|ψα⟩, has the form (check it)
⟨ψα|Hos|ψα⟩ = ∫-∞∞ (-α²x²/2 + α/2 + x²/2)*exp(-αx²) dx .