Top Banner
Solving Linear Equations UC Berkeley Fall 2004, E77 http://jagger.me.berkeley.edu/~ pack/e77 Copyright 2005, Andy Packard. This work is licensed under the Creative Commons
28

Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Dec 26, 2015

Download

Documents

Octavia Knight
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Solving Linear EquationsUC Berkeley

Fall 2004, E77http://jagger.me.berkeley.edu/~pack/e77

Copyright 2005, Andy Packard. This work is licensed under the Creative Commons Attribution-ShareAlike License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/2.0/ or send a letter to

Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Page 2: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Linear equations

Consider n equations in m unknowns.

Think of the Aij as known coefficients, and the bi as known numbers. The goal is to solve for all of the unknowns xj

nmnmnn

mm

mm

bxAxAxA

bxAxAxA

bxAxAxA

2211

22222121

11212111

Page 3: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Example of Linear Equations

Intersection of two lines

Simple truss structures–Consist of beams–Frictionless “pin” joints

Heat Transfer through conductive material

Electrical current flow through resistive network

Getting proper balance of nutrients from selection of foods

Page 4: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Simple truss analysis: Basic Concepts

M4

M5

M1

M6

M2

M3

Truss members are beams held together with pin joints (no welding – drill a hole in each beam, push pin through).

Beams only have a force acting at each end, no moments. These are called 2-force members. If the truss is in eqilibrium, total force on beam must be 0, and there cannot be a torque on the beam.

Pins transfer force between beams. If the truss is in equilibrium, all forces acting on a pin must sum to zero.

Page 5: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Force balance on a pin

F4F3

F1F2

0sinsinsinsin

0coscoscoscos

44332211

44332211

FFFF

FFFF

Sum forces on pin in horizontal and vertical directions. For equilibrium, forces must sum to zero.

Draw a free-body diagram of a given pin. The forces acting on it are the forces from the members (Newton’s 3rd law)

Measure θ from here (eg.)

Page 6: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Resultant forces on a 2-force member

Force imbalance, beam would accelerate.

These must be equal and opposite

Force balanced, but beam would rotate.

These must be along the beam

2-force member under load, in equilibrium

Page 7: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Simple truss structure analysis

M4

M5

M1

M6

M2

M3

Let Ti be the force in member Mi.

Page 8: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Free-body diagrams on each pin

T4

T5

T1

T6

T2

T3

Page 9: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Force balance on a pin

T4

T5

T1

T2

0sinsinsinsin

0coscoscoscos

55442211

55442211

TTTT

TTTT

Sum forces on pin in horizontal and vertical directions

Page 10: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Forces on a particular PIN

T4

T5

T1

T6

T2

T3

Page 11: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Forces on a particular PIN

T2

T3

0sinsin

0coscos

3322

3322

TTP

TT

Page 12: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Forces on a particular PIN

T4

T5

T1

T6

T2

T3

Page 13: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Forces on a particular PIN

T4

T6

T3

0sinsinsin

0coscoscos

664433

664433

TTT

TTT

Page 14: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Assembling the equations

0sinsinsin

0coscoscos

664433

664433

TTT

TTT

0sinsin

0coscos

3322

3322

TTP

TT

0sinsinsinsin

0coscoscoscos

55442211

55442211

TTTT

TTTT

If geometry is fixed, and external load is known, then this is 6 equations, 6 unknowns.

We need some “good notation” for linear equations….

Page 15: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Array-Vector multiplication

If A is an n-by-m array, and x is an m-by-1 vector, then the “product Ax” is a n-by-1 vector, whose i’th component is

m

jjiji xAAx

1

=n-by-m

m-by-1 n-by-1

=n-by-m

m-by-1 n-by-1

Page 16: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Array-Vector multiplication

mnmnn

mm

mm

n xAxAxA

xAxAxA

xAxAxA

Ax

Ax

Ax

Ax

2211

2222121

1212111

2

1

If A is an n-by-m array, and x is an m-by-1 vector, then the “product Ax” is a n-by-1 vector, whose i’th component is

m

jjiji xAAx

1

Page 17: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Ax as linear combination of columns of A

nmnnn

m

m

AAAA

AAAA

AAAA

321

2232221

1131211

mx

x

x

x

3

2

1

1

21

11

nA

A

A

1x

2

22

12

nA

A

A

2x

3

23

13

nA

A

A

3x

nm

m

m

A

A

A

2

