# ЧСМ 6 лаба

 ``` 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 39 40 41 42 43 44``` ```#include "stdafx.h" #include #include #include double f(double x,double y){return log(1+x*x+y*y)+sin(0.1*x+0.2*y);} double dx(double x,double y){return (2*x)/(1+x*x+y*y) +0.1*cos(0.1*x+0.2*y);} double dy(double x,double y){return (2*y)/(1+x*x+y*y) +0.2*cos(0.1*x+0.2*y);} double dxdx(double x,double y){return (2*(1-x*x+y*y))/(pow(1+x*x+y*y,2))- 0.01*sin(0.1*x+0.2*y);} double dydy(double x,double y){return (2*(1+x*x-y*y))/(pow(1+x*x+y*y,2))- 0.04*sin(0.1*x+0.2*y);} double dxdy(double x,double y){return (4*x*y)/(pow(1+x*x+y*y,2))- 0.02*sin(0.1*x+0.2*y);} double max(double x1, double x2) {return dx(x1, x2) > dy(x1, x2) ? dx(x1, x2) : dy(x1, x2);} double finddirection(double x, double y) { return (-(dx(x,y)*dx(x,y))-(dy(x,y)*dy(x,y)))/ (dxdx(x,y)*(dx(x,y)*dx(x,y)) + 2*dxdy(x,y)*dx(x,y)*dy(x,y) + dydy(x,y)*(dy(x,y)*dy(x,y))); } double descent(double x, double y,double e){ double x1 = x, y1 = y, x2, y2, t; int count = 1; while(true) { t = finddirection(x1, y1); x2 = x1-t*dx(x1,y1); y2 = y1-t*dy(x1,y1); if (max(x2, y2) <= 0.001) { printf("i = %d\t", count); printf("x = %f, y = %f \t", x1, y1); return f(x1,y1); } printf("i = %d\t", count); printf("x = %f, y = %f \t", x1, y1); printf("f(x,y) = %f\n",f(x1,y1)); x1 = x2; y1 = y2; count++; } } int main(){ double x = 1, y = 2, eps = 0.001; printf("f(x,y) = %f\n",descent(x,y,eps)); return 0; } ```