[問題] 記憶體爆炸

作者: 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