[Tex/LaTex] pgfplots plots function not correct

degreespgfplotsplottikz-pgf

This code

\documentclass{article}

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}

  \begin{tikzpicture}
    \begin{axis}
      \addplot [domain=15:30, samples=1000] {4*65*sin(0.25*asin(x/65))/x};
    \end{axis}
  \end{tikzpicture}

\end{document}

plots a heavily oscillating function. If I plot this function with another plotter (Mathematica, online plotters, …) I get a really smooth function that is the non-oscillating mean of the function that pgfplots gives.

I know that pgfplots uses degrees instead of radians, but asin() should give degrees then, I assume (so that rad() is not neccessary)? Anyways, I already tried to put rad() in all possible combinations, it often changed the output, but it never gave the correct result.

Changing the samples to 1000 gave no better result either (it started oscillating even faster). Is this a bug of pgfplots?

Are there any other options to try/change here?

Result with TikZ version 2.10 (constant interpolation):

enter image description here

Result with TikZ CVS version ≥ 2012-10-11 (linear interpolation):

enter image description here

Best Answer

This is pushing the pgfmath engine (and its approximations for the trigonometric functions) past its limits, I believe. You can work around the issue by using gnuplot as the backend instead:

\documentclass{article}

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}

  \begin{tikzpicture}
    \begin{axis}
      \addplot [no markers] gnuplot [domain=15:30, samples=100] {4*65*sin(0.25*asin(x/65))/x};
    \end{axis}
  \end{tikzpicture}

\end{document}