200 67 5MB
English Pages 441 Year 2016
Calculus and Differential Equations with Mathematica
Calculus and Differential Equations with Mathematica
Pramote Dechaumphai
Chulalongkorn University Press
Bangkok
α
Alpha Science International Ltd. Oxford, U.K.
Calculus and Differential Equations with Mathematica 440 pgs. | 151 figs.
Pramote Dechaumphai Department of Mechanical Engineering Chulalongkorn University, Bangkok Copyright © 2016 ALPHA SCIENCE INTERNATIONAL LTD. 7200 The Quorum, Oxford Business Park North Garsington Road, Oxford OX4 2JZ, U.K. www.alphasci.com ISBN 978-1-78332-264-0 E-ISBN 978-1-78332-312-8 All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, without prior written permission of the publisher.
There are so many kinds of books for me to read. Some bring me joy; Some give me knowledge and entertainment. I therefore read every day. Books present a diversity of subjects, For readers to explore for their own pleasure. Since there is so much that can be discovered in books, I will continue reading for the rest of my life without getting bored. —HRH Princess Maha Chakri Sirindhorn, composed when she was 12 years old
Translated by the Chalermprakiat Center of Translation and Interpretation, Faculty of Arts, Chulalongkorn University, as part of Chulalongkorn University Press’s celebration of the 60th Birthday of HRH Princess Maha Chakri Sirindhorn
Preface Mathematica is a software widely used to solve mathe-matical problems that arise in the fields of science and engineering. These problems require profound understanding in the fundamen-tals of calculus and differential equations. Mathematica can solve many types of calculus problems and differential equations symbolically for exact closed-form expressions. If their exact solutions are not available, approximate solutions are obtained by using numerical methods. This book, Calculus and Differential Equations with Mathematica, explains how to use Mathematica to solve calculus and differential equation problems in a clear and easy-to-understand manner. Essential topics in the calculus and differential equation courses are selected and presented. These topics include: limit, differentiation, integration, series, special functions, Laplace and Fourier transforms, ordinary and partial differential equations. Numerous examples are used to present detailed derivation for their solutions. These solutions are carried out by hands as normally done in classes and verified by using the Mathematica commands. Students thus understand detailed mathematical process for obtaining solutions. They, at the same time, realize the software capability that can provide the same solutions effectively within a short time. The solutions are then plotted to provide clear understanding of their behaviors. The author thanks Miss Kaiumporn Phongkhachorn for her fine typing and his graduate students for proofreading the manuscript. He expresses his appreciation to Miss Tasanee Watanachaopisut and Mr. Akarat Niyomploy of KNJ International (Thailand) Ltd for their kind advice and support. He acknowledges Chulalongkorn University Press and Alpha Science International for printing and distributing this book. He appreciates his wife Mrs. Yupa Dechaumphai for her support while writing this book. Pramote Dechaumphai
Contents Preface 1
vii
Symbolic Mathematics by Mathematica
1
1.1 Introduction 1.2 Symbolic Mathematics Software 1.3 History and Capability of Mathematica 1.4 Mathematica Fundamentals 1.5 Concluding Remarks Exercises
1 2 5 6 12 13
2
19
Calculus
2.1 Introduction 2.2 Limits 2.3 Differentiation 2.4 Integration 2.5 Taylor Series 2.6 Other Series 2.7 Concluding Remarks Exercises
19 20 26 35 43 48 50 51
3
59
Differential Equations
3.1 Introduction 3.2 Characteristics of Differential Equations 3.3 Solutions of Differential Equations 3.4 Concluding Remarks Exercises
59 60 62 71 72
4
First-Order Differential Equations
79
4.1 4.2 4.3 4.4
79 80 87 95
Introduction Separable Equations Linear Equations Exact Equations
x Contents
4.5 Special Equations 4.6 Numerical Methods 4.7 Concluding Remarks Exercises
107 114 120 120
5
129
Second-Order Linear Differential Equations
5.1 Introduction 129 5.2 Homogeneous Equations with Constant Coefficients 130 5.3 Solutions from Distinct Real Roots 133 5.4 Solutions from Repeated Real Roots 137 5.5 Solutions from Complex Roots 142 5.6 Nonhomogeneous Equations 150 5.7 Method of Undetermined Coefficients 152 5.8 Variation of Parameters 158 5.9 Numerical Methods 167 5.10 Concluding Remarks 170 Exercises 172 6
Higher-Order Linear Differential Equations
181
6.1 Introduction 181 6.2 Homogeneous Equations with Constant Coefficients 182 6.3 Solutions from Distinct Real Roots 185 6.4 Solutions from Repeated Real Roots 189 6.5 Solutions from Complex Roots 192 6.6 Solutions from Mixed Roots 195 6.7 Nonhomogeneous Equations 198 6.8 Numerical Methods 206 6.9 Concluding Remarks 210 Exercises 211 7
Laplace Transforms
7.1 Introduction 7.2 Definitions 7.3 Laplace Transform 7.4 Inverse Laplace Transform 7.5 Solving Differential Equations 7.6 Concluding Remarks Exercises
221 221 222 225 228 233 251 252
Contents xi
8
Fourier Transforms
259
8.1 Introduction 8.2 Definitions 8.3 Fourier Transform 8.4 Inverse Fourier Transform 8.5 Fast Fourier Transform 8.6 Solving Differential Equations 8.7 Concluding Remarks Exercises
259 260 263 269 272 275 279 279
9
285
Boundary Value Problems
9.1 Introduction 9.2 Two-Point Boundary Value Problems 9.3 Second-Order Differential Equations 9.4 Higher-Order Differential Equations 9.5 Complicated Differential Equations 9.6 Concluding Remarks Exercises
285 286 290 295 300 304 305
10 Partial Differential Equations
317
10.1 Introduction 10.2 Classification of Partial Differential Equations 10.3 Finite Element Package 10.4 Elliptic Equations 10.5 Parabolic Equations 10.6 Hyperbolic Equations 10.7 Concluding Remarks Exercises
317 318 319 320 333 345 358 359
11 Special Functions
375
375 376 378 383 386 394 397
11.1 Introduction 11.2 Error Functions 11.3 Gamma Functions 11.4 Beta Functions 11.5 Bessel Functions 11.6 Airy Functions 11.7 Legendre Functions
xii Contents
11.8 Special Integrals 11.9 Concluding Remarks Exercises
403 407 408
419 423
Bibliography Index
Chapter 1 Symbolic Mathematics by Mathematica
1.1 Introduction Calculus and differential equations are requirement courses for science and engineering students. However, some students may not realize the importance of these subjects and simply take them for fulfilling their degree requirement. Such subjects, in fact, are essential because they are basis toward studying higher level courses so that more realistic problems can be solved. Most of the commercial software for design and analyzing scientific and engineering problems today were developed based on the knowledge of mathematics and computational methods. Good
2
Chapter 1 Symbolic Mathematics by Mathematica
background in calculus and differential equations is thus needed prior to using the high-level commercial software correctly. As scientists or engineers, solutions obtained from solving mathematical problems must be further interpreted so that their physical meanings are understood. They prefer to obtain solutions without spending a lot of time deriving them. There are many software today that can provide solutions to a large class of mathematical problems. These software can be used for finding roots of algebraic equations, taking derivatives and integrating functions, including solving for solutions of many differential equations. As a simple example, the software can perform integration, 3
x
2
dx
0
numerically and returns the result of 9 immediately. At the same time, if preferred, the software can provide symbolic answer, such as, x3 x 2 dx 3 The software capability thus helps learning calculus considerably.
The idea for developing symbolic mathematics software started in early 1970’s when a group of researchers at Massachusetts Institute of Technology developed a software so called MACSYMA (Mac Symbolic Manipulation Program). It was quite astonishing at that time because the solutions can be shown in the form of symbolic expressions instead of numbers. Lately, many symbolic manipulation capabilities of the software have been improved and can be used to ease learning calculus and differential equations.
1.2 Symbolic Mathematics Software In the past, students need to memorize formulas when learning calculus. Basic formulas are required for finding derivative or integral of a given function. Proper steps must be taken
3
1.2 Symbolic Mathematics Software
carefully so that the final solutions are derived correctly. Few examples for finding solutions after taking derivative and performing integration of some functions are highlighted below. Example Find the second-order derivative of the function, x f 3 4 cos x To determine the second-order derivative of the given function above, the standard first-derivative formula is applied twice. The final solution is relatively lengthy as, d2 f dx 2
16 x cos 2 x 4 cos x 3 x 8sin x 32 x 24sin x
4 cos x 33
Deriving for the above solution by hands, mistake may occur. With the help of symbolic computer software, the solution can be obtained instantly without any error. In addition, if the tenth or other higher-order derivatives of the above function are needed, the software can provide correct solutions in a very short time as well. Example Find the first- and second-order derivatives of a more complex function, x tan x 3 tan x 21x3 7 x 4 g x3 3 x 2 6 x 18 Again, the symbolic computer software can be used to provide the first-order derivative as,
dg dx
2 x tan x 504
x2 6
2
tan 2 x 43 7 x2 6
and then the second-order derivative as,
2016 x 48 tan x 4 x tan 2 x 6 tan x 88 x ( x 2 6)3 ( x 2 6) 2 2 tan x (tan 2 x 1) x2 6 Derivation of these solutions by hands would take a long time and is likely to contain error. d 2g dx 2
4
Chapter 1 Symbolic Mathematics by Mathematica
Example Integration is another topic learned in calculus course that many students do not appreciate. This is because they have to memorize many formulas and do not know when it will be used for solving realistic problems. Examples of integration learned in calculus course include indefinite integral, such as, 1 1 x dx tan 2 3 3 x 9 Also the definite integral, such as,
2
x dx
1 x 1 2 x 1
1 1 ln 3 ln 2 2 3
Students can obtain solutions above in a short time if they use symbolic computer software. Example Symbolic computer software can help us to solve some other types of problems that require a long time to do by hands. For example, it can be used to factorize the function, h
x 4 26 x 3 212 x 2 1578 x 5859
h x 7 x 9 x 3 x 31 within a second.
to give,
Example Solving differential equations is another topic that most students do not like. This is because they are many approaches to follow depending on the types of differential equations. As an example, a general solution of the first-order ordinary differential equation, dy y 5 dx y x C e x 5 is, where C is a constant that can be determined from the given initial condition of the problem. Some differential equations are more complicated, such as, d2y dy 4 3y 0 2 dx dx
5
1.3 History and Capability of Mathematica
A general solution for the second-order ordinary differential equation above is,
y x C1 e x C2 e3 x where C1 and C2 are constants that can be determined from the boundary conditions of the problem. With the symbolic computer software, the above solutions can be obtained instantly. The software can also plot the solution behavior so that students understand its physical meaning clearly. For example, if the constants obtained after applying the boundary conditions are C1 C2 1 , the exact solution of the problem is,
y x e x e3 x The distribution of y that varies with x is plotted as shown in the figure. 3x
x
2.0
1.5
1.0
0.5
0.5
1.0
1.5
2.0
x
1.3 History and Capability of Mathematica Mathematica is an efficient computational and symbolic mathematics software widely used by scientists, engineers, researchers and students around the world. It was first developed by Dr. Stephen Wolfram in 1979. At that time, most of the engineering and scientific computer software can provide results only in numeric form. Mathematica is one of the software that can
6
Chapter 1 Symbolic Mathematics by Mathematica
provide results in the form of symbolic mathematics. It was quite amazing at that time because results in the form of mathematical symbols, such as the letters x and y, could appear on the computer monitors instead of numbers. The software has been used widely since then, especially in the research and educational communities. Researchers employ the software to manipulate complicated mathematical expressions, while students enjoy using it for verifying their answers when solving calculus and differential equation problems. This book concentrates on how to use Mathematica to provide solutions in the form of symbolic expressions similar to what we have learnt in classes. Selected topics which are important in calculus and differential equation courses are presented. Detailed derivations are illustrated prior to solving the same problems by using Mathematica commands. We will see that the same solutions are obtained instantly without any error from the software.
1.4 Mathematica Fundamentals Mathematica is a huge computer software containing a large number of commands. Because this book concentrates on solving calculus problems and differential equations, only essential commands related to these topics are presented herein. Mathematica working files have their extensions of .nb denoting notebook. If there is no previous working file, a new one can be created by clicking at the New Document icon. A working area then appears on the screen allowing us to perform calculations. For example, if we would like to add 2 with 3, we simply type 2+3 and press the Enter key (lower-right corner of most standard keyboards), In[1]:=
2
Out[1]=
5
3
1.4 Mathematica Fundamentals
7
It is noted that, for the compact keyboard, we have to hold the Shift key while pressing the Enter key to execute the commands. The input is shown by bold letters while the output is in regular letters with the executing sequence numbers in square brackets. For reading clarity, these numbers are omitted and not shown in this book. Mathematica also contains the symbol palettes so that mathematical symbols can be entered conveniently. For example, to integrate,
xn x x1 n 1 n
Both input and output that appear on the screen can be copied and pasted into Word or Notepad report directly. Noted that any statement enclosed by (* and *) is the comment statement which won’t be executed, (* This statement is similar to a comment card *) To exit the working notebook file, we click at the File and Exit icon, respectively. In addition, if we would like to abort any execution, we click at the Evaluation and Abort Evaluation icon, respectively. Mathematica can be used as an advanced calculator as demonstrated by the following examples. 2
5
3
5
3
21
2 7 3
Mathematica always gives solution in an exact form, herein, in the form of a rational number. If we prefer the solution in the form of
8
Chapter 1 Symbolic Mathematics by Mathematica
decimal points, we simply replace an integer by a real number, i.e., with a period behind it, 2
5.
3
2.33333
Solution in an exact form provides insight into it. For example,
27 3
3
If we want the above solution in the form of a real number, we can use the N[ ] command which represents the Numerical approximation, N
N
5.19615
where % denotes the former solution. The solution can be displayed with 30 significant figures by entering, N Sqrt 27 , 30 5.19615242270663188058233902452
All built-in commands always begin with capital letter such as N and Sqrt as shown above. It is noted that the symbol palettes can ease entering input, such as,
217 313 131 072 1 594 323
N , 40 0.08221169737876201999218477058914661583631
Mathematica assigns specific symbols for some wellknown quantities. These include the values of pi, exponential and imaginary number as shown in the examples below. These values are always in exact form except they are declared as real numbers.
9
1.4 Mathematica Fundamentals
0.
Pi
3.14159
Log
2
1
1
Similarly, values of the trigonometric functions are displayed in the exact form. For examples, Sin
Tan
4
1
1
3
2
Cos 1 2
6
ArcSin
12
1 2
3
3 2
12
2
Mathematica contains several commands to manipulate and simplify algebraic expressions. These commands help reducing the complexity of the final symbolic expressions. Some useful commands are described herein. The Expand command expands the given expression and then collects similar terms together. For example, f f x 5 Expand f 15
2x
x
x 5 x 3
3 ; Expand
2
x
i.e., the final result is,
f
x 2 2 x 15
As another example, g cos x y
10
Chapter 1 Symbolic Mathematics by Mathematica
g Cos x y ; Expand g, Trig True Cos x Cos y Sin x Sin y
g
i.e.,
Expand
cos x cos y sin x sin y
The Factor command factorizes the given function to make it looks simpler. For example, h
h 6 x3 11 x2 Factor h 1
x
3
2x
6 x 3 11x 2 16 x 21
16 x
21; Factor
7
3x
h 1 x 2 x 3 7 3 x
i.e.,
The Simplify command simplifies the complex expression so that it is compact and easy to understand. As an example,
u
u x 2 y Simplify u
2 x
x 2y 2 1 x y
1 y ; Simplify
xy
u xy
i.e.,
The FullSimplify command is probably the most popular command because it combines the capability of the Expand, Factor and Simplify commands together. For example, 2 x5 5 x 4 58 x 145 v 2x 5
v 2 x^5 5 x^4 FullSimplify v 29
4
x
58 x
145
2 x
5 ;
FullSimplify
11
1.4 Mathematica Fundamentals
i.e., the final solution is,
v
x 4 29
Mathematica contains the Plot command that can be used to plot a given function effectively. As an example, if we would like to plot the w function defined by, x sin x w x 2 12 for 6 x 6 , we just simply enter the command, w
x
Sin x
;
x2
12 Plot w, x,
6, 6 , PlotStyle
Black
Plot
A plot of the w function will appear on the screen with the scale of the vertical axis adjusted automatically. 0.10
0.05
6
4
2
2
4
6
0.05
0.10
0.15
The Plot command contains many options so that users can display different types of plots as they preferred. For example, the command below plots the defined w function for 0 x 40 with x and w labels on the horizontal and vertical axes. Variation of the function is displayed in black with 100 mesh points equally spaced along the curve. Plot w, x, 0, 40 , AxesLabel PlotStyle Black, Mesh 100
x, w ,
12
Chapter 1 Symbolic Mathematics by Mathematica
x sin x x 2 12 0.10
0.05
10
20
30
40
x
0.05
0.10
0.15
1.5 Concluding Remarks In this chapter, the capability of symbolic manipulation software was introduced. The software helps finding solutions of basic problems learned in calculus and differential equation courses. These include: finding derivatives of functions, perform both definite and indefinite integrations, as well as solving for exact solutions of some differential equations. At present, there are many symbolic manipulation software suitable for learning and using in research work. Among them, Mathematica has received popularity due to its capability and ease of using. Development history and essential features of Mathematica were briefly described. Few important commands were explained by using examples. These commands can help manipulating complex expressions and reduce them into simple forms. The solutions are plotted by using easy commands so that users can understand their physical meanings quickly. The chapter demonstrates advantages of using the symbolic manipulation software that can significantly reduce the effort for solving basic mathematical problems. We will appreciate these advantages in more details when we study essential calculus and differential equation topics in the following chapters.
13
Exercises
Exercises 1.
Study the symbolic manipulation capability in Mathematica. Summarize its capability for: (a) simplifying algebraic expressions (b) solving calculus problems (c) analyzing ordinary differential equations by setting up examples.
2.
Use the Expand, Factor, Simplify or FullSimplify command to reduce or determine the following quantities, (a) 3 (c) 3 x 6 4 2 x 7
(b) 163 4 (d) x 3 4 x 1
(e) ( a b )( a b )
(f) 3 x 3 2 9 x1 2 6 x 1 2
4
3.
Use the command Simplify or FullSimplify to simplify the following functions, x 2 3x 2 (a) x2 x 2
(c)
x2 x 1 2 x 4 x2
3x3 2 y 3 (e) 2 1 2 x y
4.
2x2 x 1 x 3 (b) 2x 1 x2 9 y x x y (d) 1 1 y x
2
(f)
4 x3 y3 3xy 2
2
xy
Determine the product of the function f and g for each subproblem. Then, employ the command Simplify or FullSimplify to simplify their final expressions, (a) f
x2 2x
;
g x 1
(b) f
x 1
;
g
2
x2 2
14
Chapter 1 Symbolic Mathematics by Mathematica
(c) f
sin x x 2
;
g cos x 2 x
(d) f
e x2
;
g
(e) f
sin x 2 x
;
g ln x 2 2 x
(f)
ex
;
g
5. Use
f
ln x 3
e 2 x
2
the
command Expand, Factor, Simplify or FullSimplify to yield simplest expressions of the following functions, (a) f 6 x 4 28 x 3 7 x 2 14 x 5 (b) g cos x sin x cos x sin x e x sin x 3x 7 (c) h
x tan x 3 tan x 21x3 7 x 4 x3 3 x 2 6 x 18
(d) u 3 x x 2 4 x 2 x x 2 (e) v
sin x tan 2 x 6sin x tan x 9sin x x cos 2 x x 7 cos 2 x 7
(f) w
15 x 3 xy 2 5 y 2 y 4 x 2 cos x sin y cos y sin x cos x sin y cos y sin x
6. Use
the command Expand, FullSimplify to prove that,
Factor,
Simplify
(a) x 5 y 5 x y x 4 x3 y x 2 y 2 xy 3 y 4 (b) sin 3x 3sin x 4 sin 3 x 4 tan x 4 tan 3 x 1 6 tan 2 x tan 4 x 3 1 1 cos 2 x cos 4 x (d) cos 4 x 8 2 8 x x x x (e) e e tanh x e e
(c) tan 4 x
or
15
Exercises
7.
Use
the
command Expand, FullSimplify to show that,
Factor,
Simplify
or
1 (a) tanh 2 x sech 2 x 2 tanh x (b) tanh 2 x 1 tanh 2 x
x cosh x 1 2 2 (d) cosh 4x 8 cosh 4 x 8 cosh 2 x 1 1 3 sinh 3x sinh x (e) sinh 3 x 4 4
(c) cosh
8. Use the N command to calculate and display the roots of the following prime numbers with 100 significant figures, (a)
(b) 157
7
(c) 229
(d) 443
57
89
(e) 587
(f) 881
1 13
9.
23
27 31
Use the Plot command to plot the following functions, (a) f 3 x 5 25 x 3 60 x 5x2 8x 3 3x 2 2 23 3 2 x 1 (c) h 4 (d) u sin x
(b) g
(e) v x 2 x 1 x 1 4
3
10. Use the Plot command to display the functions in Problem 9 again by showing essential details of their variations. 11. Study capabilities of the Matlab and Maple software. Then, highlight their unique features and compare capabilities with Matthematica for manipulating symbolic expressions.
16
Chapter 1 Symbolic Mathematics by Mathematica
12. Use the Factor command to simplify the function, p
3 x 5 20 x 3
Then, employ the Plot command to display the variation of this function for (a) 4 x 4 ; 500 p 500 and (b) 0 x 4 ; 80 p 80 . 13. Use the Simplify or FullSimplify command to simplify the function, q
x4 2x2 3
Then, use the Plot command to display its variation for 3 x 3 . Plot this function again but for 3 x 3 and 6 q 6 . 14. Use the Plot command to plot the following functions, (a) f
(b) g
x3 x 1 x 4 3x 2 x
(c) h 3 x 5 25 x 3 60 x with appropriate scaling in both the horizontal and vertical directions to clearly show their variations. 15. Use the Plot command to display the following trigonometric functions, (b) sin x (a) cos 2x 2 (c) cos x (d) tan x
x (e) cos 6
x (f) cos 2
with appropriate scaling in both the horizontal and vertical directions to show their variations.
17
Exercises
16. Given the function,
f
3
1 x3
Find a proper command in Mathematica for determining the expression for f 1 . Then, plot to compare the variations between f and f 1 . 17. Given the function,
g
10 x cos x
Use the Plot command to plot its variation within the interval of 2 x 2 . Then, show its variation again but for 0.5 x 0.5 . Suggest on how to plot the function when x approaches zero so that the variation is shown clearly.
Chapter 2 Calculus
2.1 Introduction Calculus is an essential subject in mathematics required for science and engineering students. It contains two main topics which are the differentiation and integration of functions. The former one is based on understanding the determination of limits. Often, many students do not enjoy studying these topics because they have to memorize formulas for deriving solutions. Some solutions require a long time to derive by employing specific techniques. Furthermore, most students do not appreciate learning these topics because they don’t know when the solutions will be used for realistic problems. With the capability of the symbolic manipulation software today, solutions to calculus problems can be obtained rapidly.
Chapter 2 Calculus
20
Students can compare solutions obtained from the software with those derived by hands. So they will have more time to understand the meanings of the solutions. This chapter shows standard techniques to derive the solutions before using Mathematica commands to confirm the validity of them. Several examples will be presented with detailed derivation for the solutions. These solutions will also be plotted to increase understanding of their phenomena.
2.2 Limits Limit of a function f x when x approaches a, is defined by,
L lim f x xa
Example Given a function, f x
x2
L lim f x lim x 2
Then,
xa
xa
a2
We can use the Limit command in Mathematica by entering and obtaining the solution as follows, f x2 ; Limit f, x
Limit
a
a2
Example Given a function,
g x
x2 a2 xa
If we follow the simple procedure used above, we get, a2 a2 x a a a
L lim g x lim x a
0 0
2.2 Limits
21
The result cannot be determined and is not correct. To find the correct solution, we should observe the variation of this function g(x) by plotting. If we assign the value of a 1 , then, g x
x 2 12 x 1
The plot of this function is shown in the figure. From the figure, the function g(x) becomes 2 as x approaches 1. x2 1 x 1 3.0
2.5
2.0
1.5
1.0 0.0
0.5
1.0
1.5
2.0
x
The proper step to determine the limit of this problem is to first let x a h , where h is small. Then, substitute x a h into the function g x to get,
g x
a h 2 a 2
aha 2a h
2ah h 2 h
Then, let h approaches zero, thus,
x2 a2 L lim 2a x a xa The solution agrees with that shown in the graph at a 1 . The same solution can be obtained instantly by using the Limit command,
Chapter 2 Calculus
22 x2 a2 ; x a Limit g, x
g
Limit
a
2a
Finding limits of functions may require different methods depending on the function types. The examples below show standard techniques to determine limits for different types of functions. Example Determine the limit, L lim
x 5
x 2 25 x5
This example is similar to the preceding example. The factoring technique can be used to find the solution as follows, x 5 x 5 lim x 5 L lim x 5 x 5 x5 55 10
Again, the Limit command is employed to obtain the same solution, Limit
x2 x
25 ,x 5
5
10
Example Determine the limit, x 2 x4 x 4 If we simply substitute x 4 , we get 0 0 , which cannot be determined. A technique to find the limit of such function is to multiply its numerator and denominator by the conjugate value of the numerator, x 2 , before taking the limit. Detailed derivation is as follows, L lim
23
2.2 Limits
L
lim
x 4
x 4 x 2
x 2 x 2
1 x 4 lim x 4 x 4 x 4 x 2 x 2
lim
1 1 4 42 Similarly, we can use the Limit command to find such solution by entering,
Limit
x 2 ,x x 4
4
Limit
1 4
Example Determine the limit, 1 1 L lim x 4 4 x 0 x Again, if we substitute x 0 directly into the function, we get 0 0 . The technique of multiplying by the conjugate value as shown in the preceding example is not applicable. A different technique of multiplying the numerator and denominator by an appropriate function is needed. For this particular problem, the appropriate function is 4 x 4 and the detailed procedure is as follows, 1 1 4 x 4 L lim x 4 4 x 0 4 x 4 x 4 x 4 x lim lim x 0 4 x x 4 x 0 4 x x 4 1 1 lim x 0 4 x 4 4 0 4 1 16
Chapter 2 Calculus
24
The same solution is obtained by using the Limit command as, Limit
1 x 4
x
1 4 , x
Limit
0
1 16
If the given function is more complex, the same Limit command still provides solution immediately as demonstrated by the following examples. Example Determine the limit,
L
4x
lim
x 4
5 x2 9 The solution is obtained by typing the Limit command followed by the given function, variable and limit value as, 4
Limit 5
x x2
4
,x 9
8 5
7
which leads to the solution, 4 x lim x 4 5 x2 9
8 5 7
3.3981
Example Determine the limit, 3
ex 1 L lim x 0 1 cos x sin x x3
Limit 1 12
Cos
x
1 Sin x
,x
0
25
2.2 Limits
3
ex 1 lim x 0 1 cos x sin x
i.e., the solution is,
12
The solution can be verified by plotting such function through the use of the Plot command as, x3
Plot 1
Cos
x
AxesLabel
1
,
x,
.5, .5 ,
Sin x
x, function , PlotStyle
Black
function 13.0
12.5
12.0
11.5 0.4
0.2
0.2
0.4
x
Example Determine the limit of the function below as x approaches infinity, 9x 4 L lim x 3x 2 5 Limit
9x 3 x2
3
4
,x 5
3
N 5.19615
N
Chapter 2 Calculus
26
i.e.,
9x 4
lim
x
3 3 5.19615
3x 2 5
Example The Limit command can also be used to find the solution when the function contains two variables,
L
Limit Limit
x2 y x
lim
x 1 y 2
x y3 y 3
x 2 y xy 3
x y 3
,x
1 , y
2
Limit
6
i.e.,
lim
x 1 y 2
x 2 y xy 3
x y 3
6
2.3 Differentiation Differentiation is one of the most important topics in calculus. This is because the physics of most science and engineering problems are described by differential equations. Differential equations contain terms that are derivatives of the unknown variables. Finding for these unknown variables is the main objective for solving the differential equations. Thus, knowing how the derivatives of a function can be found is the first step toward learning the differential equations. To find derivatives of a function as learned in classes, we need to apply basic formulas. Some formulas are easy to memorize while many others are difficult to recall. Furthermore, taking derivative of a complex function consumes a large amount of time and is likely to produce error. Before using Mathematica command to find any derivative of a function, we start from understanding definition of the derivative. The derivative of a function y(x) with respect to x is given by,
27
2.3 Differentiation
dy dx
y x 0 x lim
lim
x 0
f x x f x x
Example Find the derivative of y f x x 2 .
f x x f x x 0 x x x 2 x 2 lim x 0 x
dy dx
lim
x 2 2 x x x x 2 lim x 0 x lim 2 x x 2
x 0
As x 0 , then,
or,
dy dx dy dx
2x 0 2x
Mathematica contains the D command that can be used to find the derivative effectively. In this example, the entered commands and solution are, y x2 ; D y, x
D
2x
Variation of the function y x 2 can also be plotted easily as shown in the figure by using the Plot command, Plot y, x, AxesLabel
4, 4 , x, y , PlotStyle
Plot
Black
Chapter 2 Calculus
28
The derivative dy dx represents the slope at any x location. For example, at x 2 , the derivative dy dx 2 2 4 . x2 15
10
5
dy dx
4
2
2
4
x
Example Find the derivative of y f x 2 x 3 x 2 .
dy dx
lim
x 0
f x x f x x 2 x x 3 x x 2 x 3x 2 2
lim
x 0
x
2 x 6 x x 3 x lim x 0 x
2
lim 2 6 x 3 x
x 0
2 6x 3 0 dy dx
2 6x
Again, we can use the D command to find the derivative of the function y f x 2 x 3 x 2 as follows,
29
2.3 Differentiation
y 2x D y, x 2
3 x2 ; D
6x
Example Find the derivative of a constant function, y f x 5 . f x x f x x 0 x 55 lim lim 0 x 0 x x 0
dy dx
lim
0 That is, the derivative of a constant is zero. y 5; D y, x 0
Example Find the derivative of the function y f x x 0. f x x f x dy lim x 0 dx x
lim
x x x x
lim
x x x x x x x x x x
x 0
x 0
lim
x 0
lim
x 0
1 2 x
x x x x x x x
1 x x x
x for
Chapter 2 Calculus
30
The same D command can be employed to obtain such solution directly. Or, if preferred, the partial derivative symbol in the symbolic palette can be used as well, y
x;
xy
1 2
x
Example Find the derivative of the function y f x dy dx
lim
x 0
x . 2x 3
f x x f x x
x x x 2 x x 3 2 x 3 lim x 0 x 2 x x 3 x x 2x 3 x 2 x x 3 2 x 3 2 x 3 2 x x 3 lim x 0 x
After simplifying it, we obtain, dy dx
3 x 0 2 x 2 x 3 2 x 3 3 2 x 0 3 2 x 3
or,
dy dx
lim
3
2 x 3 2
If we use the D command together with the Simplify command to simplify the solution, we obtain the same result instantly,
31
2.3 Differentiation
x ; 2x 3 Simplify D y, x y
Simplify
3 2x 2
3
In general, the given function y f x is complicated. Finding its derivative by hands consumes a large amount of time and may produce error. The D command can eliminate such difficulty as shown in the following examples. Example Find the derivative of the function, y
f x
x 4 8 x3 12 x 5
Then, evaluate the result numerically at x 2, 0 and 2. Again, we can employ the D command to find the derivative as follows, y x4 8 x3 12 x dydx D y, x 12
24 x2
5; D
4 x3
dy dx
i.e.,
4 x3 24 x 2 12
The arrow sign can then be used to compute the numerical results when x 2, 0 and 2 as follows, dydx . x
2
116
dydx . x
0
12 dydx . x 52
2
Chapter 2 Calculus
32
These computed derivatives represent the slopes at x 2, 0 and 2 as shown in the figure. x4 8 x3 12 x 5
100
dy 2 116 dx 3
50
2
dy 0 12 dx
1
1
2
3
x
dy 2 52 dx
50
100
Example Find the derivative of the function, y
3 f x x x sin 2 x
4
If we use the D command, the result is, y
x
x
Sin x 2 3 4 ;
Simplify D y, x 4 x
x
Sin x 2 3 3 1
3 x
Sin x 2 2 1
Sin 2 x
The result was simplified, in addition, by using the Simplify command to yield the solution in a more compact form,
dy dx
3 2 4 x sin 2 x x 3 sin 2 x x sin 2 x 1 1 3
It is noted that the D command can also be used to find solutions of higher order derivatives. This is done by including the derivative order at the end of the command as shown in the following examples.
33
2.3 Differentiation
Example Find the second-order derivative of the function, f x 2 x3 7 x 2 3x 5
y y 2 x3 7 x2 D y, x, 2 14
3x
5; D
12 x
d2y dx 2
i.e.,
12 x 14
Example Find the second- and twentieth-order derivatives of the function, 1 cos x y f x x 1 cos x
Mathematica can determine derivatives of rather complex function above in a short time. We can use the AbsoluteTiming command to measure the computational time. For the second-order derivative, the computational time and result are, y
1
Cos x
x 1
Cos
x
AbsoluteTiming Simplify D y, 0.,
Sin
1 4 x3
1
Cos
3
x
x Sin 8
x
x 3 x2
Sin x 2
8
x, 2 AbsoluteTiming
Cos x
3 2
x 2 8 2 x 3 x2 5 x Sin 2 Cos x 2 8 2 x x2 5 x Sin 5
;
2
2x 2 x Cos x
x x
2 Cos x
3 2
8 Sin x
2
x Sin 3 2
x 8
x
8
2x
5
2 x Sin x
Sin 2 x x2 Cos 2 x
x Sin 2
Cos
x
x2 Sin x
2
x
4 x Sin 2 x
The first number in the result bracket above represents the computational time. This means Mathematica can determine the second-derivative of the given function almost instantly. For the twentieth-order derivative, the computational time is determined by using the command,
Chapter 2 Calculus
34
AbsoluteTiming D y,
x, 20
;
0.020001 , Null
In this latter case, Mathematica requires about 0.02 seconds to determine the twentieth-order derivative of such complex function. All of the examples above clearly demonstrate the capability of Mathematica for finding derivatives of arbitrary functions in a very short time. The D command can also be used to determine the partial derivatives of functions that contain many variables. Examples for finding partial derivatives are shown below. Example Given the function, z
f x, y
xe
x2 y 2
Determine its partial derivatives with respect to x and y. We can plot the variation of the function above as a carpet plot by using the Plot3D command. z
x2 y2 ;
x
Plot3D z, x, 2, 2 , y, 2, 2 , x, y, z , AxesLabel White & , Mesh ColorFunction
Plot3D
20
The plot is shown in the figure. The partial derivatives of the given z function with respect to x and y can be determined by using the D command as follows, dzdx
Simplify D z, x
x2 y2
dzdy
2
1
2 x2
Simplify D z, y x2 y2
D
xy
Simplify
35
2.4 Integration
The results are, z x
2 x 2 1 e
z y
2 xy e
x2 y 2
x2 y 2
The derivatives obtained above can be verified by the plot of the function z f x, y . At x y 0 , the values of z x 1 and z y 0 are obtained by using the substituting command as follows, dzdx . x
0, y
0
1 dzdy . x
0, y
0
0
2.4 Integration Integration is the inverse process of differentiation and is sometimes called anti-differentiation. It is rather a difficult topic to most students because they have to memorize many integration formulas. In addition, complicated functions require some special techniques and take a long time to integrate before reaching
Chapter 2 Calculus
36
solutions. In the past, integrating handbooks can alleviate the difficulty in finding the integral results. At present, integration of a function can be obtained easily by using the symbolic computer software. Integration of a function f x is given by,
f x dx
I
As an example, the integration of the function f x x 2 is, x3 I x dx C 3 where C is the integrating constant. We can verify the result obtained by taking its derivative as follows, dI d x3 3x2 C 0 x2 dx dx 3 3
2
which gives back the original function f x . It is noted that the integral sign
resembles the capital S
denoting summation of the area under the function f x . The function f x is called the integrand, while C is the integrating constant that can be determined from the specified condition of the problem. Few basic integration formulas learned in calculus course are: (a) (c) (e)
(g) (i)
x n 1 n 1 cos x
sin x dx sec x dx 1 1 x dx
x n dx
2
2
a x dx
(b) (d)
tan x
(f)
sin 1 x
(h)
ax ln a
(j)
1
x dx cos x dx 2 cosec x dx 1 1 x2 dx
ln x
e
ex
x
dx
sin x cot x tan 1 x
2.4 Integration
37
where the integration constant C is omitted herein for simplicity. The above basic formulas were used to derive many other integrating formulas that are summarized in integration handbooks. Mathematica has the Integrate command that can be employed to perform integration of functions effectively. Examples on the use of such command are highlighted below.
sin x dx
Example
cos x
f Sin x ; Integrate f, x
Integrate
Cos x
1
1 x
Example
2
dx tan 1 x
For convenience, the integral sign in the symbolic palette can be used,
1 1 x2
x
ArcTan x
Example
a
x
dx
ax ln a
ax x ax Log a
The integration formulas, such as those given in (a) - (j) above, can be applied to find the integrals of more complicated functions as follows.
Chapter 2 Calculus
38
Example Find the integral of,
8x
13 x
7
5 x3 3
2 x4
I
8 x3
5 x2 13 x2 2
7x
3
x
5 13 2 x 4 x3 x 2 7 x 3 2
I
i.e., the result is,
5 x 2 13x 7 dx
Example Find the integral of,
I
3 sin 4 x cos 2 x dx
3 Sin 4 x Cos 2 x 1 4
6 Cos x 2
x
Simplify
Cos 6 x
I
i.e., the result is,
1 6 cos2 x cos 6 x 4
Example Find the integral of,
I 2x
1 x
x
e2 x 1 dx ex
x
x
i.e., the result is,
I
e x e x
The basic integration formulas as shown in (a) - (j) can be further applied together with the use of some integration techniques. Some techniques are presented in details in the examples below.
2.4 Integration
39
Example Find the integral of,
I
x
u2
A technique is to let,
x 1 dx
2
x 1
2 u du dx
Then,
and
x u2 1
Thus, the given integral above becomes, I
I
After substituting u
2 u 1 u 2u du 4 2 2 u 2u 1 2u du 6 4 2 2u 4u 2u du 2
2u 7 4u 5 2u 3 7 5 3 2u 3 15u 4 42u 2 35 105
x 1 , the final solution is obtained,
I
2 x 1 105
2 x 1 105
32
32
15 x 12 42 x 1 35
15 x 2 12 x 8
The same solution can be obtained easily by using the integral symbol in the symbolic palette,
x2 2 105
x 1
1
x
x 3 2 8
12 x
15 x2
Chapter 2 Calculus
40
Example Find the integral of,
cos x
I
4
2 x3 dx
To integrate the above function, a technique different from the previous example is needed as follows,
cos x 2 x dx 1 cos x 2 4 x dx 4
I
4
3
4
3
1 cos x 4 2 d x 4 2 4 1 sin x 4 2 4
Again, the solution can be obtained by using the symbolic palette conveniently,
Cos x4 1 Sin 2 4
2 x3 x x4
If Mathematica cannot integrate the given function, the entering expression is returned. For example, I
ArcTan x
x
ArcTan x
x
tan 1 x dx
Most of practical problems require solutions of the definite integrals for which the lower and upper limits of integration are specified. Techniques for finding definite integrals of some functions are shown in the examples below.
2.4 Integration
41
Example Find the definite integral of, 4
I
2 x 1 dx
0
A technique to find the integral above is to assign a new variable, u 2 x 1 , so that du 2dx . The lower and upper limits are changed into the form of new variable u, i.e., u 0 2 0 1 1 and u 4 2 4 1 9 , respectively. Then, 9
I
1 u du 2
1 32 32 9 1 3
1
1 2 32 u 2 3
9 1
26 3
Again, we can employ the integral sign in the symbolic palette to find the same solution by simply entering, 4
2x
1
x
0
26 3
Example Find the definite integral of,
I
0
1 dx 1 x2
Using a formula in an integrating handbook, the above integral is, a
I
lim
a
0
1 dx 1 x2
lim tan 1 x
a
lim tan 1 a tan 1 0
a
2
2
0
a 0
Chapter 2 Calculus
42
1 0
x2
1
x
2
Multi-dimensional integration can also be performed in the same way as highlighted in the following examples. Example Find the two-dimensional indefinite integral of, I
f x, y dx dy
x
2
y dx dy
x3 y 2 6
x2 y x y x3 y2 6
Example Find the three-dimensional definite integral of, 6 4 2
I
f x, y, z dx dy dz 5 3 1 6 4 2
x3 y 2 z dx dy dz
5 3 1
6 5
4 3
2035 8
2 3 2 x y z 1
x
y
z
2035 8
2.5 Taylor Series
43
2.5 Taylor Series Many solutions to differential equations are in form of infinite series. In calculus course, several types of infinite series are thus studied. Popular infinite series are in the power and polynomial form as shown below. 1 2 1 3 1 4 1 x x x … xn 2! 3! 4! n 0 n ! 1 1 1 1 n sin x x x3 x5 x 7 … 1 x 2 n 1 2 1 ! n 3! 5! 7! n 0
ex 1 x
cos x 1
1 2 1 4 1 6 x x x … 2! 4! 6!
n0
1n
1 x2n 2n !
The function f x e x , f x sin x and f x cos x above can be derived in form of infinite series by first writing such f x in the form,
f x
c n 0
n
x a n
c0 c1 x a c2 x a ... cn x a ... 2
n
where ci , i 1, 2, 3,..., are determined from the derivatives of the function as follows,
f x c1 2c2 x a 3c3 x a 2 ... ncn x a n 1 ... f x 1 2c2 2 3c3 x a 3 4c4 x a 2 ... f x 1 2 3c3 2 3 4c4 x a 3 4 5c5 x a 2 ... At x a , the above equations reduce to, f a 1 c1
f a
1 2 c2
f a 1 2 3 c3 Or, in general,
f n a
n ! cn
Chapter 2 Calculus
44
cn
Thus,
f n a n!
Then, the function f x can be rewritten as,
f x
f a f a x a
1 2 f a x a 2!
1 n n f a x a ... n! The function f x in this form is called the Taylor series at x a. ...
It is noted that if a 0 , the Taylor series reduces to, 1 1 f x f 0 f 0 x f 0 x 2 ... f n 0 x n ... 2! n! 1 n f x f 0 xn or, n 0 n !
which is known as the Maclaurin series. Mathematica has the Series command that can be used to display the function f x in form of the Taylor and Maclaurin
a 0 series. The examples below demonstrate such capability. Example Find the Maclaurin series for the function, f x ex
Since the given function f x e x , then f x e x , f x e x ,..., f n x e x . Maclaurin series is,
f x e
But f n 0 e0 1 for any n , then the
x
n 0
xn n!
1
x x 2 x3 ... 1! 2! 3!
We can use the Series command to generate such series. For example, the series with the first three terms can be displayed by entering,
2.5 Taylor Series
x; f Series f,
1
x, 0, 2
x2
x
45
Series
O x 3
2
f x ex
i.e.,
1 x
x2 2
3 It is noted that the term O x represents the higher-order terms starting from the third-order term onward. Such symbol can be omitted from the output expression by using the Normal command as shown below for the same series with the first five terms,
Series f,
1
x, 0, 4
x2 2
x
x3 6
Normal
Normal
x4 24
x 2 x3 x 4 2! 3! 4! Similarly, the Taylor series x a with the first three terms can be displayed by entering, f x ex
i.e.,
Series f, a
a
a
x, a, 2
x
1 2
f x ex
i.e.,
1 x
Normal a
a
x 2
ea ea x a
ea x a 2 2!
Example Find the Maclaurin series for the function, f x cos x Since, f x f x f
2n
cos x
;
cos x
;
x 1n cos x
;
f x sin x f x sin x 2 n 1 f x 1n 1 sin x
Chapter 2 Calculus
46
At x 0 , cos 0 1 and sin 0 0 , then the derivatives of f x are, f 2 n 0 1
n
and
f 2 n 1 0 0
Thus, the Maclaurin series a 0 is,
1 1 n f 0 x 2 ... f 0 x n ... 2! n! x2 x4 x6 x8 1 0 0 0 0 ... 2! 4! 6! 8!
f x
f 0 f 0 x
n3 n5 n7 n9
If we plot the function f x by using the series above, we see that the series yield results that approach the solution of f x cos x when more terms on right-hand-side of the series are included. This means the true variation of the cosine function can be obtained by computing the function f x cos x and its derivatives at x 0 as n . We can use the Plot command to demonstrate convergence of the results as more terms are added into the series. Comparisons of these results with the true function f x cos x are shown in the figure. f Cos x ; Plot Evaluate Table Normal Series f, x, 0, n , n, 3, 21, 2 , Cos x , x, 0, 10 , Plot AxesLabel x, "f x " , PlotStyle Black, PlotRange 0, 10 , 2, 2
2.5 Taylor Series
47
fx 2
n5
1
0
9
17
13
n 21 2
4
6
8
10
x
cos x 1
n3
11
15
19
7
2
Example Use the Series command to find the first three terms of the function,
f x
cos x x x 1 2
at x 0 and x 2 . The first three terms of the Taylor series at x 0 for the given function above can be found by entering, Cos x
f
; x2 x 1 Series f, x, 0, 2
1
x
Normal
Series
x2 2 f x
i.e.,
cos x x2 1 x 2 x2 x 1
These first three terms at x 2 are, Series f,
x, 2, 2
Normal
Normal
Chapter 2 Calculus
48
Cos 2 7 2
2 x 2
5 Cos 2 Sin 2 49 7 13 Cos 2 5 Sin 2 686 49 x
i.e., cos 2 5cos 2 sin 2 5sin 2 2 13cos 2 x 2 x 2 7 7 49 49 686
2.6 Other Series Mathematica contains the Sum command that can be used to determine the series in the forms of numbers and symbols as demonstrated in the following examples. Example Determine the result of the series, 10
2
S
20 21 22 ... 210
n
n 0
We can employ the Sum command by entering, Sum 2n ,
n, 0, 10
Sum
2047 10
2
i.e.,
n
2047
n0
Example Determine the result of the series, S
n 1
1 n2
1 1 1 ... 12 22 32
The same Sum command can be used to find the result symbolically by entering,
2.6 Other Series
Sum
1 n2
,
49
n, 1,
2
6
i.e.,
n 1
1 n2
2 6
Result in the form of symbol above appears in most of calculus textbooks. Such result with 20 significant figures can be determined numerically by typing, N
, 20
N
1.6449340668482264365
It is noted that this series with the first hundred terms is, N Sum
1 n2
,
n, 1, 100
, 20
1.6349839001848928651
which is different from the exact result starting from the second decimal place onward. Example Prove the series,
n 1
1
3n 2 3n 1
1 3
Again, the Sum command can be used by entering, Sum
1 3
1 3n
2
3n
1
,
n, 1,
Sum
50
Chapter 2 Calculus
2.7 Concluding Remarks In this chapter, we have studied and reviewed essential topics in calculus. These topics are the limitation, differentiation and integration of functions. As we learned in the calculus course, several formulas and techniques are needed in order to find solutions for these problems. Some simple formulas can be memorized while many others are collected in handbooks. Learning these topics, which represents the first step toward solving higher mathematical problems, is often difficult to most students. Mathematica contains the Limit, D and Integrate commands that can be used to find limitation, differentiation and integration of a given function, respectively. The effectiveness of these commands was demonstrated through examples by comparing the solutions with those carried out by hands. The commands can provide the solutions immediately so that students will have more time to understand physical behaviors of the problems. Mathematica also contains the Series and Sum commands that can be used to generate the Taylor, Maclaurin and other series conveniently. These series can be expressed symbolically or computed numerically. Understanding these series is the basis for learning differential equations in the following chapters. Few key commands presented in this chapter clearly demonstrate the capability and efficiency of Mathematica for solving calculus problems. These commands help students to verify their solutions derived in the traditional way as learned in classes. With the Plot command, these solutions can also be plotted easily to further increase understanding of the problems. The symbolic computer software today thus can alleviate difficulty in learning calculus and increase understanding of the subject considerably.
Exercises
51
Exercises 1.
Use the Limit command to determine, x6 1 9 x 5x (a) lim 10 (b) lim x 1 x 1 x 0 x tan 3x x42 (d) lim (c) lim x 0 tan 5 x x 0 x
cos 2 x cos x x 0 x2
(e) lim
2.
(f) lim
x 2
x2 2 x x2 4 x 4
Use the Limit command to determine, x3 1 (a) lim x 1 x 1
(c) lim
x2 9 3 x2
(e) lim
1 x 1 x x
x 0
x 0
(b) lim
x 2
x3 3 x 2 x2 2 x
1 (d) lim x 2 sin x 0 x 1 1 2 2 x h x (f) lim h 0 h
Then, verify the solutions by plotting with the use of Plot command. 3.
Use the Limit command to determine, sin x 1 (a) lim (b) lim 2 x 2 cos x x x 5x 7 x 4 x 3
(c) lim (e) lim x
tan x x tan 2 x 3
160 x 0.4 90 x 4 x 0.4 15
(d) lim (f)
lim
x
x 2 3x 1 x
Then, verify the solutions by plotting with the use of Plot command.
52
Chapter 2 Calculus
4.
Use the Limit command to determine the limits of the functions containing two variable x and y, xy (a) lim x 0 x y 1 1 y 0
(b) lim
x 0 y 0
(c) lim
x 0 y 0
(d)
1 cos x 2 y 2
x2 y 2 e x y 2
1
1 x y 2
lim e
2
1 x 2 y 2
x 1 y y
2
1
1 x 2 y 2
sin 2 x 1 x2
1 y2
x 9 y 2
5. Use the D command to find the first-order derivatives of the following functions, (a) 2 x 3 x 4 4x (c) 2 x 1
(b) x 20 5 x
(e) x 4 x 2
(f)
x 2 3x (d) x 1 x2 2 x 5
Then, verify the solutions with those derived by hands. 6. Use the D command to find the first-order derivatives of the following functions, (a) x x
(b) x 12 3 x 12 3
3x 2 2 x 4 (c) 2 x2 x 1
(d)
x ln x
(f)
(e)
2x 3 x 2 x2 4 3
sin x
Then, use the Plot command to verify the solutions by plotting at appropriate x locations.
Exercises
53
7. Use the D command to find the first-order derivatives of the following trigonometric functions, (a) sin x3 x 2
(b) sin x x x3 ln x
e x x sin x (c) tan x
x2 (d) ln x 2
(e) x e x
(f) ln ecos x x
2
Then, use the Plot command to plot comparing the variations of the functions and their derivatives. 8. Given, u cos 1
x y
Use the D command to show that, 2u x y 9.
2u y x
Employ the Plot3D command to display the function z f x, y , x y 0.8 (a) z 100 x 1 x y 1 y tan 1 10 2 for 0 x 1 , 0 y 1 (b) z
x2 2 x e x y xy 2
2
for 3 x 3 , 2 y 2 Then, use the D command to find the expressions of z x and z y . Compute these expressions at x y 0 by using the substituting command.
Chapter 2 Calculus
54
10. Use the Integrate command or the integral sign in the symbolic palette to find solutions of the following integrals, (a) (c) (e)
1 x dx 1 x 3 dx sin 3x dx 4
(b) (d) (f)
2 x 3 dx 1 1 x dx 5
2
cos x dx
Then, verify the solutions by finding their derivatives. 11. Use the Integrate command or the integral sign in the symbolic palette to find solutions of the following integrals, (a)
(c)
(e)
2x 5 x2 5x 3 sin x dx 3 5cos x 1 2x dx 1 x2
dx
(b)
x
1 x2 dx
(d)
(f)
x2 dx 3x 4 sec2 x dx 4 tan 2 x
Then, verify the solutions by comparing with those derived by hands as learned in calculus course. 12. Use the Integrate command or the integral sign in the symbolic palette to find the following integrals, 1
(a)
(c)
1 sin x 2 dx
(e)
1 x cos x 4
dx
x2 5 dx 2 x
1
(b)
x
(d)
tanh
(f)
x2 4 2
x dx
x3 8 dx 2x
dx
Exercises
55
13. Use the Integrate command or the integral sign in the symbolic palette to determine the following definite integrals, 1
(a)
0 3
(c)
x
x2 9
0 2
(e)
2
2x 1 dx 5x 1
(b)
1
2
dx
(d)
0
1 x x 1
dx
2
1 dx x 4 2
4
3x 5 dx
(f)
0
1 sin 3x dx
14. Use the Integrate command or the integral sign in the symbolic palette to determine the following definite integrals, 5
(a)
1 x
4
5
(b)
dx
2
(c)
sin 2 x dx
(d)
0 2
(e)
x 4 dx
1 2
sin 3x cos x dx
0 2
4 x 2 dx
(f)
0
1 x x
2
1 dx 4
Then, verify the solutions with those derived by hands. 15. Use the Integrate command or the integral sign in the symbolic palette to find the following multi-dimensional integrals, (a) (b) (c)
x 7 xy 5 y dx dy 2 sin x cos x dx dy 2 2 x y sin z 8cos y dx dy dz 2
3
6 4 2
(d)
x y dx dy dz z 1
5 3
Then, verify the solutions with those derived by hands.
Chapter 2 Calculus
56
16. Use the Series command to express the first six terms of the Maclaurin series for the following functions, (a) e5x (c) x 2 sin x
(b) x e x (d) x cos x
(e) cos x 1
(f) sin 2 x
17. Use the Series command to express the first twenty terms of the Maclaurin series for the following functions, (a) sinh x (c) ln 1 x
(b) tan 1 x (d) e x 1 x x 2
Then, plot to compare their variations with the true functions. 18. Use the Series command to express the first five terms of the Taylor series at x a for the following functions, (a) e x sin x (c) x ln 1 2 x x (e) x2 4
(b) 3 8 x (d) x 2 cos 2 x x sin x (f) x2
19. Use the Sum command to prove the following infinite series,
1 1 1 1 4 ... = 96 14 34 54 7 4 1 1 1 1 2 (b) 2 2 2 2 ... = 12 1 2 3 4 1 1 1 1 3 (c) ... = 1 3 2 4 3 5 4 6 4 1 1 1 1 2 8 (d) 2 2 2 2 2 2 2 2 ... = 16 1 3 3 5 5 7 7 9 (a)
Exercises
57
20. Use the Sum command to show that the following functions can be written in the form of infinite series, x 2 x3 x 4 1 x 1 x ... 2 3 4 x 2 x3 1 x ... x 2! 3! x2 x4 x6 1 ... x 2! 4! 6! 1 x3 1 3 x5 1 3 5 x 7 x ... 2 3 24 5 246 7 x 1
(a) ln 1 x (b) e x
(c) cosh x
(d) sin 1 x
21. Use the Sum command to determine the exact solutions of the following infinite series,
(a)
... n 2 3n 2 3 22 32 23 33 n 1
(b)
n 1
1
1
1
1
5n 4 5n 1
1
1
1
1
1
1 1 1 ... 1 6 6 11 11 16
Then, compute the series by using the Sum command that contains only the first two hundred terms. Determine the percentage error by comparing the approximate solution with the exact solution for each case.
Chapter 3 Differential Equations 3.1 Introduction Many phenomena surrounding us are explained by differential equations. Water flow in a river or air circulation in a room is described by the differential equations representing conservations of mass, momentums and energy. Solving these differential equations lead to solutions of flow velocity, pressure and temperature. Temperature distribution of a coffee cup is governed by a differential equation that describes the energy conservation at any position in the cup. Solving such differential equation leads to the solution of the temperature. Or, deformation of a beam under loading is governed by a differential equation representing the equilibrium condition at any location along the beam. Solving the differential equation gives the deformation shape as well as the stress. Solutions obtained from these differential equations thus help understanding the problem phenomena.
60
Chapter 3 Differential Equations
Most commercial scientific and engineering software for analysis and design are based on solving differential equations. Thus, understanding how the differential equations are solved is very important. The differential equation course is thus required for science and engineering students. Even though the course consists of topics just for solving simple forms of differential equations, it is still difficult to most students. This is because there are many specific techniques to memorize and follow in order to derive for the solutions. With the symbolic computer software today, many differential equations learned in class can be solved easily. Students can compare solutions obtained from the software with those derived by hands, so that they will have more time to spend on understanding the solution behaviors. These will help them to appreciate and realize the importance in taking the differential equation course. This chapter starts from explaining characteristics and types of differential equations typically learned in the course. Techniques for solving many types of differential equations are presented. The derived solutions are compared with those obtained from using Mathematica. The derived solutions may be in the forms of polynomials or some special functions. These solutions are plotted by using simple Mathematica commands to further increase understanding of their behaviors.
3.2 Characteristics of Differential Equations In the differential equation course, we studied many types of differential equations. For an example, 3x
d2y dy 2y 4 y cos x dx 2 dx
In the differential equation above, y is the dependent variable that varies with the independent variable x. The dependent variable y y( x) is the solution to the differential equation. This equation is called the second-order differential equation according to the highest derivative order that appears in the equation.
3.2 Characteristics of Differential Equations
61
A differential equation is linear if the coefficient of each term is a constant or function of x. The differential equation becomes nonlinear if the coefficient is function of y. Thus, the differential equation above is nonlinear since the coefficient of the first-order derivative term is 2y. It is noted that exact solutions are not available or difficult to find for most nonlinear differential equations. A differential equation is called homogeneous if the term on the right-hand-side of the equation is zero. The differential equation above is a nonhomogeneous equation because the righthand-side term is cos x . In many science and engineering problems, the governing differential equations are often in some specific forms. For examples, the Airy equation, d2y xy 0 dx 2
the Bessel equation, x2
d2y dy x x2 n2 y 0 2 dx dx
and the Legendre equation,
1 x 2
d2y dy 2x n n 1 y 0 2 dx dx
The solutions of these differential equations are normally in the forms of specific functions. If a problem contains n dependent variables, then these variables must be solved from a system of n differential equations. For example, the two dependent variables, y1 and y2 , are to be solved from the two differential equations, dy 7 1 3 y2 16 dx dy 2 2 5 y1 9 dx The exact solutions of y1 x and y2 x are obtained by solving these two differential equations simultaneously.
62
Chapter 3 Differential Equations
All of the differential equations above are called ordinary differential equations because the dependent variable y is only function of the independent variable x. For most practical problems, the dependent variable y is function of many independent variables, e.g., x1 and x2 ,
2 y 2 y x12 x22
0
This latter differential equation is called partial differential equation.
3.3 Solutions of Differential Equations One way to verify the solution is to substitute it back into the differential equation. The solution must satisfy the differential equation as shown in the examples below. Example Show that, 1 x is a solution of the second-order linear homogeneous differential equation, d2y 2 y 0 dx 2 x 2 The first- and second-order derivatives of the solution are, 1 dy 2x 2 dx x 2 2 d y 2 3 dx 2 x By substituting these derivative terms into the left-hand-side of the differential equation, y
y x
x2
2 2 2 x2 1 2 2 2 2 x3 x3 x3 x 2 x 0
3.3 Solutions of Differential Equations
63
leading to the result of zero. This means the given solution is the solution of the differential equation. We can use the D command to verify such result as follows, y
x2
D y,
1 ; x 2
x, 2
x2
y
Simplify
D
0
Example Use the D command to show that, y
y x C1e x C2e 2 x
where C1 and C 2 are constants, is a solution of the second-order linear homogeneous differential equation, d 2 y dy 2y 0 dx 2 dx y C1 x C2 2 x ; D y, x, 2 D y,
x, 1
2y
Simplify
0
It is noted that C1 and C 2 could be any numerical value, the given solution is always the solution of the differential equation above. Solutions of the differential equations may be in many forms from simple to complex functions. We will learn how to derive solutions in details in the following chapters. In this chapter, however, we will use the DSolve command to conveniently find the solutions. The objective herein is to show that the solutions could be in different forms, such as the trigonometric, polynomial and exponential functions. Example Use the DSolve command to find solution of the firstorder linear nonhomogeneous differential equation,
64
Chapter 3 Differential Equations
dy dx
x3 3
x2
x2 , y x , x
DSolve y ' x y x
DSolve
C 1
i.e.,
x3 C1 3
y
where C1 is a constant. Example Use the DSolve command to find solution of the firstorder linear nonhomogeneous differential equation, dy y x2 dx
DSolve y ' x y x
2
x2 , y x , x
y x 2x
x2
x
C 1
y C1e x x 2 2 x 2
i.e., where C1 is a constant.
Example Use the DSolve command to find solution of the firstorder nonlinear homogeneous differential equation, dy y2 dx
DSolve y ' x y x
y x 2
0
0, y x , x
1 x C 1
i.e., where C1 is a constant.
y
1 C1 x
DSolve
3.3 Solutions of Differential Equations
65
The differential equation in the preceding example is nonlinear, dy y2 dx Solution of this differential equation can be plotted to show the direction field by using the VectorPlot command. For example, the direction field for 1 x 2 and 0 y 3 can be displayed by entering, dydx
y2 ;
vl
1
dydx2 ;
VectorPlot VectorPlot 1 vl, dydx vl , x, 1, 2 , y, 0, 3 , VectorStyle Black, VectorScale .04
where vl is the vector length. The plot shows the vectors representing the direction field of the solution y x that varies with x. 3.0
2.5
2.0
y
1.5
1.0
0.5
0.0 1.0
0.5
0.0
0.5
x
1.0
1.5
2.0
66
Chapter 3 Differential Equations
Since the solution of the nonlinear differential equation above is, y
1 C1 x
where C1 is a constant that depends on the initial condition. If the initial condition is given as y 0 1 , then the constant C1 can be determined, 1
1 C1 0
to give C1 1 . Thus, the exact solution corresponding to the given initial condition is, y
1 1 x
We can impose this exact solution onto the direction field by adding the StreamPoints sub-command into the VectorPlot command as follow,
VectorPlot 1 vl, dydx vl , x, 1, 2 , y, 0, 3 , StreamPoints 1, StreamStyle VectorStyle Black, VectorScale .04
StreamPoints
Black,
We can see that the exact solution from the given initial condition is a solution of the direction field. In the following examples, solutions to the differential equations are in the form of special functions, such as the error, Airy and Bessel functions. Details of these functions are given in Chapter 11.
3.3 Solutions of Differential Equations
67
y 1 (1 x) 3.0
2.5
2.0
y
1.5
1.0
0.5
0.0 1.0
0.5
0.0
0.5
1.0
1.5
2.0
x
Example Use the DSolve command to find solution of the firstorder linear nonhomogeneous differential equation, dy dx
x2 , y x , x
DSolve y ' x
y x
i.e.,
C 1
e x 2
1 2
Erf x
y C1
where C1 is a constant.
erf x 2
DSolve
68
Chapter 3 Differential Equations
Example Use the DSolve command to find solution of the second-order linear homogeneous differential equation, d2y xy 0 dx 2 DSolve y '' x y x
xy x
AiryAi
i.e.,
x C 1
y
DSolve
0, y x , x AiryBi
x C 2
C1 Ai x C2 Bi x
where C1 and C 2 are constants. The function Ai x and Bi x are the Airy and Bairy function, respectively. Values of these two functions can be determined at any x location as explained in Chapter 11. Example Use the DSolve command to find solution of the second-order linear homogeneous differential equation, x2
d2y dy x x 2 4 y 0 2 dx dx
DSolve x2 y '' x y x
i.e.,
x y' x
BesselJ
2, x C 1
y
x2
4 y x BesselY
0, y x , x 2, x C 2
C1 J 2 x C2Y2 x
where C1 and C2 are constants. The function J 2 x and Y2 x are the Bessel functions of the first and second kind, respectively. Again, values of these two functions at any x location can be determined as explained in Chapter 11. Solutions of some differential equations may be in implicit form as shown in the following examples.
3.3 Solutions of Differential Equations
69
Example Use the DSolve command to find solution of the firstorder nonlinear nonhomogeneous differential equation, dy y x2 dx
x2 , y x , x
DSolve y x y ' x y x
2 3
x3
3C 1
,
y x
DSolve 2 3
x3
3C 1
The solution of y has to be determined from the equation,
y2
2 x3 2C1 0 3
which is in an implicit form where C1 is a constant. If the initial condition is y 0 0 , then C1 0 and the solution becomes,
y 2 x3 3 Example Use the DSolve command to find solution of the firstorder nonlinear nonhomogeneous differential equation,
y DSolve y x y ' x y x
2
dy y2 dx y x
2x 2C 1
2
,
2 2, y x , x y x
2
2x 2C 1
The solution of y has to be determined from the equation,
y 2 e2( xC1 ) 2 0 which is in an implicit form where C1 is a constant.
70
Chapter 3 Differential Equations
Example Use the DSolve command to find solution of the firstorder nonlinear homogeneous differential equation, dy y y cos y sin y x dx DSolve y x Cos y x Sin y x x y' x y x , y x ,x Solve x
Sin y x
C 1 y x , y x
The solution is in an implicit form of, sin y C1 y
x
where C1 is a constant that can be determined from the given initial condition. There are many differential equations that their exact solutions cannot be found as shown in the following examples. Example Use the DSolve command to find solution of the firstorder linear nonhomogeneous differential equation, dy xy dx
DSolve y' x
xy xy
DSolve y x
x
x
,y x ,x
DSolve
,y x ,x
In this case, Mathematica cannot find a solution. The result is thus returned in form of the input command. Example Use the DSolve command to find solution of the secondorder nonlinear homogeneous differential equation, d 2 y dy y2 0 dx 2 dx
DSolve y'' x DSolve y x
2
y' x y x
y x y
x
2
0, y x , x 0, y x , x
3.3 Solutions of Differential Equations
71
Again, a solution could not be found and Mathematica returns the result as the input command. It is noted that there is a large number of problems that their explicit solutions are not available. In this case, numerical methods must be applied to provide approximate solutions. Several numerical methods can provide very accurate solutions to different types of differential equations. We will see examples that demonstrate such capability in the latter chapters.
3.4 Concluding Remarks Differential equations occur in many classes of science and engineering problems. They represent the nature of problems, such as the mass, momentums and energy must be conserved or a system must be in equilibrium. Solving the differential equations lead to solutions that help understanding their physical phenomena. This chapter starts from describing the characteristics of the differential equations by using simple examples. These include linear, nonlinear, homogeneous, nonhomogeneous, first- and second-order differential equations. Finding solutions to the differential equations depends on their types. Exact solutions to some of these differential equations are easy to find while others are difficult or impossible to obtain. This chapter presents how to use the D command in Mathematica to find derivatives of the given functions. The DSolve command is then introduced to find solutions of the differential equations. Examples have shown that these commands help us to solve the differential equations conveniently. We will study different types of the differential equations in more details in the following chapters. Solutions of the differential equations will be derived by hands prior to using Mathematica to confirm them. We will thus understand how the solutions are derived and, at the same time, appreciate the capability of the symbolic computer software.
72
Chapter 3 Differential Equations
Exercises 1.
Identify that each of the following equations is linear, nonlinear, homogeneous or nonhomogeneous differential equation, d2y dy 2 y 1 2 dx dx 2 d y dy x2 2 x 2 y cos x dx dx dy x y2 0 dx d2y cos x y sin x dx 2 d2y dy 1 y 2 2 x 7 y e x dx dx
(a) 3 (b) (c) (d) (e) 2.
Identify that each of the following equations is linear, nonlinear, homogeneous or nonhomogeneous differential equation, (a) x y y x x2 y2 (c) y x2 y 2 (e) x 2 y x y y 0
3.
(b) x 2 y y x 2 x 2y (d) y 2x y (f) x 2 y 2 y 3 x 2
In each item below, use the D command to verify that the lefthand-side function is a solution to the right-hand-side differential equation, (a) (b) (c) (d) (e)
y y
3x x 2 e 3 x
y cosh x y y
1 x2 x2 1 x
; ; ; ; ;
x y y
x2
y 2 y 3 y 0 y y 0 x 2 y 5 x y 4 y x 2 y 2 y
0
Exercises
4.
73
In each item below, use the D command to verify that the lefthand-side function is a solution to the right-hand-side differential equation, (a) y 3sin 2 x 4 cos 2 x (b) y 2
e2 x
(c) y sinh 2 x 2 cosh 2 x (d) y 2
x2 x
;
yy e 2 x
;
y 4 y 0
;
2 x y y
x2 y2
In each item below, use the D command to verify whether the left-hand-side function is a solution to the right-hand-side differential equation or not, (a) y 2 cos x 3sin x ; y y 0 ;
y y
(c) y cos 2 x
;
(d) y e 2 x 3e x
;
y xy sin 2 x y y 2 y 0
;
y 4 y
(b) y
(e) y 6.
y 4 y 0
; 1 y 2 y 2 y 0
(e) x y tan 1 y 5.
;
sin x x 2
3 sin 2 x e x
x2 2
5e x
Use the D command to show that, (a) y x 2 is an exact solution of the first-order linear homogeneous differential equation, x
dy dx
2y
(b) y e x x is an exact solution of the first-order nonlinear nonhomogeneous differential equation, dy y2 dx
7.
e 2 x 1 2 x e x x 2 1
Use the D command to show that, y
x2 x 2 x 1 ln x x 2 1 2 2
74
Chapter 3 Differential Equations
is an exact solution of the first-order nonlinear homogeneous differential equation, x
8.
dy dy ln 2 y dx dx
Use the D command to show that each of the solutions below, (a) y e x x 2 x3 xn ... 2! 3! n! is an exact solution of the second-order linear homogeneous differential equation, d2y dy x 2 x n n y 0 dx dx
(b) y 1 x
where n is any positive integer. 9.
If A and B are constants, use the D command to show that, y1 x A Bx e 3 x
and y2 x 3 A B 3Bx e 3 x are the solutions to the coupled differential equations, dy1 y2 dx dy2 and 9 y1 6 y 2 dx 10. Use the DSolve command to find solutions of the following differential equations, dy 4 y 3x (a) 2 x y dx dy (b) x 2 x 2 xy y 2 dx dy (c) 2 xy x2 3y2 dx
Exercises
dy dx dy (e) x y dx
(d) 2 x y
75
4x 3 y x 3y
11. Use the DSolve command to find solutions of the following differential equations, d2y 4x (a) y dx 2 d2y dy 3 2y 0 (b) 2 dx dx 2 d y dy 3 2 y 2e x 1 x (c) 2 dx dx 3 d y d 2 y dy 2 2y 0 (d) dx 3 dx 2 dx d4y d3y d 2 y dy (e) 3 7 2 6y 0 4 dx dx dx dx 12. Use the DSolve command to find solutions of the following differential equations, (a) x 3 y 4 x 2 y e x 1 3 cos 2 x (b) y y x x (c) y y4 y 3 (d) x 2y x 2 xy y 2 1 y (e) xy xy 13. Solution of the nonlinear differential equation, dy dx
y2 x
is in the form of Bessel function. Use the DSolve command to find such solution and plot it in the form of direction field.
76
Chapter 3 Differential Equations
14. Employ the D command to show that,
y2 x 3 0 (a) the equation is an implicit solution of the differential equation, dy 1 dx 2y x y 3 x y 3 sin x 1
(b) the equation
is an implicit solution of the differential equation, dy dx
x cos x sin x 1 y 3 x x sin x
15. Employ the D command to find the first-order differential equations corresponding to the following implicit solutions, (a) (b) (c) (d) (e)
xy ln y
0 y 3 3x 3 y 5 1 x2 y 4 y 0 y tan 1 y x tan 1 x x 2 y 2 6 x 10 y 34 0
16. In each item below, use the D command to verify whether the left implicit equation is the solution to the right differential equation, x (a) x 2 y 2 4 ; y y e xy y (b) e xy y x 1 ; y e xy x 2 xy (c) y ln y x 2 1 ; y y 1 (d) x y e xy 0 ; 1 xe xy y ye xy 1 17. Employ the D command (and other commands, if necessary) to show that the function y x in the implicit equation form below,
Exercises
77
(a) 3e y 2 2e 3 x C is the solution of the nonlinear differential equation, dy 1 y 2 3 x e 0 dx y (b) cos x sin y C is the solution of the nonlinear differential equation, dy tan y dx cot x 1 1 C y 2 y2 is the solution of the nonlinear differential equation,
(c) x 1e x
dy dx
x y3 ex y 1
where C is a constant. 18. Employ the VectorPlot command to plot the direction field of the differential equation, dy x2 y dx for the intervals of 4 x 4 and 4 y 4 . Then use the DSolve command to solve the differential equation with the initial condition of y 0 1 . Plot the solution by imposing it onto the direction field. 19. Employ the VectorPlot command to display the direction field of the nonlinear differential equation, dy 3y 2 3 dx for the intervals of 0 x 3 and 1 y 1 . Then use the DSolve command to solve the differential equation with the initial condition of y 2 0 . Plot the solution by imposing it onto the direction field.
78
Chapter 3 Differential Equations
20. Use the D command to show that the function of y x in the implicit form, 2 y2 2 y 1 2 tan 1 ln 2 8 y 2 y 1 4
2 y 1 tan 1
2 y 1
xC
where C is a constant, is a solution of the nonlinear nonhomogeneous differential equation, dy y4 1 dx Then, plot its direction field for the intervals of 4 x 4 and 3 y 3.
21. Use the D command to show that the function of y x in the implicit form, x3 y3 y C 3 3
where C is a constant, is a solution of the nonlinear nonhomogeneous differential equation, dy dx
x2 1 y2
Plot the direction field for the intervals of 4 x 4 and 4 y 4 . Then, redisplay the plot by imposing the solutions when C 7, 5, 3, 0, 3 and 5 onto the direction field.
Chapter 4 First-Order Differential Equations 4.1 Introduction The differential equation in the first-order form of, dy f x, y dx is probably the simplest form for all types of differential equations. The form is thus often used as the first step in learning how to solve differential equations. Exact solution of y x , which makes the differential equation satisfies, is not that difficult to find. This chapter presents standard techniques for finding exact solutions of the first-order differential equations in the form above. Examples will be used to derive exact solutions by employing these techniques. The derived solutions will be verified by using Mathematica commands and plotted to show their variations. If the
80
Chapter 4 First-Order Differential Equations
exact solutions are not available, numerical methods will be used to find the approximate solutions. This chapter will thus help readers to understand how to solve this type of differential equation symbolically and numerically. At the same time, readers will appreciate the current capability of the computer software that can reduce effort for finding solutions of the first-order differential equations.
4.2 Separable Equations Separation of variables is a simple technique for solving the first-order differential equations. The dependent variable y is separated from the independent variable x so that they are on the opposite sides of the equation. By doing that, solutions of the differential equations can be found easily. For example, dy x 1 y dx The variable y and x in the equation above can be separated so that they are on opposite sides as, dy x 1 dx y Integration is then performed on both sides to obtain the solution of y as function of x. It is noted that the technique cannot apply if both variables are not separable, such as, dy xy 7 dx We will apply this technique to derive exact solutions of differential equations as shown in the examples below. The derived solutions will be verified by using the Mathematica commands. Example Derive general solution of the first-order linear differential equation, y 1 dy dx x3 Then, find the exact solution for the case of y0 4 .
4.2 Separable Equations
81
The given differential equation above is separable so that the variables y and x can be placed on the opposite sides as,
dx x3
dy y 1
We can integrate both sides of the equation,
dy
y 1
ln y 1
to get,
dx
x3
ln x 3 C
where C is the integrating constant. If we apply the exponential function base e to both sides of the equation, e ln
y 1
y 1
or,
eln
x3 C
eC x 3
eC eln
x3
C1 x 3
where C1 eC . Then, for positive quantity, y 1 C1 x 3
i.e., the solution is,
y
C1 x 3 1
Here, the constant C1 is to be determined from the given initial condition. We can employ the DSolve command in Mathematica to obtain the same solution as follows, DSolve y ' x y x
1
y x 3
1
x
3 , y x ,x
x C 1
By applying the initial condition of y0 4 , the constant C1 can be determined as, 4 C1 0 3 1
C1 1 Thus, the exact solution of this problem is, y 1 x 3 1
x4
82
Chapter 4 First-Order Differential Equations
The same exact solution can be obtained by using the DSolve command, DSolve
y x
y' x y 0 4
y x 1 4 , y x ,x
x
3 ,
DSolve
x
Example Derive general solution of the first-order nonlinear differential equation, dy y 2 sin x dx Again, we separate the variables y and x so that they are on opposite sides of the equation as, dy sin x dx y2 Then, perform integration on both sides to get, dy y 2 sin x dx 1 cos x C y where C is the integrating constant. Thus, the general solution is, 1 y cos x C The same solution can be obtained by using the DSolve command as, DSolve y ' x y x
y x 2 Sin x , y x , x 1
C 1
Cos x
Depending on the initial conditions, the corresponding exact solutions can be determined. For examples,
4.2 Separable Equations
83
y0 0.1
;
y
y0 0.2
;
y
y0 0.3
;
y
1 cos x 9 1 cos x 4 1 7 cos x 3
Variations of the exact solutions can be plotted by using the Plot command as shown in the figure. y (0) 0.3
0.7 0.6
y ( x)
0.5
y (0) 0.2
0.4 0.3
y (0) 0.1
0.2
1
2
3
x
4
5
6
Example Solve the first-order nonlinear differential equation, dy y 2 e x dx We can separate the variables y and x so that they are on opposite sides of the equation as, dy e x dx y2 Then, perform integration on both sides to get, dy y 2 e x dx 1 e x C y where C is the integrating constant. Thus, the general solution is,
84
Chapter 4 First-Order Differential Equations
y
1 e C x
The same solution is obtained by using the DSolve command, DSolve y ' x
y x 2
x, y x , x
DSolve
x
y x
1
x
C 1
Example Derive exact solution of the first-order nonlinear differential equation, dy y cosh x 3 dx with the initial condition of y0 . The variables y and x in the differential equation can be separated so that the equation becomes, y dy cosh x 3 dx
Integration is performed on both sides of the equation to get,
y dy
cosh x 3 dx
y2 sinh x 3 x C 2 where C is the integrating constant. Thus, the general solution is, y
2 sinh x 3 x C
The integrating constant is determined by applying the initial condition of y0 ,
C
2 0 0 C
2 2
Hence, the exact solution is, y
2 2 sinh x 3x 2
4.2 Separable Equations
85
The same solution is obtained by using the DSolve command, DSolve
y x y' x Cosh x y 0 , y x ,x 2
y x
6x
3,
DSolve
2 Sinh x
Variation of the solution y can be plotted in the interval of 0 x 2 by using the Plot command as, Plot y x
. ,
x, 0, 2
Plot
The plot of the variation is shown in the figure. 25
20
15
y ( x) 10
5 0
1
2
3
4
5
6
x
Example Derive the exact solution of the first-order nonlinear differential equation, dy 3x 2 4 x 2 2 y 1 dx with the initial condition of y0 1 . The terms containing variables y and x are separable so that the differential equation can be written as,
2 y 1 dy 3x 2 4 x 2 dx By performing integration on both sides of the equation,
86
Chapter 4 First-Order Differential Equations
2 y 1 dy
3x
2
4 x 2 dx
y 2 2 y x3 2 x 2 2 x C
we get,
where C is the integrating constant that can be found from the initial condition of y0 1 , 1 2 0 0 0 C
C
3
Then, the exact solution is,
y 2 2 y x3 2 x 2 2 x 3 y 2 2 y x3 2 x 2 2 x 3 0
or, i.e.,
y
1
x3 2 x 2 2 x 4
A proper solution is selected according to the initial condition, y 1 x3 2 x 2 2 x 4
which is the exact solution of this problem. The above exact solution can also be obtained by using the DSolve command,
DSolve
2 y x y 0
y x
1
3 x2
1 y' x
4x
2,
1 , y x ,x 4
2x
2 x2
x3
The Plot command can then be used to display the variation of y with x as shown in the figure. Plot 1
4
2x
2 x2
x3 ,
x,
2, 1
Plot
The exact solution above can also be verified by substituting it back into the governing differential equation,
87
4.3 Linear Equations
y
1
LHS 2
4 2 y
4x
2x
2 x2
x3 ;
1 D y, x
D
3 x2
y ( x) 1.0 0.5
2.0
1.5
1.0
0.5
0.5
1.0
x
0.5 1.0 1.5 2.0
The differential equation must satisfy and the initial condition of y0 1 must agree too, y . x
0
1
4.3 Linear Equations The first-order linear differential equation is probably the simplest equation among the others which is easy to solve. This section presents a popular technique of using the integration factor to solve for the solution. The general form of the first-order linear differential equation is, a1 x
dy a0 x y b x dx
where a1 x , a0 x and b x are constants or functions of x only.
It is noted that, if the coefficient a0 x 0 , the solution can be obtained by integrating the differential equation directly as,
88
Chapter 4 First-Order Differential Equations
a1 x
i.e.,
dy dx
b x
y x
b x
a x dx C 1
where C is the integrating constant. However, when a0 x is not zero, solution to the full form of the differential equation can still be derived conveniently. The full form of the first-order linear differential equation, after dividing through by a1 x , can be rewritten in the form, dy P x y Q x dx If we multiply this differential equation by the integrating factor defined by,
x e P x dx then, the differential equation becomes, dy x x P x y x Q x dx d or, x y x Q x dx which can be integrated to give the solution directly. We will learn how to use the integrating factor to find solution of the first-order differential equation by using the following examples. Example Use the method of integrating factor to solve the firstorder linear homogeneous differential equation, dy 3y 0 dx
Here, P x 3 , then the integrating factor is,
x e 3 dx e3x By multiplying the differential equation by the integrating factor above, dy e3 x 3e 3 x y 0 dx
4.3 Linear Equations
89
d 3 x e y 0 dx Then, perform integration to get,
or,
e3 x y C where C is the integrating constant. Thus, the general solution is, y
Ce3 x
The same solution can be obtained by using the DSolve command as, DSolve y ' x
y x
3x
3y x
0, y x , x
DSolve
C 1
Example Use the method of integrating factor to solve the firstorder linear non-homogeneous differential equation, dy 2y 4 x dx Here, P x 2 , then the integrating factor is,
x e 2 dx e 2 x We first multiply the differential equation by the integrating factor, dy 2e 2 x y 4e 2 x x e 2 x dx d 2 x or, e y 4e2 x x e2 x dx Then, perform integration on both sides of the equation to get, 1 1 e 2 x y 2 e 2 x x e 2 x e 2 x C 2 4 where C is the integrating constant. Thus, the solution is, e 2 x
y
7 x C e2 x 4 2
The same solution can be obtained by using the DSolve command as,
90
Chapter 4 First-Order Differential Equations
DSolve y ' x
7 4
y x
2y x
x 2
2x
4
x, y x , x
DSolve
C 1
The integrating constant C (C[1] in Mathematica result above) is to be determined from the initial condition. Variations of y(x) according to different initial conditions of y0 2.75, 2.25, 2.00, 1.85, 1.75 and 1.50 are shown in the figure. 0
x 0.5
1.5
1.75
2
3
2.0
1.50
1
y ( x)
1.0
1.85 2.25 2.75
y (0)
2.00
4
Example Use the method of integrating factor to find the exact solution of the first-order linear non-homogeneous differential equation, dy dx
3x 2
y x
with the initial condition of y1 5 . We start by writing the given differential equation in the form, dy 1 y 3x 2 dx x
Therefore, P x 1 x , which leads to the integrating factor of,
4.3 Linear Equations
91
1
x e x dx eln x x We then multiply the differential equation by the integrating factor, dy y 3x3 dx d or, x y 3x3 dx and perform integration on both sides of the equation to get, x
3 4 x C 4 where C is the integrating constant that can be determined from the initial condition of y1 5 as follows, xy
3 4 1 C 4 17 C 4
15
Thus, the exact solution of the problem is,
y x
3 3 17 x 4 4x
The same exact solution is obtained through the use of the DSolve command by entering,
DSolve
y' x y 1
y x
17 4x
3 x2
y x , x
5 , y x ,x
Expand
Expand
3 x3 4
Example Use the method of integrating factor to derive the exact solution of the first-order linear non-homogeneous differential equation,
92
Chapter 4 First-Order Differential Equations
x
dy 2 y 4 x2 dx
with the initial condition of y1 2 . Similar to the preceding example, we first write the differential equation in the standard form as, dy 2 y 4x dx x
Therefore, P x 2 x , which leads to the integrating factor of,
x e 2 x dx e2 ln x x2 Next, we multiply the differential equation by the integrating factor, dy x2 2 xy 4 x3 dx dy 2 or, x y 4 x3 dx Then, perform integration on both sides of the equation to get,
x 2 y x4 C where C is the integrating constant that can be determined from the initial condition of y1 2 as, 12 (2) 1 C 4
C 1
Thus, the exact solution of the problem is,
y x x2
1 x2
The same solution can be obtained by using the DSolve command as,
4.3 Linear Equations
DSolve
93
x y' x y 1 1
y x
x2
4 x2 ,
2y x
2 , y x ,x
DSolve
Expand
x2
Variation of this exact solution y(x) is plotted by the Plot command as shown in the figure. Plot
1 x2
x2 ,
PlotRange
Plot
x, 0, 5 , 0, 5 ,
0, 40
40
30
y ( x)
20
10
0 0
1
2
x
3
4
5
Example Use the method of integrating factor to solve the firstorder linear non-homogeneous differential equation, 1 dy 2 y x cos x x dx x 2
The given differential equation is first written in the standard form for applying the integrating factor technique as, dy 2 y dx x
x 2 cos x
Therefore, P x 2 x , so that the integrating factor is,
94
Chapter 4 First-Order Differential Equations
x e 2 x dx eln x 2 x 2 By multiplying the integrating factor to the differential equation, we get, dy x2 2 x 3 y cos x dx d 2 or, x y cos x dx Then, performing integration on both sides to obtain,
x 2 y sin x C where C is the integrating constant. Thus, the general solution of the given differential equation is,
y x x 2 sin x C x 2 Again, the same solution can be obtained by using the DSolve command as,
1 y' x x
DSolve
x2 C 1
y x
2
y x
x Cos x , y x , x
x2
x2 Sin x
DSolve
Variations of the solution, y(x), depend on values of the integrating constant C (or C[1] from Mathematica above) as shown in the figure.
100
y ( x)
0
C 1.0 2
4
6
8
x 100
10
C 0.5
12
C0 C 0.5
200
C 1.0
4.4 Exact Equations
95
4.4 Exact Equations If the differential equation is in the form of the so called exact equation, the idea explained below can be used to find its solution conveniently. We start from the differential equation in the form, dy M x, y dx N x, y where M x, y and N x, y are functions of x and y. We can rewrite this differential equation as,
M x, y dx N x, y dy 0 But from definition of the total derivative of a function x, y ,
d
dx dy x y
If we could find the function x, y such that, x
M x, y
Then, which means,
and
y
d
0
N x, y
C
where C is a constant. This technique could be applied if the given differential equation contains the terms M x, y and N x, y that satisfy the conditions above. The differential equation containing the terms that meet such requirements is called the exact equation. We will demonstrate the approach for finding solutions to this differential equation form by using the examples below. Example Find solution of the first-order linear homogeneous differential equation, dy 1 x 2 2 xy 0 dx
96
Chapter 4 First-Order Differential Equations
We start from writing the given differential equation in the form,
2 xy dx 1 x 2 dy 0
If we compare it with the standard form of,
M x, y dx N x, y dy 0 we find that, M x, y 2 xy and N x, y 1 x 2 Then, if we choose a function,
y x2 y
we notice that, 2 xy M x, y and x
1 x 2 N x, y y
d y x2 y 0
Thus,
d
or,
y x2 y C y 1 x 2 C
So, we arrive at the solution of the given differential equation, y
C 1 x2
where C is a constant that can be determined from the initial condition. It is noted that the approach explained above can be applied if, N x, y M x, y y x Such as in the example above,
and
M x, y y
2 xy y
N x, y x
1 x 2 2 x x
2x
4.4 Exact Equations
97
We can verify that the derived solution is correct by using the derivative D command. If we let the integrating constant C 1 and substitute the solution into the left-hand-side of the differential equation, 1
y 1 LHS
; x2 1 x2 D y, x
D
2xy
0
we obtain the result of zero which is equal to the value on the righthand-side of the equation. We can also use the DSolve command to solve the given differential equation by entering,
DSolve y x
x2 y ' x
1
2xy x
0, y x , x
C 1 x2
1
If the initial condition y0 1 , then the complete problem statement of this example is, dy 2 xy 0, dx which has the exact solution of,
1 x 2
y x DSolve
x2
1 y 0
y' x
y 0 1
1 1 x2 2xy x
0,
DSolve
1 , y x ,x
1
y x 1
x2
The Plot command can be used to plot the solution of y that varies with x as shown in the figure.
98
Chapter 4 First-Order Differential Equations
y ( x) 1.0 0.8 0.6 0.4 0.2
6
4
2
2
4
6
x
Example Find solution of the first-order differential equation which is in the exact equation form,
dy 2 xy 2 1 dx 2 x2 y We start by writing the given differential equation in the form,
M x, y dx N x, y dy 0
2 xy 2 1 dx 2 x 2 y dy 0
i.e.,
It is in the form of the exact equation because,
M x, y y
4 xy
N x, y x
If we choose the function,
x2 y2 x we find that,
and
x y
2 xy 2 1 M x, y 2x2 y
N x, y
This means, from the definition of the total derivative,
4.4 Exact Equations
d
99
d x2 y 2 x 0 x2 y 2 x C
or,
where C is a constant. Thus, the general solution of the given differential equation is,
y
Cx x
The same solution can be obtained by using the DSolve command as, 2xy x 2
DSolve y ' x
2 x2 y x
x
y x
1
C 1 x
,
, y x ,x
x
y x
C 1 x
In the two examples above, we chose functions x, y so In practice, the that x M x, y and y N x, y . proper functions x, y can be derived by using the following procedure. Since x M x, y , then,
x, y
M x, y dx g y
If we take derivative of with respect to y,
i.e.,
y
g y
N x, y
g M x , y dx y y
N x, y
M x, y dx y
which can be integrated to find g y so that the function is obtained. We will use this technique to find solutions of the differential equations in the following examples.
100
Chapter 4 First-Order Differential Equations
Example Find solution of the first-order differential equation,
2 xy sec2x dx x 2 2 y dy 0 The given differential equation is in the form of the exact equation,
M x, y dx N x, y dy 0 M y
because
2x
N x
The function x, y can be found by using the technique explained above as follows,
x, y
2 xy sec
2
x dx g y
x 2 y tan x g y y
Then,
x2
g y
g y
or, We integrate to get,
N x, y x 2 2 y
2y
g y2
x, y x 2 y tan x y 2
So that,
From the definition of the total derivative and the property of the exact equation, d
dx dy M x, y dx N x, y dy 0 x y
Thus,
d x 2 y tan x y 2 2 xy sec2 x dx x 2 2 y dy 0 or,
x 2 y tan x y 2
C
The solution of y x in the equation above is in an implicit form. We can also use the DSolve command to solve for the solution of y x . The solution obtained from Mathematica is lengthy but can be reduced by including the Simplify command.
4.4 Exact Equations
DSolve y ' x
101
2xy x x2
Sec x 2
, y x ,x
Simplify
2y x
y x
1 2
x2
Sec x 2
Cos x 2 x4
4C 1
4 Tan x
y x
1 2
x2
Sec x 2
Cos x 2 x4
4C 1
4 Tan x
,
The solution obtained above contains the constant C[1]. Such solution can be used to determine the function for which it must be a constant. If we let C[1] = 1, then becomes, 1 2
y phi
x2 x2 y
Sec x 2 Tan x
y2
Cos x 2 x4
4
4 Tan x
;
Simplify
1
which is a constant as expected. We can check whether the solution y x is correct by substituting it back into the differential equation, x 2 2 y dy 1 2 xy sec2 x dx LHS
x2 2xy
2y Sec x 2
D y, x
FullSimplify
1
In the first step of finding the function as explained above, M x, y must be integrated. The derivation process would be lengthy if M x, y is complicated. We can start the process by integrating N x, y if it is simpler,
x, y
N x, y dy h x
and then find h x . This latter process is shown in the following examples.
102
Chapter 4 First-Order Differential Equations
Example Solve the first-order differential equation, 1 e x y xex y dx xe x 2 dy 0 The given differential equation is in the form of the exact equation,
M x, y dx N x, y dy 0 M y
because
e x xe x
N x
To find the function x, y , we integrate N x, y with respect to y, x, y xe x 2 dy h x
xe x y 2 y h x
h e x y xe x y x x M x, y 1 e x y xe x y Also, x By comparing these two equations, h 1 x so, h x
Then,
x, y xe x y 2 y x
Then,
d
Since, Thus,
0
xe x y 2 y x C
i.e., the solution is,
y x
Cx xe x 2
where C is a constant. We can use the DSolve command to solve the given differential equation which is in the form, dy dx
1 e x y xe x y xe x 2
4.4 Exact Equations
103
by entering,
y x ,x
x 2
y x
x y x
x xy x , x x 2
1
DSolve y ' x
Simplify
Simplify
C 1 xx
Mathematica gives the same solution as we derived earlier. The solution depends on values of the constant C as shown in the figure. 2.0
C4
1.5
C 3
y ( x)
1.0
0.5
C2
C 1
0.0 0.0
0.5
1.0
1.5
2.0
x If the given differential equation is not in the exact equation form at the beginning, we may multiply it by an integrating factor so that it becomes an exact equation. Then, we can use the same procedure to find the solutions as demonstrated in the following examples. Example Use the exact equation technique to solve the first-order differential equation,
2 x2 y dx x2 y x dy 0 The given differential equation is not in an exact equation form of,
M x, y dx N x, y dy 0
104
Chapter 4 First-Order Differential Equations
M N 1 which is not equal to 2 xy 1 . y x If we multiply both sides by the integrating factor (only function of x in this case), 1 x 2 x
because
2 y dx y 1 dy 0 x 2 x
we get,
The differential equation becomes an exact equation because,
M y
1 x2
N x
Then, we can use the exact equation technique to find the solution similar to the preceding two examples. The solution of y x is obtained in an implicit form, 2x
y y2 x 2
C
We can use the DSolve command to provide the same solution of y x but in the explicit form as, 2 x2
DSolve y ' x
y x
1 x
y x
1 x
y x
x2 y x
1 x2 1 x2
, y x ,x
DSolve
x
1
4 x3
x2 C 1
1
4 x3
x2 C 1
,
In general, the integrating factor may be function of x and y. However, if the integrating factor is only function of x or y, we can find it by determining, P
M y N x N
4.4 Exact Equations
105
If the result of P is only function of x, then the integrating factor is,
x e P x dx But if this is not the case, we determine, Q
N x M y M
If the result of Q is only function of y, then the integrating factor is,
y e Q y dy We will demonstrate this technique in the example below. Example Determine the integrating factor for solving the firstorder differential equation,
3xy y 2 dx x 2 xy dy 0 Note that the given differential equation is not in the form of the exact equation,
M x, y dx N x, y dy 0 because
M N 3 x 2 y which is not equal to 2x y . y x
We first find the integrating factor by determining, P
M y N x N x y x x y
3x 2 y 2 x y x 2 xy 1 x
Then, the integrating factor is,
y e
1 x dx
x
After multiplying this integrating factor into the differential equation, we get,
106
Chapter 4 First-Order Differential Equations
3x 2 y xy 2 dx x3 x 2 y dy 0 The differential equation is now in the exact equation form because, M N 3x 2 2 xy y x We start deriving the solution to the differential equation by finding the function x, y from,
M x, y dx g y 3x y xy dx g y
x, y
2
x, y x 3 y y
Then,
x3 x 2 y
g y
2
x2 y2 g y 2
N x, y x 3 x 2 y
g 0 y g C1
or, i.e., where C1 is a constant.
x2 y2 C1 2 But from the definition of the total derivative and the exact equation,
x, y x 3 y
Hence,
d Then,
dx dy M x, y dx N x, y dy 0 x y
d x3 y
x2 y2 C1 0 2
x2 y 2 C1 C2 2 x2 y2 i.e., x3 y C 2 where C2 and C are constants. The solution is in an implicit form that can be further determined for y x .
or,
x3 y
4.5 Special Equations
107
The DSolve command can again be used to find the solution of the differential equation. The obtained solution is in an explicit form as follows, DSolve y ' x
x3
y x
3xy x x2
y x 2
2 C 1 x2
x6
x2 x3
y x
, y x ,x
xy x
2 C 1 x2
,
x6
x2
It is noted that the explicit solution y x obtained from Mathematica is in fact identical to the implicit solution derived earlier. This can be verified by substituting the explicit solution y x into the left-hand-side of the implicit expression as follows, x3
y LHS
1 2
x3 y
2 C 1 x2 x2
x2 y2 2
x6
;
Simplify
Simplify
2C 1
The result is a constant which is equal to the right-hand-side of the implicit expression.
4.5 Special Equations Solutions of the first-order differential equations can be found easily if the equations are in some special forms. For example, the differential equation in the form,
dy dx
y f x
108
Chapter 4 First-Order Differential Equations
where only the dy dx term appears on the left-hand-side while every term on the right-hand-side is in the form of y x . The example below shows the procedure to find the solution for this type of differential equation. Example Solve the first-order nonlinear differential equation, x
dy dx
y2 y x
We start from dividing the differential equation by x, 2
y y x x If we let y ux , where u u x , then the differential equation becomes, du x u u2 u dx du u2 or, dx x We can separate the variables u and x , so that they are on opposite sides of the equation, and then perform integration, dy dx
du dx 2 u x 1 ln x C to get, u where C is the integrating constant. Thus, 1 u ln x C
By substituting u y x back, we obtain the solution y x as,
y x
x ln x C
The same solution is also obtained by using the DSolve command,
4.5 Special Equations
109 y x 2 x
DSolve x y ' x
y x
C 1
y x , y x ,x
x Log x
DSolve
The technique above can be applied to other differential equations with the term y x on the right-hand-side of the equation. For examples, x3 dy y3 dx y x dy sin and, x dx y etc.
Bernoulli equation is the first-order differential equation that can be solved conveniently by changing the variable. The Bernoulli equation is in the form, dy P x y dx
Q x y n
where P x and Q x are continuous functions of x, while n is an integer. If n 0 or 1, the Bernoulli equation reduces from the nonlinear to linear equation. The idea for solving the nonlinear Bernoulli equation is to transform it into a linear one. The techniques we learned earlier can then be applied to solve for solutions. Such idea is summarized and demonstrated by the examples below. If we divide the Bernoulli equation by y n , dy P x y1 n Q x dx and introduce a new variable v in form of y as, yn
v with,
dv dx
y1 n
1 n y n
dy dx
110
Chapter 4 First-Order Differential Equations
Then, the Bernoulli equation, after dividing by y n , above becomes a linear differential equation in the form, 1 dv P x v 1 n dx
Q x
Example Solve the first-order nonlinear differential equation which is in form of the Bernoulli equation, dy 5 5 y xy 3 dx 2
Here, P x 5 , Q x 5x 2 and n 3 .
We first divide the
given differential equation by y to give, 3
y 3
dy 5 5 y2 x dx 2
Then, we assign the new variable v y 2 , so that dv dx 2y 3dy dx . The nonlinear differential equation becomes linear as, 1 dv 5 5v x 2 dx 2 dv or, 10v 5 x dx To solve such linear differential equation, we find the integrating factor, which is, e 10 dx e10 x Then, multiply it into the linear differential equation to get, dv e10 x 10e10 x v 5 xe10 x dx d 10 x or, e v 5 xe10 x dx After performing integration on both sides of the equation, we get, 10 x 1 10 x e10 x v e C 20
4.5 Special Equations
111
v
or,
x 1 Ce 10 x 2 20
where C is the integrating constant. The final solution is obtained after we substitute the variable v y 2 back into the above solution, 1 x 1 Ce 10 x 2 20 y2 1 i.e., y x 1 Ce10 x 2 20 The same solution is obtained by using the DSolve command, 5 DSolve y ' x 5y x DSolve x y x 3, 2 y x ,x
FullSimplify
2 5x
y x 10 x
1 5
,
2x
2 5x
y x
4C 1
10 x
1 5
2x
4C 1
In this case, Mathematica gives the solution in a slightly different form but it is the same as the exact solution derived above. This can be verified as follow, 1
yDerived x 2
yDerived2
1 20
2 5x
; yMathematica C
10 x
yMathematica2
10 x
1 5
2x
; 4C
FullSimplify
0
Example Solve the first-order nonlinear differential equation which is in the form of the Bernoulli equation, dy 1 y 3x 2 y 3 dx x
112
Chapter 4 First-Order Differential Equations
Here, P x 1 x , Q x 3x 2 and n 3 . We start from dividing the given differential equation by y 3 to give, dy 1 2 3x 2 y 3 y dx x Then, we assign a new variable of v y 2 so that dv dx 2y 3dy dx and the differential equation above becomes, 1 dv 1 v 3x 2 2 dx x or,
dv 2 v 6x 2 dx x The integrating factor is determined from,
e
elnx 2 x2
2 x dx
After multiplying the differential equation by the integrating factor, we get, dv x2 2 x 3v 6 dx d 2 or, x v 6 dx Then, perform integration on both sides to give, x 2 v 6 x C
where C is the integrating constant. Thus,
v 6 x3 Cx 2 The final solution is obtained after substituting v y 2 into the above equation, y 2 6 x 3 Cx 2 or,
y
1 6 x3 Cx 2
The same solution is obtained by using the DSolve command,
4.5 Special Equations
113 y x x
DSolve y ' x
3 x 2 y x 3, y x , x
1
y x 6 x3
,
1
y x
x2 C 1
6 x3
x2 C 1
The Riccati equation is another nonlinear differential equation that can be transformed into a linear equation. The general form of the Riccati equation is, dy P x y 2 Q x y R x dx
Transformation from the nonlinear to linear equation is by changing the variable, 1 y S x z where z z x . Solving the differential equations in this form is demonstrated by the following example. Example Solve the first-order nonlinear differential equation which is in the form of the Riccati equation, dy dx
1 2 1 2 y y x x x
If we change the variable y x into the new variable z x by using the relation, 1 y 1 z dy 1 dz then, 2 z dx dx Thus, the original Riccati equation becomes,
or,
1 dz z 2 dx
2
1 1 1 1 2 1 1 x z x z x
dz 3 1 z dx x x
114
Chapter 4 First-Order Differential Equations
which is in the form of a linear differential equation. Next, we multiply the equation by the integrating factor of x 3 to give, dz x3 3x 2 z x 2 dx d 3 or, x z x2 dx Then, perform integration on both sides of the equation of get, x3 x3 z C 3 1 C or, z 3 3 x where C is the integrating constant. Thus, the final solution to the given differential Riccati equation is, 1 1 1 y 1 z 1 C 3 3 x 3C 2 x3 y x or, 3C x3 The same solution is obtained by using the DSolve command, y x 2 x
DSolve y ' x y x
1
y x x
2 , y x ,x x
2 3 C 1 x3
1
where the constant solution.
3 C 1 x3 3C 1
is equivalent to 1 3C in the derived
4.6 Numerical Methods There are many first-order differential equations that cannot be derived for exact solutions in the form of explicit expressions. For these differential equations, numerical methods
4.6 Numerical Methods
115
are used to find their approximate solutions. Mathematica contains a powerful NDSolve command that can provide approximate solutions with high accuracy. Accuracy of the solutions strongly depends on the time steps which are adjusted automatically. We will employ the examples below to demonstrate the use of such command. We will also compare the numerical solutions with the exact solutions for the cases when the exact solutions are available in order to demonstrate the numerical solution accuracy obtained from using the command. Example Employ the NDSolve command in Mathematica to solve the first-order linear nonhomogeneous differential equation, dy dx
e 2 x
0 x2
with the initial condition of y0 0 . This initial value problem has exact solution in the form of explicit expression that can be found by using the DSolve command, DSolve
2 x, y 0
y' x y x ,x
y x
1 2
0 ,
DSolve
Simplify
2x
2
i.e., the exact solution is, 1 1 e 2 x 2 The NDSolve command in Mathematica employs the Runge-Kutta method to numerically solve the first-order differential equation in the general form of, dy f x, y dx The arguments in the NDSolve command are similar to those in the DSolve command. The file below contains a set of commands that yexact
116
Chapter 4 First-Order Differential Equations
solve the differential equation numerically and compare the computed solution with the exact solution above. A plot is also created by using the Plot command as shown in the figure. The figure indicates that the numerical solution is quite accurate as compared to the exact solution. y x
:
2x
1 2
; 2 NDSolve exactsol Table x, y x , x, 0, 2, .1 ; plot1 ListPlot exactsol, PointSize .02 , Black ; Clear y ; PlotStyle numsol
NDSolve
2 x, y 0
y' x
. numsol, plot2 Plot y x Show plot1, plot2
0 , y x ,
x, 0, 2 , PlotStyle
x, 0, 2
;
Black ;
0.5
0.4
Exact
0.3
y ( x) Approx.
0.2
0.1
0.5
1.0
1.5
2.0
x Example Employ the NDSolve command in Mathematica to solve the first-order linear nonhomogeneous differential equation, dy dx
2 cos2 x sin x
0 x 10
with the initial condition of y0 0 . The exact solution can be determined by employing the DSolve command as,
4.6 Numerical Methods
DSolve
y' x y 0
y x
1
117
2 Cos 2 x Sin x , 0 , y x ,x
Cos x
Sin 2 x
i.e., the exact solution is,
yexact
sin 2 x cos x 1
We can prepare a set of commands to determine the numerical solution and compare it with the exact solution by using a plot as follows, y x : 1 Cos x Sin 2 x ; exactsol Table x, y x , x, 0, 10, .5 ; plot1 ListPlot exactsol, PlotStyle PointSize .02 , Black ; Clear y ; numsol NDSolve y ' x 2 Cos 2 x Sin x , 0 , y x , x, 0, 10 ; y 0 plot2 Plot y x . numsol, x, 0, 10 , PlotStyle Black ; Show plot1, plot2
Both the exact and numerical solutions are compared and plotted as shown in the figure. Again, the plot demonstrates that the numerical solution obtained from using the NDSolve command compares very well with the exact solution.
0.5 2
4
6
1.0 1.5 2.0 2.5
10
x
Approx.
0.5
y ( x)
8
Exact
118
Chapter 4 First-Order Differential Equations
Example Employ the NDSolve command in Mathematica to solve the first-order linear nonhomogeneous differential equation, dy dx
sin y cos x e 3 y
0 x8
with the initial condition of y0 0.2 . For this problem, if we try to find the exact solution by using the DSolve command as we did in the preceding examples, DSolve
y' x y 0
DSolve
Sin y x
3y x ,
0.2 , y x , x 3y x
y x y 0
Cos x
Cos x
Sin y x
,
0.2` , y x , x
We found that Mathematica cannot provide an exact solution and returns the same command back. We need to employ the numerical method to find the approximate solution by using a set of commands below. The plot of the computed solution is shown in the figure. It is noted that exact solutions to most of the differential equations are not available. The numerical method is thus an important tool to provide us the approximate solutions of the differential equations. numsol
NDSolve
y' x y 0
Plot y x
. numsol,
Sin y x 0.2 , y x ,
3y x ,
Cos x x, 0, 8
x, 0, 8 , PlotStyle
;
Black
There are some differential equations that their solutions change abruptly with x. These differential equations are classified as the stiff equations. Approximate solutions obtained from standard numerical methods may not be accurate because of their sudden changes. The NDSolve command can still be used to compute the numerical solution as shown in the following example.
4.6 Numerical Methods
119
3.5 3.0 2.5
y ( x)
2.0
Approx.
1.5 1.0 0.5 2
4
6
8
x
Example Employ the NDSolve command to solve the stiff differential equation which is in the form, dy dx
20e 100 x 2 2 0.6 y
0 x4
with the initial condition of y0 0.5 . The NDSolve and Plot commands are used to solve and plot for the numerical solution. The plot indicates that there is a sudden change of the solution y x at x 2 . The figure shows that Mathematica can accurately capture the sudden change of the solution. numsol
NDSolve
y' x y 0
Plot y x
. numsol,
20
100 x 2 2
0.5 , y x ,
0.6 y x , x, 0, 4
x, 0, 4 , PlotStyle
Black
3.5 3.0 2.5
y ( x)
2.0 1.5 1.0 0.5 1
2
x
3
;
4
120
Chapter 4 First-Order Differential Equations
4.7 Concluding Remarks In this chapter, we learned several techniques for finding exact solutions of the first-order differential equations. Depending on the forms of differential equations, proper techniques should be selected and applied to solve for solutions. These include the technique of separating variables, the technique of using integrating factors for linear and exact equations. Some specific techniques were also introduced to solve differential equations that are in special forms, such as the Bernoulli and Riccati equations. The same solutions were obtained by using the DSolve command in Mathematica. These solutions were also plotted by the Plot command to increase understanding of their behaviors. Numerical methods for solving the differential equations were introduced. Mathematica contains a powerful NDSolve command that can be used to provide accurate solutions. Approximate solutions obtained from the numerical method were compared with the exact solutions to highlight their efficiency. Since there are many first-order differential equations that the exact solutions cannot be found, such command thus provides an alternative way to obtain the approximate solutions with high accuracy.
Exercises 1.
Use the DSolve command to find solutions of the first-order differential equations, x2 x2 dy dy (a) (b) y y 1 x3 dx dx 3x 2 1 dy dy (c) (d) x 1 y2 3 2 y dx dx dy y 2e x (e) dx Then, use the separable equation technique to verify the solutions.
Exercises
2.
121
Use the DSolve command to find solutions of the first-order differential equations, dy 3x 2 y 0 dx dy (c) y 2 sin x 0 dx dy (e) e x x 1 y 2 0 dx
(a)
dy 1 0 dx y3 1 dy (d) 2 cos 2 y 0 x dx (b) x
Then, use the separable equation technique to verify the solutions. 3.
Use the DSolve command to solve the initial value problems, dy x3 1 y , y 0 3 (a) dx dy 6 x3e 2 y , y1 0 (b) dx dy 1 y 2 tan x, y 0 (c) 3 dx 1 dy y 0 (d) y 1 cos x, 2 dx dy sin 1 x, y0 1 (e) 1 x 2 y 2 dx Derive the solutions by using the technique of separable equation. Then, use the Plot command to plot the solution of y(x) that varies with x.
4. Solve the initial value problems below by using the DSolve command, 2x dy , y 0 2 (a) y x2 y dx (b)
dy dx
3x 2 e x , 2y 5
y 0 1
(c)
e x e x dy , 3 4y dx
y 0 1
122
Chapter 4 First-Order Differential Equations
(d)
dy dx
xy 3 , 1 x2
y 0 1
dy 1 sin x 1 y 2 , y0 1 dx Then, for each problem, derive the exact solution by using the technique of separable equation. Verify each solution by showing that both the differential equation and initial condition are satisfied.
(e)
5.
Use the integrating factor technique to find solutions of the first-order differential equations below. Verify the solutions by comparing with those obtained by employing the DSolve command. dy y dy (b) y e3 x 2x 1 dx x dx dy dy 1 (d) x 2 y (c) 4 y x 2e 4 x x3 dx dx dy sin x (e) x 3 y x 2 x dx
(a)
6.
Employ the DSolve command to solve the first-order linear differential equations, dy dy (b) 3 y x e 2 x y xe x 1 dx dx dy dy (d) x 2 y sin x (c) 2 y 3x 2 dx dx dy (e) x y x 2 e x dx Then, derive their solutions by using the technique of integrating factor.
(a)
7.
Use the technique of integrating factor to solve the initial value problems that are governed by the first-order differential equations and their initial conditions,
Exercises
123
dy y 0 1 y 2 x e2 x , dx dy y1 0 (b) 3 y xe3 x , dx dy 2 cos x y 0 (c) y , dx x x2 dy y 2 1 (d) x 2 y sin x, dx dy y 1 0 (e) x 3 4 x 2 y e x , dx Then, employ the DSolve command to solve these problems again. Plot the solution of y(x) that varies with x by using the Plot command.
(a)
8.
Solve the following initial value problems by using the DSolve command, dy y 0 2 (a) 4 y e x , dx dy 3 y y1 1 (b) 3 x 2, x dx dy y y3 4 (c) 3x, dx x 2 dy 5 y 3 x 3 x, y 1 0 (d) dx 9 x dy y 2 2 (e) sin x y cos x x sin x, dx In each problem, verify the solution by comparing with that obtained from the technique of exact equation with integrating factor. Use the Plot command to plot the solutions.
9.
Check whether the differential equations below are in the exact equation form by finding their derivatives with the derivative D command, (a) 2 xy 3 dx x 2 1 dy 0 x (b) 1 ln y dx dy 0 y
124
Chapter 4 First-Order Differential Equations
(c) cos x cos y 2 x dx sin x sin y 2 y dy (d) e x y x dx 1 e x dy 0 1 (e) 2 xy 2 dx (2 x 2 y cos y ) dy 0 x
0
10. Solve the differential equations in Problem 9 that are in the exact equation form. Show the derivation of the exact solutions in details. Then, repeat the problems by using the DSolve command to verify the derived solutions. 11. Show that the following differential equations are the exact
equations before deriving for their solutions. Then, use the DSolve command to find solutions and compare with the solutions derived. Hint: Property of the exact equation, M y N x , can be verified conveniently by using the derivative D command. (a) 2 x 4 dx 3 y 8 dy
0
(c) 4 xy 2 5 dx 4 x 2 y 2 dy y (d) 5 x dx (ln x 1) dy x 2 (e) 3x y e y dx x3 xe y 2 y dy
0
(f) tan x sin x sin y dx cos x cos y dy
0
0 0
12. Derive the exact solutions of the following initial value problems by using the exact equation technique. Verify the derived solutions with those obtained from using the DSolve command. (a) 3x 2 y dx y x3 dy
0,
y 0 0
(b) x y dx 2 xy x 2 1 dy
0,
y1 1
(c) e x y 1 dx e x 1 dy
0,
y1 1
(d) 2 x sin y dx x 2 cos y dy
0,
y1 1
2
(e) sin x cos x xy 2 dx y 1 x 2 dy 0, y0 2
Exercises
125
13. Solve the following differential equations by using the exact equation technique with the integrating factors. Compare the derived solutions with those obtained from using the DSolve command. Hint: The integrating factors for (d) and (e) are y 2 and xe x , respectively. (a) 3x 2 y dx x 2 y x dy 0 (b) x 4 x y dx x dy
0
(c) 2 y 2 2 y 4 x 2 dx 2 xy x dy
0
(d) 2 xy 4 x dx 4 x 2 y 3 dy
0
(e) x 2 sin y dx x cos y dy
0
14. Solve the following differential equations by using the exact equation technique with the integrating factors. Compare the derived solutions with those obtained from using the DSolve command. (a) y dx 1 x dy 0 (b) xy y 2 y dx x 2 y dy
0
(c) 2 y 2 3x dx 2 xy dy
0
(d) 10 6 y e3 x dx 2 dy
0
(e) x 2 sin y dx x cos y dy
0
15. Solve the following initial value problems that are governed by the differential equations and initial conditions. Derive their exact solutions by using the exact equation technique with the integrating factors. Compare the derived solutions with those obtained by using the DSolve command. (a) x dx x 2 y 4 y dy 0, y1 0 (b) x 2 y 2 5 dx y xy dy 0,
y 0 1
(c) xy dx 2 x 2 3 y 2 20 dy
y 0 1
0,
16. Derive the solutions of the differential equations that contain terms in the form of y x as follows,
126
Chapter 4 First-Order Differential Equations
(a)
dy dx
x y y x
dy xy xy 2 dx dy x2 y y3 (d) x 3 dx
(b)
dy y2 y 1 dx x2 x y dy x cos y (e) x dx x
(c)
Then, use the DSolve command to solve for solutions of these differential equations again and compare them with the derived solutions. 17. Derive solutions of the following Bernoulli differential equations. Compare the derived solutions with those obtained by using the DSolve command. dy dy 1 2 (b) x (a) y2 y y xy 2 dx x x dx dy dy y x3 y 3 (d) (c) xy xy 4 dx dx x dy (e) xy 2 y 3 x cos x dx 18. Solve the Riccati differential equation, dy 2 x 2 y 2 xy 2 dx
1
by changing the variable, y
x
1 z
Show the derivation of the exact solution in detail. Then, verify the solution by comparing with that obtained from using the DSolve command. 19. Solve the Riccati differential equation, dy dx
x3 y x 2
y x
Exercises
127
by changing the variable, y
x
1 z
Show the derivation of the exact solution in detail. Then, verify the solution by comparing with that obtained from using the DSolve command. 20. Employ the DSolve and NDSolve commands to find the exact and approximate solutions of the initial value problem governed by the first-order linear homogeneous differential equation, dy 2 xy 0 0 x 1 dx with the initial condition of y0 1 . Plot to compare the two solutions of y(x) that vary with x in the interval 0 x 1 . 21. Employ the DSolve and NDSolve commands to find the exact and approximate solutions of the initial value problem governed by the first-order nonlinear nonhomogeneous differential equation, 2 xy
dy y2 dx
x2
1 x 2
with the initial condition of y1 2 . Plot to compare the two solutions of y(x) that vary with x in the interval 1 x 2 . 22. Employ the DSolve and NDSolve commands to find the exact and approximate solutions of the initial value problem governed by the first-order nonlinear nonhomogeneous differential equation, y
dy xy 2 dx
5x
0 x2
with the initial condition of y0 2 . Plot to compare the two solutions of y(x) that vary with x in the interval 0 x 2 .
128
Chapter 4 First-Order Differential Equations
23. Use the DSolve command to find exact solution of the initial value problem governed by the stiff differential equation, dy dx
20e 100 x 2 2 0.6 y
0 x4
with the initial condition of y0 0.5 . Then, employ the NDSolve command to find the approximate solutions. Plot to compare these solutions with the exact solution and provide comments on the numerical solution accuracy. 24. Use the DSolve command to find exact solution of the initial value problem governed by the stiff differential equation, dy dx
y2 y3
0 x 2000
with the initial condition of y 0 0.001 . Then, employ the NDSolve command to find the approximate solution. Comment on the accuracy of the numerical solution that does not have the exact solution to compare.
Chapter 5 Second-Order Linear Differential Equations 5.1 Introduction We learned several techniques for solving many types of the first-order differential equations in Chapter 4. We found that proper techniques should be applied according to the types of differential equations in order to reach for the solutions. We also found that exact solutions for many differential equations cannot be derived in closed-form expressions. Numerical methods are needed to find the approximate solutions. In this chapter, we will learn how to solve the secondorder linear differential equations. This type of differential equation arises in several scientific and engineering problems, such as heat transfer, fluid flow, wave propagation, electro-magnetic field, etc. Solving these second-order differential equations is
130
Chapter 5 Second-Order Linear Differential Equations
simpler than the first-order differential equations because there are only few standard techniques that are easy to follow and understand. We will start from solving the homogeneous secondorder differential equations before extending to the nonhomogeneous equations. Several examples are used and, at the same time, the derived solutions are verified by employing Mathematica commands. At the end of the chapter, we will study how to apply the numerical methods to solve these second-order differential equations. The numerical methods provide approximate solutions when the exact solutions are complicated or not available.
5.2 Homogeneous Equations with Constant Coefficients The second-order linear homogeneous differential equation with constant coefficients can be conveniently solved for solution. Such differential equation is in the form, d2y dy a by 0 2 dx dx
where a and b are constants, while the right-hand-side of the equation is zero. A solution to this differential equation is e x for which is a number. To find the values of , we substitute this solution e x into the differential equation,
2e x a e x b e x 0 then, divide by e x to get, 2 a b 0
The result is in form of quadratic equation that can be used to find values of . We call this quadratic equation as the characteristic or auxiliary equation. The roots of this equation are,
1 , 2
1 a a 2 4b 2
5.2 Homogeneous Equations with Constant Coefficients
131
Depending on the values of the coefficients a and b, there are three possible cases for the values of the roots. We will consider these cases in details in the next three sections. It is noted that the function in the form of e x is a solution of the second-order differential equation. For example, yx
e 2 x e 3 x
where 1 2 and 2 3 , is a solution of the second-order homogeneous differential equation, d2y dy 5 6y 0 dx 2 dx We can verify this by determining the derivatives of the solution and substitute them into the equation, as follows. dy 2e 2 x 3e 3 x Since, dx d2y 4e2 x 9e3 x and, dx 2 d2y dy then, 5 6y 2 dx dx 2 x 3 x 4e 9e 5 2e 2 x 3e 3 x 6 e 2 x e 3 x 0 which is equal to the value on the right-hand-side of the equation. The derivative D command can help us to verify such equation conveniently, y LHS
2x
D y,
3 x;
x, 2
D
5 D y, x
6y
Simplify
0
If we consider these two functions e2 x and e 3 x , we see that their variations are different and do not depend on each other. Or, in the other word, they are linearly independent. We can also ensure that the two functions are linearly independent by using the Wronski’s test. The two functions y1 and y 2 are linearly independent if the determinant defined by,
Chapter 5 Second-Order Linear Differential Equations
132
W
y1
y2
y1
y2
y1 y2 y2 y1
is not zero. As in this example, y1 e 2 x and y 2 e 3 x , then, e 2 x
W
2e
e 3 x 3e
2 x
3 x
e 5 x
which is not zero. The determinant, so called the Wronskian, can be easily obtained by using the Det command, 2 x; y y1 2 y1 , y2 , W Det W
3 x;
D y1 , x , D y2 , x
; Det
5x
Here, the solution, yx
e 2 x e 3 x
of the differential equation, d2y dy 5 6y 0 2 dx dx
can be also obtained by using the DSolve command, DSolve y '' x
y x
i.e.,
2x
5 y' x
C 1
3x
y x
6y x
C 2
0, y x , x DSolve
C1 e 2 x C 2 e 3 x
where C1 and C 2 are constants. If these two constants are determined from the two initial conditions, such as y 0 0 and y 0 1 , we call the problem as the initial value problem. But if they are determined from the two boundary conditions, such as y 0 0 and y 5 1 , we call it as the boundary value problem. We will solve the initial value problem in this chapter, while solving the boundary value problem will be shown in Chapter 9.
5.3 Solutions from Distinct Real Roots
133
5.3 Solutions from Distinct Real Roots As explained in the preceding section, the second-order linear homogeneous differential equation with constant coefficients, d2y dy a by 0 2 dx dx
has a solution in the form of e x . By substituting this solution into the differential equation above, we obtain the characteristic equation, 2 a b 0 which leads to the two roots of, 1 a a 2 4b 2
1 , 2 If
a 2 4b 0 , the two roots are distinct real numbers as,
1 a a 2 4b 2 which lead to the solution of,
1
yx
and
2
1 a a 2 4b 2
C1 e 1 x C 2 e 2 x
where C1 and C 2 are constants. We will learn how to solve the differential equation when its solution consists of the distinct real roots by using the following examples. Example Derive the general solution of the second-order differential equation, d2y dy 5 4y 0 2 dx dx
After assuming the solution in the form of e x and substitute it into the differential equation, we get, 2 e x 5 e x 4 e x 0
Then, we divide it by e x to obtain the characteristic equation,
Chapter 5 Second-Order Linear Differential Equations
134
2 5 4 0
1 4 0 1 1 and 2 4
Or,
i.e., Thus, the general solution is,
y C3 e x C4 e4 x where C3 and C4 are constants. We can employ the DSolve command to obtain the same solution, DSolve y '' x
y x
x
5 y' x 4x
C 3
4y x
0, y x , x DSolve
C 4
Example Derive the general solution of the second-order differential equation, d 2 y dy 6 2 2y 0 dx dx Similar to the preceding example, by assuming the solution in the form of e x , the characteristic equation is,
Or,
6 2 2
0
2 1 3 2
0 2 3
1 and 2 2 Thus, the general solution is, y C5 e x 2 C6 e 2 x 3
i.e.,
1
Again, the DSolve command can be used to find the solution, DSolve 6 y '' x
y x
2x 3
C 5
y' x x 2
2y x
C 6
0, y x , x DSolve
5.3 Solutions from Distinct Real Roots
135
Example Derive the general solution of the second-order differential equation, d2y dy 0 7 2 dx dx If we follow the same procedure as in the preceding two examples, we obtain the characteristic equation as, 2 7 0 7 0
Or,
1 0
i.e.,
and
2 7
Thus, the general solution is, y C7 e0 x C8 e7 x C7 C8 e7 x The DSolve command can be employed to give the same solution, DSolve y '' x
y x
7 y' x 7x
C 7
0, y x , x
C 8
DSolve
Example Derive the exact solution of the initial value problem governed by the second-order differential equation, 4
d2y dy 8 3y 0 2 dx dx
with the initial conditions of y 0 1 and y 0 1 2 . From the given differential equation, the characteristic equation is, 4 2 8 3
Or,
2 12 3 0
1 2 Then, the general solution is,
i.e.,
0
1
and
2
y C9 e x 2 C10 e3 x 2
3 2
Chapter 5 Second-Order Linear Differential Equations
136
1 3 C9 e x 2 C10 e3 x 2 2 2
y
Also,
where C9 and C10 are constants that can be determined from the given initial conditions as follows, y 0 1
to give,
C9 C10
y 0
1 2
C9 1
and
1 3 C9 C10 2 2
C10 0
Hence, the exact solution for this initial value problem is, y
ex 2
We can use the DSolve command to find the same exact solution, DSolve
4 y '' x 8 y' x y 0 1, y ' 0
y x
3y x 0, 1 2 , y x ,x
x 2
DSolve
This exact solution can be plotted by using the Plot command, Plot y x
. ,
x, 0, 5
Variation of the solution y that varies with x is shown in the figure. 12 10 8
y ( x)
6 4 2
1
2
x
3
4
5
5.4 Solutions from Repeated Real Roots
137
5.4 Solutions from Repeated Real Roots From the second-order homogeneous differential equation with constant coefficients, d2y dy a by 0 dx 2 dx We assume the solution in the form of e x and substitute it into the differential equation, we obtain the characteristic equation, 2 a b 0
which leads to the two roots of, 1 1 , 2 a a 2 4b 2 If the coefficients a and b in the differential equation are given such that, a 2 4b 0 then, the two roots are the same real number, a 1 2 2 So that, the general solution is, y
e ax
2
But the general solution must consist of two functions because the differential equation is second order. Thus, we need to find the second function. If we assume the second function in the form, y u x e ax 2 a y u e ax 2 u e ax 2 Then, 2 a2 y u e ax 2 a u e ax 2 u e ax 2 and, 4 By substituting these y, y and y into the differential equation, u e ax 2 a u e ax 2 a 2 u e ax 2 a u e ax 2 a u e ax 2 4 2 2 a b u e ax 2 e ax 2 u u b 0 4
138
Chapter 5 Second-Order Linear Differential Equations
Because b a 2 4 0 in this case and e ax 2 could not be zero, this means, u 0 Or,
u x
where c and d are constant. y Hence,
cx d
cx d e ax 2
is another function that could be the solution of the differential equation. For simplicity, we may select c 1 and d 0 , so that the general solution for the case of repeated roots is,
y e ax 2 xe ax 2 We will learn how to find general solutions of the differential equations when the roots of their characteristic equations are repeated by using the following examples. Example Derive the general solution of the second-order differential equation, d2y dy 2 y 0 2 dx dx We first assume the solution in the form of e x and substitute it into the differential equation to get, 2 e x 2 e x e x
0
Then, we divide it by e x to obtain the characteristic equation, 2 2 1 0 Or,
1 1 0
which leads to the two roots of 1 1 and 2 1 . Since the roots are repeated, thus the general solution is, y C11 e x C12 xe x where C11 and C12 are constants. The same solution is obtained by using the DSolve command as,
5.4 Solutions from Repeated Real Roots
DSolve y '' x y x
x
2 y' x x
C 11
139
y x
0, y x , x
x C 12
DSolve
Example Derive the general solution of the second-order differential equation, d2y dy 6 9y 0 dx 2 dx The characteristic equation corresponding to the given differential equation is, 2 6 9 0
3 3 0
Or,
which leads to the repeated real roots of,
1 2
3
Thus, the general solution is,
y C13 e3 x C14 xe3 x where C13 and C14 are constants. Again, the DSolve command can provide the same solution, DSolve y '' x
y x
3x
6 y' x
C 13
3x
9y x
0, y x , x
x C 14
Example Solve the initial value problem governed by the secondorder differential equation, d2y dy 4 4y 0 2 dx dx with the initial conditions of y 0 1 and y 0 3 . The corresponding characteristic equation is, 2 4 4 0
Chapter 5 Second-Order Linear Differential Equations
140
2 2 0
Or,
which leads to the two repeated roots of 1 2 and 2 2 . Thus, the general solution is,
y
C15 e 2 x C16 xe2 x
y 2C15 e 2 x 2C16 xe2 x C16 e 2 x
so that,
where C15 and C16 are constants that can be determined from the two given initial conditions, y 0 1
C15 0
y 0 3
2C15 0 C16
C15 1
to give,
and
C16 5
Hence, the exact solution to this initial value problem is,
y e 2 x 5 xe 2 x The same solution is obtained by using the DSolve command, DSolve
y '' x 4 y' x y 0 1, y ' 0
y x
2x
1
4y x 0, 3 , y x ,x
5x
DSolve
The above exact solution can also be verified by substituting it back into the differential equation and using the derivative D command, y LHS 0
2x
1 D y,
5x ; x, 2
D
4 D y, x
4y
Simplify
The exact solution must also satisfy the two initial conditions which can be verified as follows,
5.4 Solutions from Repeated Real Roots
y . x 1
0
D y, x 3
. x
141
0
Example Solve the initial value problem governed by the secondorder differential equation, d 2 y dy y 0 dx 2 dx 4 with the initial conditions of y 0 1 and y 0 1 3 .
From the given differential equation, the corresponding characteristic equation is, 1 0 2 4 1 1 0 Or, 2 2 1 1 i.e., and 1 2 2 2 Since the roots are repeated, then the general solution is, y C17 e x 2 C18 xe x 2 1 1 C17 e x 2 C18 xe x 2 C18 e x 2 2 2 where C17 and C18 are constants which can be determined from the two initial conditions,
So that,
y
y 0 1
C17 0
1 C 0 C18 2 17 1 C17 1 to give, and C18 6 Thus, the exact solution to this initial value problem is, x y ex 2 ex 2 6 y 0
1 3
142
Chapter 5 Second-Order Linear Differential Equations
The same solution is obtained by using the DSolve command, DSolve
y x
y '' x y' x y 0 1, y ' 0
1 6
x 2
x 2
y x 4 0, 1 3 , y x ,x
Expand
x
The Plot command can then be used to plot the variation of y that varies with x as shown in the figure. 2.5 2.0 1.5
y ( x) 1.0
0.5
1
2
3
x
4
5
6
5.5 Solutions from Complex Roots From the second-order homogeneous differential equation with constant coefficients in the form, dy d2y a by 0 2 dx dx By assuming the solution in the form of e x and substitute it into the differential equation, we obtain the characteristic equation, 2 a b 0 which leads to two roots of,
1 , 2
1 a a 2 4b 2
If a 2 4b 0 , then the two roots are conjugate complex numbers i and i where might be zero but is not. In this case, the general solution of the differential equation is,
5.5 Solutions from Complex Roots
y
143
A e i x B e i x
where A and B are constants. By using the Euler’s formula, ei x cos x i sin x e i x cos x i sin x
and
then, the general solution above becomes, yx
e x A e i x B e i x A e x cos x i sin x B e x cos x i sin x
A B e x cos x i A B e x sin x
This solution can be written in a simpler form if we select A B 1 2 , then y x ex cos x . At the same time, if we select A 1 2 i B , we get y x ex sin x . Since the two solutions must be linearly independent, thus we can write the general solution in the form of, yx
C1 e x cos x C 2 e x sin x
where C1 and C 2 are constants. In conclusion, for the case when the roots of the characteristic equation are complex conjugate numbers, 1 1 , 2 a a 2 4b i 2 then, the general solution is in the form, yx
C1 e x cos x C 2 e x sin x
We will learn how to derive solutions of the differential equations when the two roots of their characteristic equations are complex conjugate numbers by using following examples. Example Derive the general solution of the second-order differential equation, d2y dy 2 5y 0 2 dx dx
Chapter 5 Second-Order Linear Differential Equations
144
By assuming the solution in the form of e x and substitute it into the differential equation, we get, 2 e x 2 e x 5 e x 0
After dividing it through by e x , we obtain the characteristic equation, 2 2 5 0
The two roots of this equation are complex conjugate numbers,
1 , 2
1 2 4 20 1 2i 2
By comparing the coefficients with those in the equation derived earlier, we find that,
1
and
2
Thus, the general solution of the differential equation is,
y C19 e x cos 2 x C20 e x sin 2 x where C19 and C20 are constants. The same solution can be obtained by using the DSolve command, DSolve y '' x y x
x
2 y' x
C 19 Cos 2 x
5y x x
0, y x , x
C 20 Sin 2 x
Example Derive the general solution of the second-order differential equation, d2y dy 2 2y 0 dx 2 dx The characteristic equation corresponding to the above differential equation is, 2 2 2 0 which leads to the two roots of complex conjugates,
5.5 Solutions from Complex Roots
1 , 2
Here,
145
1 2 48 2 1 and
1 i
1
Thus, the general solution is,
y
C 21 e x cos x C 22 e x sin x
where C 21 and C 22 are constants. Again, the same general solution can be obtained by using the DSolve command, DSolve y '' x y x
x
2 y' x
C 21 Cos x
2y x x
0, y x , x
C 22 Sin x
The two constants of C 21 and C 22 are determined from the initial conditions of the problem. For example, the given initial conditions are, dy and 0 2 y 0 1 dx y C 21 e x cos x C 22 e x sin x Since, then, dy C 21 e x cos x e x sin x C 22 e x sin x e x cos x dx
From the given initial conditions, the two equations become,
1 C 21 1 C 22 0 and
2 C 21 1 0 C 22 0 1
By solving these two equations, the two constants can be determined, and C 21 1 C 22 3 Hence, the exact solution of the differential equation with the initial conditions is,
y e x cos x 3 e x sin x
Chapter 5 Second-Order Linear Differential Equations
146
The DSolve command can also be used to find the exact solution of this initial value problem by entering, DSolve
y '' x 2 y' x y 0 1, y ' 0 x
y x
Cos x
3
2y x 0, 2 , y x ,x x
Expand DSolve
Sin x
Example Solve the initial value problem governed by the secondorder differential equation, 16
d2y dy 8 145 y 0 2 dx dx
with the initial conditions of y 0 2 and y 0 1 . The characteristic equation that corresponds to the differential equation is, 16 2 8 145
0
The two roots are complex conjugate numbers,
1 , 2
8 64 9280 32
1 3i 4
By comparing the coefficients of the roots with the equation derived earlier, we find that,
1 4
and
3
Thus, the general solution to the differential equation is,
y
C23 e x 4 cos 3 x C24 e x 4 sin 3 x
where C23 and C 24 are constants that can be determined from the given initial conditions of the problem. For example, if the initial conditions are given as y 0 2 and y 0 1 , the exact solution can be determined as follows. First, we need to find the derivative of the solution y,
5.5 Solutions from Complex Roots
147
1 y C23 e x 4 cos 3 x 3 e x 4 sin 3 x 4 1 C24 e x 4 sin 3 x 3 e x 4 cos 3 x 4
We apply the two initial conditions to equations of y and y , respectively,
2 C23 1 C24 0 1 C23 0 C24 0 3
1 4 Then, we solve for the two constants of C23 and C 24 to get,
and
C23
2
and
C24
1 2
Thus, the exact solution to the differential equation with the given initial conditions is,
y 2e x 4 cos 3 x
1 x4 e sin 3 x 2
The same exact solution can be obtained by using the DSolve command by entering,
DSolve
y x
16 y '' x 8 y' x 145 y x 0, y 0 2, y ' 0 1 , y x ,x Expand
2 x 4 Cos 3 x
1 2
x 4
Sin 3 x
The Plot command can then be used to plot the variation of y that varies with x as shown in the figure. Example Solve the initial value problem governed by the secondorder differential equation, 64
d2y dy 16 1025 y 0 dx 2 dx
with the initial conditions of y 0 1 and y 0 3 .
Chapter 5 Second-Order Linear Differential Equations
148
10
5
y ( x)
2
4
6
8
x
5
10
From the given differential equation, the corresponding characteristic equation is, 64 2 16 1025
0
The two roots are in the form of complex conjugates as,
1, 2
16 256 262 ,400 128
1 4i 8
By comparing the coefficients with those in the equation derived earlier, we find that,
1 8
and
4
Then, the general solution to the differential equation is,
y
C25 e x 8 cos 4 x C26 e x 8 sin 4 x
where C25 and C26 are the constants that can be determined from the initial conditions. The process starts from finding the derivative of the solution y, 1 y C25 e x 8 cos 4 x 4 e x 8 sin 4 x 8 1 C 26 e x 8 sin 4 x 4 e x 8 cos 4 x 8
and by applying the initial conditions of y 0 1 and y 0 3 into these two equations to get,
5.5 Solutions from Complex Roots
149
1 C25 1 C26 0 1 3 C25 0 C26 0 4 8
Then, we solve these two equations to obtain,
C25
1
and
C26
23 32
Thus, the exact solution of this initial value problem is,
y e x 8 cos 4 x
23 x 8 e sin 4 x 32
The same solution is obtained by using the DSolve command, DSolve
64 y '' x 16 y ' x 1025 y x y 0 1, y ' 0 3 , y x ,x x 8
y x
23 32
Cos 4 x
x 8
0, Expand
Sin 4 x
The Plot command can then be used to plot the variation of y that varies with x as shown in the figure. Plot y x
. ,
x, 0, 20
Plot
1.0
0.5
y ( x) 0.5
1.0
5
10
15
20
x
Chapter 5 Second-Order Linear Differential Equations
150
5.6 Nonhomogeneous Equations In this section and the next two sections, we will concentrate on finding the solutions of the second-order linear nonhomogeneous differential equations in the form, d2y dy a by 2 dx dx
f x
where the term on the right-hand-side of the equation is only function of x. The coefficients a and b for the terms on the lefthand-side of the equation are constants. Since the differential equation is linear, then the general solution consists of two parts, y
yh y p
where yh is the solution of the homogeneous differential equation we learned earlier. The function y p is called the particular solution that normally depends on the form of the function f x on the right-hand-side of the differential equation.
As an example, a general solution of the nonhomogeneous differential equation,
is
y
d2y y dx 2 yh y p
3 sin 2 x
A sin x B cos x 2 sin x1 cos x
The first part of the solution,
yh
A sin x B cos x
where A and B are constants, is the solution of the homogeneous differential equation, d2y y dx 2 The second part of the solution, yp
0
2 sin x1 cos x
5.6 Nonhomogeneous Equations
151
is the particular solution that depends on the form of the given function f x 3 sin 2 x on the right-hand-side of the differential equation. We can verify that the solution above is, in fact, the general solution of the nonhomogeneous differential equation. This can be done by using the derivative D command to evaluate the terms on the left-hand-side of the differential equation as follows, y A Sin x B Cos x LHS D y, x, 2 y
2 Sin x 1 Cos x TrigReduce
;
TrigReduce
3 Sin 2 x
The result is equal to the right-hand-side function of the differential equation. The same idea is applied when the given nonhomogeneous is more complex. For example, d2y dy 3 2 y 6 ex dx 2 dx Again, the general solution consists of two parts, y
yh y p
Ae x Be 2 x e x
The first part is the homogeneous solution,
yh
Ae x Be2 x
of the homogeneous differential equation, d2y dy 3 2y 0 dx 2 dx where A and B are constants. While the second part, yp ex is the particular solution. Again, we can use the derivative D command to verify the general solution above by evaluating the terms on the left-hand-side of the differential equation as follows,
152
Chapter 5 Second-Order Linear Differential Equations
y A x B 2x LHS D y, x, 2
x;
3 D y, x
2y
Simplify
6 x
D
The result is identical to the function f x on the right-hand-side of the differential equation. There are several methods for finding the particular solution of y p . The two popular methods, which are the method of undetermined coefficients and the variation of parameters, are presented in the next two sections.
5.7 Method of Undetermined Coefficients The method of undetermined coefficients is a simple method for finding the particular solution of the nonhomogeneous differential equation. The idea is to seek for the particular solution y p that contains terms which are in similar forms with the function f x on the right-hand-side of the equation. The method works well when the function f x is in the forms of the exponential,
polynomials, sine and cosine functions. The method of undetermined coefficients is demonstrated by using the following examples. Example Derive the general solution of the second-order nonhomogeneous differential equation, d2y dy 3 4 y 3e 2 x 2 dx dx The homogeneous solution is derived from the given differential equation in the homogeneous form of, d 2 yh dy 3 h 4 yh 0 2 dx dx to give,
yh
C 27 e 4 x C28e x
5.7 Method of Undetermined Coefficients
153
where C27 and C28 are constants. Or, it can be obtained by using the DSolve command, DSolve y '' x 4x
y x
3 y' x x
C 27
4y x
0, y x , x
C 28
DSolve
The particular solution y p is to be determined such that the differential equation in the form, d 2 yp dy 3 p 4 y p 3e 2 x 2 dx dx
is satisfied. In this case, let us assume, yp
Ae 2 x
where A is an constant. We assume the particular solution in the exponential form because their derivatives are also in the exponential form as, dy p dx
2 Ae2 x
and
d 2 yp dx 2
4 Ae 2 x
By substituting these derivatives into the differential equation above, we get,
(4 A 6 A 4 A) e 2 x 3e 2 x 6 Ae2 x 3e 2 x 1 A 2 Then, the particular solution is, 1 y p e2 x 2 Thus, the general solution of the nonhomogeneous differential equation is, y
C 27 e 4 x C 28 e x
where C27 and C28 are constants.
1 2x e 2
154
Chapter 5 Second-Order Linear Differential Equations
The same solution can be found by using the DSolve command, DSolve y '' x
3 y' x
2x
y x
4x
2
3 2 x, y x , x
4y x
C 27
x
C 28
DSolve
Example Derive the general solution of the second-order nonhomogeneous differential equation, d2y dy 3 4y 2 dx dx
4x 2
Since the terms on the left-hand-side of the differential equation are the same as those in the preceding example, thus, the homogeneous solution is,
yh
C 27 e 4 x C28e x
The particular solution y p is to be determined such that the differential equation, d 2 yp dy p 3 4 y p 4x 2 dx 2 dx
is satisfied. We may assume the particular solution in the form of polynomials, y p Ax 2 Bx C where A , B and C are constants. By substituting this particular solution y p into the differential equation, we get,
2 A 32 Ax B 4 Ax 2 Bx C 4x 2 Or,
4 A x 2 6 A 4 B x 2 A 3 B 4C 4x 2
Comparing the coefficients leads to the three equations, 4A 4 6 A 4B 0 2 A 3B 4C 0
5.7 Method of Undetermined Coefficients
155
Solving these three equations gives, A 1 , B 3 2 and C
13 8 . Then, the particular solution is, 3 13 x 2 8 Hence, the general solution of the given nonhomogeneous differential equation is, 3 13 y C 27 e 4 x C28e x x 2 x 2 8 The same solution can be obtained by using the DSolve command, yp
DSolve y '' x y x ,x
y x
x2
3 y' x
4y x
4 x2 , DSolve
Expand
13 8
3x 2
x2
4x
C 27
x
C 28
Example Derive the general solution of the second-order nonhomogeneous differential equation, d2y dy 3 4 y 2 sin x dx 2 dx Since the terms on the left-hand-side of the given differential equation are the same as those in the preceding example, then the homogeneous solution is, yh C 27 e 4 x C28e x The particular y p must satisfy the differential equation, d 2 yp dy 3 p 4 y p 2 sin x 2 dx dx Because the derivatives of the sine function are in the form of sine and cosine functions, thus we need to assume the particular solution in the form, y p A sin x B cos x
where A and B are constants. If we substitute this particular solution y p into the differential equation, we get,
Chapter 5 Second-Order Linear Differential Equations
156
A sin x B cos x 3 A cos x B sin x 4 A sin x B cos x 2 sin x Or,
A 3 B 4 A sin x B 3 A 4 B cos x 2 sin x
Then, comparing the coefficients leads to two equations, A 3B 4 A 2
B 3 A 4B 0
and
which can be solved to give A 5 17 and B 3 17 . Thus, the particular solution is, 5 3 y p sin x cos x 17 17 Hence, the general solution of the nonhomogeneous differential equation is, 5 3 y C 27 e 4 x C28e x sin x cos x 17 17 The same solution is obtained by using the DSolve command, DSolve y '' x 3 y' x y x ,x Expand y x
4x
C 27
x
C 28
4y x
2 Sin x , Expand
3 Cos x 17
5 Sin x 17
Example Solve the initial value problem governed by the secondorder nonhomogeneous differential equation, d2y dy 3 4 y 3e 2 x 4 x 2 2 sin x 2 dx dx with the initial conditions of y 0 0 and y 0 1 . The right-hand-side of the differential equation is the combination of the functions in the preceding three examples. Thus general solution is, y C 27 e 4 x C28e x
1 2x 3 13 5 3 e x 2 x sin x cos x 2 2 8 17 17
5.7 Method of Undetermined Coefficients
157
We can use the DSolve command to verify that the above solution is a general solution to the given differential equation, DSolve y '' x y x ,x
3 y' x
4y x
3 2x
4 x2
2 Sin x ,
Expand
13 8 3 Cos x 17
y x
2x
3x 2 2 5 Sin x 17
x2
4x
x
C 27
C 28
Since the derivative of the general solution is, 3 5 3 y 4C 27 e 4 x C28e x e 2 x 2 x cos x sin x 2 17 17 Then, by applying the initial conditions of y 0 0 and y 0 1 , we obtain, 1 13 3 0 C 27 C28 0 0 2 8 17 3 5 1 4C 27 C28 1 0 and 0 2 17 These two equations give C27 373 680 and C28 7 5 Hence, the exact solution of the initial value problem is, y
373 4 x 7 x 1 2 x 3 13 5 3 e e e x 2 x sin x cos x 680 5 2 2 8 17 17
The same solution is obtained by using the DSolve command, DSolve y 0
y '' x
0, y ' 0
13 8 3 Cos x 17
y x
3 y' x
4y x
1 , y x ,x
7
x
2x
5 2 5 Sin x 17
3 2x
4 x2
2 Sin x ,
Expand
373 4 x 680
DSolve
3x 2
x2
Chapter 5 Second-Order Linear Differential Equations
158
The Plot command can then be used to plot the variation of y that varies with x as shown in the figure. 25 20 15
y ( x) 10 5
0.2
0.4
0.6
0.8
1.0
x
5.8 Variation of Parameters The method of undetermined coefficients for solving the nonhomogeneous differential equation described in the preceding section works well when the right-hand-side functions f x are in the form of exponential, polynomials, sine and cosine functions. When the functions f x are in the other forms, it may be difficult to guess for the solutions. In this section, we will learn another method so called the variation of parameters to find the particular solutions. The advantage of this latter method is that we do not have to guess the solutions in some specific forms as we did in the method of undetermined coefficients. However, since the method involves integration, it may be difficult if the functions f x are complicated. We will learn this method by considering the same form of the second-order nonhomogeneous differential equation used earlier, d2y dy a by f x 2 dx dx Its general solution consists of two parts,
5.8 Variation of Parameters
159
yx
yh x y p x
where yh x is the solution of the homogeneous differential equation, d 2 yh dy a h by h 0 2 dx dx which can be written in the form,
yh x
Ay1 x By 2 x
where A and B are constants. The idea of the method of variation of parameters is to assume the particular solution y p x in the same form as the homogeneous solution yh x , i.e., y p x v1 x y1 x v2 x y 2 x
where v1 x and v2 x are the functions to be determined so that y p x satisfies the above nonhomogeneous differential equation. By taking the first-order derivative of the particular solution y p above, the result contains four terms, yp
v1 y1 v2 y2 v1 y1 v2 y2
This means if we determine its second-order derivative, the result will contain many more terms. Furthermore, the second-order derivative also includes the terms such as v1 and v 2 . To avoid this, let us assume the value in the first bracket of yp to be zero, v1 y1 v2 y 2 0
So that the expression of yp reduces to, yp v1 y1 v2 y 2 Then, if we take derivative of this reduced form of yp , we get, yp v1 y1 v1 y1 v2 y 2 v2 y 2
By substituting the expressions of y p , yp and yp into the differential equation, we obtain,
Chapter 5 Second-Order Linear Differential Equations
160 f x
yp ayp by p
v1 y1 v1 y1 v2 y 2 v2 y a v1 y1 v2 y 2 bv1 y1 v2 y 2 v1 y1 v2 y 2 v1 y1 ay1 by1 v2 y 2 ay 2 by 2
i.e.,
v1 y1 v2 y 2 0 0 v1 y1 v 2 y 2
f
In conclusion, the process above leads to two equations of,
and
y1v1 y 2 v2
0
y1v1 y 2 v2
f
with the two unknown functions of v1 and v 2 . These two functions can be determined by using the Cramer’s rule to give,
and
v1
fy2 y1 y2 y1 y2
v 2
fy1 y1 y2 y1 y2
Then, the two functions of v1 and v 2 can be obtained by performing integration,
and
v1
fy2 dx y1 y2 y1 y2
fy1 dx y1 y2 y1 y2
v2
From the process explained above, we can see that the method of variation of parameters can provide the particular solution directly. Since the process involves integration to find the functions v1 and v 2 , difficulty may arise if the function f x on the right-hand-side of the differential equation is complicated. We will learn how to use the method of variation of parameters to solve the nonhomogeneous differential equations through the following examples.
5.8 Variation of Parameters
161
Example Use the method of variation of parameters to solve the second-order nonhomogeneous differential equation, d2y y tan x dx 2
We can employ the technique presented in the preceding sections to derive the homogeneous solution of the homogeneous differential equation, d 2 yh yh 0 dx 2
yh C29 cos x C30 sin x
to get,
where C29 and C30 are constants. This homogeneous solution can also be obtained conveniently by using the DSolve command, DSolve y '' x y x
y x
C 29 Cos x
0, y x , x
DSolve
C 30 Sin x
It is noted that the homogeneous solution obtained above is in the form,
yh C29 y1 C30 y2 i.e.,
y1
cos x
and
y2
sin x
Since the particular solution for the method of variation of parameters is assumed in the form, y p v1 y1 v2 y 2 y p v1 cos x v 2 sin x
Thus,
where the functions v1 and v 2 are determined from, v1
f y2 dx y1 y2 y1 y2
and
v2
f y1 dx y1 y2 y1 y2
Therefore, by substituting the function f x and performing integration, we obtain the two functions v1 and v 2 as follows,
Chapter 5 Second-Order Linear Differential Equations
162
v1
tan x sin x dx cos x cos x sin x sin x
tan x sin x dx sin 2 x cos 2 x
v1
and
tan x sin x dx
x x x x ln cos sin ln cos sin sin x 2 2 2 2 tan x cos x v2 dx cos x cos x sin x sin x
v2
sin x dx
cos x
Thus, the particular solution is, x x y p ln cos sin 2 2 x x ln cos sin sin x cos x sin x cos x 2 2 x x x x ln cos sin ln cos sin cos x 2 2 2 2 Hence, the general solution of the given nonhomogeneous differential equation is, x x y yh y p C29 cos x C30 sin x ln cos sin 2 2 x x ln cos sin cos x 2 2 The same solution can be obtained by using the DSolve command, DSolve y '' x y x
y x
C 29 Cos x
x 2 x Cos x Log Cos 2 Cos x Log Cos
Tan x , y x , x C 30 Sin x x 2 x Sin 2 Sin
Expand
5.8 Variation of Parameters
163
Example Use the method of variation of parameters to solve the second-order nonhomogeneous differential equation, d 2 y dy 2 y 4x 2 dx 2 dx The homogeneous solution can be derived from the homogeneous differential equation, d 2 yh dy h 2 yh 0 dx 2 dx yh C31e2 x C32e x to get, where C31 and C32 are constants. Such homogeneous solution can also be found by using the DSolve command, DSolve y '' x
y x
2x
y' x
C 31
2y x x
0, y x , x DSolve
C 32
This homogeneous solution is in the form of,
yh C31 y1 C32 y2 i.e.,
y1
e2 x
and
y2
e x
In the method of variation of parameters, the particular solution is assumed in the same form as the homogeneous solution, y p v1 y 1 v2 y 2 y p v1e 2 x v2 e x
Thus,
Then, the functions v1 and v 2 can be determined as follows, f y2 dx y1 y2 y1 y2 4 x 2 e x 2x dx e e x 2e 2 x e x 4 x 2 e 2 x dx 3 e 2 x 2 x 2 2 x 1 3
v1
v1
Chapter 5 Second-Order Linear Differential Equations
164
and
f y1 dx y1 y2 y1 y2 4 x 2 e 2 x 2x dx e e x 2e 2 x e x 4 x 2 e x dx 3 4e x 2 x 2 x 2 3
v2
v2
Hence, the general solution of the given nonhomogeneous differential equation is,
y yh y p C31e 2 x C32 e x
e 2 x 4e x 2 2 x 2 2 x 1e 2 x x 2 x 2 e x 3 3
y C31e2 x C32e x 2 x 2 2 x 3 The same solution can be obtained by using the DSolve command, DSolve y '' x y x
3
2x
y' x 2 x2
2y x 2x
4 x2 , y x , x
C 31
x
C 32
Example Use the method of variation of parameters to solve the initial value problem governed by the second-order nonhomogeneous differential equation, d2y dy 4 4y dx 2 dx
x 1 e 2 x
with the initial conditions of y 0 0 and y 0 0 . Plot the solution of y that varies with x in the interval of 0 x 1 . The homogeneous solution of the homogeneous differential equation, d 2 yh dy 4 h 4 yh 0 2 dx dx yh C33e2 x C34 xe2 x is,
5.8 Variation of Parameters
165
where C33 and C34 are constants. The homogeneous solution above is in the form of, yh C33 y1 C34 y2 Then,
y1
e2 x
and
y2
xe 2 x
In the method of variation of parameters, the particular solution is assumed in the same form as the homogeneous solution, yp
v1 y 1 v2 y 2
y p v1e 2 x v2 xe 2 x
Thus,
where the functions v1 and v 2 are determined by integrating the functions that are in the form of f x . Here, f y2 v1 dx y1 y2 y1 y2 x 1e 2 x xe 2 x 2x dx 2 e e x 2 xe 2 x 2e 2 x xe 2 x
and
v1
v2
x3 x 2 3 2 f y1 dx y1 y2 y1 y2 x 1e 2 x e 2 x dx e 2 x e 2 x 2 xe 2 x 2e 2 x xe 2 x
x2 x 2 Hence, the general solution of the given nonhomogeneous differential equation is, y yh yp v2
y C33e 2 x C34 xe 2 x 2 3
x2 2x x2 e 2 x xe 2 x x3 x 2 y e 2 x C33 xC34 Or, 6 2 x3 3x 2 and then, y e 2 x 2C33 C34 2 xC34 x 3 2 x3
Chapter 5 Second-Order Linear Differential Equations
166
where C33 and C34 are constants that can be determined from the initial conditions as follows, y 0
0 1C33 0 0 0
y 0
0 12C33 C34 0 0 0 0
which give C33 0 and C34 0 . Hence, the solution of this initial value problem is,
y e 2 x
x3 x 2 2 6
x 2 e2 x x 3 6
The same solution is obtained by using the DSolve command by entering, DSolve
y '' x
4 y' x
y 0
0, y ' 0
y x
1 6
2x
4y x
x
1
0 , y x ,x
x2 3
2 x,
DSolve
x
The Plot command is then used to plot the variation of y that varies with x within the interval of 0 x 1 as shown in the figure. Plot y x
. ,
Plot
x, 0, 1
5
4
3
y ( x) 2
1
0.2
0.4
0.6
x
0.8
1.0
5.9 Numerical Methods
167
5.9 Numerical Methods For most of the initial value problems, their exact solutions in closed-form expressions cannot be derived easily. This is because the function f x on the right-hand-side of the nonhomogeneous differential equation is often complicated. Furthermore, if the coefficients of the derivative terms on the lefthand side of the equation are function of y, the differential equation becomes nonlinear. Exact closed-form solutions for most nonlinear differential equations are not available. Thus, the numerical methods are needed to provide approximate solutions. In this section, we will use the NDSolve command to find approximate solutions of the second-order differential equations. The commands employ the Runge-Kutta method to provide accurate solutions. The following examples demonstrate how to use these command to solve general initial value problems. Example Employ the NDSolve command to solve the initial value problem that is governed by the second-order nonhomogeneous differential equation, 36
d2y dy 12 37 y 0 2 dx dx
0 x 10
with the initial conditions of y 0 0 and y 0 1 . It is noted that this initial value problem has the exact solution of, y
e x 6 sin x
which can be obtained by using the DSolve command, DSolve y 0
y x
36 y '' x 0, y ' 0 x 6
12 y ' x 37 y x 1 , y x ,x
0, DSolve
Sin x
If the exact solution is not available, we can use the numerical method to solve for the approximate solution. In the preceding chapter, we learned how to use the NDSolve command
Chapter 5 Second-Order Linear Differential Equations
168
in Mathematica to solve the first-order differential equation. We can follow the same procedure to obtain the approximate solution of the second-order differential equation. A set of commands to solve for the approximate solution and to plot for comparing with the exact solution is shown below. The approximate solution obtained from using such NDSolve command compares very well with the exact solution as shown in the figure. x 6 Sin x ; y x : exactsol Table x, y x , x, 0, 10, .5 ; plot1 ListPlot exactsol, PointSize .02 , Black ; Clear y ; PlotStyle 12 y ' x 37 y x 0, numsol NDSolve 36 y '' x y 0 0, y ' 0 1 , y x , x, 0, 10 ; . numsol, x, 0, 10 , PlotStyle Black ; plot2 Plot y x Show plot1, plot2 4 3 2
Exact
1
y ( x)
2
4
6
8
10
x
1 2
Approx.
3
Example Employ the NDSolve command to solve the initial value problem governed by the second-order nonhomogeneous differential equation, d2y dy 0 x 12 4 3 y 20 cos x 2 dx dx with the initial conditions of y 0 0 and y 0 0 . The NDSolve command uses the Runge-Kutta method to solve for approximate solution of the second-order differential equation. It is noted that the given initial value problem above has an exact solution that can be found by the DSolve command.
5.9 Numerical Methods
DSolve y 0
169
y '' x 4 y' x 3y x 0, y ' 0 0 , y x ,x 3x
y x
3
5 2x
2 Cos x
20 Cos x , Simplify
4 Sin x
A set of commands to determine the approximate solution and to plot for comparing with the exact solution is shown below. The plot indicates that the NDSolve command can provide high solution accuracy as compared to the exact solution. The method will be useful when the exact solution to the differential equation is not available as demonstrated in the following example. y x
:
3x
3
5 2x
2 Cos x
4 Sin x ;
exactsol Table x, y x , x, 0, 12, .5 ; Table plot1 ListPlot exactsol, PlotStyle PointSize .02 , Black ; Clear y ; 4 y' x 3y x 20 Cos x , numsol NDSolve y '' x 0, y ' 0 0 , y x , x, 0, 12 ; y 0 plot2 Plot y x . numsol, x, 0, 12 , PlotStyle Black ; Show plot1, plot2
4
2
y ( x)
Exact 2
4
6
8
10
12
x
2
Approx. 4
Example Employ the NDSolve command to find the approximate solution of the initial value problem governed by the second-order nonlinear differential equation, d2y dy y y 0 2 dx dx
with the initial conditions of y 0 1 and y 0 0 .
0 x 20
Chapter 5 Second-Order Linear Differential Equations
170
For this problem, the exact solution could not be found by using the DSolve command, DSolve y 0
y '' x y x y' x y x 1, y ' 0 0 , y x ,x
0, DSolve
We will use the NDSolve command to determine the approximate solution. The commands for finding and plotting the approximate solution are, numsol NDSolve y '' x y x y' x y x 0, 1, y ' 0 0 , y x , x, 0, 20 ; y 0 . numsol, x, 0, 20 , PlotStyle Black Plot y x
The figure shows the approximate solution of this initial value problem that is governed by the second-order nonlinear differential equation and two initial conditions. 1.0
0.5
y ( x)
5
10
15
20
x
0.5
1.0
Approx.
5.10 Concluding Remarks In this chapter, several methods for solving the secondorder linear differential equations with constant coefficients were presented. For homogeneous differential equations, the exact
5.10 Concluding Remarks
171
solutions depend on the characteristic equations. The roots of the characteristic equations could be distinct real numbers, repeated real numbers or conjugate complex numbers. For nonhomogeneous differential equations, two methods were explained. These are the methods of undetermined coefficients and variation of parameters. The method of undetermined coefficients assumes the particular solution in the same form as the nonhomogeneous function. The method works well only when the nonhomogeneous functions are in the forms of exponential, polynomials, sine and cosine functions. Thus, for more general nonhomogeneous functions, the method of variation of parameters should be used. This later method provides the particular solutions directly. However, since the method involves integration of the nonhomogeneous function, difficulty may arise if such function is complicated. Several examples have been employed to show detailed derivation of the exact solutions by using the above methods. In all examples, the derived exact solutions to the differential equations were verified by using the Mathematica DSolve command. Variations of the solutions were plotted to help understanding of their physical meanings. A numerical method for solving these second-order linear differential equations was also introduced. Accurate approximate solutions were obtained by using Mathematica NDSolve command. The main advantage of such command is that they can provide approximate solutions when the exact closed-form solutions are not available. Thus, for a given differential equation, finding exact closed-form solution should be tried first. If the exact solution is not available, the numerical method is an effective tool to provide approximate solution. Examples have shown that the Mathematica command can provide approximate solutions with high accuracy and efficiency.
Chapter 5 Second-Order Linear Differential Equations
172
Exercises 1. In each problem below, show that, (a) y e 2 x 3e 4 x y 6 y 8 y 0 (b) y
2e 5 x 4 e 3 x
is the solution of is the solution of
y 8 y 15 y 0 (c) y e x 6 7e x is the solution of 6 y 5 y y 0 (d) y 2e x 3 5e 4 x is the solution of 3 y 11y 4 y 0 (e) y e 9 x 8 e 7 x 3 is the solution of 24 y 29 y 63 y 0 2. Find the determinant (Wronskian) of each solution in Problem 1. Then, verify these determinants by using the Det command. 3.
Employ the derivative D command to show that,
y
3e 2 x 7 xe 2 x
is the exact solution of the second-order homogeneous differential equation, y 4 y 4 y 0 Then, determine its determinant by using the Det command. 4.
Employ the derivative D command to show that,
y
e x cos 2 x e x sin 2 x
is the exact solution of the second-order homogeneous differential equation, y 2 y 5 y 0 Then, determine its determinant by using the Det command.
Exercises
5.
173
Find the second-order homogeneous differential equations that correspond to the following solutions, (a) e x 2e 2 x (b) 3e x e 3 x (c) 3 5e 4 x
(d) 7 e x 8e 4 x
(e) e 3 x 2e 5 x
(f) 2e 2 x 3e 3 x
6. Solve the following second-order homogeneous differential equations when their roots are distinct real numbers, 0 (a) y y 12 y (b) y 2 y 35 y
0
(c) 6 y 5 y 4 y
0
(d) 15 y 23 y 22 y
0
(e) 20 y 73 y 63 y
0
Show the derivation of their solutions in detail. Then, use the DSolve command to verify the derived solutions. 7.
Solve the following initial value problems that are governed by the second-order homogeneous differential equations and initial conditions. The characteristic equations of these differential equations contain the roots that are distinct real numbers. (a) y y 6 y 0 y 0 0 , y 0 1 (b) 2 y 3 y 5 y 0 y 0 1 , y 0 0 (c) 9 y 3 y 20 y 0 y 0 0 , y 0 2 (d) 7 y 24 y 31y 0 y 0 , y 0 2 Show the derivation of their solutions in detail. Then, use the DSolve command to verify the derived solutions and the Plot command to plot y that varies with x.
174
8.
Chapter 5 Second-Order Linear Differential Equations
Solve the following second-order homogeneous differential equations when their roots are repeated real numbers, (a) y 10 y 25 y 0 0 (b) 4 y 4 y y (c) 9 y 12 y 4 y 0 (d) 4 y 28 y 49 y 0 (e) 25 y 30 y 9 y 0 Show the derivation of their solutions in detail. Then, use the DSolve command to verify the derived solutions.
9.
Solve the following initial value problems that are governed by the second-order homogeneous differential equations and initial conditions. The characteristic equations of these differential equations contain the roots that are repeated real numbers. (a) y 6 y 9 y 0 y 0 0 , y 0 2 (b) 4 y 28 y 49 y 0 y 0 1 , y 0 0 (c) 16 y 8 y y 0 y 0 0 , y 0 1 (d) 49 y 28 y 4 y 0 y 0 1 , y 0 0 Show the derivation of their solutions in detail. Then, use the DSolve command to verify the derived solutions.
10. Solve the following second-order homogeneous differential equations when their roots are conjugate complex numbers, (a) y 2 y 6 y 0 (b) y 6 y 13 y 0 (c) y 4 y 5 y 0 (d) y 3 y 18 y 0 (e) y 6 y 10 y 0
Exercises
175
Show the derivation of their solutions in detail. Then, use the DSolve command to verify the derived solutions. 11. Solve the following initial value problems that are governed by the second-order homogeneous differential equations and initial conditions. The characteristic equations of these differential equations contain the roots that are conjugate complex numbers. (a) y 4 y 5 y 0 y 0 1 , y 0 0 (b) y 6 y 45 y 0 y 0 0 , y 0 2 (c) y 6 y 13 y 0 y 2 0 , y 2 2 (d) y y y 0 y 0 1 , y 0 4 Show the derivation of their solutions in detail. Then, use the DSolve command to verify the derived solutions and the Plot command to plot y that varies with x. 12. Employ the DSolve command to solve the second-order homogeneous differential equations with constant coefficients as follows, (a) y 4 y 4 y
0
(b) y 9 y 20 y
0
(c) 4 y 12 y 9 y 0 (d) y y
0
(e) y 6 y 25 y
0
In each problem, verify the obtained solution with that derived by hands. Or substitute it into the differential equation to check whether the differential equation is satisfied.
176
Chapter 5 Second-Order Linear Differential Equations
13. Employ the DSolve command to solve the initial value problems governed by the second-order differential equations and initial conditions below, (a) y 6 y 9 y 0 y 0 0 , y 0 3 (b) y 5 y 6 y 0 y 1 1 , y 1 2 (c) y 4 y 5 y 0 y 0 1 , y 0 0 (d) y 8 y 9 y 0 y 1 2 , y 1 0 In each case, verify that the solution satisfies the differential equation and initial conditions. 14. Use the method of undetermined coefficients to solve the second-order nonhomogeneous differential equations, (a) y y 2 y 2 x 2 (b) y 5 y 6 y e x cos x (c) y 6 y 9 y sin3x (d) y 4 y 4 y 3e x (e) 4 y 8 y 3 y x 2 sin x Show the derivation in detail. Compare the derived solutions with those obtained by using the DSolve command. 15. Use the method of undetermined coefficients to solve the initial value problems that are governed by the second-order nonhomogeneous differential equations and initial conditions, (a) 9 y 3 y 20 y sin x cos x y0 1 , y0 0 (b) 16 y 8 y y x 2 2 x y0 0 , y0 1
Exercises
177
(c) y 4 y cos2 x y0 0 , y0 0 (d) y 6 y 13 y e x y0 1 , y0 0 Show detailed derivation of the exact solutions. Then, verify these solutions with those obtained from using the DSolve command. In each case, employ the Plot command to plot the variation of y that varies with x. 16. Solve the following second-order nonhomogeneous differential equations by the method of variation of parameters. Show the derivation of their solutions in detail. Then, verify the solutions with those obtained by using the DSolve command. (a) y 4 y
cot x
(b) y y
cosh x
(c) y 2 y y
e x ln x
(d) y 3 y 2 y sin e x (e) 4 y 4 y y e x 2 1 x 2 17. Solve the following initial value problems by using the method of variation of parameters, (a) y y xe x 2 y0 1 , y0 0 (b) y 2 y 8 y 2e2 x e x y0 1 , y0 0 (c) y 4 y 4 y 6 x 2 3x e2 x y0 1 , y0 0 (d) y 4 y 5 y sin x 3 x y0 1 , y0 0
178
Chapter 5 Second-Order Linear Differential Equations
Show detailed derivation of the exact solutions. Compare these exact solutions with those obtained by using the DSolve command. Then, employ the Plot command to plot their variations for 0 x 1 . 18. Use the NDSolve command to find the approximate solution of the initial value problem governed by the second-order homogeneous differential equation, y 5 y 6 y
0
0 x2
with the initial conditions of y0 2 and y0 5 . Repeat solving the problem but by using the DSolve command to find the exact solution. Plot to compare the two solutions for 0 x 2. 19. Use the NDSolve command to find the approximate solution of the initial value problem governed by the second-order nonhomogeneous differential equation, y 3 y 2 y e3 x
0 x2
with the initial conditions of y0 1 and y0 1 . Then, use the DSolve command to find the exact solution. Plot to compare the two solutions for 0 x 2 . 20. Use the NDSolve command to find the approximate solution of the initial value problem governed by the second-order nonhomogeneous differential equation, y 2 y 5 y 4e x cos2 x
0 x5
with the initial conditions of y0 1 and y0 0 . Repeat solving the problem but by using the DSolve command to find the exact solution. Plot to compare the two solutions for 0 x 5.
Exercises
179
21. Use the NDSolve command to find the approximate solution of the initial value problem governed by the second-order nonhomogeneous differential equation, 4 y y
x 2 5 cos x e x 2
0 x5
with the initial conditions of y0 2 and y0 1 . Repeat solving the problem but by using the DSolve command to find the exact solution. Plot to compare the two solutions for 0 x 5. 22. Use the NDSolve command to solve for the approximate solution of the Bessel equation,
x 2 y xy x 2 y
0
1 x 6
with the initial conditions of y1 0 and y1 1 . Plot this approximate solution for the interval of 1 x 6 . Then, check whether the DSolve command can provide exact solution. If it can, plot to compare the two solutions. 23. Employ the NDSolve command to find the approximate solution of the second-order nonlinear equation,
y y 4 0
0 x2
with the initial conditions of y0 1 and y0 3 . Plot this approximate solution for the interval of 0 x 2 . Then, check whether the DSolve command can provide exact solution. If the exact solution can be obtained, plot to compare the two solutions. 24. Employ the NDSolve command to solve the initial value problem that is governed by the second-order nonlinear differential equation,
y 1 y 2 y y 0
0 x 20
180
Chapter 5 Second-Order Linear Differential Equations
with the initial conditions of y0 1 and y0 1 . Plot the computed variation of y x in the interval of 0 x 20 . Then, use this NDSolve command to solve this problem again when the differential equation changes slightly to,
y 10001 y 2 y y
0
0 x 6000
Plot the solution of y x in the interval of 0 x 6000 . Provide comments on the accuracy of the approximate solution y x from its abrupt change within a small interval of x.
Chapter 6 Higher-Order Linear Differential Equations 6.1 Introduction Once we understand how to solve the second-order differential equations explained in the preceding chapter, we can follow the same procedure to solve the higher-order differential equations. The higher-order linear differential equations arise in many scientific and engineering problems, such as the deflection of a beam under loading and the laminar flow behavior over a flat plate. Exact solutions obtained from solving these differential equations help us to understand more about the problem behaviors. We will start by solving the higher-order homogeneous differential equations with constant coefficients. The roots of their characteristic equations could be distinct real, repeated real, complex conjugate, or mixed numbers. Exact solutions obtained
Chapter 6 Higher-Order Linear Differential Equations
182
from different types of these roots are in different forms. After that, we will extend the idea to solve the nonhomogeneous differential equations. In all cases, we will verify the derived solutions by using the Mathematica commands. For more complicated differential equations, their exact solutions may not be derived in closed-form expressions. In these cases, we will employ Mathematica commands that use numerical method to solve for approximate solutions. Plotting command will also be used to display variations of the computed solutions. The techniques presented in this chapter will help us to understand clearly on how to solve the higher-order differential equations.
6.2 Homogeneous Equations with Constant Coefficients General form of the nth-order homogeneous linear differential equation with constant coefficients is,
an
dny d n 1 y d2y dy a ........ a a1 a0 y 0 1 2 n dxn dxn 1 dx2 dx
where an , an 1 , ....., a2 , a1 and a 0 are the constant coefficients while the right-hand-side of the equation is zero. A solution of the above differential equation is in the form of e x where is a number. We can prove this by substituting it into the differential equation to get,
an n an 1 n 1 ........ a2 2 a1 a0 e x 0 After dividing through by e x , the characteristic equation is obtained, an n an 1 n 1 ........ a2 2 a1 a0
0
which can be solved for n values of the root . For example, the third-order homogeneous differential equation, d3y d2y dy 6 11 6 y 0 3 2 dx dx dx
6.2 Homogeneous Equations with Constant Coefficients
183
has the characteristic equation in the form,
3 6 2 11 6 0
1 2 3 0
or,
which leads to the three values of root as,
1 1 ,
2 2
and
3 3
It is noted that Mathematica contains the Roots command that can be used to factorize the algebraic equation above conveniently, Roots 1
3
6 2
11
2
6
0,
Roots
3
Thus, the exact solution of the third-order differential equation is, y x e x e 2 x e3 x We can verify this exact solution by taking their derivatives and substituting them into the left-hand-side of the differential equation, dy e x 2e2 x 3e3 x dx d2y e x 4e2 x 9e3 x dx2 d3y e x 8e 2 x 27e3 x dx3 to get,
d3y d2y dy 11 6 y 6 dx3 dx 2 dx
e x 8e2 x 27e3 x
6 e x 4e2 x 9e3 x 11 e x 2e2 x 3e3 x 6 e x e2 x e3 x 0 The result is zero which is equal to the right-hand-side of the equation. It is also noted that the derivative D command can be used to find the derivatives of the solution easily as follows,
Chapter 6 Higher-Order Linear Differential Equations
184
x 2x 3 x; y LHS D y, x, 3 6 D y, x, 2 11 D y, x 6y Simplify
D
0
The general solution y x contains the three functions of
y1 e x , y2 e 2 x and y3 e3 x which are linearly independent. This can be verified by finding the determinant (Wronskian) that must not be zero as follows,
W
y1
y2
y3
y1
y2
y3
y1 y2
y3
ex
e2 x
e3 x
ex
2e 2 x
3e3 x
ex
4e 2 x
9e3 x
2e 6 x
The determinant above can be determined conveniently by using the Det command, y1 W
x; y 2
2 x; y 3
3 x;
y1 , y2 , y3 , D y1 , x , D y2 , x , D y3 , x , D y1 , x, 2 , D y2 , x, 2 , D y3 , x, 2 ; Det W Det
2 6x
The roots from the characteristic equation may be distinct real, repeated real or conjugate complex roots which lead to different forms of the solutions. We will learn how to derive the solutions according to different types of the roots in the following sections.
6.3 Solutions from Distinct Real Roots
185
6.3 Solutions from Distinct Real Roots We will use the following examples to show the derivation of exact solutions for the higher-order differential equations when roots of their characteristic equations are distinct real numbers.
Example Find solution of the third-order homogeneous differential equation,
12
d3y d2y dy 5 6 y 0 3 2 dx dx dx
By assuming the solution in the form of e x and substituting it into the differential equation, we get,
12 3 e x 5 2 e x 6 e x e x 0 After dividing through by e x , the characteristic equation in the form of an algebraic equation is obtained,
12 3 5 2 6 1 0
13 14 1 0
Or,
i.e., 1 1, 2 1 3 and 3 1 4 . The Factor command can be used to factorize the above algebraic equation, Factor 12 3 1
1
5 2 3
1
6
1
Factor
4
Thus, the general solution of the given third-order differential equation is, y C1e x C2e x 3 C3e x 4 where C1 , C2 and C3 are constants. The same solution is obtained by using the DSolve command,
Chapter 6 Higher-Order Linear Differential Equations
186
DSolve 12 y ''' x 6 y' x y x
y x
x
x 3
C 1
DSolve
5 y '' x 0, y x , x x 4
C 2
C 3
Example Find solution of the fourth-order homogeneous differential equation,
d4y d2y 5 4y 0 dx 4 dx 2 Similar to the preceding example, we assume the solution in the form of e x and substitute it into the differential equation to obtain the characteristic equation,
4 5 2 4 0
1 1 2 2 0
Or,
i.e., 1 1, 2 1, 3 2 and 4 2 . solution is,
Thus,
the
general
y C4e x C5e x C6e 2 x C7 e 2 x where C4 , C5 , C6 and C7 are constants. obtained by using the DSolve command, DSolve y '''' x
y x
x
C 4
5 y '' x x
C 5
The same solution is
4y x 2x
0, y x , x
C 6
2x
C 7
Example Solve the initial value problem governed by the fourthorder differential equation,
d4y d3y d 2 y dy 7 6y 0 dx4 dx3 dx2 dx with the initial conditions of y0 1, y0 0, y0 0 and y0 0 .
6.3 Solutions from Distinct Real Roots
187
We first solve for a general solution of the given differential equation. Assuming the solution in the form of e x leads to the characteristic equation,
4 3 7 2 6 0 The Factor command can be used to factorize the algebraic equation above, Factor 2
4
3
1
7 2
6
1
3
1 2 1 3 0
i.e.,
So that 1 1, 2 2, 3 1 and 4 3 . solution is,
Thus, the general
y C8e x C9e 2 x C10e x C11e 3 x where C8 , C9 , C10 and C11 are constants that can be determined from the initial conditions as follows,
y0 1;
C8
y0 0;
C8 2C 9 C10 3C11
y0 0;
C8 4C9 C10
y0 0;
C8 8C 9
C9 C10
C11 1 0
9C11 0
C10 27C11 0
The results are C8 3 4 , C9 1 5 , C10 1 2 and C11 1 20 . Hence, the exact solution is,
y
3 x 1 2 x 1 x 1 3 x e e e e 4 5 2 20
The same exact solution can be obtained by using the DSolve command,
Chapter 6 Higher-Order Linear Differential Equations
188
DSolve y '''' x y ''' x 7 y '' x y' x 6y x 0, y 0 1, y ' 0 0, y '' 0 y ''' 0 0 , y x ,x Expand
1 20
y x
x
3x
2
3 x 4
0,
2x
5
The solution of y that varies with x can be plotted by using the Plot command as shown in the figure. 1
0.5
1.0
1.5
2.0
x
1 2
y ( x) 3 4 5
It is noted that Mathematica contains commands that can convert solution into other computer languages directly. The FortranForm and CForm commands are used to convert the solution into the Fortran and C languages, respectively. This is convenient when the solution is to be used further in other programs. For example, the solution above is converted to Fortran language by entering, FortranForm 1
20. E
3 x
1 20 1
x
3x
2. E
2 x
3 E
3 x 4 x
4.
2x
5 E
2 x
5.
FortranForm
6.4 Solutions from Repeated Real Roots
189
6.4 Solutions from Repeated Real Roots In the preceding chapter when the roots of the secondorder differential equations are repeated, we have learnt how to derive for their solutions. For example, if the roots are 1 3 and 2 3 , then the general solution is in the form of,
y e3 x xe3 x We will follow the same procedure to derive solutions of the higher-order differential equations when their roots are repeated. We will show detailed derivation by using the following examples. Example Find solution of the third-order homogeneous differential equation,
d3y d2y dy 3 3 y 0 3 2 dx dx dx We assume the solution in the form of e x , substitute it into the differential equation and divide through by e x to get the characteristic equation as,
3 3 2 3 1 0
1 1 1 0
or
i.e., 1 2 3 1 . Thus, the general solution is,
y
C12 e x C13 xe x C14 x 2e x
The same solution is obtained by using the DSolve command, DSolve
DSolve y ''' x 3 y '' x 3 y' x y x 0, y x , x
y x
x
C 12
x
x C 13
x
x2 C 14
Chapter 6 Higher-Order Linear Differential Equations
190
Example Find solution of the fourth-order homogeneous differential equation,
d4y d3y d2y dy 6 13 12 4 y 0 4 3 2 dx dx dx dx Similar to the preceding example, by assuming the solution in the form of e x , this leads to the characteristic equation,
4 6 3 13 2 12 4 0 The Factor command is used to factorize the algebraic equation above, Factor 1
2
4
6 3
2
2
13 2
12
4
Factor
12 22 0
which gives,
1 2 1
then,
and
3 4 2
Thus, the general solution of the fourth-order differential equation is, y C15e x C16 xe x C17 e 2 x C18 xe 2 x
where C15 , C16 , C17 and C18 are constants. The same solution is obtained by using the DSolve command, DSolve y '''' x 6 y ''' x 13 y '' x 12 y ' x 4y x 0, y x , x DSolve y x
x
C 15
x
x C 16
2x
C 17
2x
x C 18
Example Solve the initial value problem governed by the fourthorder differential equation,
d4y d2y 8 16 y 0 dx4 dx2
6.4 Solutions from Repeated Real Roots
191
with the initial conditions of y0 0, y0 1, y0 0 and y0 0 . Similar to the preceding example, we start by assuming the solution in the form of e x and substituting into the differential equation. This leads to the characteristic equation in the form of algebraic equation as,
4 8 2 16 0
22 22 0
or, Then, the roots are,
1 2 2
and
3 4 2
Thus, the general solution is, y C19e 2 x C20 xe2 x C21e 2 x C22 xe2 x
where C19 , C20 , C21 and C22 are constants that can be determined from the given initial conditions as follows,
y0 0;
C19
0 C21
0 0
y0 1;
2C19 C20 2C21
C22 1
y0 0;
C19 C20 C21
C22 0
y0 0;
2C19 3C20 2C21
3C22 0
The four equations above give the values of the four constants as C19 3 8 , C20 1 4 , C21 3 8 and C22 1 4 . Hence, the exact solution of this initial value problem is,
y
3 2 x 1 2 x 3 2 x 1 2 x e xe e xe 8 4 8 4
The same exact solution is obtained by using the DSolve,
Chapter 6 Higher-Order Linear Differential Equations
192
DSolve y '''' x 8 y '' x 16 y x y 0 0, y ' 0 1, y '' 0 0, y ''' 0 0 , y x ,x Expand
3 2x 8
y x
1 4
2x
x
3 8
2x
1 4
0,
2x
x
The solution of y that varies with x is plotted as shown in the figure. Plot y x
. ,
x, 0, 2
1
0.5
1.0
1.5
2.0
x 1
y ( x) 2
3
6.5 Solutions from Complex Roots Roots of the characteristic equations from the higher-order differential equations may be in the form of the conjugate complex numbers. In this case, derivation of the general solutions is more complicated as shown by the following examples. Example Find solution of the fourth-order differential equation, d4y d2y 5 4y 0 dx 4 dx 2
homogeneous
6.5 Solutions from Complex Roots
193
By assuming the solution in the form of e x , substituting it into the differential equation and dividing through by e x , we obtain the characteristic equation as,
4 5 2 4 0
2 1 2 4 0
which is,
Then, 1 i , 2 i , 3 2i and 4 2i , where i 1 . Thus, the general solution of the fourth-order differential equation is,
y A ei x B ei x C e2 i x D e2 i x where A , B , C and D are constants. From the Euler’s formula, e i x cos x i sin x ei x cos x i sin x
and
the general solution can be written in the form of sine and cosine functions as, y C23 cos x C24 sin x C25 cos2 x C26 sin 2 x
where C23 , C24 , C25 , C26 are functions of the constants A , B , C , D above. The same solution is obtained by using the DSolve command, DSolve y '''' x
y x
5 y '' x
4y x
0, y x , x
C 23 Cos x C 24 Sin x C 25 Cos 2 x C 26 Sin 2 x
Example Solve the initial value problem governed by the fourthorder differential equation,
d4y d2y 34 225 y 0 dx 4 dx 2 with the initial conditions of y0 1 , y0 0 , y0 0 and y0 0 .
Chapter 6 Higher-Order Linear Differential Equations
194
Similar to the preceding example, we assume the solution in the form e x and substitute it into the differential equation. This leads to the characteristic equation as,
4 34 2 225 0 The Factor command can be used to factorize the algebraic equation above, Factor 2
9
4
25
to get,
34 2
Factor
225
2
2 9 2 25 0
Then, 1 3i , 2 3i , 3 5i and 4 5i where i 1 . Thus, the general solution of the fourth-order differential equation is, y A e3 i x B e3 i x C e5 i x D e5 i x where A, B , C and D are constants. By applying the Euler’s formula, the general solution above can be written in the form of sine and cosine functions as, y C27 cos3x C28 sin3x C29 cos5 x C30 sin 5 x
where C27 , C28 , C29 and C30 are to be determined from the four initial conditions as follows,
y0 1;
C27
0
C29
0
1
y0 0;
0
3C28
0
5C30
0
0 25C29
0
0
0 125C30
0
y0 0; 9C27 y0 0;
0
27C28
These four equations give the values of the four constants as C27 25 16 , C28 0, C29 9 16 and C30 0 . Hence, the exact solution of this initial value problem is,
6.6 Solutions from Mixed Roots
y
195
9 25 cos3x cos5x 16 16
The same exact solution is obtained by using the DSolve command, DSolve y '''' x 34 y '' x 225 y x 1, y ' 0 0, y '' 0 0, y 0 y ''' 0 0 , y x ,x Expand
25 Cos 3 x 16
y x
0, DSolve
9 Cos 5 x 16
Such exact solution can be plotted easily by using the Plot command. The solution of y that varies with x is shown in the figure. 2
1
y ( x)
2
4
6
x
8
10
12
14
1
2
6.6 Solutions from Mixed Roots There are cases when the roots of the characteristic equation from the given differential equations are mixed between the real and complex numbers. The same procedure explained earlier can be applied to derive for solutions as shown in the following examples.
Chapter 6 Higher-Order Linear Differential Equations
196
Example Find solution of the fourth-order homogeneous differential equation,
d4y d3y d2y dy 2 2 2 y 4 3 2 dx dx dx dx
0
The characteristic equation corresponds to the differential equation is,
4 2 3 2 2 2 1 0
12 2 1 0
or,
i.e., 1 1, 2 1, 3 i and 4 i where i 1 . Since the roots consist of repeated real and conjugate complex numbers, then the general solution is in the form,
y A e x B xex C e i x D e i x where A, B , C and D are constants. After applying the Euler’s formula, the solution can be written in the form of sine and cosine functions as,
y C31e x C32 xe x C33 cos x C34 sin x where C31 , C32 , C33 and C34 are constants. The same solution is obtained by using the DSolve command, DSolve y '''' x 2 y ''' x 2 y '' x 2 y' x y x 0, y x , x
y x
x
C 31
x
x C 32
DSolve
C 33 Cos x
C 34 Sin x
Example Solve the initial value problem governed by the fourthorder differential equation,
d4y d3y d2y dy 2 2 2 y 0 4 3 2 dx dx dx dx
6.6 Solutions from Mixed Roots
197
with the initial conditions of y0 0, y0 2, y0 0 and y0 0 . Since the given differential equation is the same as that in the preceding example, then the general solution is,
y C31e x C32 xe x C33 cos x C34 sin x where C31 , C32 , C33 and C34 are to be determined from the given initial conditions of,
y0 0;
C31
y0 2;
C31
y0 0;
C31 2C32 C33
0
0
y0 0;
C31 3C32 0 C34
0
0 C33
0
C32 0 C34
0
2
By solving the four equations above, the four constants are C31 1, C32 1, C33 1 and C34 2 . Hence, the exact solution of this initial value problem is,
y e x xex cos x 2 sin x The same exact solution is obtained by using the DSolve command, DSolve y '''' x 2 y ''' x 2 y '' x 2 y' x y x 0, y 0 0, y ' 0 y '' 0 0, y ''' 0 0 , y x ,x y x
x
x
x
Cos x
2,
2 Sin x
The solution y that varies with x is plotted by using the Plot command as shown in the figure.
Chapter 6 Higher-Order Linear Differential Equations
198
400
300
y ( x)
200
100
1
2
x
3
4
5
6.7 Nonhomogeneous Equations The higher-order nonhomogeneous differential equations that we will learn how to solve for their solutions are in the form,
an
dny d n 1 y d2y dy a ........ a a1 a0 y n 2 1 n n 2 1 dx dx dx dx
where the coefficients an , an 1,
....., a2 ,
f x
a1 and a0 are constants.
The function f x on the right-hand-side of the equation may be in form of the polynomial, exponential, sine and cosine functions. The general solution of such differential equation consists of two parts, y yh y p where yh is the homogeneous solution of the homogeneous differential equation and y p is the particular solution. We will employ the method of undetermined coefficients learned in the preceding chapter to find the particular solution. The entire process for deriving general solutions of the higher-order nonhomogeneous differential equations will be demonstrated by using the following examples.
6.7 Nonhomogeneous Equations
199
Example Find solution of the third-order nonhomogeneous differential equation,
d3y d2y dy 2 6 3x 1 3 dx dx dx The corresponding characteristic equation of the homogeneous differential equation above is,
3 2 0 which leads to the three roots of, 1 0 , 2 3 and 3 2 . Then, the homogeneous solution is,
yh
C35 C36e3 x C37 e2 x
where C35 , C36 and C37 are constants. The same homogeneous solution is obtained by using the DSolve command, DSolve y ''' x
y x
y '' x 3x
C 35
C 36
6 y' x 2x
0, y x , x
C 37
In the process of finding the particular solution y p using the method of undetermined coefficients, since the function f x on the right-hand-side of the differential equation is 3x 1 , we should assume the solution in form of the polynomials. The assumed polynomials should be second order so that after taking derivatives according to the terms on the left-hand-side of the equation will yield the first-order polynomials (term 3x) on the right-hand-side of the equation. Thus, we assume the particular solution in the form,
yp
A x2 B x C
where A, B and C are constants. We substitute the assumed y p into the differential equation to get,
200
Chapter 6 Higher-Order Linear Differential Equations
0 2 A 6(2 Ax B) 3 x 1 12 Ax (2 A 6B) 3 x 1 By comparing coefficients, the two algebraic equations are obtained, 12A 3 2 A 6B 1
and
These two equations are solved to give A 1 4 and B 1 12 . Then, the particular solution is,
yp
1 1 x2 x 4 12
Hence, the exact solution of the third-order nonhomogeneous differential equation is,
y C35 C36e3 x C37e 2 x
x2 x 4 12
The same solution is obtained by using the DSolve command, DSolve y ''' x y x ,x y x
x 12
x2 4
y '' x
6 y' x
3x
1, DSolve
C 35
3x
C 36
2x
C 37
where C35 , C36 and C37 are constants. Example Find solution of the fourth-order nonhomogeneous differential equation,
d4y d2y 5 4y dx 4 dx 2
10 sin x
The corresponding characteristic equation of the homogeneous differential equation above is,
6.7 Nonhomogeneous Equations
201
4 5 2 4 0
1 1 2 2 0
or,
The four roots are 1 1, 2 1, 3 2 and 4 2 which lead to the homogeneous solution,
yh
C38e x C39e x C40e 2 x C41e 2 x
Since the function f x on the right-hand-side of the differential equation is in the form of sine function, thus we should assume the particular solution in the form of both sine and cosine functions as,
yp
A cos x B sin x
where A and B are constants. By substituting the assumed particular solution y p into the differential equation,
A cos x B sin x 5 A cos x B sin x 4 A cos x B sin x 10sin x or, i.e.,
A 5 A 4 A cos x B 5B 4B sin x 10 sin x
10 A cos x 10B sin x 10 sin x
and comparing the coefficients, we obtain A 0 and B 1 . Then, the particular solution is,
yp
sin x
Thus, the general solution of the fourth-order nonhomogeneous differential equation is,
y C38e x C39e x C40e 2 x C41e 2 x sin x The same solution is obtained by using the DSolve command,
Chapter 6 Higher-Order Linear Differential Equations
202
DSolve y '''' x y x ,x y x
x
C 38
5 y '' x
4y x
10 Sin x , DSolve
x
2x
C 39
C 40
2x
C 41
Sin x
Example Find solution of the third-order nonhomogeneous differential equation,
d3y d2y dy 3 3 y 6e x 3 2 dx dx dx Similar to the preceding example, we first assume the homogeneous solution in the form of e x , substitute into the differential equation and divide through by e x to get the characteristic equation,
3 32 3 1 0 or,
1 1 1 0
which leads to the three roots of 1 1, 2 1 and 3 1 . Then, the homogeneous solution is,
yh
C42e x C43 xe x C44 x 2e x
In the process of finding the particular solution, since e x , xe x and x 2e x are solutions of the third-order differential equation, thus we should assume the particular solution in the form,
yp
Ax 3e x
After substituting the assumed solution y p into the differential equation, we obtain, 6 Ae x 6e x i.e.,
A 1
so that,
y p x3e x
6.7 Nonhomogeneous Equations
203
It is noted that the derivative D command can alleviate the task of substituting y p into the left-hand-side of the differential equation,
y p A x3 x ; LHS D y p , x, 3 3 D y p , x, 2 3 D yp, x yp Simplify 6A
D
x
Hence, the general solution of the third-order nonhomogeneous differential equation is,
y C42e x C43 xe x C44 x 2e x x 3e x The same solution is obtained by using the DSolve command, DSolve y ''' x
3 y '' x
3 y' x
y x
6 x,
y x ,x
y x
x
x3
x
x
C 42
x C 43
x
x2 C 44
Example Solve the initial value problem governed by the thirdorder differential equation,
d 3 y d 2 y 13 dy dx3 dx2 2 dx
e x
with the initial conditions of y0 1, y0 2 and y0 1 . We start from finding the homogeneous solution from the homogeneous differential equation. By assuming the solution in the form of e x , the corresponding characteristic equation is,
3 2 or,
13 0 2
2
So that the three roots are,
13 0 2
Chapter 6 Higher-Order Linear Differential Equations
204
1 2
1 0,
5 2
2 , 3 i
Then, the homogeneous solution is, C45 C46e x 2 cos5 x 2 C47 e x 2 sin 5 x 2
yh
where C45 , C46 and C47 are constants to be determined from the initial conditions. The particular solution is assumed in the form,
yp
A e x
By substituting the assumed particular solution into the differential equation, we obtain,
i.e.,
13 x Ae e x 2 2 A 13
It is noted that the derivative D command can help finding the result of the three derivative terms on the left-hand-side of the differential equation, yp LHS
A
x;
D yp,
13 A 2
x, 3
D yp,
x, 2
13 D yp, x 2
x
D
Thus, the general solution of the third-order nonhomogeneous differential equation is,
y C45 C46e x 2 cos5x 2 C47e x 2 sin5x 2
2 x e 13
where C45 , C46 and C47 are constants that can be determined from the initial conditions as follows,
6.7 Nonhomogeneous Equations
205
y0 1;
C45
y0 2;
0
1 C 2 46
y0 1;
0
6C46
C46
5 C 2 47 5 C 2 47
2 1 13 2 2 13 2 1 13
These three equations are solved to give C45 17 13 , C46 2 13 and C47 46 65 . Hence, the solution of the initial value problem is,
y
17 2 x 2 46 2 e cos5x 2 e x 2 sin5x 2 e x 13 13 65 13
The same solution is obtained by using the DSolve command, DSolve
y ''' x
y' 0 y x
2, y '' 0 17 13
13 y' x 2
y '' x
2 x 13
2 13
x, y 0
1 , y x ,x x 2
Cos
5x 2
1,
Expand
46 65
x 2
Sin
5x 2
The solution of y that varies with x can be plotted easily by using the Plot command as shown in the figure.
1.6
1.4
y ( x) 1.2
1.0 0
1
2
3
x
4
5
6
Chapter 6 Higher-Order Linear Differential Equations
206
6.8 Numerical Methods For all examples presented earlier in this chapter, the higher-order differential equations are linear. The coefficients of the derivative terms are constants so that their exact solutions are not difficult to find. The differential equations become nonlinear if these coefficients are function of y. Exact solutions are not available for most nonlinear differential equations. In this section, we will employ numerical methods to find approximate solutions for both linear and nonlinear differential equations. Mathematica contains the powerful NDSolve command that can provide approximate solutions with high accuracy. Several examples are presented to demonstrate the capability for finding solutions, especially for nonlinear differential equations where their exact closed-form solutions are not available. Example Use the NDSolve command to solve the initial value problem governed by the third-order homogeneous differential equation,
10
d3y d2y dy 10 y 0 dx3 dx2 dx
0 x 10
with the initial conditions of y0 0, y0 0 and y0 1 . Then, plot to compare the approximate solution with the exact solution. It should be noted that an exact solution is available for the initial value problem above. Such exact solution can be found conveniently by using the DSolve command, DSolve
y x
10 y''' x y'' x 10 y' x y 0 0, y' 0 0, y'' 0 10 101
10
x 10
10 Cos x
y x 0, 1 ,y x ,x
Sin x
6.8 Numerical Methods
207
The NDSolve command can be used to solve for the approximate solution of the same initial value problem. The command employs the Runge-Kutta method to determine the approximate solution. The file below consists of the commands that solve for the approximate solution and plot to compare with the exact solution. The approximate solution using the NDSolve command is compared with the exact solution as shown in the figure. The figure shows that both solutions agree very well. 10 10 x 10 10 Cos x Sin x ; 101 exactsol Table x, y x , x, 0, 10, 1 ; NDSolve plot1 ListPlot exactsol, PlotStyle PointSize .02 , Black ; Clear y ; numsol NDSolve 10 y''' x y'' x 10 y' x y x 0, y 0 0, y' 0 0, y'' 0 1 , y x , x, 0, 10 ; plot2 Plot y x . numsol, x, 0, 10 , PlotStyle Black ; Show plot1, plot2 Plot y x
:
3.5 3.0 2.5
y ( x)
Exact
2.0 1.5
Approx.
1.0 0.5
2
4
x
6
8
10
Example Use the NDSolve command to solve the initial value problem governed by the fourth-order nonhomogeneous differential equation,
49
d4y d2y x 442 2 9 y sin x 4 dx dx 2
0 x 100
Chapter 6 Higher-Order Linear Differential Equations
208
with the initial conditions of y0 10, y0 0, y0 0 and y0 0 . Then, plot to compare the approximate solution with the exact solution. Again, this initial value problem has an exact solution in closed-form expression. Such exact solution is complicated but can be found easily by using the DSolve command, DSolve
49 y'''' x 442 y'' x 9y x Sin x x 2, y 0 10, y ' 0 0, y'' 0 0, y ''' 0 0 ,y x ,x ; Expand Simplify y x
x 18
1715 Sin 4224
441 x Cos 7 44 x 7
Sin x 384
1 Cos 3 x 44 Sin 3 x 19 008
The NDSolve command is employed to solve for the approximate solution using a set of commands below. The computed solution is compared with the exact solution as shown in the figure. x 441 x 1 Cos 3 x Cos 18 7 44 44 1715 Sin x Sin x Sin 3 x 7 ; 4224 384 19 008 Table exactsol Table x, y x , x, 0, 100, 5 ; plot1 ListPlot exactsol, PlotStyle PointSize .02 , Black ; Clear y ; 442 y'' x 9y x numsol NDSolve 49 y'''' x Sin x x 2, y 0 10, y' 0 0, 0, y''' 0 0 , y x , x, 0, 100 ; y'' 0 plot2 Plot y x . numsol, x, 0, 100 , PlotStyle Black ; Show plot1, plot2 y x
:
6.8 Numerical Methods
209
10
Exact
5
y ( x)
20
40
60
x
80
100
5
10
Approx.
Example For many higher-order nonlinear differential equations, their exact solutions are not available. As an example, Mathematica cannot provide exact solution if the term 9 y on the left-hand-side of the differential equation in the preceding example is changed to sin( y) , i.e.,
49
d4y d2y x 442 sin( y ) sin x 2 dx 4 dx 2
0 x 100
with the same initial conditions of y0 10, y0 0, y0 0 and y0 0 ,
DSolve
DSolve
49 y'''' x 442 y'' x Sin y x Sin x x 2, y 0 10, y' 0 0, 0, y''' 0 0 ,y x ,x y'' 0 Sin y x x 2 y
442 y
Sin x , y 0 0
0, y
3
0
x
49 y
4
x
10, y 0
0,
0 ,y x ,x
The DSolve command cannot provide exact solution to such nonlinear differential equation so that the input command is returned. In this case, the NDSolve command can be used to find the approximate solution and to plot it by entering the commands as follows,
Chapter 6 Higher-Order Linear Differential Equations
210
numsol
NDSolve 49 y'''' x 442 y'' x Sin y x Sin x x 2, y 0 10, y' 0 0, 0, y''' 0 0 , y x , x, 0, 100 y'' 0 Plot y x . numsol, x, 0, 100 , PlotStyle Black
;
x 20
40
60
80
100
50
Approx.
y ( x)
100
150
6.9 Concluding Remarks In this chapter, we started from the general procedure for solving the higher-order homogeneous linear differential equations. The coefficients of the derivative terms are constants so that the exact closed-form solutions can be derived. The forms of the solutions depend on the characteristic equations arisen from the differential equations. The characteristic equations produce roots that could be distinct real, repeated real and conjugate complex roots including combination of them. We have learnt how to derive the solutions and, at the same time, verify them by using Mathematica commands. For the nonhomogeneous differential equations, we used the method of undetermined coefficients to find the particular solutions. Several examples have been employed to show detailed derivation of the solutions. The same approach was used to solve the initial value problems when their initial conditions are given in addition to the differential equations.
6.9 Concluding Remarks
211
A numerical method was introduced in the last section to solve the initial value problems. Examples have shown that the numerical method in Mathematica can provide approximate solutions with very high accuracy. The main advantage of using the numerical method is that approximate solutions can be obtained when the exact solutions are not available. This is true for most realistic problems when their differential equations are complicated and usually in nonlinear form.
Exercises 1. In each sub-problem below, show that the given solution is the general solution of the corresponding differential equation, (a) y 4e x 7e2 x 2e3 x y 2 y 5 y 6 y 0 (b) y e2 x 3xe2 x 5 x 2e2 x y 6 y 12 y 8 y 0 (c) y 2cos x sin x 5cos 2 x 3sin 2 x y IV 5 y 4 y 0
(d) y 2e 2 x 3 xe 2 x 4 cos x 5 sin x y IV 4 y 5 y 4 y 4 y 0 (e) y 5e3 x 7 xe3 x 3e5 x 2 xe5 x y IV 4 y 26 y 60 y 225 y 0 2. Employ the Det command to determine the determinant (Wronskian) of the solution for each sub-problem in Problem 1. Note that the derivative D command can help finding derivatives of the solution.
212
3.
Chapter 6 Higher-Order Linear Differential Equations
Use the derivative D command to show that,
y 4e x 2 3e x 3 5e3 x 2 7e2 x 3 is the exact solution of the fourth-order homogeneous differential equation,
36 y IV 24 y 47 y y 6 y 0 Then, employ the Det command to show that the Wronskian is nonzero. 4.
Use the derivative D command to show that,
y e3 x 2 5 xe3 x 2 3e x 5 2 xe x 5 is the exact solution of the fourth-order homogeneous differential equation,
100 y IV 260 y 109 y 78 y 9 y 0 Then, employ the Det command to show that the Wronskian is nonzero. 5.
Use the derivative D command to show that,
y 2 cos x 2 3sin x 2 4 cos7 x 3 5 sin7 x 3 is the exact solution of the fourth-order homogeneous differential equation,
36 y IV 205 y 49 y 0 Then, employ the Det command to show that the Wronskian is nonzero. 6.
Use the derivative D command to show that,
y 23 7e x 3xex 5 cos x 4 sin x is the exact solution of the fifth-order homogeneous differential equation,
yV 2 y IV 2 y 2 y y 0
Exercises
213
7. Find the third-order differential equations corresponding to the following solutions, (a) y e x 3e x 7e2 x (b) y 2e3 x 4 xe3 x 5x 2e3 x (c) y 6 sin2 x 5 cos2 x 4 sin x 2 cos x 2 (d) y 3e2 x 4 xe2 x sin x 2 cos x (e) y e x 2 xex 2 e7 x 2 xe7 x 2 Then, verify the differential equations by substituting these solutions into them. 8. Find the fourth-order differential equations corresponding to the following solutions, (a) y e x 3 e x e2 x e3 x (b) y 2e2 x xe2 x 3e x 4 xe x (c) y 5 sin x 6 cos x 7 sin2 x 9 cos2 x (d) y 3e x 4 xex 2 sin x 3 cos x (e) y e7 x 3 5xe7 x 3 3sin3x 4 cos3x Then, verify them by comparing with the solutions obtained from the DSolve command. 9.
Solve the higher-order homogeneous differential equations when roots of the characteristic equations are distinct real numbers, (a) y 6 y 9 y 14 y 0 (b) y IV y 7 y y 6 y 0 (c) y IV 16 y 86 y 176 y 105 y 0 (d) 36 y IV 24 y 47 y y 6 y
0
(e) 360 yV 786 y IV 23 y 714 y 367 y 42 y 0
214
Chapter 6 Higher-Order Linear Differential Equations
Show derivation of the solutions in detail and verify them by comparing with the solutions obtained from the DSolve command. 10. Solve the initial value problems governed by the higher-order homogeneous differential equations when roots of the characteristic equations are distinct real numbers, (a) y 6 y 11 y 6 y 0 y0 1 , y0 0 , y0 0 (b) 30 y 79 y 59 y 12 y 0 y0 0 , y0 1 , y0 0 (c) y IV 14 y 71 y 154 y 120 y 0 y0 1 , y0 0 , y0 0 , y0 0 (d) 120 y IV 2 y 263 y 20 y 21y 0 y0 1 , y0 0 , y0 0 , y0 0 Show derivation of the solutions in detail and verify them by using the DSolve command. Then, use the Plot command to plot the variation of y in the interval of 0 x 2 . 11. Solve the higher-order homogeneous differential equations when roots of the characteristic equations are repeated real numbers, (a) y 6 y 12 y 8 y
0
(b) y IV 2 y 3 y 4 y 4 y
0
(c) y IV 12 y 54 y 108 y 81y
0
(d) y IV 2 y 39 y 40 y 400 y
0
(e) yV 4 y IV y 10 y 4 y 8 y 0 Show derivation of the solutions in detail and verify them by comparing with the solutions obtained from the DSolve command.
Exercises
215
12. Solve the initial value problems governed by the higher-order homogeneous differential equations when roots of the characteristic equations are repeated real numbers, (a) y 12 y 48 y 64 y 0 y0 2 , y0 0 , y0 0 (b) y IV 2 y 11y 12 y 36 y 0 y0 1 , y0 0 , y0 0 , y0 0 (c) y IV 8 y 24 y 32 y 16 y 0 y0 0 , y0 1 , y0 0 , y0 0 (d) 36 y IV 12 y 23 y 4 y 4 y 0 y0 3 , y0 0 , y0 0 , y0 0 Show derivation of the solutions in detail and verify them by using the DSolve command. Then, use the Plot command to plot the variation of y in the interval of 0 x 2 . 13. Solve the higher-order homogeneous differential equations when roots of the characteristic equations are conjugate complex numbers, (a) y IV 5 y 4 y
0
(b) y IV 34 y 225 y
0
(c) 36 y IV 277 y 441y
0
(d) 144 y IV 481y 225 y
0
Show derivation of the solutions in detail and verify them by comparing with the solutions obtained from the DSolve command. 14. Solve the initial value problems governed by the higher-order homogeneous differential equations when roots of the characteristic equations are conjugate complex numbers, (a) y IV 13 y 36 y 0 y0 1 , y0 0 , y0 0 , y0 0
216
Chapter 6 Higher-Order Linear Differential Equations
(b) y IV 25 y 144 y 0 y0 0 , y0 1 , y0 0 , y0 0 (c) 36 y IV 241y 100 y 0 y0 0 , y0 1 , y0 2 , y0 0 (d) 144 y IV 1465y 3136 y 0 y0 0 , y0 1 , y0 2 , y0 3 Show derivation of the solutions in detail and verify them by using the DSolve command. Then, use the Plot command to plot the variation of y in the interval of 0 x 10 . 15. Solve the higher-order homogeneous differential equations when roots of the characteristic equations are distinct real, repeated real or conjugate complex numbers, (a) y 9 y 48 y 448 y
0
(b) y IV 4 y 13 y 36 y 36 y
0
(c) y IV 16 y 94 y 240 y 225 y
0
(d) 36 y IV 36 y 25 y 16 y 4 y
0
(e) 400 y IV 600 y 289 y 96 y 36 y 0 Show derivation of the solutions in detail and verify them by comparing with the solutions obtained from the DSolve command. 16. Solve the initial value problems governed by the higher-order homogeneous differential equations when roots of the characteristic equations are distinct real, repeated real or conjugate complex numbers, (a) 12 y 64 y 7 y 245 y 0 y0 1 , y0 0 , y0 0 (b) 64 y IV 192 y 148 y 12 y 9 y 0 y0 0 , y0 1 , y0 0 , y0 1
Exercises
217
(c) 100 y IV 120 y 61y 30 y 9 y 0 y0 2 , y0 0 , y0 0 , y0 0 (d) 441y IV 126 y 205 y 56 y 4 y 0 y0 0 , y0 1 , y0 0 , y0 2 Show derivation of the solutions in detail and verify them by using the DSolve command. Then use the Plot command to plot the variation of y in the interval of 0 x 2 . 17. Employ the DSolve command to find general solutions of the following higher-order differential equations, (a) 18 y IV 117 y 101y 1117 y 357 y 0 (b) 24 yV 214 y IV 103 y 784 y 161y 90 y 0 (c) 100 yVI 100 yV 271y IV 146 y 214 y 6 y 9 y 0 (d) 24 yVII 140 yVI 126 yV 311y IV 503 y 246 y 40 y 0 (e) 120 yVIII 634 yVII 239 yVI 3296 yV 2221y IV 4876 y 7196 y 3456 y 576 y 0 Then, verify them by substituting into the differential equations. 18. Derive the general solutions of the higher-order nonhomogeneous differential equations, (a) y 3 y 10 y 24 y e7 x (b) y 10 y 25 y x 4 x 2 9 (c) 4 y IV 13 y 9 y x 2 sin x (d) 9 y IV 18 y 110 y 50 y 375 y (e) 81y IV 216 y 288 y 384 y 256 y e x cos x x 2
xe x 1
218
Chapter 6 Higher-Order Linear Differential Equations
Show derivation of the solutions in detail and verify them by comparing with the solutions obtained from the DSolve command. 19. Solve the initial value problems governed by the higher-order nonhomogeneous differential equations and the initial conditions, (a) 6 y 49 y 44 y 35 y cos2 x 1 y0 0 , y0 0 , y0 0 (b) 100 y IV 229 y 9 y sin x y0 0 , y0 0 , y0 0 , y0 0 (c) 64 y IV 96 y 52 y 24 y 9 y x 2 e x y0 0 , y0 5 , y0 3 , y0 1 (d) 324 y IV 261y 25 y x 2 e x y0 0 , y0 1 , y0 2 , y0 3 Show derivation of the solutions in detail and verify them by comparing with the solutions obtained from the DSolve command. Then use the Plot command to plot the variation of y in the interval of 0 x 10 . 20. Employ the NDSolve command to determine approximate solution of the initial value problem governed by the thirdorder homogeneous differential equation, 2 y 5 y 31 y 84 y
0
0 x 1
with the initial conditions of y0 0 , y0 1 and y0 2 . Then, use the DSolve command to find the exact solution. Plot to compare the two solutions in the interval of 0 x 1 . 21. Employ the NDSolve command to determine approximate solution of the initial value problem governed by the fourthorder homogeneous differential equation,
Exercises
219
24 y IV 46 y 63 y 60 y 25 y 0
0 x2
with the initial conditions of y0 0 , y0 1 , y0 2 and y0 3 . Then, use the DSolve command to find the exact solution. Plot to compare the two solutions in the interval of 0 x 2 . 22. Employ the NDSolve command to determine approximate solution of the initial value problem governed by the fourthorder nonhomogeneous differential equation,
42 y IV 29 y 516 y 157 y 12 y
e x cos x
0 x2 with the initial conditions of y0 y0 y0 y0 0 . Then, use the DSolve command to find the exact solution. Plot to compare the two solutions in the interval of 0 x 2 . 23. Employ the NDSolve command to determine approximate solution of the initial value problem governed by the fourthorder nonhomogeneous differential equation,
4 y IV 61y 225 y
5x 2 24x
0 x 10
with the initial conditions of y0 y0 y0 y0 0 . Then, use the DSolve command to find the exact solution. Plot to compare the two solutions in the interval of 0 x 10 . 24. Check whether the DSolve command can find the exact solution of the initial value problem governed by the fourthorder nonhomogeneous nonlinear differential equation,
y y IV 61y 225 y
5x 2 24x
0 x2
with the initial conditions of y0 y0 y0 y0 0 . If the exact solution could not be found, use the NDSolve command to solve for the approximate solution. Plot to show the solution of y that varies with x in the interval of 0 x 2 .
Chapter 7 Laplace Transforms
7.1 Introduction Several practical problems are governed by the higherorder nonhomogeneous differential equations. Functions on the right-hand-side of the differential equations do have physical meanings. These functions may represent an external force of a mechanical system or an impressed voltage in an electrical system. Magnitudes of these functions may change abruptly in the form of a unit impulse or a square wave. The method for solving the nonhomogeneous differential equations presented in the preceding chapters is not suitable for solving these types of problems. The Laplace transform that we will learn in this chapter can solve these problems effectively. Laplace transform is a topic that creates difficulty in solving differential equations to most students. This is mainly because there are several transform formulas that need to
222
Chapter 7 Laplace Transforms
memorize. The Laplace transformation process includes both forward and inverse transformations. The forward transformation can be carried out without much effort, while the inverse transformation is rather difficult and limited to few functions. With the help of Mathematica commands, the task of transformations can be carried out easily. We will start the chapter by learning the definition of the Laplace transform. We will use examples to understand the transformation process. Results of the transformations will be verified by using Mathematica commands. At the end of the chapter, we will learn how to apply the method of Laplace transform to solve some realistic problems governed by the nonhomogeneous differential equations. These include the massspring-damper system subjected to different types of loadings. Solutions will be plotted to increase understanding of the system behaviors.
7.2 Definitions The Laplace transform is defined by the integration from t 0 to of the product between the functions e st and f t as, ℒ f t
e
f t dt
st
0
where f t is the function of t for t 0 . The result is denoted by,
F s ℒ f t
e
st
f t dt
0
In the opposite way, the function f t is called the inverse Laplace transform of F s ,
f t ℒ 1 F s The function f t may be in different forms. For examples, if f t 1 , the Laplace transform is,
223
7.2 Definitions
ℒ f t ℒ 1
e
st
0
1 dt e st s
0
1 s
If f t e at where a is a constant, then the Laplace transform is, ℒ f t
e
ℒ e at
1 s a t e as
st
e at dt
1 sa
0
0
for s a 0 . If f t sin at , then the Laplace transform can be obtained as follows, ℒ f t
e
ℒ sin at
st
sin at dt
0
e st sin at s
0
a s
e
st
cos at dt
0
a s a2 2
Note that the result above is from integrating by parts, i.e., if we let,
Lc ℒ cos at
Ls ℒ sin at
and
then,
e st cos at s 1 a Ls s s
e st sin at dt sin at s
Lc e st cos at dt 0
Ls
e 0
st
0
0
a st e sin at dt s 0
a a Lc e st cos at dt s0 s
By substituting Lc from the upper into lower equation, we get,
224
Chapter 7 Laplace Transforms
Ls
a1 a L s s s s
or
a2 a Ls 1 2 2 s s
Ls ℒ sin at
Thus,
a s a2 2
Similarly, if we substitute Ls from the lower equation into Lc in the upper equation, we get, Lc
i.e.,
1 aa L s s s c
or
Lc ℒ cos at
a2 1 Lc 1 2 s s
s s2 a2
This means the Laplace transform has the property of linearity as, ℒ a f t b g t a ℒ f t b ℒ g t where a and b are constants. As an example, the hyperbolic sine function is, 1 sinh at eat e at 2 then, ℒ sinh at
1 (ℒ e at ℒ e at ) 2 a 1 1 1 2 s a2 2 s a s a
Similarly, the hyperbolic cosine function is, cosh at
1 at e e at 2
then,
1 (ℒ e at ℒ e at ) 2 s 1 1 1 2 s a2 2 s a s a
ℒ cosh at
225
7.3 Laplace Transform
Laplace transform of a given function f t can be obtained without much difficulty. Many mathematical textbooks have shown tables of the Laplace transform for different functions. Same results are obtained by using Mathematica commands as will be shown in the following sections.
7.3 Laplace Transform Mathematica contains the LaplaceTransform command that can be used to obtain result of the Laplace transform of a given function f t . For examples, if we want the Laplace transform of the function,
f t eat we just enter the following, LaplaceTransform
at
LaplaceTransform
, t, s
1 a s
i.e., the result is, ℒ f t ℒ eat
1 as
Or, if we want the Laplace transform of the function, f t sin at
we enter the command, LaplaceTransform Sin a t , t, s a
a2
s2
i.e., the result is, ℒ f t ℒ sin at
a a s2 2
226
Chapter 7 Laplace Transforms
Similarly, if we want the Laplace transform of the function, f t cos at
we enter the command, LaplaceTransform Cos a t , t, s s LaplaceTransform 2 s2 a
i.e., the result is, ℒ f t ℒ cos at
s a s2 2
The Laplace transforms of the hyperbolic sine and cosine functions, ℒ sinh at
and
ℒ cosh at
can be obtained conveniently by entering the commands, LaplaceTransform Sinh a t , t, s a
a2
s2
LaplaceTransform Cosh a t , t, s s
a2
s2
i.e., the results are,
a a2 s2
and
s a2 s2
These results agree with those derived earlier. The LaplaceTransform command can be used to provide the Laplace transforms of other functions, such as, ℒ t 2
and
ℒ t 7
227
7.3 Laplace Transform
LaplaceTransform t2 , t, s 2 s3
LaplaceTransform
LaplaceTransform t7 , t, s 5040 s8
i.e., the results are, 2 and s3 which agree with the formula,
ℒ t n
5040 s8
n! s n1
The command can be also used to obtain the Laplace transforms of more complex functions. For example, f t sin at cosh at cos at sinh at LaplaceTransform Sin a t Cosh a t t, s Simplify
Cos a t Sinh a t ,
Simplify
4 a3 4 a4 s4
The Simplify command is included, in addition, in the above expression to simplify the result to,
4a 3 4a 4 s 4 It is noted that the LaplaceTransform command employs the property of linearity as mentioned earlier. As an example, f t 1 5t ℒ sin at cosh at cos at sinh at
LaplaceTransform 1 5 s2
1 s
5 t, t, s
228
Chapter 7 Laplace Transforms
i.e., the result is,
1 5 s s2
ℒ 1 5t Or, as another example,
f t 4e 3t 10 sin 2t
LaplaceTransform 4 4 3
s
3t
10 Sin 2 t , t, s
20 4 s2
LaplaceTransform
i.e., the result is, ℒ 4e3t 10sin 2t
4 20 2 s3 s 4
7.4 Inverse Laplace Transform Mathematica contains the InverseLaplaceTransform command to provide the inverse Laplace transform of a given function F s . For example, if we want to find the inverse Laplace transform of the function, 1 F s s we enter the commands, 1 InverseLaplaceTransform , s, t s InverseLaplaceTransform
1
i.e., we obtain the result of,
1 f t ℒ 1 F s ℒ 1 1 s Or, as another example, to find the inverse Laplace transform of, F s
1 sa
7.4 Inverse Laplace Transform
229 1
InverseLaplaceTransform
s
a
, s, t
at
i.e., the result is, 1 f t ℒ 1 F s ℒ 1 eat s a And another example, a F s 2 a s2
InverseLaplaceTransform Sin a t
i.e.,
a a2
s2
, s, t
InverseLaplaceTransform
a f t ℒ 1 F s ℒ 1 2 2 sin at a s
Also, the inverse Laplace transform of the function, s F s 2 s a2
s
InverseLaplaceTransform s Simplify ExpToTrig
2
a2
, s, t ; ExpToTrig
Cosh a t
i.e.,
s f t ℒ 1 F s ℒ 1 2 cosh at s a2
Many differential equation textbooks provide tables of inverse Laplace transforms for some popular forms of F s . The InverseLaplaceTransform command can reduce effort to find the inverse Laplace transforms of complicated functions F s . For example,
230
Chapter 7 Laplace Transforms
F s
3s 7 s 2s 3 2
The process to perform the inverse transformation of this function is as follows,
f t
3s 7 ℒ 1 2 s 2s 3
ℒ 1 F s
3s 7 3 s 1 10 1 ℒ 1 ℒ 2 2 s 1 4 s 1 4
2 1 ℒ 5 2 2 s 1 4 s 1 4 s 1
3ℒ 1
3et cosh 2t 5et sinh 2t et 3 cosh 2t 5 sinh 2t 4e3t et In the process as shown above, different terms must be arranged properly so that their inverse transformations could be found from the table. The same result is obtained easily by using the InverseLaplaceTransform command,
InverseLaplaceTransform t
4
3t
3s 7 , s, t s2 2 s 3
InverseLaplaceTransform
As another example when F s is complicated, F s
s s 12 2
The inverse Laplace transform can be obtained easily by using the InverseLaplaceTransform command,
7.4 Inverse Laplace Transform
231
InverseLaplaceTransform
s 2
s
1
2
, s, t
1 t Sin t 2
i.e., the result of f t is, s 1 f t ℒ 1 F s ℒ 1 t sin t 2 2 2 s 1
Variation of the f t function is plotted using the Plot command as shown in the figure below. Plot
, t,
6, 6 , PlotStyle
Black
Plot
f (t ) 1.0 0.5
6
4
2
2
4
6
t
0.5 1.0 1.5 2.0 2.5
The InverseLaplaceTransform command can provide result even though the given function F s is quite complicated,
F s
s 2 6s 9 s 1 s 2 s 4
InverseLaplaceTransform Expand 4t
30
s
s2 6 s 9 1 s 2 s
4
, s, t ;
Expand
16 5
t
2t
25 6
232
Chapter 7 Laplace Transforms
i.e., the result of f t is,
f t ℒ 1 F s s 2 6s 9 ℒ 1 s 1 s 2 s 4
25 2t 1 4t 16 t e e e 6 30 5
which can be plotted by using the Plot command as shown in the figure. Plot
, t,
6, 6 , PlotStyle
Black
Plot
f (t ) 1 106 800000
600000
400000 200000
6
4
2
2
4
6
t
The figure indicates a sudden change of f t in the interval of 5 t 4 . If we want to amplify the change that occurs in the interval of 2 t 2 , we can modify the Plot command slightly by including the desired interval for plotting as follow, Plot
, t,
2, 2 , PlotStyle
Black
The variation of f t in the interval of 2 t 2 is now shown in the figure.
7.5 Solving Differential Equations
233
f (t ) 200
150
100
50
2
1
1
2
t
7.5 Solving Differential Equations In this section, we will learn how to apply the method of the Laplace transform to solve the initial value problems. We will see that the transformation changes the differential equation to an algebraic equation which is easier to solve. It should be noted that the Laplace transform for the first-order derivative of function f t is, ℒ f t s ℒ f t f 0 Similarly, the transform for the second-order derivative of function f t is, ℒ f t s 2 ℒ f t s f 0 f 0
The transformation for the higher-order derivatives of the function f t can be determined in the same way. Application of the Laplace transform method for solving the initial value problems is demonstrated by using the following examples. Example Solve the initial value problem governed by the secondorder nonhomogeneous differential equation, y y t with the initial conditions of y 0 1 and y0 2 . We start from finding the Laplace transform of the differential equation,
234
Chapter 7 Laplace Transforms
ℒ y ℒ y ℒ t
which gives, s 2 ℒ y s y 0 y 0 ℒ y ℒ t
Since ℒ t 1 s 2 can be found by using the LaplaceTransform command as, LaplaceTransform t, t, s
LaplaceTransform
1 s2
With the given initial conditions of y 0 1 and y0 2 , then the equation above becomes, s2 Y s 2 Y
1 s2
1 Y 2 s 2 s 2 1 s
Or,
The inverse Laplace transform of the Y function above is,
1 y ℒ 1Y ℒ 1 2 s 2 s 2 1 s which can be obtained by using the InverseLaplaceTransform command as, 1 InverseLaplaceTransform t
Cos t
3 Sin t
s2
s
s2
1
2 , s, t
InverseLaplaceTransform
Thus, the solution of the initial value problem is,
y t cos t 3 sin t It is noted that if we solve this problem by hands, we need to arrange the terms of s on the right-hand-side of the Y equation properly so that we can find their inverse Laplace transforms from the transform table as follows,
7.5 Solving Differential Equations
Y
235
s2 1 2 2 s s 1 s 1 2
s 1 1 2 2 2 2 2 s s 1 s 1 s 1
s 1 3 2 2 2 s s 1 s 1
Then, s 3 1 y ℒ 1Y ℒ 1 2 2 2 s 1 s 1 s Thus, the solution is,
y t cos t 3 sin t Such solution can be plotted by using the Plot command as shown in the figure. Plot
,
t, 0, 10 , PlotStyle
Black
Plot
The plot shows that both the initial conditions of y0 1 and y0 2 are satisfied. This example demonstrates the advantage of the Laplace transform method for solving the initial value problem conveniently. Results of the Laplace and inverse Laplace transforms are obtained by using the LaplaceTransform and InverseLaplaceTransform commands, respectively.
10 8 6
y
4 2
2 2
4
6
t
8
10
236
Chapter 7 Laplace Transforms
Example Solve the initial value problem governed by the secondorder nonhomogeneous differential equation,
y 3 y 2 y 4 e 2t with the initial conditions of y0 3 and y0 5 . We start from finding the Laplace transform of the differential equation, ℒ y 3 ℒ y 2 ℒ y 4 ℒ e2t
Here ℒ e2t 1 s 2 which is obtained from using the LaplaceTransform command,
LaplaceTransform
2 t , t, s
LaplaceTransform
1 2 s
so that the transformed equation is,
s 2Y sy0 y0 3sY y0 2Y
4 s2
After applying the initial conditions, the transformed equation becomes,
s 2Y 3s 5 3 sY 3 2Y
4 s2
which gives,
4 Y 3s 14 s 2 3s 2 2 s The solution is then obtained by inverse transformation,
4 y ℒ 1Y ℒ 1 3 s 14 s 2 3 s 2 s 2 which can be done by using the InverseLaplaceTransform command,
7.5 Solving Differential Equations
InverseLaplaceTransform
237 4
s 2 3s 2 s 3s 2
14
, s, t ;
Expand
7
t
2t
4
4
2t
t
Hence, the solution of the initial value problem is,
y 4 e 2 t 7 et 4 t e 2 t The solution of y that varies with t is plotted by using the Plot command in the interval of 0 t 1 as shown in the figure. Plot
,
t, 0, 1 , PlotStyle
Plot
Black
40
30
y 20
10
0.2
0.4
0.6
0.8
1.0
t Example Solve the initial value problem governed by the fourthorder homogeneous differential equation,
y IV y 0 with the initial conditions of y0 0 , y0 0 , y0 0 and
y0 1 . Again, we start by performing the Laplace transform of the given differential equation, ℒ y IV ℒ y 0
238
Chapter 7 Laplace Transforms
to give,
s 4 Y s 3 y0 s 2 y0 s y0 y0 Y 0 Then, we apply the initial conditions to obtain,
s4 Y 0 0 0 1 Y 0 Thus, Y
1 s4 1
After that, we can find the inverse Laplace transform by using the InverseLaplaceTransform command, InverseLaplaceTransform
1 s4
, s, t ; 1 ExpToTrig
Factor ExpToTrig 1 Sin t Sinh t 2
Hence, the solution of this initial value problem is, y
1 sinh t sin t 2
Example Motion of the mass in the mass-spring-damper system as shown in the figure is governed by the second-order nonhomogeneous differential equation,
2 y y 2 y t with the initial conditions of y0 0 and y0 0 . The notation t on the right-hand-side of the differential equation is the Dirac delta function representing a unit impulse applied on the mass. The coefficients in the differential equation are equivalent to the mass of m 2 , the damping coefficient of c 1 and the spring stiffness of k 2 .
7.5 Solving Differential Equations
239
t c
k
1 m
t
y t
0
t
0
We can use the method of Laplace transform to solve for the mass motion which is the displacement in the vertical direction y(t) that varies with time t. Similar to the preceding examples, we start from transforming the differential equation, 2ℒ y ℒ y 2 ℒ y ℒ t which leads to,
2 s 2 Y s y0 y0 s Y y0 2 Y 1 It is noted that transformation of the Dirac delta function on the right-hand-side of the differential equation can be obtained conveniently by using the LaplaceTransform command, LaplaceTransform DiracDelta t , t, s DiracDelta
1
We apply the given initial conditions of zero displacement and velocity at time t 0 to give,
2 s 2 Y 0 0 s Y 0 2 Y 1 Thus,
Y
1 2s s 2 2
Then, we perform inverse transformation to find the solution of the displacement y(t) that varies with time t,
240
Chapter 7 Laplace Transforms
1 y t ℒ 1Y ℒ 1 2 2s s 2 This is carried out by using the InverseLaplaceTransform command, InverseLaplaceTransform
2
t 4
Sin
15 t 4
1 2 s2
, s, t s
2
InverseLaplaceTransform
15
Hence, the solution for the motion of the mass is,
yt
2 t 4 15 e sin t 15 4
The motion is plotted for the interval of 0 t 15 by using the command Plot[%,{t,0,15}] as shown in the figure. At the early time, the displacement is large from the unit impulse that applies on the mass. The displacement decreases as the time increases due to the damping effect.
0.3 0.2 0.1
y (t )
2 0.1
4
6
8
10
12
14
t
If the system does not include the damper c 0 , the governing differential equation becomes,
2 y 2 y t
7.5 Solving Differential Equations
241
After performing transformation, we get, 1 2s 2
Y
2
Then, we find the solution by performing the inverse transformation,
1 y t ℒ 1Y ℒ 1 2 2s 2 which can be done by using the InverseLaplaceTransform command, InverseLaplaceTransform
1 2 s2
, s, t 2
Sin t 2
This leads to the solution of the motion when there is no damper, sin t 2
y t
The motion can be plotted by using the Plot command, Plot
,
t, 0, 15 , PlotStyle
Black
Plot
The figure shows that the mass moves up and down as the sine function about y 0 . 0.4 0.2
y (t )
2 0.2 0.4
4
6
8
t
10
12
14
242
Chapter 7 Laplace Transforms
Example Determine the displacement y(t) of the mass if the massspring-damper system in the preceding example is subjected to a unit step (Heaviside) function as shown in the figure. H t c
k
1
m H t
y t
0
0
t
For the mass-spring-damper system with m 2 , c 1 and k 2 as explained in the preceding example, the corresponding differential equation is,
2 y y 2 y H t The forcing function on the right-hand-side of the equation is,
0, H t 1,
t0 t0
This differential equation is to be solved with the initial conditions of zero displacement and velocity at t 0 , i.e., y0 0 and y0 0 . By considering the differential equation, we can see that as t , y 0 and y 0 , then the displacement at the equilibrium position is y 1 2 0.5 . To determine the dynamic response of the mass, the Laplace transformation is applied to the differential equation,
2 ℒ y ℒ y 2 ℒ y ℒ H t which gives,
7.5 Solving Differential Equations
243
2 s 2 Y s y 0 y0 s Y y 0 2 Y
1 s
The transformation of the unit step function on the right-hand-side of the equation is obtained by using the LaplaceTransform command, LaplaceTransform HeavisideTheta t , t, s
1 s
HeavisideTheta
Then, the initial conditions for the displacement and velocity of y0 0 and y0 0 are imposed to give, 2s 2 Y 0 0 s Y 0 2 Y
1 s
i.e., Y
1 s 2 s 2 s 2
The inverse transformation is performed to yield the solution of the displacement y that varies with time t, 1 y t ℒ 1Y ℒ 1 2 s 2s s 2
This can be done by using the InverseLaplaceTransform command, InverseLaplaceTransform
1 s 2 s2
, s, t ; s
2
Expand
1 2
1 2
which is,
t 4
Cos
15 t 4
t 4
Sin 2
15
15 t 4
244
Chapter 7 Laplace Transforms
yt
15 1 1 t 4 1 t 4 15 t e sin t e cos 2 2 4 2 15 4
The vertical movement y that varies with time t is plotted by using the Plot command in the interval of 0 t 15 as shown in the figure, Plot
, t, 0, 15 , PlotRange PlotStyle Black
0, 15 ,
0, 0.8
,
Plot
It can be seen from the figure that the system approaches the equilibrium configuration at the displacement of y 0.5 as expected. 0.8
0.6
y (t ) 0.4 0.2
0.0 0
2
4
6
t
8
10
12
14
If we increase the damping coefficient from c 1 to c 2 , then the differential equation becomes,
2 y 2 y 2 y H t This leads to the value of Y after performing transformation, Y
1 2 s s s 1
Then, the displacement solution is,
2
7.5 Solving Differential Equations
245
1 y t ℒ 1Y ℒ 1 2 2 s s s 1
The InverseLaplaceTransform command is used to find the inverse Laplace transform, 1
InverseLaplaceTransform
2 s s2
, s, t ; s
1
Expand t 2
1 2
1 2
t 2
3 t 2
Cos
3 t 2
Sin 2
3
i.e.,
3 1 1 t 2 1 t 2 3 e sin t e cos t 2 2 2 2 3 2 The solution above is plotted as shown in the figure. The figure shows that, when the damping coefficient is larger, the massspring-damper system reaches the equilibrium configuration sooner with smaller magnitude of oscillation. y t
0.8
0.6
y (t )
0.4
0.2
0.0 0
2
4
6
t
8
10
12
14
The technique of Laplace transform can also be applied to solve a set of differential equations. This is explained by using the examples as follows.
246
Chapter 7 Laplace Transforms
Example Solve a set of two first-order differential equations,
x 2 x 3 y 0 y y 2 x 0 for the solution of x(t) and y(t) with the initial conditions of x0 8 and y0 3 . We start by finding the Laplace transform of the first differential equation, ℒ x 2 ℒ x 3 ℒ y 0
s X x0 2 X 3Y 0 and apply the initial condition to obtain,
s X 8 2 X 3Y 0 or,
s 2 X 3Y 8
Similarly, we find the Laplace transform of the second differential equation, ℒ y ℒ y 2 ℒ x 0
s Y y0 Y 2 X 0 and apply the initial condition to obtain,
sY 3 Y 2 X 0 or,
s 1Y 2 X 3
Thus, the Laplace transformation leads to the two algebraic equations,
s 2 X 3Y 8 2 X s 1Y 3 which can be solved for function X and Y. We can use the Solve command to solve them as follows,
7.5 Solving Differential Equations
eq1 s 2 x 3y eq2 2 x s 1 y Solve eq1, eq2 , 17
x
4
8s 3s
s2
247
8; 3; x, y
Solve
22
,y
4
3s 3s
to obtain,
X
17 8s 4 3s s 2
and
Y
22 3s 4 3s s 2
s2
Then, we perform the inverse transformation, 17 8s x t ℒ 1 X ℒ 1 4 3s s 2 22 3s y t ℒ 1 Y ℒ 1 4 3s s 2
and
by using the InverseLaplaceTransform command, InverseLaplaceTransform
17 4
5
t
3 4t
22 4
t
3s
s2
, s, t
InverseLaplaceTransform
InverseLaplaceTransform 5
8s
3s 3s
s2
, s, t
2 4t
Hence, the solutions of the coupled first-order differential equations are,
xt 5et 3e4t and
yt 5e t 2e 4t
248
Chapter 7 Laplace Transforms
Example A mass-spring system consisting of two masses and two springs is shown in the figure. The two masses are m1 and m2 , while the two springs have the spring stiffness of k1 and k 2 , respectively. The motion of the two masses ( y1 and y2 ) are governed by the two differential equations from the Newton’s second law. Mass m1 k1
k1 m1
m1 y1 k1 y1 k2 y2 y1
k1 y1
Mass m2 y1
m1
m2 y2 k2 y2 y1
m1
k2 k 2 y2 y1
k2
m2 y2
m2
m2
k1 6 and If m1 1, m2 1, k2 4 , then the differential equations that describe the motions of y1 t and y2 t at any time t are,
y1 10 y1 4 y2 0 and
y2 4 y1 4 y2 0
The coupled differential equations above will be solved with the initial conditions of y1 0 0, y10 1, y2 0 0 and y2 0 1 . We start by transforming the first differential equation, ℒ y1 10 ℒ y1 4 ℒ y2 0
s 2 Y1 s y1 0 y10 10Y1 4 Y2 0 After applying the given initial conditions, we obtain,
s 2 Y1 0 1 10Y1 4Y2 0 or,
s 2 10Y1 4 Y2 1 Similarly, we transform the second differential equation,
7.5 Solving Differential Equations
249
ℒ y2 4 ℒ y1 4 ℒ y2 0
s 2 Y2 s y2 0 y2 0 4 Y1 4 Y2 0 After applying the given initial conditions, we obtain,
s 2 Y2 0 1 4Y1 4Y2
0
4Y1 s 2 4Y2 1
or,
Thus, the two algebraic equations after applying the transformation and initial conditions are,
s 2 10Y1 4 Y2 1 4Y1 s 2 4Y2 1 We can use the Solve command to solve for Y1 and Y2 as follows, eq1
s2
10 y1
eq2
4 y1
s2
Solve
y1
i.e.,
4 y2
4 y2
eq1, eq2 ,
s2 24
14 s2
s
1; 1;
y1 , y2
, y2 4
Solve
6 24
s2
14 s2
s4
s2 24 14s 2 s 4 6 s2 24 14s 2 s 4
Y1 Y2
Then, we find the inverse Laplace transforms,
s2 y1 t ℒ 1Y1 ℒ 1 2 4 24 14s s 6 s2 y2 t ℒ 1Y2 ℒ 1 2 4 24 14 s s by using the InverseLaplaceTransform command,
250
Chapter 7 Laplace Transforms
s2
InverseLaplaceTransform
14 s2
24
s4
, s, t ;
Expand
Sin
2 t
5
1 5
2
3 Sin 2
3 t 6
InverseLaplaceTransform 24
s2
14 s2
s4
, s, t ;
Expand
1 5
2 Sin
1 10
2 t
3 Sin 2
3 t
The solutions of y1 t and y2 t representing displacements of mass m1 and m2 that vary with time t are,
3 sin 2 3 t 5
y1 t
2 sin 10
y2 t
2 3 sin 2 t sin 2 3 t 5 10
2t
the
These displacements y1 t and y2 t of the mass m1 and m2 are plotted as shown in the figures. 0.4
0.2
y1 (t ) 0.0 0.2
0.4
2
4
6
8
10
12
14
t
7.6 Concluding Remarks
251
0.4
0.2
y2 (t )
0.0
2
4
6
8
10
12
14
t
0.2
0.4
7.6 Concluding Remarks In this chapter, we have studied the method of Laplace transform for solving differential equations. There are many practical problems that are governed by the nonhomogeneous differential equations for which the forcing functions on the righthand-side of the equations are in form of the impulse or step functions. The standard methods learned in the preceding chapters are not suitable for solving this type of problems while the method of Laplace transformation can handle them very well. We started from understanding the definitions of the Laplace transform and inverse Laplace transform. Several examples were presented to show the transformations of several functions. At the same time, the LaplaceTransform and InverseLaplaceTransform commands are used to confirm the derived results. The method of Laplace transform was then applied to solve the nonhomogeneous differential equations for the problems mentioned above. The problems may be governed by a single differential equation or coupled equations. The method of Laplace transform changes the differential equations into algebraic equations so that they can be solved easier. Several examples have demonstrated the advantage of the method to provide solutions to this type of problems effectively.
252
Chapter 7 Laplace Transforms
Exercises 1. Use the LaplaceTransform command to find F s which are the Laplace transforms of the following functions, (a) f t t 1 2 (b) f t t1 2 (c) f t a 2 t 1 2 (e) f t eat cos b t
(d) f t a 2 b 2 t1 2 (f) f t t cos b t
where a and b are constants. 2. Use the LaplaceTransform command to find F s which are the Laplace transforms of the following functions, 2 (a) f t t 2 2 t (b) f t t 2 3 1 (d) f t sin 3 t (c) f t sin 2 4 t 2 (e) f t e2 t cosh t (f) f t t 2 e3 t 3. Use the LaplaceTransform command to find F s which are the Laplace transforms of the following functions, (a) f t e2 t cos 3 t (b) f t t 3 4t 2 3 (c) f t t 3 sin a t (d) f t t 4 e 2 t (e) f t t e a t sin b t (f) f t t e a t cos b t where a and b are constants. 4.
Use the LaplaceTransform command to find F s which are the Laplace transforms of the following functions, (a) f t 6 sin 2 t 5 cos 2 t (b) f t 3 cosh5 t 4 sinh 5t 2 (c) f t 5 e 2 t 3 3 (d) f t 1 t e t (e) f t e a t eb t / t (f) f t sin a t cos b t t
where a and b are constants.
Exercises
253
5. Use the InverseLaplaceTransform command to find f t which are the inverse Laplace transforms of the following functions, s 1 (a) F s (b) F s 2 s a s b s a s s (c) F s (d) F s s a s b s a s 2 b 2 s s F s (e) F s (f) 2 4 s b4 s 2 a 2 where a and b are constants. 6. Use the InverseLaplaceTransform command to find f t which are the inverse Laplace transforms of the following functions, (a) F s 3.8 t e2.4 t (b) F s 3 t 4 e 0.5 t 7 (d) F s (c) F s 3 s 1 s 2 15 2s 56 (e) F s (f) F s 2 2 s 4s 29 s 4s 12 7. Use the InverseLaplaceTransform command to find f t which are the inverse Laplace transforms of the following functions, 4 6 (a) F s (b) F s 4 2 16 s s 2 s 1 3s 1 (c) F s 2 (d) F s 2 s 2s 5 s 4 s 20 1 1 (e) F s (f) F s 4 s 1 2s 3 8.
Use the InverseLaplaceTransform command to find f t which are the inverse Laplace transforms of the following functions,
254
Chapter 7 Laplace Transforms
s2 s 1s 2 2 s 5 2 3 5 s 1 2 2 4 s 2 s 16 s 2 s 5
(a) F s
(b) F s
(c) F s
(d) F s
(e) F s
s 2 20s 31 s 2 2 s 3
(f) F s
5s 4 2 s 18 24 30 s 2 s3 s 9 s4
2s 5 3s 42s 13 3s 2 4s 2
s 2 2s 42 s 5
9. Use the method of Laplace transform to solve the second-order nonhomogeneous differential equation,
y 4 y 9t with the initial conditions of y0 0 and y0 7 . 10. Use the method of Laplace transform to solve the second-order nonhomogeneous differential equation,
y 3 y 2 y t with the initial conditions of y0 1 and y0 0 . 11. Use the method of Laplace transform to solve the second-order nonhomogeneous differential equation,
y 2 y 5 y et sin 2 t with the initial conditions of y0 2 and y0 1 .
Exercises
255
12. Use the method of Laplace transform to solve the third-order nonhomogeneous differential equation,
y y et with the initial conditions of y0 y0 y0 0 . 13. Use the method of Laplace transform to solve the fourth-order nonhomogeneous differential equation,
y IV 2 y y sin t with the initial conditions of y0 y0 y0 y0 0 . 14. Use the method of Laplace transform to solve the fourth-order homogeneous differential equation,
y IV 4 y 0 with the initial conditions of y 0 2, y 0 0, y 0 4, y 0 0 . Then, verify the solution by substituting it into the differential equation and initial conditions to check whether they are satisfied. 15. Use the method of Laplace transform to solve the fourth-order homogeneous differential equation,
y IV 4 y 6 y 4 y y 0 with the initial conditions of y 0 0, y 0 1, y 0 0, y 0 1 . 16. Use the method of Laplace transform to solve the second-order nonhomogeneous differential equation,
y 4 y t where t is the Dirac delta function at time t 0 with the initial conditions of y0 0 and y0 0 . Plot the solution of y t in the interval of 0 t 10 .
256
Chapter 7 Laplace Transforms
17. Use the method of Laplace transform to solve the second-order nonhomogeneous differential equation,
2 y y 4 y t where t is the Dirac delta function at time t 0 with the initial conditions of y0 0 and y0 0 . Plot the solution of y t and check whether it satisfies the initial conditions. 18. Use the method of Laplace transform to solve the second-order nonhomogeneous differential equation,
y 4 y H t where H t is the Heaviside function at time t 0 with the initial conditions of y0 0 and y0 0 . Plot the solution of y t in the interval of 0 t 10 . 19. Use the method of Laplace transform to solve the set of two first-order homogeneous differential equations,
x x y y 2 x with the initial conditions of x0 0 and y0 1 . 20. Use the method of Laplace transform to solve the set of two first-order nonhomogeneous differential equations,
2x y 2x 1 x y 3x 3 y 2 with the initial conditions of x0 0 and y0 0 . Then, verify the solutions by substituting them into the differential equations and initial conditions to check whether they are satisfied.
Exercises
257
21. Use the method of Laplace transform to solve the set of two second-order homogeneous differential equations,
x x y 0 y y x 0 with the initial conditions of x0 0, x0 2, y0 0 and y0 1 . 22. Use the method of Laplace transform to solve the set of two second-order nonhomogeneous differential equations,
x y t 2 x y 4 t with the initial conditions of x0 8, x0 0, y0 0 and y0 0 .
Chapter 8 Fourier Transforms
8.1 Introduction Fourier transform is based on the knowledge of the Fourier series used for analyzing some practical problems. The Fourier series consists of the sine and cosine functions suitable for representing different types of periodic motions, such as the swinging pendulums, telecommunication signals, electric motor vibration, etc. Analysis solutions can provide comprehensive understanding of their behaviors. Similar to the Laplace transform method learned in the preceding chapter, the Fourier transform can be used to solve some specific types of differential equations. This includes the nonhomogeneous differential equations when the functions on the right-hand-side of the equations change abruptly with time. Before applying the method of Fourier transform to solve such differential equations, the definitions of both the Fourier
260
Chapter 8 Fourier Transforms
transform and inverse Fourier transform will be introduced. Examples will be used to show how to perform transformation for different types of functions. At the same time, Mathematica commands will also be employed to confirm the results. The discrete and fast Fourier transforms which have been used in many current applications will be explained by example.
8.2 Definitions Fourier transform is a valuable tool in transforming data and functions from the time domain into the frequency domain. It has been used widely in the field of telecommunication that involves waves and signals. The idea came from the Fourier series which contain the continuous periodic functions, such as sine and cosine functions. The sine function is generally written in the form, A sin 2 t where A is the amplitude, is the frequency measured by the cycle or period per second, t is time, and is called the phase which may not be zero at time t 0 . The cosine function is in the same form except the phase is shifted by / 2 . Therefore, the periodic function f t as mentioned can be written in a general form as,
f t
n
A cos2 k 1
k
k
t Bk sin2 k t
To understand the concept more clearly, let’s consider the periodic function given by,
f t 0.5 sin t 2 sin 4 t 4 cos 2 t If we plot the first term on the right-hand-side of the periodic function above in the interval of 0 t 5 , Plot 0.5 Sin t , t, 0, 5 , PlotStyle PlotRange 0, 5 , 6, 6
Black, Plot
261
8.2 Definitions
6 4 2 0
1
2
t
3
4
5
2 4 6
we observe that the magnitude of oscillation is 0.5 and the frequency is half cycle per second. Similarly, if we plot the second term in the same interval 0 t 5, of Plot 2 Sin 4 t , PlotRange
t, 0, 5 , PlotStyle 0, 5 , 6, 6
Black, Plot
6 4 2 0
1
2
t
3
4
5
2 4 6
we see that the magnitude is now 2 and the frequency is two cycles per second. Also, if we plot the last term of the equation in the same interval of 0 t 5 ,
262
Chapter 8 Fourier Transforms
Plot 4 Cos 2 t , PlotRange
t, 0, 5 , PlotStyle 0, 5 , 6, 6
Black,
6 4 2 0
1
2
3
t
4
5
2 4 6
we see that the magnitude is 4 and the frequency is one cycle per second. By combining the three terms together, we can plot the oscillating behavior of the function f t by using the Plot command as shown in the figure. Plot 0.5 Sin t 2 Sin 4 t 4 Cos 2 t , t, 0, 5 , PlotStyle Black, PlotRange 0, 5 , 6, 6 6 4 2
f (t )
0
1
2
t
3
4
5
2 4 6
In general, the Fourier series could be in any form that may include a large number of terms. The Fourier transform method will help us to identify magnitudes and frequencies of the given functions. It
8.3 Fourier Transform
263
is noted that the analysis of Fourier transform method is usually carried out by using the complex numbers. This is because the involved equations will be in simpler forms. Both sine and cosine functions can be written in the form of complex numbers by using the Euler’s formula, ei cos i sin and e i cos i sin where i 1 is the imaginary unit number. The two equations above lead to, ei ei ei ei cos and sin 2i 2 After substituting these cos and sin functions in the form of complex numbers, the expression of f t reduces to a more compact form as,
f t
n
C
k n
k
e2 i k t
where C k is the magnitude and k is the frequency.
8.3 Fourier Transform Mathematica has options to define the Fourier transform of a function f t in many ways. A popular definition which is normally used in pure mathematics and system engineering software is,
ℱ()
f t e i t dt
It is noted that such definition may differ from those defined in some textbooks which have the factor of 2 as denominator. To employ the definition above, the option, FourierParameters
1,
1
must be specified inside the Fourier transform command. The parameters may be set at the beginning of calculation by using the command,
264
Chapter 8 Fourier Transforms
SetOptions FourierTransform, FourierParameters 1, 1
Fourier transform requires performing integration from to of the product between f t and e it . For example, the given function f t is, 1, f t 0,
x 1 x 1
which has its variation as shown in the figure. f t
2
1
1
0
t
1
Then, the Fourier transform is, ℱ()
f t e
1
i t
dt
1
ei t i
1 ei t dt
1
1
2 i sin i
ei ei i 2 sin
We can use the integration command to carry out the integration symbolically,
8.3 Fourier Transform
f
265
1; 1
f
t
t
1
2 Sin
The result is plotted by using the command, Plot
, , 3 ,3 PlotRange
, PlotStyle Black, 3 ,3 , 1, 3
The figure shows the result of Fourier transform along -axis in the scale. ℱ ( ) 3
2
1
5
5
1
Mathematica contains the FourierTransform command that can be used to transform f t from the time domain to ℱ() in the frequency domain. The definition of Fourier transform used herein is, ℱ()
f t e i t dt
For example,
f t e t 2
266
Plot
Chapter 8 Fourier Transforms
t2
, t, 5, 5 , PlotStyle
Black
Variation of the function f t with time t is shown in the figure. f (t ) 1.0
0.8
0.6 0.4
0.2
4
2
2
4
t
We can use the FourierTransform command to find the Fourier transform of this function, FourierTransform
t2 , t,
1,
FourierParameters
, 1
2 4
FourierTransform
ℱ()
i.e.,
e 2 4
The result varies with the frequency that can be plotted using the Plot command as shown in the figure.
Plot
2 4
,
,
5, 5 , PlotStyle
Black
8.3 Fourier Transform
267
ℱ ( ) 1.5
1.0
0.5
4
2
2
4
Let us consider another example, if the function f t is given by,
f t e t Plot
Abs t ,
t,
5, 5 , PlotStyle
Black
which varies with time t as shown in the figure. f (t ) 1.0
0.8
0.6
0.4
0.2
4
2
2
4
t
Result of the Fourier transform is obtained by using the FourierTransform command with its variation as shown in the
figure.
268
Chapter 8 Fourier Transforms
Abs t , t,
FourierTransform FourierParameters
1,
,
1
2 Plot
2
1
2
Plot 1
2
,
,
5, 5 , PlotStyle
Black
ℱ ( ) 2.0
1.5
1.0
0.5
4
2
2
4
If the function f t above is changed slightly to,
f t t e t The same FourierTransform command can be used to find the Fourier transform, FourierTransform t FourierParameters
Abs t , t,
1,
1
4 1
i.e.,
,
FourierTransform 2 2
ℱ()
4 i
2 12
8.4 Inverse Fourier Transform
269
8.4 Inverse Fourier Transform Similar to the Fourier transform command, Mathematica contains the InverseFourierTransform command to find the inverse Fourier transform of the function ℱ() from the frequency domain to the function f t in time domain. The inverse Fourier transform is defined by, 1 f t 2
ℱ() ei t d
For example, if the function in the frequency domain is, ℱ() 2e
Plot
Abs
2
,
,
5, 5 , PlotStyle
Black
which varies with the frequency as shown in the figure. 4
2
2
4
0.5
1.0
1.5
2.0
ℱ ( )
We can use the InverseFourierTransform command to find the inverse Fourier transform and plot its variation as follows, InverseFourierTransform FourierParameters
2 1
1,
2
Abs
,
, t,
1
InverseFourierTransform
t2
270
Chapter 8 Fourier Transforms
i.e., the result of inverse Fourier transform is, 2 f t 2 t 1 with the variation as shown in the figure. 4
2
2
t
4
0.1 0.2 0.3 0.4 0.5 0.6
f (t )
If the function in the frequency domain is given by, ℱ() 6 e 2 4
The inverse Fourier transform can be found by entering, InverseFourierTransform 6 FourierParameters 6
t2
1,
2 4
,
, t,
1
InverseFourierTransform
i.e., the result in the time domain is,
f t 6 et 2 As another example, if the function in the frequency domain is given by, 1 ℱ() 1 i The inverse Fourier transform can be found by entering,
8.4 Inverse Fourier Transform
271
1
InverseFourierTransform FourierParameters t
HeavisideTheta
1
1,
,
, t,
1
t
The result of f t in the time domain is shown in the figure. 1.0 0.8 0.6
f (t ) 0.4 0.2
1
2
3
t
4
5
If the given function contains a quantity that must always be positive value, we should inform that to Mathematica. As an example, the value of a in the function below must be a positive quantity, e 2 4 a ℱ() a 0 2a We need to declare such positive value of a inside the transform command, 2
4a
,
InverseFourierTransform
, t,
2a Assumptions a t2
2
a
0, FourierParameters
1,
1
272
i.e., the result is,
Chapter 8 Fourier Transforms
e at 2 2
f t
8.5 Fast Fourier Transform All of the functions f t we learned in the preceding sections are continuous and easy to handle. For practical problems, a large number of data points may be generated from experiments. These data points are discrete and not continuous. The technique of the Fourier transform can still be applied to analyze such data. We call the analysis of this latter case as the discrete Fourier analysis. The transformation process is known as the Discrete Fourier Transform or DFT. To understand the process, we start from a periodic function f t with the period of 2 . If we have N data points with equal intervals, the distance between each pair of data points is, 2 k tk k 0, 1, 2, ..., N 1 N The idea is to create a function f t to represent the variation of these data points in the form of,
f tk
N 1
C e n0
i n tk
n
where the coefficients Cn , n 0, 1, 2, ..., N 1 , are to be determined. It was found that the time used for determining these coefficients varies with N 2 . Later, an improved method so called the Fast Fourier Transform or FFT was developed. The method significantly reduces the computational time to N log N . This latter method was implemented on Mathematica which can be used by calling the Fourier command. We will learn how to use this Fourier command to study the signal frequency through a simple example as follow. Suppose we have a signal composing of the three sine and cosine functions,
8.5 Fast Fourier Transform
273
f t 2 sin 2 (20) t 4 cos 2 (50) t 3 sin 2 (100) t It is noted that the frequencies of these three sine and cosine functions are 20, 50 and 100 Hz, respectively. The variation of the continuous f t function is plotted from 0 to 1 as shown in the figure. f (t )
5
0.2
0.4
0.6
0.8
1.0
t
5
To include the noise similar to that occurs in the data from experiment, we first represent the continuous function f t by 500 discrete data points and then add arbitrary noise values randomly into it by using the built-in Random command. The variation of the function f t after adding noise is shown in the figure. f (t )
5
0.2
5
0.4
0.6
0.8
1.0
t
274
Chapter 8 Fourier Transforms
The variations of the original continuous function f t and after it was represented by 500 data points with noise as seen from the figures are slightly different. It is difficult to identify the three frequencies of 20, 50 and 100 Hz from these two figures. We will use the fast Fourier transform through the Fourier command to find these three frequencies. The Mathematica file below shows the commands to plot the original continuous f t function and to convert it into 500 data points. Noise is added randomly into these data points before plotting their variation again. The data points are transformed using the Fourier command to determine the amplification. The amplification is then plotted versus the frequency as shown in the figure. The figure shows that the three frequencies of 20, 50 and 100 Hz are clearly identified after using the Fourier command. This example thus demonstrates the advantage of the fast Fourier transform that can find frequencies of the data with noise normally obtained from experiment. ClearAll Define a fuction composing of 3 waves with their frequencies of 20, 50 and 100 Hz, respectively y t 2 Sin 2 20 t 4 Cos 2 50 t 3 Sin 2 100 t Plot distribution of the defined function Plot y t , t, 0, 1 , PlotStyle Black Create discrete data with total of 500 data points n 500; t 1 n; Add noise into these data to simulate data obtained from experiment datawithnoise Table N y t 2 Random .5 , t, 0, 1 t, t Random Plot these data with noise ListPlot Table i t, datawithnoise i , i, 1, n , PlotRange All, Joined True, PlotStyle Black Perform fast Fourier transform for amplitudes amplitude Fourier datawithnoise Fourier Plot the computed amplitudes versus fequencies i 1 ListPlot Table , i, 1, 120 , , Abs amplitude i n t PlotRange
All, Joined
True, PlotStyle
Black
8.6 Solving Differential Equations
275
Amplitude
40
30
20
10
20
40
60
80
100
120
Frequency
8.6 Solving Differential Equations The method of Fourier transform can be used to solve the differential equations that are in some specific forms. The Fourier transform for the first-order derivative of function f t is,
ℱ f t
i F
Similarly, the Fourier transform for the second-order derivative of function f t is,
ℱ f t
i F 2
The Fourier transform for the higher-order derivatives of function f t can be obtained in the same fashion, i.e.,
ℱ f n t i n F We will use examples to demonstrate the method of Fourier transform to solve for solutions of some specific types of differential equations as follows. Example Solve the first-order nonhomogeneous differential equation,
y 4 y e4t H t
276
Chapter 8 Fourier Transforms
where H t is the Heaviside function which is equal to one when t 0 and is equal to zero when t 0 . The differential equation can be rewritten as, e 4 t , t 0 y 4y 0, , t 0
We start by performing the Fourier transform of the differential equation,
ℱ y 4 ℱ y ℱ e4t H t We can use the FourierTransform command to find the Fourier transform for the term on the right-hand-side of the equation as, FourierTransform FourierParameters
4 t HeavisideTheta t , t,
1,
,
1 FourierTransform
4
Thus, the Fourier transform of the differential equation is,
1 i 4
i F 4F F
or,
1
i 4 i 4
Then, we perform inverse transformation by using the InverseFourierTransform command,
1
InverseFourierTransform FourierParameters 1 8
4t
8t
1,
HeavisideTheta
4
4
,
, t,
1 t
HeavisideTheta t
Thus, the solution of y that varies with t when t 0 is,
8.6 Solving Differential Equations
277
yt
e 4t 8
The plot of such solution is shown in the figure. t 0.00
0.5
0.05
f (t )
1.0
1.5
2.0
e 4t 8
0.10
0.15
It is noted that the solution can be verified by substituting it into the left-hand-side of the differential equation, 1 4t ; 8 LHS D y, t y
4y
D
4t
The result is equal to the right-hand-side of the differential equation when t 0 . Example Solve the second-order nonhomogeneous differential equation, y 3 y 2 y t where t is the Dirac delta function which is equal to one at t 0 and equal to zero at any other t. We start by performing Fourier transform of the differential equation,
ℱ y 3 ℱ y 2 ℱ y ℱ t
278
Chapter 8 Fourier Transforms
The FourierTransform command can be used to find the Fourier transform of the Dirac delta function, FourierTransform DiracDelta t , t, FourierParameters 1, 1
,
FourierTransform
1
Thus, the differential equation after transformation becomes,
i 2 F 3 i F 2 F 1 F
i.e.,
1 3 i 2 2
Then, we perform inverse transformation by using the InverseFourierTransform command to obtain the solution,
1
InverseFourierTransform FourierParameters 2t
t
1
1,
2
3
,
, t,
2
1
HeavisideTheta t
i.e., the solution of this differential equation is,
yt e2t et 1 H t Again, we can verify the solution by substituting it into the left-hand-side of the differential equation, y
2t
LHS
D y,
t
1
DiracDelta
t, 2 t
HeavisideTheta t ; 3 D y, t
2y
Simplify
HeavisideTheta
The result is the Dirac delta function which is equal to the righthand-side of the differential equation.
8.7 Concluding Remarks
279
8.7 Concluding Remarks In this chapter, we have learnt the method of Fourier transform to solve for solutions of some differential equations. Such differential equations arise in many applications for which the loads are applied to the problems instantly. Definitions of the Fourier transform and its inverse transformation were first explained. The Fourier transform changes the given function from the time domain into another function in the frequency domain. In the opposite way, the inverse Fourier transform changes the function in the frequency domain back to the time domain. The FourierTransform and InverseFourierTransform commands in Mathematica were used to obtain the transformation results as demonstrated by examples. For discrete data collected from experiments, the discrete Fourier analysis was applied. The discrete Fourier transform was explained by employing the Fourier command of the fast Fourier transform. The command helps us to identify the frequency contents from the signal with noise. In the last section, the method of Fourier transform was applied to solve differential equations. Examples have shown that the method can provide solutions effectively when the nonhomogeneous functions on the right-handside of the differential equations are in form of the Dirac delta and Heaviside functions.
Exercises 1. Use the FourierTransform command to find the Fourier transform ℱ() of the following functions, (a) f t H t (b) f t et H t (c) f t et
(d) f t
2 2
(e) f t 5e 3t 5
2
(f)
1 1 t2
f t e5 t
where H t is the Heaviside function.
280
Chapter 8 Fourier Transforms
2. Use the FourierTransform command to find the Fourier transform ℱ() of the following functions, (b) f t 3 e 4 t 2 (a) f t t 2 e t (c) f t
t 9 t2
(d) f t
(e) f t 3 t e 9 t 2
(f)
5 e3 i t t 2 4t 13
f t 25 t e 2 t H t
3. Use the FourierTransform command to find the Fourier transform ℱ() of the following functions, (a) f t 1 t (b) f t e7 t (c) f t e 16 t 2
(d) f t t et 2
(e) f t sin3 t 2
(f)
2
f t cos 5t 2
4. Use the InverseFourierTransform command to find the inverse Fourier transform f t of the following functions,
1 1 i
(b) ℱ()
2 i
(c) ℱ() e i
(d) ℱ()
1 4
6 9
(f) ℱ()
(a) ℱ()
(e) ℱ()
2
2
3
2 i 1 i
5. Use the InverseFourierTransform command to find the inverse Fourier transform f t of the following functions, (a) ℱ() (b) ℱ() (c) ℱ()
1
1 i 2 1
1 i 2 i 1 1 i 6 5 i 2
Exercises
281
(d) ℱ()
54 i 9 8 i 2
(e) ℱ() 7 e 4 (d) ℱ()
2 32
e 2 6 i 4 3 i
6. Use the InverseFourierTransform command to find the inverse Fourier transform f t of the following functions, 2 (a) ℱ() 9e 4
32
(b) ℱ() e 3
(c) ℱ()
e 2 i 5 i
(d) ℱ()
e5 i
(e) ℱ()
e 20 4 i 3 5 i
(f) ℱ()
e 2 6 i 5 3 i
7. A signal is given in the form of two sine functions,
f t sin 2 (15) t 2 sin 2 (60) t Use the Random command to add noise into the signal similar to that explained in section 8.5. Then, apply the fast Fourier transform to find the two frequencies from the amplitude versus frequency plot. 8. A signal is given in the form of a sine and two cosine functions,
f t 2 cos 2 (30) t 3 sin 2 (60) t 4 cos 2 (90) t Use the Random command to add noise into the signal similar to that explained in section 8.5. Then, apply the fast Fourier transform to find the three frequencies from the amplitude versus frequency plot.
282
Chapter 8 Fourier Transforms
9. Apply the Fourier transform to solve the first-order nonhomogeneous differential equation,
2 y y t where t is the Dirac delta function. Plot the solution of yt and verify it by substituting into the differential equation. 10. Apply the Fourier transform to solve the first-order nonhomogeneous differential equation,
y 5 y et H t where H t is the Heaviside function. Show detailed derivation of the solution yt . Plot the solution and verify it by substituting into the differential equation. 11. Apply the Fourier transform to solve the first-order nonhomogeneous differential equation,
y 8 y e8t H t where H t is the Heaviside function. Plot the solution of yt for t 0 and verify it by substituting into the differential equation. 12. Apply the Fourier transform to solve the second-order nonhomogeneous differential equation,
y 4 y 4 y t where t is the Dirac delta function. Plot the solution of yt and verify it by substituting into the differential equation. 13. Apply the Fourier transform to solve the second-order nonhomogeneous differential equation,
y 6 y 5 y t 3
Exercises
283
where t is the Dirac delta function. Show detailed derivation of the solution yt and plot its variation in the interval of 3 t 7 . Note that the Mathematica command to find Fourier transform of t 3 is, FourierTransform DiracDelta t FourierParameters 1, 1
3 , t,
,
Chapter 9 Boundary Value Problems 9.1 Introduction Solving the boundary value problems that will learn in this chapter is the first step toward understanding how to analyze practical problems. We will solve the boundary value problems that are governed by the ordinary differential equations together with the boundary conditions. Solving the ordinary differential equations is equivalent to solve the one-dimensional problems for which their exact solutions are usually available. If the exact solutions cannot be found, we will apply the numerical method to obtain the approximate solutions instead. Learning how to solve the one-dimensional problems is important as the basis to continue solving two- and threedimensional problems. For these multi-dimensional problems, the governing equations are in the form of partial differential equations which are difficult to solve. In addition, the boundary conditions are more complicated and the geometries could be complex too. In
286
Chapter 9 Boundary Value Problems
general, their exact solutions are not available and the numerical methods are the only way for finding approximate solutions. Efficient numerical methods, such as the finite element method which will be explained in the following chapter, must be applied to solve for their solutions. In this chapter, we will learn how to find exact solutions of the one-dimensional boundary value problems that are governed by simple ordinary differential equations with boundary conditions. We will derive the exact solutions and verify them by using the DSolve command. If the exact solutions are not available, we will use the NDSolve command to find their approximate solutions. The materials in this chapter thus represent the first step toward learning how to solve the more general boundary value problems.
9.2 Two-Point Boundary Value Problems Two approaches are normally used to solve the two-point boundary value problems. The first approach is to find the exact solutions when the governing differential equations and boundary conditions are not complicated. The second approach is to find the approximate solutions by using the numerical methods. In the latter approach, the methods for solving the initial value problems, such as the shooting and chasing methods, are modified to include iteration process so that the boundary conditions are satisfied. Mathematica contains the NDSolve command to solve such problems for which we will learn how to use it in detail. In this section, we will start by reviewing the derivation of exact solutions to the governing differential equations with boundary conditions. We will verify the derived solutions with those obtained by using the DSolve command. We will use the following examples to demonstrate the process. Example Derive the exact solution of the boundary value problem governed by the second-order homogeneous differential equation,
d2y 4y 0 dx 2
0 x 1
287
9.2 Two-Point Boundary Value Problems
with the boundary conditions of y0 0 and y1 1. The process for deriving the exact solution of the boundary value problem is similar to the initial value problem. We first assume a general solution in the form of e x and substitute it into the differential equation to get,
2e x 4e x 0 Then, we divide it by e x to obtain the characteristic equation,
2 4 0
2 2 0 i.e., 1 2 and 2 2 . Thus, the general solution is, y C1e2 x C2e2 x
where C1 and C2 are constants that can be determined from the given boundary conditions as follows,
y0 0;
0 C1 C2
y1 1;
1 C1e2 C2e2
By solving the two equations above, we obtain the two constants of C1 and C2 as,
C1
1 e e 2 2
and
C2
1 e e 2 2
Hence, the exact solution is,
Or,
y
e2 x e2 x e 2 e 2 e 2 e 2
y
sinh 2 x sinh 2
The same exact solution is obtained by using the DSolve command. The solution is plotted using the Plot command as shown in the figure.
288
DSolve
Chapter 9 Boundary Value Problems
y '' x 4y x 0, y 0 y x ,x FullSimplify
0, y 1
DSolve
Sinh 2 x Sinh 2
y x Plot y x
. ,
1 ,
Plot
x, 0, 1 , PlotStyle
Black
1.0 0.8 0.6
y ( x) 0.4 0.2
0.2
0.4
x
0.6
0.8
1.0
Example Derive the exact solution of the boundary value problem governed by the second-order homogeneous differential equation,
d2y 4y 0 dx 2
0 x 1
with the boundary conditions of y0 0 and y1 1. This example is identical to the previous one except the opposite sign of the zeroth-order term in the differential equation. The characteristic equation obtained from the differential equation above is,
2 4 0
2i 2i 0 So, 1 2i and 2 2i where i 1 . solution is, y Ae2i x Be2i x
Thus, the general
where A and B are constants. By using the Euler’s formula,
289
9.2 Two-Point Boundary Value Problems
ei x cos x i sin x and e i x cos x i sin x the general solution above can be written in the form of sine and cosine functions as, y C3 cos2 x C4 sin2 x where C3 and C4 are constants that can be determined from the given boundary conditions as follows,
y0 0;
0 C3 0
y1 1;
1 C3 cos2 C4 sin2
The two equations above give values of the two constants as C3 0
and C4 1 sin2 . Hence, the exact solution is, sin2 x y sin2 The same exact solution is obtained by using the DSolve command. The solution of y that varies with x is plotted by using the Plot command as shown in the figure. DSolve
y '' x 4y x 0, y 0 y x ,x FullSimplify
0, y 1
DSolve
Sin 2 x Sin 2
y x Plot y x
. ,
1 ,
Plot
x, 0, 1 , PlotStyle
Black
1.0 0.8
y ( x) 0.6 0.4 0.2
0.2
0.4
x
0.6
0.8
1.0
290
Chapter 9 Boundary Value Problems
9.3 Second-Order Differential Equations Derivation for exact solutions of the boundary value problems governed by the second-order differential equations is reviewed in the preceding section. The derived solutions were verified by using the DSolve command. For many second-order differential equations, their exact solutions cannot be derived in closed-form expressions. Numerical methods must be applied to find the approximate solutions. In this section, we will use the NDSolve command to solve the boundary value problems. The approximate solutions will be compared with the exact solutions, if available, to measure the numerical solution accuracy. The NDSolve command employs the technique similar to the commands used for solving the initial value problems. For example, to solve an initial value problem governed by the secondorder differential equation in the interval of 0 x 1 , we start the solution from the initial conditions of y0 and y0 at x 0 . The technique computes the next solutions with the time step of x until it reaches x 1 . The final solution of y1 at x 1 thus depends to the differential equation and the two initial conditions. If the same technique is used to solve the boundary value problem, it starts with the condition of y0 at x 0 and must end with the specified condition of y1 at another end of x 1 . Thus, an iteration process is needed so that the computed solution agrees with the specified boundary condition at x 1 . The examples below demonstrate the use of the NDSolve command to solve the two-point boundary value problems governed by the second-order differential equations. Example Use the NDSolve command to solve the boundary value problem governed by the second-order homogeneous differential equation, d2y dy 3 2y 0 0 x 1 2 dx dx with the boundary conditions of y0 1 and y1 0 .
291
9.3 Second-Order Differential Equations
If we derive the exact solution by first assuming it in the form of e x , we obtain two distinct roots of 1 and 2 from the characteristic equation. These two roots give the general solution in the form, y C5e x C6e2 x where C5 and C6 are constants to be determined from the given
boundary conditions of y0 1 and y1 0 . Solving these two constants leads to the exact solution of, e1 e x y 2x 1 e e 1 The same exact solution is obtained by using the DSolve command, DSolve
y '' x 3 y' x 2y x 0, y 0 0 , y x ,x Simplify y 1 2x
y x
1,
DSolve
x
1
Variation of the solution y with x is plotted using the Plot command as shown in the figure. Plot y x
. ,
x, 0, 1 , PlotStyle
Black Plot
1.0 0.8 0.6
y ( x) 0.4 0.2
0.2
0.4
0.6
x
0.8
1.0
292
Chapter 9 Boundary Value Problems
The NDSolve command can be used to find the approximate solution of this problem. A set of commands below determine such approximate solution and plot it to compare with the exact solution. As shown in the figure, the approximate solution agrees very well with the exact solution. 2x
y x
x
:
; 1 Table exactsol Table x, y x , x, 0, 1, .1 ; plot1 ListPlot exactsol, PointSize .02 , Black ; Clear y ; PlotStyle numsol NDSolve y '' x 3 y' x 2y x 0, y 0 1, y 1 0 , y x , x, 0, 1 ; . numsol, x, 0, 1 , PlotStyle Black ; plot2 Plot y x Show plot1, plot2
1.0
0.8
Exact 0.6
y ( x) Approx.
0.4
0.2
0.2
0.4
x
0.6
0.8
1.0
Example Use the NDSolve command to solve the boundary value problem governed by the second-order homogeneous differential equation, d2y dy 3 2y 0 0 x 1 2 dx dx with the boundary conditions of y0 1 and y1 0 . This example is identical to the preceding one except the boundary condition at x 1 is changed from y1 0 to y1 0 .
293
9.3 Second-Order Differential Equations
We can derive the exact solution by ourselves or use the DSolve command as follows, DSolve
y '' x y' 1
3 y' x 2y x 0, y 0 0 , y x ,x Simplify
2x
y x
1,
DSolve
2 x 2 y
i.e.,
e1 2e x e2 x e1 2
The approximate solution can be obtained by using the NDSolve command. A set of commands below determine the approximate solution and compare it with the exact solution. The figure below shows the plot of the approximate solution as compared to the exact solution. Both boundary conditions of y0 1 and y1 0 are satisfied at the ends of the domain. 2x
y x
:
2 x
; 2 exactsol Table x, y x , x, 0, 1, .1 ; plot1 ListPlot exactsol, PointSize .02 , Black ; Clear y ; PlotStyle numsol NDSolve y '' x 3 y' x 2y x 0, y 0 1, y' 1 0 , y x , x, 0, 1 ; . numsol, x, 0, 1 , PlotStyle Black ; plot2 Plot y x Show plot1, plot2 1.0
Exact 0.5
Approx.
y ( x)
0.5
0.2
0.4
0.6
0.8
1.0
x
294
Chapter 9 Boundary Value Problems
Example Use the NDSolve command to solve the boundary value problem governed by the second-order nonhomogeneous differential equation,
d 2 y dy y 4 x3 6 x 2 14x 9 dx2 dx
0 x 1
with the boundary conditions of y0 1 and y1 1. Similar to the preceding examples, we can derive the exact solution by ourselves or use the Mathematica command to find it. The DSolve command can be used to find the exact solution conveniently as follows, DSolve
y '' x y 0
y x
1
y' x
y x
1, y 1
6 x2
14 x
1 , y x ,x
6 x2
2x
4 x3
9,
DSolve
4 x3
i.e., the exact solution for this boundary value problem is, y
4 x3 6 x 2 2 x 1
A set of commands below determine the approximate solution by using the NDSolve command and plot it to compare with the exact solution obtained above. The comparison indicates that the approximate and exact solutions agree very well as shown in the figure. The method for finding the approximate solution is thus valuable when the exact solution of the problem is not available. y x : 1 2 x 6 x2 4 x3 ; NDSolve exactsol Table x, y x , x, 0, 1, .1 ; plot1 ListPlot exactsol, PlotStyle PointSize .02 , Black ; Clear y ; numsol
NDSolve
y '' x y 0
y' x 1, y 1
. numsol, plot2 Plot y x Show plot1, plot2
y x
4 x3
1 , y x ,
6 x2
14 x
x, 0, 1
x, 0, 1 , PlotStyle
9,
;
Black ;
295
9.4 Higher-Order Differential Equations
Exact
1.2
Approx.
1.1
y ( x)
1.0
0.9
0.0
0.2
0.4
0.6
0.8
1.0
x
9.4 Higher-Order Differential Equations The NDSolve command can also be used to find approximate solutions of the boundary value problems that are governed by the higher-order differential equations as demonstrated in the examples below. Example Use the NDSolve command to solve the boundary value problem governed by the third-order homogeneous differential equation,
d3y d 2 y dy 2 2y 0 dx3 dx 2 dx
0 x4
with the boundary conditions of y0 0 , y0 1 and y4 0 . This boundary value problem has an exact solution that can be found by using the DSolve command, DSolve
y ''' x 2 y '' x y 0 0, y ' 0 FullSimplify Factor 2x
1
x
y' x 1, y 4
DSolve 4
y x 2
2y x 0, 0 , y x ,x ;
4
x
1 8
4
x
296
Chapter 9 Boundary Value Problems
i.e., the exact solution is, y
e
x
1 e x e4 1 e4 e x e 2 x e8 e 4 2
The NDSolve command can be employed to determine the approximate solution. The commands below show the use of the NDSolve and Plot commands to determine and plot the approximate solution for comparing with the exact solution. The figure indicates that the NDSolve command can provide accurate solution as compared to the exact solution. 2x
y x
1
x
4
x
1
4
x
:
; 4 8 2 Table exactsol Table x, y x , x, 0, 4, .25 ; plot1 ListPlot exactsol, PointSize .02 , Black ; Clear y ; PlotStyle 2 y '' x y' x 2y x 0, numsol NDSolve y ''' x 0, y ' 0 1, y 4 0 , y x , x, 0, 4 ; y 0 plot2 Plot y x . numsol, x, 0, 4 , PlotStyle Black ; Show plot1, plot2
0.25
0.20
y ( x)
Exact
0.15
Approx.
0.10 0.05
1
2
x
3
4
297
9.4 Higher-Order Differential Equations
Example Use the NDSolve command to solve the boundary value problem governed by the fourth-order nonhomogeneous differential equation, d4y 1 0 x 1 dx 4 with the boundary conditions of y 0 0 , y 0 0 , y 1 0 and y1 0 . This boundary value problem represents the deflection behavior of a cantilever beam subjected to a uniform loading as shown in the figure. The beam of a unit length is fixed at the left end ( x 0 ) so that both the deflection and slope are zero. The right end ( x 1 ) is free to move, therefore, both the moment and shear are zero.
x
1
The exact solution of this problem can be derived by performing integration four times and applying the boundary conditions. It can also be found conveniently by using the DSolve command as follows, DSolve
y x
i.e.,
y '''' x 1, y 0 y '' 1 0, y ''' 1
x2 4
x3 6
0, y ' 0 0, 0 , y x ,x
x4 24
y
Expand
DSolve
x 4 x3 x 2 24 6 4
If we prefer to obtain the approximate solution by using the NDSolve command, we can employ the set of commands as shown in the preceding examples to determine the approximate
298
Chapter 9 Boundary Value Problems
solution and to plot it for comparing with the exact solution. The plot shows that the NDSolve command can provide accurate approximate solution of the beam deflection as compared to the exact solution. x2 x3 x4 ; 4 6 24 exactsol Table x, y x , x, 0, 1, .1 ; NDSolve plot1 ListPlot exactsol, PointSize .02 , Black ; Clear y ; PlotStyle numsol NDSolve y '''' x 1, y 0 0, y ' 0 0, y '' 1 0, y ''' 1 0 , y x , x, 0, 1 ; . numsol, x, 0, 1 , PlotStyle Black ; plot2 Plot y x Show plot1, plot2 y x
:
x 0.2
0.4
0.6
0.8
1.0
0.02 0.04 0.06
y ( x)
Exact Approx.
0.08 0.10 0.12
Example Use the NDSolve command to solve the boundary value problem governed by the fourth-order nonhomogeneous differential equation, d4y 1 0 x 1 dx 4 with the boundary conditions of y 0 0, y0 0, y 1 0 and y1 0 . This example is identical to the preceding one except the right boundary conditions at the right end of the domain. The beam is now fixed at both ends so that the deflections and slopes at ( x 0 ) and ( x 1 ) are zero as shown in the figure.
299
9.4 Higher-Order Differential Equations
x
1 In this case, the exact solution can be obtained easily by using the DSolve command, DSolve
y x
y '''' x 1, y 0 0, y ' 0 y 1 0, y ' 1 0 , y x ,x
x2 24
x3 12
x4 24
y
i.e.,
0, Expand DSolve
x 4 x3 x 2 24 12 24
The NDSolve command can be used to determine the approximate solution of the beam deflection. The commands to determine such approximate solution and to plot it for comparing with the exact solution are similar to those shown the preceding example. Again, the approximate solution compares very well with the exact solution as shown in the figure. x 0.2
0.4
0.6
0.0005 0.0010
y ( x)
Exact
0.0015
Approx. 0.0020 0.0025
0.8
1.0
300
Chapter 9 Boundary Value Problems
9.5 Complicated Differential Equations Many boundary value problems are governed by complicated differential equations. To solve them, we may start by using the DSolve command to find their exact solutions. If the exact solutions are not available, we can use the NDSolve command to find the approximate solutions instead. Example Use the NDSolve command to solve the boundary value problem governed by the second-order homogeneous differential equation with variable coefficients,
d 2 y 2 dy 2 y 0 dx 2 x dx x 2
1 x 2
The boundary conditions are y 1 5 and y 2 3 . We start from employing the DSolve command to find the exact solution, DSolve
2 y' x x
y '' x y 1
y x
4 x2
5, y 2
2 x2
y x
0,
3 , y x ,x
DSolve
Simplify
x
The exact solution for this boundary value problem is,
y
4 x x2
We can use the NDSolve command to find the approximate solution. The commands below consist of the NDSolve command to determine for the approximate solution and the Plot command to plot it for comparing with the exact solution above. The comparison indicates good agreement between the two solutions as shown in the figure.
301
9.5 Complicated Differential Equations
y x
:
4
x; x2 exactsol Table x, y x , x, 1, 2, .1 ; Table plot1 ListPlot exactsol, PlotStyle PointSize .02 , Black ; Clear y ; 2 2 y' x y x 0, numsol NDSolve y '' x x x2 y 1
5, y 2
plot2 Plot y x . numsol, Show plot1, plot2
3 , y x ,
x, 1, 2
x, 1, 2 , PlotStyle
;
Black ;
5.0
4.5
y ( x)
Exact Approx.
4.0
3.5
3.0 1.0
1.2
1.4
1.6
1.8
2.0
x Example Use the NDSolve command to solve the boundary value problem governed by the second-order nonlinear differential equation,
y
d 2 y dy dx 2 dx
2
0
1 x 3
with the boundary conditions of y1 2 and y3 2 . The DSolve command can provide the exact solution for the nonlinear differential equation with the boundary conditions above,
302
Chapter 9 Boundary Value Problems
DSolve
y x y '' x y 1
y x
1
2, y 3
0,
DSolve
2 , y x ,x
x
y
i.e.,
y' x 2
1 x
The approximate solution is obtained by using the NDSolve command. Similar to the preceding examples, the NDSolve and Plot commands are used to determine the approximate solution and to plot it for comparing with the exact solution, respectively. The comparison between the approximate and exact solution is shown in the figure. The figure shows that the NDSolve command can provide accurate approximate solution to this nonlinear boundary value problem. 2.0 1.9 1.8
y ( x)
Exact
1.7
Approx.
1.6 1.5
1.0
1.5
2.0
2.5
3.0
x Example Use the NDSolve command to solve the boundary value problem governed by the second-order nonlinear differential equation,
d2y dy 0 2y 2 dx dx
0 x 1
with the boundary conditions of y 0 1 and y 1 1 2 .
303
9.5 Complicated Differential Equations
In this case, the DSolve command cannot provide an exact solution. However, it is found that the solution,
y
1 1 x
is an exact solution because it satisfies the differential equation. We can check this by using the derivative D command, y LHS
1 1
; x D y,
x, 2
2 y D y, x
D
0
The solution also satisfies the two boundary conditions which can be verified by using the substituting command, y . x
0
1 y . x
1
1 2
If we cannot find the exact solution of the problem, we can use the NDSolve command to find the approximate solution in the same fashion as explained in the preceding examples. We can employ the NDSolve and Plot commands to determine and plot the approximate solution, respectively. As shown in the figure, the approximate solution is quite accurate and can be obtained conveniently. This example demonstrates the benefit of using the numerical method to find the approximate solution when the exact solution cannot be derived in general, especially for most nonlinear differential equations.
304
Chapter 9 Boundary Value Problems
1.0
0.9
Exact 0.8
Approx.
y ( x) 0.7
0.6
0.5 0.0
0.2
0.4
x
0.6
0.8
1.0
9.6 Concluding Remarks Methods for solving the boundary value problems governed by the ordinary differential equations and boundary conditions were presented. For the problems with simple differential equations, their exact solutions can be derived. The process for deriving exact solutions is similar to that for the initial value problems except the application of the boundary conditions instead of the initial conditions. Mathematica contains the DSolve command that can be used to find exact solutions for many types of the differential equations. For the boundary value problems that are governed by more complicated differential equations, such as those with variable coefficients and in nonlinear form, their exact solutions may not be available. In this case, the numerical method must be applied to obtain approximate solutions. Mathematica contains the NDSolve command that can provide accurate numerical solutions. The boundary value problems solved in this chapter are all in one-dimensional domain. The problems are governed by the ordinary differential equations with simple boundary conditions. For two- and three-dimensional problems, they are governed by the partial differential equations. The boundary conditions are more complicated and their domains could be arbitrary. In general, their exact solutions cannot be found. Finding the approximate solutions
305
Exercises
by using the numerical methods is the only way to solve the problems. We will learn a popular method, so called the finite element method, for solving these problems in the next chapter.
Exercises 1. Derive the exact solutions of the following boundary value problems, 0 x 1 (a) y 4 y 0 y0 0 , y 1 5 (b) y 9 y 0 y 0 4 , y 2 1
0 x2
(c) y y 0 y 0 1 , y 2 1
0 x 2
(d) y y 2 y 0 y0 0 , y 1 1
0 x 1
(e) y 2 y 3 y 0 y 0 1 , y1 2
0 x 1
Verify the solutions with those obtained by using the DSolve command. In each sub-problem, employ the Plot command to plot the solution of y that varies with x within the given domain. 2. Derive the exact solutions of the following boundary value problems, 0 x 1 (a) y y x 2 y 0 0 , y 1 0 (b) y 4 y cos x y0 0 , y1 0
0 x 1
306
Chapter 9 Boundary Value Problems
(c) y 2 y y 5 x y0 0 , y1 0
0 x 1
(d) y 2 y y x 2 1 y 0 5 , y 1 10
0 x 1
(e) y 4 y 4 y x 1 e 2 x y 0 3 , y1 0
0 x 1
Verify the solutions with those obtained by using the DSolve command. In each sub-problem, employ the Plot command to plot the solution of y that varies with x within the given domain. 3.
Use the DSolve command to solve the following boundary value problems, 1 x 2 (a) x 2 y 3 xy 3 y 0 y 1 5 , y 2 0 (b) x 2 y 2 xy 2 y 0 y 1 2 , y2 2
1 x 2
(c) x 2 y 3 xy y x 2 y1 0 , y2 0 1 (d) y y 0 x y 1 50 , y 4 100 (e) x 2 y xy y ln x y1 0 , y 2 2
1 x 2 1 x 4 1 x 2
In each sub-problem, verify the solution by substituting it into the differential equation and boundary conditions. 4.
Use the derivative D command to show that, cos5 1 x x y 32 sin cos 1 sin 5 2 2
is the exact solution of the boundary value problem governed by the second-order differential equation,
307
Exercises
y
1 y 4
8
0 x 10
with the boundary conditions of y0 0 and y 10 0 . Then, use the DSolve command to check whether Mathematica can provide the above solution. 5. Use the derivative D command to show that,
y xsin x is the exact solution of the boundary value problem governed by the second-order nonhomogeneous differential equation,
y 2 xy y 21 x 2 cos x
0 x
2 with the boundary conditions of y0 0 and y 2 2 . Then, use the DSolve command to check whether Mathematica can provide the above solution. 6.
Use the derivative D command to show that,
y tan x 4 is the exact solution of the boundary value problem governed by the second-order nonlinear differential equation,
y 2 y y 0
0 x
2 with the boundary conditions of y 0 1 and y 2 1 . Then, use the DSolve command to check whether Mathematica can provide the above solution. 7. Use the derivative D command to show that,
y
1 x
is the exact solution of the boundary value problem governed by the second-order nonlinear differential equation, 1 x 3 y y y2 0
308
Chapter 9 Boundary Value Problems .
with the boundary conditions of y1 2 and y 3 2 . Then, use the DSolve command to check whether Mathematica can provide the above solution. 8. Employ the NDSolve command to find the approximate solution of the boundary value problem governed by the second-order homogeneous differential equation, y y 0 0 x 1 with the boundary conditions of y 0 1 and y 1 1 . Plot to compare the approximate solution with the exact solution obtained by using the DSolve command. 9. Employ the NDSolve command to find the approximate solution of the boundary value problem governed by the second-order nonhomogeneous differential equation, y 2 y y x 2 0 x 1 with the boundary conditions of y 0 5 and y1 2 . Plot to compare the approximate solution with the exact solution obtained by using the DSolve command. 10. Employ the NDSolve command to find the approximate solution of the boundary value problem governed by the second-order homogeneous differential equation with variable coefficients, 1 x 8 x 2 y xy x 2 y 0 The boundary conditions are y 1 1 and y 8 0 . Plot to compare the approximate solution with the exact solution obtained by using the DSolve command. 11. Employ the NDSolve command to find the approximate solution of the boundary value problem governed by the second-order homogeneous differential equation with variable coefficients, 1 x 3 x 2 y xy y 0
309
Exercises
The boundary conditions are y1 1 and y 3 4 . Plot to compare the approximate solution with the exact solution obtained by using the DSolve command. 12. Employ the NDSolve command to find the approximate solution of the boundary value problem governed by the second-order homogeneous differential equation with variable coefficients, 1 x 64 6 x 2 y x y y 0 The boundary conditions are y1 2 and y 64 12 . Plot to compare the approximate solution with the exact solution obtained by using the DSolve command. 13. Employ the NDSolve command to find the approximate solution of the boundary value problem governed by the second-order nonhomogeneous differential equation with variable coefficients, x y y x 5 1 x 2 The boundary conditions are y 1 1 2 and y2 4 . Plot to compare the approximate solution with the exact solution obtained by using the DSolve command. 14. Employ the NDSolve command to find the approximate solution of the boundary value problem governed by the second-order nonhomogeneous differential equation with variable coefficients, x 2 y x y 3 y 3x
1 x 2
The boundary conditions are y1 1 and y 2 5 . Then, use the DSolve command to check whether Mathematica can provide an exact solution. If it can, plot to compare the approximate solution with the exact solution. If it cannot, plot to show only the approximate solution.
310
Chapter 9 Boundary Value Problems
15. Employ the NDSolve command to find the approximate solution of the boundary value problem governed by the second-order nonhomogeneous differential equation with variable coefficients, y x y x 2 y 2x 3
0 x 1
The boundary conditions are y0 1 and y 1 1 . Then, use the DSolve command to check whether Mathematica can provide an exact solution. If it can, plot to compare the approximate solution with the exact solution. If it cannot, plot to show only the approximate solution. 16. Employ the NDSolve command to find the approximate solution of the boundary value problem governed by the second-order nonhomogeneous differential equation with variable coefficients, 2x 2 y 2 y 2 y x 2 1 0 x 1 x 1 x 1 The boundary conditions are y (0) 2 and y (1) 5 3 . Plot to compare the approximate solution with the exact solution of,
y
x 4 3x 2 x2 6 2
17. Employ the NDSolve command to find the approximate solution of the boundary value problem governed by the second-order nonhomogeneous differential equation with variable coefficients, 2x 2 y 2 y 2 y x 2 1 0 x 1 x 1 x 1 The boundary conditions are y (0) y (0) 0 and y(1) y(1) 3 . Plot to compare the approximate solution with the exact solution of,
y
x 4 3x 2 x 1 6 2
311
Exercises
18. Employ the NDSolve command to find the approximate solution of the boundary value problem governed by the second-order homogeneous nonlinear differential equation, y y y 2 0
0 x 1
with the boundary conditions of y0 1 and y1 2 . Then, use the DSolve command to check whether Mathematica can provide an exact solution. If it can, plot to compare the approximate solution with the exact solution. If it cannot, plot to show only the approximate solution. 19. Employ the NDSolve command to find the approximate solution of the boundary value problem governed by the second-order homogeneous nonlinear differential equation,
y 2 y y 0
1 x 2
with the boundary conditions of y 1 1 and y 2 1 2 . Then, use the DSolve command to check whether Mathematica can provide an exact solution. If it can, plot to compare the approximate solution with the exact solution. If it cannot, plot to show only the approximate solution. 20. Employ the NDSolve command to find the approximate solution of the boundary value problem governed by the second-order homogeneous nonlinear differential equation, y y ( y) 2 0
0 x 1
with the boundary conditions of y0 1 and y 1 2 . Plot to compare the approximate solution with the exact solution of,
y
3x 1
21. Employ the NDSolve command to find the approximate solution of the boundary value problem governed by the second-order homogeneous nonlinear differential equation,
y 2 y y 0
0 x 1
312
Chapter 9 Boundary Value Problems
with the boundary conditions of y0 1 and y 1 1 2 . Plot to compare the approximate solution with the exact solution of,
y 1 x 1 22. Employ the NDSolve command to find the approximate solution of the boundary value problem governed by the second-order homogeneous nonlinear differential equation, y x y2 0
0 x2
with the boundary conditions of y 0 2 and y 2 4 . Plot to compare the approximate solution with the exact solution of,
y
cot 1 x 2
23. Derive the exact solutions of the following boundary value problems, (a) y 2 y 3 y 2 y 2 x 2 sin x y0 0 , y0 1 , y 2 0
0 x 2
(b) y 3 y 10 y 24 y 24 x 2 20 x 18 y0 1 , y 0 0 , y1 2
0 x 1
0 x2 (c) y 3 y 2 y 16e 3 x 6 2 6 2 y0 2 , y 2 e e , y2 3e e (d) y y 8 y 12 y 4 sin x 36 cos x 12 y0 0 , y 0 , y 4
0 x
Verify the solutions with those obtained from using the DSolve command. In each sub-problem, employ the Plot command to plot the solution of y that varies with x within the given domain.
313
Exercises
24. Derive the exact solutions of the following boundary value problems,
0 x 1 (a) y IV 2 y y 9e 2 x 2 2 y 0 3 , y 0 2 , y 1 e 2 , y1 2e 2 0 x (b) y IV 10 y 16 y 7 sin x 48 y 0 3 , y0 1 , y 3 , y 1 0 x5 (c) y IV y 1 y0 2 , y0 1 , y 5 e5 1 , y5 e5 (d) y IV 8 y 24 y 32 y 16 y 16 x 2 48 x 32 0 x2 y0 1 , y0 1 , y2 7 , y 2 5 Verify the solutions with those obtained from using the DSolve command. In each sub-problem, employ the Plot command to plot the solution of y that varies with x within the given domain. 25. Use the DSolve command to find the exact solution of the boundary value problem governed by the third-order homogeneous differential equation,
d3y d 2 y dy 2 2y 0 dx3 dx 2 dx
0 x 1
with the boundary conditions of y 0 0, y 0 0 and y 1 1 . Plot the solution of y that varies with x by using the Plot command. Repeat the problem but by employing the NDSolve command to solve for the approximate solution. Plot to compare the approximate solution with the exact solution. 26. If the differential equation in preceding problem becomes nonlinear,
d3y d 2 y dy 2 2 y2 0 3 dx dx dx
0 x 1
314
Chapter 9 Boundary Value Problems
with the same boundary conditions of y 0 0, y 0 0 and y1 1 , use the DSolve command to check whether it can find the exact solution. If it cannot, employ the NDSolve command to find the approximate solution and plot to show its variation. 27. Employ the NDSolve command to find the approximate solution of the boundary value problem governed by the thirdorder nonhomogeneous nonlinear differential equation,
y
d 3 y dy dx3 dx
2x
0 x 1
with the boundary conditions of y0 1, y 0 0 and y1 2 . Plot to compare the approximate solution with the exact solution of,
y
x2 1
28. The velocity profile of a laminar boundary layer flow over a flat plate can be found by solving the third-order homogeneous nonlinear differential equation,
2
d3y d2y 0 y dx3 dx 2
0 x 1
with the boundary conditions of y 0 0, y 0 0 and y1 1 . Employ the NDSolve command to find the approximate velocity profile y that varies with the depth x in the interval of 0 x 1 . 29. A simply-support beam of a unit length is subjected to a uniform loading as shown in the figure. The deflection y(x) along the beam length in the x-direction can be found by solving the fourth-order nonhomogeneous differential equation, d4y 1 0 x 1 dx 4
315
Exercises
with the boundary conditions of y0 y0 y1 y1 0 . Employ the NDSolve command to find the approximate solution of y that varies with x. Plot to compare the approximate solution with the exact solution of,
y
x 4 x3 x 24 12 24
x
1
30. The deflection y of a cantilever beam subjected to an axial force P as shown in the figure is governed by the fourth-order nonhomogeneous differential equation,
d4y d2y 1 dx 4 dx 2
0 x 1
with the boundary conditions of y 0 y0 y 1 y1 0 . Employ the NDSolve command to find the approximate deflection of y that varies with x along the beam length. Plot to compare the approximate solution with the exact solution that can be found by using the DSolve command.
P x
1
316
Chapter 9 Boundary Value Problems
31. Employ the NDSolve command to find the approximate solution of the boundary value problem governed by the fourth-order nonhomogeneous nonlinear differential equation,
y
d4y d2y y x3 6 x 1 dx 4 dx 2
0 x 1
with the boundary conditions of y 0 1, y0 0, y1 0 and y1 3 . Plot to compare the approximate solution with the exact solution of,
y
x3 1
Then, check whether the DSolve command can find the exact solution above. If it cannot, verify the exact solution by substituting it into the differential equation and boundary conditions via the derivative D and substituting commands, respectively.
Chapter 10 Partial Differential Equations 10.1 Introduction Most scientific and engineering problems are governed by partial differential equations for which the dependent variable u varies with the three coordinates of x, y, z, and time t. Solving the partial differential equations is more difficult than the ordinary differential equations learned earlier in the preceding chapters. Their exact solutions are not available, in general, and numerical methods are used to obtain the approximate solutions. The widely used numerical methods are the finite difference, finite element and finite volume methods. The finite element method is the popular one because it can handle complicated boundary conditions and domain geometries effectively. Mathematica contains a package that uses the finite element method to solve for approximate solutions of the partial differential equations in one, two and three dimensions.
Chapter 10 Partial Differential Equations
318
This chapter begins with the classification of the partial differential equations. The Mathematica finite element package for solving these differential equations is explained. The package is then used to solve the elliptic, parabolic and hyperbolic partial differential equations, respectively. Exact solutions for simple domain geometries are derived so that the finite element solutions can be compared to measure their accuracy. More complicated examples, for which their exact solutions are not available, are then used to demonstrate the efficiency of the finite element method implemented in the package.
10.2 Classification of Partial Differential Equations The partial differential equations in two-dimensional forms are simple and easy to understand. The unknown dependent variable u is function of x- and y- coordinates and may be time t. These partial differential equations are normally classified into three types: (a) Elliptic equation,
u u c c a u x x y y
f
(b) Parabolic equation,
d and
u u u c c au t x x y y
f
(c) Hyperbolic equation,
m
2u u u c c a u t 2 x x y y
f
where m, d, c, a and f are constants or may be function of x and y. The boundary conditions consist of,
10.3 Finite Element Package
319
(a) Specifying value of the dependent variable u along the boundary (Dirichlet condition),
hu r where h and r are constants or function of x and y. (b) Specifying gradient value of the dependent variable u along the boundary (Neumann condition),
c
u qu g n
where c, q and g are constants or function of x and y. The letter n denotes a unit vector normal to the boundary. Solving the elliptic equation does not need the initial condition while the parabolic equation needs an initial condition of u x, y,0 at time t 0 . The hyperbolic equation needs two initial conditions of u x, y,0 and u x, y,0 t at time t 0 .
10.3 Finite Element Package The finite element method is used to solve the partial differential equations. The main advantage of the method is its flexibility for modelling arbitrary geometry easily. The problem domain is first divided into small elements connected at nodes where the unknowns are located. The finite element equations for each element are derived from the governing differential equation of the problems. These finite element equations are assembled together to form a set of simultaneous algebraic equations. The boundary conditions are then imposed prior to solving for solutions of the unknowns at nodes. A finite element software can be developed after understanding the finite element procedure above. A software package was developed and implemented in Mathematica. By using few commands, simple geometry with small elements can be generated automatically. After the differential equation, boundary and initial conditions are provided, the package performs
320
Chapter 10 Partial Differential Equations
calculation to give the solutions at nodes. These solutions can be displayed in many ways by using the current Mathematica plotting capability. The package is thus idealized for beginners to study the finite element method. Examples in the following sections show how to use necessary commands that are built in the finite element package to solve the elliptic, parabolic and hyperbolic differential equations in one and two dimensions. For problems with simple geometry, exact solutions are also derived so that accuracy the finite element solutions can be evaluated. These examples thus demonstrate advantages of the finite element method for solving problems with complex geometry.
10.4 Elliptic Equations The elliptic partial differential equation in two dimensions is in the form, u u c c a u f x x y y where c, a and f are constants or function of x and y. The partial differential equations in the elliptic form above arise in many applications. These include steady-state heat transfer, potential flow, cross-sectional stress in a bar under torsion, electric potential, underground seepage flow, etc. We will use the finite element package in Mathematica to solve for the solution of u(x,y) from the elliptic differential equation with specified boundary conditions. It is noted that quadratic elements are the default element type used in the package. Example Use the finite element package to solve the elliptic differential equation in one dimension,
2u 8 0 x 2
0 x 1
with the boundary conditions of u(0) 0 and u(1) 1. Discretize the domain into 4 linear elements with equal length. Show all commands used and the mesh with node and element numbers. Compare the finite element solution with the exact solution of,
10.4 Elliptic Equations
321
u ( x) x(5 4 x) Repeat solving the problem with a refined mesh of 16 elements. The commands below define the domain 0 x 1 , discretize the domain into two-node linear elements, plot the elements with node and element numbers on them, define the differential equation, specify the boundary conditions, solve for nodal solutions, and plot to compare with the exact solution. The analysis is repeated using 16 quadratic elements with the element length of 0.25. As shown in the figures, the finite element solution approaches the exact solution when the mesh is refined. Needs "NDSolve`FEM`" ; ImplicitRegion True, x, 0, 1 ; mesh1 ToElementMesh , MaxCellMeasure 0.25, "MeshOrder" Show mesh1 "Wireframe" "MeshElementIDStyle" Red , mesh1 "Wireframe" "MeshElementIDStyle" Blue, "MeshElement" "PointElements"
1 ode
1
2
2
3
3
4
4
5
x,x u
x 8 0; DirichletCondition u x 0, x 0 , D 1, x 1 ; DirichletCondition u x mesh1 ; sol1 NDSolveValue ode, D , u, x exact x 5 4 x ; Plot sol1 x , exact , x, 0, 1 , PlotRange All, PlotStyle Directive Blue, Thick , Directive Red, Dashed
1.5
Exact F.E.
1.0
u ( x) 0.5
0.2
0.4
x
0.6
0.8
1.0
1 ;
Chapter 10 Partial Differential Equations
322
mesh2 ToElementMesh , MaxCellMeasure 0.25 ; sol2 NDSolveValue ode, D , u, x mesh2 ; Plot sol2 x , exact , x, 0, 1 , PlotRange All, Directive Blue, Thick , Directive Red, Dashed PlotStyle
1.5
Exact
1.0
u ( x)
F.E.
0.5
0.2
0.4
x
0.6
0.8
1.0
Example Use the finite element package to solve the elliptic differential equation in one dimension,
2u 2u 2 2 sin( x) x 2
0 x 1
with the boundary conditions of u(0) 0 and u (1) 0. Discretize the domain into 4 linear elements with equal length. Compare the finite element solution with the exact solution of,
u ( x) sin( x) Repeat solving the problem with a refined mesh of 16 elements. This example is similar to the preceding one except the differential equation is more complicated. The three terms in the differential equation lead to different finite element matrices. These matrices take time to derive if they are carried out by hands. This example thus demonstrates efficiency of the package that can provide solution in a short time.
10.4 Elliptic Equations
323
Needs "NDSolve`FEM`" ; ImplicitRegion True, x, 0, 1 ; mesh1 ToElementMesh , MaxCellMeasure 0.25, "MeshOrder" 1 ; Show mesh1 "Wireframe" "MeshElementIDStyle" Red , mesh1 "Wireframe" "MeshElementIDStyle" Blue, ; "MeshElement" "PointElements" 2 u x 2 2 Sin x 0; ode x,x u x DirichletCondition u x 0, x 0 , D 0, x 1 ; DirichletCondition u x mesh1 ; sol1 NDSolveValue ode, D , u, x exact Sin x ; Plot sol1 x , exact , x, 0, 1 , PlotRange All, Directive Blue, Thick , Directive Red, Dashed PlotStyle
Exact
1.0
0.8
F.E.
0.6
u ( x) 0.4
0.2
0.2
0.4
x
0.6
0.8
1.0
mesh2 ToElementMesh , MaxCellMeasure 0.25, "MeshOrder" mesh2 ; sol2 NDSolveValue ode, D , u, x Plot sol2 x , exact , x, 0, 1 , PlotRange All, Directive Blue, Thick , Directive Red, Dashed PlotStyle 1.0
Exact
0.8
0.6
u ( x)
F.E.
0.4
0.2
0.2
0.4
x
0.6
0.8
1.0
2 ;
Chapter 10 Partial Differential Equations
324
Example Use the finite element package to solve the elliptic partial differential equation, 2u 2u 0 x 2 y 2 for the solution of u ( x, y ) in a rectangular domain with the boundary conditions as shown in the figure. y u sin x 2
1
u=0
u=0
x u=0 2
It is noted that the exact solution for this problem which is derived in the next example is, sin x 2 sinh y 2 u x, y sinh 2 By comparing coefficients of the governing differential equation with the standard form of the elliptic differential equation, we find that c 1 , a 0 and f 0 . This problem is equivalent to a steady-state heat conduction in a rectangular plate with the size of 2 1 . Zero temperature (u 0) is specified along the left, right and bottom edges while the temperature is u sin x 2 along the top edge. Commands for using the finite element package to solve this problem are shown below. The rectangular domain of the plate is first defined. The domain is then discretized by using the linear 3-node triangular elements with the approximate size of 0.005. The governing differential equation is provided with the specified
10.4 Elliptic Equations
325
boundary conditions along the four edges. The finite element analysis is performed to yield solutions at nodes. Variations of the computed solutions are displayed by the contour and carpet plots. Needs "NDSolve`FEM`" ; ImplicitRegion True, x, 0, 2 , y, 0, 1 ; mesh1 ToElementMesh , MaxCellMeasure 0.005, "MeshOrder" mesh1 "Wireframe"
pde
2 x,y
u x, y
1 ;
0;
0 x 2 y 0 , x DirichletCondition u x, y Sin ,y 1 ; 2 sol1 NDSolveValue pde, D , u, x, y mesh1 ; ContourPlot sol1 x, y , x, y mesh1, ContourShading Automatic, ColorFunction "Rainbow", PlotLegends Automatic, AspectRatio Automatic D
DirichletCondition u x, y
0, x
The exact solution in the preceding example can be derived by using the method of separation of variable. Detailed derivation of the exact solution is presented in the following example.
Chapter 10 Partial Differential Equations
326
Example Derive the exact solution of the elliptic differential equation which is in form of the Laplace equation,
2u 2u x 2 y 2
0
for a rectangular domain with dimensions of w as shown in the figure. The boundary conditions along the four edges are,
u0, y 0 ,
u, y 0
u x,0 0 ,
u x, w
y
w u0
f x
u f x
2u 2u 0 x 2 y 2
u0
u0
x
The method of separation of variables is applied by first assuming that the solution is in the product form of the functions X x and Y y , u x, y X x Y y By substituting the assumed solution into the differential equation, we obtain, X Y X Y 0 where the prime symbol ( ) denotes the derivative order. The equation above can be written as,
10.4 Elliptic Equations
327
1 d2X X dx 2
1 d 2Y Y dy 2
Since X is only function of x while Y is only function of y, then both sides of this equation must be equal to a constant, 1 d2X X dx 2
1 d 2Y Y dy 2
2
Thus, the given partial differential equation becomes two ordinary differential equations which should be solved easier. If we consider the first ordinary differential equation, d2X 2 X dx 2
0
Its general solution is in the form of sine and cosine functions,
X x Asin x B cos x where A and B are constants. These two constants are determined as follows. Since the left edge boundary condition is u0, y 0 , then X 0 Y y 0 , or X 0 0 , so that B 0 . Similarly, the right edge boundary condition is u, y 0 , then X Y y 0 , or X 0 . Then, X x above becomes,
X 0 Asin But A cannot be zero, thus,
n
and
n
where n is an integer. Hence, in general,
n which are called the eigenvalues.
n
n 1, 2, 3, ...
Similarly, if we consider the second ordinary differential equation,
Chapter 10 Partial Differential Equations
328
d 2Y 2 Y 0 dy 2 which has the general solution of,
Y y E sinh y F cosh y where E and F are constants. The constant F is determined from the bottom edge boundary condition of u x,0 0 , i.e., X x Y 0 0 . Then Y 0 0 , which leads to F 0 . Thus, the general solution of the partial differential equation is,
u x, y X x Y y A sin x E sinh y u x, y C sin x sinh y
Or,
where C AE denotes a new constant. Since there are n values of , i.e, 1 , 2 , 3 , ..., n , thus, the general solution can be written in the summation form for n values of as,
C
u x, y
n 1
n
sin n x sinh n y
The constants Cn are determined from the top edge boundary condition at y w as,
u x, w
f x
C n 1
Or,
D n1
n
sin n x
n
sinh n w sin n x
f x
where Dn Cn sinh n w . This means, once we obtain Dn from the above equation, we can find Cn and also the exact solution of
u x, y .
To solve for Dn , we multiply both sides of the equations
by sinm x where m denotes an integer, and perform integration from to as follows,
10.4 Elliptic Equations
n 1
329
n x m x Dn sin sin dx
f x sin
m x dx
But from the integration formula,
sin
, m n n x m x sin dx 0, m n
which is known as the orthogonal properties. Then, the equation above reduces to,
Dn
f x sin
n x dx
Dn
Or,
1 n x f x sin dx
2
f x sin 0
n x dx
But Dn Cn sinh n w Cn sinh n w , therefore, Cn
2 n w sinh
f x sin 0
n x dx
Hence, the exact solution of this problem is, u x, y
n y 2 sinh n x sin n w n 1 sinh
f x sin 0
n x dx
For the special case in the preceding example, if
f x sin
x 2
with the domain sizes of 2 and w 1 , the integral in the exact solution reduces to,
0
n x f x sin dx
2
0
sin
x 2
sin
1, n 1 n x dx 2 0, n 1
Chapter 10 Partial Differential Equations
330
Thus, the exact solution of the preceding example is,
Or,
u x, y
y 2 sinh 2 x sin 2 2 sinh 2
u x, y
sin x 2 sinh y 2 sinh 2
This exact solution can be plotted to show the distribution u x , y by using the Plot3D command as follows, of uexact
Sin
x 2 Sinh Sinh 2
y 2
;
Plot3D uexact, x, 0, 2 , y, 0, 1 , AxesLabel x, y, "u x,y " , ColorFunction ViewPoint 1.8, 2.4, 0.5
White & ,
Distribution of the exact solution u x, y is shown in the figure.
Exact solution The finite element solution obtained from the preceding example can also be plotted by using the same Plot3D command with additional Mesh option as shown in the figure. Plot3D sol1 x, y , Element x, y , mesh1 , x, y, "u x,y " , ColorFunction AxesLabel 1.8, 2.4, 0.5 , Mesh All ViewPoint
White & ,
10.4 Elliptic Equations
331
Finite element solution Example Use the finite element package to solve the elliptic partial differential equation, 2u 2u 3 2 2 5u 8 y x for a domain with complicated geometry and boundary conditions as shown in the figure. The problem statement is equivalent to the two-dimensional steady-state heat transfer in a plate. The plate material has its thermal conductivity coefficient of 3 units and is subjected to surface convection with the convection coefficient of 5 units. The plate is also subjected to a surface heating with the magnitude of 8 units. The temperatures along the upper and lower edges vary linearly with x while all other edges are insulated.
u 3 x y
1
u 0 n
.5
x
nˆ
1
nˆ
u 0 n
1
1
1 u 1 x
0.5 0.5
The file below contains commands to create the domain geometry and discretize it into a number of linear triangular
Chapter 10 Partial Differential Equations
332
elements as shown in the figure. The governing differential equation and the boundary conditions are specified. The finite element analysis is then performed to give the solutions at nodes. These solutions are displayed by using contour plot as shown in the figure. The entire process is quite convenient. The mesh can be refined to improve the solution accuracy. Parameters in the partial differential equation including boundary conditions can be changed to increase understanding the solution behaviors. Needs "NDSolve`FEM`" ; 1 RegionUnion Disk 0, 0 , 1 , Rectangle 0, 1 , 3, 1 ; 2 RegionDifference 1, Disk 0, 0 , .5 ; 3 RegionDifference 2, Rectangle 2.5, .5 , 3.1, .5 ; RegionDifference 3, Polygon 1, 0 , 2, .5 , 2, .5 ; mesh1 ToElementMesh , MaxCellMeasure 0.005, "MeshOrder" 1 ; mesh1 "Wireframe" pde
3
2 x,y
u x, y
5 u x, y
8
0;
DirichletCondition u x, y 1 x, y 1 , D DirichletCondition u x, y 3 x, y 1 ; sol1 NDSolveValue pde, D , u, x, y mesh1 ; ContourPlot sol1 x, y , x, y mesh1, Contours 20, ContourShading Automatic, ColorFunction "Rainbow", PlotLegends Automatic, AspectRatio Automatic
10.5 Parabolic Equations
333
10.5 Parabolic Equations The parabolic partial differential equation in two dimensions is in the form,
u u u c c au f t x x y y where d , c , a and f are constants or may be function of x and y. The parabolic equation is more complicated than the elliptic equation because of an additional independent variable of t. Finding the exact solution is more difficult, especially for domain with arbitrary geometry. The finite element package in Mathematica can alleviate such difficulty by finding the approximate solution instead. d
Example Use the finite element package to solve the parabolic differential equation in one dimension, u 2u 0 x , t 0 t x 2 with the boundary conditions of u (0, t ) u ( , t ) 0 and the initial condition of, u ( x, 0) sin x 2sin(2 x) Discretize the domain into 10 elements with equal length. Plot to compare the finite element solution with the exact solution of, u ( x, t ) e t sin x 2e 4t sin(2 x ) at t 0.1 and 0.5 . The file below contains commands to create the domain, discretize the domain into 10 linear elements, display the finite element model with node and element numbers, define the differential equation with the boundary and initial conditions solve the problem from t 0 to 1 . The finite element solutions at t 0.1 and t 0.5 are compared with the exact solutions as shown in the figures. The comparisons indicate that the nodal errors increase with time. More accurate solution can be obtained by refining the mesh or by using higher-order elements. As mentioned
Chapter 10 Partial Differential Equations
334
earlier, the quadratic element is the default element type used in the Mathematica finite element package. Needs "NDSolve`FEM`" ImplicitRegion True, ToElementMesh
mesh1
x, 0,
;
,
, "MeshOrder" 1 ; 10 Show mesh1 "Wireframe" "MeshElementIDStyle" Red , mesh1 "Wireframe" "MeshElementIDStyle" Blue, "MeshElement" "PointElements" pde 0; t u t, x x,x u t, x DirichletCondition u t, x 0, x 0 , D 0, x ; DirichletCondition u t, x Sin x 2 Sin 2 x ; ic u 0, x mesh1 ; sol1 NDSolveValue pde, D , ic , u, t, 0, 1 , x MaxCellMeasure
tt Sin x tt .1; exact 2 4 tt Sin 2 x ; , PlotRange All, Plot sol1 tt, x , exact , x, 0, Directive Blue, Thick , Directive Red, Dashed PlotStyle tt Sin x tt .5; exact 2 4 tt Sin 2 x ; , PlotRange All, Plot sol1 tt, x , exact , x, 0, Directive Blue, Thick , Directive Red, Dashed PlotStyle frame Table Plot sol1 t, x , x, 0, , Mesh None, ColorFunction "Rainbow", PlotLegends Automatic, 1.5, 3.0 , t, 0, 1, 1 20 PlotRange Manipulate frame i , i, 20, "time" , 1, Length frame , 1 , SaveDefinitions True
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10 10 11
2.0
Exact 1.5
u ( x, 0.1)
F.E.
1.0 0.5
0.5 0.5
1.0
1.5
x
2.0
2.5
3.0
10.5 Parabolic Equations
335
Exact
0.8
0.6
u ( x, 0.5)
0.4
F.E.
0.2
0.5
1.0
1.5
x
2.0
2.5
3.0
Example Use the finite element package to solve the parabolic partial differential equation in the form,
2
2u u 2 u 3 2 2 8 t y x
for a circular domain with a unit radius. The domain has the specified boundary condition of u 0 along the edge as shown in the figure and the initial condition of u x, y,0 0 at time t 0 . u0
1
The problem statement is equivalent to transient heat conduction in a circular plate with specified zero temperature along the edge and zero initial temperature. The plate material has the
Chapter 10 Partial Differential Equations
336
thermal conductivity coefficient of 3 units and the specific heat of 2 units with a unit of material density. The plate is also subjected to a specified surface heating of 8 units. We can create a finite element model for the entire plate, but due to symmetry of the solution, only the lower half of the plate can be modelled. As shown in the figure, the boundary condition of u 0 is applied along the outer edge. Along the center line, the gradient of u normal to the edge must be equal to zero representing the insulated boundary condition. u 0 n
nˆ
1 u0
The file below contains commands for creating the domain geometry, discretizing it into a number of triangular elements, specifying the differential equation with the boundary and initial conditions, solving the problem, and displaying the solutions. The finite element mesh and the solution at t 0.2 displayed in form of the contour and carpet plots are shown in the figures. Needs "NDSolve`FEM`" ; 1 Disk 0, 0 , 1 ; RegionDifference 1, Rectangle 1., 0. , 1., 1. mesh1 ToElementMesh , MaxCellMeasure 0.01 ; mesh1 "Wireframe" pde D
2 t u t, x, y
3 2x,y u t, x, y
DirichletCondition u t, x, y
8 0, x2
;
0; y2
1
;
ic u 0, x, y 0; sol1 NDSolveValue pde, D , ic , u, t, 0, .2 , x, y mesh1 ; ContourPlot sol1 .2, x, y , x, y mesh1, Contours 15, ContourShading Automatic, ColorFunction "Rainbow", PlotLegends Automatic, AspectRatio Automatic
10.5 Parabolic Equations
337
Plot3D sol1 .2, x, y , Element x, y , mesh1 , AxesLabel x, y, "u x,y,0.2 " , ColorFunction 1.8, 2.4, 0.5 , Mesh All ViewPoint
White & ,
Example Use the finite element package to solve the parabolic partial differential equation,
2u u 2 u 2 2 2 3u t y x
4
Chapter 10 Partial Differential Equations
338
on the 3 2 rectangular domain with small ellipse and rectangular holes inside. The initial condition is u x, y,0 0 while the boundary conditions are shown in the figure. The procedure for solving this problem is similar to that explained the preceding example. However, the domain geometry is more complicated with different types of the boundary conditions as shown in the figure.
nˆ
u 0 n
u x , y ,0 0
nˆ
u0
u0 u 0 n
nˆ u 0 n
nˆ The commands below are used to carry out the analysis of this problem. The computed solutions of u x, y, t at t 0.1 and 0.3 are plotted using contour lines as shown in the figures. Needs "NDSolve`FEM`" ; 1 RegionDifference Rectangle 0, 0 , 3, 2 , Disk 2.2, 1.3 , .4 ; RegionDifference 1, Rectangle .4, .4 , 1.2, 1.1 mesh1 ToElementMesh , MaxCellMeasure 0.004 ; pde D
t u t, x, y
2 2x,y u t, x, y
DirichletCondition u t, x, y DirichletCondition u t, x, y
3 u t, x, y 0, x 0, x
0 , 3 ;
4
; 0;
10.5 Parabolic Equations
339
ic u 0, x, y 0; sol1 NDSolveValue pde, D , ic , u, t, 0, .5 , x, y mesh1 ; ContourPlot sol1 .1, x, y , x, y mesh1, Contours 15, ContourShading Automatic, ColorFunction "Rainbow", PlotLegends Automatic, AspectRatio Automatic ContourPlot sol1 .3, x, y , x, y mesh1, Contours 15, ContourShading Automatic, ColorFunction "Rainbow", PlotLegends Automatic, AspectRatio Automatic Plot3D sol1 .3, x, y , Element x, y , mesh1 , AxesLabel x, y, "u x,y,0.3 " , ColorFunction White & , ViewPoint 1.8, 2.4, 4.0 , Mesh All
t 0 .1
t 0 .3
340
Chapter 10 Partial Differential Equations
Animation of the transient solution u x, y, t can help us to understand the solution behavior clearly. To see the animation, the following commands may be used, frame Table Plot3D sol1 t, x, y , x, y mesh1, ColorFunction "Rainbow", PlotLegends Automatic, Mesh None, PlotRange .01, 1. , t, 0, 0.5, .05 Manipulate frame i , i, 10, "time" , 1, Length frame , 1 , SaveDefinitions True
A sample of the transient solution u x, y at time t 0.3 is shown as a carpet plot in the figure.
This example demonstrates that the finite element method can provide approximate solution to the differential equation with complicated boundary conditions and geometry effectively. The next example shows detailed derivation of the exact solution for the parabolic differential equation with simple boundary conditions and domain geometry. The example will show that the exact solution is not easy to derive even for a simple problem. These two
10.5 Parabolic Equations
341
examples thus highlight benefits of using the finite element method to obtain approximate solutions for complex problems. Example Derive the exact solution of the parabolic partial differential equation,
u 2u u 2 0 t x 2 y 2 for the w rectangular domain as shown in the figure. The boundary conditions are,
u x, 0, t
0,
u x, w, t 0,
0 x
u 0, y, t
0,
u , y, t 0,
0 yw
and the initial condition is,
u x, y, 0
f x, y
t0
y u0
w
u0
u 2u u 2 0 t x 2 y 2 u x, y , 0
u0
f x, y
x u0
Chapter 10 Partial Differential Equations
342
The method of separation of variables is used to solve for the exact solution. We start by assuming the solution u x, y, t as the product of the three functions X x , Y y and T t ,
u x, y, t X x Y y T t By substituting it into the differential equation, we obtain,
X Y T X Y T X Y T 0 where the prime symbol ( ) denotes the derivative order. We divide the equation through by X Y T and move some terms to get,
T Y T Y
X X
Since the terms on the left-hand-side of the equation are only functions of t and y while the term on the right-hand-side of the equation is only function of x, then they must be equal to a constant,
T Y T Y
X X
2
Similarly,
T Y 2 2 T Y Hence, the method of separation of variables changes the given partial differential equation into three ordinary differential equations as,
X 2 X 0,
Y 2Y 0 and T 2 2 T 0
At the same time, the given boundary conditions become,
X 0 0,
X 0,
Y 0 0
and
Y w 0
By using the same procedure as shown in the preceding example of the elliptic differential equation, the eigenvalues and eigenvectors are obtained,
10.5 Parabolic Equations
and
343
m
m ,
X m x
n
n , w
Yn y
m x sin n y sin w
The ordinary differential equation related to the time t is,
T 2 2 T 0 Its general solution is in the form, T
where
Amn e mn t 2
m n w Thus, the general solution is, 2
2 mn 2m n2
u x, y, t
X m 1 n 1
m
A m 1 n 1
mn
2
Yn T m x n y mn2 t sin sin e w
where the constants Amn are determined from the initial condition
of u x, y,0 f x, y by using the orthogonal properties, w
Amn
4 m x n y f x, y sin sin dx dy w 0 0 w
As an example, if the initial condition is,
u x, y,0
f x, y x x 2 y w y
then, the constants Amn are, w
Amn
4 m x n y x x 2 y w y sin sin dx dy w 0 0 w 48 2 w2 1m 1n 1 2 3 m n
Chapter 10 Partial Differential Equations
344
Hence, the exact solution for this particular case is,
u x, y, t
m 1 n 1
48 2 w2
mn
2 3
1m 1n 1
m x n y m2 sin sin e w
2 n2 w2 2t
The exact solution above is in the form of infinite series. We can create a Mathematica file to compute the solution. For example, the file for determining the solution of u x, y, t at t 0.02 for a unit square domain w 1 consists of the following statements, t
0.02; nterms
100;
nterms nterms
48
uexact m 1
mn 2 3
n 1
Sin m
1 m
1 n
x Sin n
y
Plot3D uexact, x, 0, 1 , y, 0, 1 , AxesLabel x, y, "u x,y,0.02 " , ColorFunction White & , ViewPoint 1.8, 2.4, 0.5
1 m 2 n2
2t
;
Plot3D
The same problem is solved by using the finite element package for the approximate solution. The commands used for obtaining the finite element solution are as follows, Needs "NDSolve`FEM`" ; ImplicitRegion True, x, 0, 1 , y, 0, 1 ; mesh1 ToElementMesh , MaxCellMeasure 0.05 ; pde D
ic
2 x,y u t, x, y
t u t, x, y
0;
DirichletCondition u t, x, y 0, x 1 y 0 y 1 ; x 0 u 0, x, y
x 1
x2
y 1
y ;
mesh1 ; sol1 NDSolveValue pde, D , ic , u, t, 0, .02 , x, y Plot3D sol1 .02, x, y , Element x, y , mesh1 , x, y, "u x,y,0.02 " , ColorFunction White & , AxesLabel 1.8, 2.4, 0.5 , Mesh All ViewPoint
10.6 Hyperbolic Equations
345
The exact and finite element solutions are compared in form of the carpet plots as shown in the figures.
Exact solution
Finite element solution
10.6 Hyperbolic Equations The hyperbolic partial differential equation in two dimensions is in the form,
2u u u m 2 c c a u f t x x y y where m, c, a and f are constants or function of x and y. The hyperbolic equation is more complicated than the elliptic and
346
Chapter 10 Partial Differential Equations
parabolic equations. The dependent variable u is function of the independent variables x, y and t. Two initial conditions of u x, y ,0 and u x, y,0 t are needed for solving the problem. In this section, we will use the finite element package to solve the hyperbolic partial differential equation for both simple and complex domains. Example Use the finite element package to solve the hyperbolic differential equation in one dimension,
2u 2u 0 x 1, t 0 t x 2 with the boundary conditions of u (0, t ) u (1, t ) 0 and the initial conditions of, u u ( x, 0) sin(2 x) and ( x, 0) 2 sin(2 x) x Plot to compare the finite element solution with the exact solution of, u ( x, t ) sin(2 x)[sin(2 t ) cos(2 t )] at t 0.2 and 0.4 . The file below contains commands for solving the given one-dimensional hyperbolic partial differential equation with the specified boundary and initial conditions. The domain of a unit length is discretized into 10 quadratic finite elements to provide the solution accuracy. It is noted that quadratic finite elements are the default elements used in the finite element package. If preferred, linear finite elements can be chosen but users need to specify them as shown in the one-dimensional elliptic and parabolic examples. After the differential equation, boundary and initial conditions are provided, the analysis is performed to determine nodal solutions at different times. The computed finite element solutions are compared with the exact solution at t 0.2 and 0.4 as shown in the figures. These figures show that the finite element
10.6 Hyperbolic Equations
347
solutions coincide with the exact solutions. The last two commands at the end of the file are for plotting the finite element solutions at different times and creating animation of the solutions that vary with time. Needs "NDSolve`FEM`" ; ImplicitRegion True,
x, 0, 1
;
1 ; 10 Show mesh1 "Wireframe" "MeshElementIDStyle" Red , mesh1 "Wireframe" "MeshElementIDStyle" Blue, "MeshElement" "PointElements" pde u t, x 0; t,t x,x u t, x DirichletCondition u t, x 0, x 0 , D 0, x 1 ; DirichletCondition u t, x u 0, x Sin 2 x , ic 2 Sin 2 x ; Derivative 1, 0 u 0, x mesh1 ; sol1 NDSolveValue pde, D , ic , u, t, 0, 2 , x Sin 2 x Sin 2 tt Cos 2 tt ; tt .2; exact Plot sol1 tt, x , exact , x, 0, 1 , PlotRange All, Directive Blue, Thick , Directive Red, Dashed PlotStyle tt .4; exact Sin 2 x Sin 2 tt Cos 2 tt ; Plot sol1 tt, x , exact , x, 0, 1 , PlotRange All, Directive Blue, Thick , Directive Red, Dashed PlotStyle frame Table Plot sol1 t, x , x, 0, 1 , Mesh None, ColorFunction "Rainbow", PlotLegends Automatic, 2, 2 , t, 0, 2, 2 10 PlotRange Manipulate frame i , i, 10, "time" , 1, Length frame , 1 , SaveDefinitions True mesh1
ToElementMesh
, MaxCellMeasure
Exact 1.0 0.5
u ( x, 0.2) 0.5 1.0
F.E. 0.2
0.4
x
0.6
0.8
1.0
Chapter 10 Partial Differential Equations
348
0.2
0.1
F.E.
u ( x, 0.4)
0.2
0.4
x
0.6
0.8
1.0
Exact
0.1
0.2
Example Use the finite element package to solve the hyperbolic partial differential equation in the form,
2u 2u 2u 0 t 2 x 2 y 2 for a 2 2 unit square domain. The boundary conditions are u 0 on the left and right edges while u y 0 on the top and bottom edges as shown in the figure. y u 0 y 1, 1 1, 1
u0
u0
1, 1
u 0 y
1, 1
The initial conditions are,
u x, y,0 tan1 cos x 2 u x, y,0 t 4 sin x esin y 2
x
10.6 Hyperbolic Equations
349
The file below consists of commands for defining the domain geometry, discretizing it into a number of quadratic triangular elements with element size of approximately 0.01 unit, plotting the mesh, specifying the governing differential equation with boundary and initial conditions, solving for the nodal solutions at different times, displaying the solutions in form of carpet plots at time t 10 and 20 , generating an animation file, and displaying the solution as a carpet plot at time t 20 . Needs "NDSolve`FEM`" ; ImplicitRegion True, x, 1, 1 , y, 1, 1 ; mesh1 ToElementMesh , MaxCellMeasure 0.01 ; mesh1 "Wireframe" pde D
ic
t,t u t, x, y
2 x,y u t, x, y
DirichletCondition u t, x, y DirichletCondition u t, x, y x u 0, x, y ArcTan Cos , 2 Derivative 1, 0, 0
u
0, x, y
0; 0, x 0, x
1
4 Sin
1 , ;
x
Sin
y 2
;
sol1 NDSolveValue pde, D , ic , u, t, 0, 20 , x, y mesh1 ; ContourPlot sol1 10, x, y , x, y mesh1, Contours 15, ContourShading Automatic, ColorFunction "Rainbow" ContourPlot sol1 20, x, y , x, y mesh1, Contours 15, ContourShading Automatic, ColorFunction "Rainbow" frame Table Plot3D sol1 t, x, y , x, y mesh1, Mesh None, ColorFunction "Rainbow", PlotLegends Automatic, 2.5, 2.5 , t, 0, 20, 20 20 PlotRange Manipulate frame i , i, 20, "time" , 1, Length frame , 1 , SaveDefinitions True Plot3D sol1 20, x, y , Element x, y , mesh1 , AxesLabel x, y, "u x,y,20 " , ColorFunction White & , 1.5, 2.5, 1.5 ViewPoint
The contour plots of the finite element solutions at t 10 and 20 are shown herein. The solution at t 20 is also shown as a carpet plot.
Chapter 10 Partial Differential Equations
350 t 10
t 20
Example Use the finite element package to solve the hyperbolic partial differential equation,
5
2u 2u 2u 3u 4 x2 y 2 t 2
2
for a unit square domain with two small holes inside as shown in the figure. The boundary conditions are u 0 on the left and right edges, and u y 0 on the top and bottom edges while u n 0 along inner edges of the holes. The two initial conditions are,
10.6 Hyperbolic Equations
351
u x, y,0 tan1 cos x 2 u x, y,0 t 4 sin x esin y 2 y
1, 1
u 0 y
1, 1
u0
nˆ
x
u0
nˆ
1, 1
1, 1
u 0 y
Since this example is similar to the preceding one except the differential equation and the two holes inside the domain, we can follow the same procedure to solve the problem. The file below consists of commands similar to those used in the preceding example except the element size of approximately 0.002 unit to provide accurate solution. Needs "NDSolve`FEM`" ; 1 RegionDifference Rectangle 1, 1 , 1, 1 , .45, .45 , .27 ; Disk RegionDifference 1, Disk 0.35, 0.35 , .37 ; mesh1 ToElementMesh , MaxCellMeasure 0.002 ; mesh1 "Wireframe" pde D
ic
5 t,t u t, x, y 4 DirichletCondition DirichletCondition u 0, x, y ArcTan Derivative 1, 0, 0
2 x,y u t, x, y
u t, x, y u t, x, y Cos x 2 u
0, x, y
3 u t, x, y
0, x 0, x ,
2
0;
1 , 1 ;
4 Sin
x
Sin
y 2
;
Chapter 10 Partial Differential Equations
352
sol1 NDSolveValue pde, D , ic , u, t, 0, 40 , x, y mesh1 ; mesh1, Contours 15, ContourPlot sol1 10, x, y , x, y ContourShading Automatic, ColorFunction "Rainbow" ContourPlot sol1 40, x, y , x, y mesh1, Contours 15, ContourShading Automatic, ColorFunction "Rainbow" frame Table Plot3D sol1 t, x, y , x, y mesh1, Mesh None, ColorFunction "Rainbow", PlotLegends Automatic, 4, 4 , t, 0, 40, 40 20 PlotRange Manipulate frame i , i, 20, "time" , 1, Length frame , 1 , SaveDefinitions True Plot3D sol1 22, x, y , Element x, y , mesh1 , PlotRange 4, 3 , x, y, "u x,y,22 " , ColorFunction White & AxesLabel
The finite element mesh, the solution contours at time t 10 and 40 are shown herein. The solution at t 22 is also shown as a carpet plot.
Finite element mesh with 2,619 quadratic triangular elements and 5,452 nodes
t 10
t 40
10.6 Hyperbolic Equations
353
To highlight the advantage of using the finite element method to solve for approximate solution of the hyperbolic problem, we will use the example below to show the derivation of exact solution for a very simple problem. We will see that the derivation is rather lengthy and complicated. Example Derive the exact solution of the hyperbolic partial differential equation,
2u 2u u 2 0 t 2 x 2 y 2 for a rectangular domain with the dimensions of w as shown in the figure. The boundary conditions are,
u x, 0, t
0,
u x, w, t 0 ,
0 x
u 0, y, t
0,
u , y, t 0 ,
0 yw
and the initial conditions are,
u x, y, 0
f x, y ,
u x, y,0 0 t
t0
The method of separation of variables is again used to derive the exact solution. We first assume the exact solution
Chapter 10 Partial Differential Equations
354 y
u0
2u 2u u 2 0 t 2 x 2 y 2 w u0
u x, y , 0
f x, y
u0
u x, y , 0 0 t
x
u0
u x, y, t in form of the product of the three functions X x, Y y and T t as, u x, y, t X x Y y T t By substituting it into the differential equation, we obtain,
X Y T X Y T X Y T 0 where the prime symbol ( ) denotes the derivative order. We divide the equation through by X Y T and move some terms to get,
T Y T Y
X X
Since the terms on the left-hand-side of the equation are only functions of t and y while the term on the right-hand-side of the equation is only function of x, then they must be equal to a constant,
10.6 Hyperbolic Equations
355
X T Y 2 X T Y T Y 2 which leads to, 2 T Y Hence, the method of separation of variables changes the partial differential equation into three ordinary differential equations as,
X 2 X 0 , Y 2Y 0
and T 2 2 T 0
while the boundary conditions become,
X 0 0 ,
X 0 ,
Y 0 0
and
Y w 0
The process leads to the eigenvalues and the eigenvectors similar to those explained in the elliptic and parabolic problems, m m x m X m x sin , n n y n Yn y sin and , w w The ordinary differential equation for the time t is,
T 2 2 T 0 The general solution of this differential equation is in the form of sine and cosine functions. But after applying the initial condition of u x, y,0 t 0 , the solution is only in the form of cosine function as, T t Amn cos mnt 2 2 m n 2 mn m2 n2 w
where
Thus, the general solution of the partial differential equation is,
u x, y, t
X m 1 n 1
m
A m 1 n 1
mn
Yn T m x n y sin sin cos mn t w
Chapter 10 Partial Differential Equations
356
where the constant Amn can be determined from the initial
condition of u x, y,0 f x, y by using the orthogonal properties as explained in the preceding examples. These constants Amn are, w
Amn
4 m x n y f x, y sin sin dx dy w 0 0 w
As an example, if the initial condition is,
u x, y,0
f x, y x x y w y
then, the constants Amn are, w
Amn
4 m x n y x x y w y sin sin dx dy w 0 0 w 16 2 w 2 1m 1 1n 1 2 3 m n
So that the exact solution for this case is,
u x, y, t
m 1 n 1
16 2 w2
mn
2 3
1
m
1 1 1 n
m x n y sin sin cos mnt w The exact solution above is in the form of infinite series. To solve for the solution of u x, y, t at t 0.35 for a unit square domain w 1 , a Mathematica file can be created with commands as follows, t
0.35; nterms
100;
nterms nterms
uexact m 1
n 1
Sin m
16 mn 2 3
x Sin n
1 m
y Cos
1
m2
1 n
n2
1
2 t
;
10.6 Hyperbolic Equations
Plot3D uexact, x, 0, 1 , y, 0, 1 , White & , Mesh 25, ColorFunction ViewPoint 1.8, 2.4, 0.4
357
Plot3D
The same problem is solved by using the finite element package. The approximate solution obtained from the finite element package is compared with the exact solution in the form of carpet plot as shown in the figures. The comparison indicates that the finite element method in Mathematica can provide accurate approximate solution by agreeing very well with the exact solution.
u x, y, 0.35
Exact solution
u x, y, 0.35
Finite element solution
358
Chapter 10 Partial Differential Equations
10.7 Concluding Remarks In this chapter, we learned three types of the partial differential equations which are in the elliptic, parabolic and hyperbolic forms. We solved these partial differential equations for their solutions in both one and two dimensions. Exact solutions can be derived only for simple differential equations with plain boundary conditions and geometry. For more complicated problems, we have to employ the numerical methods to solve for approximate solutions. Mathematica contains the finite element package to solve these problems for approximate solutions. The package solves the partial differential equations that are in different forms. The boundary conditions may be complicated and the geometry could be arbitrary. The process starts from discretizing the problem domain into a number of small elements. These elements are connected at nodes where the unknowns are located. The finite element equations are derived for each element and assemble together to form up a set of simultaneous equations. The boundary conditions are then imposed on the set of equations before solving them for the solutions at nodes. Several examples are used to show derivation of exact solutions for simple problems and to find approximate solutions for more complicated ones. The results have demonstrated that the finite element package in Mathematica can provide approximate solutions with high accuracy if the finite element meshes are refined with small elements. These results highlight the advantages of using the finite element method for solving partial differential equations with complicated boundary conditions and domain geometries.
Exercises
359
Exercises 1.
Use the finite element package to solve the elliptic differential equation in one dimension,
d 2u u sin x dx 2
0 x 2
with the boundary conditions of u (0) u ( 2) 0. Discretize the domain into 2, 5 and 10 linear elements. Plot to compare the finite element solutions with the exact solution of, x u ( x) cos x 2 Repeat solving the problem but by using the quadratic element. Provide comments on the improved solution accuracy. 2.
Use the finite element package to solve the elliptic differential equation in one dimension,
d 2u 6u 10 x dx 2
0x2
with the boundary conditions of u (0) u (2) 0. Discretize the domain into 2, 5 and 10 linear elements. Plot to compare the finite element solutions with the exact solution of, u ( x)
5x (sin 6 x)(3cos 6 x 10) cos 6 x 3 3sin(2 6)
Repeat solving the problem but by using the quadratic element. Provide comments on the improved solution accuracy. 3.
Use the finite element package to solve the elliptic differential equation in one dimension,
d du (1 2 x) 1 4 x x 2 dx dx
0 x 1
Chapter 10 Partial Differential Equations
360
with the boundary conditions of u (0) u (1) 0. Discretize the domain into 2, 5 and 10 linear elements. Plot to compare the finite element solutions with the exact solution of,
5ln(1 2 x) x3 11x 2 x 9 ln 3 18 24 24 Repeat solving the problem but by using the quadratic element. Provide comments on the improved solution accuracy. u ( x)
4.
Use the finite element package to solve the parabolic differential equation in one dimension,
u t
2u x 2
0 x 1, t 0
with the boundary conditions of u (0, t ) u (1, t ) 0 and the initial condition of u ( x,0) 0. Discretize the domain into 5 and 10 linear elements. Plot to compare the finite element solutions with the exact solution of, u ( x, t ) 1 x
sin(n x)e n 2
1
n2 2t
n 1
at t 0.1 , 0.2 and 0.5 respectively. Repeat solving the problem but by using the quadratic elements to show the improved solution accuracy. 5.
Use the finite element package to solve the parabolic differential equation in one dimension,
u 2u t x 2
2
0 x 1, t 0
with the boundary conditions of u (0, t ) u (1, t ) 0 and the initial condition of,
u ( x, 0) sin( x) x(1 x) Discretize the domain into 5 and 10 linear elements. Plot to compare the finite element solutions with the exact solution of,
Exercises
361
u ( x, t ) sin( x)e t x(1 x) 2
at t 0.3. Repeat solving the problem but by using the quadratic elements to show the improved solution accuracy. 6.
Use the finite element package to solve the hyperbolic differential equation in one dimension,
2u 2u 0 x 1, t 0 t 2 x 2 with the boundary conditions of u (0, t ) u (1, t ) 0. The two initial conditions are, u u ( x, 0) sin( x) and ( x, 0) 0 t Discretize the domain into 5 and 10 linear elements. Plot to compare the finite element solutions with the exact solution of, u ( x, t ) sin( x) cos( t ) at t 2 and 5. Repeat solving the problem but by using the quadratic elements to show the improved solution accuracy. 7.
Use the finite element package to solve the hyperbolic differential equation in one dimension,
2u 2u 0 x , t 0 2et sin x t 2 x 2 with the boundary conditions of u (0, t ) u ( , t ) 0. The two initial conditions are, u u ( x, 0) sin x and ( x, 0) sin x t Discretize the domain into 5 and 10 linear elements. Plot to compare the finite element solutions with the exact solution of, u ( x, t ) e t sin x
at t 1 and 4. Repeat solving the problem but by using the quadratic elements to show the improved solution accuracy.
Chapter 10 Partial Differential Equations
362
8.
Use the finite element package to solve the elliptic partial differential equation,
2 u 2u x 2 y 2
0
for a unit square domain of 0 x 1 and 0 y 1 with the boundary conditions of,
u x,0 0 ,
u x,1 1
0 x 1
u0, y 0 ,
u1, y 0
0 y 1
Plot to compare the solution with the exact solution of,
u x, y
sin n x sinh n y n 1,3 ,5 ,... n sinh n 4
9. If the boundary condition along the right edge of the square domain in Problem 8 is changed to,
u1, y 1
0 y 1
use the finite element package to solve the problem again. Plot to compare the solution with the exact solution if it can be derived. 10. Use the finite element package to solve the elliptic partial differential equation,
2u 2u x 2 y 2
1
for a unit square domain of 0 x 1 and 0 y 1. The four edges have the specified boundary conditions of u 0 . Plot to compare the solution with the exact solution of,
u x, y
16 sin i x sin j y π 4 i,j i3 j 2 i 2 j 3 1,3 ,5 ,...
Exercises
363
11. If there is a circular hole with radius of 0.2 at the center of the square domain in Problem 10, use the finite element package to solve the problem again when the hole edge has the: (a) Dirichlet boundary condition of u 0 and (b) Neumann boundary condition of u n 0 . Plot to compare the two solutions in form of the carpet plot. 12. Use the finite element package to solve the elliptic partial differential equation,
2 u 2u x 2 y 2
0
for a unit square domain of 0 x 1 and 0 y 1 with the boundary conditions of,
u x,0 0 , u x,1 x u0, y 0 , u1, y y
0 x 1
0 y 1
Plot to compare the solution with the exact solution of u x, y xy . 13. Use the finite element package to solve Problem 12 again if the differential equation is changed to,
2u 2u 5 2 2 7u 10 y x Explain the physical meaning of the solution which is different from that obtained in Problem 12. 14. Use the finite element package to solve the elliptic partial differential equation,
2 u 2u x 2 y 2
0
for a unit square domain of 0 x 1 and 0 y 1 with the boundary conditions of,
Chapter 10 Partial Differential Equations
364
u x,0 1 ,
u x,1 u x,1 2 y
0 x 1
u u 1, y 0 0 y 1 0, y 0 , x x Plot to compare the solution with the exact solution of, y u x, y 1 2 15. Use the finite element package to solve Problem 14 again if the differential equation is changed to,
2u 2u 2 2 5u 9 y x Plot the solution u x, y in form of the carpet plot. 16. Use the finite element package to solve the elliptic partial differential equation,
2u 2u x 2 y 2
x2 y 2 e x y
for a rectangular domain with the size of 2 1 units, i.e., 0 x 2 and 0 y 1. The boundary conditions are,
u x, 0
1,
u x, 1 ex ,
0 x2
u 0, y
1,
u 2, y e2 y ,
0 y 1
Plot to compare the solution with the exact solution of,
u x, y exy 17. Use the finite element package to solve the elliptic partial differential equation,
2u 2u 2x x3 6xy 6 xy2 1 x 2 y 2
Exercises
365
for a unit square domain of 0 x 1 and 0 y 1. The four edges have the specified boundary conditions of u 0 . Plot to compare the solution with the exact solution of,
u x, y
x x4 y y 2
18. Use the finite element package to solve the elliptic partial differential equation,
2u 2u 20 x 2 y 2 for a circular domain with a unit radius. The boundary condition along the edge is u 0 . Compare the solution with the exact solution of u x, y 5 1 x2 y 2 ,
y
x
1
19. Use the finite element package to solve Problem 18 again if the circular domain contains a small circular hole with radius of 0.3 unit and a square hole with dimension of 0.2 0.2 units as shown in the figure. The boundary conditions for the edges of the circular hole and square hole are u 0 and u n 0 , respectively. Plot the solution u x, y in form of the carpet plot.
Chapter 10 Partial Differential Equations
366
y
1 x .4
.4
20. Use the finite element package to solve the elliptic partial differential equation,
2u 2u x 2 y 2
0
for a square domain with the size of 8 8 units. The domain contains a circular hole with the radius of 2 units at its center as shown in the figure. If the boundary conditions of the hole and the outer boundary of the domain are u 100 and u 0 , respectively, solve for the solution of u x, y . Then, plot the solution in form of the carpet plot.
Exercises
367
y
u0
u 100
u0 x
8
2 u0 u0 8
21. Due to symmetry of the solution in Problem 20, only the upper right quarter of the domain as shown in the figure can be used for the analysis. Solve the problem again with the boundary conditions as shown in the figure. Plot the solution in form of the carpet plot.
y u0 u 0 n u0
2
u 100 u 0 n
x
Chapter 10 Partial Differential Equations
368
22. Use the finite element package to solve the elliptic partial differential equation which is in form of the Helmholtz equation, 2u 2u a x, y u f x, y x 2 y 2 for a unit square domain of 0 x 1 and 0 y 1. The four edges have the specified boundary conditions of u 0 . Find the solution if a 2 and
f x, y xy x2 71 y 2 1 x2 y 2 7 Plot to compare the solution with the exact solution of,
u x, y
x x3 y y 3
23. Use the finite element package to solve the parabolic partial differential equation,
u 2 u 2 u 0 t x 2 y 2 for a rectangular domain with the dimensions of 0.3 units, i.e., 0 x and 0 y 0.3 . The boundary conditions along the four edges are u n 0 and the initial condition is,
u x, y,0
co s x
Plot to compare the solution with the exact solution of,
u x, y, t et cos x when t 0.2 . 24. Use the finite element package to solve the parabolic partial differential equation,
u 2u 2u 2 t x 2 y 2
Exercises
369
for the rectangular domain of 0 x 1 and 0 y 0.2 . The boundary conditions are shown in the figure. The initial condition is,
u x, y,0 sin x x1 x Plot to compare the solution with the exact solution of,
u x, y, t e 2t sin x x1 x when t 0.1 . Study the solution behavior from animation in the form of carpet plot.
y u n 0
u0
0 .2 u 0
x
u n 0 1 .0
25. Solve Problem 24 again when the domain contains two square holes and a circular hole as shown in the figure. The boundary conditions along the edges of the holes are u n 0 . Provide comments on the solution behavior which is different from that obtained in Problem 24.
y
0.1
0.1
0.1
0 .2 0 .1 0.25
0.25
0.25 1 .0
0.25
x
Chapter 10 Partial Differential Equations
370
26. Use the finite element package to solve the parabolic partial differential equation, u 2u 2u 0 t x 2 y 2 for the rectangular domain of 0 x 1 and 0 y 0.2 with the boundary conditions of,
u x,0, t y
0,
u x,0.2, t 0 , y
0 x 1
u0, y, t
1,
u1, y, t 0 ,
0 y 0.2
and the initial condition of,
u x, y,0 1 x
1
sin 2 x
Plot to compare the solution with the exact solution of,
u x, y, t 1 x
1
e 4 t sin2 x 2
when t 0.01, 0.02 and 0.05 . 27. Use the finite element package to solve the parabolic partial differential equation,
7
u 2u 2u 4 2 2 3 u 12 t y x
for the 4 4 unit square domain with two holes as shown in the figure. The boundary conditions along the outer four edges are u 0 . The initial condition is given by u x, y,0 0 . Find the solutions at t 0.2, 0.5 and 1 .0 when the boundary conditions along the hole edges are: (a) u 0 and (b) u n 0 . Plot the solutions in form of the carpet plot.
Exercises
371
y 1 .2 1 .2 .5
4 .7
1 .5
x 1 .5
4
28. Use the finite element package to solve the hyperbolic partial differential equation,
2u 2u 2 u 0 t 2 x 2 y 2 for the domain of 0 x 1 and 0 y 0.2 with the boundary conditions as shown in the figure. The initial conditions are,
u x, y,0 sin x
and
u x, y,0 0 t
Plot to compare the solution with the exact solution of,
u x, y, t sin x cos t when t 1.0 and 2.0 .
Chapter 10 Partial Differential Equations
372
y u n 0
u0
0 .2 u 0
x
u n 0 1 .0
29. Solve Problem 28 again if the rectangular domain contains three small circular holes as shown in the figure. The boundary conditions along the hole edges are u n 0 . Compare the solution with that obtained in Problem 28 by plotting it in form of the carpet plot.
y
.07
0 .2
.07
.07
0 .1
x 0.25
0.25
0.25
0.25
1 .0
30. Use the finite element package to solve the hyperbolic partial differential equation,
2 u 2u 2 u t 2e sin x t 2 x 2 y 2 for a rectangular domain of 0.3 units, i.e., 0 x and 0 y 0.3 with the boundary conditions of,
u x,0, t 0 , y
u x,0.3, t 0 y
u0, y, t 0 ,
u , y, t 0
0 x
0 y 0.3
Exercises
373
and the initial conditions of,
u x, y,0 sin x
and
u x, y,0 sin x t
Plot to compare the solution with the exact solution of,
u x, y, t et sin x when t 0.2 and 0.5 . 31. Use the finite element package to solve the hyperbolic partial differential equation,
2u 2u 2 u 0 t 2 x 2 y 2 for a rectangular domain of 1 0.2 units, i.e., 0 x 1 and 0 y 0.2 with the boundary conditions of,
u x,0, t 0, y
u x,0.2, t 0 y
u0, y, t 0,
u1, y, t 0
0 x 1
0 y 0.2
and the initial conditions of,
u x, y,0 sin2 x and
u x, y,0 2 sin2 x t
Plot to compare the solution with the exact solution of,
u x, y, t sin 2 x sin 2 t cos 2 t when t 0.3 and 0.6 . 32. Use the finite element package to solve the hyperbolic partial differential equation,
3
2u 2u 2u 2u 5 x 2 t 2 y 2
4
Chapter 10 Partial Differential Equations
374
for a rectangular domain of 6 4 units with the boundary conditions along the outer edges as shown in the figure. The boundary conditions along the hole edges are u n 0 . The initial conditions are given by,
u x, y,0 0
and
u x, y,0 t
0
Find the solutions for the interval of 0 t 1 . Display the solutions at t 0.3, 0.5 and 1.0 in form of the carpet plot. y
3
u n 0
.75 .75 2.5
u0
4
.75 u 1
1.5 u n 0
6
x 2
Chapter 11 Special Functions 11.1 Introduction Special functions often occur while solving mathematical problems in science and engineering. These special functions include the error functions, Gamma functions, Beta functions, Bessel functions, Airy functions and Legendre functions. These functions are in various forms of the infinite series as well as in the integral forms. In the past, their values could not be determined conveniently, so many textbooks have to provide them as tables in appendices. Mathematica contains commands for determining these functions. The commands can be implemented in a program to work together with other numerical methods for solving the entire problem. This chapter begins with the definitions of special functions that are generally encountered in mathematics. The Mathematica commands for determining these functions are
376
Chapter 11 Special Funcions
presented by using examples. The examples demonstrate high efficiency of these commands for determining values of the special functions.
11.2 Error Functions The error function occurs during solving many forms of differential equations in scientific and engineering problems. The definition of the error function is, x
2
erf x
t e dt 2
0
As an example, the exact solution of the initial value problem governed by the first-order ordinary differential equation and the initial condition, dy 2x y 2 dx
;
is,
y 0 1
y x e x 1 erf x 2
where erf x denotes the error function evaluated at x. The exact solution above can be obtained by using the DSolve command, DSolve y x
y' x x2
1
2xy x
2, y 0
1 ,y x ,x
Erf x
DSolve
The solution of y that varies with x can be plotted by using the Plot command for the interval of 0 x 1 as shown in the figure. Plot y x
. , x, 0, 1 , PlotStyle
Black
377
11.2 Error Functions
7 6
y e x 1 erf ( x) 2
5
y ( x)
4 3 2 1 0.2
0.4
0.6
x
0.8
1.0
The error function is determined automatically at any x in the Plot command that contains y x function above to provide the solution for plotting. To determine the error function at any x, e.g. at x 1 , we use the Erf command as follow, N Erf 1
Erf
0.842701
Note that the error function changes moderately from 1 to 1 in the interval of 3 x 3 . Such change, as shown in the figure, can be plotted by using the Plot command. Values of the error function approach 1 and 1 for x 3 and x 3 , respectively. Plot Erf x , x,
3, 3 , PlotStyle
Black
f ( x) 1.0
f erf ( x)
0.5
3
2
1
1
0.5
1.0
2
3
x
378
Chapter 11 Special Funcions
Mathematica also contains the Erfc command to determine the complementary error function with the definition of,
2
erfc x
e
t 2
dt
x
1 erf x As an example, the complementary error function of 1 is, N Erfc 1
Erfc
0.157299
Variation of the complementary error function from 3 to 3 is shown in the figure. f ( x) 2.0
1.5
f erfc( x)
1.0
0.5
3
2
1
1
2
3
x
11.3 Gamma Functions The Gamma function is another function often occurs during solving mathematical problems. The definition of the Gamma function is,
x
t
x 1 t
e dt
0
As an example, the Gamma function when x 1 is,
379
11.3 Gamma Functions
t
1
11 t
e dt
e
t
dt
0
0
et
0 1 1
0
The Gamma function has the special property of,
x 1 x x which can be verified by performing the integrations by parts as follows,
x 1
t
x
e dt t e t
x
t
0
0
xt
x1
1 et dt
0
x t x 1 et dt x x 0
Furthermore, if x is a positive integer, then,
x 1 x!
x = 1, 2, 3, …
This relation helps determining their values easily. For examples, x 0;
0 1 1
0! 1
1;
1 1 2 1! 1
x 2;
2 1 3 2! 2
x
Mathematica contains the Gamma command for finding values of the Gamma function conveniently. For examples, Gamma 1
Gamma
1
Gamma 5 24
The latter result can be verified by 5 4! 4 3 2 1 24 .
380
Chapter 11 Special Funcions
If x is not an integer, the Gamma command can still be used. For examples, Gamma
Gamma 0.71 1.2825
Gamma 4.38 9.86389
We can employ the Plot command to display variation of the Gamma function for 0 x 5 as shown in the figure. Plot Gamma x , x, 0, 5 , PlotStyle
Black
20
15
( x)
10
5
1
2
x
3
4
5
If x is a negative integer, the Gamma function has the value of infinity. For examples, Gamma
1
Gamma
ComplexInfinity
Gamma
5
ComplexInfinity
If x is not an integer but a negative value, The Gamma function has a finite value. For examples,
381
11.3 Gamma Functions
Gamma
0.71
Gamma
4.3664
Gamma
4.38
0.0782076
We can use the Plot command together with the GridLines command to display variation of the Gamma function on background grids in the interval of 5 x 5 as shown in the figure.
Plot Gamma x , x, 5, 5 , PlotStyle Black, GridLines GridLines Automatic ( x)
x
The Gamma function also has other interesting properties,
1 2
1 1 3 5... 2 x 1 x , 2 2x x 1 x 1 22 x 1 x x 2
sin x
2 x
x = 1, 2, 3, …
382
Chapter 11 Special Funcions
which can be verified by the Gamma command. For example, the first property above, Gamma
1 2
Gamma
Mathematica also contains the incomplete Gamma function which is defined by,
a, x
1 a
x
et t a 1 dt
0
where a and x are positive values. As an example, when a 1.5 and x 0.5 , Gamma 1.5, 0.5 0.710091
Variations of the incomplete Gamma function when a 1.5, 2.0 and 2.5 are shown in the figure. Plot
Gamma 1.5, x , Gamma 2.0, x , Gamma 2.5, x x, 0, 5 , PlotStyle Black 1.4 1.2
a 2.5
1.0
( a, x )
0.8
a2
0.6 0.4 0.2
a 1.5 1
2
3
4
5
x
,
383
11.4 Beta Functions
11.4 Beta Functions Definition of the Beta function is given by, 1
t
B x, y
x 1
1 t y 1 dt
0
where x 0 and y 0 . For examples, 1
B1,1
t
11
1 t dt 11
0
t
2 1
1 t dt 11
0
t 0
1
1
t dt
1 2
1 2
0
1
B1,2
dt 0
1
B2,1
1
11
1 t
2 1
1
dt
1 t dt 0
Mathematica contains the Beta command that can be used to determine values of the Beta function conveniently. For examples, the three functions above are obtained by entering, Beta 1, 1
Beta
1
Beta 2, 1 1 2
Beta 1, 2 1 2
Variations of the Beta function with x for y 1, 2 and 3 are shown in the figure.
Plot
Beta x, 1 , Beta x, 2 , Beta x, 3 x, 0, 4 , PlotStyle Black
, Plot
384
Chapter 11 Special Funcions
2.5
2.0
1.5
B ( x, y ) 1.0
y 1
y2
0.5
y3 1
2
3
4
x From the three examples shown above, we found a special property of the Beta function,
B x, y B y, x which can be verified by starting from the definition of the Beta function,
B x, y
1
t
x 1
1 t y 1 dt
0
If we substitute t by 1 s , we obtain,
B x, y
0
1 s
x 1
s y 1 ds
1
1
s
y 1
1 s x 1 ds B y, x
0
In addition, the Beta function can be determined from the Gamma function,
B x, y
x y x y
We can also verify this relation by substituting value of x and y. As an example, when x 1.5 and y 2.5 , then,
B1.5,2.5
1.5 2.5 1.5 2.5
385
11.4 Beta Functions
Beta
Beta 1.5, 2.5 0.19635
Gamma 1.5 Gamma 2.5 Gamma 1.5 2.5 0.19635
The Beta function also represents the integral value of the product between sine and cosine functions in the form, 2
x y 2 cos2 x 1 sin2 y 1 d B x, y x y 0 As an example, if we want to find value of the integral, 2
I 2 cos2 sin3 d 0
which means when x 3 2 and y 2 , we can determine it from,
B1.5,2
1.5 2 3.5
or
as follows, Gamma 1.5 Gamma 2.0 Gamma 1.5 2.0
Gamma
0.266667
The solution above can be confirmed by using the integrating command directly, 2
2
Cos
2
Sin
3
N
0
0.266667
As for another example, if we want to find the solution of the integral, 2
I 2 tan d 0
386
Chapter 11 Special Funcions
We can rewrite this integral in the form, 2
2
sin d 2 cos1 2 sin1 2 d cos 0
I 2 0
which means x 1 4 and y 3 4 . The solution is obtained from,
B1 4 , 3 4
or
1 4 3 4 1 Beta
Beta 0.25, 0.75 4.44288
Gamma 0.25 Gamma 0.75 Gamma 1.00
Gamma
4.44288
Again, the solution can be verified by using the integrating command, 2
2
Tan
N
0
4.44288
11.5 Bessel Functions Solutions of some differential equations are in the form of Bessel functions. The standard form of the differential equation, so called the Bessel differential equation, that yields solution in the form of Bessel functions is,
x 2 y x y x 2 n2 y 0 where n 0 . The general solution is,
y x C1J n x C2Yn x
387
11.5 Bessel Functions
where C1 and C2 are constants that can be determined from the initial conditions. The function J n x is called the Bessel function
of the first kind of order n while the function Yn x is called the Bessel function of the second kind of order n. The Bessel function of the first kind of order n is expressed in the form of infinite series containing the Gamma function as,
J n x
k 0
1k x 2n 2 k k! n k 1
Mathematica has the BesselJ[n,x] command that can determine the Bessel function of the first kind of order of n at the value of x easily. As an example, The Bessel function of the first kind of order zero at x 1 is obtained by typing, BesselJ 0, 1
N
BesselJ
0.765198
J 0 1 0.765198
i.e.,
Variation of the Bessel function of the first kind of order zero is plotted with x by using the Plot command as shown in the figure. Plot BesselJ 0, x , x, 0, 10 , PlotStyle GridLines Automatic
J 0 ( x)
x
Black,
388
Chapter 11 Special Funcions
The Bessel functions of the first kind of order zero, one and two that vary with x are plotted together by using the Plot command as shown in the figure. Plot
BesselJ 0, x , BesselJ 1, x , BesselJ 2, x , x, 0, 10 , PlotStyle Black Plot 1.0
J 0 ( x)
0.8
J1 ( x )
0.6 0.4
J n ( x)
J 2 ( x)
0.2
2
4
6
8
10
0.2 0.4
x The Bessel function of the first kind of order n can be determined from the Bessel function of the first kind of order n by using the relation,
J n x 1 J n x n
As an example, for n 1 and x 2 , the value on the left-hand-side of the equation above is, LHS
BesselJ
1, 2
BesselJ
N
0.576725
which is equal to the value on the left-hand-side of the equation,
RHS
11 BesselJ 1, 2
N
0.576725
Mathematica can find the derivative of the Bessel function symbolically by using the derivative D command. For example,
389
11.5 Bessel Functions
d n J n x J n1 x J n x dx x we enter the commands as follows, D BesselJ n, x , x BesselJ
1
FullSimplify
D
n BesselJ n, x x
n, x
Similarly, Mathematica can also perform integration of the Bessel function symbolically by using the integrating command. For example,
x xn BesselJ n
n
J n 1 x dx x n J n x
1, x
x
FullSimplify
xn BesselJ n, x
The Bessel function of the second kind of order n has the definition of, J x cosn J n x Yn x n sinn The Bessel function of the second kind of order n at any x can be determined from the BesselY[n,x] command. As an example, the Bessel function of the second kind of order zero at x 2 is obtained by entering, BesselY 0, 2
N
BesselY
0.510376
i.e.,
Y0 2 0.510376
The Bessel functions of the second kind of order zero, one and two that vary with x are plotted together by using the Plot command as shown in the figure.
390
Plot
Chapter 11 Special Funcions
BesselY 0, x , BesselY 1, x , BesselY 2, x , x, 0, 10 , PlotStyle Black Plot 0.5
Y0 ( x)
2
Y1 ( x)
Y2 ( x) x
4
Yn ( x)
6
8
10
0.5
1.0
To understand the behavior of the Bessel functions, we study the oscillation of the mass-spring system as shown in the figure. A mass with m 1 is attached to a spring for which its stiffness k varies with time t in k e 0.02t the form, m
y 0 1
k e0.02t The equilibrium condition during oscillation leads to the governing differential equation in the form,
d2y e 0.02t y 0 dt 2 where y is the unknown displacement that varies with time t. The initial conditions are given by a unit displacement and zero velocity at time t 0 as, y 0 1
and
dy 0 0 dt
To solve for the exact solution in form of the Bessel functions, we change the form of the differential equation by letting,
391
11.5 Bessel Functions
0.01t x 100 e
dx e0.01t 0.01x dt
so that, From the chain rule,
dy dy dx dy 0.01x dt dx dt dx
and d2y d dy dx d dy 0.01x 0.01x 2 dx dt dt dx dx dt
0.0001x
d dy x dx dx
x 2 10000e0.02t
Since
e0.02t 0.0001x 2
then,
Thus, the differential equation becomes,
x or,
x2
d dy x x2 y 0 dx dx
d2y dy x x2 y 0 2 dx dx
which is in form of the Bessel differential equation of order zero. The general solution of this differential equation is,
y x C1 J 0 x C2 Y0 x where C1 and C2 are constants that can be determined from the two initial conditions as follows,
and
y t 0 1
or
y x 100 1
dy t 0 0 dt
or
dy x 100 0 dx
The two conditions above lead to a set of two simultaneous equations,
392
Chapter 11 Special Funcions
J 0 100 C1 Y0 100 C2 1 J 0 100 C1 Y0100 C2 0
and
After solving for the two constants of C1 and C2 , we substitute them into the general solution to obtain the exact solution of,
y x 50 J1 100Y0 x Y1 100 J 0 x Then, by substituting x 100 e 0.01t , the exact solution of y can be written in form of time t as, y t 50 J1 100 Y0 100e 0.01t Y1 100 J 0 100e 0.01t
The solution can be determined for the interval of 0 t 100 by creating a file that contains the following commands,
y
50
BesselJ 1, 100 BesselY 0, 100
.01 t
BesselY 1, 100 BesselJ 0, 100
.01 t
Plot y, t, 0, 100 , PlotStyle
Black
;
Plot
The commands generate a plot of the mass movement that varies with time as shown in the figure. The figure indicates that the magnitude of the mass movement increases with time. Such behavior agrees with the fact that the spring stiffness weakens with time.
1.5 1.0 0.5
y (t ) 0.5 1.0 1.5
20
40
60
80
100
t
393
11.5 Bessel Functions
If the sign in front of the third term of the Bessel differential equation changes from positive to negative, the equation is called the modified Bessel differential equation,
x 2 y xy x 2 n2 y 0 The general solution of the modified Bessel differential equation is in the form,
y x C1 I n x C2 Kn x where C1 and C2 are constants that can be determined from the initial conditions. The function I n x is called the modified Bessel
function of the first kind of order n , while the function Kn x is called the modified Bessel function of the second kind of order n .
Mathematica contains the BesselI[n,x] command to determine the modified Bessel function of the first kind of order n at a value of x. The modified Bessel functions of the first kind of order zero, one and two that vary with x are plotted together by using the Plot command as shown in the figure. Plot
BesselI 0, x , BesselI 1, x , BesselI 2, x , x, 0, 4 , PlotRange 0, 4 , 0, 6 , BesselI PlotStyle Black 6
5
4
I 0 ( x)
I n ( x) 3
I1 ( x)
2
I 2 ( x)
1
0 0
1
2
x
3
4
394
Chapter 11 Special Funcions
Similarly, the modified Bessel functions of the second kind of order zero, one and two that vary with x can be plotted together by using the Plot command as shown in the figure. Plot
BesselK 0, x , BesselK 1, x , BesselK 2, x , x, 0, 2 , PlotRange 0, 2 , 0, 3 , BesselK PlotStyle Black 3.0 2.5
K 2 ( x)
2.0
K n ( x)
K1 ( x)
1.5 1.0
K 0 ( x)
0.5 0.0 0.0
0.5
1.0
1.5
2.0
x
11.6 Airy Functions Airy functions are special functions that arise from solving the Airy differential equation,
d2y xy 0 dx 2 The differential equation in the form above occurs while solving some problems in physics. The form looks quite clean but a simple solution is not available. The general solution of the Airy differential equation is, y x C1 Ai x C2 Bi x
where C1 and C2 are constants. The Ai x and Bi x denote the Airy and Bairy functions, respectively. These two functions are,
395
11.6 Airy Functions
Ai x
1
0
Bi x
1 3 dt
cos xt t 3
1 1 1 sin xt t 3 dt exp xt t 3 dt 0 3 0 3 1
Mathematica contains the AiryAi[x] and AiryBi[x] commands for determining the Airy and Bairy functions at any x, respectively. For examples, if we want to determine the Airy function at
x 0 , we type, AiryAi 0
AiryAi
N
0.355028
Or, to determine the Bairy function at x 1, we enter, AiryBi
1
AiryBi
N
0.103997
Variations of the Airy and Bairy functions can be plotted with x as shown in the figure by creating commands as follows, Plot AiryAi x , AiryBi x , x, 15, 5 , Plot PlotRange 15, 5 , 0.5, 1 , PlotStyle Directive Black , Directive Black, Dashed 1.0 0.8
Ai ( x)
0.6 0.4 0.2
15
10
5
5 0.2
Bi ( x)
0.4
x
396
Chapter 11 Special Funcions
Now, we can solve for the solution of the Airy differential equation, d2y 0 x 1 xy 0 dx 2 with the initial conditions of y 0 and y0 . The general solution of the differential equation is, y x C1 Ai x C2 Bi x
where C1 and C2 are constants that can be determined from the two initial conditions as follows, C1 Ai 0 C2 Bi 0 C1 Ai0 C2 Bi0
Results of C1 and C2 are in form of the Airy function at x 0 which can be found by using the AiryAi[0] command. Results of the C1 and C2 can also be written in form of the Gamma functions as, 31 6 C1 1 6 1 3 3 2 3
23 C2 1 3 3 1 3 3 2 3 where the values of the Gamma functions are obtained from the Gamma command. If the initial conditions are given by, y 0 1
and
y0 0
then, C1 and C2 become, C1
31 6
1 3
and
C2
31 3 1 3
Thus, the exact solution y x of the initial value problem governed by the Airy differential equation is,
397
11.7 Legendre Functions
y x
31 6
1 3
Ai x
3 1 3 13
Bi x
The exact solution is plotted and compared with the approximate solution obtained from using the numerical method via the NDSolve command as shown in the figure. y
31 Gamma
6
AiryAi x
1 3
31
3
1 3
Gamma
AiryBi x ;
Table exactsol Table x, y , x, 0, 1, .1 ; plot1 ListPlot exactsol, PlotStyle PointSize .02 , Black ; Clear y ; xy x 0, numsol NDSolve y'' x NDSolve y 0 1, y' 0 0 , y x , x, 0, 1 ; plot2 Plot y x . numsol, x, 0, 1 , PlotStyle Black ; Show plot1, plot2
1.15
Numerical 1.10
y ( x)
Exact
1.05
1.00 0.0
0.2
0.4
x
0.6
0.8
1.0
11.7 Legendre Functions Many problems in the fields of applied mathematics, physics and chemistry are governed by the differential equations in form of the Legendre equation. The Legendre differential equation is,
398
Chapter 11 Special Funcions
2
y
dx
2
1 x 2 d
2x
dy nn 1 y 0 dx
0 x 1
where n = 0, 1, 2, … are positive integers. General solution of the Legendre differential equation consists of the Legendre functions of order n ,
y x C1 Pn x C2 Qn x where C1 and C2 are constants. The Pn x and Qn x are called the Legendre functions of the first and second kind, respectively. These functions are given by, 1 dn 2 Pn x n x 1n n 2 n! dx 1 x 1 Pn x ln 1 x 2
Qn x
and
For example, when n 1, P1 x
1 d 2 x 1 x 21 1! dx
Q1 x
1 x 1 P1 x ln 1 x 2
x 1 x ln 2 1 x
Thus, for n 0 to 5, these functions are,
P0 x 1
;
P1 x
x
P2 x
1 3 x 2 1 2
;
P3 x
1 5 x 3 3 x 2
P4 x
1 35 x 4 30 x 2 3 ; 8
P5 x
1 63 x5 70 x 3 15 x 8
Variations of Legendre functions of the first kind, P0 to P4 are shown in the figure.
399
11.7 Legendre Functions
Pn ( x) 1.0
P0
P1
P3 1.0
0.5
P4
0.5
0.5
0.5
1.0
x
P2
1.0
Similarly, the Legendre functions of the second kind when n 0 to 4 are, x 1 x 1 1 x ; Q1 x 1 ln ln 2 1 x 2 1 x 1 1 x 3 Q2 x x 3 x 2 1 ln 4 1 x 2 1 3 1 x 5 2 2 5 x 3x ln Q3 x x 4 1 x 2 3 1 1 x 35 3 55 35x 4 30 x 2 3 ln x x Q4 x 16 1 x 8 24
Q0 x
Variations of Legendre functions of the second kind, Q0 to Q3 are shown in the figure. Qn ( x) 1.0
Q2 0.5
1.0
Q3
0.5
0.5
Q0
0.5
Q1 1.0
1.0
x
400
Chapter 11 Special Funcions
The Legendre functions Pn x and Qn x above are solutions of the Legendre differential equations. For example, when n 1 , the Legendre differential equation reduces to,
1 x 2 d
2
y 2
2x
dy 2y 0 dx
dx If the boundary conditions are given such that both constants C1 and C2 are equal to one, then the exact solution to this boundary value problem is, y x P1 x Q1 x y x x
or,
x 1 x ln 1 2 1 x
We can verify the validity of this solution by substituting it into the differential equation. This can be easily done by using the symbolic mathematics capability in Mathematica as follows, P1
x; Q1
LHS
1
x 1 x Log 2 1 x 2 x D y, x, 2
1; y
P1
Q1 ;
2 x D y, x
FullSimplify LHS
2 y; D
0
The result obtained is zero which is equal to the right-hand-side of the differential equation. This means the solution containing the Legendre functions P1 x and Q1 x is the solution to the differential equation above. A more complicated Legendre differential equation is the associated Legendre differential equation in the form of,
d2y dy m2 1 x 2 2 x dx nn 1 2 y 0 dx 1 x 2
0 x 1
where n and m are positive integers. If m 0 , the associated Legendre differential equation reduces to the Legendre differential
401
11.7 Legendre Functions
equation. The general solution of the associated Legendre differential equation is,
y x C1Pnm x C2Qnm x where C1 and C2 are constants which are determined from the given boundary conditions. The Pnm x and Qnm x are the associated Legendre functions of the first and second kind, respectively. These functions are in the forms,
and
m Pn x
1m 1 x 2
dm P x m n dx
m Qn x
1m 1 x 2
dm Qn x m dx
m 2
m 2
The associated Legendre function of the first kind has the property of, Pnm x 0
mn
if
For example, when n 1 and m 0, 1 , the associated Legendre functions are,
P10 x
P11 1 x 2
12
and
Variations of P10 and P11 are plotted as shown in the figure. P1m ( x) 1.0
P10
0.5
1.0
0.5
0.5
0.5
P11 1.0
1.0
x
402
Chapter 11 Special Funcions
In Mathematica, the Legendre functions of the first and second kinds of order n at any x are obtained by using the command LegendreP[n,x] and LegendreQ[n,x], respectively. Similarly, the associate Legendre functions of the first and second kinds of order n at any m and x are obtained by using the command LegendreP[n,m,x] and LegendreQ[n,m,x], respectively. The examples below show how to use the above commands to determine values of the Legendre functions at any n, m and x. The Legendre function of the first kind of order n 1 at x 0.5 is obtained by entering, LegendreP 1, 0.5
LegendreP
0.5
Similarly, the Legendre function of the second kind of order n 2 at x 0.5 is determined from, LegendreQ 2, 0.5
LegendreQ
0.818663
The associate Legendre function of the first kind of order n 2 and m 2 at x 0.5 is determined from, LegendreP 2, 2, 0.5
LegendreP
2.25
In the same way, the associate Legendre function of the second kind of order n 2 and m 1 at x 0.5 is obtained from, LegendreQ 2, 1, 0.5
LegendreQ
0.729806
It is noted that, the associated Legendre functions of order n 2 when m 0, 1 and 2 are,
403
11.8 Special Integrals
P20
1 3x 2 1 2
;
P21 3x1 x 2
12
;
P22 31 x 2
Variations of these functions are plotted as shown in the figure. P2m ( x) 3
2
P21 1.0
P22
1
0.5
0.5
P20
1.0
x
1
11.8 Special Integrals Mathematica contains commands for determining several special integrals. Different types of special integrals can be found by searching with the key words of “Special Functions” under the Help menu. In this section, some special integrals normally encountered while solving mathematical problems are presented. The Dawson integral is a special integral that occurs in conduction heat transfer and theory of electric oscillation. The integral is in the form,
F x e x
2
x
t e dt
2
0
The function F x above is the exact solution of the differential equation, dF 2 xF 1 dx
404
Chapter 11 Special Funcions
with the initial condition of F 0 0 . We can verify that the function F x above satisfies the differential equation by substituting it into the left-hand-side of the equation as follows, F LHS
x2
x t2 0
D F, x
t; D
2xF
1
The result is one which is equal to the value on the right-hand-side of the equation. Mathematica has the DawsonF command for determining value of the Dawson integral, F x , at a given x . For example, the Dawson integral at x 1.5 is obtained by typing, DawsonF
DawsonF 1.5 0.428249
Variation of the Dawson integral in the interval of 5 x 5 is plotted by using the command, Plot DawsonF x ,
x,
5, 5 , PlotStyle
Black
as shown in the figure. F ( x) 0.6 0.4 0.2
4
2
2 0.2 0.4 0.6
4
x
405
11.8 Special Integrals
The dilogarithm integral is another special integral normally occurs while solving some mathematical problems. The integral is in a specific form of, 0
f x
x
ln 1 t dt t
We can employ the PolyLog command to determine the dilogarithm integral f x at a given x. For example, values of the dilogarithm integral f x in the interval of 5 x 1 can be plotted as shown in the figure by using the command, Plot PolyLog 2, x ,
x,
5, 1 , PlotStyle
Black
PolyLog
f ( x) 1
5
4
3
2
1
1
x
1
2
The exponential integral is another special integral that arises while solving some mathematical problems. The integral is in the form, e t Ei x dt t x Mathematica contains the ExpIntegralEi[x] command to determine this special integral at a given x. As an example, the exponential integral at x 0.7 is obtained by entering,
406
Chapter 11 Special Funcions
ExpIntegralEi 0.7
ExpIntegralEi
1.06491
Variation of the exponential integral for 1 x 1 is plotted by using the command, Plot ExpIntegralEi x , PlotStyle Black
x,
1, 1 ,
Plot
as shown in the figure. Ei ( x) 2 1
1.0
0.5
0.5
1.0
x
1 2 3 4
The Fresnel integrals are special integrals that contain sine and cosine functions in the form, x
S x
2
2
sin 2 t 0 x
and
Cx
cos 2 t 0
dt dt
Values of the Fresnel integrals, S x and C x , are obtained by using the FresnelS and FresnelC commands. For example, these two special integrals are determined in the interval of 5 x 5 and plotted as shown in the figure by using the commands,
407
11.9 Concluding Remarks
Plot FresnelS x , FresnelC x , 5, 5 , 0.8, 0.8 PlotRange PlotStyle Directive Black , Directive Black, Dashed
x, ,
5, 5 , FresnelS FresnelC
C ( x) 0.5
S ( x) 4
2
2
4
x
0.5
It can be seen from the figure that,
1 2
S (0) C 0
0
S ( ) C ( )
1 2
S () C ()
and
11.9 Concluding Remarks In this chapter, details of special functions and integrals normally arise while solving mathematical problems are presented. The special functions include the error and complementary error functions, the Gamma and incomplete Gamma functions, the Beta functions, the Bessel and modified Bessel functions, the Airy and Bairy functions, and the Legendre and associated Legendre functions. The special integrals presented herein are the Dawson integral, the dilogarithm integral, the exponential integral and the Fresnel integrals. Because these special functions and integrals are in complicated forms, they are tabulated as values and provided in appendices in many mathematical textbooks.
408
Chapter 11 Special Funcions
Mathematica contains commands for determining values of these special functions and integrals conveniently. Several examples are presented to demonstrate how to use these commands. Variations of the special functions and integrals are plotted to display their physical meanings. These commands can be included in a computer program to alleviate difficulty for solving the complete problem. The ability of these commands thus helps us to solve mathematical problems more effectively.
Exercises 1.
Develop a computer program to find values of the error and complementary error functions by using the Erf and Erfc commands. Show these values in form of a table for 3 x 3 with the increment of x 0.05 .
2.
For a small value of x, the error function may be determined from the series, erf x
x3 x5 x7 2 x ........ 3 1 ! 5 2 ! 7 3 !
Compute the percentages of error by comparing the series solutions with those obtained by using the Erf command for x 0.01 , 0.1 and 0.5, respectively. 3.
If x is large, the error function may be determined from the series, 1 1 3 1 3 5 e x 1 2 ........ 2 3 x 2 x 2 x 2 2 x 2 2
erf x 1
Compute the percentages of error by comparing the series solutions with those obtained by using the Erf command for x 1.5 , 2 and 3, respectively.
409
Exercises
4. The error function can be written in form of the Maclaurin series as, n 2 1 x 2 n 1 erf x n 0 n!2n 1
x3 x5 x7 x9 2 ...... x 3 10 42 216 Develop a computer program to determine the error function from the series above. Compare the solutions with those obtained by using the Erf command for x 0.5, 1 and 2, respectively. 5. Use the Gamma command to find the values of, (a) 8.37 (b) 1.5 2.3 (c) 3.64 1.18
(d) 1002
(e) log 0.5
(f) e 1.6
6. If x is a negative non-integer value, use the Gamma command to show that, x 1 x Then, plot the variations of x and x 1 for the interval of 2 x 1 . x
7. Develop a computer program to prove that, 1 1 3 5...2m 1 (a) m 2 2m
1 (b) m 2
1m 2 m 1 3 5...2m 1
(c) m 1m 2 m 3
3 m 1 m 1
where m is any positive integer. Show results for two cases when m 2 and 4.
410
Chapter 11 Special Funcions
8. Plot the variations of x and 1 x functions for 5 x 5 on the same graph. Explain the relation between the two functions. 9. Develop a computer program to show that B x, y B y, x in form of a table and by plotting them in two dimensions, e.g. for 1 x 4 and 1 y 4 . 10. Employ the Beta function to determine the following integrals, 1
(a)
t
1
1 t dt
(b)
0
1
(c)
0
t 1 t dt
1
1 t dt 1 t
0
t dt 1 t
(d)
0
2
2
(e)
2 sin cos d
(f)
0
sin cos d 3
0
Verify the results by comparing with those obtained from numerical integration. 11. Employ the Beta command to show that, (a) B x, x 2
1 2 x
1 B x, , 2
1 1 (b) Bn, n B n , n 2 2
x0
2
4 n 1
n
,
n 1, 2, 3, ...
12. For m 1 and n 2 , show that,
Bm, n
0
t m1 dt 1 t m n
The value on the left-hand-side of the equation is obtained by using the Beta command. The value on the right-hand-side of the equation is determined from numerical integration. Repeat the problem when m 2 and n 3 .
411
Exercises
13. Develop a computer program to determine results of the following series for x = 0.5, 1, 2 and 3. Verify the results by using the BesselJ and BesselI commands x2 x4 x6 (a) J 0 x 1 2 2 2 2 2 2 .... 2 2 4 2 4 6 3 5 x x x x7 ... (b) J1 x 2 22 4 22 42 6 22 42 62 8 x2 x4 x6 (c) I 0 x 1 2 2 2 2 2 2 ... 2 2 4 2 4 6 3 5 x x x x7 2 2 2 2 2 2 ... (d) I1 x 2 2 4 2 4 6 2 4 6 8 14. Use the BesselJ command for the Bessel function of the first kind of order n to show that, (a) J1 2 x
2 sin x x
(c) J 3 2 x
2 x 2 x
sin x cos x x
(d) J 3 2 x
2 x
cos x sin x x
(e)
2 x
3 1 sin x 3 cos x x 2 x
(b) J 1 2 x
J5 2 x
(f) J 5 2 x
cos x
2 x
3 sin x 3 1 cos x 2 x x
15. Use the BesselI command for the modified Bessel function of the first kind of order n to show that,
2 sinh x x
(b) I 1 2 x
2 cosh x x
(a) I1 2 x
412
Chapter 11 Special Funcions
2 x
cosh x sinh x x
(d) I 3 2 x
2 x
sinh x cosh x x
(e) I 5 2 x
1 sinh x cosh x x x x 2
(c) I 3 2 x
(f) I 5 2 x
2
2 x
3
3
3 1 cosh x 3 sinh x x 2 x
16. Use the BesselJ and BesselI commands for the Bessel and modified Bessel functions of the first kind of order n to show that, 2n (a) J n 1 x J x J n 1 x x n 2n (b) I n 1 x I n 1 x I x x n when n = 1, 2, 3 and x = 0.5, 1, 2, 3. 17. Develop a computer program by using the Bessel function with BesselJ command and the modified Bessel function with BesselI command to show that, (a) sin x 2 J1 x J 3 x J 5 x ... (b) cos x
J 0 x 2 J 2 x 2 J 4 x ...
(c) sinh x 2I1 x I 3 x I 5 x ... (d) cosh x I 0 x 2 I 2 x I 4 x I 6 x ... 18. Use the Bessel functions with BesselJ, BesselY and BesselI commands to show that, when x is very large x 0 , the Bessel functions below can be approximate by, (a) J n x
2 n cos x 2 4 x
413
Exercises
(b) Yn x
2 n sin x 2 4 x
(c) I n x
ex 2 x
19. Use the symbolic mathematics derivative D command to find derivatives of the following Bessel functions, 1 (a) J n x J x J n 1 x 2 n 1 (b) x J n x x J n 1 x n J n x (c) x J n x n J n x x J n 1 x (d)
d n x J n x dx
(e)
d n x J n x dx
x n J n 1 x
x n J n 1 x
(f) J n x
1 J x 2 J n x J n 2 x 4 n2
(g) J n x
1 J x 3 J n 1 x 3 J n 1 x J n 3 x 8 n 3
20. Use the symbolic mathematics derivative D command to find derivatives of the Bessel functions for validating the following relations, 1 (a) I n x I x I n 1 x 2 n 1 (b) x I n x x I n 1 x n I n x (c) x I n x x I n1 x n I n x (d)
d n x I n x dx
x n I n1 x
(e)
d n x I n x dx
x n I n 1 x
414
Chapter 11 Special Funcions
21. Use the integrating command to symbolically integrate, (a)
x J x dx
(c)
J a x dx
(b)
0
(d)
0
0
(e)
0
2 0
x dx
1
xJ
J 3x dx 0
0
J 2 3x dx x
(f)
e
x
J 0 2 x dx
0
where a is a constant. 22. Use the symbolic mathematics integrating command together with the Bessel function BesselJ, BesselY and BesselI commands to show that, (a) J 0 x
1
(b) Y0 x (c) I 0 x
1
cos x sin d 0
2
cos x cosh d 0
cosh x sin d 0
when x 0.5 , 1 , 2 and 3 . 23. In a mass-spring system, the mass and spring stiffness are,
m 1
and
k e0.02t
The governing differential equation representing the mass motion y t is,
d2y e0.02t y 0 dt 2 If the initial conditions are, y 0 1
and
dy 0 0 dt
415
Exercises
solve the initial value problem above for solution in form of the Bessel functions. Plot the solution of the displacement y t that varies with time t. Explain the physical meanings of the solution. 24. Use the AiryAi and AiryBi commands to show that, as x , then, 1 2 Ai x x
1 4
2 1 32 sin x 4 3
2 1 32 cos x 4 3 In the opposite way, as x , then, 1 2 Bi x x
Ai x
1 4
1 1 2 1 4 2 x 3 2 x e 2
Bi x 1 2 x 1 4e 2 x
3
32 3
25. Solve the Airy differential equation, d2y xy 0 dx 2
0 x2
with the boundary conditions of y 0 0 and y0 1 . Plot to compare the exact solution y x with the approximate solution obtained from solving the same boundary value problem by the numerical method. The NDSolve command may be used in the process for obtaining the approximate solution. 26. Employ the LegendreP and Gamma commands to validate the relation below for the Legendre function of the first kind at x 0 and n 1, 2, 3. P2 n 0
1n n 1 2 n 1
416
Chapter 11 Special Funcions
27. Given the Legendre function of the first kind, 1 dn 2 x 1n 2 n! dx n
Pn x
n
Use the symbolic mathematics capability in Mathematica to find their derivatives, P1 x , P2 x and P3 x . Then, plot their variations in the interval of 1 x 1 . 28. Given the Legendre function of the second kind, 1 x 1 P x ln 1 x 2 n
Qn x
Use the symbolic mathematics capability in Mathematica to find the Legendre function in terms of x when n = 0, 1, 2, 3 and 4. Then, plot their variations in the interval of 1 x 1 . 29. Use the symbolic mathematics capability in Mathematica to show that,
P x dx
n
Pn 1 x Pn 1 x 2n 1
when n 1 , 2 and 3 . 30. Use the symbolic mathematics capability in Mathematica to verify the orthogonal properties of the Legendre functions, 1
P x P x dx
n
0
n
1
1
and
P x
2
n
dx
1
when , n 1 , 2 and 3 .
2 2n 1
n
417
Exercises
31. Develop a computer program to show that the Fresnel integrals can be expressed in form of the infinite series, x
S x
sin 2 t
2
0
dt
1n 22 n 1 x 4 n 3 2n 1! 4n 3 n 0
x
Cx
cos 2 t 0
2
dt
1n 22 n x 4 n 1 2n ! 4n 1 n 0
Verify the computer program when x 4 , 2 , 0 , 1 , 3 by comparing the computed results with those obtained from using the FresnelS and FresnelC commands. Also compare the results with the numerical integration solutions by using the NIntegrate command.
Bibliography Abell, M. L. and Braselton, J. P., Mathematica by Example, Fourth Edition, Elsevier, San Diego, 2009. Borwein, J. M. and Skerritt, M. P., An Introduction to Modern Mathematical Computing with Mathematica, Springer, London, 2012. Boyce, W. E. and DiPrima, R. C., Elementary Differential Equations and Boundary Value Problems, Ninth Edition, John Wiley & Sons, New York, 2009. Bronson, R. and Costa, G. B., Differential Equations, Schaum’s Outline Series, Third Edition, McGraw-Hill, New York, 2009. Cheung, C. K., Keough, G. E., Gross, R. H. and Landraitis, C., Getting Started with Mathematica, Third Edition, John Wiley and Sons, New York, 2009. Dechaumphai, P., Finite Element Method: Fundamentals and Applications, Alpha Science International, Oxford, 2010. Don, E., Mathematica, Schaum’s Outline Series, Second Edition, McGraw-Hill, New York, 2009. Edwards, C. H. and Penny, D. E., Elementary Differential Equations, Sixth Edition, Pearson Education, New Jersey, 2008. Hazrat, R., Mathematica: A Problem-Centered Springer-Verlag, London, 2010.
Approach,
Hoste, J., Mathematica DeMystified, McGraw-Hill, New York, 2009.
420
Calculus and Differential Equations with Mathematica
Hunt, B. R., Lipsman, R. L., Osborn, J. E., Outing, D. A. and Rosenberg, J. M., Differential Equations with Mathematica, Third Edition, John Wiley and Sons, New York, 2009. Jeffrey, A., Advanced Engineering Mathematics, Academic Press, San Diego, 2002. Kreyszig, E., Advanced Engineering Mathematics, Tenth Edition, John Wiley and Sons, New York, 2011. Mangano, S., Mathematica Cookbook, O’Reilly Media, Sebastopol, 2010. Nagle, R.K., Saff, E. B. and Snider, A. D., Fundamentals of Differential Equations, Eighth Edition, Pearson, New York, 2012. O’Neil, P. V., Advanced Engineering Mathematics, Seventh Edition, Cengage Learning, Stamford, 2012. Pinsky, M., Partial Differential Equations and Boundary-Value Problems with Applications, American Mathematical Society, Providence, 2010. Prem, K., Partial Differential Equations and Mathematica, CRC Press, Boca Raton, 1997. Ricardo, H. J., A Modern Introduction to Differential Equations, Second Edition, Elsevier, San Diego, 2009. Ruskeepaa, H., Mathematica Navigator: Mathematics, Statistics and Graphics, Third Edition, Elsevier, San Diego, 2009. Simmons, G. F. and Krantz, S. G., Differential Equations: Theory, Techniques and Practice, McGraw-Hill, Singapore, 2007. Spiegel, M. R., Lipschutz, S., Liu, J., Mathematical Handbook of Formulas and Tables, Schaum’s Outline Series, Fourth Edition, McGraw-Hill, New York, 2012. Thomas, G. B. Jr., Calculus, Eleventh Edition, Pearson, New Jersey, 2005.
Bibliography
421
Torrence, B. F. and Torrence, E. A., The Student’s Introduction to Mathematica, A Handbook for Precalculus, Calculus, and Linear Algebra, Second Edition, Cambridge University Press, Cambridge, 2009. Varberg, D., Purcell, E. J. and Rigdon, S. E., Calculus, Ninth Edition. Pearson, New Jersey, 2007. Wagon, S., Mathematica in Action, Problem Solving Through Visualization and Computation, Third Edition, Springer, St. Paul, 2010. Wellin, P., Programming with Mathematica, Second Edition, Cambridge University Press, Cambridge, 2013. Wolfram, S., The Mathematica Book, Fifth Edition, Wolfram Media, Champaign, 2003. Wrede, R. and Spiegel, M. R., Advanced Calculus, Schaum’s Outline Series, Third Edition, McGraw-Hill, New York, 2010. Zill, D. G., A First Course in Differential Equations with Modeling Applications, Tenth Edition, Brooks/Cole, Boston, 2012.
Index Airy function, 394, 415 Amplitude, 260 Bairy function, 394, 415 Beam, 297, 315 Bessel function, 386, 411 derivative, 389, 413 first kind, 387, 391 modified first kind, 393 modified second kind, 393 second kind, 387, 391 Beta function, 383, 410 property, 384 Boundary condition, 319, 324 Dirichlet, 319 Neumann, 319 Boundary Value Problem, two-point, 286 Calculus, 19 Comment statement, 7 Complex number, 142 conjugate, 148, 193 Computational time, 33 Condition, 66 boundary, 287, 302 initial, 81, 85, 92, 135, 148, 164, 186, 233 Cycle, 260
Damping coefficient, 238, 242 Derivative, 27, 32, 43 first-order, 3 higher-order, 33 partial, 34 second-order, 3, 33 Determinant, 131, 184 Differential equation, 59 Airy, 61, 394 associated Legendre, 400 Bernoulli, 109, 126 Bessel, 61, 386, 393 characteristics, 60 coefficient, 87, 130, 182 coupled, 61, 246 exact equation, 95 first-order, 4, 64, 79, 118 fourth-order, 186, 237, 297 higher-order, 181, 295 homogeneous, 61, 64, 130, 182, 286 Legendre, 61, 397 linear, 61, 68, 87 nonhomogeneous, 61, 67, 150, 198, 236, 294 nonlinear, 61, 64, 69, 83, 118, 301, 316 ordinary, 62, 70 partial, 62, 317
424
Calculus and Differential Equations with Mathematica
Riccati, 113, 126 second-order, 4, 60, 129, 168, 236, 290 separable equation, 80 solution, 62, 66 special equation, 107 stiff equation, 118, 128 third-order, 182, 199, 295 variable coefficient, 300 Differentiation, 26 Domain, frequency, 260 rectangular, 324, 341, 354 time, 260 Eigenvalues, 327, 342, 355 Eigenvectors, 342, 355 Equation, auxiliary, 130 characteristic, 130, 137, 146, 185, 200, 287 roots of, 130, 182, 287 Error function, 376, 408 complementary, 378 Euler’s formula, 143, 193, 263, 288 Finite element, 317 color contours, 325, 337 element, 319, 334 linear, 320, 334 mesh, 321, 325, 332 node, 319, 334 one-dimensional, 320, 333, 346 package, 319 quadratic, 321, 347
two-dimensional, 324, 335, 348 Fourier transform, 259, 263 definition, 260, 263 derivative, 275 discrete, 272 fast, 272 inverse, 269 Frequency, 260, 273 Function, 3, 36, 43, 98 Airy, 68 Bairy, 68 Bessel, 68 cosine, 43, 70, 260 Dirac delta, 238, 256, 277 exponential, 5, 43, 63, 131, 137, 184, 222, 263, 291 Heaviside, 242, 256, 276 linearly independent, 131, 184 periodic, 260,272 sine, 43, 70, 260 special, 375 Gamma function, 378, 384 incomplete, 382 Heat conduction, steady-state, 324 unsteady, 335 Hertz, 273 Icon, Abort Evaluation, 7 Evaluation, 7 Exit, 7 File, 7 New Document, 6
Index
Imaginary unit number, 263 Initial condition, 319, 338, 346 Integral, 4, 38, 222 Dawson, 403 definite, 41 dilogarithm, 405 exponential, 405 Fresnel, 406, 417 indefinite, 40 special, 403 Integrating constant, 5, 36, 83 Integration, 2, 35 by parts, 223 formulas, 36 three-dimensional, 42 two-dimensional, 42 Laplace transform, 221, 225 definition, 222 inverse, 228, 234, 240 Legendre function, first kind, 398, 416 orthogonal property, 416 second kind, 398, 416 Limit, 20, 26, 41 Magnitude, 261 Mass, 238, 242 Mathematica, fundamentals, 6 history, 5 input command, 6 notebook, 6 output command, 6 working file, 6 Mathematica command, AbsoluteTiming, 33
425
AiryAi, 395 AiryBi, 395 ArcSin, 9 ArcTan, 40, 349 BesselI, 393 BesselJ, 387 BesselK, 394 BesselY, 389 Beta, 383 CForm, 188 Clear, 116, 168 ContourPlot, 332, 339 Cos, 9, 38, 117 Cosh, 85, 226 D, 27, 63, 140, 184, 303 DawsonF, 404 Derivative, 347, 351 Det, 132, 184 DiracDelta, 239, 277, 283 DirichletCondition, 321, 334, 347 Disk, 332, 338, 351 DSolve, 63, 69, 81, 134, 153, 167, 191, 288, 376 Element, 330, 339 Erf, 377 Erfc, 378 Evaluate, 46 Expand, 9, 91, 231, 243 ExpIntegralEi, 406 ExpToTrig, 228 Factor, 10, 13, 185, 187, 190, 194, 295 FortranForm, 188 Fourier, 274 FourierTransform, 266, 277 FresnelC, 407
426
Calculus and Differential Equations with Mathematica
FresnelS, 407 FullSimplify, 10, 13, 101 Gamma, 379, 382, 397 HeavisideTheta, 276, 243 ImplicitRegion, 321, 334, Integrate, 37 InverseFourierTransform, 269, 277 InverseLaplaceTransform, 228, 240 LaplaceTransform, 225, 239 LegendreP, 402 LegendreQ, 402 Limit, 20, 24 ListPlot, 116, 274, 294 Log, 9 Manipulate, 334, 347 N, 8, 15, 25, 49, 377 NDSolve, 116, 119, 167, 207, 294 NDSolveValue, 321, 334, 347 Normal, 46 Pi, 9 Plot, 11, 25, 83, 136, 207, 232, 260, 288, 377 Plot3D, 34, 332, 339, 344, 357 Polygon, 332 PolyLog, 405 Random, 274, 281 Rectangle, 332, 338, 351 RegionDifference, 332, 338, 351 RegionUnion, 332 Roots, 183 Sec, 101
Series, 45, 48 SetOptions, 264 Show, 116, 168, 294 Simplify, 10, 31, 101, 227 Sin, 9, 37, 117 Sinh, 226 Solve, 246, 249 Sqrt, 8 Sum, 48 Table, 46, 168, 207, 274 Tan, 9 ToElementMesh, 321, 334, 347 VectorPlot, 64, 77 Mathematica option, AspectRatio, 332, 339 Assumptions, 271 AxesLabel, 11, 27 ColorFunction, 34, 330 Contours, 332, 339 ContourShading, 336 Directive, 321, 334, 347 FourierParameters, 260 GridLines, 381 Joined, 274 Length, 334, 347 MaxCellMeasure, 321, 334, 347 Mesh, 11, 330 MeshElement, 321, 334, 347 MeshElementIDStyle, 321, 334, 347 MeshOrder, 321, 334 Normal, 45, 47 PlotLegends, 334, 347 PlotRange, 46, 93, 244, 260, 395
427
Index
PlotStyle, 11, 27, 244, 260, 289, 377 PointSize, 116, 168 StreamPoints, 66 StreamStyle, 66 Trig, 10 TrigReduce, 151 VectorScale, 65 VectorStyle, 65 ViewPoint, 330, 339 Wireframe, 321, 334, 347 Method, exact equation, 95 integrating factor, 88, 104 linear equation, 87 separable equation, 80 separation of variables, 326, 342, 353 undetermined coefficients, 152, 199 variation of parameters, 158, 164 Noise, 273 Number, integer, 8 real, 8 Numerical method, 114, 206 Runge-Kutta, 167 Partial differential equation, classification, 318 elliptic, 318, 320 exact solution, 329, 341, 356 hyperbolic, 318, 345 parabolic, 318, 333 Period, 260
Phase, 260 Plot, carpet, 331, 345, 352 contours, 330, 345, 357 Problem, boundary value, 132, 285 initial value, 132, 167, 193, 233 Property, linearity, 224 orthogonal, 329, 343, 356 Rational number, 7 Roots, complex, 142, 191 distinct real, 133, 185 mixed, 195 repeated real, 137 Series, infinite, 43 Maclaurin, 44, 46 Taylor, 43 Software, commercial, 2, 60 MACSYMA, 2 Solution, approximate, 80, 115 exact, 66, 73, 79, 86, 115, 147, 183, 188, 197, 291 general, 80, 99, 143, 185, 190, 287 homogeneous, 150, 154, 159, 198, 201 implicit, 76, 78, 106 particular, 150, 159, 198, Spring stiffness, 238, 242, 248, 390, 414
428
Calculus and Differential Equations with Mathematica
Square bracket, 7 Symbol palettes, 7, 39 Symbolic, differentiation, 4 integration, 4 manipulation, 2 mathematics, 1 software, 2, 60 System, mass-spring, 248, 390, 414 mass-spring-damper, 238
Temperature, 324, 335 Time, 260, 319, 339, 350, 390 second, 261 Variable, dependent, 60, 318 independent, 60, 318 Wronski’s test, 131 Wronskian, 132, 184