Solutions to Differential Equations: Special Functions

Visualizing a few special functions

Bessel's equation

Bessel's equation is a second-order ODE having the following form, with the parameter ν being real and nonnegative.

In[148]:=

BesselODE = x 2 y '' [ x ] + x y ' [ x ] + ( x 2 - ν 2 ) y [ x ] 0

Out[148]=

( x 2 - ν 2 ) y [ x ] + x y [ x ] + x 2 y ′′ [ x ] 0

Bessel's equation arises in problems in heat conduction and mass diffusion for problems with cylindrical symmetry (and many other situations). It's solution is a linear combination of two special functions called Bessel functions of the first kind, BesselJ in Mathematica, and Bessel functions of the second kind, BesselY in Mathematica.

In[149]:=

DSolve [ BesselODE , y [ x ] , x ]

Out[149]=

{ { y [ x ] BesselJ [ ν , x ] C [ 1 ] + BesselY [ ν , x ] C [ 2 ] } }

The functions BesselJ and BesselY can be evaluated numerically and of course Mathematica has this capability built-in.

In[150]:=

MyPlotStyle [ HowMany_Integer ] := Table [ { Hue [ 0.66 * i / HowMany ] , Thickness [ 0.01 ] } , { i , 0 , HowMany } ]

In[151]:=

Plot [ { BesselJ [ 0 , x ] , BesselY [ 0 , x ] } , { x , 0 , 20 } , PlotStyle MyPlotStyle [ 2 ] ]

[Graphics:HTMLFiles/index_1.gif]

Out[151]=

Graphics

In[152]:=

Plot [ { BesselJ [ 5 , x ] , BesselY [ 5 , x ] } , { x , 0 , 20 } , PlotStyle MyPlotStyle [ 2 ] ]

[Graphics:HTMLFiles/index_2.gif]

Out[152]=

Graphics

In[153]:=

Plot [ { BesselJ [ 1 / 2 , x ] , BesselY [ 1 / 2 , x ] } , { x , 0 , 20 } , PlotStyle MyPlotStyle [ 2 ] ]

[Graphics:HTMLFiles/index_3.gif]

Out[153]=

Graphics

As an example of an application where the Bessel functions arise, consider radially-symmetric heat flow in an infinitely long cylinder of radius a that has an initial temperature profile T =T(r) and a surface temperature T(r = a) = T r ,and  substitute T= - κα 2 t τ into the heat equation T t 2 T in cylindrical coordinates. The function τ must obey d 2 τ r 2 + 1 r dr + α 2 τ= 0, which has the form of Bessel's equation of order ν = zero. The solution will have the form T= A J 0 (αr) - κα 2 t where A is a constant and J 0 (αr)is the Bessel function of order zero of the first kind. The parameter α must, from boundary conditions, be a solution to the equation J(αa) = 0. The initial temperature distribution, f(r), can be expanded as a series of Bessel functions of zero order, analogous to what we did with Fourier series. The general solution to the heat-flow problem will then be an infinite series of Bessel functions, each modified by an exponentially decaying amplitude, taking the form T= n = 1 A n J 0 ( α n r) - κα n 2 t .  For a more thorough discussion, see H.S. Carslaw and J.C. Jaeger, Conduction of Heat in Solids, Oxford University Press, Second Edition, pp. 194–196 (1959).

Legendre's equation

Legendre's equation is a second-order ODE having the following form, with the parameters m and n being integers such that n is positive and -n m n (seems to suggest applications to quantum numbers!). Legendre's equation arises in physical problems with spherical symmetry. The simplest form of the equation has only one parameter, n and takes the form:

In[154]:=

LegendreODE = ( 1 - x 2 ) y '' [ x ] - 2 x y ' [ x ] + ( n ( n + 1 ) ) y [ x ] 0

Out[154]=

n ( 1 + n ) y [ x ] - 2 x y [ x ] + ( 1 - x 2 ) y ′′ [ x ] 0

