341Appendix B
temp(i) = x(i) + delx;
temp(j) = x(j) - delx;
term2 = func_multivar(temp);
temp = x;
temp(i) = x(i) - delx;
temp(j) = x(j) + delx;
term3 = func_multivar(temp);
temp = x;
temp(i) = x(i) - delx;
temp(j) = x(j) - delx;
term4 = func_multivar(temp);
sec_deriv(i,j) = (term1-term2-term3+term4)/(4*delx^2);
end
end
end
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% MATLAB code modified_newton.m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% n_of_var -> number of design variables
% x = [-3 2] -> starting value of x
% epsilon1, epsilon2 -> constant used for terminating
% the algorithm
% delx -> required for gradient computation
% falpha_prev -> function value at first/previous iteration
% deriv -> ...