cafaxo
f(z) = \sum_{n=0}^\infty n^3 z^n.
The sum we are looking for will then be f(1/2).
We start with the closed form of the geometric series:
\sum_{n=0}^\infty z^n = 1/(1 - z).
Take the derivative with respect to z on both sides and multiply both sides with z to get:
\sum_{n=0}^\infty n z^n = z/(1 - z)^2.
Repeat this step to get:
\sum_{n=0}^\infty n^2 z^n = (z^2 + z)/(1 - z)^3.
Repeat again to get:
\sum_{n=0}^\infty n^3 z^n = (z^3 + 4z^2 + z)/(1 - z)^4.
Insert z=1/2 into that and we get 26.
[1] https://github.com/cafaxo/Llama2.jl/tree/master/src/training
For example, for 8-bit signed integers we choose the representatives -128, -127, ..., 127 of the residue classes -128 + 256Z, -127 + 256Z, ..., 127 + 256Z in the ring of integers modulo 256.
For 8-bit unsigned integers, we instead choose the representatives 0, 1, ..., 255.
Mathematically, I do not see how anything is "breaking" as the article claims.
Numerically, such a binary answer is pretty useless. Here, we need a measure of how singular/nonsingular a matrix is relative to the numerical precision we are working with.
Let's say we are in a setting where we only work with integers. Linear maps are bijective if the determinant is invertible in the underlying ring. In the case of Z, this only applies to -1 and 1.
So, the code is also incorrect in the integer setting. Here, we should not check for 0, but for -1 or 1.
The problem with the determinant is not about performance. It is just useless for determining if a matrix is singular. The thing that gives it away is that the determinant is influenced by a rescaling of the matrix:
det(s A) = s^n det(A) where A is a n x n matrix
As an example, would you say that [[1e-10, 0], [0, 1e-10]] is singular? It has condition number 1.
"Consider the matrix A = np.array([[1, 2], [2, 4]]). We can check if this matrix is singular or nonsingular using the determinant function. [...]"
No. The determinant is not a suitable way to do that. A proper way to numerically measure singularity would be to compute the condition number of the matrix (the ratio of its largest to smallest singular value).
AlphaDev's optimization relies on the fact that B and C are already in the correct order. This precondition is missing from the prompt given to GPT-4. It seems that GPT-4 is hallucinating something that only resembles the correct optimization at first glance.