Animating a Dehn Twist

The mapping class group of an oriented topological manifold Y is the group Mod(Y) of orientation preserving homeomorphisms from Y to itself modulo isotopy. In other words, Mod(Y) is the quotient of the (orientation preserving) homeomorphism group Homeo_+(Y) by the connected component of the identity map. A famous theorem of Dehn asserts that the mapping class groups of an oriented surface Σ of genus g is generated by isotopy classes of Dehn twists (even better, for closed surfaces, Lickorish later showed that it is generated by 3g-1 of them and was able to give explicit generators). What, then, is a Dehn twist? If one has an embedded circle c in Σ, a Dehn twist about c is the homeomorphism from Σ to itself obtained by first identifying a tubular neighborhood A of c in Σ with the standard annulus S^1x[0,1] and using this identification to extend the self-homeomorphism of A given by the "twist map" (z,t)\mapsto(e^{2\pi it}z,t) via the identity outside of A. This is usually depicted in books and papers, by necessity, using a static image showing what happens to the line segment {1}x[0,1] under the twist map and, while this gives a good general sense of what is going on, I've always found it a bit unsatisfying since it is somewhat trickier to visualize just how much the rest of the annulus is being twisted so I decided to try my hand at animating the twist map.

To make this animation, I used the following LaTeX code to create a standalone .pdf document containing each of the individual frames in succession and then converted this into a .gif image using an online .pdf to .gif converter. In future, I would like to understand how to use the animate package for LaTeX to accomplish the same result natively.

\documentclass[tikz]{standalone}\usepackage{tikz}\begin{document} \foreach \angle in {0,1,...,72}{\begin{tikzpicture}[scale=3]\fill[white] (-1.2,-1.2) rectangle (1.2,1.2);
% Plots light blue circles in each frame.\foreach \radius in {1,2,3,4}{\draw[blue!7] (0,0) circle (0.35+0.13*\radius);  }
% Plots red curves in each frame. The \angle parameter produces% a total twist of 5 degrees at the innermost radius of the annulus% in each successive frame.
\draw[red,domain=0:1,smooth,variable=\t] plot ({(1-0.65*\t)*cos(\angle*5*\t)},{(1-0.65*\t)*sin(\angle*5*\t)}); 
% Plots light blue radial curves in each frame. The \angle parameter% serves the same role as in the red curve while the \a parameter% produces a radial shift of 36*\a degrees at each step.
\foreach \a in {1,2,...,9}{\draw[blue!7,domain=0:1,smooth,variable=\t] plot ({(1-0.65*\t)*cos(\angle*5*\t+36*\a)},{(1-0.65*\t)*sin(\angle*5*\t+36*\a)}); }
\draw (0,0) circle (0.35);\draw (0,0) circle (1);\end{tikzpicture}}
% Produces 7 static frames of the final image to create a slight pause at the end of the animation.
\foreach \b in {0,1,...,6}{\begin{tikzpicture}[scale=3]\fill[white] (-1.2,-1.2) rectangle (1.2,1.2);
\foreach \radius in {1,2,3,4}{\draw[blue!7] (0,0) circle (0.35+0.13*\radius);  }
\draw[red,domain=0:1,smooth,variable=\t] plot ({(1-0.65*\t)*cos(360*\t)},{(1-0.65*\t)*sin(360*\t)}); 
\foreach \a in {1,2,...,9}{\draw[blue!7,domain=0:1,smooth,variable=\t] plot ({(1-0.65*\t)*cos(360*\t+36*\a)},{(1-0.65*\t)*sin(360*\t+36*\a)}); } \draw (0,0) circle (0.35);\draw (0,0) circle (1);\end{tikzpicture}} \end{document}

Better Function Plotting

As a result of several conversations about our mutual dissatisfaction with available function plotting tools for LaTeX, I sat down with my colleague Marissa Masden to construct a better utility to allow us to more quickly and easily create nice graphs of functions for use in exam writing. The following code is still a work in progress but it is functional and produces very nice-looking graphs, as in the example below.

To do: replace the function of the \axes and \function commands with \varaxes and \varfunction, respectively, as these produce better results so the former are deprecated.

Code:


