THMMY's "Optimization Techniques" course assignments.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

22 lines
683 B

  1. % Given environment
  2. clear;
  3. % Setup the function under test
  4. syms x y;
  5. fexpr = x^5 * exp(-x^2 - y^2);
  6. title_fun = "$f(x,y) = x^5 \cdot e^{-x^2 - y^2}$";
  7. % Calculate the gradient and Hessian
  8. grad_fexpr = gradient(fexpr, [x, y]); % Gradient of f
  9. hessian_fexpr = hessian(fexpr, [x, y]); % Hessian of f
  10. % Convert symbolic expressions to MATLAB functions
  11. fun = matlabFunction(fexpr, 'Vars', [x, y]); % Function
  12. grad_fun = matlabFunction(grad_fexpr, 'Vars', [x, y]); % Gradient
  13. hessian_fun = matlabFunction(hessian_fexpr, 'Vars', [x, y]); % Hessian
  14. % Amijo globals
  15. global amijo_beta amijo_sigma
  16. %fixed step size globals
  17. global gamma_fixed_step