Presentation is loading. Please wait.

Presentation is loading. Please wait.

Section 8 Numerical Analysis CSCI E-24 José Luis Ramírez Herrán October 20, 2015.

Similar presentations


Presentation on theme: "Section 8 Numerical Analysis CSCI E-24 José Luis Ramírez Herrán October 20, 2015."— Presentation transcript:

1 Section 8 Numerical Analysis CSCI E-24 José Luis Ramírez Herrán October 20, 2015

2 Section 8 Outline 1.Midterm Exam: we will go over the exam later tonight 2.Assignment 4: We haven't seen the material from Assignment 4, though many have already started on it 3.Background Assignment 4 4.Related problems to Assignment 4

3 Homework 4 – Total: 69 points Due 5:00 PM EST November 3rd, 2015 1.Exercise 4.1.8: Find the best line and RMSE (6 points) 2.Exercise 4.2.2: Fit data to periodic models (6 points) 3.Exercise 4.3.2: QR with Gram-Schmidt (6 points) 4.Exercise 4.3.4: QR with Householder reflectors (6 points) 5.Exercise 4.3.6: Least Squares with QR (6 points) 6.Plotting Linear Fit (8 points) 7.Gram-Schmidt (8 points) 8.Graduate Work - Orthogonal Polynomials (8 points) 9.Regression Equation (10 points) 10.Economizing Power Series (5 points)

4 Calendar

5 Background homework 4 – Least Squares

6 Least Squares – Part 1

7 4.1 LEAST SQUARES AND THE NORMAL EQUATIONS The need for least squares methods comes from two different directions, one each from our studies of before the Midterm, we learned how to find the solution of Ax = b when a solution exists. In the next 2 lectures, we find out what to do when there is no solution. When the equations are inconsistent, which is likely if the number of equations exceeds the number of unknowns, the answer is to find the next best thing: the least squares approximation.

8 4.1.1 Inconsistent systems of equations

9 What is the meaning of a system with no solutions? Perhaps the coefficients are slightly inaccurate. In many cases, the number of equations is greater than the number of unknown variables, making it unlikely that a solution can satisfy all the equations. In fact, m equations in n unknowns typically have no solution when m > n. Even though Gaussian elimination will not give us a solution to an inconsistent system Ax = b, we should not completely give up. An alternative in this situation is to find a vector x that comes the closest to being a solution.

10 to find a vector x that comes the closest to being a solution. If we choose this "closeness" to mean close in Euclidean distance, there is a straight- forward algorithm for finding the closest x. This special x will be called the least squares solution.

11 We can get a better picture of the failure of system (4.1) to have a solution by writing it in a different way. The matrix form of the system is Ax = b, or The alternative view of matrix/vector multiplication is to write the equivalent equation

12 Vector Equation In fact, any m x n system Ax = b can be viewed as a vector equation

13 Figure 4.1 (b) shows a direction for us to go when a solution does not exist.

14 there is no pair x1, x2 that solves (4.1 ), but there is a point in the plane Ax of all possible candidates that is closest to b.

15 Finding a formula for, the least squares “solution”

16 perpendicularity To work with perpendicularity, recall that two vectors are at right angles to one another if their dot product is zero. For two m-dimensional column vectors u and v, we can write the dot product solely in terms of matrix multiplication by

17 The Fact

18 Orthogonality Least squares is based on orthogonality. The shortest distance from a point to a plane is carried by a line segment orthogonal to the plane. The normal equations are a computational way to locate the line segment, which represents the least squares error.

19 Means?

20 system of equations that defines the least squares solution which is is known as the normal equations.

21 The Normal Equations

22 EXAMPLE 4.1 Find the least squares solution x that minimizes the Euclidean length of the residual r = b - Ax. Use the normal equations to find the least squares solution of the inconsistent system (4.1).

23 The components of the normal equations are The normal equations

24 an now be solved by Gaussian elimination. The tableau form is Which can be solved to get Substituting the least squares solution into the original problem yields To measure our success at fitting the data, we calculate the residual of the least squares solution

25 If the residual is the zero vector, then we have solved the original system Ax = b exactly. If not, the Euclidean length of the residual vector is a backward error measure of how far is from being a solution.

