2
0
Fork 0
mirror of https://github.com/MartinThoma/LaTeX-examples.git synced 2025-04-26 06:48:04 +02:00
LaTeX-examples/tikz/cubic-function/cubic-function.tex
Martin Thoma 7740f0147f Remove trailing spaces
The commands

find . -type f -name '*.md' -exec sed --in-place 's/[[:space:]]\+$//' {} \+

and

find . -type f -name '*.tex' -exec sed --in-place 's/[[:space:]]\+$//' {} \+

were used to do so.
2015-10-14 14:25:34 +02:00

53 lines
1.7 KiB
TeX

\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}