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

Replace simple references to recursive functions in formulas #308

Open ckrause opened 10 months ago

ckrause commented 10 months ago

Example:

; A266709: Coefficient of x in minimal polynomial of the continued fraction [2,1^n,2,1,1,...], where 1^n means n ones.
; Formula: a(n) = b(n+2), b(n) = 2*b(n-1)+2*b(n-2)-b(n-3), b(3) = -25, b(2) = -7, b(1) = -5, b(0) = 1

mov $2,1
add $0,2
lpb $0
  sub $0,1
  add $1,$2
  add $5,$1
  add $1,$2
  mov $3,$5
  sub $3,6
  mov $4,$2
  mov $2,$3
  mov $5,1
  add $5,$4
lpe
mov $0,$2

=> It would be nice to simplify the formula to a(n) = 2*a(n-1)+2*a(n-2)-a(n-3) with adjusted initial terms.