26 Residual

27 Example

28 Assignment 4 – section 4.1.1

29

30 Exercise 4.1.1

31 Review Least Squares – Part 2 fitting Models to Data

32 4.1.2 Fitting models to data Let (t 1, y 1 ),..., (t m, y m ) be a set of points in the plane, which we will often refer to as the "data points." Given a fixed class of models, such as all lines y = c 1 + c 2 t, we can seek to locate the specific instance of the model that best fits the data points in the 2-norm. The core of the least squares idea consists of measuring the residual of the fit by the squared errors of the model at the data points and finding the model parameters that minimize this quantity.

33 Least squares fitting of a line to data. The best line is the one for which the squared error is as small as possible among all lines

34 Find the line that best fits the three data points One each of the data points lies above, on, and below the best line.

35 The model is y = c 1 + c 2 t, and the goal is to find the best c 1 and c 2 Substitution of the data points into the model yields

36

37 The previous example suggests a three-step program for solving least squares data-fitting problems

38

39 EXAMPLE – part 1 Find the best line and best parabola for the four data points (-1, 1), (0, 0), (1, 0), (2, -2). three steps: Solving for the coefficients c1 and c2 results in the best line y = c1 + c2t = 0.2 - 0.9t.

40 EXAMPLE – part 2

41 EXAMPLE – part 3 Problem: best parabola for the four data points (-1, 1), (0, 0), (1, 0), (2, -2). three steps:

42 EXAMPLE – part 4

43

44 MatLab

45 Example 4.4 shows that least squares modeling need not be restricted to finding best lines. By expanding the definition of the model, we can fit coefficients for any model as long as the coefficients enter the model in a linear way

46 Least Squares – Part 3 Conditioning

47 Conditioning of least squares We have seen that the least squares problem reduces to solving the normal equations. How accurately can the least squares solution x be determined? This is a question about the forward error of the normal equations. We carry out a double precision numerical experiment to test this question, by solving the normal equations in a case where the correct answer is known.

48

49 MatLab to solve the normal equations for a Vander Monde matrix,

50

51 4.1 Problems

52

53

54

55

56 Continuation Least Squares – Part 4 Periodic Data

57 Periodic data calls for periodic models. Outside air temperatures, for example, obey cycles on numerous timescales, including daily and yearly cycles governed by the rotation of the earth and the revolution of the earth around the sun. As a first example, hourly temperature data are fit to sines and cosines.

58 The fact that temperature is roughly periodic with a period of 24 hours, at least in the absence of longer-term temperature movements. The model uses this information by fixing the period to be exactly one day, where we are using days for the t units. The variable t is listed in these units in the table. Substituting the data into the model results in the following over-determined system of linear equations:

59

60

61

62

63

64 Vs

65

66 Continuation Least Squares – Part 5 Data Linearization

67 Data Linearization Exponential growth of a population is implied when its rate of change is proportional to its size. Under perfect conditions, when the growth environment is unchanging and when the population is well below the carrying capacity of the environment, the model is a good representation. cannot be directly fit by least squares because c 2 does not appear linearly in the model equation. Once the data points are substituted into the model, the difficulty is clear: The set of equations to solve for the coefficients are nonlinear and cannot be expressed as a linear system Ax =b. Therefore, our derivation of the normal equations is irrelevant.

68

69

70

71

72

73

74

75

76

77 Continuation Least Squares – Part 6 QR Factorization

78 QR Factorization

79

80

81

82 EXAMPLE

83

84

85

86

87 Example

88

89 MatLab

90 Applications of the QR Factorization

91

92

93

94

95

96

97

98

99

100

101

102 Assignment 4

103 Homework 4 related problems 4.1.1 4.2.1 4.3.1 4.3.3 4.3.5

104 4.2.1 part 1

105 4.2.1 part2

106 4.3.1

107

108 4.3.3 part 1

109 4.3.3 part2

110 4.3.5 part 1

111

112

113

114

115

116

117

118

119

120

121


Download ppt "Section 8 Numerical Analysis CSCI E-24 José Luis Ramírez Herrán October 20, 2015."

Similar presentations


Ads by Google