How do I plot the Fibonacci sequence (using tikzpicture preferably)?
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xmin=0, xmax=30, ymin=2, ymax=3]
\addplot[samples at={1,2,...,30}, only marks] expression {<Add Fibonacci sequence here>};
\end{axis}
\end{tikzpicture}
\end{document}
Edit
Since it seems more complicated than I thought, I went for the following solution: plot the discrete version of the continuous Fibonacci function, see for instance here. Any suggestions are surely still welcomed.
So now it goes like this:
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xmin=0, xmax=8, ymin=0, ymax=14, xlabel=$n$, ylabel=$a_n$, axis x line=center, axis y line=center]
\addplot[samples at={0,1,...,7},only marks] expression {( ((1+sqrt(5))/(2))^\x - cos(deg(\x * pi)) * ((1+sqrt(5))/(2))^(-\x) )/sqrt(5) };
\end{axis}
\end{tikzpicture}
\end{document}
Best Answer
Here is a direct loop method :
EDIT: If you want to go to 30 (and more) you can use
xint
package.EDIT: Following the comment of @jfbu the following code will produce the same image:
NOTE: It is probably faster to use directly something like