Upload
others
View
23
Download
0
Embed Size (px)
Citation preview
Mathematica for Dirac delta functions and Green
functions
DiracDelta function
Mathematic has Dirac’s delta function built in for use in integrals and solving differential equations.
If you evaluate it directly you get 0 unless the argument is 0 in which case it gives you the function
back---it is not evaluated and does not evaluate to infinity.
8DiracDelta@1D, DiracDelta@0D, DiracDelta@-1D<80, DiracDelta@0D, 0<So there is no peak in a plot of the function
Plot@DiracDelta@xD, 8x, -1, 1<, Exclusions ® None, PlotStyle ® 8Red, Thick<D
-1.0 -0.5 0.5 1.0
-1.0
-0.5
0.5
1.0
However, it integrates to give the theta function:
Integrate@DiracDelta@xD, xDHeavisideTheta@xDPlot@HeavisideTheta@xD, 8x, -1, 1<, Exclusions ® None, PlotStyle ® 8Red, Thick<D
-1.0 -0.5 0.5 1.0
0.2
0.4
0.6
0.8
1.0
And differentiating the theta function returns the Dirac delta function
D@HeavisideTheta@xD, xDDiracDelta@xDFurther derivatives are just denoted symbolically
D@DiracDelta@xD, xDDiracDelta
¢@xDNote that numerical integration over a delta function does not give the correct result because the rou-
tines cannot “find” the infinitely narrow peak. So, beware of this---use DiracDelta only in analytical
integrations or solves.
NIntegrate@DiracDelta@xD, 8x, -1, 1<DNIntegrate::izero :
Integral and error estimates are 0 on all integration subregions. Try increasing the value of the MinRecursion
option. If value of integral may be 0, specify a finite value for the AccuracyGoal option. �
0.
Integrals using Dirac delta function
Defining properties
Integrate@f@xD DiracDelta@x - 1D, 8x, -Infinity, Infinity<Df@1DIntegral vanishes if integration range does not include position of delta function
Integrate@f@xD DiracDelta@x - 1D, 8x, -Infinity, 0.5<D0.
Dirac delta is an even function
Integrate@f@xD DiracDelta@-xD, 8x, -1, 1<Df@0DCorrect Jacobians
Integrate@f@xD DiracDelta@3 Hx - 1LD, 8x, -2, 2<Df@1D3
Example from lecture
Integrate@3 Exp@xD DiracDelta@Sinh@2 xDD, 8x, -Infinity, Infinity<D3
2
Checking explicitly:
2 RevisedGreen.nb
D@Sinh@2 xD, xD2 Cosh@2 xD2 Cosh@0D2
IntegrateB3
2
Exp@xD DiracDelta@xD, 8x, -Infinity, Infinity<F
3
2
Correctly picks up multiple crossings of zero by argument of delta function
Integrate@f@xD DiracDelta@Sin@2 xDD, 8x, -1, Pi + 1<D1
2
Kf@0D + fB Π
2
F + f@ΠDO
More examples from lecture
Integrate@Cos@x � 2D DiracDelta@Sin@xDD, 8x, -Pi � 2, 3 Pi � 2<D1
Integrate@Cos@x � 2D DiracDelta@Sin@xDD, 8x, -Pi � 2, -Pi � 4<D0
Integrals of derivatives of delta functions
Integrate@f@xD DiracDelta'@xD, 8x, -1, 1<D-f
¢@0D
A few cautions about Mathematica’s DiracDelta[ ]:
Only HeavisideTheta[x]’s derivative gives DiracDelta[ ], functions with similar behavior do not
testfunctions =
8HeavisideTheta@xD, UnitStep@xD, HSqrt@x^2D � x + 1L � 2, HAbs@xD � x + 1L � 2<
:HeavisideTheta@xD, UnitStep@xD, 1
2
1 +x2
x
,
1
2
1 +Abs@xD
x
>
RevisedGreen.nb 3
Plot@ð, 8x, -1, 1<D & �� testfunctions
:
-1.0 -0.5 0.5 1.0
0.2
0.4
0.6
0.8
1.0
,
-1.0 -0.5 0.5 1.0
0.2
0.4
0.6
0.8
1.0
,
-1.0 -0.5 0.5 1.0
0.2
0.4
0.6
0.8
1.0
,
-1.0 -0.5 0.5 1.0
0.2
0.4
0.6
0.8
1.0
>
The limits from each side have the appropirate values
Limit@testfunctions, x ® 0, Direction ® 1D80, 0, 0, 0<Limit@testfunctions, x ® 0, Direction ® -1D81, 1, 1, 1<At the discontinuous point they have different interpretations
testfunctions �. x ® 0
Power::infy : Infinite expression
1
0
encountered. �
Infinity::indet : Indeterminate expression 0 ComplexInfinity encountered. �
Power::infy : Infinite expression
1
0
encountered. �
Infinity::indet : Indeterminate expression 0 ComplexInfinity encountered. �
8HeavisideTheta@0D, 1, Indeterminate, Indeterminate<Mathematica will only correctly identify the derivative of HeavisideTheta[x] as DiracDelta[x]
D@testfunctions, xD
:DiracDelta@xD, Indeterminate x � 0
0 True, 0,
1
2
-Abs@xD
x2
+Abs
¢@xDx
>
DiracDelta[ ] is not defined for complex arguments:
DiracDelta@2 + IDDiracDelta@2 + äD
4 RevisedGreen.nb
Integrate@DiracDelta@x - ID, 8x, -2 I, 2 I<D
à-2 ä
2 ä
DiracDelta@-ä + xD âx
Limits which can be used to define a delta function will not return DeltaFunction[ ]:
Limit@¶ � Hx^2 + ¶^2L, ¶ ® 0D0
Integrals will not return a delta function:
Integrate@Exp@I k xD, 8x, -¥, ¥<, Assumptions -> k Î RealsD
Integrate::idiv : Integral of ãä k x
does not converge on 8-¥, ¥<. �
IntegrateAãä k x
, 8x, -¥, ¥<, Assumptions ® k Î RealsEBut FourierTransform[ ] will:
FourierTransform@Exp@I k xD, x, y, FourierParameters ® 8-1, -1<DDiracDelta@k - yD
Sec. 8.11 #9---example worked in class
Mathematica can deal with general t0 (which it assumes is real, as DiracDelta is only defined for reals):
Clear@t0, yD
soln9 =
Flatten@DSolve@8y''@tD + 2 y'@tD + 10 y@tD � DiracDelta@t - t0D, y'@0D � 0, y@0D � 0<,y@tD, tDD �� Simplify
:y@tD ®1
3
ã-t+t0 HHeavisideTheta@3 t - 3 t0D - HeavisideTheta@-3 t0DL Sin@3 Ht - t0LD>
Make into a function:
yy@t_D = FullSimplify@Flatten@y@tD �. soln9 DD1
3
ã-t+t0 HHeavisideTheta@t - t0D - HeavisideTheta@-t0DL Sin@3 Ht - t0LD
Next consider t0=1 for definiteness.
This gives the answer obtained in class in various ways:
t0 = 1; yy@tD1
3
ã1-t
HeavisideTheta@-1 + tD Sin@3 H-1 + tLD
Recall this is a damped oscillator at rest given a unit impulse at t=1, so that its slope has a discontinu-
ity, although the function is continuous.
RevisedGreen.nb 5
Plot@yy@tD, 8t, -1, 10<, PlotStyle ® 8Thick, Red<,PlotRange ® 88-1, 10<, 8-0.2, 0.25<<D
2 4 6 8 10
-0.2
-0.1
0.1
0.2
Finding Green function obtained in Boas using “DiracDelta”
soln = DSolve@8y''@tD + y@tD � DiracDelta@t - tpD, y@0D � 0, y@Pi � 2D � 0<, y@tD, tD
::y@tD ® -Cos@tpD HeavisideThetaB Π
2
- tpF Sin@tD + Cos@tpD HeavisideTheta@t - tpD Sin@tD -
Cos@tD HeavisideTheta@t - tpD Sin@tpD + Cos@tD HeavisideTheta@-tpD Sin@tpD>>To simplify, need to let Mathematica know the range of “tp”.
This result agrees with that we found.
soln2 = Simplify@soln, Assumptions ® 80 < tp < Pi � 2<D88y@tD ® -Cos@tpD Sin@tD + HeavisideTheta@t - tpD Sin@t - tpD<<Green function is thus
GG@t_, tp_D = -Sin@tD Cos@tpD + HeavisideTheta@t - tpD Sin@t - tpD;
Sec. 8.12 #13---example worked in class
Forcing function.
ff@x_D = Piecewise@88x, 0 £ x < Pi � 4<, 8Pi � 2 - x, Pi � 4 £ x < Pi � 2<<Dx 0 £ x <
Π
4
Π
2- x
Π
4£ x <
Π
2
0 True
6 RevisedGreen.nb
Plot@ff@xD, 8x, 0, Pi � 2<, PlotStyle ® 8Thick, Red<D
0.5 1.0 1.5
0.2
0.4
0.6
0.8
Here’s the result for the solution using the Green function from above applied to the forcing function:
fullyy@x_D = Integrate@GG@x, xpD ff@xpD, 8xp, 0, Pi � 2<D �� Simplify
1
4
K-4 J-1 + 2 N Sin@xD - HeavisideThetaB-Π
4
+ xF K-2 Π + 4 x + 4 CosB Π
4
+ xF +
2 HΠ - 2 x - 2 Cos@xDL HeavisideThetaB-Π
2
+ xF + Π SinB Π
4
+ xFO + HeavisideTheta@xDK4 Hx - Sin@xDL + HeavisideThetaB-
Π
4
+ xF K-4 x - 4 CosB Π
4
+ xF + Π SinB Π
4
+ xFOOO
To get simple form, need to tell Mathematica the range of x:
yyless@x_D = Integrate@GG@x, xpD ff@xpD, 8xp, 0, Pi � 2<, Assumptions ® 80 < x < Pi � 4<D
x - 2 Sin@xDyymore@x_D =
Integrate@GG@x, xpD ff@xpD, 8xp, 0, Pi � 2<, Assumptions ® 8Pi � 4 < x < Pi � 2<D1
2
JΠ - 2 x - 2 2 Cos@xDN
Subsequent three plots show resulting y, y’ and y’’, so that one can see the nature of the solution,
whose third derivative is discontinuous.
RevisedGreen.nb 7
Plot@fullyy@xD, 8x, 0, Pi � 2<, PlotStyle ® 8Thick, Blue<, AxesLabel ® 8"x", "y"<D
0.5 1.0 1.5
x
-0.20
-0.15
-0.10
-0.05
y
Plot@Evaluate@D@fullyy@xD, xDD, 8x, 0, Pi � 2<,PlotStyle ® 8Thick, Blue<, AxesLabel ® 8"x", "y'"<D
0.5 1.0 1.5
x
-0.4
-0.2
0.2
0.4
y'
Plot@Evaluate@D@fullyy@xD, 8x, 2<DD, 8x, 0, Pi � 2<,PlotStyle ® 8Thick, Blue<, AxesLabel ® 8"x", "y''"<D
0.5 1.0 1.5
x
0.2
0.4
0.6
0.8
1.0
y''
Mathematica can also solve the differential equation including the piecewise function:
8 RevisedGreen.nb
Simplify@DSolve@8y''@xD + y@xD � ff@xD, y@0D � 0, y@Pi � 2D � 0<, y@xD, xDD
::y@xD ®
-J-1 + 2 N Cos@xD 2 x > Π
-J-1 + 2 N Sin@xD x £ 0
1
2JΠ - 2 x - 2 2 Cos@xDN Π
4< x £
Π
2
x - 2 Sin@xD True
>>
Keep in mind when Mathematica says “True” for a piecewise function, it just means “Otherwise”
RevisedGreen.nb 9