Download presentation
Presentation is loading. Please wait.
Published byPrudence Miles Modified over 9 years ago
1
MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu http://www.bc.inter.edu/facultad/omeza Department of Mechanical Engineering Inter American University of Puerto Rico Bayamon Campus
2
Lecture 9 MECN 3500 Inter - Bayamon 2 Tentative Lectures Schedule TopicLecture Mathematical Modeling and Engineering Problem Solving 1 Introduction to Matlab 2 Numerical Error 3 Root Finding 4-5-6 System of Linear Equations 7-8 Least Square Curve Fitting 9 Polynomial Interpolation Numerical Integration Ordinary Differential Equations
3
Lecture 9 MECN 3500 Inter - Bayamon Least-Squares Regression Curve Fitting 3
4
Lecture 9 MECN 3500 Inter - Bayamon To Describes techniques to fit curves (curve fitting) to discrete data to obtain intermediate estimates. 4 Course Objectives
5
Lecture 9 MECN 3500 Inter - Bayamon Curve fitting techniques are used to fit curves to data to obtain intermediate estimates or to derive a simpler function from a complicated function. Least squares regression is used when the data exhibits a significant degree of error or noise. Interpolation is used to fit curves that pass directly through each of the points. Introduction 5
6
Lecture 9 MECN 3500 Inter - Bayamon Least-squares regression techniques used to fit a curve to experimental data. These techniques used to derive an approximate function that fits the shape or general trend of the data. Techniques: linear regression, polynomial regression, multiple linear regression Linear Regression 6
7
Lecture 9 MECN 3500 Inter - Bayamon Linear Regression Fit a straight line to a set of paired observations (x 1,y 1 ), (x 2,y 2 ), …, (x n,y n ) The mathematical expression for the straight line is y = a 0 + a 1 x + e e is called the error or “residual” The residual is the difference between the observation and the line: e = y a 0 a 1 x What are the values of a 0 and a 1 ? 7
8
Lecture 9 MECN 3500 Inter - Bayamon 1.Minimize the sum of the residual errors Criteria for a Best Fit NO GOOD 8
9
Lecture 9 MECN 3500 Inter - Bayamon Criteria for a Best Fit 2.Minimize the sum of the absolute values of the residual errors NO GOOD 9
10
Lecture 9 MECN 3500 Inter - Bayamon Criteria for a Best Fit 3.Minimax: minimize the maximum error NO GOOD 10
11
Lecture 9 MECN 3500 Inter - Bayamon Criteria for a Best Fit 11 4.Minimize the sum of the squares of the residuals This criterion yields a unique line for a given set of data.
12
Lecture 9 MECN 3500 Inter - Bayamon Least-Squares Fit of a Straight Line 12 To determine the values of a 0 and a 1, differentiate S r with respect to each of the coefficients and set to zero: The equations become: The normal equations are
13
Lecture 9 MECN 3500 Inter - Bayamon Least-Squares Fit of a Straight Line 13 The slope and the y-intercept are given by y = a 0 + a 1 x + e a 0 is the intercept a 1 is the slope
14
Lecture 9 MECN 3500 Inter - Bayamon Least-Squares Fit of a Straight Line 14 The slope and the y-intercept are given by y = a 0 + a 1 x + e a 0 is the intercept a 1 is the slope
15
Lecture 9 MECN 3500 Inter - Bayamon Example 17.1 15 Fit a straight line to the data xixi yiyi 10.5 22.5 32 44 53.5 66 75.5
16
Lecture 9 MECN 3500 Inter - Bayamon 16
17
Lecture 9 MECN 3500 Inter - Bayamon Quantification of Error of Linear Regression 17 To quantify the error reduction due to describing the data in terms of a straight line, we use the coefficient of determination which is defined as It represents the fraction of variability in y that can be explained by the variability in x (how close the points are to the line). For r 2 = 1, it signifies the line explains 100% of the variability of the data.
18
Lecture 9 MECN 3500 Inter - Bayamon Example 17.1 18 Compute the coefficient of determination for the linear regression in previous example S t = 22.7145 S r = 2.9911 r 2 = 0.868 This indicates that 86.8% of the original uncertainty is explained by the linear model. Answer
19
Lecture 9 MECN 3500 Inter - Bayamon Linearization of Nonlinear Relationships 19 Transformations can be used to express the data in a form that is compatible with the linear regression.
20
Lecture 9 MECN 3500 Inter - Bayamon Linearization of Nonlinear Relationships 20 Example 1: Suppose the relationship between x and y is It can be linearized by taking the ln of both sides: Example 2: Consider It can be transform into the linear form
21
Lecture 9 MECN 3500 Inter - Bayamon Linearization of Nonlinear Relationships 21 Example 3: Consider It can be linearized by inverting both sides
22
Lecture 9 MECN 3500 Inter - Bayamon Linearization of Nonlinear Relationships 22
23
Lecture 9 MECN 3500 Inter - Bayamon Example 17.4 23 Fit to the data Answer xy 10.5 21.7 33.4 45.7 58.4 x'y' 0-0.301 0.3010.23 0.4770.531 0.6020.756 0.6990.924
24
Lecture 9 MECN 3500 Inter - Bayamon Polynomial Regression 24 We need to fit a polynomial to data using polynomial regression. A second-order polynomial or quadratic fit is y = a 0 + a 1 x + a 2 x 2 + The sum of squares of the residues: Differentiate S r with respect to all parameters:
25
Lecture 9 MECN 3500 Inter - Bayamon Polynomial Regression 25 Set the partials to zero and arrange These equations are called the normal equations. They form a system of linear equations with 3 equations and 3 unknowns. In general, an mth order polynomial requires solving a system of m+1 linear equations.
26
Lecture 9 MECN 3500 Inter - Bayamon 26
27
Lecture 9 MECN 3500 Inter - Bayamon Example 17.4 27 Fit a second-order polynomial to the data xy 02.1 17.7 214 327 441 561
28
Lecture 9 MECN 3500 Inter - Bayamon Multiple Linear Regression 28 Multiple Linear Regression The function y is a linear function of 2 or more independent variables, such as y = a 0 + a 1 x 1 + a 2 x 2 + The sum of the squares of the residuals To minimize S r,
29
Lecture 9 MECN 3500 Inter - Bayamon Multiple Linear Regression 29 The normal equations are
30
Lecture 9 MECN 3500 Inter - Bayamon 30
31
Lecture 9 MECN 3500 Inter - Bayamon Example 17.5 31 Fit the data with multiple linear regression x1x1 x2x2 y 005 2110 2.529 730 463 5227
32
Lecture 9 MECN 3500 Inter - Bayamon Regression in Matlab and Excel 32 Use the polyfit function Regression in Excel Use Add Trendline Regression in Matlab
33
Lecture 9 MECN 3500 Inter - Bayamon Homework7 www.bc.inter.edu/facultad/omeza www.bc.inter.edu/facultad/omeza Omar E. Meza Castillo Ph.D. 33
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.