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
(0, 1) : 50 | |
(1, 0) : 50 | |
(0, 2) : 258 | |
(1, 1) : 600 | |
(2, 0) : 258 | |
(0, 3) : 186 | |
(1, 2) : 1086 | |
(2, 1) : 1086 | |
(3, 0) : 186 | |
(0, 4) : 5 |
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
#!/usr/bin/env python3 | |
''' Create a closed track from cubic Bezier curves, and animate a circle | |
following the track at constant speed. | |
https://en.wikipedia.org/wiki/B%C3%A9zier_curve#Cubic_B%C3%A9zier_curves | |
https://gist.github.com/PM2Ring/d6a19f5062b39467ac669a4fb4715779 | |
Press the Add button to add black control dots to the Canvas. The first |
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
#! /usr/bin/env python3 | |
''' Demonstrate the PIL .fromarray bitmap bug | |
PIL's Image.fromarray function has a bug with mode '1' images | |
See | |
https://stackoverflow.com/questions/2761645/error-converting-pil-bw-images-to-numpy-arrays | |
Written by PM 2Ring 2017.06.26 |
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
""" Julian day number to date conversion | |
Proleptic Gregorian and Julian, with Astronomical years | |
i.e., 1 AD = year 1, 1 BC = year 0, 2 BC = year -1, etc | |
Derived from RG Tantzen (1963), ACM. | |
Algorithm 199: conversions between calendar date and Julian day number. | |
https://en.wikipedia.org/wiki/Julian_day | |
Julian day number 0 assigned to the day starting at noon on | |
January 1, 4713 BC, proleptic Julian calendar |
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
""" Maxwell–Boltzmann distribution | |
See https://en.m.wikipedia.org/wiki/Maxwell%E2%80%93Boltzmann_distribution | |
Written by PM 2Ring 2021.06.20 | |
""" | |
# Gas constant g⋅m^2⋅s^−2⋅K^−1⋅mol^−1 | |
R = 8314.46261815324 | |
@interact | |
def _(T=('temp (°C)', 20), mass=('mass (g/mol)', 29), | |
auto_update=False): |
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
""" Lorenz attractor | |
From https://en.wikipedia.org/wiki/Lorenz_system | |
Modified for Sagemath by PM 2Ring 2023.01.04 | |
""" | |
import numpy as np | |
from scipy.integrate import odeint | |
# Build Bezier curves |
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
""" Borwein + Borwein quadratic pi | |
Algorithm 2.1 from "Pi and the AGM" (Wiley, 1987) | |
Written by PM 2Ring 2023.1.2 | |
""" | |
from math import floor, log, pi | |
from decimal import Decimal as D, getcontext | |
def borwein_pi(loops): | |
x = D(2).sqrt() |
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
Standard Solar Model (BP2004) | |
https://www.sns.ias.edu/~jnb/SNdata/Export/BP2004/bp2004stdmodel.dat | |
astro-ph/0402114 | |
Columns in the Standard Model table (below) represent: | |
1) Mass fraction in units of the solar mass | |
2) Radius of the zone in units of one solar radius | |
3) Temperature in units of deg (K) | |
4) Density in units of g/cm^3 |
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
#! /usr/bin/env python3 | |
''' Generalization of the 'Fitch' Cheney card trick | |
Written by PM 2Ring 2003.02.13 | |
Converted to Python 2018.06.27 | |
''' | |
import sys | |
import readline |