Skip to content

Instantly share code, notes, and snippets.

@travisdoesmath
travisdoesmath / app.js
Last active November 24, 2020 02:58
Triple Pendulums are Chaotic
var nPendulums = 20;
var pendulums = d3.range(nPendulums).map(x => new Pendulum({theta1: 0.75 * Math.PI + 0.00001*x/nPendulums}))
var fadeBackground = true;
var svg = d3.select("svg")
width = +svg.attr("width"),
height = +svg.attr("height"),
g = svg.append("g").attr("transform", "translate(" + width*.5 + "," + height*.5 + ")");
@travisdoesmath
travisdoesmath / app.js
Last active July 23, 2024 01:32
(N>1)-tuple pendulums are chaotic
let test = new TuplePendulum({N: 4, thetas:[1, 2, 3], omegas:[0.1,0.2,0.3]})
var nPendulums = 5
var pendulums = d3.range(nPendulums).map(x => new TuplePendulum({N: 2**x, thetas: [0.5 * Math.PI]}))
var fadeBackground = false;
var svg = d3.select("svg")
width = +svg.attr("width"),
alphabet = ' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
def poly_from_coefficients(coefs):
def poly(x):
p = 0
for i, coef in enumerate(coefs):
p += coef * x ** i
return p
def poly_prime(x):
from pprint import pprint
def poly_from_coefficients(coefs):
def poly(x):
p = 0
for i, coef in enumerate(coefs):
p += coef * x ** i
return p
return poly