1. Trang chủ
  2. » Công Nghệ Thông Tin

Giới thiệu về các thuật toán - lec24

4 142 0
Tài liệu được quét OCR, nội dung có thể không chính xác
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Numerics
Trường học Massachusetts Institute of Technology
Chuyên ngành Introduction to Algorithms
Thể loại bài giảng
Năm xuất bản 2008
Thành phố Cambridge
Định dạng
Số trang 4
Dung lượng 171,08 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Giới thiệu về các thuật toán -

Trang 1

6.006 Introduction to Algorithms

Spring 2008

For information about citing these materials or our Terms of Use, visit: htto://ocw.mit.edu/terms.

Trang 2

Lecture 24: Numerics II

Lecture Overview

e Review:

— high precision arithmetic

— multiplication

e Division

— Algorithm

— Error Analysis

e Termination

Review:

Want millionth digit of 2:

[v2 - 102 đ = 109

Compute |./a]| via Newton’s Method

xo = 1 (initial guess) Xi+1 = ae Tự — division!

Converges quadratically; ÿ correct digits doubles each step

Multiplication:

1 Naive Divide & Conquer method: 6(d?) time

2 Karatsuba: 0(d198: 3) — 60(d1584 )

3 Toom-Cook generalizes Karatsuba (break into k > 2 parts )

T(d) = 5T(d/3) + 0(d) = 0 (a?) = 9 (a4)

4 Schonhage-Strassen - almost linear! 6(d lgdlglgd) using FFT All of these are in gmpy package

5 Furer(2007): @ (n log n20 los" ”) where log” ?› is iterated logarithm ‡ times log needs

to be applied to get a number that is less than or equal to 1

Trang 3

High Precision Division

a

We want high precision rep of 3

1

e Compute high-precision rep of ọ first

e High-precision rep of ; means lz! where R is large value s.t it is easy to divide by

R

Ex: R = 2" for binary representations

Division

Rk Newton’s Method for computing ?

f(z) = = RB (zero atx = 2)

—Ì

¿-9

Xi+1 — Xi — Fx) = Xi — —

1 6b by;? > multiply

2 2

Example

R 2'© 65536

t — = — = — =13107.2

216

Try initial guess —— = 21

Xo = 2'* = 16384

Xxi = 2- (16384) — 5(16384)?/65536 = 12288 x2 = 2- (12288) — 5(12288)?/65536 = 13056 x3 = 2- (13056) — 5(13056)?/65536 = 13107

Trang 4

Error Analysis

Yur = XA R Assume x; = — (1+ €;) b

= 2 (1+4) 2— 7) —ms | x} n1) (1+ 4) Gta

= (2+ 24) = (Lt 26+ i ))

= x=ø7)=T (+) where €j41 = —e;"

Quadratic convergence; { digits doubles at each step

Therefore complexity of division = complexity of multiplication

Termination

Iteration: yj;41 = it Lebel)

Do floors hurt? Does program terminate?

Iteration is

Nit -@

Nit

= n7 wherey = 5 + Sand0<7<1

Since 5 > Vab, 5 > Va, so subtracting + always leaves us > |vwœ| This won't stay stuck above ife; <1 (good initial guess)

Ngày đăng: 15/11/2012, 10:24

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN