Docsity

Math Review Lecture Notes, Lecture notes of Vector Analysis

Partial preview of the text

Download Math Review Lecture Notes and more Lecture notes Vector Analysis in PDF only on Docsity!

Lecture 4:

Math Review

Administrative

HW0 out, due 2/

HW1 out soon

This Lecture: Goal

  • Not a โ€œLinear algebra in one lectureโ€ โ€“ thatโ€™s

impossible.

  • You should have seen this before
  • Aimed at reviving your knowledge and plugging any

gaps

  • Aimed at giving you intuitions
  • Iโ€™ll intentionally go fast ; intent is for slides to be a

reference for you to review later

Floating Point Arithmetic

Free Drinks in Vegas

Each game/variable has mean $0.10, std $

100 games is

uncertain and

fun!

100K games is

guaranteed profit:

99.999999% lowest

value is $0.064.

$0.01 for drinks

$0.054 for profits

Letโ€™s make it big

  • Suppose we take the average of 50M normally

distributed numbers (mean=31, std=1)

  • Theory : Average is a normally distributed random

variable with mean 31 and std

(

)*+

โ‰ˆ 10

,)

  • Practice :

Result:

17.4695??

What is a number?

7

6

5

4

3

2

1

0

Adding two numbers

โ€œIntegersโ€ on a computer are integers modulo 2

k

Carry

Flag

Result

8

7

6

5

4

3

2

1

0

Some Gotchas

42

32 + 9 x 40 / 10 =

32 + 104 / 10 =

Overflow

32 + (9 x 40) / 10 =

uint

32 + (9 x 40) / 10 = 68

math

Why 104?

9 x 40 = 360

360 % 256 = 104

Should be:

9x4=

32 + 10 =

42

What is a number?

7

6

5

4

3

2

1

0

How can we do fractions?

5

4

3

2

1

0

  • 1
  • 2

Floating Point Numbers

Sign (S) Exponent (E)

Fraction (F)

๐‘บ

๐‘ฌ#๐’ƒ๐’Š๐’‚๐’”

๐Ÿ‘

7 - 7

0

Bias: allows exponent to be negative (bias = - 127 for float32)

Note: fraction = significant = mantissa;

exponents of all ones or all zeros are special numbers

Floating Point Numbers

Sign Exponent

Fraction

  • 2

0

x 1.00 = - 1

0/

  • 2

0

x 1.125 = - 1.

1/

  • 2

0

x 1.25 = - 1.

0 1 0

2/

  • 2

0

x 1.75 = - 1.

  • 2

0

x 1.875 = - 1.

6/

7/

7 - 7=

(-bias)

  • 1

โˆ’๐Ÿ

๐‘บ

๐Ÿ

๐‘ฌ#๐’ƒ๐’Š๐’‚๐’”

๐Ÿ +

๐‘ญ

๐Ÿ

๐Ÿ‘

Floating Point Numbers

Sign Exponent

Fraction

  • 2

0

x 1.00 = - 1

  • 2

0

x 1.125 = - 1.

  • 2

2

x 1.00 = - 4

  • 2

2

x 1.125 = - 4.

Gap between numbers is relative , not absolute

Adding Floating Point Numbers

Sign Exponent Fraction

  • 2

2

x 1.00 = - 4

  • 2
    • 1

x 1.00 = - 0.

  • 2

2

x 1.125 = - 4.

Actual implementation is complex