gpt4 book ai didi

gnuplot - Gnuplot和复指数

转载 作者:行者123 更新时间:2023-12-04 13:23:32 26 4
gpt4 key购买 nike

谁能告诉我如何使用gnuplot绘制复杂的指数。我尝试使用此脚本绘制它们,但是参数i无法识别。

set terminal epslatex color colortext size 9cm,5cm
set size 1.5,1.0
set output "eulerjeva_identiteta_1.tex"

set style line 1 linetype 1 linewidth 3 linecolor rgb "#FF0055"
set style line 2 linetype 2 linewidth 1 linecolor rgb "#FF0055"
set style line 3 linetype 1 linewidth 3 linecolor rgb "#2C397D"
set style line 4 linetype 2 linewidth 1 linecolor rgb "#2C397D"
set style line 5 linetype 1 linewidth 3 linecolor rgb "#793715"
set style line 6 linetype 2 linewidth 1 linecolor rgb "#793715"
set style line 7 linetype 1 linewidth 3 linecolor rgb "#b1b1b1"
set style line 8 linetype 3 linewidth 1 linecolor rgb "#b1b1b1"

set grid

set samples 7000

set key at graph .95, 0.4
set key samplen 2
set key spacing 0.8

f(x) = exp(i*x)
g(x) = exp(-i*x)
h(x) = exp(i*x)+exp(-i*x)

set xrange [-2*pi:2*pi]
set yrange [-1.2:1.2]

set xtics ("$0$" 0, "$\\pi$" pi, "$-\\pi$" -pi)
set ytics ("$1$" 1, "$-1$" -1)

set xlabel "$x$"

plot [-2*pi:2*pi] f(x) ls 1 title "$\\e^{ix}$", g(x) ls 3 title "$\\e^{-ix}$", h(x) ls 5 title "$\\e^{ix} + \\e^{-ix}$"

最佳答案

Gnuplot无法将i理解为sqrt(-1),因为gnuplot并未为变量i分配值-就其而言,它只是另一个变量名。 Gnuplot可以使用以下格式理解和处理复数

z = {a,b}

它以复数形式表示复数 z = (a + ib)。所以,我可以定义
i = {0.0,1.0}

仍然存在当您绘制图形时会得到什么的问题
plot exp(i*x)

所有的点都是“不确定的”,因为它们具有虚构的分量。 (尽管 h(x) = exp(i*x)+exp(-i*x)纯粹是实数,所以它可以很好地绘制。)问题是gnuplot只能绘制实数。你可以试试
plot real(exp(i*x)), imag(exp(i*x))

分别可视化组件,或者可以绘制参数图:
set parametric
plot real(exp(i*t)), imag(exp(i*t))

关于gnuplot - Gnuplot和复指数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15851842/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com