# How to create a Ricker Wavelet in TikZ

Is there an easy way to create this wavelet in TikZ.

Following the formula I have which is (1-2pi(x)^2)(e^-pi(x)^2) but when trying to create this I arrived at the issue that the function I have graphed goes over the x-axis 4 times instead of two.

The work I have so far is:

\begin{center}
\begin{tikzpicture} [xscale=1, yscale=2, line width=1.25]
\draw [help lines] (-10,-1) grid (10,1);
\draw [domain=-10:10, smooth] plot (\x, {(1-(2*pi*(\x)*(\x)))* e^(-pi*(\x)*(\x))});
\end{tikzpicture}
\end{center}


The problem is smooth, which doesn't always give good results, as the smoothing sometimes causes overshoots.

Instead, increase the number of samples from the default 25 to, for example, 200:

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture} [xscale=1, yscale=2, line width=1.25]
\draw [help lines] (-3,-1) grid (3,1);
\draw [domain=-3:3,samples=200] plot (\x, {(1-(2*pi*(\x)*(\x)))* e^(-pi*(\x)*(\x))});
\end{tikzpicture}
\end{document}


Note further that with your original code the curve is wrong in other ways as well. In the image below, the black curve is your example, and the crosses marks where TikZ has calculated a value of the function. Compare that to the blue line, where I increased the number of samples to 400.

• Thanks a ton for this I have been trying to figure out what was wrong for days. – Davinchi47 May 23 '17 at 14:37