# Plot condition number of Hilbert matrix against matrix size n.

• March 16th 2009, 01:02 AM
Plot condition number of Hilbert matrix against matrix size n.
Plot condition number of Hilbert matrix against matrix size n. Propose set of linear equations with Hilbert matrix of coefficients and with solution http://www.lookpic.com/files/matr.jpg.Try to solve the equation for different n and plot the norm of the residual against n.

Honestly I have no idea how to cooperate with it. I've just found out that i have to use hilb(n).
• March 16th 2009, 02:56 AM
CaptainBlack
Quote:

Plot condition number of Hilbert matrix against matrix size n. Propose set of linear equations with Hilbert matrix of coefficients and with solution http://www.lookpic.com/files/matr.jpg.Try to solve the equation for different n and plot the norm of the residual against n.

Honestly I have no idea how to cooperate with it. I've just found out that i have to use hilb(n).

As:

$
H_n = \begin{bmatrix}
1 & \frac{1}{2} & ... & \frac{1}{n} \\
\frac{1}{2} & \frac{1}{3} & ... & \frac{1}{n+1} \\
: & : & \ddots & : \\
\frac{1}{n} & \frac{1}{n+1} & ... & \frac{1}{2n-1} \\
\end{bmatrix}
$

You want the solution of:

$
H_nx=c
$

to be:

$
x=\begin{bmatrix}1 \\ 1 \\ \vdots \\ 1 \end{bmatrix}
$

in which case we want:

$
c=\begin{bmatrix}\sum_{r=1}^n \frac{1}{r} \\ \\ \sum_{r=2}^{n+1} \frac{1}{r} \\ \\ \vdots \\ \\ \sum_{r=n}^{2n-1} \frac{1}{r}\end{bmatrix}
$

CB
• March 16th 2009, 07:32 AM
Ummm.... It looks for me like a magic (Worried) And how to write an m. file concerning solution of this problem? Would you be so kind and tell me?
• March 17th 2009, 10:10 AM
CaptainBlack
Quote:

Originally Posted by CaptainBlack
As:

$
H_n = \begin{bmatrix}
1 & \frac{1}{2} & ... & \frac{1}{n} \\
\frac{1}{2} & \frac{1}{3} & ... & \frac{1}{n+1} \\
: & : & \ddots & : \\
\frac{1}{n} & \frac{1}{n+1} & ... & \frac{1}{2n-1} \\
\end{bmatrix}
$

You want the solution of:

$
H_nx=c
$

to be:

$
x=\begin{bmatrix}1 \\ 1 \\ \vdots \\ 1 \end{bmatrix}
$

in which case we want:

$
c=\begin{bmatrix}\sum_{r=1}^n \frac{1}{r} \\ \\ \sum_{r=2}^{n+1} \frac{1}{r} \\ \\ \vdots \\ \\ \sum_{r=n}^{2n-1} \frac{1}{r}\end{bmatrix}
$

CB

Untested:

Code:

Hn=hilb(n); x=ones(n,1); c=(sum(Hn))';  % or Hn*x x1=Hn\c; err=sqrt((x1-x)'*(x1-x)); cn=cond(Hn);
CB