One session:
julia> function foo(z)
c = 100
max = 80
for n = 1:max
abs(z) ≥ 2 && return n-1
z = z^2 + c
end
return max
end
foo (generic function with 1 method)
julia> foo(x, y) = foo(x + y*im)
foo (generic function with 2 methods)
julia> foo_grid(n) =
broadcast(foo,
linspace(-0.5, 1, n)',
linspace(-1, 0.5, n))
foo_grid (generic function with 1 method)
julia> foo_grid(10)
10x10 Array{Float64,2}:
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
julia> function foo(z)
c = 1 + 1*im
max = 80
for n = 1:max
abs(z) ≥ 2 && return n-1
z = z^2 + c
end
return max
end
foo (generic function with 2 methods)
julia> foo(x, y) = foo(x + y*im)
foo (generic function with 2 methods)
julia> foo_grid(n) =
broadcast(foo,
linspace(-0.5, 1, n)',
linspace(-1, 0.5, n))
foo_grid (generic function with 1 method)
julia> foo_grid(10)
10x10 Array{Float64,2}:
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
Another session:
julia> function foo(z)
c = 1 + 1*im
max = 80
for n = 1:max
abs(z) ≥ 2 && return n-1
z = z^2 + c
end
return max
end
foo (generic function with 1 method)
julia> foo(x, y) = foo(x + y*im)
foo (generic function with 2 methods)
julia> foo_grid(n) =
broadcast(foo,
linspace(-0.5, 1, n)',
linspace(-1, 0.5, n))
foo_grid (generic function with 1 method)
julia> foo_grid(10)
10x10 Array{Float64,2}:
1.0 2.0 5.0 80.0 3.0 3.0 3.0 3.0 3.0 80.0
2.0 2.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 2.0
2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0
2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0
2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0
2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 1.0
2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 1.0
2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 1.0 1.0
2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 1.0 1.0
2.0 2.0 2.0 2.0 2.0 2.0 2.0 1.0 1.0 1.0