hw1.mws

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 := proc (x, y) options operator, arrow; 20*x*y-3...

> hi(1,2); To test if it gives the correct output.

350

> 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.

vector([20*y-60*x-180, 20*x-80*y+280])

> with(plots):

Warning, the name changecoords has been redefined

> gradplot(hi(x,y),x=-5..5,y=-5..5); 2d plot of the gradient.

[Maple Plot]

> evalf(hi(-2,3));

720.

> evalf(sqrt(2)*220);

311.1269836

>