LaTeX で arctan2 / atan2 関数を使用するにはどうすればよいでしょうか?

LaTeX で arctan2 / atan2 関数を使用するにはどうすればよいでしょうか?

LaTeX には、他の三角関数のように美しい結果を印刷できる arctan2 / atan2 関数がありますか\sin \cos?

答え1

amsmathは、や、\DeclareMathOperator{\foo}{foo}に似たタイプセット、つまり直立フォントと正しい間隔の新しい演算子名を定義するために提供されます。\sin\cos\ln

\atantwoこれはと一緒に使用することもできます(2ただし、 はマクロ名の一部として許可されていないため、 となります) \atantwo

\documentclass{article}

\usepackage{amsmath}

\DeclareMathOperator{\atantwo}{atan2}

\DeclareMathOperator{\arctantwo}{arctan2}


\begin{document}

\[
\atantwo ( y, x)
\]

\[
\arctantwo ( y, x)
\]



\[
\sin (x y)
\]



\end{document}

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

注:atan2(y,x)関数 は極座標での角度を決定し、関数 と関連がありますが、関数 とは異なりますatan(y/x)。この 2 つは互換性がありません。atan関数 の出力範囲は です(-pi/2,pi/2)が、atan2関数 の出力範囲は です(-pi,pi]。 の場合はx>0ですatan2(y,x)=atan(y/x)。 の場合x<0は ですatan2(y,x)=atan(y/x) +/- pi。またx=0の場合atan(y/x)は が未定義ですが、またはの場合は です。 のこの定義(または同等の) は、数学でも、C、FORTRAN、matlab などの一般的なプログラミング言語でも同じです。atan2(y,x)=pi/2y>0-pi/2y<0atan2arctan2

答え2

必要に応じて、もう少し賢くして\atan2\arctan2

\long\def\gobbleone#1{}
\protected\def\atan{\futurelet\tmptoken\doatan}
\protected\def\doatan{\operatorname{atan\ifx\tmptoken22\fi}%
  \ifx\tmptoken2\expandafter\gobbleone\fi}
\protected\def\arctan{\futurelet\tmptoken\doarctan}
\protected\def\doarctan{\operatorname{arc\,tan\ifx\tmptoken22\fi}%
  \ifx\tmptoken2\expandafter\gobbleone\fi}

$\atan2(y, x) \arctan2(y, x) \sin(x, y)$

答え3

別のオプションとしては、 を使用することです\mathrm。つまり、

$\mathrm{atan2}$
$\mathrm{arctan2}$

これにより

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

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

関連情報