THMMY's "Optimization Techniques" course assignments.
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

Script_3_Newton.m 1.2 KiB

3 dni temu
123456789101112131415161718192021222324252627282930313233343536373839404142
  1. % Define environment (functions, gradients etc...)
  2. GivenEnv
  3. % Point x0 = (0, 0)
  4. % =========================================================================
  5. point = 1;
  6. x0 = [0, 0];
  7. f = fun(x0(1), x0(2));
  8. gf = grad_fun(x0(1), x0(2));
  9. hf = hessian_fun(x0(1), x0(2));
  10. ev = eig(hf);
  11. fprintf('Initial point (%d, %d), f = %f, grad = [%f;%f], hessian = [%f %f ; %f %f]. Eigenvalues= [%f, %f], Can NOT use method\n', x0, f, gf, hf, ev);
  12. disp(' ');
  13. % Point x0 = (-1, 1)
  14. % =========================================================================
  15. point = 2;
  16. x0 = [-1, 1];
  17. point_str = "[" + x0(1) + ", " + x0(2) + "]";
  18. f = fun(-1, 1);
  19. gf = grad_fun(x0(1), x0(2));
  20. hf = hessian_fun(x0(1), x0(2));
  21. ev = eig(hf);
  22. fprintf('Initial point (%d, %d), f = %f, grad = [%f;%f], hessian = [%f %f ; %f %f]. Eigenvalues= [%f, %f], Can NOT use method\n', x0, f, gf, hf, ev);
  23. disp(' ');
  24. % Point x0 = (1, -1)
  25. % =========================================================================
  26. point = 3;
  27. x0 = [1, -1];
  28. point_str = "[" + x0(1) + ", " + x0(2) + "]";
  29. f = fun(-1, 1);
  30. gf = grad_fun(x0(1), x0(2));
  31. hf = hessian_fun(x0(1), x0(2));
  32. ev = eig(hf);
  33. fprintf('Initial point (%d, %d), f = %f, grad = [%f;%f], hessian = [%f %f ; %f %f]. Eigenvalues= [%f, %f], Can NOT use method\n', x0, f, gf, hf, ev);