Differential equations (of order $n$):
$$ f(\frac{d^ny}{dx^n}, \frac{d^{n-1}y}{dx^{n-1}}, \ldots, \frac{dy}{dx}, x,y) =0$$First order differential equations:
$$ f(\frac{dy}{dx},y,x) = 0$$First order differential equations of the first degree:
$$ \frac{dy}{dx} = f(x,y)$$Separable (first-order first-degree) differential equations:
$$ \frac{dy}{dx} = f(x)g(y)$$Simple cases:
$$ \frac{dy}{dx} = f(x) \text{ or } \frac{dy}{dx}= f(y)$$import matplotlib.pyplot as plt
from scipy import *
from scipy import integrate
from scipy.integrate import ode
import numpy as np
%matplotlib inline
fig = plt.figure(num=1,figsize=(10,10))
ax=fig.add_subplot(111)
xmin=-1;xmax=1;ymin=-1;ymax=1;
gridx=30;gridy=30;
x=np.array(range(100))/100.;x=xmin+(xmax-xmin)*x;
plt.xlim([xmin,xmax])
plt.ylim([ymin,ymax])
plt.xlabel(r"$x$",fontsize=18)
plt.ylabel(r"$y$",fontsize=18)
plt.tick_params(axis='both', which='major', labelsize=16)
#Vector field
X,Y = np.meshgrid( np.linspace(xmin,xmax,gridx),np.linspace(xmin,xmax,gridy) )
dX = 1
dY = Y/np.sqrt(1-X**2)
#Normalize arrows
N = np.sqrt(dX**2+dY**2)
U, V = dX/N, dY/N
ax.quiver( X,Y,U, V,minshaft=5,width=0.005,headwidth=0,color="black")
# Ploting function
c=0.3
f=c*exp(np.arcsin(x))
ax.plot(x,f)
c=-0.5
f=c*exp(np.arcsin(x))
ax.plot(x,f)
plt.show()
fig = plt.figure(num=1,figsize=(10,10))
ax=fig.add_subplot(111)
xmin=-2;xmax=1;ymin=-1;ymax=1;
gridx=30;gridy=30;
x=np.array(range(100))/100.;x=xmin+(xmax-xmin)*x;
plt.xlim([xmin,xmax])
plt.ylim([ymin,ymax])
plt.xlabel(r"$x$",fontsize=18)
plt.ylabel(r"$y$",fontsize=18)
plt.tick_params(axis='both', which='major', labelsize=16)
#Vector field
X,Y = np.meshgrid( np.linspace(xmin,xmax,gridx),np.linspace(xmin,xmax,gridy) )
dX = 1
dY = 1/((2*X+1)**2+1)
#Normalize arrows
N = np.sqrt(dX**2+dY**2)
U, V = dX/N, dY/N
ax.quiver( X,Y,U, V,minshaft=5,width=0.005,headwidth=0,color="black")
# Ploting solutions obtained in classroom for a=1
c=-pi/8; f=0.5*np.arctan(2*x+1)+c; ax.plot(x,f);
c=0;f=0.5*np.arctan(2*x+1)+c;ax.plot(x,f);
c=1;f=0.5*np.arctan(2*x+1)+c;ax.plot(x,f);
plt.show()