[问题] 内存爆炸

楼主: ar851060 (ar851060)   2017-11-16 16:38:40
大家好,小弟我是最近刚学Mathematica的菜鸟
最近老师出作业是要模拟Runge Kutta来解圆周运动,并且画图出来
但是我打出来后跑结果却是 no more memory available
以下是我打的code
xA[n_] := Cos[2*\[Pi]/20*n]
yA[n_] := Sin[2*\[Pi]/20*n]
(*Runge Kutta Method*)
xRK[n_] :=
xRK[n - 1] +
1/6*2*\[Pi]/
100*(xF1[n - 1] + 2*xF2[n - 1] + 2*xF3[n - 1] + xF4[n - 1])
xF1[n_] := Sqrt[xRK[n]]
xF2[n_] := Sqrt[xRK[n] + \[Pi]/100*xF1[n]]
xF3[n_] := Sqrt[xRK[n] + \[Pi]/100*xF2[n]]
xF4[n_] := Sqrt[xRK[n] + (2 \[Pi])/100*xF3[n]]
xRK[0] := 1
yRK[n_] :=
yRK[n - 1] +
1/6*2*\[Pi]/
100*(yF1[n - 1] + 2*yF2[n - 1] + 2*yF3[n - 1] + yF4[n - 1])
yF1[n_] := Sqrt[yRK[n]]
yF2[n_] := Sqrt[yRK[n] + \[Pi]/100*yF1[n]]
yF3[n_] := Sqrt[yRK[n] + \[Pi]/100*yF2[n]]
yF4[n_] := Sqrt[yRK[n] + (2 \[Pi])/100*yF3[n]]
yRK[0] := 0
接下来作图:
ListPlot[{Table[{xA[n],yA[n]},{n,100}],Table[{xRK[n],yRK[n]},{n,100}]},PlotMarkers->Automatic,PlotLegends->{analytic
method,runge kutta method},PlotRange->All,AspectRatio->Automatic]
请各位大神帮我小弟解惑,我会十分感激你的

Links booklink

Contact Us: admin [ a t ] ucptt.com