Created
May 20, 2018 13:54
-
-
Save beta-decay/088028144a90e69c048ff3e98ad4c617 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fnums <- c(1, 1) | |
x <- 1:30 | |
phi <- c() | |
pdiff <- c() | |
actual = 0.5 * (1 + 5^0.5) | |
for (i in x) { | |
next_fibo = fnums[i] + fnums[i+1] | |
fnums <- c(fnums, next_fibo) | |
approx = fnums[i+1] / fnums[i] | |
phi <- c(phi, approx) | |
difference = abs((approx - actual)/actual * 100) | |
pdiff <- c(pdiff, log(difference)) | |
} | |
par(mfrow=c(2,1)) | |
plot(x, phi, type = "l", col = "red", lwd = 3, ylab="Approximate value of phi", xlab="Number of points") | |
plot(x, pdiff, pch=16, ylab="Log10 of % Difference", xlab="Number of points") | |
abline(lm(x ~ pdiff)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment