First Order Differential Equations
The Euler Method
The Euler method is a numerical technique for approximating solutions to first-order differential equations. It's like taking baby steps along a curve, using the derivative to guide each step.
Consider a point $(x_n, y_n)$, where the derivative of this point is $$y_n'(x_n, y_n)$$. The tangent line at this point is given by
$$y - y_n= y_n'(x_n, y_n)(x-x_n)$$
$$y = y_n + y_n'(x_n, y_n)(x-x_n)$$
Now let us consider a new point $x_{n+1}, y_{n+1}$, where $x_{n+1}$ is defined by $x_{n+1}= x_{n}+h$ for some small $h$.
Here comes the approximation step. We can imagine that, for some small $h$, the rate of change at the points $(x_n, y_n)$ and $(x_{n+1}, y_{n+1})$ are incredibly similar to the point where they are effectively the same.
If the rate of change at these points are similar, the point $(x_{n+1}, y_{n+1})$ should lie on the tangent line of $(x_n, y_n)$
Therefore, by substituting the point $(x_{n+1}, y_{n+1})$ into the tangent line:
$$y_{n+1} = y_n + y_n'(x_n,y_n)(x_{n+1}-x_n)$$
$$y_{n+1} = y_n + y_n'(x_n)(h)$$
$$y_{n+1} = y_n + hy_n'(x_n)$$
Or alternatively, by letting $f(x_n, y_n) = y_n'(x_n,y_n)$
$$y_{n+1} = y_n + h\cdot f(x_n, y_n)$$
Where:
- $y_{n+1}$ is the next y-value
- $y_n$ is the current y-value
- $h$ is the step size
- $f(x_n, y_n)$ is the derivative at the current point
Thus obtaining a sequence of values $(x_n, y_n)$ that satisfy a differential equation.
TipChoose a smaller step size ($h$) for better accuracy, but be aware this increases computational work. For smaller $h$, the approximation of rate of changes being similar between $x_n$ and $x_{n+1}$ becomes more accurate.
ExampleSolve $\frac{dy}{dx} = x + y$ with initial condition $y(0) = 1$ using h = 0.2 for the first two steps.
Step 1: At x = 0, y = 1 $y_1 = 1 + 0.2(0 + 1) = 1.2$
Step 2: At x = 0.2, y = 1.2 $y_2 = 1.2 + 0.2(0.2 + 1.2) = 1.48$
TipRemember that the Euler's method is not foolproof. There are cases when it doesn't work, for example.
- When the rate of change increases rapidly such that the derivative approximation is invalid.
- Asymptotes—certain differential equations don't have solutions at certain points, but Euler's method neglects this and spits out a number anyway.
For using this with a GDC, go to "Recursion" and define the equations:
$$x_{n+1}=x_n + h$$
$$y_{n+1}=y_n + hf(x_n,y_n)$$
Along with the initial condition (i.e. the values of $x_0$ and $y_0$ .
The calculator will do the rest.
Variables Separable Method
This method works when we can separate variables to different sides of the equation.
Steps:
- Rearrange to get all $y$ terms on one side and $x$ terms on the other
- Integrate both sides
Solve $\frac{dy}{dx} = \frac{x}{y}$
- Separate variables: $y,dy = x,dx$
- Integrate: $\frac{y^2}{2} = \frac{x^2}{2} + C$
- Solution: $y = \pm\sqrt{x^2 + 2C}$
Integrating Factor Method
Used when the DE is in the form: $$\frac{dy}{dx} + P(x)y = Q(x)$$
The integrating factor is: $$ \mu(x) = e^{\int P(x)dx}$$
The reason why this works is because if we multiply both sides of the DE by the integrating factor:
$$ e^{\int P(x) dx}\frac{dy}{dx}+yP(x)e^{\int P(x) dx}=e^{\int P(x) dx}Q(x) $$
We can notice that this can now be written in the form:
$$\frac{d}{dx}(ye^{\int P(x)dx} ) = e^{\int P(x) dx}Q(x)$$
Therefore: $$ye^{\int P(x)dx}=\int e^{\int P(x) dx}Q(x) dx$$
Which hopefully, is a solve-able integral that you can do.
TipLook for terms with y and dy/dx that can be combined into a product rule form.
ExampleSolve $\frac{dy}{dx} + 2xy = x$
- Identify $P(x) = 2x$ and $Q(x) = x$
- Find $\mu(x) = e^{\int 2x,dx} = e^{x^2}$
- Multiply both sides: $e^{x^2}\frac{dy}{dx} + 2xe^{x^2}y = xe^{x^2}$
- Recognize left side as derivative: $\frac{d}{dx}(e^{x^2}y) = xe^{x^2}$
- Integrate: $e^{x^2}y = \frac{1}{2}e^{x^2} + C$
- Solve for y: $y = \frac{1}{2} + Ce^{-x^2}$
Homogeneous Differential Equations
A DE is homogeneous if it can be written as: $$\frac{dy}{dx} = f(\frac{y}{x})$$
Solve using substitution $y = vx$, where $v$ is a function of $x$:
- Let $y = vx$
- Use substitution $\frac{dy}{dx} = v + x\frac{dv}{dx}$
- Substitute and solve for v
Don't forget to substitute back y = vx after solving for v!
ExampleSolve $\frac{dy}{dx} = \frac{y}{x} + \frac{y^2}{x^2}$
- Let $y = vx$
- $v + x\frac{dv}{dx} = v + v^2$
- $x\frac{dv}{dx} = v^2$
- Separate: $\frac{dv}{v^2} = \frac{dx}{x}$
- Integrate: $-\frac{1}{v} = \ln|x| + C$
- Solve for v and substitute back: $y = \frac{-x}{\ln|x| + C}$