I am generally confused on how to solve this problem, I was given very little background on how to solve an initial value problem through Mathematica.
I believe I have created the graph below properly, correct me if I am wrong.
I am generally confused on how to solve this problem, I was given very little background on how to solve an initial value problem through Mathematica.
I believe I have created the graph below properly, correct me if I am wrong.
Okay so first, you did a relative good job if this is your first time with Mathematica/Programming.
You used DSolve to get the Solution which is good and right. But I would say, you take a look at DSolveValue. Its the same Function, its just putting out the solution with nothing else (No list, no Rule) which is what you want here.
If you still want to use DSolve, you have to substitute the y[x] with a
ReplaceAlland aPartto get rid of the List. This looks like this:sol = (y[x] /. DSolve[{y'[x] == x^2*y[x], y[1] == 3}, y[x], x])[[1]] 3 E^(-(1/3) + x^3/3)(You dont need the Part (...[1]) here since Plot could handle it)
Second you used VectorPlot. But for the Phase-Portrait i'd recommend StreamPlot.
You can now Plot your Field, Plot your solution (with a simple Plot) and combine these two with Show.
This looks like this:
sol = DSolveValue[{y'[x] == x^2*y[x], y[1] == 3}, y[x], x]
Show[StreamPlot[{1, x^2*y}, {x, -4, 4}, {y, -8, 8}],
Plot[sol, {x, -4, 4}, PlotStyle -> Red]]
(I also added a PlotStlye->Red to the Plot to get a good contrast between the field plot and ODE-Plot)
Hope this helps
It can done by utilizing the StreanPoints option, which takes the initial condition as an input and select the streamline passing through the initial condition,
f[x_, y_] := x^2*y
StreamPlot[{1, f[x, y]}, {x, -5, 6}, {y, -4, 3}, Frame -> False,
Axes -> True, AspectRatio -> 1/GoldenRatio, AxesLabel -> {"x", "y(x)"}, BaseStyle -> 12,
StreamPoints -> {{{{1, 3}, Red}, Automatic}}]