Download presentation
Presentation is loading. Please wait.
1
Some Comments on Root finding
2
Avoid subtraction of nearly equal numbers
Some Comments on Root finding Consider the following two numbers a= ; b= ; c = a - b ans = Avoid subtraction of nearly equal numbers a=1e-16; b=1; c=-1; a+(b+c) (a+b)+c Associative property π+ π+π = π+π +π ans = e-16 why
3
Avoid subtraction of nearly equal numbers
Some Comments on Root finding Avoid subtraction of nearly equal numbers % solve x^2 + b*x + 1 = 0 f x*(a*x+b)+c; xeps = 1e-8; b = (2/xeps) + xeps; a=1; c=1; f a*x^2 + b*x +c x1 = (-b+sqrt(b^2-4*a*c))/(2*a) y1=(-2*c)/(b+sqrt(b^2-4*a*c)) f(x1) f(y1) abs((x1-y1)/y1)*100 Solve: π₯ 2 +π π₯+1=0 π=2Γ 10 8 π₯ 1 = βπ+ π 2 β4ππ 2π rationalizing the numerator x1 = y1 = e-09 ans = 100 π₯ 1 = β2π π+ π 2 β4ππ
4
Avoid subtraction of nearly equal numbers
Some Comments on Root finding Avoid subtraction of nearly equal numbers The Secant Method Algebraically equivalent formula π₯ π+1 = π₯ π β π( π₯ π )( π₯ π β π₯ πβ1 ) π π₯ π βπ( π₯ πβ1 ) π₯ π+1 = π₯ πβ1 π π₯ π β π₯ π π π₯ πβ1 π π₯ π βπ( π₯ πβ1 ) in general, this iteration equation is likely to be less accurate than the one given in left box. why Here, we subtract two nearly equal numbers in both numerator and denominator.
5
Formula Error Equation guess
Some Comments on Root finding Formula Error Equation guess x0 suff close to x* Any π₯ π+1 = π₯ π β π( π₯ π ) πβ²( π₯ π ) π₯ β β π₯ π+1 = π 2 π 2 π β² π₯ π π₯ β β π₯ π 2 Newtonβs Secant π₯ π+1 = π₯ π β π( π₯ π )( π₯ π β π₯ πβ1 ) π π₯ π βπ( π₯ πβ1 ) π₯ π+1 = π π + π π 2 π₯ β β π₯ π β€ πβπ 2 π Bisection Fixed-point π₯ π+1 =π( π₯ π ) π₯ β β π₯ π β€ π π π₯ β β π₯ πβ1 πβ²(π₯) β€π βπ₯ False position Secant +test
6
Some Comments on Root finding
Cq1 solution Cq2 solution
7
Apply Newtonβs method to find a solution to π₯β6πππ π₯=0, π₯ 0 =2
Some Comments on Root finding Apply Newtonβs method to find a solution to π₯β6πππ π₯=0, π₯ 0 =2 In the interval [0,π] that is accurate to within 10 β3 π₯ π+1 = π₯ π+1 β π₯β6πππ π₯ 1+6sinβ‘(π₯) Newtonβs method: π π₯ π π₯ π+1 β π₯ π e-01 e-02 e-04 e-09
8
Multiple Root Some Comments on Root finding
π₯=1 is a zero of multiplicity 2 of the the function π π₯ = (π₯β1) 2 (π₯β3) 2 Note that no change of sign close to the root. (bisection ,FP ??) Definition: Theorem p of f (x) = 0 is a zero of multiplicity m of f if for π₯=π, we can write π π₯ = (π₯βπ) π π π₯ where π(π)β 0 p is a zero of multiplicity m of f if and only if π π = π (1) π =β―= π πβ1 π =0 and π (π) π β 0
9
Multiple Root Some Comments on Root finding Example:
Show that f has a zero of multiplicity 2 at x = 0. π π₯ = π π₯ βπ₯β1 Newtonβs method are shown in Table The sequence is clearly converging to 0, but not quadratically.
10
modification of Newtonβs method
Some Comments on Root finding modification of Newtonβs method Example: Show that f has a zero of multiplicity 2 at x = 0. π π₯ = π π₯ βπ₯β1 If p is a zero of f of multiplicity m π π₯ = (π₯βπ) π π π₯ then p is a zero of πβ² of multiplicity m-1 Hence p is a simple zero of ΞΌ π₯ = π(π₯) πβ²(π₯) Newtonβs method can then be applied to ΞΌ π₯ The only drawback to this method is the additional calculation of
11
modification of Newtonβs method
Some Comments on Root finding modification of Newtonβs method Example: Show that f has a zero of multiplicity 2 at x = 0. π π₯ = π π₯ βπ₯β1 If p is a zero of f of multiplicity m π π₯ = (π₯βπ) π π π₯ then p is also a fixed point of π π₯ =π₯βπ π(π₯) πβ²(π₯) π₯ π+1 = π₯ π βπ π( π₯ π ) πβ²( π₯ π )
12
Nonlinear system of equations:
Some Comments on Root finding Nonlinear system of equations: π 1 =π₯ π₯ 2 + π₯ 3 2 β8 π 2 =2π₯ π₯ 2 2 β π₯ 3 β11 π 3 =π₯ π₯ π₯ 3 2 β14 π₯ π₯ 2 + π₯ 3 2 =8 2π₯ π₯ 2 2 β π₯ 3 =11 π₯ π₯ π₯ 3 2 =14 Convert into πΉ π =0 πΉ π = π₯ π₯ 2 + π₯ 3 2 β8 2π₯ π₯ 2 2 β π₯ 3 β11 π₯ π₯ π₯ 3 2 β14 π₯ π₯ 2 + π₯ 3 2 β8=0 2π₯ π₯ 2 2 β π₯ 3 β11=0 π₯ π₯ π₯ 3 2 β14=0 π= π₯ 1 π₯ 2 π₯ 3
13
Some Comments on Root finding
Def: Jacobian Matrix πΉ π = π₯ π₯ 2 + π₯ 3 2 β8 2π₯ π₯ 2 2 β π₯ 3 β11 π₯ π₯ π₯ 3 2 β14 π½ π = π π 1 π₯ 1 π π 1 π₯ 2 π π 1 π₯ 3 π π 2 π₯ 1 π π 2 π₯ 2 π π 2 π₯ 3 π π 3 π₯ 1 π π 3 π₯ 2 π π 3 π₯ 3 π= π₯ 1 π₯ 2 π₯ 3 Example: π½ π = 2 π₯ π₯ π₯ 2 2 β1 2 π₯ 1 2 π₯ 2 2 π₯ 3 Example: π (0) = 1 β1 1 π½ π (0) = β1 2 β2 2
14
π (π+1) = π (π) β π½ ( π (π) ) βπ π( π (π) )
Some Comments on Root finding Newtonβs method for single variable π₯ π+1 = π₯ π β π( π₯ π ) πβ²( π₯ π ) π₯ π+1 = π₯ π β πβ²( π₯ π ) βπ π( π₯ π ) Newtonβs method for system of nonlinear equations πΉ π =0 π (π+1) = π (π) β π½ ( π (π) ) βπ π( π (π) ) π (π) = π₯ 1 (π) π₯ 2 (π) π₯ 3 (π)
15
π¨π π =π Newtonβs method for system of nonlinear equations πΉ π =0
Some Comments on Root finding Newtonβs method for system of nonlinear equations πΉ π =0 π (π+1) = π (π) β π½ ( π (π) ) βπ π( π (π) ) π (π) = π₯ 1 (π) π₯ 2 (π) π₯ 3 (π) π (π+1) β π π =β π½ ( π (π) ) βπ π( π (π) ) π (π+1) β π π = π½ π π βπ (βπ π π ) π π = π½ π π βπ (βπ π π ) π½ π π π π = βπ π π π¨π π =π This is a linear system of n-equations in n-unknowns where π΄=π½ π π πππ
π= βπ π π
16
ALGORITHM: (Newtonβs method for system of nonlinear equations)
Some Comments on Root finding ALGORITHM: (Newtonβs method for system of nonlinear equations) πΉ= π₯ π₯ 2 + π₯ 3 2 β8 2π₯ π₯ 2 2 β π₯ 3 β11 π₯ π₯ π₯ 3 2 β14 π½ π = 2 π₯ π₯ π₯ 2 2 β1 2 π₯ 1 2 π₯ 2 2 π₯ 3 πΏ (π) = π π (π) π π (π) π π (π) π (0) = 1 β1 1 Given initial guess π½ π (0) = β1 2 β2 2 1) Calculate Jacobian Matrix π¨= π± πΏ (π) π= β7 β7 β13 2) Calculate right-hand-side vector π= βπ πΏ π β1 2 β π¦ 1 (0) π¦ 2 (0) π¦ 3 (0) = β7 β7 β13 β π¦ 1 (0) π¦ 2 (0) π¦ 3 (0) = 19/18 β4/3 28/9 3) Solve the linear system: π¨π π =π 4) update π (1) = β πΏ (π) = πΏ (π) + π (π) Repeat (1 - 4)
17
Some Comments on Root finding
clear; clc f [ x(1)^2+x(2)+β¦ x(3)^2-8;2*x(1)+3*x(2)^2-x(3)-11; x(1)^2+x(2)^2+x(3)^2-14]; x=[1;-1;1]; format short for n=1:10 [J] = jacob(x); F = - f(x); y = J\F x = x + y end x function [J] = jacob(x); J=[ 2*x(1) *x(3); ... *x(2) ; β¦ 2*x(1) 2*x(2) *x(3)]; 1 2 3 4 n π π (π) π π (π) π π (π) π₯ π₯ 2 + π₯ 3 2 =8 2π₯ π₯ 2 2 β π₯ 3 =11 π₯ π₯ π₯ 3 2 =14
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.