1
$\begingroup$

I bet this has asked before, but I can't seem to find an answer anywhere.

I have x and y functions which, individually plotted, are showing up fine, but when I try to plot the parametrically, the graph does not show up. I absolutely cannot figure out why this is occurring, and I've tried simpler functions (such as x=sin[t]), which work, leading me to believe it has something to do with the way I solved the differential equation.

    k1 = 9*^9*(1.6*^-19)^2;
    me = 511*^3;
    mp = 938*^6;
    ℏ = 6.59*^-1;
    U[r_] := -k1/r;
    V[r_] := U[r] + l[r]^2/2/μ/r^2;
    L := n*ℏ;
    ϕ'[r_] := L/me/r^2;
    F[r_] := -k1/r^2;
    μ = (me + mp)/(me*mp);
    u[ϕ_] := 1/r[ϕ];
    l[r_] := μ r^2 ϕ'[r];
    n = .1;

    sol = NDSolve[{D[D[u[ϕ], ϕ], ϕ] == 
         u[ϕ] - μ/l[r[ϕ]]^2/u[ϕ]^2*F[r[ϕ]], 
        r[1] == 30, r'[1] == 5}, r[ϕ], {ϕ, 0, 4 Pi}];

    X[ϕ1_] := r[ϕ]*Cos[ϕ] /. sol /. ϕ -> ϕ1;
    Y[ϕ1_] := r[ϕ]*Sin[ϕ] /. sol /. ϕ -> ϕ1;

    Plot[X[th], {th, 0, 2 Pi}]
    Plot[Y[th], {th, 0, 2 Pi}]
    ParametricPlot[{X[t], Y[t]}, {t, 0, 2 Pi}]
$\endgroup$
0

1 Answer 1

2
$\begingroup$

Note the First@sol part:

X[ϕ1_] := r[ϕ]*Cos[ϕ] /. First@sol /. ϕ -> ϕ1;
Y[ϕ1_] := r[ϕ]*Sin[ϕ] /. First@sol /. ϕ -> ϕ1;

ParametricPlot[{X[t], Y[t]}, {t, 0, 2 Pi}, AspectRatio -> 1]

Mathematica graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.