Let’s check how to generate Cauchy Matrix from arrays in Numpy Python library.
Generating matrices
First I generated two arrays. Both sixth elements. First one from 10 to 12 and the second one 4 to 8. To do that I used linspace Numpy function.
Cauchy Matrix will be generated by below code:
cauchy_matrix = 1/np.subtract.outer(my_array, my_second_array)
import numpy as np my_array = np.linspace(10, 12, 6) my_second_array = np.linspace(4, 8, 6) cauchy_matrix = 1/np.subtract.outer(my_array, my_second_array) print(f"My first array: \n {my_array}") print(f"My second array: \n {my_second_array}") print(f"Cauchy Matrix generated based on above arrays: \n{cauchy_matrix}")
And this is my Cauchy Matrix generated by Python Numpy library.
[[0.16666667 0.19230769 0.22727273 0.27777778 0.35714286 0.5 ] [0.15625 0.17857143 0.20833333 0.25 0.3125 0.41666667] [0.14705882 0.16666667 0.19230769 0.22727273 0.27777778 0.35714286] [0.13888889 0.15625 0.17857143 0.20833333 0.25 0.3125 ] [0.13157895 0.14705882 0.16666667 0.19230769 0.22727273 0.27777778] [0.125 0.13888889 0.15625 0.17857143 0.20833333 0.25 ]]