Math & ScienceIllustration of a mathematical progression

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
Atticus_Freeze
Posts: 3
Joined: Thu Jun 30, 2011 12:01 pm

Illustration of a mathematical progression

Post by Atticus_Freeze »

I want to know how to make an illustration that plots a sequence such as ${a_n} = 1/n^2$, where n is a natural number, using either pstricks or tikZ. I don't want to use Mathematica or Maple to do this since I want to heavily customize my diagram with specific labels and markers to illustrate the idea of a convergent sequence in real analysis. Any help would be deeply appeciated!! :D
Last edited by Atticus_Freeze on Thu Jun 30, 2011 9:01 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

frederic
Posts: 9
Joined: Mon Jun 27, 2011 7:25 pm

Illustration of a mathematical progression

Post by frederic »

One possibility is as follows:

Code: Select all

\begin{tikzpicture}[xscale=0.5,yscale=4]
\draw[->] (0,0) -- (10,0) node[right] {$x$};
\draw[->] (0,0) -- (0,1) node[left] {$y$};

\foreach \n [evaluate=\n as \y using 1/\n^2] in {1,...,10}{
  \node at (\n,\y) {\tikz{\fill[blue] (0,0) circle[radius=1pt];}};
}

\end{tikzpicture}
I drew the dots within the nodes, this way they are not affected by the scaling factors of the beginning of the picture. To see this, replace the line with the node by simply

Code: Select all

\fill[blue] (\n,\y) circle[radius=1pt];
Note that this sequence is not a very nice sequence to draw, as it converges rather quickly to 0.
torbjorn t.
Posts: 162
Joined: Wed Jun 17, 2009 10:18 pm

Illustration of a mathematical progression

Post by torbjorn t. »

You could also write it as

Code: Select all

\begin{tikzpicture}[xscale=0.5,yscale=4]
\draw[->] (0,0) -- (10,0) node[right] {$x$};
\draw[->] (0,0) -- (0,1) node[left] {$y$};

\foreach \n [evaluate=\n as \y using 1/\n^2] in {1,...,10}{
  \node at (\n,\y) [fill=blue,circle,inner sep=0pt,minimum size=1pt] {};
}

\end{tikzpicture}
Another possibility using pgfplots:

Code: Select all

\documentclass[a4paper]{article}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[samples at={1,2,...,10},ymin=0]
  \addplot+[only marks,mark size=1pt] {1/x^2};
\end{axis}
\end{tikzpicture}
\end{document}
Atticus_Freeze
Posts: 3
Joined: Thu Jun 30, 2011 12:01 pm

Re: Illustration of a mathematical progression

Post by Atticus_Freeze »

Thank you very much, both of you. Also, 1/n^2, wasn't a good choice. I picked it hastily, but really, I just wanted an example for any convergent sequence. Thanks alot!
Post Reply