Some object is moving along a path in the plane. At n+1 points of time we have recorded the corresponding (x,y) positions of the object: (x0,y0), (x1,y1), ..., (xn,yn). The total length L of the path from (x0,y0) to (xn,yn) is the sum of all the individual line segments ((xi−1,yi−1) to (xi,yi), i=1,...,n): L=∑i=1n(xi−xi−1)2+(yi−yi−1)2−−−−−−−−−−−−−−−−−−−−−√. Write a function pathlength( x,y ) for computing L according to the formula. The arguments x and y hold all the x0,...,xn and y0,...,yn coordinates, respectively. (You may assume x and y are lists of the same length.) (This assignment is based on Langtangen, Exercise 3.17a.)

Solved
Show answers

Ask an AI advisor a question