160 likes | 344 Views
ES 314 Nov 27, 2012 Numerical Analysis Source: Maurice Herlihy, Brown Univ. Numerical Analysis Solving equations Finding min/max Integrating linear systems: eigenvalue, eigenvector computation Examples - applications. topics covered.
E N D
ES 314 Nov 27, 2012 Numerical Analysis Source: Maurice Herlihy, Brown Univ.
Numerical Analysis Solving equations Finding min/max Integrating linear systems: eigenvalue, eigenvector computation Examples - applications topics covered
Exact answers are sometimes hard or impossible to achieve in practice Numerical methods provide an approximation that is generally good enough Useful in all fields of engineering and physical sciences, but growing in utility in the life sciences and the arts Movement of planets, stars, and galaxies Investment portfolio management by hedge funds Quantitative psychology Simulations of living cells Airline ticket pricing, crew scheduling, fuel planning Why Numerical Methodsare Important Figure is a Babylonian clay tablet showing an approximation of 21/2.
General form f (x ) = 0 Approximation may be good enough Iterative approach with the bisection method Equations in One Variable
Function can be specified as a mathematical expression as a string with no predefined variables function handle name of an anonymous function Must be in the form f (x ) = 0 f (x ) = c f (x ) - c = 0 Equations in One Variable (cont.) x = fzero(function, x0) function: function to be solvedx0:initial guess at solutionx:the solution
Find the solution of Rewrite as Plot it to get estimate Solving a Nonlinear Equation
Solvef (x ) = 0 by repeating the assignment untilxis close enough to 0 Newton's Method
Local minima or maxima occur when the derivative of the function is zero Finding Minima and Maxima x = fminbnd(function, x1, x2) function: function to be solvedx1,x2:interval for minimumx:function minimum m-files: lect12_1
For best view in a theater, sit at distance x such that angleΘis maximum Find x with the configuration shown Applying Law of Cosines ExampleMaximum Viewing Angle
Angle is between 0 andπ/2 Cosine decreases from 1 atΘ = 0, thus maximum angle corresponds to minimum cos(Θ) Do a quick plot of cos(Θ) as a function of xto estimate the solution range Find the minimum with fminbnd Maximum Viewing Angle
Find the area under the curve of a function Examples Area and volume Velocity from acceleration Work from force and displacement Integrand can be a function or set of data points Numerical Integration
Function must be written for element-by-element operations Function must be well-behaved between aandb(no vertical asymptote) Difference is in method of integration Integration in MATLAB q = quad(function, a, b)q = quadl(function, a, b) function: function to be solveda,b:integration limitsq:value of integral
Example Integrating with Data Points q = trapz(x, y)x,y: vectors of data pointsq: value of integral
To estimate the amount of water that flows in a river during a year, consider the cross section shown. The height h and speed v are measured on the first of each month. Water Flow in a River
Flow rate (volume per second) Total amount of water Water Flow in a River