一个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/08/31 21:29:11
![一个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](/uploads/image/z/5060711-47-1.jpg?t=%E4%B8%80%E4%B8%AAmathematica%E7%A8%8B%E5%BA%8F%E6%B7%BB%E5%8A%A0%E4%BD%9C%E5%9B%BE%E8%AF%AD%E5%8F%A5Clear%5Bx%2Cy%2Cn%2Ch%2CS1%2CS2%2CS3%2CS4%2Ci%5D%3By%5B1%5D+%3D+0%3B+h+%3D+0.1%3Bn+%3D+100Do%5Bx%5Bi%5D+%3D+1.0+%2B+%28i+-+1%29%2Ah%2C%7Bi%2C1%2Cn+%2B+1%7D%5Df%5Bx_%2Cy_%5D+%3D+2.5-0.8+y%3BDo%5B%7BS1+%3D+f%5Bx%5Bi%5D%2Cy%5Bi%5D%5D%2CS2+%3D+f%5Bx%5Bi%5D+%2B+h%2F2%2Cy%5Bi%5D+%2B+h%2AS1%2F2%5D%2CS3+%3D+f%5Bx%5Bi%5D+%2B+h%2F2%2Cy%5Bi%5D+%2B+h%2AS2%2F2%5D%2CS4+%3D+f%5Bx)
一个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 的用法及例子.