実行可能な地域

実行可能な地域

実行可能な領域をプロットしたいのですが、方法がわかりません。ガイダンスが必要です。

ここに画像の説明を入力してください

\documentclass[tikz, border=5mm]{standalone}

\begin{document}
    
    \begin{tikzpicture}
        
        \draw[gray!50, thin, step=0.5] (-1,-3) grid (5,4);
        \draw[very thick,->] (-1,0) -- (5.2,0) node[right] {$x_1$};
        \draw[very thick,->] (0,-3) -- (0,4.2) node[above] {$x_2$};
        
        \foreach \x in {-1,...,5} \draw (\x,0.05) -- (\x,-0.05) node[below] {\tiny\x};
        \foreach \y in {-3,...,4} \draw (-0.05,\y) -- (0.05,\y) node[right] {\tiny\y};
        
    
        
        \draw (-1,-3) -- node[above,sloped] {\tiny$x_1=-1$} (-1,3);
        
        \draw (0,0) -- node[above,sloped] {\tiny$x_1\leq x_2$} (3,3);
        \draw (0,0) -- node[above,sloped] {\tiny$x_1\leq x_2$} (3,-3);
        \draw (-1,3) -- node[above,sloped] {\tiny$x_2=3$} (3,3);
        \draw (-1,3) -- node[above,sloped] {\tiny$x_2=-3$} (3,3);
        
    \end{tikzpicture}
    
\end{document}

現在の結果:

結果

答え1

結果が正確にどのようになるかはわかりませんが、おそらくこれが役立つでしょう。

領域を描画する場合は、その領域の境界を表す線を連結する必要があります。連結しないと、連結されていない単一の線だけが作成されます。また、領域が図の一部をカバーしないようにする場合は、カバーしないものの前に配置する必要があります。

\documentclass[tikz, border=10pt]{standalone}

\begin{document}
    
    \begin{tikzpicture}

        \draw[gray!50, thin, step=0.5] (-1,-3) grid (5,4);

        \draw[fill=gray!10]
            (-1,-3) 
                -- node[above, sloped] {\tiny$x_1=-1$} (-1,3)
                -- node[above, sloped] {\tiny$x_2=3$} (3,3)
                -- node[above, sloped] {\tiny$x_1\leq x_2$} (0,0)
                -- node[above, sloped] {\tiny$x_1\leq -x_2$} (3,-3)
                -- node[above, sloped] {\tiny$x_2=-3$} cycle;

        \draw[very thick, ->] (-1,0) -- (5.2,0) node[right] {$x_1$};
        \draw[very thick, ->] (0,-3) -- (0,4.2) node[above] {$x_2$};
        
        \foreach \x in {-1,...,5} 
            \draw (\x,0.05) -- (\x,-0.05) 
            \ifnum\x=0\relax
                node[below right] {\tiny\x}
            \else
                node[below] {\tiny\x}
            \fi ;
        \foreach \y in {-3,...,4} 
            \draw (-0.05,\y) -- (0.05,\y) 
            \ifnum\y=0\else
                node[right] {\tiny\y}
            \fi ;

        \draw[very thick, <->] 
            (0:2) arc[start angle=0, end angle=45, radius=2] 
            node[midway, right] {\tiny$q$};

        \node[align=center] at (3,-2) {unstable \\ region};
        \node[align=center] at (1,-2) {stable \\ region};
        
    \end{tikzpicture}
    
\end{document}

ここに画像の説明を入力してください


ほとんどのラベルとグリッドを削除すると、次の図に似たものになります。

\documentclass[tikz, border=10pt]{standalone}

\begin{document}
    
    \begin{tikzpicture}

        \draw[fill=gray!10]
            (-1,-3) -- (-1,3) -- (3,3) -- (0,0) -- (3,-3) -- cycle;

        \draw[very thick, ->] (-1,0) -- (3,0) node[right] {$x_1$};
        \draw[very thick, ->] (0,-3) -- (0,3.5) node[above] {$x_2$};

        \draw[very thick, <->] 
            (0:2) arc[start angle=0, end angle=45, radius=2] 
            node[midway, right] {$q$};

        \node[align=center] at (3,-2) {unstable \\ region};
        \node[align=center] at (1,-2) {stable \\ region};
        
    \end{tikzpicture}
    
\end{document}

ここに画像の説明を入力してください

関連情報