Skip to content
DeepForgeby svx
All problems
EasyLinear Algebrala-194

Cauchy Matrix

Problem

Build the Cauchy matrix from two lists:

C[i][j] = 1 / (x[i] + y[j])

Assume x and y are real lists with no zero denominators.

Hint

Cauchy matrices are symmetric when x == y and have a closed-form determinant.

Test cases

case 1
in: [[1,2],[3,4]]
expected: [[0.25,0.2],[0.2,0.16666666666666666]]
case 2
in: [[0,1],[1,2]]
expected: [[1,0.5],[0.5,0.3333333333333333]]
case 3
in: [[2],[2,3,4]]
expected: [[0.25,0.2,0.16666666666666666]]
case 4
in: [[1,2,3],[1,2,3]]
expected: [[0.5,0.3333333333333333,0.25],[0.3333333333333333,0.25,0.2],[0.25,0.2,0.16666666666666666]]
Starter codePython
def cauchy_matrix(x, y):
    # Your code here
    pass

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