Its solution is a linear combination of two special functions, Legendre and PLegendreQ:

In[155]:=

DSolve [ LegendreODE , y [ x ] , x ]

Out[155]=

{ { y [ x ] C [ 1 ] LegendreP [ n , x ] + C [ 2 ] LegendreQ [ n , x ] } }

The two-parameter form of the Legendre equation is:

In[156]:=

AnotherFormLegendreODE = ( 1 - x 2 ) y '' [ x ] - 2 x y ' [ x ] + ( n ( n + 1 ) - m 2 1 - x 2 ) y [ x ] 0

Out[156]=

( n ( 1 + n ) - m 2 1 - x 2 ) y [ x ] - 2 x y [ x ] + ( 1 - x 2 ) y ′′ [ x ] 0

which has a solution involving the same special functions:

In[157]:=

DSolve [ AnotherFormLegendreODE , y [ x ] , x ]

Out[157]=

{ { y [ x ] C [ 1 ] LegendreP [ n , m , x ] + C [ 2 ] LegendreQ [ n , m , x ] } }

Of course, Mathematica can evaluate and plot Legendre functions…

In[158]:=

Plot [ { LegendreP [ 0 , x ] , LegendreQ [ 0 , x ] } , { x , - 1 , 1 } , PlotStyle MyPlotStyle [ 2 ] ]

[Graphics:HTMLFiles/index_4.gif]

Out[158]=

Graphics

In[159]:=

Plot [ { LegendreP [ 1 , x ] , LegendreQ [ 1 , x ] } , { x , - 1 , 1 } , PlotStyle MyPlotStyle [ 2 ] ]

[Graphics:HTMLFiles/index_5.gif]

Out[159]=

Graphics

In[160]:=

Plot [ { LegendreP [ 2 , x ] , LegendreQ [ 2 , x ] } , { x , - 1 , 1 } , PlotStyle MyPlotStyle [ 2 ] ]

[Graphics:HTMLFiles/index_6.gif]

Out[160]=

Graphics

In[161]:=

Plot [ Evaluate [ Table [ LegendreP [ i , x ] , { i , 0 , 10 } ] ] , { x , - 1 , 1 } , PlotStyle MyPlotStyle [ 11 ] ]

[Graphics:HTMLFiles/index_7.gif]

Out[161]=

Graphics

In[162]:=

Plot [ Evaluate [ Table [ LegendreQ [ i , x ] , { i , 0 , 10 } ] ] , { x , - 1 , 1 } , PlotStyle MyPlotStyle [ 11 ] ]

[Graphics:HTMLFiles/index_8.gif]

Out[162]=

Graphics

Note how some of the Legendre functions are even and some are odd.  Recall that by summing even and odd functions, functions that are neither even or odd can be produced.

Hypergeometric and Laguerre special functions

Here is another differential equation whose solution involves special functions.  Many special functions are defined and analyzed precisely because they are solutions to simple ODEs

In[163]:=

