Saturday, March 15, 2014

TikZ: Mengarsir Daerah antara Dua Kurva

Pada tulisan ini saya tampilkan salah satu paket untuk menggambar, yaitu TikZ, dalam menggambar luas daerah yang dibatasi oleh dua kurva dengan interval tertentu.
Materi ini merupakan bagian dari konsep Integral (Kalkulus).

Dalam pengkodean, pada contoh dokumen di bawah ini, saya juga menyertakan penggunaan paket bclogo (untuk menempatkan tulisan dalam suatu "kotak" dengan "hiasan" tertentu), paket adjustbox (yang saya gunakan agar environment minipage menempatkan tulisan di dalamnya "merapat" ke atas), paket geometry (untuk mengatur ukuran halaman), definisi warna, jenis huruf (Computer Concrete) dan environment fbox (untuk menempatkan frase dalam kotak).

Dokumen ini saya susun melalui writeLaTeX.
Demikian semoga bermanfaat!

Adjie Gumarang Pujakelana 2014
\documentclass{article}
\title{Daerah Dua Kurva}
\usepackage{tikz}
\usepackage{adjustbox}
\usepackage[lmargin=3cm,rmargin=2cm,tmargin=2cm,bmargin=2cm]{geometry}
\usepackage[tikz]{bclogo}
\definecolor{bgblue}{RGB}{245,243,253}
\definecolor{wine-stain}{rgb}{0.5,0,0}

\begin{document}
\pagenumbering{gobble}

\begin{bclogo}[
couleur = bgblue,
marge=20, blur,
cadreTitre = true, 
arrondi = 0.3, 
epBarre=3.5,
logo = \Huge\bccrayon, 
couleurOmbre=gray, 
couleurBarre=orange!30,
couleurBord=orange!30!gray!60,
ombre=true,
couleurOmbre = blue!20!black!20]
{\Large\color{wine-stain} Mengarsir Daerah antara Dua Kurva dengan TikZ}
\vspace{25pt}
\adjustbox{valign=t}{\begin{minipage}[t]{0.5\textwidth}
\centering
\begin{tikzpicture}
\draw[->] (-1,0) -- (3,0) node[right] {$x$};
\draw[->] (0,-1) -- (0,5) node[left] {$y$};
\draw [-,samples=100,domain=-0.5:2.3] plot(\x,{2*\x});
\draw [-,samples=100,domain=-1:2.5] plot(\x,{\x});
\draw [fill=brown,fill opacity=0.2] plot [smooth,samples=100,domain=0:2](\x,{\x}) -- plot [smooth,samples=100,domain=2:0] (\x,{2*\x});
\draw[dashed, ultra thin,gray] (2,0) -- (2,2) node[below] {};
\draw (2,0) node[below] {$2$};
\draw (2.55,2.65) node[right] {$y=x$};
\draw (2.32,4.84) node[right] {$y=2x$};
\end{tikzpicture}
\end{minipage}}\hfill
%
\adjustbox{valign=t}{\begin{minipage}[t]{0.5\textwidth}
\centering
\begin{tikzpicture}
\draw[->] (-2.3,0) -- (2,0) node[right] {$x$};
\draw[->] (0,-2.5) -- (0,3) node[left] {$y$};
\draw [-,samples=100,domain=-2.14:1.7] plot(\x,{(\x)^2-2});
\draw [-,samples=100,domain=-2.3:1.5] plot(\x,{-\x});
\draw [fill=brown,fill opacity=0.2] plot [smooth,samples=100,domain=-2:1](\x,{-\x}) -- plot [smooth,samples=100,domain=1:-2] (\x,{(\x)^2-2});
\draw[dashed, ultra thin,gray] (-2,0) -- (-2,2) node[below] {};
\draw[dashed, ultra thin,gray] (1,0) -- (1,-1) node[below] {};
\draw (-2,0) node[below] {$2$};
\draw (1,0) node[above] {$1$};
\draw (1.68,0.86) node[above] {$y=x^2-2$};
\draw (1.48,-1.38) node[right] {$y=-x$};
\end{tikzpicture}
\end{minipage}}\hfill

