loda-cpp
loda-cpp copied to clipboard
Gaussian elimination not working for A001042
The currently generated formula for A001042 is:
a(n) = a(n-1)^2-a(n-1)+b(n-1), b(n) = -a(n-1)+b(n-1)
Note that by Gaussian elimination we should find a simpler formula for b(n):
a(n)-b(n) = a(n-1)^2
b(n) = a(n)-a(n-1)^2
Substituting it in the main formula, we can further simplify to:
a(n) = a(n-1)^2-a(n-2)^2
Issue can be reproduced using:
./loda export -l debug A001042
Relevant code is here: https://github.com/loda-lang/loda-cpp/blob/main/src/form/variant.cpp