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).
(In reply to
computer assisted solution by Charlie)
Since my algorithm for taking a determinant was slow, I checked out a couple of versions of Basic that had built-in functions for taking a determinant:
TI-Basic on a TI 84 ce calculator:
Variable Name: PASCLDET
Comment: Created by TI Connect CE 5.3.0.384
Store Type: RAM
----------
{0}STO->L1
For(N,1,20)
{N,N STO->dim([A]
For(I,1,N)
1 STO->[A](1,I)
1 STO->[A](I,1)
End
For(R,2,N)
For(C,2,N)
[A](R-1,C)+[A](R,C-1)STO->[A](R,C)
End
End
det([A])STO->L1(1+dim(L1
Output(1,1,L1)
End
I populated the list with a zero just to initialize it, as it wouldn't accept a null list for some reason. So the 0 at the beginning doesn't mean anything, and the first 1 is for the 1x1 matrix.
Variable Name: L1
Comment: Created by TI Connect CE 5.3.0.384
Store Type: RAM
----------
0
1
1
1
1.000000000002
1
0.99999999999075
1.0000000029382
1.0000000049376
1.000000019085
0.99999939385755
0.99999999936503
0.99998391443018
0.9989719804611
1.0014385302497
0
0
0
0
0
0
It ran into rounding errors quickly, as the calculator stores only 14 significant figures internally (it shows only ten in its display).
Mintoris Basic for Android:
Open 2,"pascal determinant.txt","w"
for n=1 to 20
dim a(n-1,n-1)
for i=0 to n-1
a(0,i)=1
a(i,0)=1
next
for row=1 to n-1
for col=1 to n-1
a(row,col)=a(row-1,col)+a(row,col-1)
next
next
print n,matdet(a())
Writeln 2,str$(n)+" "+str$(matdet(a()))
next
print
Print 1000000/3-333333
Writeln 2,str$(1000000/3-333333)
Close 2
n determinant
1 1
2 1
3 1
4 1
5 1
6 1
7 0.999999999996
8 0.999999999982
9 0.999999999929
10 0.999999995065
11 0.999999996536
12 1.000000228645
13 0.999998493428
14 0.999976582983
15 1.000976525481
16 1.000609535119
17 1.001842043219
18 1.369102534734
19 -4.417485151413001
20 20.043823196746
0.333333333314
This version of basic is just about as accurate as VB, with 15 or 16 significant decimal digits. The 0.333333333314 was just an accuracy test, using 1000000/3-333333 to eliminate the first six significant figures and find ten more digits accurate as 3's.
As the matrix gets larger, not only are there more multiplications, but the numbers get larger also, and after subtractions significant digits get lost. The TI's zeros are probably overflows subtracting from overflows--at least that's a viable theory.
Edited on April 11, 2018, 1:06 pm
|
Posted by Charlie
on 2018-04-11 12:34:22 |