I use the code below for drawing the Weierstrass function (from here). How can I change it to draw x²·weierstrass(x)?
\documentclass[margin=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{fpu}
\def\x{\noexpand\x}
\edef\weierstrass{0}
\edef\currentbn{1}
\foreach \i in {1,...,19} {
% \global makes these definitions last beyond the current iteration
\global\edef\currentbn{2*\currentbn} % b_n = 2 * b_n;
\global\edef\weierstrass{\weierstrass + (1/(\currentbn)*cos((\currentbn*\x) r))} % weierstrass = weierstrass + (1/b_n) cos(b_n*\x radians);
}
\begin{document}
\begin{tikzpicture}
\draw[thick, color=lightgray,step=0.25cm,solid] (-2,-0.75) grid (2,1.0);
\draw[<->] (-2.1,0) -- (2.1,0) node[below right] {$x$};
\draw[<->] (0,-0.9) -- (0,1.1) node[left] {$y$};
\draw[color=blue, thick, domain=-2:2, samples=501, /pgf/fpu, /pgf/fpu/output format=fixed]
plot (\x, {\weierstrass});
\end{tikzpicture}
\end{document}
Thanks in advance!

x^2and usex*xinstead. Even when it works, it takes much longer to compute. – John Kormylo Oct 01 '19 at 13:44x*x, but on my machine this is a ~3% effect forPDFLaTeXand ~5% forlualatex(which ironically takes longer here). – Oct 01 '19 at 14:15(a*x+b)*x+c. – John Kormylo Oct 01 '19 at 14:17