mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-26 06:48:04 +02:00
added plot of cubic function
This commit is contained in:
parent
2dba607a6b
commit
2d7f2ff7c5
2 changed files with 84 additions and 0 deletions
53
tikz/cubic-function/cubic-function.tex
Normal file
53
tikz/cubic-function/cubic-function.tex
Normal file
|
@ -0,0 +1,53 @@
|
|||
\documentclass{article}
|
||||
\usepackage[pdftex,active,tightpage]{preview}
|
||||
\setlength\PreviewBorder{2mm}
|
||||
|
||||
\usepackage{pgfplots}
|
||||
\usepackage{tikz}
|
||||
\usetikzlibrary{arrows, positioning, calc, intersections}
|
||||
|
||||
\begin{document}
|
||||
|
||||
% Define this as a command to ensure that it is same in both cases
|
||||
\newcommand*{\ShowIntersection}[2]{
|
||||
\fill
|
||||
[name intersections={of=#1 and #2, name=i, total=\t}]
|
||||
[red, opacity=1, every node/.style={above left, black, opacity=1}]
|
||||
\foreach \s in {1,...,\t}{(i-\s) circle (2pt)
|
||||
node [above left] {\s}};
|
||||
}
|
||||
|
||||
\begin{preview}
|
||||
\begin{tikzpicture}
|
||||
\begin{axis}[
|
||||
axis x line=middle,
|
||||
axis y line=middle,
|
||||
width=15cm, height=15cm, % size of the image
|
||||
grid = major,
|
||||
grid style={dashed, gray!30},
|
||||
%xmode=log,log basis x=10,
|
||||
%ymode=log,log basis y=10,
|
||||
xmin=-2, % start the diagram at this x-coordinate
|
||||
xmax= 4, % end the diagram at this x-coordinate
|
||||
ymin=-7, % start the diagram at this y-coordinate
|
||||
ymax= 7, % end the diagram at this y-coordinate
|
||||
%/pgfplots/xtick={0,1,...,60}, % make steps of length 5
|
||||
%extra x ticks={23},
|
||||
%extra y ticks={0.507297},
|
||||
axis background/.style={fill=white},
|
||||
ylabel=y,
|
||||
xlabel=x,
|
||||
%xticklabels={,,},
|
||||
%yticklabels={,,},
|
||||
tick align=outside,
|
||||
tension=0.08]
|
||||
% plot the stirling-formulae
|
||||
\addplot[name path global=a, domain=-2:4, red, thick,samples=500]
|
||||
{-x*x*x + 4*x*x-x-4};
|
||||
\addplot[name path global=b, domain=0.25:4, blue, thick, dashed] {x-1.2};
|
||||
\addplot[name path global=c, domain=0.25:4, blue, thick, dashed] {x+0.42};
|
||||
\ShowIntersection{a}{b};
|
||||
\end{axis}
|
||||
\end{tikzpicture}
|
||||
\end{preview}
|
||||
\end{document}
|
Loading…
Add table
Add a link
Reference in a new issue