brot/mandelbrot.lua

local bignum = require "bignum"

local M = {}

local function sq(x, y)
	return x*x - y*y, 2 * x * y
end

function M.orbit(iter, x, y)
	local o = {}
	local zx, zy = bignum.float(0, 32), bignum.float(0, 32)
	for i = 1, iter do
		local rx, ry = bignum.tonumber(zx), bignum.tonumber(zy)
		table.insert(o, {rx, ry})
		zx, zy = sq(zx, zy)
		zx, zy = zx + x, zy + y
	end
	return o
end

return M