Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Fixed Step Size
- syms x x_1 x_2 x_3
- f(x) = (x_1-4)^4 + (x_2-3)^2 + 4*(x_3+5)^4;
- % Initial Variables
- epsilon = 10^(-3);
- x= [4;2;-1];
- alpha = 0.005;
- gradf1(x_1) = (diff(f(x),x_1));
- gradf2(x_2) = (diff(f(x),x_2));
- gradf3(x_3) = (diff(f(x),x_3));
- for (i=1:10)
- gradf = [gradf1(x(1));gradf2(x(2));gradf3(x(3))
- y = x - alpha*gradf;
- x = y;
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement