In this blog post, you will learn what a Laplace Transform is, and how to use them to solve differential equations.
What is a Laplace Transform?
Laplace Transforms are important because they enable you to solve differential equations algebraically. Therefore, they are important for solving problems in science, engineering, and applied math.
The definition of a Laplace Transform is the following:
Given a function f(t) defined for all t greater than or equal to zero, the Laplace Transform of f is the function F defined as follows:
For all values of s for which the improper integral converges.
Computing the Laplace Transform by Definition
Let’s look at a simple function f(t)=2, and compute its Laplace Transform.
Note: once you compute some of these by hand, you notice you keep using the same ones over and over. Therefore, there are tables of Laplace transforms you can reference to compute them. You can also use them for computing the inverse of the transform.
Inverse Transforms
As you might guess, sometimes, we want to reverse F(s) back to a function f(t), which is the inverse Laplace Transform. Since, we just computed one, let’s reverse it.
This is important when you want to transform the algebraically solved expression back into a particular solution of a differential equation (more on that later.)
Solving a Differential Equation with Laplace Transforms
Consider the following differential equation:
with the initial conditions x(0)=x'(0)=0. Taking the Laplace transform of it converts it into the following:
Solving for X(s), we get the following:
Now, to compute the inverse Laplace transform, which will give us x(t). We must use partial fractions, which gives us the following:
Solving this partial fraction, you will obtain A=C=0, B= 3/5, and D=-3/5.
Therefore, we have the following:
By computing the inverse Laplace transform, we get x(t), which is the following:
This is the particular solution to the equation given the initial conditions.
Final Thoughts
In this blog post, you learned what Laplace transforms are, and you learned how to use them to solve differential equations.
Euler’s method is used for numerical approximation of a solution to a differential equation that can’t be solved for an explicit solution using elementary methods, such as substitution for homogeneous equations or Bernoulli equations (Henry Edwards et al., 2022). Katherine Johnson used Euler’s method to solve real-world problems at NASA (Meyers, 2017). Personally, I disagree with her claim that math is either absolutely right or absolutely wrong, though.
The algorithm for Euler’s method is to first pick an initial point
of the particular solution you want to compute (Henry Edwards et al., 2022). Then, one chooses a horizontal step-size h, which is the horizontal distance between the approximated points of the solution. The formula to calculate the (n+1)-th point is the following (Henry Edwards et al., 2022):
where
One must be careful when using Euler’s method because there is a local error when moving away from the initial point, which is a vertical distance from the approximated point to the actual point of the particular solution curve (Henry Edwards et al., 2022). As one moves further from the initial point, the error accumulates, and it is called cumulative error (Henry Edwards et al., 2022). The remedy for this is to choose a sufficiently small step size, which will reduce the error (Henry Edwards et al., 2022). However, there is typically a tradeoff when picking h because when h is too small, it may take thousands of years to compute even with a computer (Henry Edwards et al., 2022).
Katherine Johnson was an African American applied mathematician who worked at NASA (Meyers, 2017). She suggested to use Euler’s method to solve differential equations related to the trajectory of astronaut John Glenn’s space capsule. Despite the method being “ancient”, as described by one of her male colleagues, she rebutted that “it works numerically” (Meyers, 2017).
When Katherine Johnson claims “math: you’re either right or wrong — and that I liked about it” (National Geographic, 2021, 0:45) , I tend to disagree. I disagree because sometimes oversimplified models can enable one to capture important insights into the problem. For example, the Lotka-Volterra predator-prey model allows one to see that predator-prey populations oscillate; however, the models typically do not allow one to actually predict the populations in nature (Chasnov, 2022; Clark & Neuhauser, 2022). This is a case in mathematics where it is possible to be partially correct.
In conclusion, Euler’s method is an old yet effective way to numerically approximate solutions to differential equations. It has been used to solve real-world problems in NASA by applied mathematicians like Katherine Johnson to calculate trajectories of a space capsule. Also, despite Katherine Johnson’s claim that one is either right or wrong in math, I think that it is possible to be partially correct in math in the case of oversimplified models that allow one to gain further insights into problems like the Lotka-Volterra predator-prey model.
Using MATLAB to Obtain a Numerical Approximation of a Solution
Next, MATLAB will be used to solve the following differential equation:
with initial condition y(0) = -3.
The following is the MATLAB code to do so:
% Euler's Method for solving:
% y' = x + (1/5)y
% y(0) = -3
clc;
clear;
% Step size
h = 1;
% Interval
x0 = 0;
xn = 5;
% Initial condition
y0 = -3;
% Number of steps
n = (xn - x0)/h;
% Arrays to store values
x = zeros(1, n+1);
y = zeros(1, n+1);
% Initial values
x(1) = x0;
y(1) = y0;
% Euler's Method loop
for i = 1:n
x(i+1) = x(i) + h;
y(i+1) = y(i) + h * ( x(i) + (1/5)*y(i) );
end
% Display results
disp(' x y');
disp([x' y']);
% Plot the approximation
plot(x, y, '-', 'LineWidth', 1.5);
xlabel('x');
ylabel('y');
title('Euler Method Approximation');
grid on;
Clark, A. T., & Neuhauser, C. (2018). Harnessing uncertainty to approximate mechanistic models of interspecific interactions. Theoretical Population Biology, 123, 35–44. https://doi.org/10.1016/j.tpb.2018.05.002
Henry Edwards, C., Penney, D. E., & Calvis., D. (2022). Differential Equations and Boundary Value Problems: Computing and Modeling (6th Edition).
Differential equations show up everywhere in science and engineering: vibrating springs, electrical circuits, population models, and control systems all rely on them. In this post, we’ll walk through how to solve the second-order linear differential equation
y′′+2y′+y=cos(t)
Afterwards, it will be demonstrated how to solve such a problem with MATLAB.
Solve the Homogeneous Equation
We begin with the associated homogeneous equation:
y′′+2y′+y=0
To solve it, we use the characteristic equation method. Replace:
y′′→r²
y′→r
y→1
This gives:
r²+2r+1=0
Factor the polynomial:
(r+1)²=0
So we have a repeated root:
r=−1
For a repeated root r, the homogeneous solution is:
where C1 and C2 are arbitrary constants.
Find a Particular Solution
Now we need a particular solution y_p(t) to account for the forcing term cos(t).
Because the right-hand side is trigonometric, we try:
Notice that the Acos(t) and −Acos(t) cancel, and the Bsin(t) terms also cancel:
2Bcos(t)−2Asin(t)=cos(t)
Now match coefficients.
For cos(t):
2B=1
so
B=1/2
For sin(t):
−2A=0
so
A=0
Therefore,
y_p(t)=(1/2)*sin(t)
Write the General Solution
The full solution is the sum of the homogeneous and particular solutions:
So the final answer is
Why This Method Works
This approach is standard for linear differential equations with constant coefficients:
Solve the homogeneous equation using the characteristic polynomial.
Guess a form for the particular solution based on the forcing term.
Determine unknown coefficients by substitution.
Combine both parts.
The exponential portion captures the system’s natural behavior, while the sine term reflects the external forcing function.
Solving with MATLAB
The following is the MATLAB code that will solve the problem:
syms y(t) t;% dy = y'dy = diff(y(t));% dy2 = y''dy2 = diff(y(t), 2);% y'' + 2*y' + y = cos(t)diffEq = dy2 + 2*dy + y == cos(t);% solve the differential equation and simplify it.simplify(dsolve(diffEq))
By executing the code, you will obtain the same answer that was manually solved for:
Running the above MATLAB code and obtaining the same solution.
Final Thoughts
The equation
y′′+2y′+y=cos(t)
is a classic example of a damped, driven system. The repeated root in the homogeneous solution creates the factor of te^(−t), while the cosine forcing introduces a sinusoidal steady-state response.
Once you’re comfortable with this process, you can apply it to a huge class of differential equations that appear in physics, engineering, and applied mathematics.