# Метод покоординатного спуска

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38``` ```-module(lab1). -import(math, [pow/2]). -export([result/1]). %f(X,Y) -> 100*pow((Y-pow(X,2)),2) + pow((1-X),2). % Rozenbrok f(X,Y) -> K = 4, pow(X,4) + 2*K*pow(X,3) - K*K*X*X - 2*pow(K,3)*X + pow(Y,4) - Y*Y*(2*K*K + 2*K) + 2*pow(K,4) + K*K*K + K*K. f({x,X}) -> fun(Y) -> f(X,Y) end; f({y,Y}) -> fun(X) -> f(X,Y) end. mps_search(F,Point,Step) -> This = F(Point), Next = F(Point+Step), if This > Next -> mps_search(F,Point+Step,Step); true -> Point end. mps(F,Point,Step) -> C = F(Point), L = F(Point-Step), R = F(Point+Step), if L < R -> mps_search(F,Point,Step*(-1)); L > R -> mps_search(F,Point,Step); L == R andalso C > R -> mps_search(F,Point,Step); L == R andalso C < R -> Point end. result({startpoint,X,Y}) -> New_x = mps(f({y,Y}),X,0.0001), New_y = mps(f({x,New_x}),Y,0.0001), Sqrt = math:sqrt(pow((X-New_x),2)+pow((Y-New_y),2)), if Sqrt < 0.00000001 -> io:format("~w~n",[f(New_x,New_y)]); true -> io:format("~w, ~w~n",[New_x,New_y]), result({startpoint,New_x,New_y}) end. ```