mxtlrr / treng

Hyperoperation engine with it's own homebrew big number library.
1 stars 0 forks source link

Optimize `pow(a,b)` #1

Open mxtlrr opened 2 months ago

mxtlrr commented 2 months ago

Currently, for example, computing 3^(2^32) takes over 9 minutes just to get to 3^500000.

What can we do to fix this?

  1. Split up exponents, for example:

$$ a^n = \prod_{k=1}^{t} a^t $$

(note that here, $t$ is the biggest whole number such that $a/t$.)

  1. Store known exponents in a table i. If we have already computed the value of the exponent, we store the result in a table so we don't have to compute it again ii. If the exponent is something basic like n^2 or n^3, we can store the value of n^2/n^3 in a table so we don't spend computing power.