28
Teach ill-conditioning to introductory linear algebra students in a single lecture! Shake a Stick at Ill-Conditioning A Multi-Modal Lesson Professor Je/ Stuart Mathematics Department Pacic Lutheran University Tacoma, WA 98447 USA je/[email protected] January 2009 Professor Je/ Stuart Mathematics Department Pacic Lutheran University Tacoma, WA 98447 Teach ill-conditioning to introductory linear algebra students in a single lecture! January 2009 1 / 23

Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

Teach ill-conditioning to introductory linear algebrastudents in a single lecture!

Shake a Stick at Ill-Conditioning � A Multi-Modal Lesson

Professor Je¤ Stuart

Mathematics DepartmentPaci�c Lutheran UniversityTacoma, WA 98447 USAje¤[email protected]

January 2009

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 1 / 23

Page 2: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

A Common Student Misconception

Held by students

Post College Algebra

Post Calculus

Post Linear Algebra

Post BA with Math Major

The Misconception �All invertible linear systems of equations behave the same way:

There is a unique solution

Gaussian Elimination gives it

Computers always do GE faster and better

there is no more to be said

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 2 / 23

Page 3: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

Equipment for Physical Demonstration

Required Equipment:

Chalk board and chalk (white board and markers)

Two chairs

Two rigid rods at least six feet long

Broom sticks or mop handlesYard or meter sticks duct-taped togetherRigid plastic pipeThe longer, the better!!

Five student "volunteers" (Two with decent balance)

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 3 / 23

Page 4: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

Before The Physical Demonstration

Discuss idea of data uncertainty when using real world information

Discuss geometric implication in linear context

uncertainty of line locationan envelope of possible lines

Sketch a family of lines and the envelope of a �Shaking Line�

Discuss two uncertain lines and their intersection

A region of possible intersection points

Discuss geometric e¤ect of right hand side perturbations on systemsand the impact on the intersection point

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 4 / 23

Page 5: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

Perform The Physical Demonstration - Shake the Sticks!

Do demonstration twice

First time with rods crossing at approximately a right angle but NOThorizontal and verticalSecond time with rods crossing but almost parallel.

Each end of a stick is held by a di¤erent student.

Two students stand on chairs to obtain the proper angle betweensticks.

Instructor alternately tells students to shake the sticks or to stop.

Each time the shaking stops, the point of intersection is marked onchalk/white board.

Perform at least a dozen steps of shaking and marking, more asneeded in order for patterns to appear for case of nearly parallel sticks.

Time permitting, repeat demonstration using di¤erent orientation forthe lines or di¤erent angle between the lines.

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 5 / 23

Page 6: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

Perform The Physical Demonstration - Shake the Sticks!

Do demonstration twice

First time with rods crossing at approximately a right angle but NOThorizontal and verticalSecond time with rods crossing but almost parallel.

Each end of a stick is held by a di¤erent student.

Two students stand on chairs to obtain the proper angle betweensticks.

Instructor alternately tells students to shake the sticks or to stop.

Each time the shaking stops, the point of intersection is marked onchalk/white board.

Perform at least a dozen steps of shaking and marking, more asneeded in order for patterns to appear for case of nearly parallel sticks.

Time permitting, repeat demonstration using di¤erent orientation forthe lines or di¤erent angle between the lines.

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 5 / 23

Page 7: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

Perform The Physical Demonstration - Shake the Sticks!

Do demonstration twice

First time with rods crossing at approximately a right angle but NOThorizontal and verticalSecond time with rods crossing but almost parallel.

Each end of a stick is held by a di¤erent student.

Two students stand on chairs to obtain the proper angle betweensticks.

Instructor alternately tells students to shake the sticks or to stop.

Each time the shaking stops, the point of intersection is marked onchalk/white board.

Perform at least a dozen steps of shaking and marking, more asneeded in order for patterns to appear for case of nearly parallel sticks.

Time permitting, repeat demonstration using di¤erent orientation forthe lines or di¤erent angle between the lines.

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 5 / 23

Page 8: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

Perform The Physical Demonstration - Shake the Sticks!

Do demonstration twice

First time with rods crossing at approximately a right angle but NOThorizontal and verticalSecond time with rods crossing but almost parallel.

Each end of a stick is held by a di¤erent student.

Two students stand on chairs to obtain the proper angle betweensticks.

