
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)
. 둘은 서로 바꿔 사용할 수 없습니다. 함수 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
그리고 if x=0
then은 for 또는 for atan(y/x)
동안 정의되지 않습니다 . 이 정의 (또는 동등하게 )는 수학과 C, FORTRAN, matlab을 포함한 일반 프로그래밍 언어 모두에서 동일합니다.atan2(y,x)=pi/2
y>0
-pi/2
y<0
atan2
arctan2
답변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)$