Tupper's self-referential formula: Difference between revisions

Content added Content deleted
Line 59: Line 59:


=={{header|Julia}}==
=={{header|Julia}}==
<syntaxhighlight lang="julia">import Images: colorview
<syntaxhighlight lang="julia">import Images: colorview, Gray
import Plots: plot
import Plots: plot


setprecision(BigFloat, 8000)
setprecision(BigFloat, 8000)


""" get logical inverse of Tupper function values for white on black graphic """
function tupper_mat(k)
function tupper_mat(k)
tmatrix = falses(17, 106)
tmatrix = trues(17, 106)
for (i, x) in enumerate(0.0:1:105), (j, y) in enumerate(k:k+16)
for (i, x) in enumerate(0.0:1:105), (j, y) in enumerate(k:k+16)
tmatrix[j, 107 - i] = 1/2 < floor(mod(floor(y / 17) * 2^(-17 * floor(x) - mod(floor(y), 17)), 2))
tmatrix[j, 107 - i] = 1/2 >= floor(mod(floor(y / 17) * 2^(-17 * floor(x) - mod(floor(y), 17)), 2))
end
end
return tmatrix
return tmatrix
Line 83: Line 84:


function test_tupper()
function test_tupper()
f = tupper_mat(k)
bmap = tupper_mat(k)
display(plot(colorview(Gray, .!f), ylims = [1,17])) # invert black / white with .!
display(plot(colorview(Gray, bmap), ylims = [1,17])) # invert black / white with .!
savefig("tupper.png")
savefig("tupper.png")
end
end