introduction to scientific computing · disasters problems themes deconstruction introduction to...

21
Disasters Problems Themes Deconstruction Introduction to Scientic Computing Steve Marschner Cornell CS 322 Cornell CS 322 Introduction to Scientic Computing 1

Upload: others

Post on 17-Oct-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Scientific Computing · Disasters Problems Themes Deconstruction Introduction to Scienti˝c Computing Steve Marschner Cornell CS 322 Cornell CS 322 Introduction to

Disasters Problems Themes Deconstruction

Introduction to Scienti�c Computing

Steve Marschner

Cornell CS 322

Cornell CS 322 Introduction to Scienti�c Computing 1

Page 2: Introduction to Scientific Computing · Disasters Problems Themes Deconstruction Introduction to Scienti˝c Computing Steve Marschner Cornell CS 322 Cornell CS 322 Introduction to

Disasters Problems Themes Deconstruction

Outline

Two numerical cautionary tales

Standard types of problems and solutions

Themes of CS322

Deconstructing matrix-vector products

Cornell CS 322 Introduction to Scienti�c Computing 2

Page 3: Introduction to Scientific Computing · Disasters Problems Themes Deconstruction Introduction to Scienti˝c Computing Steve Marschner Cornell CS 322 Cornell CS 322 Introduction to

Disasters Problems Themes Deconstruction

Ariane 5 explosion

Cornell CS 322 Introduction to Scienti�c Computing 3

Page 4: Introduction to Scientific Computing · Disasters Problems Themes Deconstruction Introduction to Scienti˝c Computing Steve Marschner Cornell CS 322 Cornell CS 322 Introduction to

Disasters Problems Themes Deconstruction

Ariane 5 explosion

First launch of Ariane 5 expendable launcher lost control andexploded at t + 40 sec.

Problem: number format conversion error

• Convert 64-bit FP (Matlab double ) 16-bit signed integer(Matlab int16 )

• Value is ≥ 215• Uncaught exception =⇒ crash of guidance system

