Solve the following problem using matlab i have it\'s analytic solution, i just
ID: 2989172 • Letter: S
Question
Solve the following problem using matlab
i have it's analytic solution, i just need it's solution using matlab (the code and the solution)
analytic solution:
Find the maximum of the function f (X) = 2 x1, + x2 +10 subject to g(X) = x1 + 2 x 2 2 = 3 using the Lagrange multiplier method. Also find the effect of changing the right-hand side of the constraint on the optimum value of f(X). SOLUTION The Lagrange function is given by L(X, lambda) = 2.x1 + x2 + 10 + lambda(3 - x1 - 2x 2 2 The necessary conditions for the solution of the problem are 2 The solution of Eqn. Is The application of the sufficiency condition of Eq. (2.44) yields Hence X* will be a maximum of f with f* = f(X*) 16.07. One procedure for finding the effect on f* of changes in the value of b (right-hand side of the constraint) would be to solve the problem all over with the new value of b. Another procedure would involve the use of the value of lambda *. When the original constraint is tightened by 1 unit (i.e., db = -1). Eq. (2.57) gives df* = lambda*db = 2(-1) = -2 Thus the new value of f* is f*+df* = 14.07. On the other hand, if we relax the original constraint by 2 units (i.e., db = 2), we obtain df* = lambda*db = 2(+2) = 4 and hence the new value of f* is f* + df* = 20.07.Explanation / Answer
x = linspace(-1.5,1.5); [X,Y] = meshgrid(x,x); figure; hold all surf(X,Y,2*X+Y); shading interp; theta = linspace(0,2*pi); [x1,y1] = pol2cart(theta,3); plot3(x1,y1,x1+2*y1) view(38,8) % adjust view so it is easy to see function gamma = func(X) x = X(1); y = X(2); lambda = X(3); gamma = x + y + lambda*(x^2 + y^2 - 1); end function dLambda = dfunc(X) % initialize the partial derivative vector so it has the same shape % as the input X dLambda = nan(size(X)); h = 1e-3; % this is the step size used in the finite difference. for i=1:numel(X) dX=zeros(size(X)); dX(i) = h; dLambda(i) = (func(X+dX)-func(X-dX))/(2*h); end end X1 = fsolve(@dfunc,[1 1 0],optimset('display','off')) % let's check the value of the function at this solution fval1 = func(X1) sprintf('%f',fval1) plot3(X1(1),X1(2),fval1,'ro','markerfacecolor','b')
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.