Classification of differential equations

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)$$

Solving separable differential equations

$$ \frac{dy}{dx} = f(x)g(y) \Rightarrow $$

$$ \frac{1}{g(y)}dy = f(x)dx \Rightarrow $$

$$ \int \frac{1}{g(y)}dy = \int f(x)dx \Rightarrow $$

$$ G(y) + C_1 = F(x) +C_2 \Rightarrow $$$$ y = G^{-1} (F(x) + C) \text{, where } C=C_1+C_2$$
In [6]:
import matplotlib.pyplot as plt
from scipy import *
from scipy import integrate
from scipy.integrate import ode
import numpy as np
%matplotlib inline

Example 1

$$ \frac{d y}{d x} = \frac{y}{\sqrt{1-x^2}}$$
In [9]:
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()
/home/edugalt/.local/lib/python3.5/site-packages/ipykernel/__main__.py:18: RuntimeWarning: divide by zero encountered in true_divide
/home/edugalt/.local/lib/python3.5/site-packages/ipykernel/__main__.py:22: RuntimeWarning: invalid value encountered in true_divide

Example 4

$$\frac{dy}{dx} = \frac{1}{(2x+1)^2+1} $$
In [11]:
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()
In [ ]: