Let $A$ be an arbitrary matrix. By definition, null space of $A$ is the space made by set of vectors $x$ such that $Ax = \vec{0}$.
Let
$$ A = \begin{bmatrix} a_1&b_1&0&0& \cdots & 0\\ b_1&a_2&b_2&0&\cdots&0\\ 0&b_2&a_3&b_3&\cdots&0\\ 0&0&\ddots&\ddots&\ddots&\vdots\\ 0&0&0&b_{n-2}&a_{n-1}&b_{n-1}\\ 0&0&0&0&b_{n-1}&a_n \end{bmatrix}, $$ $b_i \neq 0$, and denote the $j$th leading principle submatrix of $A$ by $A_j$ and we denote determinant of $A$ by $|A|$. I am looking for a vector $v=[v_1, \cdots,v_n]$ such that $Av = \vec{0}$.
To do so, I do the following steps:
$$a_1.v_1 + b_1.v_2 = 0 \Rightarrow v_2 = -\dfrac{a_1}{b_1}v_1 = -\dfrac{|A_1|}{b_1}$$ $$ b_1.v_1+a_2v_2+b_2v_3 = 0 \Rightarrow v_3 = -\dfrac{b_1}{b_2}.v_1+a_2 \dfrac{a_1}{b_1b_2}v_1 = \dfrac{a_1a_2-b_1^2}{b_1b_2}v_1 = \dfrac{|A_2|}{b_1b_2}v_1 $$
In general it can be verified that
$$ v_i = (-1)^{i+1}\dfrac{|A_{i-1}|}{\prod_{j=1}^{i-1}b_j}, $$ and from what I see, for any start vector entry $v_1$, I can build a $\vec{v}$.
I have this matrix
$$ A = \begin{bmatrix} -39.3219&3.2766&0&0&0\\ 3.2766&3.1063&-8.1100&0&0\\ 0&-8.1100&-44.1120&35.3205&0\\ 0&0&35.3205&-85.7838&-99.2419\\ 0&0&0&-99.2419&30.4548\\ \end{bmatrix}, $$ and I set the $v_1 = 1$. I wrote a program in Matlab to compute $v_i$ according to the relation given above. The result is
$$v=[1.0000, 12.0000, 5.0000, 9.0000, -6.0000]$$
and $Av$ in Matlab yields
1.0e+03 *
0
0
0
0.0000
-1.0802
I can't understand why the last component is nonzero. I made a few other examples and the same thing happened. I would be appreciated for any help.
Thanks in advance
Update
This is the Matlab code
function test()
n = 5;
v1=[1];
Q= [
-39.3219 3.2766 0 0 0;
3.2766 3.1063 -8.1100 0 0;
0 -8.1100 -44.1120 35.3205 0;
0 0 35.3205 -85.7838 -99.2419;
0 0 0 -99.2419 30.4548]
B1 = diag(Q,1);
for i=2:n
submatrix = Q(1:i-1,1:i-1);
value = (det(submatrix)*v1(1)*(-1)^(i+1))/prod(B1(1:i-1));
v1=[v1,value];
end
Q*v1'
end
Update: my guess
In the last two rows we have \begin{align*} b_{n-2}v_{n-2}+a_{n-1}v_{n-1}+b_{n-1}v_n &= 0\\ b_{n-1}v_{n-1}+a_nv_n &= 0 \end{align*}
May be there must be some conditions such $v_n$ in both rows be the same.
For a real square matrix to have a nontrivial null space, it must be singular. The matrix in your example isn’t, so it’s not surprising that your algorithm didn’t product a null vector for it. In fact, it’s possible to show directly that, with $v$ constructed as in your question, the last element of $Av$ vanishes iff $\lvert A\rvert = 0$.
First, observe that $$\lvert A\rvert = \left(a_n \lvert A_{n-1} \rvert - b_{n-1}^2 \lvert A_{n-2} \rvert\right). \tag1$$ This is obtained by expanding the determinant along the last row or column. Next, writing $v_i = c_i\lvert A_{i-1}\rvert v_1$, we have $$c_{i+1} = -{c_{i}\over b_i}. \tag2$$ The last element of $Av$ is therefore $$\begin{align} a_nv_n+b_{n-1}v_{n-1} &= \left(a_n c_n \lvert A_{n-1} \rvert + b_{n-1} c_{n-1} \lvert A_{n-2} \rvert\right)v_1 \\ &= \left(a_n c_n \lvert A_{n-1} \rvert - b_{n-1}^2 c_n \lvert A_{n-2} \rvert\right)v_1 \\ &= c_n \lvert A \rvert v_1. \end{align}$$ Since the $b_i$ are all nonzero and we’ve chosen $v_1\ne0$, this vanishes iff $\lvert A \rvert = 0$. All of the other elements of $Av$ vanish identically since, using a similar argument, $a_iv_i+b_{i-1}v_{i-1} = c_i\lvert A_i\rvert v_1 = -b_{i+1}v_{i+1}$. The last element of $Av$ is different because there’s no $b_{n+1}v_{n+1}$ term to cancel this.
An interesting feature of your construction is that if the rank of $A$ is $r$, then the last $n-r-1$ elements of $v$ must be zero: the rank of a matrix is equal to the order of its largest nonvanishing minor.