Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <math.h>
#include <complex.h>
#include <assert.h>
#ifndef WIDTH
#define WIDTH 800
#endif
#ifndef HEIGHT
// Draw a graph of argument or modulus of p_n(z)
// where p_0(z) = z and p_{i+1}(z) = p_i(z)^2 + z
// Written by David A. Madore, 2020-01-29. Public Domain.
#include <stdio.h>
#include <math.h>
#include <complex.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <complex.h>
#include <assert.h>
#ifndef MAXITER
#define MAXITER 1000
## Let FBCD be a quadrilateral, angle(DBF)=a, angle(DBC)=b,
## angle(FCB)=c, angle(FCD)=d, angle(FDB)=e. Show that if a=20deg,
## b=60deg, c=50deg, d=30deg then e=30deg.
## We call ta = tan(a/2), tb = tan(b/2), etc.
## B=(0,0), C=(1,0), F=(u,v) and D=(x,y).
R.<ta,tb,tc,td,te,x,y,u,v> = PolynomialRing(QQ,9)
def ratcos(t):
@Gro-Tsen
Gro-Tsen / covid19-links.md
Last active November 26, 2020 18:58
Links to information sources on COVID-19 outbreak
git clone https://github.com/pcm-dpc/COVID-19/
cd COVID-19
fgrep -i lombardia dati-regioni/dpc-covid19-ita-regioni.csv | cut -d , -f 11,12 | perl -pe 's/,/\t/g' > /tmp/lombardia.dat
(echo 'set terminal pngcairo size 800,600' ; echo 'set output "/tmp/lombardia.png"' ; echo 'plot "/tmp/lombardia.dat" using ($0+1):($2/$1), -0.01199*x+0.35964') | gnuplot
R
data = read.table("/tmp/lombardia.dat", header=FALSE, sep="\t")
colnames(data) = c("cases", "variation")
data$id <- seq.int(nrow(data))
fit = lm(data$variation/data$cases ~ data$id)
summary(fit)
git clone https://github.com/pcm-dpc/COVID-19/
cd COVID-19
fgrep -i lombardia dati-regioni/dpc-covid19-ita-regioni.csv | cut -d , -f 15 > /tmp/lombardia.dat
R
data = read.table("/tmp/lombardia.dat", header=FALSE, sep="\t")
colnames(data) = c("cases")
data$variation = diff(c(0, data$cases))
data$day <- seq.int(nrow(data))
data2 = subset(data, cases>=1)
repnum = 3
var('s i r t')
p = desolve_system_rk4([-repnum*i*s, repnum*i*s-i, i], [s,i,r], ics=[0, N(1/repnum), N((repnum-log(repnum)-1)/repnum), N(log(repnum)/repnum)], ivar=t, end_points=[-5,8], step=0.01)
list_plot([(tmp[0], tmp[1]) for tmp in p], color="green", plotjoined=True) + list_plot([(tmp[0], tmp[2]) for tmp in p], color="red", plotjoined=True) + list_plot([(tmp[0], tmp[3]) for tmp in p], color="blue", plotjoined=True)
list_plot([(tmp[0], tmp[1]) for tmp in p], color="green", plotjoined=True, ymin=1e-5, ymax=1, scale="semilogy") + list_plot([(tmp[0], tmp[2]) for tmp in p], color="red", plotjoined=True, ymin=1e-5, ymax=1, scale="semilogy") + list_plot([(tmp[0], tmp[3]) for tmp in p], color="blue", plotjoined=True, ymin=1e-5, ymax=1, scale="semilogy")
G = N(-lambert_w(-repnum*exp(-repnum))/repnum)
qx = [(N(j/100), N(((1-G)^2/sqrt(G))*exp(repnum*(1-G)*(j/100)))) for j in range(-500,801)]
q = [(t, ((1-G)^2 + G*x)/((1-G)^2 + x), ((1-G)^4*x)/(((1-G)^2 + G*x)*((1-G)^2 + x)), ((1-G)*G*x)/((1-G)^2 + G*x))
import requests
import pandas
import numpy as np
from sklearn.gaussian_process import GaussianProcessRegressor
from sklearn.gaussian_process.kernels import ConstantKernel as C, RBF, WhiteKernel as W, DotProduct as DP
import matplotlib
matplotlib.use('TkAgg')
from matplotlib import pyplot as plt
spherical-interactions.html