HW5 Sol

HW5 Sol - EE103 Winter 2009 HW 5 Solution Applied Numerical...

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

View Full Document Right Arrow Icon
EE103, Winter 2009, HW 5 Solution, SEJ Page 1 / 8 Applied Numerical Computing Instructor: Prof. S. E. Jacobsen HW5 Solution Students: Distributed HW solutions are a component of the course and should be fully understood. SEJ Prob 1 (a)- When using Newton’s method to solve the non-linear least squares problem, we have the following: For the code, NewtonMin.m, the Newton update is: 1 x kk k x d α + =+ , where k d is the direction found by solving F Hd F = ∇ , and the step-size, k , is determined by a “back-tracking ½” strategy (Peruse the code). The Hessian is 1 () () i m T Ff f i f i HJ x J x f x H x = ⎛⎞ ⎜⎟ ⎝⎠ To find ( ) i f Hx , 2 22 12 1 1 0 (, ) i ii i xu i f ue fxx e x u e H x ue −− ⎡⎤ ∇= = ⎣⎦ In problem 3 of HW#4 we wrote the lines of code that would compute the Jacobian. Here we will use it to find F H . function [J] = hw4p3jac(x,u,v) for k=1:length(u) J(k,:)=[exp(-x(2)*u(k)), -x(1)*u(k)*exp(-x(2)*u(k))]; end and, to find F H : function H = hw4p3hes(x,u,v,f,J) H=J'*J; for i=1:length(u)
Background image of page 1

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

View Full DocumentRight Arrow Icon
EE103, Winter 2009, HW 5 Solution, SEJ Page 2 / 8 H=H+f(i)*[0,-u(i)*exp(-x(2)*u(i)); -u(i)*exp(-x(2)*u(i)),x(1)*u(i)^2*exp(-x(2)*u(i))]; end Below is the m-file that returns the values of ( ), ( ), and ( ) F Fx H x at any given x: %this m-file contains two “sub-functions” The first function calls %the other two functions. function [Fx gx H]= hw5p1(x,u,v) for k=1:length(u) f(k)=x(1)*exp(-x(2)*u(k))-v(k); end f=f'; Fx=f'*f; J=hw4p3jac(x,u,v); gx=f'*J; gx=gx'; H=hw4p3hes(x,f,J,u,v); function [J] = hw4p3jac(x,u,v) for k=1:length(u) J(k,:)=[exp(-x(2)*u(k)), -x(1)*u(k)*exp(-x(2)*u(k))]; end function H = hw4p3hes(x,f,J,u,v) H=J'*J; for i=1:length(u) H=H+f(i)*[0,-u(i)*exp(-x(2)*u(i)); -u(i)*exp(-x(2)*u(i)),x(1)*u(i)^2*exp(-x(2)*u(i))]; end As instructed in the problem statement, the function NewtonMin needs the information contained in u,v; those are included in the input arguments to the function function [xMin,gx,Hx] = NewtonMin(f,x0,tol,u,v) and by including u,v in the input arguments to every feval statement in NewtonMin.m: feval(f,xnew,u,v)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/30/2009 for the course EE 103 taught by Professor Vandenberghe,lieven during the Winter '08 term at UCLA.

Page1 / 8

HW5 Sol - EE103 Winter 2009 HW 5 Solution Applied Numerical...

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

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