使用 Tikz 填充区域

使用 Tikz 填充区域

我想要填充下图中标题中提到的区域。

\documentclass[11pt]{scrartcl}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{float}
\usepackage{tikz}
\usetikzlibrary{patterns}

\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}[domain=-1:12, range=-1:12, scale=0.7, thick, font=\small]
\node [left, color=orange] at (0, 9) {$9$};
\node [below, color=orange] at (3, 0) {$3$};
\draw [ultra thick, color=cyan, smooth, samples = 1000, domain={0.57}:{14}] plot (\x, {8/\x)});
\draw [ultra thick, color=cyan, smooth, samples = 1000, domain={0}:{3}] plot (\x, {9 - \x^2});
\draw[->] (-1.5, 0) -- (15, 0) node [right] {$x_1$};
\draw[->] (0, -1.5) -- (0, 15) node [above] {$x_2$};
\end{tikzpicture}
\caption{Fill the are $x_1^2 + x_2 \ge 9$ and $x_1x_2 \le 8$}
\end{figure}
\end{document}

参见下图。请注意问题有两个函数,但物质中的 $x$ 轴有三个。

如何填充该区域?

答案1

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[domain=-1:12, range=-1:12, scale=0.7, thick, font=\small]
\begin{scope}
\clip[smooth, samples = 1000, domain={0}:{3}]
    (0,8/0.57) -- plot (\x, {9 - \x^2}) -- (14,0) |- cycle;
\fill[red] [smooth, samples = 1000, domain={0.57}:{14}]
    (0,8/0.57) -- plot (\x, {8/\x)}) -- (14,0) -|  cycle;
\end{scope}

\draw[->] (-1.5, 0) -- (15, 0) node [right] {$x_1$};
\draw[->] (0, -1.5) -- (0, 15) node [above] {$x_2$};
\node [left, color=orange] at (0, 9) {$9$};
\node [below, color=orange] at (3, 0) {$3$};

\draw [ultra thick, color=cyan, smooth, samples = 1000, domain={0.57}:{14}] plot (\x, {8/\x)});
\draw [ultra thick, color=cyan, smooth, samples = 1000, domain={0}:{3}] plot (\x, {9 - \x^2});
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容