As others already have written, the Dirac delta is not a real function and it can't be plotted. Other programs that claim to plot it just fake it.
Having said that, you can roll a diracDelta of your own, that more or less mimics the Dirac Delta's behavior but is still continuous. Advantage with respect to Heike's solution is that we don't need to increase the number of PlotPoints
.
I'll use the NormalDistrution with a very small standard deviation:
diracDelta[x_] = PDF[NormalDistribution[0, 1/100], x];
eqn1wb := (2 ((I Pi f) Exp[(-I) 2 Pi f]) ((1/2) DiracDelta[f - 2] +
DiracDelta[f + 2]))/(1 + I 2 Pi f);
wb1 = Plot[
Re[eqn1wb] /. DiracDelta -> diracDelta // Evaluate, {f, -5, 5},
PlotStyle :> {Thick, Red}, AspectRatio :> 1,
GridLines :> {{-4, -2, 2, 4}, {1.0, 0.5, -0.5, -1.0}},
PlotLabel :> "Re(w) - Frequency Response",
AxesLabel :> {"f", "W(f)"}, PlotRange -> {Automatic, 1.5}]
DiracDelta's are sometimes plotted by using arrows. Of course we can do that as well. In this case we can set the function at zero everywhere and add arraows in the Epilog
part of the plot.
Plot[0, {f, -5, 5}, PlotStyle :> {Thick, Red}, AspectRatio :> 1,
GridLines :> {{-4, -2, 2, 4}, {1.0, 0.5, -0.5, -1.0}},
PlotLabel :> "Re(w) - Frequency Response",
AxesLabel :> {"f", "W(f)"}, PlotRange -> {Automatic, 1.},
Epilog -> {Red, Thick,Arrow[{{-2, 0}, {-2, 1}}], Arrow[{{2, 0}, {2, 1}}]}]
I believe the convention is to scale the lengths of the arrows in proportion to the factors in front of the DiracDelta. The above can be easily extended to do that.
Factors can be found using Coefficient
:
Coefficient[eqn1wb, DiracDelta[-2 + f]]
(*
==> (I E^(-2 I f \[Pi]) f \[Pi])/(1 + 2 I f \[Pi])
*)
Ratio's of coefficients:
Coefficient[eqn1wb, DiracDelta[2 + f]]/Coefficient[eqn1wb, DiracDelta[2 - f]]
(*
==> 2
*)
Locations of the Dirac delta's:
Cases[eqn1wb, DiracDelta[a__] :> Solve[a == 0, f], Infinity]
(*
==> {{{f -> 2}}, {{f -> -2}}}
*)
I'm not going to automate it all, but the idea is clear. In the end you'll get something like: