// Definition of a gradient of the test function for Steepest Descent // f = (x1-1)^2 + (x2-2)^2 + 0.7*sin(x1*x2) #include "SteepestDescent.h" Vec GradF(const Vec x){ int n=2; float x1,x2; Vec gradf; if(x.n!=n){ printf("inapropriate input"); return x; } // Pulling the xvalue x1=x.comp[0]; x2=x.comp[1]; // Computing the Gradient gradf.n=n; gradf.comp = (float *) malloc(n*sizeof(float)); gradf.comp[0]=2*(x1-1) + 0.7*x2*cos(x1*x2); gradf.comp[1]=2*(x2-2) + 0.7*x1*cos(x1*x2); return gradf; }