Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I seem to be having some trouble with the Sinc[x] function, and I think it's due to rounding, but I'm not sure.

The code is below, with relevant constants:

b = 0.1;
a = 8.7106181548*^-18;
alpha$of$r[r_] := alpha /. FindRoot[alpha - b * alpha + (b/a) * Sin[a * alpha] ==
                                    r (1 - 2 * b),  {alpha, r (1 - 2 *b)}];

u[r_] := b * Sinc[a * alpha$of$r[r]];
Plot[b - u[r], {r, 10^9, 10^10}]

When we plot the function u[r] in the range specified, it does not seem to return a continuous curve as expected. Here's a picture of the plot:

wacky-looking plot

Could anyone offer insight as to why this happens and how I could fix it? I apologize in advance if I'm missing any information, as I'm new here. Thanks!

share|improve this question
    
You are running into machine precision rounding issues here. Try the option WorkingPrecision or look up the function SetPrecision in the docs. It should give you some ideas how to avoid the problem. –  Thies Heidecke Jun 11 '13 at 22:57

1 Answer 1

up vote 4 down vote accepted

The problem in your question is not about accuracy of $\text{sinc}(x)$ function itself but with the precision of FindRoot. When you increase working precision of the calculations (by using WorkingPrecision option) then the result is smooth

b=1/10;
a=87106181548 10^-28;
alpha[r_]:=alpha/.FindRoot[alpha-b alpha+(b/a) Sin[a alpha]==r (1-2 b), {alpha,r (1-2 b)},
                           WorkingPrecision->20];
u[r_]:=b Sinc[a alpha[r]];
Plot[b-u[r],{r,10^9,10^10}]//Quiet

enter image description here

Please note that I also increased precision of the a and b parameters by removing the decimal point.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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