%mathpiper,def="HilbertMatrix"

// The arguments of the following functions should be checked
// notoriously hard to manipulate numerically
HilbertMatrix(n):=GenMatrix({{i,j}, 1/(i+j-1)}, n,n );
HilbertMatrix(m,n):=GenMatrix({{i,j}, 1/(i+j-1)}, m,n );


%/mathpiper



%mathpiper_docs,name="HilbertMatrix",categories="User Functions;Matrices (Special)"
*CMD HilbertMatrix --- create a Hilbert matrix
*STD
*CALL
	HilbertMatrix(n)
	HilbertMatrix(n,m)
*PARMS

{n,m} -- positive integers

*DESC

The function {HilbertMatrix} returns the {n} by {m} Hilbert matrix
if given two arguments, and the square {n} by {n} Hilbert matrix
if given only one. The Hilbert matrix is defined as {A(i,j) = 1/(i+j-1)}.
The Hilbert matrix is extremely sensitive to manipulate and invert numerically.

*E.G.

In> PrettyForm(HilbertMatrix(4))

	/                          \
	| ( 1 ) / 1 \ / 1 \ / 1 \  |
	|       | - | | - | | - |  |
	|       \ 2 / \ 3 / \ 4 /  |
	|                          |
	| / 1 \ / 1 \ / 1 \ / 1 \  |
	| | - | | - | | - | | - |  |
	| \ 2 / \ 3 / \ 4 / \ 5 /  |
	|                          |
	| / 1 \ / 1 \ / 1 \ / 1 \  |
	| | - | | - | | - | | - |  |
	| \ 3 / \ 4 / \ 5 / \ 6 /  |
	|                          |
	| / 1 \ / 1 \ / 1 \ / 1 \  |
	| | - | | - | | - | | - |  |
	| \ 4 / \ 5 / \ 6 / \ 7 /  |
	\                          /

*SEE HilbertInverseMatrix
%/mathpiper_docs