在下面的脚本中,我想绘制y(x)
:
这个函数u(x)
:
编辑
绘制y(x)
很容易,但是我在绘制函数u(x)
时遇到了问题。你知道吗
u(x)
与y(x)
的函数相同,但每一步都求和。你知道吗
因此,为了绘制u(x)
,我尝试了sum [<var> = <start>:<end>] <expression>
策略。我将此符号实现为:
replot sum[x=1:6] y(x) with line lt -1 lw 1 lc 2 title "u(x)"
在以下脚本中:
#
set ylabel "y" font ", 20"
set xlabel 'x' font ", 20"
set format y "%9.4f"
set xrange [1:6]
set yrange [0:20]
set xtics font ", 15"
set ytics font ", 15"
set key font ",17" # Changes the font of the letters of the legend
y(x) = (2*x)/(x**2)
plot y(x) with line lt -1 lw 1 lc 1 title "y(x)"
replot sum[x=1:6] y(x) with line lt -1 lw 1 lc 2 title "u(x)"
pause -1
set term post enh color eps
set output "y_x.eps"
replot
我不确定sum[x=1:6] y(x)
策略是否真的在策划u(x)
。你知道吗
为了检查这一点,我们可以执行以下操作:
我们知道:
那么,gnuplot中u(6)
的值是多少?如果运行该脚本,将得到:
缩放:
我看到u(6)
正在达到2.0000
的值,而不是3.5835
。你知道吗
这使我认为replot sum[x=1:6] u(x)
不是在绘制u(xi)(第二个公式)
如何绘制u(x)
?。你知道吗
编辑2
在此脚本中运行replot sum[i=1:6] y(i)
:
set ylabel "y" font ", 20"
set xlabel 'x' font ", 20"
set format y "%9.4f"
set xrange [1:6]
set yrange [0:20]
set xtics font ", 15"
set ytics font ", 15"
set key font ",17" # Changes the font of the letters of the legend
y(x) = (2*x)/(x**2)
plot y(x) with line lt -1 lw 1 lc 1 title "y(x)"
replot sum[i=1:6] y(i) with line lt -1 lw 1 lc 2 title "u(x)"
pause -1
set term post enh color eps
set output "y_x.eps"
replot
生成以下内容:u(6) = 3.000
:
编辑3
使用y(x) = (2.*x)/(x**2)
或y(x) = (2.*x)/(x**2.)
,我得到u(6) = 4.9
:
编辑4
制作:
N=100
replot sum[i=0:N-1] y(1. + (i+0.5)*5./N)*5./N with line lt -1 lw 1 lc 5 title "sum(x)"
产生一个常数(青色线)y=3.58
。这是求和的数值近似结果。你知道吗
我真正想要实现的是为x_{i}
的所有值绘制函数u(x)
。。。其中,在每个步骤i
,对所有先前步骤执行求和,并且生成一个新值u
。我想绘制函数u(x)
。。。你知道吗
实际上,实际绘制为
u(x)
的只是6*y(x)
,如果在脚本中替换与
这条线将与
u(x)
重合。你知道吗另外,请注意,函数
y(x)
在区间[0, 6]
中是不可积的,因为它在0
处的行为与1/x
相同(在公式中,可以得到表达式ln(0)
)。你知道吗相关问题 更多 >
编程相关推荐