You are on page 1of 26

Applied Numerical Methods

with MATLAB®
for Engineers and Scientists
4th Edition
Steven C. Chapra

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University and


Prof. Steve Chapra, Tufts University

©McGraw‐Hill Education. All rights reserved. Authorized only for instructor use in the classroom. No reproduction or further distribution permitted without the prior written consent of McGraw‐Hill Education.
Part 1
Chapter 1
Mathematical Modeling,
Numerical Methods, and
Problem Solving

©McGraw‐Hill Education. All rights reserved. Authorized only for instructor use in the classroom. No reproduction or further distribution permitted without the prior written consent of McGraw‐Hill Education.
Chapter Objectives
Learning how mathematical models can be formulated on
the basis of scientific principles to simulate the behavior of
a simple physical system.
Understanding how numerical methods afford a means to
generalize solutions in a manner that can be implemented
on a digital computer.
Understanding the different types of conservation laws that
lie beneath the models used in the various engineering
disciplines and appreciating the difference between steady-
state and dynamic solutions of these models.
Learning about the different types of numerical methods we
will cover in this book.
©McGraw‐Hill Education.
A Simple Mathematical Model
A mathematical model can be broadly defined
as a formulation or equation that expresses
the essential features of a physical system or
process in mathematical terms.

Models can be represented by a functional


relationship between dependent variables,
independent variables, parameters, and
forcing functions.

©McGraw‐Hill Education.
Model Function
Dependent independent forcing
𝑓 , parameters,
variable variables functions

Dependent variable - a characteristic that usually reflects


the behavior or state of the system
Independent variables - dimensions, such as time and
space, along which the system’s behavior is being
determined
Parameters - constants reflective of the system’s properties
or composition
Forcing functions - external influences acting upon the
system
©McGraw‐Hill Education.
Model Function Example
Assuming a bungee jumper is in mid-flight,
an analytical model for the jumper’s velocity,
accounting for drag, is

Dependent variable - velocity v


Independent variables - time t
Parameters - mass m, drag coefficient cd
Forcing function - gravitational acceleration g
©McGraw‐Hill Education.
Model Results
Using a computer (or a calculator), the model can be used to
generate a graphical representation of the system. For
example, the graph below represents the velocity of a 68.1
kilogram jumper, assuming a drag coefficient of 0.25
kilograms per mile

©McGraw‐Hill Education.
Numerical Modeling
Some system models will be given as implicit functions
or as differential equations - these can be solved either
using analytical methods or numerical methods.
Example - the bungee jumper velocity equation from
before is the analytical solution to the differential
equation
𝑑 2

where the change in velocity is determined by the


gravitational forces acting on the jumper versus the
drag force.
©McGraw‐Hill Education.
Numerical Methods
To solve the problem using a numerical
method, note that the time rate of change of
velocity can be approximated as:

i 1

i 1

©McGraw‐Hill Education.
Euler’s Method
Substituting the finite difference into the
differential equation gives
𝑑 2

i 1 𝑖 𝑑 2
i 1 𝑖
Solve for
𝑑 2
i 1 𝑖 𝑖 i 1 𝑖

©McGraw‐Hill Education.
Numerical Results
Applying Euler’s method in 2 s intervals yields:

How do we improve the solution?


• Smaller steps
©McGraw‐Hill Education.
Bases for Numerical Models
Conservation laws provide the foundation for many
model functions.

Different fields of engineering and science apply


these laws to different paradigms within the field.

Among these laws are:


• Conservation of mass
• Conservation of momentum
• Conservation of charge
• Conservation of energy
©McGraw‐Hill Education.
Summary of Numerical Methods

©McGraw‐Hill Education.
Part 1
Chapter 2
MATLAB Fundamentals

©McGraw‐Hill Education. All rights reserved. Authorized only for instructor use in the classroom. No reproduction or further distribution permitted without the prior written consent of McGraw‐Hill Education.
Matlab User Interface

©McGraw‐Hill Education.
Calculator Mode
The MATLAB command widow can be used
as a calculator where you can type in
commands line by line. Whenever a
calculation is performed, MATLAB will assign
the result to the built-in variable ans
Example:
>> 55/11
ans =
5
©McGraw‐Hill Education.
MATLAB Syntax

• Syntax is the rules that must be followed


when developing MATLAB programs or
simply using the Command Window as a
calculator.
MATLAB Variables
• Variables allow you to store numerical
values, character strings or represent an
unknown quantity.
• Variable names are case sensitive; and can
contain up to 63 letters, numbers and the
underscore symbols, but not symbols.
• Variables are globally defined within a
MATLAB program.
• By default, variables are stored as floating
point numbers with 16 significant figures.
MATLAB Syntax-Variables
• The range of floating point numbers is
between -1.7x10308 to 1.7x10308 (Version
R2014a).
• The command ‘>>whos’ used in the
Command Window will list the defined
variables along with their characteristics.
• The command ‘>>clear’ removes all
variables from the Command Window.
Special Variables
• Inf – when a variable exceeds the largest
or smallest number available.
• NaN – Not a number, usually the result of
an undefined mathematical operation, e.g.,
0/0.
• pi –  to 15 significant figures.
Format Examples
>> format short; pi
ans =
3.1416
>> format long; pi
ans =
3.14159265358979
>> format short eng; pi
ans =
3.1416e+000
>> pi*10000
ans =
31.4159e+003
Note - the format remains the same unless another format
command is issued.
©McGraw‐Hill Education.
Assignment Statements

• An assignment statement defines the value


of a variable in terms of specified constants,
in terms of known variables or in terms of
unknown variable, e.g.,
• ‘b=8.34’
• ‘b=c+a’
• ‘b=x+y’
Assignment Statements
• If an assignment statement is not followed
by a semicoln (;), the value of the
assignment statement is displayed.
• If an assignment statement is followed by a
semicoln (;), the value of the assignment
statement is not displayed.
• Therefore, you normally follow each
assignment statement by a semicolon unless
you want the value displayed.
MATLAB Syntax-Arithmetric
Operators

• ‘+’ addition, e.g., ‘5+6’


• ‘-’ subtraction, e.g., ‘5-6’
• ‘*’ multiplication, e.g., ‘5*6’
• ‘/’ division, e.g., ‘5/6’
• ‘^’ exponentation, e.g., ‘5^6’
• In general, ^ is evaluated first, followed by
* and / and finally + and -.
Arithmetic Operation Example

• x=3^2/3+2*4/2^3
• Evaluate exponentials first:
• x=9/3+2*4/8
• Next perform multiplication and division:
• x=3+1
• Finally, perform addition and subtraction:
• x=4
Arithmetric Operators

• Parenthesis supersede the order indicated by the


mathematical operators. Inner most parenthesis
are evaluate first.
• E.g., ‘b=(3+((4-2)*2-(5-2)^2))’
• Evaluate inner most (), ‘b=(3+(2*2-3^2))’
• Evaluate inner most (), ‘b=(3+(-5))’
• Finally, ‘b=-2’

You might also like