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

Simplify exponential functions #229

Open ckrause opened 1 year ago

ckrause commented 1 year ago

Check this formula:

; A139486: a(n) = Product_{j=0..n-1} (2^j + 2).
; Formula: a(n) = a(n-1)*(2*b(n-2)+2), a(1) = 3, a(0) = 1, b(n) = 2*b(n-1), b(1) = 2, b(0) = 1

=> b(n) should be simplified to 2^n See https://github.com/loda-lang/loda-cpp/blob/main/src/formula.cpp#L231

ckrause commented 1 year ago

Another example

; A085521: a(n) = Product_{k=0..n} (2^(2k+1)+1).
; Formula: a(n) = b(n)/3, b(n) = b(n-1)*(c(n-1)+1), b(1) = 9, b(0) = 3, c(n) = 4*c(n-1), c(1) = 8, c(0) = 2