Numerical Analysis A. Mucherino Notions of Linear Numerical Analysis systems Finding the speed of the wind A simple algorithm Roots of functions Antonio Mucherino Functions and roots The bisection method University of Rennes 1 Interpolation www.antoniomucherino.it A reaction equilibrium constant Interpolation . . . . . . and regression? Numerical last update : August 2013 integration The area of a circle Trapezoidal rule Optimization Definition and commom methods
Numerical Analysis A. Mucherino Linear systems Finding the speed of the wind Numerical Analysis A simple algorithm Roots of functions Linear systems Functions and roots The bisection method Interpolation A reaction equilibrium constant Interpolation . . . . . . and regression? Numerical integration The area of a circle Trapezoidal rule Optimization Definition and commom methods
Aircraft and wind Numerical Analysis Suppose an aircraft flies from Paris to A. Mucherino Rio and then it comes back. Suppose the wind is constant during the whole Linear travel and it is able to influence the systems speed of the aircraft. Finding the speed of the wind A simple algorithm Roots of functions Paris - Rio, time t 1 = 5 . 1 hours, aircraft flying against wind Functions and roots The bisection Rio - Paris, time t 2 = 4 . 7 hours, aircraft flying with wind method Interpolation distance: 5700 miles A reaction equilibrium constant Interpolation . . . . . . and regression? How can we find the average speed of the aircraft and the Numerical integration average speed of the wind? The area of a circle Trapezoidal rule Optimization Definition and commom methods
How to solve this problem? Numerical Let x be the average speed of the aircraft, Analysis and let y be the average speed of the wind: A. Mucherino the actual aircraft speed is x − y when it flies against the wind the actual aircraft speed is x + y when it flies with the wind Linear systems the distance d for each travel can be computed as the product between the Finding the speed of time ( t 1 or t 2 ) and the actual speed the wind A simple algorithm Roots of We can define the following system of equations: functions Functions and roots � t 1 ( x − y ) = d The bisection method t 2 ( x + y ) = d Interpolation A reaction equilibrium constant Interpolation . . . . . . and regression? This is a linear system: Numerical integration t 1 , t 2 and d are parameters (already known) The area of a circle Trapezoidal rule x and y are variables Optimization Definition and commom methods
Linear systems General form of a linear system with 2 equations: Numerical Analysis � A. Mucherino a 11 x + a 12 y = b 1 a 21 x + a 22 y = b 2 Linear systems And, in matrix form: Finding the speed of the wind A simple algorithm � � � � � � a 11 a 12 x b 1 Roots of = functions a 21 a 22 y b 2 Functions and roots The bisection method � a 11 Interpolation � a 12 A reaction The coefficient matrix is able to provide information equilibrium constant a 21 a 22 Interpolation . . . . . . and regression? Numerical about the existence of solutions integration The area of a circle about the number of solutions Trapezoidal rule Optimization Definition and (out of the scope of this course) . commom methods
The solution for our example Numerical Analysis For the system A. Mucherino � t 1 x − t 1 y = d Linear t 2 x + t 2 y = d systems Finding the speed of the wind A simple algorithm Roots of we can find a solution ( x , y ) analytically: functions Functions and roots The bisection d method x = + y Interpolation t 1 A reaction equilibrium constant Interpolation . . . � � 1 − t 2 . . . and regression? d t 1 Numerical y = integration 2 t 2 The area of a circle Trapezoidal rule Optimization Definition and commom methods
The solution for our example Numerical So, in our example: Analysis A. Mucherino t 1 = 5 . 1 t 2 = 4 . 7 Linear systems d = 5700 Finding the speed of the wind and therefore: A simple algorithm Roots of functions x = 1165 . 2 miles / hours Functions and roots The bisection method y = 47 . 6 miles / hours Interpolation A reaction equilibrium constant Interpolation . . . . . . and regression? Can we program a computer to make this work for us? Numerical integration The area of a circle Trapezoidal rule Optimization Note that, in this simple example, we did not consider the health rotation. Definition and commom methods
Back substitution Numerical Analysis Suppose the coefficient matrix of our linear system is an upper A. Mucherino triangular matrix: Linear systems a 11 a 12 a 13 a 14 x 1 b 1 Finding the speed of the wind 0 a 22 a 23 a 24 x 2 b 2 = A simple algorithm 0 0 a 33 a 34 x 3 b 3 Roots of functions 0 0 0 a 44 x 4 b 4 Functions and roots The bisection method Interpolation In this situation, we can compute: A reaction equilibrium constant Interpolation . . . x 4 = b 4 . . . and regression? a 44 Numerical integration The area of a circle Trapezoidal rule Optimization Definition and commom methods
Back substitution Numerical Analysis Suppose the coefficient matrix of our linear system is an upper A. Mucherino triangular matrix: Linear systems a 11 a 12 a 13 a 14 x 1 b 1 Finding the speed of the wind 0 a 22 a 23 a 24 x 2 b 2 = A simple algorithm 0 0 a 33 a 34 x 3 b 3 Roots of functions 0 0 0 a 44 x 4 b 4 Functions and roots The bisection method Interpolation In this situation, we can compute: A reaction equilibrium constant Interpolation . . . x 3 = b 3 − a 34 x 4 . . . and regression? a 33 Numerical integration The area of a circle Trapezoidal rule Optimization Definition and commom methods
Back substitution Numerical Analysis Suppose the coefficient matrix of our linear system is an upper A. Mucherino triangular matrix: Linear systems a 11 a 12 a 13 a 14 x 1 b 1 Finding the speed of the wind 0 a 22 a 23 a 24 x 2 b 2 = A simple algorithm 0 0 a 33 a 34 x 3 b 3 Roots of functions 0 0 0 a 44 x 4 b 4 Functions and roots The bisection method Interpolation In this situation, we can compute: A reaction equilibrium constant Interpolation . . . x 2 = b 2 − a 23 x 3 − a 24 x 4 . . . and regression? a 22 Numerical integration The area of a circle Trapezoidal rule Optimization Definition and commom methods
Back substitution Numerical Analysis Suppose the coefficient matrix of our linear system is an upper A. Mucherino triangular matrix: Linear systems a 11 a 12 a 13 a 14 x 1 b 1 Finding the speed of the wind 0 a 22 a 23 a 24 x 2 b 2 = A simple algorithm 0 0 a 33 a 34 x 3 b 3 Roots of functions 0 0 0 a 44 x 4 b 4 Functions and roots The bisection method Interpolation In this situation, we can compute: A reaction equilibrium constant Interpolation . . . x 1 = b 1 − a 12 x 2 − a 13 x 3 − a 14 x 4 . . . and regression? a 11 Numerical integration The area of a circle Trapezoidal rule Optimization Definition and commom methods
C function for back substitution Numerical Analysis void back(int n,double **a,double *x) { A. Mucherino // n is the system dimension // a is the coefficient matrix // (must be upper triangular) Linear // x is systems // the vector of known terms (input) Finding the speed of the wind // the solution (output) A simple algorithm Roots of int i,j; functions Functions and roots The bisection for (i = n - 1; i >= 0; i--) method { Interpolation for (j = i+1; j < n; j++) A reaction equilibrium constant { Interpolation . . . x[i] = x[i] - a[i][j]*x[j]; . . . and regression? }; Numerical x[i] = x[i]/a[i][i]; integration }; The area of a circle Trapezoidal rule }; Optimization Definition and commom methods
Gaussian elimination Numerical Analysis How to solve linear systems whose coefficient matrix is not in A. Mucherino triangular form? Linear Gaussian elimination method : transform the system in an systems equivalent system whose coefficient matrix is in triangular form . Finding the speed of the wind A simple algorithm Example: Roots of 2 x + y − z = 8 functions Functions and roots − 3 x − y + 2 z = − 11 The bisection method − 2 x + y + 2 z = − 3 Interpolation A reaction 2 x + y − z = 8 equilibrium constant Interpolation . . . 1 + 1 = ⇒ . . . and regression? 2 y 2 z = 1 Numerical − z = 1 integration The area of a circle Trapezoidal rule Optimization Definition and commom methods
Recommend
More recommend