Posts
Author Archives: Linuxgal
M6 – Math
Today is piday Here’s a bash script I saved as “pi” somewhere in $PATH #!/bin/bash echo “scale=$1;a(1)*4” | bc -l I demonstrate it this way: $ for i in {1..20}; do pi $i; done 2.8 3.12 3.140 3.1412 3.14156 3.141592 … Continue reading
Posted in Uncategorized
Leave a comment
M5 – Math
π calculation using a Machin-like arctangent formula #!/usr/bin/python3 from decimal import Decimal, getcontext import sys digits = int(sys.argv[1]) if len(sys.argv) > 1 else 50 getcontext().prec = digits + 5 # a few extra digits to avoid rounding errors def arctan(x): … Continue reading
Posted in Uncategorized
Leave a comment