Email or username:

Password:

Forgot your password?
⛧ esoterik ⛧

finding rational approximations of pi using #modal, no big deal

9 comments
⛧ esoterik ⛧

this is not as cool as i had hoped because it just hardcodes the first 14 terms of the continued fraction for pi, i.e. 3, 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1

oeis.org/A001203

(i did implement a generalized continued fraction which isn't hardcoded, but (A) it converges much more slowly and (B) it doesn't actually find the "best" convergents (e.g. 355/113) so it just didn't seem very useful.)

⛧ esoterik ⛧

i should have put "useful" in scare-quotes

Devine Lu Linvega

@d6 3 minutes, are you using the peano arithmetic rules?

⛧ esoterik ⛧

@neauoire this is using the binary arithmetic rules i wrote (with 0 and 1), but it has to do a TON of division of large numbers, which is slow.

Devine Lu Linvega

@d6 This is very nice! All in native numbers then.

I don't know if you saw, but I've started putting a x11 playground to draw modal programs to a framebuffer?

Fractals next?
git.sr.ht/~rabbits/thuesday

⛧ esoterik ⛧

@neauoire oh! yes! that would be super fun.

i need to port arith.modal to the number device you implemented. i think that should give at least a 10x speed up.

Devine Lu Linvega

@d6 we're still figuring out how to do it right, so it might change still. But yeah, the fib example shows how it works a bit, the ?0-9 registers match values, and ?: on an operator is a kind of bang to evaluate an arithmetic operation.

⛧ esoterik ⛧

@neauoire i'm cheating -- just using a continued fraction representation:

git.phial.org/d6/modal/src/bra

i had a GCF implementation using the faster fraction from here: en.wikipedia.org/wiki/Generali

however the regular CF provides better approximations, so it seemed better to do it that way.

Go Up