Dot Product and Vector Length

~8 mincode completion

Implement dot_and_lengths(a, b) returning the array [a . b, |a|, |b|].

Where this shows up

~8 min

8 employers weight this skill

4 quant funds, 2 defense companies, 2 autonomy companies. Top match scores 93.

Python
import numpy as np


def dot_and_lengths(a, b):
    """
    The dot product of two vectors and the length of each.

    Args:
        a: vector of d numbers
        b: vector of d numbers

    Returns:
        array [a . b, |a|, |b|]
    """
    # YOUR CODE HERE
    pass
Loading docs…

The AI Mentor needs an account

It reads your code and the failing tests and nudges you toward the fix without handing you the answer. Free accounts get it on every problem you're working on today.