Skip to content

tkz-fn examples

Tangent lines

Tangent lines
View TeX code
% !TEX TS-program = lualatex
\documentclass[border=12pt]{standalone}
\usepackage{tkz-fn}
\begin{document}
\begin{tikzpicture}
  \tkzFnInit[xmin=-3,xmax=3,ymin=-3,ymax=3]
  \tkzFnGrid
  \tkzFnAxes
  \tkzFnDef{f}{x^3/3 - x}
  \tkzFnDraw[thick,red,domain=-2.5:2.5](f)
  % horizontal tangents at the extrema, oblique tangent at the inflection point
  \tkzFnTangent[color=blue,kl=1.5,kr=1.5](f,-1)
  \tkzFnTangent[color=blue,kl=1.5,kr=1.5](f,1)
  \tkzFnTangent[color=teal,kl=1.5,kr=1.5](f,0)
  \tkzFnTangent[color=orange,kl=0.8,kr=0.3](f,2)
  \tkzFnDefPoint(f,-1){A}
  \tkzFnDefPoint(f,1){B}
  \tkzFnDefPoint(f,0){I}
  \tkzFnDefPoint(f,2){C}
  \tkzFnDrawPoints(A,B,I,C)
  \tkzFnLabelPoints[above](A)
  \tkzFnLabelPoints[below](B)
  \tkzFnLabelPoints[above left](I)
  \tkzFnLabelPoints[left](C)
  \tkzFnText[fill=white](-1.6,2.5){slope at $C$: $\tkzFnPrint{diff(f,2)}$}
\end{tikzpicture}
\end{document}