下記のコードでは次のエラーが発生します:
パッケージ PGF 数学エラー: 不明な演算子c' or
co' ('{4cos(deg(x))}' 内)。
パッケージ PGF 数学エラー: 不明な演算子p' or
pi' ('2pi' 内)。
パッケージ PGF 数学エラー: 不明な演算子p' or
pi' ('2pi' 内)。
助けてください
\documentclass{article}
\usepackage{graphicx} % Required for inserting images
\usepackage{amsmath}
\usepackage[a4paper, total={6in, 8in}]{geometry}
\usepackage{graphicx} % Required for inserting images
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=0.8]
\draw[<->] (-4,0) -- (4,0) node[right] {$x$};
\draw[<->] (0,-4) -- (0,4) node[above] {$y$};
\draw[dashed] (0,-4) -- (0,4);
\draw[blue,thick,->] plot [domain=0:2pi,samples=100] ({0},{4cos(deg(x))});
\draw[red,thick,->] plot [domain=0:2pi,samples=100] ({0},{-4cos(deg(x))});
\end{tikzpicture}
\end{center}
\end{document}
答え1
これを試して:
\documentclass{article}
\usepackage{graphicx} % Required for inserting images
\usepackage{amsmath}
\usepackage[a4paper, total={6in, 8in}]{geometry}
\usepackage{graphicx} % Required for inserting images
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=0.8]
\draw[<->] (-4,0) -- (4,0) node[right] {$x$};
\draw[<->] (0,-4) -- (0,4) node[above] {$y$};
\draw[dashed] (0,-4) -- (0,4);
\draw[blue,thick,domain=0:{2*pi},samples=100] plot ({\x},{4*cos(\x r)});
\draw[red,thick,domain=0:{2*pi},samples=100] plot ({\x},{-4*cos(\x r)});
\end{tikzpicture}
\end{center}
\end{document}