The Euclidean norm of an ndimensional vector x is defined by

The Euclidean norm of an n-dimensional vector x is defined by:

Implement a robust routine for computing this quantity for any given input vector x. Your routine should avoid overflow and harmful underflow. Compare both the accuracy and the performance of your robust routine with a more straightforward naive implementation. Can you devise a vector that produces significantly different results from the two routines? How much performance does the robust routine sacrifice?

1/2 i-1

Solution

solution---

I have implemented the solution in python. It requires a for loop.


def euclidean_norm(x):
   l=len(x)
   sum=0
   for i in range(l):
       sum=sum+(x[i]**2)
   if(sum!=0):
       sum=sum**(0.5)
   return sum

The Euclidean norm of an n-dimensional vector x is defined by: Implement a robust routine for computing this quantity for any given input vector x. Your routine

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site