Skip to main content
added 22 characters in body
Source Link
azerbajdzan
  • 25.1k
  • 2
  • 22
  • 62

Here is a code that plots your arrows correctly:

Cases[1ca = Cases[
   1.56664 DiracDelta[(4.3 + 0. I) - x] + 
    I Sqrt[\[Pi]/2] DiracDelta[(4.6 + 0. I) - x] + 
    1.56664 DiracDelta[(4.3 + 0. I) + x] - 
    I Sqrt[\[Pi]/2] DiracDelta[(4.6 + 0. I) + x], 
   a_ DiracDelta[b_] :> {{a}, x /. Solve[b == 0]}];
di = Flatten[Tuples /@ %ca, 1];
im = Select[di, Im[#[[1]]] != 0 &];
re = Select[di, Im[#[[1]]] == 0 &];
mm = Max[Abs[Join[re[[All, 1]], Im[im[[All, 1]]]]]] + 0.1;
Plot[{}, {x, -5, 5}, 
 Epilog -> {Red, Arrow[{{#[[2]], 0}, {#[[2]], #[[1]]}}] & /@ re, Blue,
    Arrow[{{#[[2]], 0}, {#[[2]], Im[ #[[1]]]Im[#[[1]]]}}] & /@ im}, 
 PlotRange -> mm]
Clear[diClear[ca, di, im, re, mm]

enter image description here

He are more complex DiracDelta functions plotted:

-2 DiracDelta[x + 1] + 5 DiracDelta[(7 x + 3) (x - 4)] - 
 3 I DiracDelta[x - 3/2] + 2 I DiracDelta[x + 3]

enter image description here

Here is a code that plots your arrows correctly:

Cases[1.56664 DiracDelta[(4.3 + 0. I) - x] + 
   I Sqrt[\[Pi]/2] DiracDelta[(4.6 + 0. I) - x] + 
   1.56664 DiracDelta[(4.3 + 0. I) + x] - 
   I Sqrt[\[Pi]/2] DiracDelta[(4.6 + 0. I) + x], 
  a_ DiracDelta[b_] :> {{a}, x /. Solve[b == 0]}];
di = Flatten[Tuples /@ %, 1];
im = Select[di, Im[#[[1]]] != 0 &];
re = Select[di, Im[#[[1]]] == 0 &];
mm = Max[Abs[Join[re[[All, 1]], Im[im[[All, 1]]]]]] + 0.1;
Plot[{}, {x, -5, 5}, 
 Epilog -> {Red, Arrow[{{#[[2]], 0}, {#[[2]], #[[1]]}}] & /@ re, Blue,
    Arrow[{{#[[2]], 0}, {#[[2]], Im[ #[[1]]]}}] & /@ im}, 
 PlotRange -> mm]
Clear[di, im, re, mm]

enter image description here

He are more complex DiracDelta functions plotted:

-2 DiracDelta[x + 1] + 5 DiracDelta[(7 x + 3) (x - 4)] - 
 3 I DiracDelta[x - 3/2] + 2 I DiracDelta[x + 3]

enter image description here

Here is a code that plots your arrows correctly:

ca = Cases[
   1.56664 DiracDelta[(4.3 + 0. I) - x] + 
    I Sqrt[\[Pi]/2] DiracDelta[(4.6 + 0. I) - x] + 
    1.56664 DiracDelta[(4.3 + 0. I) + x] - 
    I Sqrt[\[Pi]/2] DiracDelta[(4.6 + 0. I) + x], 
   a_ DiracDelta[b_] :> {{a}, x /. Solve[b == 0]}];
di = Flatten[Tuples /@ ca, 1];
im = Select[di, Im[#[[1]]] != 0 &];
re = Select[di, Im[#[[1]]] == 0 &];
mm = Max[Abs[Join[re[[All, 1]], Im[im[[All, 1]]]]]] + 0.1;
Plot[{}, {x, -5, 5}, 
 Epilog -> {Red, Arrow[{{#[[2]], 0}, {#[[2]], #[[1]]}}] & /@ re, Blue,
    Arrow[{{#[[2]], 0}, {#[[2]], Im[#[[1]]]}}] & /@ im}, 
 PlotRange -> mm]
Clear[ca, di, im, re, mm]

enter image description here

He are more complex DiracDelta functions plotted:

-2 DiracDelta[x + 1] + 5 DiracDelta[(7 x + 3) (x - 4)] - 
 3 I DiracDelta[x - 3/2] + 2 I DiracDelta[x + 3]

enter image description here

Source Link
azerbajdzan
  • 25.1k
  • 2
  • 22
  • 62

Here is a code that plots your arrows correctly:

Cases[1.56664 DiracDelta[(4.3 + 0. I) - x] + 
   I Sqrt[\[Pi]/2] DiracDelta[(4.6 + 0. I) - x] + 
   1.56664 DiracDelta[(4.3 + 0. I) + x] - 
   I Sqrt[\[Pi]/2] DiracDelta[(4.6 + 0. I) + x], 
  a_ DiracDelta[b_] :> {{a}, x /. Solve[b == 0]}];
di = Flatten[Tuples /@ %, 1];
im = Select[di, Im[#[[1]]] != 0 &];
re = Select[di, Im[#[[1]]] == 0 &];
mm = Max[Abs[Join[re[[All, 1]], Im[im[[All, 1]]]]]] + 0.1;
Plot[{}, {x, -5, 5}, 
 Epilog -> {Red, Arrow[{{#[[2]], 0}, {#[[2]], #[[1]]}}] & /@ re, Blue,
    Arrow[{{#[[2]], 0}, {#[[2]], Im[ #[[1]]]}}] & /@ im}, 
 PlotRange -> mm]
Clear[di, im, re, mm]

enter image description here

He are more complex DiracDelta functions plotted:

-2 DiracDelta[x + 1] + 5 DiracDelta[(7 x + 3) (x - 4)] - 
 3 I DiracDelta[x - 3/2] + 2 I DiracDelta[x + 3]

enter image description here