Application - Ray Tracing and Bézier surfaces. TANA09 Lecture 3. Error Estimate. Application - Ray tracing and Beziér surfaces.

Similar documents
MATH ASSIGNMENT 03 SOLUTIONS

Numerical Methods I Solving Nonlinear Equations

ROOT FINDING REVIEW MICHELLE FENG

MATH 3795 Lecture 13. Numerical Solution of Nonlinear Equations in R N.

THE SECANT METHOD. q(x) = a 0 + a 1 x. with

Outline. Math Numerical Analysis. Intermediate Value Theorem. Lecture Notes Zeros and Roots. Joseph M. Mahaffy,

Math Numerical Analysis

Scientific Computing. Roots of Equations

CHAPTER 2 POLYNOMIALS KEY POINTS

3.1 Introduction. Solve non-linear real equation f(x) = 0 for real root or zero x. E.g. x x 1.5 =0, tan x x =0.

Fixed Points and Contractive Transformations. Ron Goldman Department of Computer Science Rice University

SOLUTION OF ALGEBRAIC AND TRANSCENDENTAL EQUATIONS BISECTION METHOD

Computational Methods CMSC/AMSC/MAPL 460. Solving nonlinear equations and zero finding. Finding zeroes of functions

PART I Lecture Notes on Numerical Solution of Root Finding Problems MATH 435

NON-LINEAR ALGEBRAIC EQUATIONS Lec. 5.1: Nonlinear Equation in Single Variable

Numerical Methods Lecture 3

Numerical solutions of nonlinear systems of equations

Lecture 8. Root finding II

Numerical Solution of f(x) = 0

Jim Lambers MAT 460/560 Fall Semester Practice Final Exam

Chapter 3: Root Finding. September 26, 2005

Lecture 39: Root Finding via Newton s Method

INTRODUCTION TO NUMERICAL ANALYSIS

Math 471. Numerical methods Introduction

Numerical Analysis Fall. Roots: Open Methods

Numerical Methods in Physics and Astrophysics

Chapter 4. Solution of Non-linear Equation. Module No. 1. Newton s Method to Solve Transcendental Equation

Chapter 1 Mathematical Preliminaries and Error Analysis

Introductory Numerical Analysis

CS 323: Numerical Analysis and Computing

Midterm Review. Igor Yanovsky (Math 151A TA)

Numerical Methods in Physics and Astrophysics

Lecture Notes to Accompany. Scientific Computing An Introductory Survey. by Michael T. Heath. Chapter 5. Nonlinear Equations

Math /Foundations of Algebra/Fall 2017 Numbers at the Foundations: Real Numbers In calculus, the derivative of a function f(x) is defined

Numerical techniques to solve equations

Nonlinearity Root-finding Bisection Fixed Point Iteration Newton s Method Secant Method Conclusion. Nonlinear Systems

Math Numerical Analysis Mid-Term Test Solutions

