- I believe the main issue for you is that Mathematica does not know what
x[t]
and y[t]
are in your ParametricPlot
command. An excellent way to solve this is by using ReplaceAll
(a.k.a. /.
) with the Rule
s already included in the solution produced by DSolve
.
- Ensure that your parameters (e.g.
U
and V
) are assigned values with Set
(=
); do not use Equal
(==
) here, which is an operator used to define equations and do logical comparisons of two expressions.
- Assign values (using
Set
) to all of your parameters, as mentioned by user halirutan.
I propose the following improved code:
Clear["Global`*"]
m = k = v = θ = g = 1;
m x''[t] == -k m x'[t];
m y''[t] == -k m y'[t] - m g;
U = v Cos[θ];
V = v Sin[θ];
soln = DSolve[{m x''[t] == -k m x'[t], m y''[t] == -k m y'[t] - m g,
x[0] == 0, y[0] == 0, x'[0] == U, y'[0] == V}, {x[t], y[t]}, t][[1]];
ParametricPlot[{x[t], y[t]} /. soln, {t, 0, 3}]
As a further example, I've included a direction field and a parametric plot of a specific solution for a different, first-order differential equation. The specific solution corresponds to a single value (in this case C[1] = 0
) for the constant of integration which is in the general solution.
soln=DSolve[y'[x]==(x^2)/(1-y[x]^2),y[x],x];
plotone=ParametricPlot[{x,y[x]/.soln[[1]]/.C[1]->0},{x,-10,10}, PlotStyle->{Red, Thickness[0.01]}];
plottwo=StreamPlot[{(1 - y^2),x^2},{x,-10,10}, {y,-10,10}, VectorScale->.2, StreamStyle-> Blue];
Show[plottwo,plotone]
ParametricPlot[{x[t], y[t]} /. soln, ...]
and in order to get a plot you need to specify numerical values for your parameters. $\endgroup$NDSolve
. $\endgroup$Clear
thenRemove
is redundant.Clear
will remove all rules associated with a symbol, but the symbol remains known.Remove
does that and removes the symbol from the "known" symbols list. Personally, I useClear
, and sometimesClearAll
, if I've setAttributes
or attachedMessages
to the symbol, and reserveRemove
for when I have to deal with shadowing. $\endgroup$Context
, so that multiple notebooks do not conflict with each other. $\endgroup$