3
$\begingroup$

So I was just doing some homework, and I happened to graph this

$\frac{1-cos(3x)}{3x}$

For some unknown reason I decided to zoom into to ridiculous levels and I saw a really really weird behavior of the graph. Sorta like a cartoony signal wave or something. Zoomed out Zoomed in

Is this actually what this graph would look like in a perfect world or is this just a display of the inaccuracies of computer trigonometry? How would you go about proving what the graph actually looked like considering such small number are used?

$\endgroup$
1
$\begingroup$

This is due to computational artifacts of floating points. Observe that $$ \frac{1-\cos 3x}{3x} = \frac{1}{3x} \left( 1 - \sum_{j=0}^\infty \frac{(-1)^j (3x)^{2j}}{(2j)!} \right) = -\sum_{j=1}^\infty \frac{(-1)^j (3x)^{2j-1}}{(2j)!} = \frac{3}{2}x + \mathrm o_0(x) $$ so the graph nearby $0$ should resemble the graph of $3x/2$.

$\endgroup$
1
$\begingroup$

This is an fun example of what is called loss of significance, in which the closeness of two terms being subtracted leads to loss in the number of significant digits in floating point arithmetic. Your function is continuous away from zero, and has what is called a removable discontinuity at $x=0$.

$\endgroup$
1
  • 1
    $\begingroup$ Inded, for a nicer plot around $x=0$, replace $\frac{1-\cos3x}{3x}$ with the (there) equivalent expression $$\frac{(1-\cos 3x)(1+\cos3x)}{3x(1+\cos3x)}=\frac{1-\cos^2 3x}{3x(1+\cos3x)}=\frac{\sin^2 3x}{3x(1+\cos3x)}$$ $\endgroup$ Apr 3 '16 at 20:09

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.