1

mx

mnmnn

mm

mm

xAxAxA

xAxAxA

xAxAxA

2211

2222121

1212111

add, to give

Page 18: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Linear equations

Consider n equations in m unknowns.

Collect–The Aij into an n-by-m array called A

–The bi into a n-by-1 vector called b, and

–The xj into an m-by-1 vector called x

Then the equations above can be written concisely as

nmnmnn

mm

mm

bxAxAxA

bxAxAxA

bxAxAxA

2211

22222121

11212111

bAx matrix/vector multiply

vector equality

Page 19: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Linear equationsFor the equation Ax=b, there are 3 distinct cases

=

=

=

Square, equal number of unknowns and equations

Underdetermined: more unknowns than equations

Overdetermined: fewer unknowns than equations

Page 20: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Types of solutions with “random” data“Generally” the following observations would hold

=

=

=

One solution (eg., 2 lines intersect at one point)

Infinite solutions (eg., 2 planes intersect at many points)

No solutions (eg., 3 lines don’t intersect at a point)

Page 21: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Linear equationsBut anything can happen. For example:

=

=

=

No solution (2 parallel lines) Many solutions (2 parallel lines)

No solutions (2 parallel planes)Solutions (3 lines that do intersect at a point)

Page 22: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Assembling the equations

0sinsinsin

0coscoscos

664433

664433

TTT

TTT

0sinsin

0coscos

3322

3322

TTP

TT

0sinsinsinsin

0coscoscoscos

55442211

55442211

TTTT

TTTT

If geometry is fixed, and external load is known, then this is 6 equations, 6 unknowns

Page 23: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Assembling the equations

0

0

0

0

0

000

000

0000

0000

00

00

6

5

4

3

2

1

643

643

32

32

5421

5421

P

T

T

T

T

T

T

sss

ccc

ss

cc

ssss

cccc

0sinsinsin

0coscoscos

664433

664433

TTT

TTT0sinsin

0coscos

3322

3322

TTP

TT

0sinsinsinsin

0coscoscoscos

55442211

55442211

TTTT

TTTT

In matrix/vector form

Page 24: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Norms of vectors

If v is an m-by-1 column (or row) vector, the “norm of v” is defined as

m

kkvv

1

2:

Symbol to denote “norm of v”

Square-root of sum-of-squares of components, generalizing Pythagorean’s theorem

The norm of a vector is a measure of its length. Some facts:

||v||=0 if and only if every component of v is zero

||v + w|| ≤ ||v|| + ||w||

Page 25: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

The “Least Squares” Problem

If A is an n-by-m array, and b is an n-by-1 vector, let c* be the smallest possible (over all choices of m-by-1 vectors x) mismatch between Ax and b (ie., pick x to make Ax as much like b as possible).

bAxcmx

1,min:

“is defined as”“the minimum, over all m-by-1 vectors x”

“the length (ie., norm) of the difference/mismatch between Ax and b.”

Page 26: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Four cases for Least Squares

Recall least squares formulation

There are 4 scenarios

c* = 0: the equation Ax=b has at least one solution–only one x vector achieves this minimum–many different x vectors achieves the minimum

c* > 0: the equation Ax=b has no solutions–only one x vector achieves this minimum–many different x vectors achieves the minimum

bAxcmx

1,min:

Page 27: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

The backslash operator

If A is an n-by-m array, and b is an n-by-1 vector, then

>> x = A\b

solves the “least squares” problem. Namely

–If there is an x which solves Ax=b, then this x is computed

–If there is no x which solves Ax=b, then an x which minimizes the mismatch between Ax and b is computed.

In the case where many x satisfy one of the criterion above, then a smallest (in terms of vector norm) such x is computed.

So, mismatch is handled first. Among all equally suitable x vectors that minimize the mismatch, choose a smallest one.

Page 28: Solving Linear Equations UC Berkeley Fall 2004, E77 pack/e77 Copyright 2005, Andy Packard. This work is licensed under the.

Four cases: x=A\b as solution of

No Mismatch:

c* = 0, and only one x vector achieves this minimum

Choose this x

c* = 0, and many different x vectors achieves the minimum

From all these minimizers, choose smallest x (ie., norm)

Mismatch:

c* > 0, and only one x vector achieves this minimum

Choose this x

c* > 0, and many different x vectors achieves the minimum

From all minimizers, choose an x with the smallest norm

bAxcmx

1,min: