hw4_solution_2008

# hw4_solution_2008 - Problem 1 The definition of the...

This preview shows pages 1–4. Sign up to view the full content.

Problem 1: The definition of the Jacobian is shown in the Matlab code. I also wrote a function to evaluate the values of the three functions at a given x, y and z values. After defining the Jacobian and the functions, a code was written for Newton iteration. I achieved the following three different outcomes by starting with different initial guesses. All the three are possible steady states for the population. The first outcome shows that the three species can actually coexist. The second solution shows that the eagles dominate over the wolves in the competition for food and thus the wolves are completely eliminated from the jungle. The third solution seems a little weird because it shows that the bunnies and wolves are almost finished and a lot of eagles remain. This seems to be a weird solution but anyhow it is a solution to the given equations. Initial Guess Converged solution X Y Z X Y Z 1 1 0 1.6136 0.3864 0.6136 1 0 1 0.98 0 1 0 1 1 2.1784e-33 0 7.0711 MATLAB CODE Function to evaluate the jacobian at given values of x, y and z function a = jacobian(values) x = values(1); y = values(2); z = values(3); a=zeros(3,3); a(1,1) = 1-y-z; a(1,2) = -x; a(1,3) = -x; a(2,1) = y; a(2,2) = -1+x-z; a(2,3) = -y; a(3,1) = z; a(3,2) = 0.01*z; a(3,3) = 0.04*z+x+0.01*y; Function to evaluate the equation functions at given values of x, y and z function vec = f(values) %a function which evaluates the functions at given values of x, y and z x = values(1); y = values(2); z = values(3); vec = zeros(3,1);

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

View Full Document
P=1; vec(1) = (x-x*y-x*z); vec(2) = (-y+x*y-y*z); vec(3) = (0.02*z^2-P+x*z+0.01*y*z); Program for finding steady state solutions by Newton Iteration method %Newton Iteration for bunnies, wolves and eagles problem x = [1 1 0]'; dx=zeros(3,1); xold=zeros(3,1); sre = 1; i=0; disp([i sre x']) while sre>1e-4 xold = x; A = jacobian(xold); b = -f(xold); dx = A\b; x = xold + dx; if x~=0; sre = max(abs((x-xold)./x)); end i=i+1; disp([i sre x']) if i >50 'Newton iteration did not converge' break end end
Problem 2 PART(A) We fit a 1 st order polynomial (i.e. a straight line F=a0+a1*v) with nonzero intercept by using polyfit. It comes out to be the following F = 19.4702*v -234.2857 The straight line fit the data very well; however, it predicts a negative force of -234.2857 for v=0. This value is unphysical. When the object is not moving, the drag force can not act on it. Hence, a better linear relation will be F=m*v, which has a zero intercept. This fit has been show in the part (B).

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 08/06/2008 for the course ME 17 taught by Professor Milstein during the Summer '07 term at UCSB.

### Page1 / 11

hw4_solution_2008 - Problem 1 The definition of the...

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

View Full Document
Ask a homework question - tutors are online