Skip to content

Instantly share code, notes, and snippets.

View 20220504-extended-dynkin-diagrams.tex
\documentclass[10pt,a4paper]{article} % -*- coding: utf-8 -*-
\usepackage[a4paper,margin=1.5cm]{geometry}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{times}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
View shape-of-c3.sage
C = CartanType("C3")
rk = C.rank()
detcmat = C.cartan_matrix().det()
invcmat = C.cartan_matrix().inverse()
WCR = WeylCharacterRing(C)
WR = WeightRing(WCR)
# Fundamental coweights:
fundcoweights = dict([(i+1, sum([invcmat[i][j]*WCR.simple_coroots()[j+1] for j in range(rk)])) for i in range(rk)])
# Coefficients of highest root:
hwcf = [WCR.highest_root().scalar(fundcoweights[j]) for j in range(1,rk+1)]
View OrbitControls.js
console.warn( "THREE.OrbitControls: As part of the transition to ES6 Modules, the files in 'examples/js' were deprecated in May 2020 (r117) and will be deleted in December 2020 (r124). You can find more information about developing using ES6 Modules in https://threejs.org/docs/index.html#manual/en/introduction/Import-via-modules." );
/**
* @author qiao / https://github.com/qiao
* @author mrdoob / http://mrdoob.com
* @author alteredq / http://alteredqualia.com/
* @author WestLangley / http://github.com/WestLangley
* @author erich666 / http://erichaines.com
* @author ScieCode / http://github.com/sciecode
*/
View example.vote
A>B>C>D: 00.00%
A>B>D>C: 05.60%
A>C>B>D: 06.80%
A>C>D>B: 07.00%
A>D>B>C: 01.50%
A>D>C>B: 06.30%
B>A>C>D: 04.40%
B>A>D>C: 06.70%
B>C>A>D: 02.30%
B>C>D>A: 06.60%
View perlscoping.pl
#! /usr/local/bin/perl -w
use strict;
use warnings;
for ( my $i=0 ; $i<5 ; $i++ ) {
my $var;
sub returnvar { return $var; }
$var = $i;
print "\$i=$i, \$var=$var, returnvar returns ", returnvar, "\n";
}
View thornify.js
// JavaScript functions to replace "th" by the letter thorn throughout
// a document. Use this with `thornifyDoc(window.document)`.
// Written by David A. Madore, 2022-04-02. Public Domain.
function thornifyString(s) {
return s.replace(/T[Hh]/g, "\u00DE").replace(/th/g, "\u00FE");
}
function thornifyDoc(doc) {
View q-analog-plots-on-unit-circle.sage
### The case of E_6
WCR = WeylCharacterRing("E6", style="coroots")
weylcovec = sum([rt.associated_coroot() for rt in WCR.positive_roots()])/2
R.<t> = QQ['t']
weyldenom = prod([t^rt.scalar(weylcovec)-1 for rt in WCR.positive_roots()])
weylnumertab = [None] + [prod([t^(rt.scalar(weylcovec)+(1 if WCR.fundamental_weights()[i].scalar(rt.associated_coroot())>0 else 0))-1 for rt in WCR.positive_roots()]) for i in range(1,6+1)]
counttab = [None] + [R(weylnumertab[i]/weyldenom) for i in range(1,6+1)]
def realize(pol):
d = pol.degree()
def v(x):
View gamma-ticks.pl
#! /usr/local/bin/perl -w
# Generate a ticking sound where the intervals between ticks are
# distributed following a Gamma distribution.
# Produces raw 48k 16-bit signed single channel audio. So pipe this to:
# sox -t raw -r 48k -c 1 -e signed -b 16 -L - -t wav ticks.wav
# Command-line parameters are:
# -r <number>: the average tick rate in ticks per second (defaults to 2)
View tileable-fractals.sage
# Base 3-w where w is a 6-th root of unity
w = N(exp(I*pi/3))
def dragonpoints(depth):
if depth <= 0:
return [(1+w)/3]
else:
parta = [z+1 for z in dragonpoints(depth-1)]
partb = [z/w+w for z in dragonpoints(depth-1)]
partc = [z+w for z in dragonpoints(depth-1)]
return [z/(3-w) for z in parta+partb+partc]
View stoermers-problem.sage
# Return cnt solutions of the Pell-Fermat equation x^2 - d*y^2 = 1
def pell_equation(d, cnt):
if cnt < 1:
return []
# First, find the "fundamental" solution
cf = continued_fraction(QQbar(sqrt(d)))
i = 0
(xfun,yfun) = (None,None)
while True:
r = cf.convergent(i)