一个mathematica程序添加作图语句Clear[x,y,n,h,S1,S2,S3,S4,i];y[1] = 0; h = 0.1;n = 100Do[x[i] = 1.0 + (i - 1)*h,{i,1,n + 1}]f[x_,y_] = 2.5-0.8 y;Do[{S1 = f[x[i],y[i]],S2 = f[x[i] + h/2,y[i] + h*S1/2],S3 = f[x[i] + h/2,y[i] + h*S2/2],S4 = f[x
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/08 12:10:52
一个mathematica程序添加作图语句Clear[x,y,n,h,S1,S2,S3,S4,i];y[1] = 0; h = 0.1;n = 100Do[x[i] = 1.0 + (i - 1)*h,{i,1,n + 1}]f[x_,y_] = 2.5-0.8 y;Do[{S1 = f[x[i],y[i]],S2 = f[x[i] + h/2,y[i] + h*S1/2],S3 = f[x[i] + h/2,y[i] + h*S2/2],S4 = f[x
一个mathematica程序添加作图语句
Clear[x,y,n,h,S1,S2,S3,S4,i];
y[1] = 0; h = 0.1;
n = 100
Do[x[i] = 1.0 + (i - 1)*h,{i,1,n + 1}]
f[x_,y_] = 2.5-0.8 y;
Do[{S1 = f[x[i],y[i]],S2 = f[x[i] + h/2,y[i] + h*S1/2],
S3 = f[x[i] + h/2,y[i] + h*S2/2],S4 = f[x[i] + h,y[i] + h*S3],
y[i + 1] = y[i] + (S1 + 2 S2 + 2 S3 + S4)*h/6},{i,1,n}]
Do[Print[x[i]," ",y[i]],{i,1,n + 1}]
需要在后面做出图形,求问需要添加的语句.
一个mathematica程序添加作图语句Clear[x,y,n,h,S1,S2,S3,S4,i];y[1] = 0; h = 0.1;n = 100Do[x[i] = 1.0 + (i - 1)*h,{i,1,n + 1}]f[x_,y_] = 2.5-0.8 y;Do[{S1 = f[x[i],y[i]],S2 = f[x[i] + h/2,y[i] + h*S1/2],S3 = f[x[i] + h/2,y[i] + h*S2/2],S4 = f[x
你要是想画出 x 与 y 的图像可以用 ListPlot 函数,需要添加的语句如下:
ListPlot[Table[{x[i], y[i]}, {i, n + 1}]]输出图像:
要想将点连接起来可以加上选项 Joined .
更多图像选项及细节调整,请参考函数 ListPlot 的用法及例子.