\bigskip
\adjustbox{valign=t}{\begin{minipage}[t]{0.5\textwidth}
\centering
\begin{tikzpicture}
\draw[->] (-3,0) -- (3,0) node[right] {$x$};
\draw[->] (0,-1) -- (0,5) node[left] {$y$};
\draw [-,samples=100,domain=-2.2:1.5] plot(\x,{-(\x)^2+4});
\draw [-,samples=100,domain=-2.5:1.5] plot(\x,{\x+2});
\draw [fill=brown,fill opacity=0.2] plot [smooth,samples=100,domain=-2:1](\x,{\x+2}) -- plot [smooth,samples=100,domain=1:-2] (\x,{-(\x)^2+4});
\draw (-2,0) node[above left] {$-2$};
\draw (1,0) node[below] {$1$};
\draw (1.48,3.68) node[right] {$y=x+2$};
\draw (1.44,1.63) node[right] {$y=-x^2+4$};
\draw[dashed, ultra thin,gray] (1,0) -- (1,3) node[below] {};
\end{tikzpicture}
\end{minipage}}\hfill
%
\adjustbox{valign=t}{\begin{minipage}[t]{0.5\textwidth}
\centering
\begin{tikzpicture}[scale=0.8]
\draw[->] (-1,0) -- (5,0) node[right] {$x$};
\draw[->] (0,-1) -- (0,5) node[left] {$y$};
\draw [-,samples=100,domain=-0.5:3] plot(\x,{\x});
\draw [-,samples=100,domain=-0.5:4.5] plot(\x,{4-\x});
\draw [fill=brown,fill opacity=0.2] plot [smooth,samples=100,domain=0:2](\x,{4-\x}) -- plot [smooth,samples=100,domain=2:0] (\x,{\x});
\draw[dashed, ultra thin,gray] (2,0) -- (2,2) node[below] {};
\draw (2,0) node[below] {$2$};
\draw (3,3.18) node[right] {$y=x$};
\draw (3.32,0.9) node[right] {$y=4-x$};
\end{tikzpicture}
\end{minipage}}\hfill

\bigskip
\adjustbox{valign=t}{\begin{minipage}[t]{0.5\textwidth}
\centering
\begin{tikzpicture}[scale=1.5]
\draw[->] (-1.5,0) -- (2,0) node[right] {$x$};
\draw[->] (0,-1) -- (0,2.5) node[left] {$y$};
\draw [-,samples=100,domain=-1:1.5] plot(\x,{(\x)^2});
\draw [-,samples=100,domain=-0.7:1.7] plot(\x,{\x});
\draw [fill=brown,fill opacity=0.2] plot [smooth,samples=100,domain=0:1](\x,{\x}) -- plot [smooth,samples=100,domain=1:0] (\x,{(\x)^2});
\draw (1.52,2.31) node[right] {$y=x^2$};
\draw (1.68,1.78) node[below right] {$y=x$};
\draw[dashed, ultra thin,gray] (1,0) -- (1,1) node[below] {};
\draw (1,0) node[below] {$1$};
\end{tikzpicture}
\end{minipage}}\hfill
%
\adjustbox{valign=t}{\begin{minipage}[t]{0.5\textwidth}
\centering
\begin{tikzpicture}[scale=0.7]
\draw[->] (-3,0) -- (3.5,0) node[right] {$x$};
\draw[->] (0,-4.5) -- (0,5) node[left] {$y$};
\draw [-,samples=100,domain=-2.2:2.4] plot(\x,{(\x)^2-4});
\draw [-,samples=100,domain=-2.4:2.3] plot(\x,{4-(\x)^2});
\draw [fill=brown,fill opacity=0.2] plot [smooth,samples=100,domain=-2:2](\x,{4-(\x)^2}) -- plot [smooth,samples=100,domain=2:-2] (\x,{(\x)^2-4});
\draw (2.3,1.29) node[right] {$y=x^2-4$};
\draw (2.3,-1.29) node[right] {$y=4-x^2$};
\draw (2,0) node[below right] {$2$};
\draw (-2,0) node[below left] {$-2$};
\end{tikzpicture}
\end{minipage}}\hfill
\end{bclogo}

\end{document}


-->
Related Posts Plugin for WordPress, Blogger...