A Hilbert matrix is defined as:

where

and

Example:

In this post I have written a code that generates Hilbert matrices using C language.

### CODE:

/******************************* ****HILBERT MATRIX GENERATOR**** *******************************/ #include<stdio.h> /******** Function that generates a Hilbert matrix Parameters: no. of rows: m, no. of coulmns: n, a matrix of size mxn that would store the Hilbert matrix ********/ void Hilbert(int m, int n, double H[m][n]){ int i,j; for(i=0;i<m;i++){ for(j=0;j<n;j++){ H[i][j]=(double)1.0/((i+1)+(j+1)-1.0); } } } /******* Function that prints the elements of a matrix row-wise Parameters: rows(m),columns(n),matrix[m][n] *******/ void printMatrix(int m, int n, double matrix[m][n]){ int i,j; for(i=0;i<m;i++){ for(j=0;j<n;j++){ printf("%lf\t",matrix[i][j]); } printf("\n"); } } int main(){ int m,n,i,j; printf("Enter the size of the Hilbert matrix you want to generate:\nNo. of rows (m): "); scanf("%d",&m); printf("\nNo. of columns (n): "); scanf("%d",&n); double H[m][n]; Hilbert(m,n,H); printf("\nThe reequired Hilbert matrix is:\n"); printMatrix(m,n,H); }

### OUTPUT:

### Android Apps:

I’ve also created a few Android apps that perform various matrix operations and can come in handy to those taking a course on Numerical Methods.

Download: https://play.google.com/store/apps/details?id=com.bragitoff.numericalmethods

Download: https://play.google.com/store/apps/details?id=com.bragitoff.matrixcalculator

### References and resources:

https://en.wikipedia.org/wiki/Hilbert_matrix

http://mathworld.wolfram.com/HilbertMatrix.html

http://reference.wolfram.com/language/ref/HilbertMatrix.html