Question: Write a function that computes the distance between two points p and q , both of which are provided to the function as two separate

Write a function that computes the distance between two points p and q, both of which are provided to the function as two separate arrays. In general, the function must be able to calculate the distance between points in an n-space, using the formula:
For example, a possible input could be p=array([1,3,4]) and q=array([0,0,-1]). Here p and q are points in a three-dimensional space, since each point has three coordinates. The distance between the two points in the example is given by:
Create a version of that function that uses NumPys vectorized operations, and another version that does not use vectorized operations (i.e., that depends on loops).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!