Skip to content

tkz-fn examples

Area between two curves

Area between two curves
View TeX code
% !TEX TS-program = lualatex
\documentclass[border=12pt]{standalone}
\usepackage{tkz-fn}
\begin{document}
\begin{tikzpicture}[scale=3]
  \tkzFnInit[xmin=0,xmax=1.5,xstep=0.5,ymin=0,ymax=1.5,ystep=0.5]
  \tkzFnGrid
  \tkzFnAxes
  \tkzFnDef{f}{sqrt(x)}
  \tkzFnDef{g}{x^2}
  \tkzFnDef{h}{sqrt(x) - x^2}
  \tkzFnArea[fill=orange!40,domain=0:1](f,g)
  \tkzFnDraw[thick,red,domain=0:1.5](f)
  \tkzFnDraw[thick,blue,domain=0:1.22](g)
  \tkzFnDefPoint(f,1.4){P}
  \tkzFnText[above left,text=red](P){$y=\sqrt{x}$}
  \tkzFnDefPoint(g,1.15){Q}
  \tkzFnText[right,text=blue](Q){$y=x^2$}
  \tkzFnText(1.1,0.25){$\displaystyle\int_0^1\!\big(\sqrt{x}-x^2\big)\,dx
     \approx \tkzFnPrint[4]{integral(h,0,1)}$}
\end{tikzpicture}
\end{document}