Skip to content
DeepForgeby svx
All problems
EasyLinear Algebrala-051

Vector Triple Product

Problem

Compute the vector triple product a x (b x c) using the identity

a x (b x c) = b * (a . c) - c * (a . b)

All vectors are 3D.

Hint

Use the BAC-CAB identity so no cross product computation is needed.

Test cases

case 1
in: [[1,2,3],[4,5,6],[7,8,9]]
expected: [-24,-6,12]
case 2
in: [[1,0,0],[0,1,0],[0,0,1]]
expected: [0,0,0]
case 3
in: [[1,1,1],[1,0,0],[0,1,0]]
expected: [1,-1,0]
case 4
in: [[2,0,1],[1,3,0],[0,1,4]]
expected: [4,10,-8]
Starter codePython
def vector_triple_product(a, b, c):
    # Your code here
    pass

4 test cases · run your code against them in the editor