Skip to content
DeepForgeby svx
All problems
HardLinear Algebrala-304

Minimum Norm Solution 2x3

Problem

Solve the underdetermined system A*x = b with A of shape 2x3 and linearly independent rows.

The minimum-norm solution is x = A^T (A A^T)^(-1) b. Return None if A A^T is singular.

Hint

The row-space formula picks the solution orthogonal to the null space, which is the shortest one.

Test cases

case 1
in: [[[1,0,0],[0,1,0]],[2,3]]
expected: [2,3,0]
case 2
in: [[[1,1,1],[1,-1,0]],[3,0]]
expected: [1,1,1]
case 3
in: [[[1,0,1],[0,1,1]],[1,1]]
expected: [0.3333333333333333,0.3333333333333333,0.6666666666666666]
case 4
in: [[[1,2,3],[2,4,6]],[1,2]]
expected: null
case 5
in: [[[1,0,1],[0,1,1]],[0,0]]
expected: [0,0,0]
Starter codePython
def minimum_norm_solution(A, b):
    # Your code here
    pass

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