1
$\begingroup$

The function is:

y[w_]= 0.32 DiracDelta[(2.495*10^-21 + 0. I) + 1.054*10^-50 w] 
       + 1.19 DiracDelta[(1.979*10^-20 + 0. I) + 1.054*10^-58 w];

Question 1) How can I remove all component less than 10^(-22) in y[w_]? (or remove "0.I")
Question 2) How I can Plot[y[w]]?

Please help! Thanks!

$\endgroup$
  • 1
    $\begingroup$ Look up Chop[]. $\endgroup$ – J. M.'s discontentment Jul 26 '16 at 8:16
  • $\begingroup$ Concerning a way of representing DiracDelta[] with graphics primitives, here is a solution. $\endgroup$ – andre314 Jul 26 '16 at 8:44
  • $\begingroup$ but I can't convert y[w_] to Fourier transform? which is the exactly function here I must use? $\endgroup$ – Haimuoi Jul 26 '16 at 9:11
2
$\begingroup$

You can use Round to get rid of small component.

Round[1. + 10.^-5 I, 10.^-6]

$1. + 0.00001 \rm I$

Round[1. + 10.^-5 I, 10.^-3]

$1.$

For your code

y[w_,n_]= Round[0.32 DiracDelta[(2.495*10^-21 + 0. I) + 1.054*10^-50 w] 
           + 1.19 DiracDelta[(1.979*10^-20 + 0. I) + 1.054*10^-58 w],10.^-n];

to eliminate numbers less than 10^-n

How to Plot

Here I define a plotting function ddplot

y[w_] = 0.32 DiracDelta[(2.495*10^-21 + 0. I) + 1.054*10^-50 w] + 
        1.19 DiracDelta[(1.979*10^-20 + 0. I) + 1.054*10^-58 w];
ddplot[n_] := ListPlot[Cases[y[0], x_ DiracDelta[y_] :> Round[{y, x}, 10.^-n]],
                       Filling -> Bottom]

ddplot[22]
ddplot[20]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ It didn't work , Mathematica said "ListPlot::argx: ListPlot called with 0 arguments; 1 argument is expected. >>" . Could you repair it? $\endgroup$ – Haimuoi Jul 27 '16 at 0:26
  • $\begingroup$ Which version of Mathematica are you using? Are you using y[w_] or y[w_,n_]? For plotting you have to use y[w_], similar to the one you wrote in your question. $\endgroup$ – Sumit Jul 27 '16 at 6:15
  • $\begingroup$ Yes, I used y[w_] and version 9.0. But "0.I" is the result of previous calculations (in my progress). $\endgroup$ – Haimuoi Jul 27 '16 at 7:08
  • $\begingroup$ hmm. What is the output of y[0]? Perhaps that is where I miss something ! $\endgroup$ – Sumit Jul 27 '16 at 8:06
2
$\begingroup$

(Extended comment)

Here is the solution exposed in this answer adapted to your problem :

y[w_] = 0.32 DiracDelta[(2.495*10^-21) + 1.054*10^-50 w] + 
  1.19 DiracDelta[(1.979*10^-20) + 1.054*10^-58 w]

ti00 = Collect[y[w], DiracDelta[_], coeff]

ti01 = ti00 /. 
  coeff[c_] DiracDelta[exp_] :> 
   With[{ww = w /. Last[Solve[exp == 0, {w}]]}, 
    Line[{{ww/(2 Pi), 0}, {ww/(2 Pi), Abs[c]}}]]

Graphics[List @@ ti01 , AspectRatio -> 1, Frame -> True]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thank you very much, but I still wonder why DiracDelta not reach infinity in your graphic? Could you help me plot another function (it has a division)! z[w_]=0.32 DiracDelta[(2.495*10^-21 ) + 1.054*10^-50 w] + 1.19 DiracDelta[(1.979*10^-20) + 1.054*10^-58 w]/ ( w (-8*10^-21 + 1.05*10^-34 w)^2 + 3.8*10^-25 (1.3 DiracDelta[(-2.23*10^-20) + 1.05*10^-34 w]) $\endgroup$ – Haimuoi Jul 26 '16 at 22:31
  • $\begingroup$ @Haimuoi If you see a Dirac as the limit of schrinking pulses with constant surfaces S, then S is the value that determine the strengh of the Dirac. The lines in the graphic are representing the S. Concerning the second part of your comment, I have no answer. $\endgroup$ – andre314 Jul 27 '16 at 18:48
  • $\begingroup$ Dear @andre.! Thank you for your help :) I'll try. $\endgroup$ – Haimuoi Jul 28 '16 at 5:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.