FOUNDATIONS - Korea University
Download
Report
Transcript FOUNDATIONS - Korea University
Graphics
2. Solving Equations
of One Variable
Korea University Computer Graphics Lab.
Lee Seung Ho / Shin Seung Ho
Roh Byeong Seok / Jeong So Hyeon
kucg.korea.ac.kr
Graphics Lab @ Korea University
Contents
KUCG
Bisection Method
Regula Falsi and Secant Method
Newton’s Method
Muller’s Method
Fixed-Point Iteration
Matlab’s Method
kucg.korea.ac.kr
Graphics Lab @ Korea University
Graphics
Bisection Method
kucg.korea.ac.kr
Graphics Lab @ Korea University
Bisection Method
KUCG
1
0.5
0
ab
m
2
-0.5
y x 3
-1
2
-1.5
-2
1
1.1
1.2
kucg.korea.ac.kr
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2
Graphics Lab @ Korea University
Finding the Square Root of 3 Using
Bisection
How can we get
y x 3
2
KUCG
3?
y 0: x 3
3
b1 a1
error is at most
2k
kucg.korea.ac.kr
Graphics Lab @ Korea University
Approximating the Floating Depth
for a Cork Ball by Bisection(1/2)
KUCG
Cork ball
Radius : 1
Density : 0.25
y x 3x 1
3
2
if y 0,
we can get floatingdepth of cork ball by x [0,1]
kucg.korea.ac.kr
Graphics Lab @ Korea University
Approximating the Floating Depth
for a Cork Ball by Bisection(2/2)
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Discussion of Bisection Method
kucg.korea.ac.kr
KUCG
Graphics Lab @ Korea University
Fixed-Point Iteration
KUCG
x g (x)
Solution of equation
Convergence Theorem of fixed-point iteration
if 1 g ( x) 1 / 2,
xk x xk xk 1
kucg.korea.ac.kr
Graphics Lab @ Korea University
Fixed-Point Iteration to Find a Zero
of a Cubic Function
KUCG
f ( x) 5 x 3 10x 3 0,
10x 5 x 3 3
x 0.5 x 3 0.3 g ( x)
g ( x) 1.5 x 2
kucg.korea.ac.kr
Graphics Lab @ Korea University
Matlab’s Methods(1/2)
roots(p)
KUCG
p : vector
Example
3
2
p
(
x
)
x
7
x
14x 7
EDU> r = roots(p); (p=[1 -7 14 -7])
r = 3.8019
2.445
0.75302
kucg.korea.ac.kr
Graphics Lab @ Korea University
Matlab’s Methods(2/2)
fzero( ‘function name’,x0 )
KUCG
function name: string
x0 : initial estimate of the root
Example
function y = flat10(x)
y = x.^10 – 0.5;
z = fzero(‘flat10’,0.5)
z = 0.93303
kucg.korea.ac.kr
Graphics Lab @ Korea University
Graphics
Regular Falsi and
Secant Methods
2005. 3. 23
Byungseok Roh
kucg.korea.ac.kr
Graphics Lab @ Korea University
Regula Falsi Method
KUCG
The regula falsi method start with two point, (a, f(a)) and
(b,f(b)), satisfying the condition that f(a)f(b)<0.
The straight line through the two points (a, f(a)), (b, f(b)) is
y f (a)
f (b) f (a )
( x a)
ba
The next approximation to the zero is the value of x where the
straight line through the initial points crosses the x-axis.
x a
kucg.korea.ac.kr
ba
af (b) bf (a)
f (a)
f (b) f (a)
f (b) f (a)
Graphics Lab @ Korea University
Regula Falsi Method (cont.)
KUCG
If there is a zero in the interval [a, c],
we leave the value of a unchanged
and set b = c.
On the other hand, if there is no zero
in [a, c], the zero must be in the
interval [c, b]; so we set a = c and
leave b unchanged.
The stopping condition may test the size of y, the amount by which the
approximate solution x has changed on the last iteration, or whether the
process has continued too long.
Typically, a combination of these conditions is used.
kucg.korea.ac.kr
Graphics Lab @ Korea University
Example
KUCG
Finding the Cube Root of 2 Using Regula Falsi
Since f(1)= -1, f(2)=6, we take as our
starting bounds on the zero a=1 and b=2.
Our first approximation to the zero is
ba
2 1
( f (b)) 2
(6)
f (b) f (a)
6 1
2 6 / 7 8 / 7 1.1429
x b
We then find the value of the function:
y f ( x) (8 / 7)3 2 0.5073
Since f(a) and y are both negative, but y
and f(b) have opposite signs
kucg.korea.ac.kr
Graphics Lab @ Korea University
Example (cont.)
Calculation of
kucg.korea.ac.kr
3
KUCG
2 using regula falsi.
Graphics Lab @ Korea University
Secant Method
KUCG
The secant method, closely related to the regula falsi method,
results from a slight modification of the latter.
Instead of choosing the subinterval that
must contain the zero, we form the next
approximation from the two most recently
generated points:
x1 x0
x2 x1
y1
y1 y0
At the k-th stage, the new approximation
to the zero is
xk 1 xk
xk xk 1
yk
yk yk 1
The secant method has converged with a tolerance of 104.
kucg.korea.ac.kr
Graphics Lab @ Korea University
Example
KUCG
Finding the Square Root of 3 by Secant Method
To find a numerical approximation to
y f ( x) x 2 3.
3 , we seek the zero of
Since f(1)=-2 and f(2)=1, we take as our starting bounds on the
zero x0 1 and x1 2 .
Our first approximation to the zero is
x2 x1
x1 x0
2 1
5
y1 2
(1) 1.667
y1 y0
1 (2)
3
Calculation of
kucg.korea.ac.kr
3 using secant method.
Graphics Lab @ Korea University
Graphics
NEWTON’S METHOD
kucg.korea.ac.kr
Graphics Lab @ Korea University
Newton’s Method
KUCG
Newton’s method uses straight-line approximation which is the
tangent to curve.
.
f ( x) f ' ( x0 )(x x0 ) f ( x0 )
Intersection point
f ( x0 )
x1 x0
f ' ( x0 )
xk 1 xk
kucg.korea.ac.kr
f ( xk )
f ' ( xk )
Graphics Lab @ Korea University
Example
KUCG
Finding Square Root of ¾
3
4 approximate the zero of
f ( x) 4 x 2 3 using the fact
that f ' ( x) 8 x .
x1 x0
f ( x0 )
2
0 .5
1
f ' ( x0 )
4
Continuing for one more step
f ( x1 )
1
x2 x1
1.0 7 / 8 0.875
f ' ( x1 )
8
kucg.korea.ac.kr
Graphics Lab @ Korea University
Finding Floating Depth for a
Wooden Ball
KUCG
Volume of submerged
segment of the Sphere
V x(3r 2 x 2 ) / 6
To find depth at which the ball
float, volume of submerged
segment is time.
x(3r 2 x 2 ) / 6 (4 / 3)
Simplifies to
x3 3x 2 4 0
kucg.korea.ac.kr
Graphics Lab @ Korea University
Finding Floating Depth for a
Wooden Ball (cont.)
KUCG
To find depth a ball, density is one-third of water float.
f ( x) x3 3x 2 4 / 3
Calculation f(x) using Newton’s Method
kucg.korea.ac.kr
Graphics Lab @ Korea University
Oscillations in Newton Method
Ex)
KUCG
Newton’s method give Oscillatory result for some funtions & initial
estimates.
f ( x) x3 3x 2 x 3
kucg.korea.ac.kr
Graphics Lab @ Korea University
Graphics
Muller’s Method
kucg.korea.ac.kr
Graphics Lab @ Korea University
Muller’s Method
KUCG
based on a quadratic approximation
procedure
1.
2.
3.
Decide the parabola passing through (x1,y1), (x2, y2)
and (x3,y3)
Solve the zero(x4) that is closest to x3
Repeat 1,2 until x converge to predefined tolerance
advantage
Requires only function values;
Derivative need not be calculated
X can be an imaginary number.
kucg.korea.ac.kr
Graphics Lab @ Korea University
Muller’s Method (Cont’)
KUCG
y y3 c2 ( x x3 ) d1 ( x x3 )(x x2 )
y3 y 2
c2 c1
y2 y1
c1
c2
d1
x3 x1
x2 x1
x3 x2
x4 x3
kucg.korea.ac.kr
2 y3
s sign(s) s 2 4 y3d1
Graphics Lab @ Korea University
Example
KUCG
Finding the sixth root of 2 using Muller’s method
6
y
f
(
x
)
x
2, x1 0.5, x2 1.5 , x3 1.0
y1 1.9844, y2 9.3906, y3 1
c1
y2 y1
11.375
x2 x1
c2
y3 y2
20.781
x3 x2
D
c2 c1
18.812
x3 x1
s c2 d1 ( x3 x2 ) 20.781 18.812(0.5) 11.375
x4 x3
1
kucg.korea.ac.kr
2 y3
s sign( s ) s 2 4 y3d1
2(1)
11.375 11.375 4(1)18.812
2
1.0779
Graphics Lab @ Korea University
Example (Cont’)
i
x
KUCG
y
1
0.5
-1.9844
2
1.5
9.3906
3
1
-1
4
1.0779
-0.43172
5
1.117
-0.05635
6
1.1255
0.00076162
7
1.1255
-4.7432e-07
Calculation of
kucg.korea.ac.kr
6
converge
2 using Muller’s method
Graphics Lab @ Korea University
Another Challenging Problem
y x10 0.5
kucg.korea.ac.kr
KUCG
Tolerance = 0.0001
step
x
Y
1
0
-0.5
2
1
0.5
3
0.5
-0.49902
4
0.80875
-0.38029
5
0.9081
-0.11862
6
0.94325
0.057542
7
0.93269
-0.0018478
8
0.93303
-6.3021e-06
9
0.93303
-3.1235e-10
Graphics Lab @ Korea University
MATLAB function for Muller’s
Method
KUCG
P.65~66 code
kucg.korea.ac.kr
Graphics Lab @ Korea University