ps4sol - 18.02 Fall 2008 Problem Set 4, Part B Solutions 1....

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 18.02 Fall 2008 Problem Set 4, Part B Solutions 1. a) LS (4) translates into braceleftBigg ( x x ) a + ( x u ) b = ( x y ) ( x u ) a + ( u u ) b = ( y u ) or equivalently A z = r , with A = bracketleftbigg x x x u x u u u bracketrightbigg , z = bracketleftbigg a b bracketrightbigg , r = bracketleftbigg x y y u bracketrightbigg In Matlab notation: A=[x*x x*u; x*u u*u] , and r=[x*y; y*u] (or even shorter: A=[x;u]*[x u] , r=[x;u]*y ) c) Matlab input and output (condensed for brevity) >> x = [1:1:7]; y = [0.25 1 2.1 4.7 9.8 18.7 48.1]; u = [1 1 1 1 1 1 1]; >> A = [x*x x*u; x*u u*u]; r = [x*y; y*u]; z = inv(A)*r z = 6.6661-14.5714 (the best fit is: y = 6.666 x - 14.571) >> v = z*[x;u] v = -7.9054 -1.2393 5.4268 12.0929 18.7589 25.4250 32.0911 (predicted) >> y - v 8.1554 2.2393 -3.3268 -7.3929 -8.9589 -6.7250 16.0089 (differences) a = 6 . 666, b = 14 . 571, and the largest error is about 16 (for the last data point). d) Matlab input and output: (note A remains the same) >> lny = log(y); r1 = [x*lny; lny*u]; z1 = inv(A)*r1 z1 = 0.8277-1.8841 (the best fit is: ln(y) = 0.8277 x - 1.8841)(the best fit is: ln(y) = 0....
View Full Document

This note was uploaded on 04/28/2009 for the course MATH 18.02 taught by Professor Auroux during the Fall '08 term at MIT.

Page1 / 2

ps4sol - 18.02 Fall 2008 Problem Set 4, Part B Solutions 1....

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online