code: def exp(cls, q):
          
          tolerance = 1e-17
          v_norm = np.linalg.norm(q.vector)
          vec = q.vector
          if v_norm > tolerance:
              vec = vec / v_norm
          magnitude = exp(q.scalar)
          return Quaternion(scalar = magnitude * cos(v_norm), vector = magnitude * sin(v_norm) * vec)
docs: Quaternion Exponential.
  
          Find the exponential of a quaternion amount.
  
          Params:
               q: the input quaternion/argument as a Quaternion object.
  
          Returns:
               A quaternion amount representing the exp(q). See [Source](https://math.stackexchange.com/questions/1030737/exponential-function-of-quaternion-derivation for more information and mathematical background).
  
          Note:
               The method can compute the exponential of any quaternion.