-- $Id: domaincoloring-functions.lua 965 2024-08-26 17:50:33Z herbert $

kpse.set_program_name("luatex")

function f0(z)
   return cmath.sin(1/z)*cmath.cos(1/z)/z^3+1/z
end

function f1(z)
    return cmath.cos(z)/cmath.sin(z^4-1)
end

function f2(z)
  local c = complex(1,-1)
  local d = complex(0,0.28)
  return cmath.cos(c^2*z^2)/cmath.cos(c*(z-d))
end

function f3(z)
  return z*(z+i)^2/(z-i)^2
end

function f4(z)
  if abs(z) < 0.1 then 
    return complex(0.001,0.001)  
  else 
    return cmath.sin(1/(z*z))
  end
end

function f5(z)
  return cmath.sqrt(1-1/(z*z)+z^3)
end

function f9(z)
  local c = complex(1,-1)
  local d = complex(1,1)
  return z^2*c^2*(z*c-1-i)/(z*c-2*d)
end

function f10(z)
  local sum = complex(0,0)
  for n=1,20 do
      sum = sum + z^n/(1-z^n)
  end
  return sum
end

function f11(z)   
  local iterateNo = 3
  for n=1,iterateNo do
    z = z^2 
  end
  return z
end

function f12(z)   -- julia
  local iterateNo = 15
  for n=1,iterateNo do
    z = z^2 + complex(0.25,-0.5)
  end
  return z
end

function f13(z)   -- mandelbrot
  local iterateNo = 15
  local c = z
  z = complex(0,0)
  for n=1,iterateNo do
    z = z^2 + c
  end
  return z
end

function f14(z)   
  local iterateNo = 5
--  local c = z
--  z = complex(0,0)
  for n=1,iterateNo do
    z = cmath.sin(z)*cmath.sin(0.8*z) -- + c
  end
  return z
end

