Skip to content

Instantly share code, notes, and snippets.

@8q
Created February 15, 2017 17:22
Show Gist options
  • Save 8q/c40d58b00304ff207dd8651c3c0f2d2d to your computer and use it in GitHub Desktop.
Save 8q/c40d58b00304ff207dd8651c3c0f2d2d to your computer and use it in GitHub Desktop.
R lang test
xmin <- -2
xmax <- 2
ymin <- -2
ymax <- 2
size <- 1000 #点の数はsize*size
n <- 100 #発散判定の試行回数
X <- matrix(rep(seq(xmin, xmax, length=size), times=size), nrow=size)
Y <- matrix(rep(seq(xmin, xmax, length=size), times=size), nrow=size, byrow=TRUE)
C <- X + 1i * Y
Z <- matrix(rep(numeric(size), times=size), nrow = size)
Res <- matrix(rep(numeric(size), times=size), nrow = size)
for(i in 1:n) {
Z = Z^2 + C
mask = abs(Z) > 2
Z[mask] <- C[mask] <- 0 + 0i
Res[mask] <- i
print(i)
}
image(Res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment