
任意の多項式の根を複素平面上にプロットしたいと思います。
例: $P(x)=x^4-x^3-1$ が与えられているとします。この多項式の 4 つの根すべてを $Oxy$ 複素平面上にプロットします。
この場合、Tikz は便利なツールになると思いますが、このパッケージの経験はありません。
答え1
より技術的な数学に進む場合は、sagetex
オープンソースのCASにアクセスできるパッケージを使用する必要があります。セージCTANに関するドキュメントはここ. 欲しいものを手に入れるための「手っ取り早い」方法をご紹介します。
\documentclass{article}
\usepackage{sagetex}
\begin{document}
\begin{sagesilent}
x = polygen(QQ)
f = x^4-x^3-1
root_list = f.roots(CC)
real_roots = []
for root in root_list:
real_roots += [root[0].n(digits=3)]
P = list_plot(real_roots,color='red',size=25)
\end{sagesilent}
The roots of the polynomial $\sage{f}$ plotted in the complex plane
\begin{center}
\sageplot[scale=.8]{P}
\end{center}
The roots of $\sage{f}$ are $\sage{real_roots}$.
\end{document}
出力は次のとおりです。
コードの複雑さは分かりませんが、これそしてこれコードを理解するには、 を使用します。 を使用すると、
x = polygen(QQ)
有理係数の多項式の根を見つけることができ、f.roots(CC)
複素根を見つけるように sage に指示できます。 SAGE は CAS なので、これらの数値は sqrt(2) などのオブジェクトになる可能性があり、プロット可能な小数に変換する必要があります。 これは によって実現されますfor root in root_list: real_roots += [root[0].n(digits=3)]
。 実際のプロットは によって変数 P に格納されます。ここで、P = list_plot(real_roots,color='red',size=25)
色とサイズは、最初は小さすぎて簡単には見えないポイントを参照します。 これはすべてsagesilent
、ドキュメントに含まれないスクラップ ペーパーのようなモードで行われます。 LaTeX コードでは、 を使用して\sage{}
数値/計算を取得し、\sageplot{}
でプロットを取得します。これは SAGE で実行されます。 プロットを sage で実行すると、コードが短くなります。また、CAS が計算を行うので、関数を変更でき (係数と変数の乗算が必要であることを覚えておいてください)、SAGE が結果を計算します。 もう少しコーディングすれば、プロットをより見栄えの良いものにすることができtikz
ます。 ゼータ関数で私が行った方法を参照してください。ここ. これにはかなりの行数の追加が必要になります。私のコードでは、SAGE は によって 4 つのゼロも生成できることに注目してください\sage{real_roots}
。CAS にこの作業を行わせることで、間違いを防ぐことができます。
SAGEはLaTeXディストリビューションの一部ではありません。SAGEにアクセスするには、無料のCocalcアカウントを作成するのが最適です。ここ。
答え2
ティけZはコンピュータ代数システムではありません。もちろん、自分で根を計算し、極座標を使用してプロットすることができます。(原理的には、TiけZ は根を決定する方程式を数値的に解きますが、これはおそらく少しクレイジーです。
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{amsmath}
\DeclareMathOperator{\re}{Re}
\DeclareMathOperator{\im}{Im}
\begin{document}
\begin{tikzpicture}[scale=4]
\draw[-latex] (-1.5,0) -- (1.75,0) node[below left] {$\re z$};
\draw[-latex] (0,-1.5) -- (0,1.5) node[below right] {$\im z$};
\draw (1,0.05) -- (1,-0.05) node[below]{1};
\draw (0.05,1) -- (-0.05,1) node[left]{i};
\foreach \X/\Y in {-76.5/0.94,76.5/0.94,180/0.82,0/1.38}
{\fill (\X:\Y) circle[radius=1pt];}
\end{tikzpicture}
\end{document}
答え3
次回は、より多くのユーザーをあなたの投稿に引き付けるために、最小限の動作例を投稿する必要があります。いずれにせよ、あなたは新しいユーザーなので、この回答は TeX.SE への歓迎の意を表します。
まず第一に、実際のルーツは 2 つ以上ないと思います。
Tiを使えば簡単にプロットできるけZ:
\documentclass[tikz]{standalone}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}[>=stealth,scale=2]
\draw[->] (0,-2.5)--(0,2.5) node[left] {$y$};
\draw[->,name path=ox] (-2.5,0)--(2.5,0) node[above]{$x$};
\draw (0,0) node[below left] {$O$};
\foreach \i in {-2,-1,1,2} {
\draw (-.05,\i)--(.05,\i);
\draw (0,\i) node[left] {$\i$};
\draw (\i,-.05)--(\i,.05);
\draw (\i,0) node[below] {$\i$};
}
\draw[red,name path=pl] plot[smooth,samples=500,domain=-1.1:1.6] (\x,{\x*\x*\x*\x-\x*\x*\x-1});
\path[name intersections={of=ox and pl,by={i1,i2}}];
\fill (i1) circle (1pt) node[above right] {$A$};
\fill (i2) circle (1pt) node[below right] {$B$};
\end{tikzpicture}
\end{document}
交差点がわかれば、その座標がわかります。
\documentclass[tikz]{standalone}
\usetikzlibrary{intersections}
\newdimen\xa
\newdimen\xb
\newdimen\ya
\newdimen\yb
\makeatletter
\def\convertto#1#2{\strip@pt\dimexpr #2*65536/\number\dimexpr 1#1}
\makeatother
% https://tex.stackexchange.com/a/239496/156344
\begin{document}
\begin{tikzpicture}[>=stealth,scale=2]
\draw[->] (0,-2.5)--(0,2.5) node[left] {$y$};
\draw[->,name path=ox] (-2.5,0)--(2.5,0) node[above]{$x$};
\draw (0,0) node[below left] {$O$};
\foreach \i in {-2,-1,1,2} {
\draw (-.05,\i)--(.05,\i);
\draw (0,\i) node[left] {$\i$};
\draw (\i,-.05)--(\i,.05);
\draw (\i,0) node[below] {$\i$};
}
\draw[red,name path=pl] plot[smooth,samples=500,domain=-1.1:1.6] (\x,{\x*\x*\x*\x-\x*\x*\x-1});
\path[name intersections={of=ox and pl,by={i1,i2}}];
\fill (i1) circle (1pt) node[above right] {$A$};
\path (i1); \pgfgetlastxy{\xa}{\ya}
\fill (i2) circle (1pt) node[below right] {$B$};
\path (i2); \pgfgetlastxy{\xb}{\yb}
\draw (0,-3) node[text width=10cm,align=left] {%
There are two roots:\\
$A$ at $({\convertto{cm}{\xa}*2}, 0)$ and $B$ at $({\convertto{cm}{\xb}*2}, 0)$.};
\end{tikzpicture}
\end{document}
もちろん、いつでもどこでも使用でき\xa
ます\xb
;-)
マーモットが言ったように、TiけZ は計算機ではありません。交差を使用して実根を見つけるのに役立つだけです。また、自分で根を見つける以外に、LaTeX ツールでこれを行うのは簡単ではないと思います。