こんにちは!M2の加藤です.

最近tikzで図を書くことにハマっているので,コードを公開しようと思います.
以下は今日のゼミで発表した「最小化問題の基本概念」のスライド中で使った図たちです.

使っていただけたら嬉しいです(o*°▽°)o
pdfはこちら

\documentclass[11pt]{jsarticle}
\renewcommand{\figurename}{Fig.}
%%%%% 図 %%%%%
\usepackage[dvipdfmx]{graphicx}
\usepackage{tikz,pgfplots}
\usetikzlibrary{intersections}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{calc}
\usepackage{float}
%%%%% 数式 %%%%%
\usepackage{amsmath}
\usepackage{amsthm}
%%%%% ページレイアウト%%%%%
\setlength{\textwidth}{40zw}
\setlength{\textheight}{40\baselineskip}
\usepackage[top=25truemm,bottom=23truemm,left=20truemm,right=20truemm]{geometry}
%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%
\begin{document}
\title{tikzによる作図}
\author{長江研究室\quad M2\quad 加藤 桃子}
\date{2014年6月5日}
\maketitle
%%%%%%%%%%%%%%%%% 
%%%%%%%%%%%%%%%%% 
\begin{figure}[H]
  \centering
  \begin{tikzpicture}[scale=1]
    \draw[->,color=black] (0,0) -- (10,0);
    \draw[color=black] (10,0) node[right] {$x$};% x軸
    \draw[->,color=black] (0,0) -- (0,6);
    \draw[color=black] (0,6) node[left] {$z(x)$};% z(x)軸
    \draw (0,4) parabola bend(2,1) (3,2) parabola bend(4,3) (5,4) parabola bend(6,5)
    (7,4) parabola bend(8,3) (10,6);% 曲線(parabola bend(x,y)は放物線の傾きが0
    % になる点)
    \fill (2,1) circle (2pt) node[anchor=north east] {極小値};% 点とその斜め下
    % に「極小値」                             
    \fill (4,3) circle (2pt) node[above=2mm] {変曲点};
    \fill (6,5) circle (2pt) node[above] {極大値};
    \fill (8,3) circle (2pt) node[anchor=north west] {極小値}; 
    \draw[dashed] (2,1) -- (2,0) node[below]{$a$};% 点線の終わりにa
    \draw[dashed] (4,3) -- (4,0) node[below]{$b$};
    \draw[dashed] (6,5) -- (6,0) node[below]{$c$};
    \draw[dashed] (8,3) -- (8,0) node[below]{$d$};
  \end{tikzpicture}
  \caption{}
