This is a
tutorial made solely for the purpose of education and it was designed
for students taking Applied Math 0330. It is primarily for students who
have very little experience or have never used
Mathematica before and would like to learn more of the basics for this computer algebra system. As a friendly reminder, don't forget to clear variables in use and/or the kernel.
Finally, the commands in this tutorial are all written in bold black font,
while Mathematica output is in normal font. This means that you can
copy and paste all commands into Mathematica, change the parameters and
run them. You, as the user, are free to use the scripts for your needs to learn the Mathematica program, and have
the right to distribute this tutorial and refer to this tutorial as long as
this tutorial is accredited appropriately.
Return to computing page for the first course APMA0330
Return to computing page for the second course APMA0340
Return to Mathematica tutorial for the second course APMA0330
Return to Mathematica tutorial for the first course APMA0340
Return to the main page for the course APMA0340
Return to the main page for the course APMA0330
Return to Part IV of the course APMA0330
where \( \texttt{D} = {\text d} / {\text d}x \) is the derivative operator (with respect to independent variable x).
Theorem: If coefficients \( a_n (x), a_{n-1} (x), \ldots , a_0 (x) \)
are continuous functions on some interval |a,b| and \( a_n (x) \ne 0 , \) then the homogeneous
linear differential equation \( L \left[ x, \texttt{D} \right] y =0 , \) which can be written as
has n linearly independent solutions \( \left\{ y_1 (x), y_2 (x), \ldots , y_n (x) \right\} \)
that are continuous on the interval |a,b|. Then the general solution of the equation on the interval is
on an interval |a,b|, and let \( \left\{ y_1 (x), y_2 (x), \ldots , y_n (x) \right\} \)
be a fundamental set of solutions of the associated homogeneous differential equation
\( L \left[ x, \texttt{D} \right] y =0 \) on |a,b|. Then the general solution
of the nonhomogeneous equation \( L \left[ x, \texttt{D} \right] y = f(x) \) on the interval is
where \( C_1 , C_2 , \ldots , C_n \) are arbitrary constants. ■
As we see from the previous Theorem, the general solution of a nonhomogeneous linear equation consists of the sum of two functions:
\[
y (x) = y_p (x) + y_h (x) ,
\]
The linear combination \( y_h (x) = C_1 \, y_1 (x) + C_{2} \, y_2 (x) + \cdots + a_{n-1} \, y_{n-1} (x) + a_n \, y_n (x) , \)
which is the general solution of the homogeneous equation \( L \left[ x, \texttt{D} \right] y = 0 \) is
sometimes called the complementary function for nonhomogeneous equation. In other words, to solve a
nonhomogeneous linear differential equation \( L \left[ x, \texttt{D} \right] y = f(x) \)
we first solve the associated homogeneous equation \( L \left[ x, \texttt{D} \right] y = 0 \)
and then find any particular solution of the nonhomogeneous equation.
If all coefficients of the linear differential operator \( L \left[ \texttt{D} \right] \)
are constants, then the general solution of the corresponding homogeneous equation \( L \left[ x, \texttt{D} \right] y = 0 \)
exist for all x on real axis. In this case, it is [possible to find the fundamental set of solutions explicitly.
Following Leonhard Euler, we seek solutions to the homogeneous linear constant coefficient equation
as exponential function \( y (x) = e^{\lambda\,x} , \) for some parameter λ. Substituting
the exponential function into the homogeneous equation, we get
The polynomial of degree n, denoted by \( L(\lambda ) , \) is called the
characteristic polynomial corresponding to the linear constant coefficient differential operator
\( L \left[ \texttt{D} \right] = a_n \texttt{D}^n + \cdots + a_1 \texttt{D} + a_0 . \)
If the characteristic equation \( L(\lambda ) =0 \) has n distinct roots (real or complex),
we get n linearly independent exponential solutions that constitute the fundamental set of solutions for the
given homogeneous linear constant coefficient differential equation.
A particular interest is a second order differential equation. Let us consider the equation of motion for
undriven damped harmonic oscillator (coefficients μ and ω0 > 0 are assumed constants)
\[
\ddot{y} + 2\mu\,\dot{y} + \omega_0^2 y =0 ,
\]
subject to the initial conditions
\[
y(0) = y_0 , \qquad \dot{y}(0) = v_0 .
\]
Assuming that the roots of the characteristic equation \( \lambda^2 + 2\mu\,\lambda + \omega_0^2 =0 \)
are distinct,
the differential equation has two linearly independent solutions
\( y_{1,2} = e^{\lambda_{1,2} t} . \)
Then the solution (which is unique) of the given initial value problem can be expressed as
The corresponding characteristic polynomial \( L(\lambda ) = \lambda^2 - \lambda -6 = (\lambda +2)(\lambda -3) \)
has two distinct real roots \( \lambda =-2 \) and \( \lambda = 3 . \)
Then the functions \( y_1 (x) = e^{-2x} \) and \( y_2 (x) = e^{3x} \)
form a fundamental set of solutions, and the general solution to \( L \left[ x, \texttt{D} \right] y = 0 \) is
\[
y(x) = C_1 e^{-2x} + C_2 e^{3x} ,
\]
where C1 and C1 are arbitrary constants.
roots = Solve[s^2 - s - 6 == 0, s]
first = s /. roots[[1]]
second = s /. roots[[2]]
root = {first, second}
Soln = Map[Exp[# x] &, root]
{E^(-2 x), E^(3 x)}
AllSoln[x_]=Soln.{c1,c2}
Out[17]= c1 E^(-2 x) + c2 E^(3 x)
Simplify[L[x, AllSoln] == 0] (* check the answer *)
Out[18]= True
DSolve[y''[x] - y'[x] - 6 y[x] == 0, y[x], x]
Example: We consider the third order linear differential operator:
The corresponding characteristic polynomial \( L(\lambda ) = \lambda^3 -2\,\lambda^2 - 5\,\lambda +6 = (\lambda -1)(\lambda +2)(\lambda -3) \)
has three distinct real roots \( \lambda =1, \) \( \lambda =-2 , \) and \( \lambda = 3 . \)
Then the functions \( y_1 (x) = e^{x} , \quad y_1 (x) = e^{-2x} , \) and \( y_3 (x) = e^{3x} \)
form a fundamental set of solutions, and the general solution to \( L \left[ x, \texttt{D} \right] y = 0 \) is
Return to the main page (APMA0330)
Return to the Part 1 (Plotting)
Return to the Part 2 (First Order ODEs)
Return to the Part 3 (Numerical Methods)
Return to the Part 4 (Second and Higher Order ODEs)
Return to the Part 5 (Series and Recurrences)
Return to the Part 6 (Laplace Transform)