Академический Документы
Профессиональный Документы
Культура Документы
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Classification of Equations
Linear: independent variable appears to the first power only, either alone or multiplied by a constant Nonlinear: Polynomial: independent variable appears raised to powers of positive integers only General non-linear: all other equations
Solution Methods
Linear: Easily solved analytically Polynomials: Some can be solved analytically (such as by quadratic formula), but most will require numerical solution General non-linear: unless very simple, will require numerical solution
Since the signs are opposite, we know that the method will converge to a root of the equation The value of the function at the midpoint of the interval is: Computation: An Introduction Using MATLAB Engineering
and Excel
Interval
New Interval
Since f(ylower) and f(ymid) have opposite signs, the lower half of the interval is kept
Is interval width If signs are same (+ narrow enough to product), eliminate lower stop? half of interval. Engineering Computation: An Introduction Using MATLAB
and Excel
If signs are different (Is interval width product), eliminate upper narrow enough to Introduction Using MATLAB stop?Engineering Computation: Anhalf of interval. Excel and
Answer: y= 0.857
Engineering Computation: An Introduction Using MATLAB and Excel
In-Class Exercise
Draw a flow chart of the algorithm used to find a root of an equation using the bisection method Write the MATLAB code to determine a root of
Define tolerance tol Input lower and upper limits low and high while high-low > 2*tol mid = (high+low)/2 Evaluate function at lower limit and midpoint: fl = f(low), fm = f(mid) NO fl*fm > 0?
MATLAB Solution
Consider defining the function
as a MATLAB function fun1 This will allow our bisection program to be used on other functions without editing the program only the MATLAB function needs to be modified
Engineering Computation: An Introduction Using MATLAB and Excel
MATLAB Function
function y = fun1(x) y = exp(x) - 15*x -10;
Find Root
>> bisect Enter the lower limit Enter the upper limit
0 10
0 3
Root found: 3.0000 This value is not a root we might want to add a check to see if the converged value is a root Engineering Computation: An Introduction Using MATLAB
and Excel
Modified Code
Add solution tolerance (usually looser than convergence tolerance):
0 3
No root found
Numerical Tools
Of course, Excel and MATLAB have built-in tools for finding roots of equations However, the examples we have considered illustrate an important concept about non-linear solutions: Remember that there may be many roots to a non-linear equation. Even when specifying an interval to be searched, keep in mind that there may be multiple solutions (or no solution) within the interval. Engineering Computation: An Introduction Using MATLAB
and Excel