\end{figure}
%%%%%%%%%%%%%%%%% 
\begin{figure}[H]
  \centering
  \begin{tikzpicture}[scale=1]
    \def\tangentlength{5cm};% \tangentlengthという5cmの直線を定義
    \draw [,thick] (0,6) node (yaxis) [above] {$z(x)$}% z(x)軸
    |- (9,0) node (xaxis) [right] {$x$};% z(x)軸と直交するようにx軸
    \draw [name path=C1] (1,5) parabola bend(4,1) (7,4);% 曲線C1
    \path [name path=L1] (4.5,0) -- (4.5,4);% 直線L1
    \path[name path=L1'] ($(4.5,0)+(1pt,0)$) -- ($(4.5,4)+(1pt,0)$);% 直線
    % L1よりわずかにずれた所にL1'
    \path[name intersections={of=C1 and L1}];% C1とL1の交点を求める
    \coordinate (a) at (intersection-1);% 交点の座標を(a)とする
    \path[name intersections={of=C1 and L1'}];
    \coordinate (b) at (intersection-1);
    \draw[name path=L2]
    ($(a)!-\tangentlength/2!(b)$)--($(a)!\tangentlength/2!(b)$);% (a),(b)
    % を通る長さ\tangentlengthの直線を引く
    \path[name path=L3] (6.3,0) -- (6.3,5);
    \path[name intersections={of=C1 and L3}];
    \coordinate (c) at (intersection-1);
    \path[name intersections={of=L2 and L3}];
    \coordinate (d) at (intersection-1);
    \draw[dashed] (a) -- (a |- xaxis) node[below] {$x_1$};% (a)からx軸に垂
    % 線を下ろし,x軸の下にx_1と書く
    \draw[dashed] (c) -- (c |- xaxis) node[below] {$x_2$};
    \draw[dashed] (c) -- (c -| yaxis) node[left] {$z(x_2)$};
    \draw[dashed] (d) -- (d -| yaxis) node[left] {$z(x_1)+\dfrac{dz(x_1)}{dx}(x_2-x_1)$};
  \end{tikzpicture}
  \caption{}
\end{figure}
%%%%%%%%%%%%%%%%% 
\begin{figure}[H]
  \centering
  \begin{tikzpicture}[scale=1]
    \draw[->,thick] (-1,0) -- (7,0);
    \draw (7,0) node[right] {$x$};
    \draw[->,thick] (0,-1) -- (0,6);
    \draw (0,6) node[above] {$z(x)$};
    \draw [name path=C1] (-0.5,4) parabola bend(2,1) (6,3);
    \draw[dashed, name path=L2] (5,6) -- (5,-1) node[below] {$x=a^{''}$};
    \draw[dashed, name path=L1] (3,6) -- (3,-1) node[below] {$x=a^{'}$};
    \path[name intersections={of=C1 and L1}];
    \coordinate (c) at (intersection-1);
    \fill (c) circle (2pt) node[below] {最小値};
    \fill[gray, opacity=.3] (3,6) -- (-1,6) -- (-1,-1) -- (3,-1);% グレー,
    % 透明度0.3の領域を描く
    \fill[gray, opacity=.3] (7,6) -- (5,6) -- (5,-1) -- (7,-1);
  \end{tikzpicture}
  \caption{}
\end{figure}
%%%%%%%%%%%%%%%%% 
\begin{figure}[H]
  \centering
  \begin{tikzpicture}[scale=1]
    \draw[->,thick] (-1,0) -- (7,0);
    \draw (7,0) node[right] {$x_1$};
    \draw[->,thick] (0,-1) -- (0,6);
    \draw (0,6) node[above] {$x_2$};
    \fill[blue,opacity=0.4] (1,1) circle [x radius=6mm, y radius=5mm]; % 青,透
    % 明度0.4,中心(1,1),x方向6mm,y方向5mmの楕円を描く
    \fill[blue,opacity=0.4] (1.2,1.3) circle [x radius=12mm, y radius=10mm]; 
    \fill[blue,opacity=0.4] (1.5,1.7) circle [x radius=20mm, y radius=17mm];
    \fill[blue,opacity=0.3] (1.9,2.1) circle [x radius=28mm, y radius=25mm];
    \fill[blue,opacity=0.2] (2.2,2.3) circle [x radius=36mm, y radius=30mm];% 等高線
    \draw[thick, name path=L2] (1.1,1) -- node[left]{$g_2$} (0.2,3.5);
    \draw[thick, name path=L1] (0.1,3.3) --  node[left]{$g_1$} (2.6,5);
    \draw[thick, name path=L6] (2.4,5) --  node[right]{$g_6$} (5,3.7);
    \draw[thick, name path=L5] (4.8,3.9) --  node[right]{$g_5$} (4.6,1.6);
    \draw[thick, name path=L4] (4.8,2) --  node[below]{$g_4$} (2.6,0.5);
    \draw[thick, name path=L3] (3,0.5) --  node[below]{$g_3$} (0.9,1.2);% 制約条件
    \path[name intersections={of=L2 and L3}];% L2とL3の交点を求める
    \coordinate (a) at (intersection-1);% 交点の座標を(a)と名付ける
    \draw[dashed] (a) -- (a |- xaxis) node[below] {$x_1^*$};% aからx軸に点線を下
    % ろす
    \draw[dashed] (a) -- (a -| yaxis) node[left] {$x_2^*$};% aからy軸に点線を
    % 下ろす
    \fill[red] (a) circle (2pt);
  \end{tikzpicture}
  \caption{}
\end{figure}
%%%%%%%%%%%%%%%%% 
\begin{figure}[H]
  \centering
  \begin{tikzpicture}[scale=1]
    \fill[blue,opacity=0.4] (1,1) circle [x radius=6mm, y radius=5mm]; 
    \fill[blue,opacity=0.4] (1.2,1.3) circle [x radius=12mm, y radius=10mm]; 
    \fill[blue,opacity=0.4] (1.5,1.7) circle [x radius=20mm, y radius=17mm];
    \draw[thick, name path=L2] (1.1,1) -- node[left]{$g_2$} (0.2,3.5);
    \draw[thick, name path=L3] (3,0.5) --  node[below]{$g_3$} (0.9,1.2);% 制約条件
    \path[name intersections={of=L2 and L3}];% L2とL3の交点を求める
    \coordinate (a) at (intersection-1);% 交点の座標を(a)と名付ける
    \draw[->] (a) -- ($(0.1,1)!(a)!(-0.8,3.5)$) node[left]{$-\nabla g_2$};% L2と平行な線分に垂線を下ろす
    \draw[->] (a) -- ($(2,0)!(a)!(-0.1,0.7)$) node[below]{$-\nabla g_3$};% L3と平行な線分に垂線を下ろす
    \draw[->] (a) -- (0.2,0.2) node[left]{$-\nabla z$};
  \end{tikzpicture}
  \caption{}
\end{figure}
%%%%%%%%%%%%%%%%% 
\begin{figure}[H]
  \centering
  \begin{tikzpicture}[scale=1]
    \draw [->,thick] (-4,0) -- (4,0);
    \draw (4,0) node[right] {$x$};% x軸
    \draw [->,thick] (0,-3) -- (0,3);
    \draw (0,3) node[above] {$L(x,u)$};% y軸
    \draw [->,thick] (-2,-2.5) -- (2,2.5);
    \draw (2,2.5) node[above] {$u$};% u軸
    \fill[blue,opacity=.6] (-3,-1.5) parabola[bend at end](-2.5,1.5) parabola[bend
    at start](-2,1.2) parabola[bend at
    end](0,0) parabola[bend at start](2,1.2) parabola[bend at end](2.5,1.5)
    parabola[bend at start](2,-1.5) -- (-3,-1.5);% 手前
    \fill[blue,opacity=.3] (-2.5,1.5) parabola[bend
    at start](-2,1.2) parabola[bend at
    end](0,0) parabola[bend at start](2,1.2) parabola[bend at end](2.5,1.5)
    parabola[bend at start](3,-0.5) -- (-2,-0.5) parabola[bend at
    end](-2.5,1.5);% 奥
    \fill[red] circle (2pt) node[above] {鞍点};
  \end{tikzpicture}
  \caption{}
\end{figure}
%%%%%%%%%%%%%%%%% 
\begin{figure}[H]
  \centering
  \begin{tikzpicture}[scale=1]
    \draw[->,thick] (-1,0) -- (7,0);
    \draw (7,0) node[right] {$x_1$};
    \draw[->,thick] (0,-1) -- (0,6);
    \draw (0,6) node[above] {$x_2$};
    \fill[blue,opacity=0.2] (-1,1) -- (-1,-1) -- (1,-1);
    \fill[blue,opacity=0.2] (-1,3) -- (-1,-1) -- (3,-1);
    \fill[blue,opacity=0.2] (-1,5) -- (-1,-1) -- (5,-1);
    \fill[blue,opacity=0.2] (-1,6) -- (-1,-1) -- (7,-1) -- (0,6);
    \fill[blue,opacity=0.2] (-1,6) -- (-1,-1) -- (7,-1) -- (7,1) -- (2,6);
    \fill[blue,opacity=0.1] (-1,6) -- (-1,-1) -- (7,-1) -- (7,3) -- (4,6);
    \fill[blue,opacity=0.1] (-1,6) -- (-1,-1) -- (7,-1) -- (7,6);% 目的関数の降下方向
    \draw[thick, name path=L2] (1.1,1) -- (0.2,3.5);
    \draw[thick, name path=L1] (0.1,3.3) -- (2.6,5);
    \draw[thick, name path=L6] (2.4,5) --  (5,3.7);
    \draw[thick, name path=L5] (4.8,3.9) -- (4.6,1.6);
    \draw[thick, name path=L4] (4.8,2) --  (2.6,0.5);
    \draw[thick, name path=L3] (3,0.5) --  (0.9,1.2);% 制約条件
    \path[name intersections={of=L2 and L3}];% L2とL3の交点を求める
    \coordinate (a) at (intersection-1);% 交点の座標を(a)と名付ける
    \fill[red] (a) circle (2pt);% (d)に赤い点を置く
  \end{tikzpicture}
\end{figure}
%%%%%%%%%%%%%%%%% 
\begin{figure}[H]
  \centering
  \begin{tikzpicture}[scale=1]
    \draw [,thick] (0,5) node (yaxis) [above] {$z(x_1,x_2)$}
    |- (8,0) node (xaxis) [right] {$x_1$};
    \draw [->,thick] (0,0) -- (-2,-3);
    \draw (-2,-3) node[below] {$x_2$};
    \fill[blue,opacity=.7] (1,2) to [out=-80,in=-180] (4,-2) to [out=0,in=-100]
    (6,0) parabola[bend at end](5,-0.3) parabola[bend at start](1,2);% お碗
    \fill[blue,opacity=.5] (1,2) parabola[bend at end](5,-0.3) parabola[bend at
    start](6,0) parabola[bend at end](2,2.3) parabola[bend at start](1,2);% 断面
    \draw[thick] (2.5,1.5) -- (4.5,-1);
    \fill (2.5,1.5) circle (2pt);
    \fill (4.5,-1) circle (2pt);
  \end{tikzpicture}
\end{figure}
%%%%%%%%%%%%%%%%% 
%%%%%%%%%%%%%%%%% 
\end{document}