Instructor alternately tells students to shake the sticks or to stop.

Each time the shaking stops, the point of intersection is marked onchalk/white board.

Perform at least a dozen steps of shaking and marking, more asneeded in order for patterns to appear for case of nearly parallel sticks.

Time permitting, repeat demonstration using di¤erent orientation forthe lines or di¤erent angle between the lines.

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 5 / 23

Page 9: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

Perform The Physical Demonstration - Shake the Sticks!

Do demonstration twice

First time with rods crossing at approximately a right angle but NOThorizontal and verticalSecond time with rods crossing but almost parallel.

Each end of a stick is held by a di¤erent student.

Two students stand on chairs to obtain the proper angle betweensticks.

Instructor alternately tells students to shake the sticks or to stop.

Each time the shaking stops, the point of intersection is marked onchalk/white board.

Perform at least a dozen steps of shaking and marking, more asneeded in order for patterns to appear for case of nearly parallel sticks.

Time permitting, repeat demonstration using di¤erent orientation forthe lines or di¤erent angle between the lines.

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 5 / 23

Page 10: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

Perform The Physical Demonstration - Shake the Sticks!

Do demonstration twice

First time with rods crossing at approximately a right angle but NOThorizontal and verticalSecond time with rods crossing but almost parallel.

Each end of a stick is held by a di¤erent student.

Two students stand on chairs to obtain the proper angle betweensticks.

Instructor alternately tells students to shake the sticks or to stop.

Each time the shaking stops, the point of intersection is marked onchalk/white board.

Perform at least a dozen steps of shaking and marking, more asneeded in order for patterns to appear for case of nearly parallel sticks.

Time permitting, repeat demonstration using di¤erent orientation forthe lines or di¤erent angle between the lines.

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 5 / 23

Page 11: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

The Computational Experiment - Part 1

Linear system AX = B with

A =�1 �11 1

�and B =

�13

�.

Solve it and sketch the lines.

Note lines are perpendicular.

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 6 / 23

Page 12: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

