I'm trying to draw the function described in the title on the interval $[-0.05,0.05]$, but all I get is a straight line:
This is my code:
\documentclass[a4paper,11pt,finnish]{report}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
clip=false,
axis line style = thick,
axis x line = middle,
axis y line = middle,
ticks = none,
xlabel=$x$,
xlabel style ={anchor=west},
ylabel=$y$,
ylabel style ={anchor=south}
]
\addplot[domain=-0.05:-0.01,samples=1000] {x^2 * sin(1/x) + x/2};
\addplot[domain=0.01:0.05,samples=1000] {x^2 * sin(1/x) + x/2}
node [pos = 0.95,above left] {$f(x)$};
\node at(axis cs: 0,0) [circle,fill,scale=0.3] {};
\end{axis}
\end{tikzpicture}
\end{document}
What I would like to see is the fluctuations in the function present in this interval. Is this simply a matter of precision, or something else?
sin
function expects input in degrees, you're telling it to plot over a set of radian values where the plot is non-linear, but if those numbers are taken to be degrees the plot is linear. This answer should cover things sufficiently.