Generate Hilbert matrix
stm_hilbert.Rd
stm_hilbert()
creates an n x n
Hilbert matrix, where each
element is defined as Hij = 1 / (i + j - 1)
, where i
and
j
are the row and column indices.
Details
The Hilbert matrix is used in numerical analysis and is known for
its ill-conditioning as n increases. This function uses the
outer()
function to generate the matrix efficiently.
Examples
stm_hilbert(3)
#> [,1] [,2] [,3]
#> [1,] 1.0000000 0.5000000 0.3333333
#> [2,] 0.5000000 0.3333333 0.2500000
#> [3,] 0.3333333 0.2500000 0.2000000
stm_hilbert(5)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 1.0000000 0.5000000 0.3333333 0.2500000 0.2000000
#> [2,] 0.5000000 0.3333333 0.2500000 0.2000000 0.1666667
#> [3,] 0.3333333 0.2500000 0.2000000 0.1666667 0.1428571
#> [4,] 0.2500000 0.2000000 0.1666667 0.1428571 0.1250000
#> [5,] 0.2000000 0.1666667 0.1428571 0.1250000 0.1111111