News for hackers. Stuff that matters.
Re:Scientists discover fractal patterns in a quantum material by excessive on Saturday October 26, 2019 @09:39PM (#21367406)
Here is one in Python. Uncomment the if statement if you want it to terminate.

    def sin(x):
        def recur(x, n, s, p, f):
            #if n > 9: return s;
            return recur(x, n + 2, s + p/f, -p*x*x, f*(n + 1)*(n + 2))

        return recur(x, 1, 0, x, 1)
Of course maybe it's cheating from your intent because it's really just implementing the Taylor series, and it has too many arguments. I believe any analytic function could be defined this way if you can figure out the pattern for its derivatives.

There are no comments on this comment yet.