Timeline for Plotting Dirac Delta Function as colored arrows
Current License: CC BY-SA 4.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 29, 2020 at 8:57 | comment | added | TKS |
Testing whether the imaginary part is zero suppresses some arrows. I changed the code to ArrowsDeltaFunctionNew[eqn_, x_] := Module[{xs, di, im, re, mm}, xs = Cases[eqn, a_ DiracDelta[b_] :> {{a}, x /. Solve[b == 0]}]; di = Flatten[Tuples /@ xs, 1]; im = Select[di, Im[#[[1]]] != 0 &]; re = Select[di, Re[#[[1]]] != 0 &]; mm = Max[Abs[Join[Re[re[[All, 1]]], Im[im[[All, 1]]]]]] + 0.1; Plot[{}, {x, -5, 5}, Epilog -> {Red, Arrow[{{#[[2]], 0}, {#[[2]], Re[#[[1]]]}}] & /@ re, Blue, Arrow[{{#[[2]], 0}, {#[[2]], Im[#[[1]]]}}] & /@ im}, PlotRange -> mm] ];
|
|
Dec 27, 2020 at 20:26 | comment | added | TKS | Yes thanks ... (it's late, I better stop now) :-) | |
Dec 27, 2020 at 19:56 | comment | added | azerbajdzan | It works in the module you posted. | |
Dec 27, 2020 at 19:54 | comment | added | TKS | Yes your code works! I just wanted to use it in a module. | |
Dec 27, 2020 at 19:53 | comment | added | azerbajdzan |
??? It works for me: ArrowsDeltaFunctionNew[ 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], x]
|
|
Dec 27, 2020 at 19:51 | history | edited | azerbajdzan | CC BY-SA 4.0 |
added 22 characters in body
|
Dec 27, 2020 at 19:48 | comment | added | TKS | Thanks for the hint! I have tried to put your code in a module, but this isn't working. ArrowsDeltaFunctionNew[eqn_, x_] := Module[{xs, di, im, re, mm}, xs = Cases[eqn, a_ DiracDelta[b_] :> {{a}, x /. Solve[b == 0]}]; di = Flatten[Tuples /@ xs, 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] ]; | |
Dec 27, 2020 at 19:23 | history | answered | azerbajdzan | CC BY-SA 4.0 |