Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Retrieve data from Horizons using a batch-file | |
Written by PM 2Ring 2021.12.27 | |
""" | |
import re, requests | |
url = "https://ssd.jpl.nasa.gov/api/horizons_file.api" | |
pat = re.compile(r"(?:[^'\s]|'[^']*')+") | |
@interact | |
def go(batch=InputBox(width=40, height=24)): | |
if not batch: return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Format preserving encryption using a Feistel network | |
See https://stackoverflow.com/a/51429458/4014959 | |
Written by PM 2Ring 2016.08.22 | |
Version using Blake2 hashing 2021.06.14 | |
Added pair permutation 2024.01.17 | |
""" | |
from hashlib import blake2s as blake | |
from random import Random |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Chromostereopsis illusion | |
With generated blue noise dither (void & cluster), | |
Poisson disk, white noise, checks, and undithered. | |
See https://mathematica.stackexchange.com/q/289992 | |
""" | |
import numpy as np | |
from scipy import ndimage | |
from sage.repl.image import Image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Plot filled ellipse in 3D. | |
With major axis and line of nodes | |
Written by PM 2Ring 2023.9.24 | |
""" | |
var('th') | |
deg = n(pi / 180) | |
def ellipse(a, ec): |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Gauss / Salamin / Brent true AGM pi | |
Binary fixed point | |
Written by PM 2Ring 2023.11.1 | |
""" | |
from math import isqrt | |
def AGM_pi(loops, bits): | |
a, b = 1 << bits, isqrt(1 << 2*bits-1) | |
s = 1 << bits-2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" pi from 10 * asin((phi-1)/2) | |
Uses Carlson's accelerated version of | |
Borchardt's modified AGM algorithm | |
Written by PM 2Ring 2022.05.11 | |
""" | |
from itertools import count | |
from decimal import Decimal as D, getcontext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" BBerg32 | |
Primality test for 32 bit integers using a single SPRP test. | |
The SPRP base comes from a hash table. | |
Hash and bases by Bradley Berg | |
See https://techneon.com/download/is.prime.32.base.data | |
""" | |
bases = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Deterministic Miller-Rabin primality test | |
See https://en.m.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test | |
and https://miller-rabin.appspot.com/ | |
Written by PM 2Ring 2015.04.29 | |
Updated 2022.04.20 | |
""" | |
small_primes = [ |
NewerOlder