As a starter
In[14]:= rorb[X, 0]
Out[14]= X^2/(4 \[Pi]^2 (1 - Sqrt[1 + (X^2 (-4 \[Pi]^2 + X^2/2))/(8 \[Pi]^4)]))
from which one sees, that rorb[0,0] seems to be indeterminate (0/0) but the numerator vanishs with second oder, the denominator vanishes with first order, so L'Hospital would mean rorb[0,0]=1
In[15]:= Limit[rorb[X, 0], X -> 0]
Out[15]= 1
but Mma says
In[16]:= rorb[0, 0]
During evaluation of In[16]:= Power::infy: Infinite expression 1/0 encountered. >>
During evaluation of In[16]:= Infinity::indet: Indeterminate expression (0 ComplexInfinity)/(4 \[Pi]^2) encountered. >>
Out[16]= Indeterminate
one could easily fix that by
defining rorb[0,0] to the correct limit.In either case this
Manipulate[
ParametricPlot[{rorb[vy0, \[CurlyPhi]] Cos[\[CurlyPhi]],
rorb[vy0, \[CurlyPhi]] Sin[\[CurlyPhi]]}, {\[CurlyPhi], 0,
2 \[Pi]}, PlotStyle -> Black, AspectRatio -> Automatic,
FrameLabel -> {"\!\(\*
StyleBox[\"x\",\nFontFamily->\"cmmi12\",\nFontSize->14,\nFontWeight\
->\"Plain\",\nFontSlant->\"Italic\",\n\
FontVariations->{\"CompatibilityType\"->0}]\)\!\(\*
StyleBox[
StyleBox[
RowBox[{
StyleBox[\" \",\nFontFamily->\"cmmi12\"],
StyleBox[\" \",\nFontFamily->\"Arial Narrow\"]}]],\nFontSize->14,\n\
FontWeight->\"Plain\",\nFontVariations->{\"CompatibilityType\"->0}]\)\
\!\(\*
StyleBox[\"[\",\nFontFamily->\"Arial Narrow\",\nFontSize->12,\n\
FontWeight->\"Plain\",\nFontVariations->{\"CompatibilityType\"->0}]\)\
\!\(\*
StyleBox[\"AU\",\nFontFamily->\"Arial Narrow\",\nFontSize->12,\n\
FontWeight->\"Plain\",\nFontVariations->{\"CompatibilityType\"->0}]\)\
\!\(\*
StyleBox[\"]\",\nFontFamily->\"Arial Narrow\",\nFontSize->12,\n\
FontWeight->\"Plain\",\n\
FontVariations->{\"CompatibilityType\"->0}]\)", "\!\(\*
StyleBox[\"y\",\nFontFamily->\"cmmi12\",\nFontSize->14,\nFontWeight\
->\"Plain\",\nFontSlant->\"Italic\",\n\
FontVariations->{\"CompatibilityType\"->0}]\)\!\(\*
StyleBox[\" \",\nFontFamily->\"cmmi12\",\nFontSize->14,\nFontWeight\
->\"Plain\",\nFontVariations->{\"CompatibilityType\"->0}]\)\!\(\*
StyleBox[\"[\",\nFontFamily->\"Arial Narrow\",\nFontSize->12,\n\
FontWeight->\"Plain\",\nFontVariations->{\"CompatibilityType\"->0}]\)\
\!\(\*
StyleBox[\"AU\",\nFontFamily->\"Arial Narrow\",\nFontSize->12,\n\
FontWeight->\"Plain\",\nFontVariations->{\"CompatibilityType\"->0}]\)\
\!\(\*
StyleBox[\"]\",\nFontFamily->\"Arial Narrow\",\nFontSize->12,\n\
FontWeight->\"Plain\",\n\
FontVariations->{\"CompatibilityType\"->0}]\)"}, PlotRange -> All,
PlotLabel -> "Elipti?na orbita, egzaktno"], {vy0, 0, 20,
Appearance -> "Labeled"}]
starts with an error without taking care about the limit.
Now about the EC[vy_] thing: that will not work because - as the error message states - the iterator for the Do[..., {i,nt}] has no upper limit nt, nt is a module local variable and is
not set inside the Module[]. You have set it
before the module, but the Module EC
Euler - Cromerov metod
x0 = 1.; y0 = 0.; vx0 = 0.; vy0 = 2 \[Pi]; t0 = 0.; tf = 10.;
r0 = Sqrt[x0^2 + y0^2]; v02 = vx0^2 + vy0^2; e0 = v02/2 - (4 \[Pi]^2)/r0;
l0 = vy0 x0 - vx0 y0;
nt = 100000; dt = (tf - t0)/nt;
tt = {t0}; xx = {x0}; yy = {y0}; ee = {e0}; ll = {l0};
t = t0; x = x0; y = y0; vx = vx0; vy = vy0;
EC[vy_] := Module[{vx, x, dt, r, y, t, xx, yy, tt, v2, e, ee, ll, l, i, nt},
Do[(<snip> ....];
has all this variables as
local entities, see
Module, the fix is to initialize that local variables to the values you want.
Then there is another error, defining EC[vy_] you cannot assign another value to vy! Starting EC[2 Pi] you say vy = 2 Pi and then vy = vy - (4 \^2*y*dt)/r^3 means to assign 2 Pi to become something different from 2 Pi - forbidden with very sound reason. Use another name for the input, e.g. EC[vy0_] then it works and gives this picture
last but not least find please my modifications - which should be checked against further errors - in the appendix
Attachments: