Skip to content

Instantly share code, notes, and snippets.

@isomorphisms
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isomorphisms/365e37d2e26547677995 to your computer and use it in GitHub Desktop.
Save isomorphisms/365e37d2e26547677995 to your computer and use it in GitHub Desktop.
Galois / commutators / Abel-Ruffini / Boas Katz / Vladimir I. Arnol'd
#start with six random coefficients for the quintic + a constant
start <- complex( modulus=1+rnorm(6,sd=.1), argument=1:6 )
twiddler <- function(x) complex(modulus=1, argument=x)
#there’s some bogus R nonsense about c() and list() coming…
swirl <- list(start)
#twiddle the 6 inputs around
for (j in 1:326/8) { swirl <- c( swirl, list( start + c(0,-8*twiddler(j)*j,0,8*twiddler(j)*j,0,0) ) ) }
#change the zeroes to twiddle the other coefficients
require(magrittr) #as if you didn't already!
require(animation)
#you can replace this with just the 'for' loop for testing
saveGIF({
for (swoop in swirl) {
#side by side
par(mfrow=c(1,2));
#organising the plots with aesthetic stuff on a second line; is that more readable?
plot( swoop, pch=19, main='coefficients',
xlim=c(-3,3), ylim=c(-3,3), col=rgb(0,0,0, 1-1:6/10) );
#polyroot finds the answers for you, and so is in some sense the "main part" of this script. If I feed polyroot(1,2,-3) it solves x² + 2x − 3 = 0.
polyroot( swoop ) %>% plot(pch=19, cex=2
col=rainbow(5), main='solutions',
xlim=c(-3,2), ylim=c(-3,5) )
}}, interval=.03, movie.name='Abel-Ruffini.5.clown-balls.gif', ani.width=700, ani.height=300)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment