0
$\begingroup$

I am using Mathematica 10. I have the following code yielding a ragged plot

    market [r_, a_] = (1 + 2*r + a^2)/(1 - 2*I*(Sqrt[a^2 - r^2])  - a^2);


stock11[l_, x_, r_, a_] = (
   Abs[market[r, a]]^2* Exp[- 5.59 * 10^9 * x])/
   2 (Cosh[(1.1174 * 10^10)/2 x] - Exp[- l* x] Cos[5.302*10^9 x]);

stock22[l_, x_] = 
  Exp[- 5.59 * 10^9* x]/
   2 (Cosh[(1.1174 * 10^10)/2 x] + Exp[- l*x] Cos[5.302*10^9 x]);

VarianceS[l_, x_, r_, a_] = 
  1 - 4*stock11[l, x, r, a] + 8*stock11[l, x, r, a]*stock22[l, x]  + 
   Abs[market[r, a]]^2* Exp[-2*5.59 * 10^9*x] (Exp[-2*l*x] - 1) ; 

Λ[l_, x_, r_, a_] = 
 1 - 2 stock11[l, x, r, 
    a]; (* The two time correlation Subscript[C, 01] = Subscript[c, \
12] = Λ*)

VarianceT[l_, x_, r_, a_] = 
 2 Λ[l, x, r, a] - Λ[l, 2*x, r, a];

differenceV[l_, x_, r_, a_] = 
  VarianceS[l, x, r, a] - VarianceT[l, x, r, a];

Plot[differenceV[0, 1.7889*10^-10*x, 0.001596, 2.228*10^-3], {x, 0, 
  20}]

Mathematica graphics

Is there any way of smoothing this raggedness/peaks?

$\endgroup$
5
  • $\begingroup$ You use F. How is it defined? $\endgroup$
    – Coolwater
    Commented Jan 23, 2018 at 17:40
  • $\begingroup$ Perhaps the undefined symbol noticed by @Coolwater can fix it, but as written I can't find a plot scale on which your function is not ragged: list = Table[ differenceV[0, 1.7889*10^-10*x, 0.001596, 2.228*10^-3], {x, 0, 20, 0.001}]; ListLinePlot@list yields this: i.sstatic.net/XTI4W.png $\endgroup$
    – Jason B.
    Commented Jan 23, 2018 at 17:42
  • $\begingroup$ @Coolwater, sorry. F[r,a] was a typo. It is actually market[r,a]. $\endgroup$
    – H. Kenan
    Commented Jan 23, 2018 at 17:45
  • $\begingroup$ I expect the difference of two smooth functions to be a smooth curve. Could it be possible to obtain a smooth curve? $\endgroup$
    – H. Kenan
    Commented Jan 23, 2018 at 17:49
  • 2
    $\begingroup$ I added a plot. It rather makes the problem obvious to those who understand numerics (it's machine-precision rounding error of the difference of two things that are approximately equal). If a question is about how a plot looks, probably the plot should be included anyway. $\endgroup$
    – Michael E2
    Commented Jan 24, 2018 at 13:06

1 Answer 1

4
$\begingroup$

After replacing the inexact numbers by exact numbers, FullSimplify turns the function you plot into 0

a1 = 559/100;
a2 = 11174/10000;
a3 = 5302/1000;

market[r_, a_] = (1 + 2*r + a^2)/(1 - 2*I*(Sqrt[a^2 - r^2]) - a^2);
stock11[l_, x_, r_, a_] = (Abs[market[r, a]]^2*Exp[-a1*10^9*x])/2 (Cosh[(a2*10^10)/2 x] -
                           Exp[-l*x] Cos[a3*10^9 x]);
stock22[l_, x_] = Exp[-a1*10^9*x]/2 (Cosh[(a2*10^10)/2 x] + Exp[-l*x] Cos[a3*10^9 x]);

VarianceS[l_, x_, r_, a_] = 1 - 4*stock11[l, x, r, a] + 8*stock11[l, x, r, a]*
  stock22[l, x] + Abs[market[r, a]]^2*Exp[-2*a1*10^9*x] (Exp[-2*l*x] - 1);
Λ[l_, x_, r_, a_] = 1 - 2 stock11[l, x, r, a];
VarianceT[l_, x_, r_, a_] =  2 Λ[l, x, r, a] - Λ[l, 2*x, r, a];

differenceV[l_, x_, r_, a_] = VarianceS[l, x, r, a] - VarianceT[l, x, r, a];

differenceV[0, 17889/10000*10^-10*x, 1596/1000000, 2228/1000*10^-3] // FullSimplify

0

So to get a non-ragged plot use Plot[0, {x, 0, 20}]

$\endgroup$
1
  • $\begingroup$ its actually zero even if you leave the a's and other constants symbolic. $\endgroup$
    – george2079
    Commented Jan 23, 2018 at 18:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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