Suppose that Pascal's triangle is written as follows:
1  1   1   1   1  .  .  .
1  2   3   4   5  .  .  .
1  3   6  10  15  .  .  .
1  4  10  20  35  .  .  .
1  5  15  35  70  .  .  .
.    .    .    .    .
.    .    .    .    .
.    .    .    .    .
The first row and column consist entirely of 1s, and every other number is the sum of the number to its left and the number above. For each positive number n, let D(n) denote the determinant of the matrix consisting of the first n rows and first n columns of this array. Compute D(n).
The program at bottom uses Cramer's rule to calculate the determinants up through D(10). All are 1. So now treat this as a sequences problem:
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
As a sequence puzzle this indicates that D(n) = 1 for all n. As in all sequence puzzles, this is not a proof.
1 1 1 1 1 . . .
1 2 3 4 5 . . .
1 3 6 10 15 . . .
1 4 10 20 35 . . .
1 5 15 35 70
We can manually verify the correctness of the Cramer calculation through n=3:
For 1, D(1) = 1
D(1 1)
(1 2) = 2 - 1 = 1
D(1 1 1
1 2 3
1 3 6)
Using diagonals:
1 1 1 1 1
1 2 3 1
1 3 6 1 3
= 1*2*6 + 1*3*1 + 1*1*3 - 1*2*1 - 3*3*1 - 6*1*1
= 12 + 3 + 3 - 2 - 9 - 6 = 1
Beyond this we need to trust Cramer's rule.
DefDbl A-Z
Dim crlf$, tri(100, 100)
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr(13) + Chr(10)
maxsize = 10
For i = 1 To maxsize
tri(1, i) = 1
tri(i, 1) = 1
Next i
For row = 2 To maxsize
For col = 1 To maxsize
tri(row, col) = tri(row - 1, col) + tri(row, col - 1)
Next col
Next row
For sz = 1 To maxsize
Text1.Text = Text1.Text & mform(sz, "##0") & " " & det(sz, tri()) & crlf
DoEvents
Next
Text1.Text = Text1.Text & crlf & " done"
End Sub
Function det(sz, triangle())
If sz = 2 Then
xx = xx
End If
If sz = 1 Then
det = triangle(1, 1)
Exit Function
End If
ReDim matrix(sz - 1, sz - 1)
tot = 0
For col = 1 To sz
newrow = 0
For r = 2 To sz
newrow = newrow + 1
newcol = 0
For c = 1 To sz
If c <> col Then
newcol = newcol + 1
matrix(newrow, newcol) = triangle(r, c)
End If
Next
Next r
term = triangle(1, col) * det(sz - 1, matrix())
If col Mod 2 = 0 Then term = -term
tot = tot + term
Next col
det = tot
End Function
Function mform$(x, t$)
a$ = Format$(x, t$)
If Len(a$) < Len(t$) Then a$ = Space$(Len(t$) - Len(a$)) & a$
mform$ = a$
End Function
n=10 was the first value of n where it took any noticeable time at all to evaluate the determinant (a couple of seconds), but at n=11 it was taking longer than I wanted to wait.
|
Posted by Charlie
on 2018-03-31 14:28:37 |