Loss: 5× 108 dollars (that's $25,856 as an int16 )

Cornell CS 322 Introduction to Scienti�c Computing 3

Page 5: Introduction to Scientific Computing · Disasters Problems Themes Deconstruction Introduction to Scienti˝c Computing Steve Marschner Cornell CS 322 Cornell CS 322 Introduction to

Disasters Problems Themes Deconstruction

Patriot anti-missile system failure

Cornell CS 322 Introduction to Scienti�c Computing 4

Page 6: Introduction to Scientific Computing · Disasters Problems Themes Deconstruction Introduction to Scienti˝c Computing Steve Marschner Cornell CS 322 Cornell CS 322 Introduction to

Disasters Problems Themes Deconstruction

Patriot anti-missile system failure

Patriot had trouble hitting fast-moving targets, sometimes.

In 1991 a Scud missile hit a barracks, killing 28, triggering a USgovernment investigation. . .

• System makes time calculations to sync to radar• Starts to fail after it's been up for a day or so

Cornell CS 322 Introduction to Scienti�c Computing 4

Page 7: Introduction to Scientific Computing · Disasters Problems Themes Deconstruction Introduction to Scienti˝c Computing Steve Marschner Cornell CS 322 Cornell CS 322 Introduction to

Disasters Problems Themes Deconstruction

Patriot anti-missile system failure

Clock reads in tenths of a second since boot time

Software multiplies by 0.1 to get seconds

• Number format: �xed point with 24 bits of fraction◦ precision better than a millionth of a second◦ does not represent 1/10 exactly

What is the error in representing 0.1 and what is its effect?

Cornell CS 322 Introduction to Scienti�c Computing 4

Page 8: Introduction to Scientific Computing · Disasters Problems Themes Deconstruction Introduction to Scienti˝c Computing Steve Marschner Cornell CS 322 Cornell CS 322 Introduction to

Disasters Problems Themes Deconstruction

Sleipner A offshore platform failure

Norwegian offshore drilling platform collapses and sinks

Concrete structure designed using �nite element structural analysis

• What this means, roughly• Approximation not precise enough

An example of a higher-level problem→ maybe not a numerical one, really.These stories borrowed from Douglas Arnold

read more: http://www.ima.umn.edu/∼arnold/disasters/disasters.html

Cornell CS 322 Introduction to Scienti�c Computing 5

Page 9: Introduction to Scientific Computing · Disasters Problems Themes Deconstruction Introduction to Scienti˝c Computing Steve Marschner Cornell CS 322 Cornell CS 322 Introduction to

Disasters Problems Themes Deconstruction

Standard types of problems

• Systems of equations◦ linear geometric transformation circuit analysis◦ nonlinear orbital calculations

• Overconstrained systems◦ linear linear data modeling circuit analysis◦ nonlinear nonlinear data modeling

• Approximation◦ linear �tting polynomials◦ nonlinear �tting gamma curves

Cornell CS 322 Introduction to Scienti�c Computing 6

Page 10: Introduction to Scientific Computing · Disasters Problems Themes Deconstruction Introduction to Scienti˝c Computing Steve Marschner Cornell CS 322 Cornell CS 322 Introduction to

Disasters Problems Themes Deconstruction

Standard types of problems

• Optimization◦ nonlinear practically everything◦ constrained spacetime constraints◦ linear programming economics

• Integration◦ de�nite integrals (quadrature) lighting◦ differential equations

I initial value problem mechanical systemsI boundary value problem ordinary: hanging chain cloth, �uids

Cornell CS 322 Introduction to Scienti�c Computing 6

Page 11: Introduction to Scientific Computing · Disasters Problems Themes Deconstruction Introduction to Scienti˝c Computing Steve Marschner Cornell CS 322 Cornell CS 322 Introduction to

Disasters Problems Themes Deconstruction

Types of methods

• Direct (�xed sequence of operations leads to ananswer�number of steps is predetermined)

• Iterative (repeatedly re�ne an approximation until someaccuracy goal is reached�number of steps variable)

• Probabilistic (approximate the answer by some computationbased on a number of stochastic �experiments�)

Cornell CS 322 Introduction to Scienti�c Computing 7

Page 12: Introduction to Scientific Computing · Disasters Problems Themes Deconstruction Introduction to Scienti˝c Computing Steve Marschner Cornell CS 322 Cornell CS 322 Introduction to

Disasters Problems Themes Deconstruction

Properties of methods

• Accuracy• Stability• Rate of convergence• Execution time (time complexity)• Memory requirements (space complexity)

Cornell CS 322 Introduction to Scienti�c Computing 8

Page 13: Introduction to Scientific Computing · Disasters Problems Themes Deconstruction Introduction to Scienti˝c Computing Steve Marschner Cornell CS 322 Cornell CS 322 Introduction to

Disasters Problems Themes Deconstruction

Themes of CS322

• continuous mathematics• �nite precision arithmetic

◦ precision, accuracy◦ intuitive sense for precision

• high level thinking• stability

◦ of problems◦ of algorithms

Cornell CS 322 Introduction to Scienti�c Computing 9

Page 14: Introduction to Scientific Computing · Disasters Problems Themes Deconstruction Introduction to Scienti˝c Computing Steve Marschner Cornell CS 322 Cornell CS 322 Introduction to

Disasters Problems Themes Deconstruction

Themes of CS322

• iterative approximation◦ convergence (guarantees)◦ convergence (rate)

• ef�ciency◦ computational complexity◦ effective use of linear algebra libraries

• applications• visualization• direct vs. iterative methods• linear vs. nonlinear problems

Cornell CS 322 Introduction to Scienti�c Computing 9

Page 15: Introduction to Scientific Computing · Disasters Problems Themes Deconstruction Introduction to Scienti˝c Computing Steve Marschner Cornell CS 322 Cornell CS 322 Introduction to

Disasters Problems Themes Deconstruction

Deconstructing a matrix-vector product

There are a number of ways to think about the meaning of amatrix-vector product. Some examples follow, but �rst a moresystematic nomenclature:

Ax = ba11 a12 a13

a21 a22 a23

a31 a32 a33

x1

x2

x3

=

b1

b2

b3

This 3× 3 example can serve to de�ne this notation for any sizematrices and vectors. Note that the row index is �rst, then thecolumn index (contrary to C, Java, etc.).

Cornell CS 322 Introduction to Scienti�c Computing 10

Page 16: Introduction to Scientific Computing · Disasters Problems Themes Deconstruction Introduction to Scienti˝c Computing Steve Marschner Cornell CS 322 Cornell CS 322 Introduction to

Disasters Problems Themes Deconstruction

Deconstructing a matrix-vector productscalar level

A matrix-vector product is shorthand for a sum of products ofentries: a11 a12 a13

a21 a22 a23

a31 a32 a33

x1

x2

x3

=

b1

b2

b3

bi =

3∑j=1

aijxj for i = 1, 2, 3

Cornell CS 322 Introduction to Scienti�c Computing 11

Page 17: Introduction to Scientific Computing · Disasters Problems Themes Deconstruction Introduction to Scienti˝c Computing Steve Marschner Cornell CS 322 Cornell CS 322 Introduction to

Disasters Problems Themes Deconstruction

Deconstructing a matrix-vector productscalar level

A matrix-vector product is shorthand for a sum of products ofentries: a11 · · · a1n

.... . .

...an1 · · · ann

x1...

xn

=

b1...

bn

bi =

n∑j=1

aijxj for i = 1, . . . , n

Cornell CS 322 Introduction to Scienti�c Computing 11

Page 18: Introduction to Scientific Computing · Disasters Problems Themes Deconstruction Introduction to Scienti˝c Computing Steve Marschner Cornell CS 322 Cornell CS 322 Introduction to

Disasters Problems Themes Deconstruction

Deconstructing a matrix-vector productdot product

A matrix-vector product is shorthand for dot products with the rows:a11 a12 a13

a21 a22 a23

a31 a32 a33

x1

x2

x3

=

b1

b2

b3

� r1 �

� r2 �

� r3 �

|x|

=

r1 · xr2 · xr3 · x

=

b1

b2

b3

bi = ri · x for i = 1, 2, 3

Cornell CS 322 Introduction to Scienti�c Computing 12

Page 19: Introduction to Scientific Computing · Disasters Problems Themes Deconstruction Introduction to Scienti˝c Computing Steve Marschner Cornell CS 322 Cornell CS 322 Introduction to

Disasters Problems Themes Deconstruction

Deconstructing a matrix-vector productdot product

A matrix-vector product is shorthand for dot products with the rows:a11 · · · a1n.... . .

...an1 · · · ann

x1...

xn

=

b1...

bn

� r1 �

...

� rn �

|x|

=

r1 · x...

rn · x

=

b1...

bn

bi = ri · x for i = 1, . . . , n

Cornell CS 322 Introduction to Scienti�c Computing 12

Page 20: Introduction to Scientific Computing · Disasters Problems Themes Deconstruction Introduction to Scienti˝c Computing Steve Marschner Cornell CS 322 Cornell CS 322 Introduction to

Disasters Problems Themes Deconstruction

Deconstructing a matrix-vector productlinear combination

A matrix-vector product is shorthand for a linear combination ofcolumns: a11 a12 a13

a21 a22 a23

a31 a32 a33

x1

x2

x3

=

b1

b2

b3

| | |c1 c2 c3

| | |

x1

x2

x3

=

|b|

b = x1c1 + x2c2 + x3c3

Cornell CS 322 Introduction to Scienti�c Computing 13

Page 21: Introduction to Scientific Computing · Disasters Problems Themes Deconstruction Introduction to Scienti˝c Computing Steve Marschner Cornell CS 322 Cornell CS 322 Introduction to

Disasters Problems Themes Deconstruction

Deconstructing a matrix-vector productlinear combination

A matrix-vector product is shorthand for a linear combination ofcolumns: a11 · · · a1n

.... . .

...an1 · · · ann

x1...

xn

=

b1...

bn

| |c1 · · · cn

| |

x1...

xn

=

|b|

b =

n∑j=1

xjcj

Cornell CS 322 Introduction to Scienti�c Computing 13