2. 4 Using a For Loop-Finding the Path .15 2.4 Using a For Loop-Finding the Path Next, construct and plot the path on the surface of the hill that the skier Maple language), gives the x and y components of the direction of steeper should take. The negative of the gradient(-Vf(x, y)or -grad(f(x, y))in escent. At each point(x, y, z)on the surface, the skier should travel in the direction of-Vf(x, y), while staying on the surface. Since-Vf(x, y)changes from point to point, you can break the process into steps, building an approximation of the path of steepest descent. If the step size is too large the path may leave the surface of the hill. If the step size is too small, you derive no benefit from the increased number of calculations Performing the initialization Assume that the skier is currently at the starting point(xl, yl, z1). Use a timestep of 0. 1 and find 25 points along the path. Use the arrays point 3d and outed to store the values of the computed points and the direction taken spectively. To simplify the calculation of the points and route define vector representations of the expressions for the hill and the derivatives with respect to both x and y To define vector representations of the expressions t the prompt, enter the following and press ENTER g:=eval(f,{x=P[1],y=P[2]}) gx: =eval(fx, (x=P[l], y=p[2]1) gy: =eval(fy, x=P[l], y=P[2J)) To declare the arrays for storing the values at each timestep At the prompt, enter the following and press ENTER. point3d: =Array (1. 25) routed: =Array (1.. 25); At the prompt, enter the following and press ENTER timestep: =0.1; point3d[1]: =<xl, y1, Z1> Note: The notation <x1, y1, 21> defines a vector while Pu accesses the ith element of the list P. For more information about Vectors refer to Vector (Vector-construct a Vector). For more information about lists, refer to ?lists (Sets and Lists2.4 Using a For Loop—Finding the Path • 15 2.4 Using a For Loop—Finding the Path Next, construct and plot the path on the surface of the hill that the skier should take. The negative of the gradient (−∇"%− "%) in the Maple language), gives the and %components of the direction of steepest descent. At each point %: on the surface, the skier should travel in the direction of −∇"%, while staying on the surface. Since −∇"% changes from point to point, you can break the process into steps, building an approximation of the path of steepest descent. If the step size is too large, the path may leave the surface of the hill. If the step size is too small, you derive no benefit from the increased number of calculations. Performing the initialization Assume that the skier is currently at the starting point ()%):)). Use a timestep of 0.1 and find 25 points along the path. Use the arrays ( and ( to store the values of the computed points and the direction taken, respectively. To simplify the calculation of the points and route, define vector representations of the expressions for the hill and the derivatives with respect to both and %. To define vector representations of the expressions: • At the prompt, enter the following and press ENTER. &'/"1'<!)#%'<!,#2$ &'/"1'<!)#%'<!,#2$ %&'/"%1'<!)#%'<!,#2$ To declare the arrays for storing the values at each timestep: • At the prompt, enter the following and press ENTER. (&'=%) ,7$ (&'=%) ,7$ To define the initialization: • At the prompt, enter the following and press ENTER. &' )$ (!)#&'>)%):)?$ Note: The notation >)%):)? defines a Vector while P[i] accesses the ith element of the list P. For more information about Vectors, refer to @ (Vector - construct a Vector). For more information about lists, refer to (Sets and Lists).