#Maths
# ODEs - An Introduction
## What are ODEs?
Ever wondered how we could model the rate of change in temperature of a hot drink as a function of its original temperature?
Alright, maybe not with *that* wording, but it's a great, practical example of a *differential equation* - where we model the rates of changes of functions (their derivatives) against the original functions!
There are actually different types of differential equation - we'll be going over some of the basics in this example. Listed below:
- **Generic Differential Equation**: $\frac {dy}{dx} = f(x)$
- **Linear Differential Equation: $\frac{dy}{dx} + P(x)y = Q(x)$**
- **Separable differential equation**: $\frac {dy}{dx} = f(x)g(y)$
- **Homogeneous differential equation**: $\frac{dy}{dx} = f \left( \frac{y}{x} \right)$
For the multivariable **Partial Differential Equation**, feel free to first take a look at[[Partial Derivatives (Maths)| Partial Derivatives]].
>[!Abstract]- The concept of "Order" in DEs
>Look at the **highest-order** derivative in the equation. That is the **order** of the entire differential equation.
>
>For example, take the differential equation: $\frac {d^{2}y}{dx^2} = 2xy + y^2$
>This would be a <u>**second**</u> order differential equation, as the second order of the DE is the prevailing order in the equation.
# Solving Simple ODEs
## An ODE in the form $\frac {dy}{dx} = f(x)$
Oh dear! Another differential equation lies before us, this time more daunting than ever!
Nope, just integrate by the variable in question on both sides. That should show it!
>[!Abstract]- Example Question 1)
>Let us define $f(x)$ as a simple linear function $f(x) = 2x + 3$
>$\int_ \, dy = \int 2x+3\,dx$
>This thus equals to:
>$y = x^2 + 3x + C$
>Therefore given linear values C can also be found through substitution.
## An ODE in the form $\frac {dy}{dx} = f(x)g(y)$
This is a **separable differential equation**, where there is a multivariable composite function. We'd typically integrate both sides as functions of $x$, but we evidently can't do that this time...
This is difficult to visualise, so we can create a simple composite differential equation as a visual guide for us:
$\frac{dy}{dx} = xy$
We can divide both sides by the composite $y$ function, allowing us to get something like:
$\int \frac{1}{y}\frac{dy}{dx} \, dx = \int x \, dx $
This makes the equation easy to solve! All we have to do is solve the simple integrals to get our solution:
$\ln y = \frac{x^2}{2} + c$
$y = e^{\frac{x^2}{2} + c}$
>[!Abstract]- Example Question 1) i) - HL AAI
>Question: Solve the differential equation:
>$\frac{dy}{dx} = \frac{y+2}{x+1}$
>**Solution:**
>
>We can first rewrite the equation (so that we don't get lost, pretty common)
>$\frac{dy}{dx} = \frac{1}{x+1}y+2$
>We can then divide both sides by $y+2$. For the purpose of skipping steps, I'm going to directly integrate both sides by $dx$, giving us:
>$\int \frac{1}{y+2} \frac{dy}{dx} \, dx = \int \frac{1}{x+1} \, dx $
>$\int \frac{1}{y+2} \, dy = \ln(x+1) + c$
>$\ln (y+2) = \ln(x+1) + c$
>$y = x + 3 + c$
## Homogenous Differential Equations
A homogeneous equation is one where a multivariable function $f(x,y)$ can be written as a composite with the function:
$\frac{dy}{dx} = f\left( \frac{y}{x} \right)$
Where the $y$ values and $x$ values are constants to be found. An example of a homogeneous DE is shown below:
$\frac{dy}{dx} = \frac{{y + x}}{x}$
Simplifying gives us a better idea of why it is homogeneous:
$\frac{dy}{dx} = \frac{y}{x} + 1$
Now it's time for us to solve it!
>[!Success]- Solving the Equation
>To solve this, we can use the substitution $y = vx$. where $v$ is an arbitrary constant that can be expressed in terms of $x$. We therefore get the equation:
>$\frac{dy}{dx} = \frac{{vx + x}}{x}$
>To continue solving this, let's try differentiating the function $y = vx$. Note that as $v$ can be written in terms of $x$, this lets us create the following expression for $\frac{dv}{dx}$ using the product rule:
>$\frac{d}{dx}(vx) = v + x \frac{dv}{dx}$
>This serves as a substitution for $\frac{dy}{dx}$ as we have performed the equivalent of an implicit differentiation for $y$. This lets us continue to simplify:
>$x\frac{dv}{dx} + v = \frac{vx + x}{x} = v + 1$
>$x \frac{dv}{dx} = 1$
>$\frac{dv}{dx} = \frac{1}{x}$
>Integrate on both sides!
>$\int dv = \int \frac{1}{x} \, dx$
>$v = \ln \mid x\mid + c$
>We can therefore get a general formula of:
>$\frac{y}{x} = \ln \mid x\mid + c$
>$y = x\ln \mid x \mid + \ cx$
# ODEs - Methods of Solving
## Euler's Iterative Method
This method is a really, **really** slow method of approximation which can be used to solve ODEs if an initial numerical value (the **start**), an ending value, the **endpoint**, and the incrementation of the function, the **stepsize.** With a stepsize given by h with limits to ℎ=0 an approximation can be created of the rates of change.
>[!Success]- Intuition
>In each question that lets you use this method, there'll typically be a table and a range for you to fill in. For example, let's take the differential equation $\frac{dy}{dx} = x-y+7$ as an example. It is given that the range of the approximations we want to find are in the range $0 < x < 1$. The stepsize is defined as $h = 0.2$.
>Remember that the $y$ value changes with any change in the $x$ value, giving us a formula for the $y$ value after each step (using the function to denote sensitivity):
>$y_i = y_{i-1} + hf(x_{i-1}, y_{i-1})$
>Where $i-1$ denotes the values of the variables at the stepsize before.
>You can imagine this as an extension of the fundamental theorem of calculus - the $y$ value increments with respect to $\frac{dy}{dx}$, similar to:
>$y_{i} = \Delta x \left( \frac{dy}{dx} \right)$
>This is why the formula for $\Delta x$ using Euler's method is:
>$x_{i} = x_{i-1} + h$
>We can then substitute the stepsize we have on $x$, $0.2$, in place of $\Delta x$. We can substitute both values into the original equation as shown given that the original $x$ value is 0 and $y(0)$ is 0.5:
>$y_{i} = 0.5 + (0 - 0.5 + 7)$
>Getting us a new value for $y_i$ of $1.8$. We can use these new values for $x$ and $y$ to plug back into the function and get another $y$ value for the step.
## An ODE in the form $\frac{dy}{dx} + P(x)y = Q(x)$:(Integrating Factors)
An integrating factor is a tool we use to solver *linear differential equations* - or DEs where the variables are arranged as shown above. Given functions $P(x)$ and $Q(x)$ in the first-order differential equation, we can write the integrating factor as shown:
$\mu(x) = e^{\int P(x) \, dx }$
>[!Abstract]- Why $e$?
>
Let's look at an example to familiarise ourselves with LDEs:
$\frac{dy}{dx} + xy = x^2$
This is a imple example of a linear differential equation. Note that our $P(x)$ can therefore be interpreted as $x$, meaning that our integrating factor will be:
$\mu(x) = e^{\int x \, dx } = e^{\frac{1}{2}x^2}$
Multiplying both sides by the integrating factor yields:
$e^{\frac{1}{2}x^2}\left( \frac{dy}{dx} \right) + xe^{\frac{1}{2}x^2}y = x^2$
Note that this is a product rule derivative. Let's rewrite this by integrating by parts:
$\frac{d}{dx}(ye^{\frac{1}{2}x^2}) = x^2$
Now math the expression to get our answer!
$ ye^{\frac{1}{2}x^2} = \frac{x^3}{3} + c$
$\frac{1}{2}x^2y = \ln\left( \frac{x^3}{3} + c\right)$
$y = \frac{2\ln\left( \frac{x^3}{3} + c\right)}{x^2}$
We get our general formula for the differential equation! The expression's pretty complicated though...
Oh well, an answer's an answer!
# Second-Order Differential Equations
very difficult topic :(
By this point, we're out of the HL AA range! Hurray! We'll be using the differential equation book by Zills and Cullen moving forward, giving us a better view and intuition of topics both new and old.
Where the west is wild...
We take a second-order differential equation as a differential equation with a highest order of 2 - these also form the backbone for our [[Boundary Value Problems (Maths)|boundary value problems]], which require a second-order derivative to find a solution for.
## Pursuit Curves
# Example Problems
>[!Example]- 11A Question 28)
>Consider this system of Coupled Differential Equations:
>$\frac{dx}{dt} = x+2y$
>$\frac{dy}{dt} = x-y$
>When $t = 0$, $x = 1$ and $y = 2$.
>Use Euler's Method with a step length of 0.1 to estimate the values of $x$ and $y$ when $t = 1$.
>
>**Solution:**
>
>[!Example]- 11B Question 41)
>a) Show that the substitution $u = y + \frac{1}{x}$ transforms the differential equation $x^2 \frac{dy}{dx} = xy - x + 2$ into $x \frac{du}{dx} = u - 1$.
>b) Hence find the general solution of the equation $x^2\frac{dy}{dx} = xy-x+2$.
>
>**Solution a)**
>Note that taking the derivative of $u$ with respect to $x$ gives us the following:
>$\frac{du}{dx} = \frac{dy}{dx} - \frac{1}{x^2}$
>We can therefore perform a substitution with the $\frac{dy}{dx}$ in the main differential equation:
>$x^2 (\frac{du}{dx} + \frac{1}{x^2}) = xy-x+2$
>
>**Solution b)**
><u>*Method 2*</u>:
>Just use our simpler differential equation and treat it like a $\frac{dy}{dx} = f(x)$ relationship:
><u>*Method 1*</u>:
>Use the integrating factor method!
>$x^2\frac{dy}{dx} - xy = 2-x$
>$\frac{dy}{dx} - \frac{y}{x} = \frac{2}{x^2} - \frac{1}{x}$
>The integrating factor for this equation is therefore given by $\mu_{x} = e^{\int \frac{1}{x} \, dx } = e^{1/x}$
>Multiply both sides by the integrating factor:
>$\frac{1}{x} \frac{dy}{dx} - \frac{y}{x^2} = \frac{2}{x^3} - \frac{1}{x^2}$
>Isolate the $y$ and exterminate - integrate both sides!
>$\int \frac{1}{x} \, dy - \frac{y}{x^2} = \int \frac{2}{x^3} - \frac{1}{x^2} \, dx $
>$\frac{y}{x} = \frac{1}{x} - \frac{1}{x^2} + c$
>This gives us our final answer:
>$y = 1 - \frac{1}{x} + cx$
>[!Example]- 11B Question 45)
>Variables x and y satisfy the differential equation $\sqrt{ 1 − x^2}\ \frac{dy}{dx}$ = $\sqrt{ 1-y^2 }$ when y = 1/2 and x = $\frac{\sqrt{3}}{2}$ . Show that this particular solution can be written in the form y = $x\sqrt{ A } + B \sqrt{ 1-x^2 }$, stating the values of the constants A and B.
>
>**Solution:**
>Note that we can rewrite this as a separable differential equation with the formula $\frac{dy}{dx} = f(x) g(y)$:
>$\frac{dy}{dx} = \frac{\sqrt{ 1-y^2 }}{\sqrt{ 1-x^2 }}$
>Let's simplify this using the general separable differential equation formula!
>$\int \frac{1}{\sqrt{ 1-y^2 }} \frac{dy}{dx} \, dx = \int \frac{1}{\sqrt{ 1-x^2 }} \, dx $
>This nets us the following identity:
>$\arcsin y = \arcsin x + c$
>Where $c$ is an arbitrary constant consisting of the constants from both integrals.
>Substitute our numerical values to get a value for $c$:
>$\arcsin \frac{1}{2} = \arcsin \frac{\sqrt{ 3 }}{2} + c$
>$c = -\frac{\pi}{6}$
>We can bring out the $\arcsin$ on both sides by applying the $\sin$ operator to both sides:
>$y = \sin \left( \left( \arcsin x-\frac{\pi}{6} \right) \right)$
>Note that this is a compound angle. We can use the [[Trig Identities - Derivations DLC Ver. (Maths)|compound angle identity for sine]] to expand this:
>$y = \sin \arcsin x\cos \frac{\pi}{6} - \cos \arcsin x \sin \frac{\pi}{6}$
>$y = x\cos c - \cos \arcsin x\sin \frac{\pi}{6}$
>This means that $\arcsin x$ must be an angle for $\cos x$ to be valid. Note that we can make a right triangle with hypotenuse length 1 and a height with length x. This means it's base is given by the length $\sqrt{ 1-x^2 }$ thanks to Pythagoras' Theorem. We can therefore take the $\sin$ of the right triangle as $\frac{o}{h} = \frac{x}{1}$, meaning that our angle to the base $\theta$ is equal to $\arcsin x$. Remember that $\cos \theta$ is given by the formula $\frac{a}{h}$, giving us:
>$\cos \arcsin x = \sqrt{ 1-x^2 }$
>To prove that we can write the differential equation in the form specified, we must substitute the values from $c$ into the equation as shown:
>$y = x\frac{\sqrt{ 3 }}{2} - \sqrt{ 1-x^2 } \frac{1}{2}$
>This gives us a value for the constants $A$ and $B$:
>$A = \frac{x}{2} = \frac{\sqrt{ 3 }}{4}$
>$B = \frac{1}{2}$
>[!Example]- 11C Question 19)
>Find the particular solution of the differential equation $\frac{dy}{dx} + \frac{2xy}{x^2+1} = 2x$ with the initial condition $y = 0$ when $x = 0$.
>[!Example]- 11C Question 22)
>A lazy accountant is given a bunch of differential equations to do. Unfortunately, he's since forgotten the maths he's done in high school in favour of learning how to ride a unicycle and really needs a way to simplify the equation. Show that the general solution of the differential equation $\frac{dy}{dx} - y\tan x = \cos x$ can be written int$y = A \sin x + (Bx + c)\sec x$.
>
>**Solution a)**
>Find the integrating factor.
>$\mu(x) = e^{\int -\tan x \, dx } = e^{\ln \cos x} = \cos x$
>Multiply it across the entire expression to get:
>$\frac{d}{dx}(y\cos x) = \cos^2x$
>Integrate both sides to get:
>$y\cos x = \frac{1}{2}(x + \sin x\cos x) + c$
>Now divide by $\cos x$! Make sure the algebra's always right - bad algebra is a question-killer for physics and maths.
>$y = \frac{x}{2\cos x} + \frac{1}{2}\sin x + \frac{c}{\cos x}$
>Rewrite all the $\cos x$ terms into $\sec x$ to get your answer. We've proven it!
>$y = \frac{x}{2} \sec x + \frac{1}{2}\sin x + c \sec x$
>$y = \frac{1}{2}\sin x + \left( \frac{x}{2} + c \right) \sec x$
>$y = A\sin x + (Bx + c)\sec x$
# What's Next?