New plot (#1) � plot the right-hand side vector B and eightneighboring points bB given by�

1� 0.013

�,

�0.99

3� 0.01

�,

�1

3� 0.01

�,

�1.01

3� 0.01

�Note all entries in these points agree within 1% with entries of B.

Have each student solve at least one of new problems AX = bB.Previously prepared handouts each with two of the systems help.

Plot student solutions along with original on new plot (#2).

Note solutions to perturbed problems are all quite close to originalsolution.

Share plot of 3000 small, random perturbations of B and plot ofcorresponding solutions (#3 and #4).

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 7 / 23

Page 13: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

0.985 0.99 0.995 1 1.005 1.01 1.0152.985

2.99

2.995

3

3.005

3.01

3.015Figure 1.  The point B = [1,3]' and its eight neighboring points.

B = [ 1 , 3 ]'

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 8 / 23

Page 14: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

1.985 1.99 1.995 2 2.005 2.01 2.0150.985

0.99

0.995

1

1.005

1.01

1.015Figure 2.  T he solutions to the linear system for B and its  eight neighbors.

X = [ 2 , 1 ]'

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 9 / 23

Page 15: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

0.975 0.98 0.985 0.99 0.995 1 1.005 1.01 1.015 1.02 1.0252.975

2.98

2.985

2.99

2.995

3

3.005

3.01

3.015

3.02

3.025Figure 3.  Three thousand perturbations of B = [1,2]'.

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 10 / 23

Page 16: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

1.98 1.985 1.99 1.995 2 2.005 2.01 2.015 2.020.98

0.985

0.99

0.995

1

1.005

1.01

1.015

1.02Figure 4.  The solutions for the three thousand perturbed systems.

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 11 / 23

Page 17: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

The Computational Experiment - Part 2

Linear system AX = B with

A =�1 1.00011 1

�and B =

�3.00013

�.

Solve system and sketch the lines.

Note lines are almost parallel.

Repeat process of perturbations to B using same ∆bj = �0.01.Have students solve perturbed systems.

Plot perturbed solutions (#5 and #6).

Handouts simplify organizational details in a larger class.

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 12 / 23

Page 18: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

2.985 2.99 2.995 3 3.005 3.01 3.0152.985

2.99

2.995

3

3.005

3.01

3.015Figure 5.  The point B = [3.0001,3]' and its eight neighbors.

B = [ 3.0001 , 3 ] '

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 13 / 23

Page 19: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

­250 ­200 ­150 ­100 ­50 0 50 100 150 200 250­250

­200

­150

­100

­50

0

50

100

150

200

250Figure 6. The solutions  to the linear system for B and i ts  eight neighbors.

(3 Points)

(2 Points)

(2 Points)

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 14 / 23

Page 20: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

Comment on the very di¤erent outcome.

Note some right-hand side perturbations produce small perturbationsin solutions but others produce large ones.

Share plot of 3000 random perturbations of B and plot ofcorresponding solutions (#7 & #8).

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 15 / 23

Page 21: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

2.975 2.98 2.985 2.99 2.995 3 3.005 3.01 3.015 3.02 3.0252.975

2.98

2.985

2.99

2.995

3

3.005

3.01

3.015

3.02

3.025Figure 7.  Three thousand perturbations of B = [3.0001,3]'.

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 16 / 23

Page 22: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

­300 ­200 ­100 0 100 200 300­300

­200

­100

0

100

200

300Figure 8.  T he solutions  for the three thousand perturbed systems.

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 17 / 23

Page 23: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

The Algebraic Analysis - Part 1

Solve the 1st system AX = B + ∆B algebraically.�1 �11 1

� �xy

�=

�1+ ∆b13+ ∆b2

�,

Solution

x = 2+∆b1 + ∆b1

2,

y = 1+∆b2 � ∆b1

2.

Note that small changes in ∆b1 and ∆b2 on right-hand side lead tosmall changes in x and y .

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 18 / 23

Page 24: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

The Algebraic Analysis - Part 2

Solve the 2nd system AX = B + ∆B algebraically.�1 1.00011 1

� �xy

�=

�3.0001+ ∆b13+ ∆b2

�,

Solution

x = 2+ ∆b2 � 10000(∆b1 � ∆b2),y = 1+ 10000(∆b1 � ∆b2).

When ∆b1 = ∆b2, small changes in ∆b1 lead to small changes in xand no changes in y .When ∆b1 6= ∆b2, small changes in ∆b1 and ∆b2 can produce verylarge changes in x and y .

Emphasize only some small right hand side perturbations lead tolarge solution perturbations.

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 19 / 23

Page 25: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

Concluding Remarks

Emphasize that as linear system changes from roughly orthogonal toroughly degenerate, system becomes more sensitive to perturbations.

Prompt students for intuitive discussion of what happens with threelinear systems in three unknowns, being sure to discuss geometricmeaning of perturbing equation of a plane.

Emphasize quality of the solutions of linear system based on uncertaindata depends not just on quality of data, but also on geometry of thesystem.

Reemphasize even with good data, the angles between the lines orplanes can a¤ect certainty that one should assign to the solution.

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 20 / 23

Page 26: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

Further Adventures

condition number as a numerical measure of geometric e¤ects and asa measure of worst-case error magni�cation.

well-conditioned ("small" condition number)

ill-conditioned ("big" condition number)

For 1st system AX = B, condition number of A is 1.(Well-Conditioned)

For 2nd system AX = B, condition number of A is 40002.(Ill-Conditioned)

Even perpendicular lines can be ill-conditioned by scaling.

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 21 / 23

Page 27: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

Have students investigate well scaled and badly scaled systems such as�1 00 1

� �xy

�=

�1+ ∆b13+ ∆b2

�and �

1 00 0.0001

� �xy

�=

�1+ ∆b1

0.0003+ ∆b2

�.

Have students conduct numerical experiments that involveperturbations of both A and B.

Using computers as well as geometric insight, have studentsinvestigate perturbation sensitivity in the case of three equations inthree unknowns.

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 22 / 23

Page 28: Teach ill-conditioning to introductory linear algebra students in a …stuartjl/Shake_a_Stick.pdf · 2009-01-06 · Held by students Post College Algebra Post Calculus Post Linear

Thank you!

The plots and the paper will be available on the author�s website:

http://www.plu.edu/~stuartjl/PLUCourses/shake_a_stick/

Just Google: "Stuart" AND "Shake a Stick"

Professor Je¤ Stuart Mathematics Department Paci�c Lutheran University Tacoma, WA 98447 USA je¤[email protected] ()Teach ill-conditioning to introductory linear algebra students in a single lecture!January 2009 23 / 23