loda-lang / loda-cpp

Runtime and miner for the LODA language written in C++
https://loda-lang.org/
Apache License 2.0
21 stars 1 forks source link

Gaussian elimination not working for A001042 #311

Open ckrause opened 8 months ago

ckrause commented 8 months ago

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