#!/usr/bin/python import numpy as np import matplotlib.pyplot as plt import scipy.integrate as ode from mpl_toolkits import mplot3d q=1. m=1. qm=q/m b=[0.,0.,0.1] e=[0.,0.,0.] betta=0.00 v0=10. def func(y,t): yp=np.zeros_like(y) yp[0]=y[3] yp[1]=y[4] yp[2]=y[5] yp[3]=qm*(y[4]*b[2]-y[5]*b[1]+e[0])-betta*y[3] yp[4]=qm*(y[5]*b[0]-y[3]*b[2]+e[1])-betta*y[4] yp[5]=qm*(y[3]*b[1]-y[4]*b[0]+e[2])-betta*y[5] return yp y0=[0.,0.,0.,0.,10.,0.] time=np.arange(0,600,100) res=ode.odeint(func,y0,time) p=plt.axes(projection="3d") p.plot(res[:,0],res[:,1],res[:,2]) plt.grid() plt.show() print (res)