# How to force Mathematica to give answer in certain functional form?

I want Mathematica to evaluate $$0=\psi (x) \left(\frac{k x^2}{2}-\text{En}\right)-\frac{\hbar ^2 \psi ''(x)}{2 m}$$ and give me answer in terms of the Hermite polynomials but it gives me result in terms of some crazy functions called Parabolic Cylindrical functions. Is there a way to force mathematica to give results using Hermite Polynomial and Hypergeometric function?

It turns out mathematica used to give results in these Hermite polynomials and Hypergeometric functions in some earlier versions.

My question is, can I ask Mathematica to give the solution in terms of function I want?

Codes I used:

eq1 = 0 == (V - En) \[Psi][x] - ((\[HBar]^2) \[Psi]''[x] )/(2 m) /.
V -> (k x^2)/2

DSolve[eq1, {\[Psi][x]}, {x}]


The result I got:

 {{\[Psi][x] ->
C[2] ParabolicCylinderD[(-2 En Sqrt[m] - Sqrt[k] \[HBar])/(
2 Sqrt[k] \[HBar]), (I Sqrt[2] k^(1/4) m^(1/4) x)/
Sqrt[\[HBar]]] +
C[1] ParabolicCylinderD[(2 En Sqrt[m] - Sqrt[k] \[HBar])/(
2 Sqrt[k] \[HBar]), (Sqrt[2] k^(1/4) m^(1/4) x)/Sqrt[\[HBar]]]}}


In a printed book I have (which was in some earlier version), they get:

diffyq = y''[x] + (\[Nu] + 1/2 - 1/4 x^2) y[x];
DSolve[diffyq == 0, y[x], x] // FullSimplify
{{y[x] ->
E^(-(x^2/
4)) (C[1] HermiteH[\[Nu], x/Sqrt[2]] +
C[2] Hypergeometric1F1[-(\[Nu]/2), 1/2, x^2/2])}}


If I run the same code in my version I get:

{{y[x] ->
C[2] ParabolicCylinderD[-1 - \[Nu], I x] +
C[1] ParabolicCylinderD[\[Nu], x]}}


Now, I want Mathematica to give me results in terms of Hermite polynomials and not these crazy functions.

• Please provide the code used and the solution obtained. – bbgodfrey Oct 17 '19 at 3:36
• @bbgodfrey thanks for reminding that, I just added the code used. – Pradip Kattel Oct 17 '19 at 3:51
• You are solving the 1D harmonic oscillator problem. Notice that you do not specify the boundary conditions (BC). Therefore, MA gives a generic solution that depends on 2 constants and valid for any value of energy. In reality, for physically correct BC the solution is only possible for certain energy values (En) --discrete spectrum. – yarchik Oct 17 '19 at 20:10

eqn = ψ[x] (k x^2/2 - En) - ℏ^2 ψ''[x]/(2 m) == 0;

sol = DSolve[eqn, ψ, x][[1]]

(* {ψ ->
Function[{x},
C[2] ParabolicCylinderD[(-2 En Sqrt[m] - Sqrt[k] ℏ)/(
2 Sqrt[k] ℏ), (I Sqrt[2] k^(1/4) m^(1/4) x)/Sqrt[ℏ]] +
C[1] ParabolicCylinderD[(2 En Sqrt[m] - Sqrt[k] ℏ)/(
2 Sqrt[k] ℏ), (Sqrt[2] k^(1/4) m^(1/4) x)/Sqrt[ℏ]]]} *)


Verifying the solution,

eqn /. sol // FullSimplify

(* True *)


Use FunctionExpand to convert from ParabolicCylinderD to HermiteH

ψ[x] /. sol // FunctionExpand // Simplify

(* 2^(1/4 - (En Sqrt[m])/(2 Sqrt[k] ℏ)) E^(-((Sqrt[k] Sqrt[m] x^2)/(
2 ℏ))) (2^((En Sqrt[m])/(Sqrt[k] ℏ)) E^((
Sqrt[k] Sqrt[m] x^2)/ℏ) C[
2] HermiteH[-(1/2) - (En Sqrt[m])/(Sqrt[k] ℏ), (
I k^(1/4) m^(1/4) x)/Sqrt[ℏ]] +
C[1] HermiteH[-(1/2) + (En Sqrt[m])/(Sqrt[k] ℏ), (k^(1/4) m^(1/4) x)/
Sqrt[ℏ]]) *)