STOP, a i+ 1 is the desired root. )f(a i) > 0. Else If f(a i+ 1. Set a i+1 = a i+ 1 and b i+1 = b Else Set a i+1 = a i and b i+1 = a i+ 1

NUMERICAL AND STATISTICAL COMPUTING (MCA-202-CR)

Finding the Roots of f(x) = 0. Gerald W. Recktenwald Department of Mechanical Engineering Portland State University

Finding the Roots of f(x) = 0

Math 4329: Numerical Analysis Chapter 03: Newton s Method. Natasha S. Sharma, PhD

x x2 2 + x3 3 x4 3. Use the divided-difference method to find a polynomial of least degree that fits the values shown: (b)

Solution of Algebric & Transcendental Equations

Simple Iteration, cont d

Root Finding Convergence Analysis

1.1: The bisection method. September 2017

Roots of equations, minimization, numerical integration

SYSTEMS OF NONLINEAR EQUATIONS

Roots of Equations. ITCS 4133/5133: Introduction to Numerical Methods 1 Roots of Equations

Computing roots of polynomials by quadratic clipping

Variable. Peter W. White Fall 2018 / Numerical Analysis. Department of Mathematics Tarleton State University

MA 8019: Numerical Analysis I Solution of Nonlinear Equations

FIXED POINT ITERATION

We consider the problem of finding a polynomial that interpolates a given set of values:

Math 4329: Numerical Analysis Chapter 03: Fixed Point Iteration and Ill behaving problems. Natasha S. Sharma, PhD

Solutions of Equations in One Variable. Newton s Method

CS 450 Numerical Analysis. Chapter 5: Nonlinear Equations

MATH 1902: Mathematics for the Physical Sciences I

Outline. Scientific Computing: An Introductory Survey. Nonlinear Equations. Nonlinear Equations. Examples: Nonlinear Equations

Downloaded from

Root Finding (and Optimisation)

15 Nonlinear Equations and Zero-Finders

University of Houston, Department of Mathematics Numerical Analysis, Fall 2005

NUMERICAL METHODS. x n+1 = 2x n x 2 n. In particular: which of them gives faster convergence, and why? [Work to four decimal places.

CS 323: Numerical Analysis and Computing

Homework 2 - Solutions MA/CS 375, Fall 2005

Lecture 10: Finite Differences for ODEs & Nonlinear Equations

Newton s Method and Linear Approximations

Math 1A UCB, Fall 2010 A. Ogus Solutions 1 for Problem Set 4

Analysis Methods in Atmospheric and Oceanic Science

Scientific Computing: An Introductory Survey

1. Method 1: bisection. The bisection methods starts from two points a 0 and b 0 such that

Solution of a System of ODEs with POLYMATH and MATLAB, Boundary Value Iterations with MATLAB

Nonlinearity Root-finding Bisection Fixed Point Iteration Newton s Method Secant Method Conclusion. Nonlinear Systems

Analysis Methods in Atmospheric and Oceanic Science

Lecture 23: Hermite and Bezier Curves

Two hours. To be provided by Examinations Office: Mathematical Formula Tables. THE UNIVERSITY OF MANCHESTER. 29 May :45 11:45

1 Review of Interpolation using Cubic Splines

Goals for This Lecture:

INTERPOLATION. and y i = cos x i, i = 0, 1, 2 This gives us the three points. Now find a quadratic polynomial. p(x) = a 0 + a 1 x + a 2 x 2.

MATH 3795 Lecture 12. Numerical Solution of Nonlinear Equations.

Lecture 44. Better and successive approximations x2, x3,, xn to the root are obtained from

Solving nonlinear equations (See online notes and lecture notes for full details) 1.3: Newton s Method

Homework and Computer Problems for Math*2130 (W17).

The reference [Ho17] refers to the course lecture notes by Ilkka Holopainen.

DRAFT - Math 101 Lecture Note - Dr. Said Algarni

Motivation: We have already seen an example of a system of nonlinear equations when we studied Gaussian integration (p.8 of integration notes)

Order of convergence

Lectures 9-10: Polynomial and piecewise polynomial interpolation

Numerical Methods. Root Finding

Announcements. Topics: Homework:

CS 221 Lecture 9. Tuesday, 1 November 2011

Tu: 9/3/13 Math 471, Fall 2013, Section 001 Lecture 1

Nonlinear Equations and Continuous Optimization

Numerical Analysis. EE, NCKU Tien-Hao Chang (Darby Chang)

The problems that follow illustrate the methods covered in class. They are typical of the types of problems that will be on the tests.

p 1 p 0 (p 1, f(p 1 )) (p 0, f(p 0 )) The geometric construction of p 2 for the se- cant method.

Queens College, CUNY, Department of Computer Science Numerical Methods CSCI 361 / 761 Spring 2018 Instructor: Dr. Sateesh Mane.

Jim Lambers MAT 419/519 Summer Session Lecture 11 Notes

Transcription:

TANA09 Lecture 3 Application - Ray Tracing and Bézier surfaces Application - Ray tracing and Beziér surfaces. z = B(x, y) q o Error estimate. Cancellation. The Newton-Raphson method. Analysis. Order of convergence. The Secant method. Single and double roots. x y Application - Implementation of the square root. A ray of light originates from o and points in the direction q. Where does the line p(t) = o + t q intersect the surface z = B(x, y)? 12 november 2018 Sida 1 / 26 12 november 2018 Sida 2 / 26 Algorithm We solve the problem by the steps Error Estimate The surface patch associated with a certain polygon is given by a cubic polynomial. z = B(x, y), where x, y, and z are the local coordinates. Write the vectors o och p in the local coordinates. Find the root of the polynomaial f(x) x f(t) = o z + tq z B(o x + tq x, o y + tq y ) = 0. Spline surfaces and curves is the last exercise of the course. Masters thesis Joakim Löv, 2006. Implementation on a GPU. Question A numerical method generates a sequence x k x, where x is a root of the equation f(x) = 0. What is a suitable stopping criteria? Let x be an approximation of the root x. Can we estimate the error x x? 12 november 2018 Sida 3 / 26 12 november 2018 Sida 4 / 26

The Newton-Raphson method Lemma Let x be an approximation of the root x. Then f 0 x x f( x) M, where f (x) M near the root x. f 1 x 2 x 1 x 0 x Exemple We have found an approximate root x = 0.56714335 to the equation f(x) = x e x. Estimate the error. Remark Usually we have cancellation in the computation of the function value f( x). If f( x) µ we cannot neglect the computational errors. Newton-Raphson Given x 0 we compute a sequence x k+1 = x k f(x k) f, k = 0, 1, 2... (x k ) 12 november 2018 Sida 5 / 26 12 november 2018 Sida 6 / 26 Exemple Solve the equation f(x) = x e x = 0. Here we have f (x) = 1+e x. k x k f(x k ) 0 0.550000000 2.69 10 2 1 0.567089834 8.38 10 5 2 0.567143290 8.10 10 10 Order of convergence Definition Let{x k } be a sequence that converges to x. The order of convergence is the largest integer p such that lim k x k x x k 1 x p = C <. Very fast convergence. Always convergence to a single root if the starting approximation is good enough. Two function calls in each step (both f(x) and f (x)). Requires that f (x) is available. Remark If p = 1 the convergence is linear and if p = 2 we have quadratic convergence. Example Consider the fixed point iteration x k+1 = φ(x k ) = e x k. Show that the convergence is linear. 12 november 2018 Sida 7 / 26 12 november 2018 Sida 8 / 26

The Secant method Theorem Let{x k } be the sequence computed by Newton-Raphsons method. If the method converges to a single root x then x k+1 x C x k x 2, Thus the order of convergence is p = 2. Exemple Suppose x k+1 x 3.5 x k x 2 och x 0 x < 0.5 10 2. What does this mean in practice? What happens if we have a double root? If the derivative f (x) is unavailable we can approximate f (x k ) f(x k) f(x k 1 ) x k x k 1. Secant method Given x 0 and x 1 we computes a sequence ( ) f(xk ) f(x k 1 ) 1 x k+1 = x k f(x k ). x k x k 1 Questions What is the order of comvergence? Stable? 12 november 2018 Sida 9 / 26 12 november 2018 Sida 10 / 26 Exemple Solve the equation f(x) = x e x = 0 using the Secant method. k x k f(x k ) 0 0.700000000000000 2.03 10 1 1 0.600000000000000 5.12 10 2 2 0.566373515585849 1.21 10 3 3 0.567147844602993 7.14 10 6 4 0.567143291044208 9.94 10 10 5 0.567143290409783 8.9 10 16 6 0.567143290409784 1.11 10 16 Lemma The rate of convergence is given by log(ε k /ε k 1 ) p = lim k log(ε k 1 /ε k 2 ), where ε k = x k x. Example The iterations x 2, x 3 and x 4, with ε k = x k x 6, gives p log(ε 4/ε 3 ) log(ε 4 /ε 3 ) = 1.7308... Instead using x 3, x 4 and x 5 we get p 1.57. Very fast convergence. How to estimate the rate of convergence p? Theorem The order of convergence for the Secant method is p = (1+ 5)/2 1.618. 12 november 2018 Sida 11 / 26 12 november 2018 Sida 12 / 26

Double roots Example Solve f(x) = (x e x ) 2 using Newtons method. Definition A function f(x) has a root x of multiciplicity k if we can write f(x) = (x x ) k g(x), where g(x ) 0. Example For a single root as have f(x ) = 0 and f (x ) 0. For a double root both f(x ) = 0 and f (x ) = 0. Question How to modify the error estimate to cover the case of double roots? k x k f(x k ) 0 0.550000000000000 7.3 10 4 1 0.581851788560507 5.3 10 4 2 0.555794973335401 3.2 10 4 3 0.576692919807852 2.2 10 4 4 0.559647895670487 1.4 10 4 5 0.57337002513594 9.5 10 5 10 0.565003205175893 1.1 10 5 20 0.566881467726078 1.7 10 7 This is clearly linear convergence! Lemma If x is a double root then Newtons method has the order of convergence p = 1. 12 november 2018 Sida 13 / 26 12 november 2018 Sida 14 / 26 Application - The square root Lemma Let x be an approximation of a double root x. Then ( ) 2 f( x) 1/2 x x, M where M f (ξ), ξ ( x, x ). Example Let x = 0.56689 be an approximate root to f(x) = (x e x ) 2. Estimate the error x x. Remark For double roots we get drastically slower convergence and worse error estimates. Tripple roots? Problem Implement a as efficiently as possible on a computer with IEEE double precision arithmetic. Solve the equation f(x) = x 2 a using the Newton-Raphson method. Pick the starting approximation x 0 and use that a is a normalized floating point number so 1 a < 4 and 1 x < 2. Determine the number of iteratioins. We want afor-loop and not awhile-loop. Confirm that the accuracy is accaptable. We prefer a relative error µ. 12 november 2018 Sida 15 / 26 12 november 2018 Sida 16 / 26

Theorem For every 0 < x 0 < the iteration sequence is convergent and x k+1 = 1 2 (x k + a x k ) lim x k = a. k Lemma The convergence is quadratic and x k+1 a 1 2 (x k a) 2. The starting approximation x 0 = 1.5 gives an initial error x 0 a 1 2. Alternatively use a table a a 1.0 1.000000000000000 1.5 1.224744871391589 2.0 1.414213562373095 2.5 1.581138830084190 3.0 1.732050807568877 3.5 1.870828693386971 Now the initial error is at most x 0 a < 0.12. Larger table means fewer iterations. simpler to write in C++ due to bitoperations. 12 november 2018 Sida 17 / 26 12 november 2018 Sida 18 / 26 Matlab Implementation Experimental error analysis function [x]=squareroot(a) table=[1.000000000000000 1.224744871391589 1.414213562373095 1.581138830084190 1.732050807568877 1.870828693386971 2.000000000000000]; x=table(round(2*(a-1)+1)); for k=1:4,x=(x+a/x)/2;,end; A total of 4 divisions and 4 additions to compute a. How large is the error? There is only a finite number of floating point numbers 1 a < 4. Can test all cases! 12 november 2018 Sida 19 / 26 x 4 sqrt(a) [*µ] 2 1.8 1.6 1.4 1.2 1 0.8 0.6 0.4 0.2 0 1 1.5 2 2.5 3 3.5 4 a The differenceabs(squareroot(a)-sqrt(a)) for 1000 evenly distributed values a between 1 and 4. Equality in 751 cases and a 2µ difference in 249 cases. In order to make a better test we need to compute a with extended precision or trust the mathematical analysis. 12 november 2018 Sida 20 / 26

Equation solving in Matlab The function fzero solves non-linear equations. It is used by typing >> I = fzero( fun, x0 ); The funktionintegral computes integrals. It is used by typing >> I = integral( fun, a, b ); Exemple Compute the integral Exemple Solve the equation f(x) = e 2x x = 0. In Matlab we write >> f = @(x) exp(-2*x)-x; >> x = fzero( f, 1 ) x = 0.4263 For equation solving in multiple variables there is a function fsolve. Considerably more difficult to prove existance and also harder to obtain rapid convergence. 12 november 2018 Sida 21 / 26 In Matlab we type I = 1 0 (e 2x cos(x 2 )+4x)dx. >> f = @(x) exp(2*x).*cos(x.^2)+4*x; >> I = integral( f, 0, 1) I = 4.6736 12 november 2018 Sida 22 / 26 Application - How much of a boat is under water? Solution Given the water line y = c and the shape of the hull y = f(x) we can calculate how much water is beeing displaced. Problem The weight of a boat exactly corresponds to the weight of the displaced water. y x 0.5 y=c x=a x=b 0-0.5-1 -1.5-2 -0.5 0 0.5 1 1.5 2 2.5 3 3.5 Given a certain weight how can we calculate how much of the boat that is under water? 12 november 2018 Sida 23 / 26 Let g(c) be the displaced volume given the water level c. We have that g(c) = b a (f(x) c)dx. We want to solve g(c)ρ L = 0, where ρ is the densityt and L is the weight of the boat. 12 november 2018 Sida 24 / 26

Matlab We have a functionshipshape(x) and write a function Summary function V=DisplacedVolume( c ) a=fzero( @(x)shipshape(x)-c,0.4); % Root near x=0.4 b=fzero(@(x)shipshape(x)-c,2.5); % Root near 2.5 V=integral( @(x)shipshape(x)-c, a, b ); end Use the function to solve the problem in Matlab L=697; % Weight in kg. rho=998; % Density in kg/m3 c = fzero( @(c)displacedvolume( c )*rho-l, 0.9 ) c=1.0253 Equation solving is an important part of many applications. If both f(x) and f (x) are known the optimal choice is almost always Newton-Raphsons method. The secant method is almost as fast and does not require the derivative f (x). Fixed point iteration is both simple and easy to use but often slow. Used when other methods are difficult to apply. 12 november 2018 Sida 25 / 26 12 november 2018 Sida 26 / 26