4.1: Introduction to Laplace Transforms

Open In Colab

Reading: Notes on Diffy Q’s Section 6.1 Part A

A useful problem solving technique in mathematics (and possibily life outside of math) can be summarized as follows:

For example, the “reverse product rule” a special integrating factor, \(\mu(t)\), is used to transform a linear first order differential equation into an easier problem we solve. In this chapter we study we will apply a similar technique to solve differential equations, using the Laplace transform. Before jumping right into differential equations, we will first get some practice working with the Laplace transform and explore some properties. Laplace transforms are a powerful tool for solving differential equations, are nice example of an integral transform that have applications throughout mathematics and engineering, and are an example of a lot of nice mathematical concepts from calculus coming together.

Improper Integrals


The improper integral of \(g\) over \(\lbrack a , \infty )\) is defined as

\[ \int_a^{\infty} g(t) \ dt = \lim_{N \to \infty} \int_a^N g(t) \ dt.\]

  • We say the improper integral converges if the limit exists.
  • Otherwise we say the improper integral diverges.

Question 1:


Using calculus (not Python), determine whether the integral converges or diverges. Be sure you justify the steps in your work.

\[\int_0^{\infty} e^{-0.2t} \ dt\]

Solution to Question 1:







Question 2:


Use the Python widget generated by the code cells below to demonstrate whether the improper integral converges or diverges. Explain how you determined your answer using the widget.

\[\int_0^{\infty} e^{-0.2t} \ dt\]

Solution to Question 2:





Run (do not edit) the 3 code cells below. Once the widget has opened, use the slider to change the upper limit of the integral. Click the “Run Interact” button to calculate the definite integral and plot the result.


#########################
# Do not edit!
# Just run the code cell
#########################

import numpy as np
import matplotlib.pyplot as plt
import sympy as sym
from sympy.abc import s,t

def my_fun(x):  
    return np.exp(-0.2*x)

def plot_int(f, t0=0, t1=1, tmax=30):
    x = np.linspace(t0, tmax, 1000)
    ans = sym.integrate(sym.exp(-0.2*t), (t,0,t1))
    plt.plot(x, my_fun(x))
    plt.fill_between(x, my_fun(x), 0,  
                     where = (x >= t0) & (x <= t1),
                     color = 'orange')
    plt.show()
    return print("Area is approx. ", ans)
#########################
# Do not edit!
# Just run the code cell
#########################

from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets

# A special thing from colab to enable widgets
#from google.colab import output
#output.enable_custom_widget_manager()
################################
# DO NOT EDIT this code cell
# Simply Run this code cell 
# Then click on "Run Interact" 
# To approx the definite integral
##################################

interact_manual(plot_int, 
                f=fixed(my_fun),
                t0=fixed(0),
                t1=widgets.FloatSlider(min=0.1, max=30.0, step=0.1, value=1),
                tmax=fixed(30))

Question 3:


Use the Python widget generated by the code cells below to demonstrate whether the integral converges or diverges. Then verify your results using calculus. - Is your intuition in working with the widget consistent with result derived using calculus? Explain.

\[\int_1^{\infty} \frac{1}{t} \ dt\]

Solution to Question 3:






Run (do not edit) the code cell below. Once the widget has opened, use the slider to change the upper limit of the integral. Click the “Run Interact” button to calculate the definite integral and plot the result. Then verify using calculus and justifying your work.


################################
# DO NOT EDIT this code cell
# Simply Run this code cell 
# Then click on "Run Interact" 
# To approx the definite integral
##################################

# Updating function to be 1/x
def my_fun(x): 
    return 1/x

# Updating plotting function
def plot_int(f, t0=1, t1=2, tmax=80):
    x = np.linspace(t0, tmax, 1000)
    ans = sym.integrate(1/t, (t,1,t1))
    plt.plot(x, my_fun(x))
    plt.fill_between(x, my_fun(x), 0,  
                     where = (x >= t0) & (x <= t1),
                     color = 'orange')
    plt.show()
    return print("Area is approx. ", ans)

interact_manual(plot_int, 
                f=fixed(my_fun),
                t0=fixed(1),
                t1=widgets.FloatSlider(min=0.1, max=80.0, step=0.1, value=1),
                tmax=fixed(80))

Definition of the Laplace Transform


Let \(f(t)\) be a function on \(\lbrack 0 , \infty )\). The Laplace transform of \(f\) is the function \(F\) defined by

\[\Large{\color{dodgerblue}{ \mathscr{L} \left\{ f \right\} = F(s) = \int_0^{\infty} e^{-st}f(t) \ dt}} .\]

  • The domain of \(F(s)\) is all values of \(s\) for which the integral converges.
  • The functions \(f\) and \(F\) form a transform pair.

Question 4:


Using the definition of the Laplace transform, find the Laplace transform \(F(s)=\mathscr{L} \left\{ f(t) \right\}\) for \(f(t) = 2\). Be sure to state the domain of the resulting Laplace transform \(F(s)\), and provide justifications for your supporting work.

Solution to Question 4:







Computing Laplace Transforms with SymPy in Python


