Преглед изворни кода

added example for taylor polynoms

Martin Thoma пре 13 година
родитељ
комит
a7e3e56a42

+ 31 - 0
tikz/taylorpolynom-sin/Makefile

@@ -0,0 +1,31 @@
+SOURCE = taylorpolynom-sin
+DELAY = 80
+DENSITY = 300
+WIDTH = 500
+
+make:
+	pdflatex -shell-escape $(SOURCE).tex -output-format=pdf
+	make clean
+
+clean:
+	rm -rf  $(TARGET) *.class *.html *.log *.aux *.data *.gnuplot *.table
+
+gif:
+	pdfcrop $(SOURCE).pdf
+	convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif
+	make clean
+
+png:
+	make
+	make svg
+	inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png
+
+transparentGif:
+	convert $(SOURCE).pdf -transparent white result.gif
+	make clean
+
+svg:
+	#inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg
+	pdf2svg $(SOURCE).pdf $(SOURCE).svg
+	# Necessary, as pdf2svg does not always create valid svgs:
+	inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg

+ 32 - 0
tikz/taylorpolynom-sin/taylorpolynom-sin-pgf.tex

@@ -0,0 +1,32 @@
+\documentclass[varwidth=true, border=2pt]{standalone}
+
+\usepackage{pgfplots}
+\usepackage{tikz}
+\usetikzlibrary{arrows, positioning, calc}
+
+\begin{document}
+\begin{tikzpicture}
+    \begin{axis}[
+        axis x line=middle,
+        axis y line=middle,
+        enlarge y limits=true,
+        xmin=-8, xmax=8, % Positive domain...
+        width=15cm, height=8cm,     % size of the image
+        grid = major,
+        grid style={dashed, gray!30},
+        ymin=-4,      % start the diagram at this y-coordinate
+        ymax= 4,      % end   the diagram at this y-coordinate
+        axis background/.style={fill=white},
+        ylabel=$y$,
+        xlabel=$x$,
+        legend style={at={(0.07,0.35)}, anchor=north}
+     ]
+      \addplot[domain=-8:8,thick,samples=100,red] {x};
+      \addplot[domain=-8:8,thick,samples=100,green] {x-x^3/6};
+      \addplot[domain=-8:8,thick,samples=100,blue]  {x-x^3/6+x^5/120};
+      %\addplot[domain=-8:8,thick,samples=100,pink]  {x-x^3/6+x^5/120-x^7/5040+x^9/362880-x^11/3916800};
+      \addplot[domain=-8:8,thick,samples=100,black] {sin(deg(x))};
+      \legend{$T_1$, $T_3$, $T_5$, $T_{11}$, $T_\infty$}
+    \end{axis} 
+\end{tikzpicture}
+\end{document}

+ 39 - 0
tikz/taylorpolynom-sin/taylorpolynom-sin.tex

@@ -0,0 +1,39 @@
+\documentclass{article}
+\usepackage[pdftex,active,tightpage]{preview}
+\setlength\PreviewBorder{0mm}
+
+\usepackage{pgfplots}
+\usepackage{tikz}
+\usetikzlibrary{arrows, positioning, calc}
+
+\usepackage{xcolor}
+\definecolor{pink}{HTML}{FF0BB7}
+
+\begin{document}
+\begin{preview}
+\begin{tikzpicture}
+    \begin{axis}[
+        axis x line=middle,
+        axis y line=middle,
+        enlarge y limits=true,
+        xmin=-8.5, xmax=8.5, % Positive domain...
+        width=15cm, height=8cm,     % size of the image
+        grid = major,
+        grid style={dashed, gray!30},
+        ymin=-4,      % start the diagram at this y-coordinate
+        ymax= 4,      % end   the diagram at this y-coordinate
+        axis background/.style={fill=white},
+        ylabel=$y$,
+        xlabel=$x$,
+        legend style={at={(0.07,0.37)}, anchor=north}
+     ]
+      \addplot[domain=-8:8,thick,samples=200,red]   {x};
+      \addplot[domain=-8:8,thick,samples=200,green] {x-x^3/6};
+      \addplot[domain=-8:8,thick,samples=200,blue]  {x-x^3/6+x^5/120};
+      \addplot[domain=-8:8,thick,samples=200,pink]  {x-x^3/6+x^5/120-x^7/(7!)+x^9/(9!)-x^11/(11!)+x^13/(13!)-x^15/(15!)};
+      \addplot[domain=-8:8,thick,samples=200,black] {sin(deg(x))};
+      \legend{$T_1$, $T_3$, $T_5$, $T_{15}$, $T_\infty$}
+    \end{axis} 
+\end{tikzpicture}
+\end{preview}
+\end{document}