View
214
Download
0
Category
Preview:
Citation preview
1
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
CEE 3704Statistical and Numerical
Analysis
Fall 2003
Dr. David W. Dinehart
2
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Lecture Outline
• Overview of the second half of the course– Identify expectations– Define and identify Numerical Methods– Topics to be covered
• Identify the necessary steps of creating a program
• Identify Different Types and Measures of Error
• Review of Excel
3
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Learning Outcomes
1. Identify the necessary steps of creating a program, using either flowcharts, algorithms or pseudocode
2. Identify and define different types and measures of error
3. Use Excel to solve a numerical problem
4
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Course Overview
• Attendance and Punctuality – Come on time– Do not walk out mid-lecture
• Room– Nice facility – PowerPoint – White Board – Computer
Examples
5
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Course Reader
6
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Homework Requirements
• Performed on Engineering Paper or Computer
• Include problem statement
• Figure/Sketch (use straight edge)
• Equations
• Units• Significant Figures• Stapled• Group work• No late homework• No inferior
homework• Solutions posted on
website
7
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
What are Numerical Methods?
• Numerical Methods are a class of methods for solving a wide variety of mathematical problems/engineering systems
• In our case, these mathematical problems will be representing engineering systems
8
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Mathematical Representation of a Physical System
Load on a Beam
Flow in a Stream
9
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Topics to be Covered
• Formulation and Error• Finding Roots of an Equation• Linear Algebra - Matrices• Numerical Integration• Numerical Derivatives
10
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Numerical Methods
• Numerical methods only employ arithmetic operations and logic; therefore, they are ideally suited for computer application
We won’t be doing a lot of “programming”;
we will be using Excel extensively.
11
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Applicability of Numerical Methods
• In this course we want to understand the various types of numerical methods so that we know their capabilities and limitations
12
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Important Limitations
1. No complex physical situation can be exactly simulated mathematically
2. No numerical method is trouble-free in all situations
3. No numerical method is completely error-free
4. No numerical method is optimal for all situations
13
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Important Limitations
• Number 1 is very important, but beyond our focus
• There is a lot of overlap between 2, 3, and 4
• This is where we will focus• You will see and apply various
numerical methods in your other courses
14
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Computers and Software
What is the slope of the line?
h
eexf
xhx
Numerical Derivative
15
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Programming
• Any engineering equation can be expressed as a function
• The second half of this course will allow us to solve these functions
• Numerical analysis techniques lend themselves to computer programming
Where do we start?
16
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Your plan of attack(includes equations)
Nuts and bolts
*VERY IMPORTANT*
Revisions/Improvements
17
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Algorithms, Flowcharts, and Pseudocode
18
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Flowchart Symbols
19
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Fundamental Control Structures
1. Sequence
2. Selection
3. Repetition
*Any program can be constructed using only these three operations
20
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Selection
21
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Repetition
22
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Types of Error• Human Error• Data Error
– Example: How tall is he/she?
As accuracy increases, the number of significant figures increases and the “costs” increase. In general, increasing accuracy and precision increases “costs”.
23
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Types of Error - Continued• Example of Precision vs. Cost
– Consider the distance from the football stadium to the entrance of CEER. The “cost” will depend on the accuracy and precision.
• Use a map with a scale to keep the “cost” low, but sacrifice precision
• Use a survey crew to gain precision, but the “cost” goes up
• Round-off Error– Computer Software
• Truncation Error– Equations– Numerical Methods
24
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Significant Figures
• The significant digits of a number are those that can be used with confidence– How many significant digits does 5,000 have?
• 1 - 2 - 3 - 4 ?• It depends on the confidence
– How can we show the confidence?• Scientific Notation
– 5 x103 - 1 significant digit– 5.00 x 103 - 3 significant digits
25
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Significant Figures - Continued– How many significant figures do the following have
• 0.00562• 0.0000562• 0.000000562• Each of the above has 3 significant digits. The zeros are
just used to locate the decimal point
– What is ? 3.14159265…• Engineers and computers can only retain a finite number
of significant figures. The omission of the remaining figures is round-off error.
26
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Significant Figures - Continued– Example
10.34 kg6.1 kg25.21 kg13 kg
Add the following measures of weight
55 kg
We can’t say 54.65 kg because we don’t know whether or not 13 is 13.00 kg or 13.45 kg
Don’t give answers to more significant figures than you know (especially in Excel)!
54.65 kg
27
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Accuracy and Precision• Accuracy - how close a measured value
agrees with a true value• Precision - how close measured values
agree with each other– Testing concrete cylinders
• Cement + Sand + Water + Rock = Concrete• Experimental work – making and breaking concrete
cylinders to measure strength• Concrete has many non-uniformities - strength
increases as time increases• Design strength = 4,000 psi at 28 days (true value)
28
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Definition of Error• Relationship between the exact (or true) result
and approximate result is …
True Value = Approximation + Error
Rewriting… Et = True Value - Approximation
Et = Exact Value of the Error
t - “True” Error
This measure does not account for the magnitude of error relative to the magnitude we are interested in.
29
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Definition of Error - Continued
Et = 2.0”It’s great for measuring distance from stadium to CEER It’s not so good for measuring someone’s heightOne method to account for the magnitudes of the quantities being evaluated is to normalize the error to the true value.
Is this good?
True Fractional Relative Error = True Error
True Value
30
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Definition of Error - Continued
True Percent Relative Error = Et = True Error
True Valuex 100%
What is the problem with these measures of error?
In real world applications we usually don’t know the True Value
In these cases what do we do?
We can normalize to our best approximation
Ea =Approximate Error
Approximationx 100%
‘a’ denotes we are normalizing to an approximate value
31
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Definition of Error - Continued
Ea =Current Approximation - Previous Approximation
Current Approximationx 100%
One of the challenges of using numerical methods is determining error estimates without knowing the True Value
A lot of numerical methods use an iterative approach. A current approximation is made based on a previousapproximation. For these cases the percent relative error is...
Note ‘E’ can be positive or negative. We are usually not interested in the sign.
For an iterative approach, we use Ea as a stopping criteria
32
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Round-off Error• Definition: the discrepancy introduced by the
omission of significant figures– Computers retain a fixed number of significant figures
during a calculation; therefore, numbers like and e cannot be expressed exactly.
– Computers use a Base-2 representation so they cannot precisely represent certain exact Base-10 numbers
• We are most familiar with Base-10 - 10 digits
5214 = 5x103 + 2x102 + 1x101 + 4x100
4 x 1 = 41 x 10 = 10
2 x100 = 2005 x 1000 = 5000
5,214
33
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Chopping vs. Rounding = 3.14159265358
If we need to store this number in Base-10 carrying 7significant figures...
One method of approximation is chopping - chop off anythingbeyond 7 figures
3.141592 Et = True - Approx. = 0.00000065
An alternative method is rounding - if the last discarded digitis 5 we round up
3.141593 Et = -0.00000035
Rounding reduces the error… in this case almost by 50%
34
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Truncation Error & Taylor Series• Truncation errors occur when we replace an exact
mathematical procedure with an approximation• Taylor Series
– Used to predict a value of a function at one point based on the value of the function and its derivatives at another point
f(xi+1) = f(xi) + f ’(xi)h + f ’’(xi)h2 + f ’’’(xi)h3 + … + f(n)(xi)hn + Rn
2! 3! n!h = Step Size = xi+1 - xi
Rn = Remainder Term = f (n+1)()hn+1
(n+1)Rn accounts for all terms from n+1 to h = Value between xi and xi+1
35
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Taylor Series - Continued
Zero-Order Approximation - 1st Term
f(xi+1) = f(xi) Value of the new point is approximately equal to the value of the old point(This is true for a constant function)
If the function changes over the interval (h), we need more terms
To increase the accuracy of our approximation we can…
1. Increase the number of terms
2. Decrease our step size, h
36
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Roundoff vs. Truncation
Let’s look at Excel
37
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Homework #1
• Review my Excel example• Create your weekly schedule in Excel
– Borders/Shading– Fonts– Color– Column Width
38
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Bad HomeworkMonday Tuesday WednesdayThursday Friday
7:30-8:308:30-9:309:30-10:30 NA NA NA10:30-11:30NA NA NA11:30-12:3012:30-1:301:30-2:30 Office Hours2:30-3:303:30-4:304:30-5:305:30-6:306:30-9:30 Dynamics
39
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Better Homework
40
Villanova UniversityDept. of Civil & Environmental Engineering
CEE 3704Statistical and Numerical Analysis
Homework #1
• Review my Excel example• Create your weekly schedule in Excel• “Program” problem 3-13 from structural
analysis in Excel (solution is on the course homepage)– Include the figure– Calculations and commentary– Answers (forces and reactions) boxed and
highlighted– Use multiple worksheets as necessary – Setup the spreadsheet so that it can solve for the
member forces and reactions for various horizontal and vertical lengths and loadings
• Due next Thursday
Recommended