DSolve [ x y '' [ x ] + ( q + 1 - x ) y ' [ x ] + p y [ x ] 0 , y [ x ] , x ]

Out[163]=

{ { y [ x ] C [ 1 ] HypergeometricU [ - p , 1 + q , x ] + C [ 2 ] LaguerreL [ p , q , x ] } }

In[164]:=

Plot [ LaguerreL [ 4 , 1 , x ] , { x , - 5 , 15 } ]

[Graphics:HTMLFiles/index_9.gif]

Out[164]=

Graphics

Using Special Functions to visualize the eigensolutions for an electron bound to a fixed proton--The Hydrogen Atom

Note: There are some issues that will be updated about the following in future versions---users should not consider the following to be sufficiently checked for accuracy (yet).

Eigenfunctions for Hydrogen:

Preliminary Definitions:
n will be the first quantum number n =1,2,3
L will be the second quantum number L=0,1,2,... (n-1)
m will be the third quantum number m = -L,-L+1,... 0,1,2, +L
These rules come from restrictions on the special functions that make up the eigenfunctions for the H-atom

In[165]:=

Z = 1 ; a0 = 1 ;

κ[n_] := κ[n] =    ( Z)/(a0  n)

ρ[n_, r_] := 2 κ[n] r

A[n_ , L_] := A[n , L] = Factorial[n - L - 1]/(2 n (Factorial[n + L])^3)^(1/2)

Prefact[n_, L_] := Prefact[n, L] =    (2 κ[n])^3/2  A[n, L]

R[n_ , L_, r_] := Prefact[n, L] ρ[n, r] Exp[-ρ[n, r]/2] LaguerreL[n - L - 1, 2 L + 1, ρ[n, r]]

The eigenfunctions for the Hydrogen Atom can now be written down.  The eigenfunctions will relate to the above definitions and involve the Spherical Harmonics which are related to Legendre functions and its derivatives.

In[171]:=

HAtom [ n_ , L_ , m_ , { r_ , θ_ , ϕ_ } ] := R [ n , L , r ] SphericalHarmonicY [ L , m , θ , ϕ ]

In[172]:=

<< Calculus`VectorAnalysis`

In[173]:=

CoordinatesFromCartesian [ { x , y , z } , Spherical ]

Out[173]=

{ x 2 + y 2 + z 2 , ArcCos [ z x 2 + y 2 + z 2 ] , ArcTan [ x , y ] }

In[174]:=

SphericalCoords [ x_ , y_ , z_ ] := Module [ { rsq = x ^ 2 + y ^ 2 + z ^ 2 , r , phi = ArcTan [ x , y ] } , r = Sqrt [ rsq ] ; Return [ { r , ArcCos [ z / r ] , phi } ] ]

2,1,1 corresponds to a 2p spin up electron

In[175]:=

HAtom [ 2 , 1 , 1 , SphericalCoords [ 1 , 2 , 1 ] ]

Out[175]=

- 1 48 - 3 2 + ArcTan [ 2 ] 5 π

In[176]:=

N [ HAtom [ 2 , 1 , 1 , SphericalCoords [ 1 , 2 , 1 ] ] ]

Out[176]=

- 0.0034536942448454423 - 0.006907388489690884

In[177]:=

<< Graphics`ContourPlot3D`

In[178]:=

Abs [ HAtom [ 2 , 1 , 1 , CoordinatesFromCartesian [ { 0 , 1 , .5 } , Spherical ] ] ]

Out[178]=

0.0067205656881381285

Plot a surface of constant probability density. Only an octant can be plotted, the numerical methods do not behave well on the coordinate "zero value" planes.

In[179]:=

p1 = ContourPlot3D [ Abs [ HAtom [ 2 , 1 , 1 , SphericalCoords [ x , y , z ] ] ] , { x , - 5 , 5 } , { y , 0.001 , 5 } , { z , 0.002 , 5 } , MaxRecursion -> 2 , Contours -> { 0.006 , 0.007 , 0.008 } ]

[Graphics:HTMLFiles/index_16.gif]

Out[179]=

Graphics3D

In[180]:=

epsilon = 10 ^ ( - 6 )

Out[180]=

1 1000000

In[181]:=

pdens = NMaximize [ Abs [ HAtom [ 3 , 2 , 1 , SphericalCoords [ x , y , z ] ] ] , { x , y , z } ]

Out[181]=

{ 0.00004804484923849476 , { x - 2.0751797601104656 , y 0.4400326483545185 , z 2.1213203050671967 } }

In[182]:=

p1 = ContourPlot3D [ Abs [ HAtom [ 3 , 2 , 1 , SphericalCoords [ x , y , z ] ] ] , { x , - 10 , 10 } , { y , epsilon , 10 } , { z , epsilon , 10 } , MaxRecursion 2 , PlotPoints -> { 7 , 7 } , Contours -> { 0.95 pdens [ [ 1 ] ] } ]

[Graphics:HTMLFiles/index_17.gif]

Out[182]=

Graphics3D

In[183]:=

p2 = ContourPlot3D [ Abs [ HAtom [ 3 , 2 , 1 , SphericalCoords [ x , y , z ] ] ] , { x , - 10 , 10 } , { y , epsilon , 10 } , { z , - epsilon , - 10 } , MaxRecursion 2 , PlotPoints -> { 7 , 7 } , Contours -> { 0.95 pdens [ [ 1 ] ] } ]

[Graphics:HTMLFiles/index_18.gif]

Out[183]=

Graphics3D

However, we can always put the octants back together like a puzzle

In[184]:=

Show [ p1 , p2 ]

[Graphics:HTMLFiles/index_19.gif]

Out[184]=

Graphics3D

Write a function to place all the octants on one graph

In[185]:=

HAtomShow [ n_ , L_ , m_ , pfrac_ ] := Module [ { nu , nd , su , sd , pmax , plevel , whole , half } , pmax = NMaximize [ Abs [ HAtom [ n , L , m , SphericalCoords [ x , y , z ] ] ] , { x , y , z } ] ; plevel = pfrac ( pmax [ [ 1 ] ] ) ; nu = ContourPlot3D [ Abs [ HAtom [ n , L , m , SphericalCoords [ x , y , z ] ] ] , { x , - 10 , 10 } , { y , epsilon , 10 } , { z , epsilon , 10 } , MaxRecursion 2 , PlotPoints -> { 5 , 5 } , Contours -> { plevel } , DisplayFunction Identity ] ; nd = ContourPlot3D [ Abs [ HAtom [ 3 , 2 , 1 , SphericalCoords [ x , y , z ] ] ] , { x , - 10 , 10 } , { y , epsilon , 10 } , { z , - epsilon , - 10 } , MaxRecursion 2 , PlotPoints -> { 5 , 5 } , Contours -> { plevel } , DisplayFunction Identity ] ; su = ContourPlot3D [ Abs [ HAtom [ n , L , m , SphericalCoords [ x , y , z ] ] ] , { x , - 10 , 10 } , { y , - epsilon , - 10 } , { z , epsilon , 10 } , MaxRecursion 2 , PlotPoints -> { 5 , 5 } , Contours -> { plevel } , DisplayFunction Identity ] ; sd = ContourPlot3D [ Abs [ HAtom [ 3 , 2 , 1 , SphericalCoords [ x , y , z ] ] ] , { x , - 10 , 10 } , { y , - epsilon , - 10 } , { z , - epsilon , - 10 } , MaxRecursion 2 , PlotPoints -> { 5 , 5 } , Contours -> { plevel } , DisplayFunction Identity ] ; whole = Show [ nu , nd , su , sd , DisplayFunction Identity ] ; half = Show [ nu , nd , DisplayFunction Identity ] ; Show [ GraphicsArray [ { whole , half } ] , DisplayFunction $DisplayFunction ] ]

It takes about a minute to compute and display one probability density contour

In[186]:=

H210 = HAtomShow [ 2 , 1 , 0 , 0.8 ]

[Graphics:HTMLFiles/index_20.gif]

Out[186]=

GraphicsArray

The next one takes a couple minutes, presumably because of the small probability values?

3,2,1 corresponds to a 3d spin-up electron

In[187]:=

H321 = HAtomShow [ 3 , 2 , 1 , 0.8 ]

[Graphics:HTMLFiles/index_21.gif]

Out[187]=

GraphicsArray

I am not sure why I am only getting the top half here...

In[188]:=

H31m1 = HAtomShow [ 3 , 1 , - 1 , 0.8 ]

[Graphics:HTMLFiles/index_22.gif]

Out[188]=

GraphicsArray

In[189]:=

H531 = HAtomShow [ 5 , 3 , 1 , 0.9 ]

[Graphics:HTMLFiles/index_23.gif]

Out[189]=

GraphicsArray


Created by Mathematica  (October 24, 2006) Valid XHTML 1.1!