Snippets

Stuart Morrison Visualising the Riemann Zeta Function

Created by Stuart Morrison

File snippet.r Added

  • Ignore whitespace
  • Hide word diff
+library(pracma)
+library(ggplot2)
+library(animation)
+library(gganimate)
+library(dplyr)
+
+#### Create complex set ####
+    # Imaginary parts
+    y <- seq(0, 100, len = 10001)
+    
+    # Complex vector
+    z <- 0.5 + y * 1i
+    
+#### Evaluation of Zeta function ####
+    # Real part
+    real <- Re(zeta(z))
+    
+    # Imaginary part
+    imaginary <- Im(zeta(z))
+
+#### Plotting ####
+    zeta_df <- data.frame(real = real,
+                 imag = imaginary,
+                 frame = 1:10001)
+    
+    g <- zeta_df %>% 
+            ggplot(aes(x = real, y = imaginary, frame = frame)) +
+                geom_path(size = 1.2, aes(cumulative = T)) +
+                geom_point(size = 2, aes(x = 0, y = 0)) 
+    gganimate(p = g, filename = "riemann.mp4", interval = 0.001, title_frame = F)
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.