We can use the sympy.laplace_transform() function from the SymPy library to check our work.

  • sympy.laplace_transform_(function, func_variable, variable_of_transform).

    • By default, we typically use t as the variable in \(f(t)\), and
    • We use s as the variable in the resulting transform \(F(s)\).
    • We use f to denote the function.
    • Thus we use sympy.laplace_transform_(f,t,s).

  • The function will return the Laplace transform (if it exists) as well as domain of \(F(s)\) based on the convergence of the improper integral.

  • For more examples with sympy.laplace_transform_(function, t, s), here’s a good resource.

  • For official documentation, see SymPy Documentation.

Question 5:


Run the code cells below to check your work in Question 4 to find Laplace transform \(F(s)=\mathscr{L} \left\{ f(t) \right\}\) for \(f(t) = 2\).

Solution to Question 5:






Check your previous answer using the Python code cells below.



import sympy as sym
from sympy.abc import s,t


f = 2  # define your function with respect to t
F = sym.laplace_transform(f, t, s)  # sym.laplace_transform_(function, func_var, out_var)

print(F)  # returns F(s) and convergence interval
# Use the option noconds=True to hide info about domain

F = sym.laplace_transform(f, t, s, noconds=True)  # hides conditions for convergence
print(F)

Building a Laplace Transform Function in Python


To help simplify the Python code, we define a Laplace transform function with the command L(f).

  1. Define your function f as a function of the symbol t imported in the code above.
  2. Then run the command L(f) to find the Laplace transform \(F(s) = \mathscr{L} \left\{f(t) \right\}\).
Caution

Be sure you have imported SymPy and imported s and t as symbols.

##################################
# DO NOT EDIT THIS CELL
# Run this code cell to create a 
# Laplace transform function
##################################

def L(f):
    return sym.laplace_transform(f, t, s, noconds=True)

Question 6:


Find and state the domain of the Laplace transform \(F(s)=\mathscr{L} \left\{ f(t) \right\}\) for \(f(t) = t\).

Solution to Question 6:





Solve “by hand” using calculus, and then check your answer using the Python code cell below.


#############################################################
# STUDENT TO DO: 
# Replace the ?? with an approrpriate expression
#############################################################

f = ??  # define your function with respect to t

L(f)

Question 7:


Find and state the domain of the Laplace transform \(F(s)=\mathscr{L} \left\{ f(t) \right\}\) for \(f(t) = e^{3t}\).

Solution to Question 7:






Solve “by hand” using calculus, and then check your answer using the Python code cell below.



#############################################################
# STUDENT TO DO: 
# Replace the ?? with an approrpriate expression
#############################################################

f = sym.exp(??)  # define your function with respect to t

L(f)

Question 8:


Find and state the domain of the Laplace transform \(F(s)=\mathscr{L} \left\{ f(t) \right\}\) for \(f(t) = \cos{(bt)}\) where \(b \ne 0\) is a constant.

Solution to Question 8:






Solve “by hand” using calculus, and then check your answer using the Python code cell below.


#############################################################
# STUDENT TO DO: 
# Replace the ?? with an approrpriate expression
#############################################################

b = sym.symbols('b', real=True, nonzero=True)

f = sym.cos(??)  # define your function with respect to t

L(f)

Question 9:


Find and state the domain of the Laplace transform \(F(s)=\mathscr{L} \left\{ f(t) \right\}\) for

\[f(t) = \left\{ \begin{array}{ll} 5 \ \ & 0 < t < 2 \\ e^{8t} \ \ & t >2 \end{array} \right.\]

Solution to Question 9:






Solve “by hand” using calculus, and then check your answer using the Python code cell below.



#############################################################
# STUDENT TO DO: 
# Replace each ?? with an approrpriate expression
#############################################################


f = sym.Piecewise(??)  # define your function with respect to t

L(f)

Common Laplace Transforms


Below is a table of common Laplace transforms pairs. You can now verify each of these using Python!

\(\displaystyle \large f(t)\) \(\displaystyle \large F(s) = \mathscr{L} \left\{ f(t) \right\}\)
\(\displaystyle \large f(t)=1\) \(\displaystyle \large F(s)=\frac{1}{s}, \ s > 0\)
\(\displaystyle\large f(t)=e^{at}\) \(\displaystyle \large F(s) = \frac{1}{s-a}, \ s > a\)
\(\displaystyle \large f(t)=t^n, \ n=1,2, \ldots\) \(\displaystyle \large F(s) = \frac{n!}{s^{n+1}}, \ s > 0\)
\(\displaystyle \large f(t)=\sin{(bt)}\) \(\displaystyle \large F(s) = \frac{b}{s^2+b^2}, \ s > 0\)
\(\displaystyle \large f(t)=\cos{(bt)}\) \(\displaystyle \large F(s) = \frac{s}{s^2+b^2}, \ s > 0\)

Creative Commons License Information


Creative Commons License
Exploring Differential Equations by Adam Spiegler is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Based on a work at https://github.com/CU-Denver-MathStats-OER/ODEs and original content created by Rasmussen, C., Keene, K. A., Dunmyre, J., & Fortune, N. (2018). Inquiry oriented differential equations: Course materials. Available at https://iode.sdsu.edu.