CS3220 - Introduction to Scientific Computing · Conditioning • Another example: in linear...

22
CS3220 - Introduction to Scientific Computing Summer 2008 Jonathan Kaldor 1

Transcript of CS3220 - Introduction to Scientific Computing · Conditioning • Another example: in linear...

Page 1: CS3220 - Introduction to Scientific Computing · Conditioning • Another example: in linear algebra, n x n matrices are either singular (not invertible) or non-singular (invertible)

CS3220 - Introduction to Scientific Computing

Summer 2008Jonathan Kaldor

1

Page 2: CS3220 - Introduction to Scientific Computing · Conditioning • Another example: in linear algebra, n x n matrices are either singular (not invertible) or non-singular (invertible)

Overview

• Course Mechanics

• What is scientific computing anyways?

• MATLAB refresher

2

Page 3: CS3220 - Introduction to Scientific Computing · Conditioning • Another example: in linear algebra, n x n matrices are either singular (not invertible) or non-singular (invertible)

Course Mechanics

• See syllabus

• Homeworks

• Exams

• Grading

• TA: Jesse Simons

3

Page 4: CS3220 - Introduction to Scientific Computing · Conditioning • Another example: in linear algebra, n x n matrices are either singular (not invertible) or non-singular (invertible)

Scientific Computing

• a.k.a. numerical analysis, a.k.a. numerical methods...

• Different things to different people

4

Page 5: CS3220 - Introduction to Scientific Computing · Conditioning • Another example: in linear algebra, n x n matrices are either singular (not invertible) or non-singular (invertible)

Scientific Computing

• Pedantic definition: use of computers to support other sciences

• Analysis of data

• Model Generation

• ... but not entirely

5

Page 6: CS3220 - Introduction to Scientific Computing · Conditioning • Another example: in linear algebra, n x n matrices are either singular (not invertible) or non-singular (invertible)

Scientific Computing

• Another definition: intersection of analytical math with applied computer science

• How to solve (or approximate) answers to problems in

• linear algebra

• calculus

• differential equations

6

Page 7: CS3220 - Introduction to Scientific Computing · Conditioning • Another example: in linear algebra, n x n matrices are either singular (not invertible) or non-singular (invertible)

Scientific Computing

• In reality, combination of the two

• Given a problem (maybe, but not always, motivated by other scientific fields)...

• ... determine the methods needed to solve the problem...

• ... and understand how to implement the solutions efficiently on a computer

7

Page 8: CS3220 - Introduction to Scientific Computing · Conditioning • Another example: in linear algebra, n x n matrices are either singular (not invertible) or non-singular (invertible)

Scientific Computing

• “But don’t we already know how to solve those problems?”

8

Page 9: CS3220 - Introduction to Scientific Computing · Conditioning • Another example: in linear algebra, n x n matrices are either singular (not invertible) or non-singular (invertible)

Why it is important

• Yes, but the computer adds its own peculiarities

• Floating point numbers introduce additional error

• Running time important

9

Page 10: CS3220 - Introduction to Scientific Computing · Conditioning • Another example: in linear algebra, n x n matrices are either singular (not invertible) or non-singular (invertible)

Floating Point Numbers

• In math, numbers have as much precision as needed

• On computers, numbers have a finite precision

• e.g. π versus 3.141592

• Leads to accumulation of error

• 1e-10 + 1e10 = ???

10

Page 11: CS3220 - Introduction to Scientific Computing · Conditioning • Another example: in linear algebra, n x n matrices are either singular (not invertible) or non-singular (invertible)

Floating Point Numbers

• In math, zero is well-defined and distinct

• In floating point, imprecision leads to uncertainty

• Result of computation is 1e-15 ... is it actually zero?

11

Page 12: CS3220 - Introduction to Scientific Computing · Conditioning • Another example: in linear algebra, n x n matrices are either singular (not invertible) or non-singular (invertible)

Floating Point Numbers(a real life example)

• As part of research, needed to solve cubic equation

• detect collisions between two triangles as they move over time

• Quadratic formula for quadratics, no closed-form solution for quartics

• For cubics, though...

12

Page 13: CS3220 - Introduction to Scientific Computing · Conditioning • Another example: in linear algebra, n x n matrices are either singular (not invertible) or non-singular (invertible)

Floating Point Numbers(a real life example)

13

Page 14: CS3220 - Introduction to Scientific Computing · Conditioning • Another example: in linear algebra, n x n matrices are either singular (not invertible) or non-singular (invertible)

Floating Point Numbers(a real life example)

• Implemented closed form solution for cubics...

13

Page 15: CS3220 - Introduction to Scientific Computing · Conditioning • Another example: in linear algebra, n x n matrices are either singular (not invertible) or non-singular (invertible)

Floating Point Numbers(a real life example)

• Implemented closed form solution for cubics...

• ... and it worked!...

13

Page 16: CS3220 - Introduction to Scientific Computing · Conditioning • Another example: in linear algebra, n x n matrices are either singular (not invertible) or non-singular (invertible)

Floating Point Numbers(a real life example)

• Implemented closed form solution for cubics...

• ... and it worked!...

• ... well, almost all of the time

13

Page 17: CS3220 - Introduction to Scientific Computing · Conditioning • Another example: in linear algebra, n x n matrices are either singular (not invertible) or non-singular (invertible)

Floating Point Numbers(a real life example)

• So what happened?

• Method was unstable - accumulation of floating point error in method meant answers were not exact

• ... and it was just large enough to occasionally miss

14

Page 18: CS3220 - Introduction to Scientific Computing · Conditioning • Another example: in linear algebra, n x n matrices are either singular (not invertible) or non-singular (invertible)

Conditioning

• Another example: in linear algebra, n x n matrices are either singular (not invertible) or non-singular (invertible)

• In scientific computing, third option: ill-conditioned (nearly-singular)

• matrix is technically non-singular, but close enough that inverse cannot be computed with good accuracy

15

Page 19: CS3220 - Introduction to Scientific Computing · Conditioning • Another example: in linear algebra, n x n matrices are either singular (not invertible) or non-singular (invertible)

This Course

• Study types of problems, methods of solution

• Emphasis on:

• Problem recognition

• How each method works

• How things can go wrong

16

Page 20: CS3220 - Introduction to Scientific Computing · Conditioning • Another example: in linear algebra, n x n matrices are either singular (not invertible) or non-singular (invertible)

This Course

• Additional goals:

• Efficient code

• Being able to discuss sources of error

• MATLAB plotting tools

• Identifying easy / hard problems

17

Page 21: CS3220 - Introduction to Scientific Computing · Conditioning • Another example: in linear algebra, n x n matrices are either singular (not invertible) or non-singular (invertible)

Course Topics (List)

• Linear Systems

• Linear Fitting

• Interpolation

• Root finding / optimization

• Differential Equations

18

Page 22: CS3220 - Introduction to Scientific Computing · Conditioning • Another example: in linear algebra, n x n matrices are either singular (not invertible) or non-singular (invertible)

Course Topics (Visually)

[see http://www.graphics.cornell.edu/~jmkaldor/caf-scarf-2-h264-960-24.mov ]

19