타원곡선을 그리려고 합니다.
어쨌든 곡선은 점의 가까운 범위(-2.1,0)에서 중단됩니다. 그렇기 때문에 이 지점에서는 약간의 틈이 생기고 두 기능이 연결되지 않아 보기에도 좋지 않습니다.
이미 비슷한 문제에 직면한 사람이 있거나 이 문제를 해결하는 방법에 대한 아이디어가 있습니까?
이것은 내 코드입니다.
\begin{figure}[h]
\centering
\begin{tikzpicture}
\begin{axis}[
xmin=-3,
xmax=4.5,
ymin=-7,
ymax=7,
xlabel={$x$},
ylabel={$y$},
scale only axis,
axis lines=middle,
domain=-3:3.45,
samples=200,
smooth,
clip=false,
axis equal image=true,
]
\addplot [blue] {sqrt(x^3-3*x+3)};
\addplot [blue] {-sqrt(x^3-3*x+3)};
\end{axis}
\end{tikzpicture}
\end{figure}
답변1
여기에 줄거리를 한 번에 그려보자는 제안이 있습니다. LaTeX 없이 수식을 추가하는 것은 고통스럽기 때문에 코드에 설명이 있습니다.
\documentclass[fleqn]{article}
\usepackage{amsmath}
\DeclareMathOperator{\sign}{sign}
\usepackage{dsfont}
\usepackage[margin=2cm]{geometry}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16,LaTeXNewbie/.style={xmin=-3,
xmax=4.5,
ymin=-7,
ymax=7,
xlabel={$x$},
ylabel={$y$},
scale only axis,
axis lines=middle,
samples=200,
smooth,
clip=false,
axis equal image=true,}
}
\begin{document}
In order to plot the points $(x,y)\in\mathds{R}^2$ that satisfy
\begin{equation}
y^2=x^3+a\,x+b\;,
\end{equation}
let us first find the $x$ for which $y=0$. This is a cubic equation with the
solution
\begin{equation}\label{eq:x0}% https://tex.stackexchange.com/a/533003/194703
x_0=\frac{\sqrt[3]{2} \left(\sqrt{12 a^3+81 b^2}-9
b\right)^{2/3}-2 \sqrt[3]{3} a}{6^{2/3}
\sqrt[3]{\sqrt{12 a^3+81 b^2}-9 b}}\;.
\end{equation}
So one ``brute force'' solution is to use $x_\mathrm{min}$ to define the plot
interval (see Figure~\ref{fig:elliptic}).
\begin{figure}[htb]
\centering
\begin{tikzpicture}[declare function={xnod(\a,\b)=0.001+%
(-2*pow(3,1/3)*\a + pow(2,1/3)*%
pow(abs(-9*\b + sqrt(12*pow(\a,3) + 81*pow(\b,2))),2/3))/%
(pow(6,2/3)*sign(-9*\b + sqrt(12*pow(\a,3) + 81*pow(\b,2)))*%
pow(abs(-9*\b + sqrt(12*pow(\a,3) + 81*pow(\b,2))),1/3));
ysol(\x,\a,\b)=sqrt((\x*\x*\x+\a*\x+\b));}]
\begin{axis}[LaTeXNewbie,
domain={xnod(-3,3)}:3.45,
]
\addplot [blue] {sqrt(x^3-3*x+3)};
\addplot [blue] {-sqrt(x^3-3*x+3)};
\end{axis}
\end{tikzpicture}
\caption{``Brute force'' solution.}
\label{fig:ellipticbf}
\end{figure}
\clearpage
An arguably more elegant solution goes as follows. Define
\begin{align}
x_\mathrm{tamed}(x)&=x_0+|x|\;,\\
y_\mathrm{sol}(x)&=\sign(x)\,
\sqrt{x_\mathrm{tamed}^3+a\,x_\mathrm{tamed}+b}\;.
\end{align}
with $x_0$ from \eqref{eq:x0}. Then we need only to do the parametric plot of
\begin{equation}
\gamma(t)=\bigl(x_\mathrm{tamed}(t),y_\mathrm{sol}(t)\bigr)\;,
\end{equation}
where now the plot domain determines how far the lower and upper branches,
respectively, extend right from $x_0$. That is, \texttt{domain=-5:5} in the plot
in Figure~\ref{fig:elliptic}) means both the upper and lower branch extend from
$x_0$ to $x_0+5$. In particular, we need only one \verb|\addplot| command.
\begin{figure}[htb]
\centering
\begin{tikzpicture}[declare function={xnod(\a,\b)=0.001+%
(-2*pow(3,1/3)*\a + pow(2,1/3)*%
pow(abs(-9*\b + sqrt(12*pow(\a,3) + 81*pow(\b,2))),2/3))/%
(pow(6,2/3)*sign(-9*\b + sqrt(12*pow(\a,3) + 81*pow(\b,2)))*%
pow(abs(-9*\b + sqrt(12*pow(\a,3) + 81*pow(\b,2))),1/3));
ysol(\x,\a,\b)=sign(\x)*sqrt((pow(xtamed(\x,\a,\b),3)+\a*xtamed(\x,\a,\b)+\b));
xtamed(\x,\a,\b)=xnod(\a,\b)+abs(\x);
a=-3;b=3;}]
\begin{axis}[LaTeXNewbie,
domain=-5:5,%<-different meaning than usual, see text
]
\addplot [blue] ({xtamed(x,a,b)},{ysol(x,a,b)});
\end{axis}
\end{tikzpicture}
\caption{Arguably more elegant solution.}
\label{fig:elliptic}
\end{figure}
\end{document}