\documentclass[crop,tikz,convert={outext=.svg,command=\unexpanded{pdf2svg \infile\space\outfile}},multi=false]{standalone}[2018/08/7]\usepackage{pgf}\usepackage{ifthen}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% These document class options will force the compiler to output a cropped PDF suitable for use within the \includegraphics[keyvals]{imagefile} command in another .tex file.
\title{}\author{}\makeatletter
\newcommand{\axes}[3]{% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This macro produces a square grid with labeled horizontal and vertical axes for plotting functions. % The the three command arguments are as follows: % #1 stores the length of the positive horizontal axis % #2 stores the horizontal axis label % #3 stores the vertical axis label. % For example, \axes{3}{t}{u} will produce a (6cm)x(6cm) grid with horizontal axis labeled by t and vertical axis labeled by u. % Note: the axis lengths accept any decimal value but (half-)integer values produce the nicest results. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \foreach can't perform arithmetic inside its own list so numerical min, min+1, and max values need to be stored so that it can recognize the pattern in the list. The PGF package is necessary for these commands to work. The presence of the factor of 2 allows us to create a grid with step-size 0.5cm. \pgfmathtruncatemacro{\hmax}{2*#1} \pgfmathtruncatemacro{\hmin}{-2*#1} \pgfmathtruncatemacro{\hminplusone}{-2*#1+1} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This for loop draws a grid with step size 0.5cm in color 20% gray. Warning: some printers may not print these grid lines correctly so it may be necessary to adjust the color value. \foreach \h in {\hmin,\hminplusone,...,\hmax}{% \draw[gray!20] ({-#1},{0.5*\h}) -- ({#1},{0.5*\h}); \draw[gray!20] ({0.5*\h},{-#1}) -- ({0.5*\h},{#1}); }; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This for loop draws labels on the axes in color 55% blue. The color may be adjusted manually. \foreach \a in {1,2,...,#1}{ \draw[blue!55] ({\a},-0.25) node {${\a}$}; \draw[blue!55] (-0.25,{\a}) node {${\a}$}; }; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This draws axes. \draw[thick,->] ({0},{-#1}) -- ({0},{#1}); \draw[thick,->] ({-#1},{0}) -- ({#1},{0}); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This draws the horizontal axis label. \draw ({#1+0.25},0) node {$#2$}; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This draws the vertical axis label. \draw (0,{#1+0.25}) node {$#3$}; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This cuts off anything drawn in the same tikzpicture outside of the (#1cm)x(#1cm) square after the \axes command. \clip ({-#1},{-#1}) rectangle ({#1},{#1});}
\newcommand{\varaxes}[4]{% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This macro produces a square grid with labeled horizontal and vertical axes for plotting functions. % The the three command arguments are as follows: % #1 stores the length of the positive horizontal axis % #2 stores the length of the positive vertical axis % #3 stores the horizontal axis label % #4 stores the vertical axis label. % For example, \axes{4}{3}{t}{u} will produce a (8cm)x(6cm) grid with horizontal axis labeled by t and vertical axis labeled by u. % Note: the axis lengths accept any decimal value but (half-)integer values produce the nicest results. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % LaTeX will not perform arithmetic inside lists so numerical min, min+1, and max values need to be stored so that \foreach can recognize the pattern in the list. The PGF package is necessary for these commands to work. The presence of the factor of 2 enables us to create a grid with step-size 0.5cm. \pgfmathtruncatemacro{\hmax}{2*#1} \pgfmathtruncatemacro{\hmin}{-2*#1} \pgfmathtruncatemacro{\hminplusone}{-2*#1+1} \pgfmathtruncatemacro{\vmax}{2*#2} \pgfmathtruncatemacro{\vmin}{-2*#2} \pgfmathtruncatemacro{\vminplusone}{-2*#2+1} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This for loop draws a grid with step size 0.5cm in color 20% gray. Warning: some printers may not print these grid lines correctly so it may be necessary to adjust the color value. \foreach \h in {\hmin,\hminplusone,...,\hmax}{% \draw[gray!20] ({0.5*\h},{-#2}) -- ({0.5*\h},{#2}); }; \foreach \v in {\vmin,\vminplusone,...,\vmax}{% \draw[gray!20] ({-#1},{0.5*\v}) -- ({#1},{0.5*\v}); }; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This for loop draws labels on the axes in color 55% blue. The color may be adjusted manually. \foreach \a in {1,2,...,#1}{ \draw[blue!55] ({\a},-0.25) node {${\a}$}; }; \foreach \b in {1,2,...,#2}{ \draw[blue!55] (-0.25,{\b}) node {${\b}$}; }; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This draws axes. \draw[thick,->] ({0},{-#2}) -- ({0},{#2}); \draw[thick,->] ({-#1},{0}) -- ({#1},{0}); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This draws the horizontal axis label. \draw ({#1+0.25},0) node {$#3$}; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This draws the vertical axis label. \draw (0,{#2+0.25}) node {$#4$}; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This cuts off anything drawn in the same tikzpicture outside of the (#1cm)x(#1cm) square after the \axes command. \clip ({-#1},{-#2}) rectangle ({#1},{#2});}
\newcommand{\asymaxes}[6]{% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This macro produces a rectangular grid with labeled horizontal and vertical axes for plotting functions. % The the three command arguments are as follows: % #1 stores the length of the negative horizontal axis % #2 stores the length of the positive horizontal axis % #3 stores the length of the negative vertical axis % #4 stores the length of the positive vertical axis % #5 stores the horizontal axis label % #6 stores the vertical axis label. % For example, \axes{2}{4}{3}{5}{t}{u} will produce a (6cm)x(8cm) grid with lower-left corner at (-2,-3) and upper-right corner at (4,5), horizontal axis labeled by t, and vertical axis labeled by u. % Note: the axis lengths accept any decimal value but (half-)integer values produce the nicest results. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % LaTeX will not perform arithmetic inside lists so numerical min, min+1, and max values need to be stored so that \foreach can recognize the pattern in the list. The PGF package is necessary for these commands to work. The presence of the factor of 2 enables us to create a grid with step-size 0.5cm. \pgfmathtruncatemacro{\hmax}{2*#2} \pgfmathtruncatemacro{\hmin}{-2*#1} \pgfmathtruncatemacro{\hminplusone}{-2*#1+1} \pgfmathtruncatemacro{\vmax}{2*#4} \pgfmathtruncatemacro{\vmin}{-2*#3} \pgfmathtruncatemacro{\vminplusone}{-2*#3+1} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This for loop draws a grid with step size 0.5cm in color 20% gray. Warning: some printers may not print these grid lines correctly so it may be necessary to adjust the color value. \foreach \h in {\hmin,\hminplusone,...,\hmax}{% \draw[gray!20] ({0.5*\h},{-#3}) -- ({0.5*\h},{#4}); }; \foreach \v in {\vmin,\vminplusone,...,\vmax}{% \draw[gray!20] ({-#1},{0.5*\v}) -- ({#2},{0.5*\v}); }; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This for loop draws labels on the axes in color 55% blue. The color may be adjusted manually. \foreach \a in {1,2,...,#2}{ \draw[blue!55] ({\a},-0.25) node {${\a}$}; }; \foreach \b in {1,2,...,#4}{ \draw[blue!55] (-0.25,{\b}) node {${\b}$}; }; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This draws axes. \draw[thick,->] ({0},{-#3}) -- ({0},{#4}); \draw[thick,->] ({-#1},{0}) -- ({#2},{0}); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This draws the horizontal axis label. \draw ({#2+0.25},0) node {$#5$}; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This draws the vertical axis label. \draw (0,{#4+0.25}) node {$#6$}; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This cuts off anything drawn in the same tikzpicture outside of the (#1cm)x(#1cm) square after the \axes command. \clip ({-#1},{-#3}) rectangle ({#2},{#4});}
\newcommand{\polaraxes}[1]{% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This macro produces a round parametric grid of radius #1 with labeled horizontal and vertical axes and radian measures for plotting polar functions. % Note: #1 accepts any decimal value but (half-)integer values produce the nicest results. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \pgfmathtruncatemacro{\rmax}{2*#1} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This for loop draws a circular grid with step size 0.5cm in color 20% gray. Warning: some printers may not print these grid lines correctly so it may be necessary to adjust the color value. \foreach \r in {1,2,...,\rmax}{% \draw[gray!20] (0,0) circle ({0.5*\r}); }; \foreach \t in {0,1,...,24}{% \draw[gray!20] (0,0) -- ({(#1)*cos(15*\t)},{(#1)*sin(15*\t)}); }; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % These produce slightly thicker and darker gray horizontal and vertical axes to make the graph easier to read. \draw[thick,gray!50] ({0},{-#1}) -- ({0},{#1}); \draw[thick,gray!50] ({-#1},{0}) -- ({#1},{0}); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This for loop draws labels on the horizontal and vertical axes in color 55% blue. The color may be adjusted manually. \foreach \a in {1,2,...,#1}{ \draw[blue!55] ({\a},-0.25) node {${\a}$}; \draw[blue!55] (-0.25,{\a}) node {${\a}$}; }; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Radian labels \draw[violet!55] ({#1+0.25},0) node {$0$}; \draw[violet!55] ({(#1+0.35)*cos(30)},{(#1+0.35)*sin(30)}) node {$\frac{\pi}{6}$}; \draw[violet!55] ({(#1+0.35)*cos(45)},{(#1+0.35)*sin(45)}) node {$\frac{\pi}{4}$}; \draw[violet!55] ({(#1+0.35)*cos(60)},{(#1+0.35)*sin(60)}) node {$\frac{\pi}{3}$}; \draw[violet!55] ({0},{#1+0.35}) node {$\frac{\pi}{2}$}; \draw[violet!55] ({(#1+0.35)*cos(120)},{(#1+0.35)*sin(120)}) node {$\frac{2\pi}{3}$}; \draw[violet!55] ({(#1+0.35)*cos(135)},{(#1+0.35)*sin(135)}) node {$\frac{3\pi}{4}$}; \draw[violet!55] ({(#1+0.35)*cos(150)},{(#1+0.35)*sin(150)}) node {$\frac{5\pi}{6}$}; \draw[violet!55] ({-(#1+0.25)},{0}) node {$\pi$}; \draw[violet!55] ({(#1+0.35)*cos(210)},{(#1+0.35)*sin(210)}) node {$\frac{7\pi}{6}$}; \draw[violet!55] ({(#1+0.35)*cos(225)},{(#1+0.35)*sin(225)}) node {$\frac{5\pi}{4}$}; \draw[violet!55] ({(#1+0.35)*cos(240)},{(#1+0.35)*sin(240)}) node {$\frac{4\pi}{3}$}; \draw[violet!55] ({0},{-(#1+0.35)}) node {$\frac{3\pi}{2}$}; \draw[violet!55] ({(#1+0.35)*cos(300)},{(#1+0.35)*sin(300)}) node {$\frac{5\pi}{3}$}; \draw[violet!55] ({(#1+0.35)*cos(315)},{(#1+0.35)*sin(315)}) node {$\frac{7\pi}{4}$}; \draw[violet!55] ({(#1+0.35)*cos(330)},{(#1+0.35)*sin(330)}) node {$\frac{11\pi}{6}$}; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This cuts off anything drawn in the same tikzpicture outside of the (#1cm) radius circle after the \axes command. \clip (0,0) circle ({#1});}
\newcommand{\function}[4]{% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This macro will plot the function in argument #4 with domain [#1,#2] and color #3. The arguments #1 and #2 take numerical values, #3 accepts any predefined latex color or combination of colors using the color1!value1!color2!value2 syntax, and #4 accepts an argument in the variable \x. Caution: in order to ensure that polynomial functions of \x are plotted correctly, the variable should be enclosed in parentheses since latex reads commands from left to right unless they are enclosed in parentheses; e.g. \x^2 will be read as sign(x)x^2 since latex sees the sign of the variable before it sees the squaring function. Warning: since this plotting function uses the 'smooth' option, \varfunction may be more suitable for plotting transcendental functions. \draw[domain=#1:#2,smooth,thick,color=#3] plot ({\x},{#4});}
\newcommand{\varfunction}[5]{% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This macro will plot the function in argument #4 with domain [#1,#2], color #3, and number of samples #5. The arguments #1, #2, and #5 take numerical values, #3 accepts any predefined latex color or combination of colors using the color1!value1!color2!value2 syntax, and #4 accepts an argument in the variable \x. Caution: in order to ensure that polynomial functions of \x are plotted correctly, the variable should be enclosed in parentheses since latex reads commands from left to right unless they are enclosed in parentheses; e.g. \x^2 will be plotted as sign(x)x^2 since latex sees the sign of the variable before it sees the squaring function. Note: arguments of trigonometric functions are interpreted by LaTeX in degrees by default so it is necessary to rescale the argument in order to obtain a nice-looking graph. \draw[domain=#1:#2,samples=#5,thick,color=#3] plot ({\x},{#4});}
\newcommand{\parafunction}[6]{% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This macro will produce the parametric plot x=#4 y=#5 with domain [#1,#2], color #3, and number of samples #5. The arguments #1, #2, and #5 take numerical values, #3 accepts any predefined latex color or combination of colors using the color1!value1!color2!value2 syntax, and #4 accepts an argument in the variable \x. Caution: in order to ensure that polynomial functions of \x are plotted correctly, the variable should be enclosed in parentheses since latex reads commands from left to right unless they are enclosed in parentheses; e.g. \x^2 will be plotted as sign(x)x^2 since latex sees the sign of the variable before it sees the squaring function. Note: arguments of trigonometric functions are interpreted by LaTeX in degrees by default so it is necessary to rescale the argument in order to obtain a nice-looking graph. \draw[domain=#1:#2,samples=#6,thick,color=#3] plot ({#4},{#5});}
\newcommand{\polarfunction}[5]{% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This macro will plot the function in argument #4 with domain [#1,#2], color #3, and number of samples #5. The arguments #1, #2, and #5 take numerical values, #3 accepts any predefined latex color or combination of colors using the color1!value1!color2!value2 syntax, and #4 accepts an argument in the variable \x. Caution: in order to ensure that polynomial functions of \x are plotted correctly, the variable should be enclosed in parentheses since latex reads commands from left to right unless they are enclosed in parentheses; e.g. \x^2 will be plotted as sign(x)x^2 since latex sees the sign of the variable before it sees the squaring function. Note: arguments of trigonometric functions are interpreted by LaTeX in degrees by default so it is necessary to rescale the argument in order to obtain a nice-looking graph. \draw[domain=#1:#2,samples=#5,thick,color=#3] plot ({(#4)*cos(57.2958*\x)},{(#4)*sin(57.2958*\x)});}
\newcommand{\piece}[7]{% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This macro will plot the function in argument #6 with domain [#1,#2] and color #5 as a piecewise function with #7 samples. The arguments #1, #2, and #7 take numerical values, #3 and #4 accept values 0 and 1, #5 accepts any predefined latex color or combination of colors using the color1!value1!color2!value2 syntax, and #6 accepts an argument in the variable \x. %\pgfmathtruncatemacro{\lend}{#6@#1} %\pgfmathtruncatemacro{\rend}{#6@#2}% \tikzset{declare function={f(\x)=#6;}} \draw[domain=#1:#2,samples=#7,thick,color=#5] plot ({\x},{#6}); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % These if-then-else statements produce an open-endpoint circle if argument  \ifthenelse{0=#3}{\draw[thick,fill=white,declare function={f(\x)=#6;}] ({#1},{f(#1)}) circle (0.055);}{\draw[thick,fill,declare function={f(\x)=#6;}] ({#1},{f(#1)}) circle (0.055);} \ifthenelse{0=#4}{\draw[thick,fill=white,declare function={f(\x)=#6;}] ({#2},{f(#2)}) circle (0.055);}{\draw[thick,fill,declare function={f(\x)=#6;}] ({#2},{f(#2)}) circle (0.055);}}
\newcommand{\pieceval}[2]{% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This function produces a small circle at the coordinates (#1,#2) to serve as an isolated function value in a piecewise plot. \draw[thick,fill] ({#1},{#2}) circle (0.055);}
\begin{document} \begin{tikzpicture} \varaxes{5}{5}{x}{y} %% \function{-4}{5}{orange!90!pink!80}{-0.05*(\x)^3+0.25*(\x)^2-0.5} %% \varfunction{0.0001}{5}{blue}{ln(\x)*sin(120*\x)}{700} %% \varfunction{-5}{-0.0001}{blue}{ln(-\x)*sin(120*\x)}{700} \end{tikzpicture} \begin{tikzpicture} \polaraxes{5} %% \parafunction{0}{3}{red}{sin(120*\x)-2}{-1+(cos(120*\x)-1)^2}{500} %% \polarfunction{-8}{8}{cyan}{0.125*(\x)^2}{500} \end{tikzpicture} \begin{tikzpicture} \asymaxes{3}{8}{2}{5}{s}{t} %% \piece{-3.25}{-2}{0}{0}{black}{-(\x+2)^2+3}{100} \piece{-2}{-1}{1}{1}{black}{2}{5} \piece{-1}{0}{0}{1}{black}{ln(abs(\x)+1)+2}{100} \piece{0}{2}{0}{1}{black}{(\x-1)^2}{100} \piece{2}{3}{0}{0}{black}{0.5*\x+0.5}{100} \pieceval{3}{2.5} \piece{3}{5}{0}{1}{black}{0.5*\x-0.5}{100} \piece{5}{8.25}{0}{0}{black}{0.25*sin(360*\x)+3}{100} \end{tikzpicture}\end{document}
FunctionPlotting.pdf