# how to plot solution of differential system

Hi, everyone! I got a question. I have a system of three Newton's equations

x''=-x/(x*x+y*y+z*z)^3/2-F(t)
y''=-x/(x*x+y*y+z*z)^3/2
z''=-x/(x*x+y*y+z*z)^3/2


I use ode_solver() to solve numerically the system by using y for x, y for y, y for z like in example in the manual without using jacobian:

j_1= lambda t,y: [ y, y, y,  -y/(y*y+y*y+y*y)^(1.5)-F*cos(w*t), -y/(y*y+y*y+y*y)^(1.5), -y/(y*y+y*y+y*y)^(1.5)]


How may I plot the curve (x(t), y(t)) or (x(t), z(t))? T.plot_solution(i=0, filename=outfile) allows to plot only (x(t), t), (y(t), t) or (z(t), t) Thank you

edit retag close merge delete

Sort by » oldest newest most voted

You can get access to the list of solution points using the .solution option.

a=T.solution
print a


The code above shows the solution points and you can see the data structure. To plot what you want, try these:

xysoln=[[soln,soln] for soln in a]
list_plot(xysoln)

yzsoln=[[soln,soln] for soln in a]
list_plot(yzsoln)

xzsoln=[[soln,soln] for soln in a]
list_plot(xzsoln)

xyzsoln=[[soln,soln,soln] for soln in a]
list_plot(xyzsoln)

more

more

If you like it, please "accept" @calc314's answer by hitting the check mark.