CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www. cse. psu

Slides:



Advertisements
Similar presentations
Numerical Computation Lecture 4: Root Finding Methods - II United International College.
Advertisements

Lecture 5 Newton-Raphson Method
Roundoff and truncation errors
Binary Addition Rules Adding Binary Numbers = = 1
CSE Differentiation Roger Crawfis. May 19, 2015OSU/CIS 5412 Numerical Differentiation The mathematical definition: Can also be thought of as the.
EE 382 Processor DesignWinter 98/99Michael Flynn 1 AT Arithmetic Most concern has gone into creating fast implementation of (especially) FP Arith. Under.
A few words about convergence We have been looking at e a as our measure of convergence A more technical means of differentiating the speed of convergence.
Open Methods (Part 1) Fixed Point Iteration & Newton-Raphson Methods
Copyright 2008 Koren ECE666/Koren Part.9b.1 Israel Koren Spring 2008 UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering Digital Computer.
VLSI Arithmetic. Multiplication A = a n-1 a n-2 … a 1 a 0 B = b n-1 b n-2 … b 1 b 0  eg)  Shift.
CSE 246: Computer Arithmetic Algorithms and Hardware Design Instructor: Prof. Chung-Kuan Cheng Winter 2004 Lecture 10 Thursday 02/19/02.
Revision.
CSE 246: Computer Arithmetic Algorithms and Hardware Design Instructor: Prof. Chung-Kuan Cheng Fall 2006 Lecture 8: Division.
Addition Subtraction Multiplication Division
Computer Arithmetic Integers: signed / unsigned (can overflow) Fixed point (can overflow) Floating point (can overflow, underflow) (Boolean / Character)
Ch. 21. Square-rootingSlide 1 VI Function Evaluation Topics in This Part Chapter 21 Square-Rooting Methods Chapter 22 The CORDIC Algorithms Chapter 23.
Derivative of an Inverse AB Free Response 3.
CISE301_Topic11 CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4:
CSCI 125 & 161 Lecture 13 Martin van Bommel. Floating Point Data Floating point numbers are not exact Value 0.1 in binary is very close to 1/10, but not.
Digital Kommunikationselektronik TNE027 Lecture 2 1 FA x n –1 c n c n1- y n1– s n1– FA x 1 c 2 y 1 s 1 c 1 x 0 y 0 s 0 c 0 MSB positionLSB position Ripple-Carry.
Advanced Algebraic Algorithms on Integers and Polynomials Prepared by John Reif, Ph.D. Analysis of Algorithms.
June 2007 Computer Arithmetic, Function EvaluationSlide 1 VI Function Evaluation Topics in This Part Chapter 21 Square-Rooting Methods Chapter 22 The CORDIC.
1/30 Division by Convergence 授課老師:王立洋老師 製作學生: M 蔡鐘葳.
Lecture 6 Numerical Analysis. Solution of Non-Linear Equations Chapter 2.
Numerical Methods.
Dr. Jie Zou PHY Chapter 2 Solution of Nonlinear Equations: Lecture (II)
Newton-Raphson Method. Figure 1 Geometrical illustration of the Newton-Raphson method. 2.
§3.6 Newton’s Method. The student will learn about
Newton-Raphson Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul Transforming Numerical Methods Education.
Solving 1-Step Equations 2 An Equation is Like a Balance.
CSE 330: Numerical Methods. Introduction The bisection and false position method require bracketing of the root by two guesses Such methods are called.
More Binary Arithmetic - Multiplication
Newton-Raphson Method
Numerical Methods Some example applications in C++
Newton-Raphson Method
Root Finding Methods Fish 559; Lecture 15 a.
CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www. cse. psu
Dr. Clincy Professor of CS
Addition Subtraction Multiplication Division
UNIVERSITY OF MASSACHUSETTS Dept
Addition Subtraction Multiplication Division
Lecture 9: Floating Point
Secant Method.
CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www. cse. psu
CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www. cse. psu
CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www. cse. psu
Chapter 6 Floating Point
Outline Introduction Floating Point Arithmetic Adder Multiplier.
UNIVERSITY OF MASSACHUSETTS Dept
CSE 575 Computer Arithmetic Spring 2005 Mary Jane Irwin (www. cse. psu
Addition Subtraction Multiplication Division
CSE 575 Computer Arithmetic Spring 2002 Mary Jane Irwin (www. cse. psu
CSE Differentiation Roger Crawfis.
Secant Method – Derivation
Chapter 6.
Numerical Analysis Lecture 45.
Roots of equations Class VII.
Newton-Raphson Method
Computers in Civil Engineering 53:081 Spring 2003
Addition Subtraction Multiplication Division
Newton-Raphson Method
UNIVERSITY OF MASSACHUSETTS Dept
Addition Subtraction Multiplication Division
3.8 Newton’s Method How do you find a root of the following function without a graphing calculator? This is what Newton did.
Newton-Raphson Method
CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www. cse. psu
Chapter 6.
1 Newton’s Method.
Errors and Error Analysis Lecture 2
CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4: KFUPM CISE301_Topic1.
Presentation transcript:

CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www. cse. psu CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www.cse.psu.edu/~mji) These slides need more work!!

Division by Reciprocation Assuming a fast multiplier is provided, another way to do division is via reciprocation Q = P/D  P * 1/D that can be particularly efficient if several divisions by the same divisor need to be performed. Compute reciprocal by Series expansion (Taylor series) Additive iteration (Newton-Raphson) Also consider that divide happens infrequently would like divide time to approx. equal multiply time (if possible)

Two Goals Shoot for logarithmic convergence (e.g., double the number of “resolved” quotient bits each iteration) Use only simple operations (e.g., add, subtract, compare, multiply)

Reciprocation by Series Expansion Let D = 1 + X and ½ ≤ D < 1 Then, based on the Maclaurin series g(X) = 1/D = 1/(1+X) = 1 – X + X2 –X3 +X4 - . . . and since X = D - 1, the above can be factored (for ½ ≤ D < 1) into 1/D = (1 - X)(1 + X2)(1 + X4)(1 + X8)(1 + X16). . . Notice that the 2’sc of 1 + Xj = 1 - Xj since 2 – (1 + Xj) = 1 - Xj and (1 + Xj) (1 - Xj) = 1 - X2j Maclaurin series is a special case of the Taylor series

IBM 360/91 Approach Compute 1/D to 32-bit precision via (1 – X)(1 + X2)(1 + X4) by table look-up 1 - X8 = [(1 – X)(1 + X2)(1 + X4)](1 + X) 1 + X8 is the 2’sc of 1 - X8 1 – X16 = (1 + X8)(1 – X8) 1 + X16 is the 2’sc of 1 – X16 1 – X32 = (1 + X16)(1 – X16) 1 + X32 is the 2’sc of 1 – X32 Requires a 28 x 8 table look-up and three multiplies to compute the needed terms start off with a ROM table look up (for speed) - want to start off with 8 bits (to the right of the binary point) “correct” so need an 2**8 x8 bit ROM (or better a 2**10x8 bit ROM) to give the first 8 bits of the inverse

Series Expansion Calculations 1/D = (1 - X)(1 + X2)(1 + X4)(1 + X8)(1 + X16) (1 + X32) table look-up (1 + X) * (1 - X8) * 2s’c (1 + X8) * * (1 – X16) 2s’c (1 + X16) Need two multipliers per iteration * * (1 – X32) 2s’c (1 + X32)

Additive Iteration Function must be based on a continuous and differentiable function of the form f(X) = 0 finding the root of Q = P/D or 1/D (or something close) where we can develop an iterative method for finding the root where the iterations contain only simple operations (i.e., no divide)

Newton-Raphson Approach Newton-Raphson method Determine a root of f(X) = 0 giving the iterative recurrence Xi+1 = Xi - f(Xi)/f’(Xi) f’(Xi) = f(Xi)/(Xi-Xi+1) f(X) Xi+1 Xi tangent at Xi a second order equations (I.e., uses the 1st derivative) and will need 2 multiplies per iteration Xi+2 Root

Newton-Raphson Reciprocation Newton-Raphson applied to reciprocation uses f(X) = 1/X – D = 0 which has a root at X = 1/D Since f’(X) = -(1/X)2, gives the recurrence Xi+1 = Xi (2 – XiD) Chose X0 such that 0 < X0 < 2/D Requiring two multipliers per iteration In general, for D in [1/2, 1) so that 1/D is in (1,2] -> picking X0 = 1.5 is simple and adequate (and since error0 < 1/D convergence is guaranteed) or choosing X0 = 1 also converges and first iteration only requires one multiply choosing X0 = 1 approaches the root from below f(X) is continuous and differentiable and 1/X = D, so X = 1/D so it has a root at the reciprocal simple iteration using 2 multiplies

Decimal Example Find 1/D where D = 0.75 (1/D= 1.33333. . .) For lecture X3 = . . . = 1.333313 3 = 0.000021

Convergence Rate Gives quadratic convergence (i+1 ≤ |i|2) Xi+1 = Xi (2 – XiD) and i = 1/D – Xi So Xi = 1/D - i = (1 – Di )/D and i+1 = 1/D – Xi+1 i+1 = 1/D – [Xi (2–XiD)] = [1-2DXi+(DXi)2]/D And substituting for Xi i+1 = [1 - 2D((1–D i)/D) + (1–Di)2]/D = D i2 Recall that D < 1, so i+1 ≤ |i|2 to get 32 bits of precision, need 5 iterations each requiring two multiplies

Binary Example Find 1/D where D = 0.75 = 0.1100 X1 = 2-D = 01.0100 = 1.25 1 ≤ 2-2 X2 = 01.01010100 = 2 ≤ 2-4 For lecture X3 = 01.0101010101010100 = 3 ≤ 2-8

Initial Values For D in [½, 1) a good initial value would be X0 = 1.5 since it limits 0 to the maximum of 0.5 A better approximation would be X0 = 4(√3 – 1) - 2D = 2.9282 - 2D that can be obtained easily and quickly from D by shifting and adding

Speeding it Up Iterative division takes 2log2n - 1 multiplications So with 64-bit numbers and a 5 ns multiplier, division would need 2*6 - 1 = 55 ns Speedups are possible through Reducing the number of multiplies by doing a better initial guess (e.g., with a table look-up) Using narrower multiplications Performing the multiply faster

Key References Anderson, The IBM system 360/91 floating point execution unit, IBM J Res. Development, 11(1):34-53, 1967. Flynn, On division by functional iteration, IEEE Trans. on Computers, C-19(8): 702-706, 1970. Oberman and Flynn, Division algorithms and implementation, IEEE Trans. on Computers, C-46(8):833-854, 1997. Waser and Flynn, Introduction to Arithmetic for Digital Systems Designers, HRW, 1982.