Calculation of the Gradient of a scalar function
> hi := (x,y) -> 10*(2*x*y-3*x^2-4*y^2-18*x+28*y +12); This is the scalar function, which is the height of a hill.
> hi(1,2); To test if it gives the correct output.
> with(linalg): importing a package called linalg
Warning, the protected names norm and trace have been redefined and unprotected
> grad( hi(x,y), vector([x,y]) ); calculation of the gradient.
> with(plots):
Warning, the name changecoords has been redefined
> gradplot(hi(x,y),x=-5..5,y=-5..5); 2d plot of the gradient.
> evalf(hi(-2,3));
> evalf(sqrt(2)*220);
>