1.1. Revision of Concepts#
Classification of Differential Equations#
Note
Important things to retain from this block:
Identify characteristics of differential equations
Understand how numerical and analytical solutions might differ as we get to more complex problems which need simplification
Remember that analytical solutions are not always possible
Differential equations can be classified as Ordinary Differential Equations (ODEs) and Partial Differential Equations (PDEs). ODEs have derivatives with respect to a single independent variable (either time or space), for example:
describes the rate of change of the variable \(x\) in time \(t\).
PDEs have derivatives with respect to multiple independent variables (often time and space), for example:
describes the propagation of the concentration \(c\) in time \(t\) along dimension \(x\).
The classification can be done more precisely by the equation’s order and linearity (linear or non-linear). The order refers to the highest derivative while non-linear equations are those in which the dependent variable or its derivative(s) are non linear (exponential, sine or with a power different than 1). See the following examples:
Analytical vs Numerical Solutions#
Equations can be solved in two ways: analytically and numerically. The analytical solution is exact while a numerical solution requires computational methods to approximate the solution. So why would we use anything other than analytical solutions? Well, analytical solutions are difficult/impossible to find for complex equations, specially when the problem involves a complex geometry. This complexity will be treated later in the book. For now, let’s illustrate analytical and numerical solutions considering a simple problem.
Find the value \(x\) for \(f(x)=3x-2\) when \(f(x) = 0\) in the interval \([0,1]\).
Analytical Solution
Note that there is no need for any extra computation. You can say that there is only one computation needed: the assignment of the \(x\) value.
The code below shows an iterative method to find the x value.
def f(x):
return 3*x-2
dx = 0.001
for i in range(1000):
x = dx*i
if f(x) * f(x+dx) < 0:
print("Number of computations needed to find a solution",i*4)
break
print("Answer x = ", x+dx)
Number of computations needed to find a solution 2664
Answer x = 0.667
Note that the 2664 computations needed is highly dependent on the method (this one is not very efficient). Here the search starts at x=0 and increases in steps of 0.001, which also limits the accuracy of the solution.
Let us now look to another simple example:
Find the value \(x\) for \(f(x) = 3\sin(x)-2\) when \(f(x) = 0\) in the interval \([0,1]\).
Analytical Solution
Numerical Solution
import math
def f(x):
return 3*math.sin(x)-2
dx = 0.001
for i in range(1000):
x = dx*i
if f(x) * f(x+dx) < 0:
print("Number of computations needed to find a solution",i*4)
break
print("Answer x = ", x+dx)
Number of computations needed to find a solution 2916
Answer x = 0.73
Note that there is no attempt to solve f(x) directly. Only the function is defined and the exact same steps of the previous problem are followed.