Skip to content

Instantly share code, notes, and snippets.

View Hermann-SW's full-sized avatar

Hermann Stamm-Wilbrandt Hermann-SW

View GitHub Profile
@Hermann-SW
Hermann-SW / a11.3399714628553118047.gp
Created January 16, 2026 16:54
Compute number of primes of form x^2 + x + A for x <= 10^11 (for Jacobson and Williams A = 3399714628553118047)
export(A=3399714628553118047); a(n)=parsum(k=0, 10^n, isprime(k^2+k+A));
default(threadsizemax,1000*10^6); \\ default 8MB was too small
#
print(a(11));
@Hermann-SW
Hermann-SW / a11.A331876.gp
Created January 15, 2026 07:21
Script to compute a(11) for oeis sequence A331876 (Euler polynomial)
a(n)=parsum(k=0, 10^n, isprime(k^2 + k + 41));
default(threadsizemax,1000*10^6); \\ default 8MB was too small
#
print(a(11));
@Hermann-SW
Hermann-SW / a11.gp
Last active January 10, 2026 14:50
Script to verify a(11) for oeis sequence A392244
a(n)=parsum(k=1, 10^n, isprime(k^2+(k+1)^2));
default(threadsizemax,100*10^6); \\ default 8MB was too small
#
print(a(11));
@Hermann-SW
Hermann-SW / coretemps
Last active January 10, 2026 15:57
Determine temerature statistics for sockets and cores
#!/bin/bash
nsockets=$(grep "physical id" /proc/cpuinfo | sort -u | wc -l)
for((i=0; i<nsockets; ++i))
do
coretemp=$(sensors -A | sed -n "/^coretemp-isa-000$i/,/^$/p")
echo "$coretemp" | grep "Package" | sort
high=$(echo "$coretemp" | grep "Core" | cut -b17- | grep high | sort -n)
ts=$(
(
echo "$high" | sort -n | head -1
@Hermann-SW
Hermann-SW / parallel_dfs_bfs_evenly.cc
Last active January 5, 2026 18:34
Determine pi_{k^2+(k+1)^2}(10^n) (for all k<=10^n)
/* NOLINT(legal/copyright)
f=parallel_dfs_bfs_evenly
g++ $f.cc -O3 -Wall -pedantic -Wextra -fopenmp -o $f
cpplint $f.cc
cppcheck --enable=all --suppress=missingIncludeSystem $f.cc --check-config
*/
#include <string.h>
#include <omp.h>
#include <iostream>
@Hermann-SW
Hermann-SW / pi.cc
Created January 3, 2026 21:21
Determine pi(10^n) = pi_{k}(10^n) (for all k<=10^n)
// NOLINT(legal/copyright)
// g++ pi.cc -lgmp -lgmpxx -O3 -Wall -pedantic -Wextra -o pi
// (cpplinted and cppchecked)
//
#include <time.h>
#include <math.h>
#include <gmpxx.h>
#include <assert.h>
#include <iostream>
@Hermann-SW
Hermann-SW / par.cc
Last active January 7, 2026 00:22
Determine pi_{k^2+(k+1)^2}(10^n) (for all k<=10^n)
// NOLINT(legal/copyright)
// g++ par.cc -O3 -Wall -pedantic -Wextra -o par -fopenmp
// (cpplinted and cppchecked)
//
#include <string.h>
#include <iostream>
#include <cassert>
#include <tuple>
#include <queue>
@Hermann-SW
Hermann-SW / apollonian_circles.jscad
Last active December 10, 2025 01:55
Apollonian circles playground
"use strict"
const jscad = require('@jscad/modeling')
const math = require('mathjs')
const { extrudeLinear } = jscad.extrusions
const { hullChain } = jscad.hulls
const { circle } = jscad.primitives
const { vectorText } = jscad.text
const { scale, translate } = jscad.transforms
@Hermann-SW
Hermann-SW / gimod.gp
Last active December 6, 2025 06:04
modulus for Gaussian integers, with t_COMPLEX and number field
\\ from Karim Belabas, corresponds to GP nfeltdivrem()
\\ https://pari.math.u-bordeaux.fr/archives/pari-users-2511/msg00054.html
\\
gimod(w, z) = my(q = round(w / z)); w - q*z;
gidivrem(w,z) = my(q = round(w / z)); [q, w - q*z];
@Hermann-SW
Hermann-SW / F4.gp
Last active November 16, 2025 17:43
verify that 𝔽₄ = ({0,1,a,b}, matrix +, matrix *) is a field
\\ verify that 𝔽₄ = ({0,1,a,b}, matrix +, matrix *) is a field
\\
assert(b,s="")={if(!(b),error(Str(s)))};
F4 = { [[0,0; \\ 0
0,0],
[1,0; \\ 1
0,1],
[0,1; \\ a
1,1],