Can someone help write a function to find to critical points? Solution function
ID: 3641897 • Letter: C
Question
Can someone help write a function to find to critical points?Explanation / Answer
function [c,d] = critcalpoints(f) %CRITCALPOINTS(f) is a function to determine the critical points of a 2D %surface given the function f(x,y). %The method choosen is to compute the first and second partial derivatives %on the given function by first evaluating the Jacobian and Hessian Matrix %and then solve by finding the eigenvalues of obtained critical points. %Declaration of Variables syms x y f=x^3-3*x^2+5*x*y-7*y^2; % First Order Partial Derivative using the Jacobian Matrix gradf = jacobian(f,[x,y]); % Second Order Patrial Derivative using the Hessian Matrix hessmatf = jacobian(gradf,[x,y]); %Solving the First Order Partial Derivative for critical points [xcr,ycr]=solve(gradf(1),gradf(2)); %Evaluating the critical points in the Hessian Matrix H1=subs(hessmatf,[x,y],[xcr(1),ycr(1)]… H2=subs(hessmatf,[x,y],[xcr(2),ycr(2)]… %Computing the eigenvalue of the evaluation of critical points eig(H1); eig(H2); %Converting to numerical values c = double(eig(H1)); d = double(eig(H2)); %Classifying and Pritning the Critical Points if (c(1) > 0 & d(1) > 0) | (c(2) > 0 & d(2) > 0) print( [xcr,ycr], ' is a minimum') elseif (c(1) < 0 & d(1) < 0) | (c(2) < 0 & d(2) < 0) print( [xcr, ycr], ' is a maximum') elseif (c(1) < 0 & d(1) > 0) | (c(1) > 0 & d(1) < 0) print( [xcr, ycr], ' is a saddle point') elseif (c(2) < 0 & d(2) > 0) | (c(2) > 0 & d(2) < 0) print( [xcr, ycr], ' is a saddle point') elseif (c(1)==0 | d(1)==0) print( [xcr, ycr], ' is degenerate') elseif (c(2)==0 | d(2)==0) print( [xcr, ycr], ' is degenerate') endRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.