blog.darkstar.work - a simple url encoder/decoder

 a simple url encoder/decoder
 http://blog.darkstar.work

Labels

Wirtschaft (152) Pressefreiheit (131) Österreich (123) IT (98) code (62) Staatsschulden (37) EZB (27) Pensionssystem (16)

2023-12-09

¼ π

¼ π = arctan(1) = arctan(45°) ✓

mathematical proof still required for:
¼ π = 1 - ⅓ + ⅕ - ¹/₇ + ¹/₉ - ¹/₁₁ + (1/13) - ...
¼ π = (n=0;n→∞)∑ (-1)ⁿ / (2n + 1)
better way to approximate π is to add iteration m=n-1 and iteration n and double it.

pi.c

a computing approach in simple ansi c:
#include <stdlib.h> #include <stdint.h> #include <stdio.h> #include <math.h> int main(int argc, char **argv) { long l = 0, loopmax = (argc > 1) ? atol(argv[1]) : 32;
double m = 0, n = 0, pi = 0;
for (l = 0; l < (INT16_MAX * loopmax); l++) {
m = n; n += (pow((-1), l) / (2*l + 1)); } pi = 2 * (m + n); printf("loops \t: %ld\npi \t= %.16f\n", l, pi);
printf("pi_m \t= %.16f\npi_n \t= %.16f\n", (4*m), (4*n));
return 0; }     

compilation & linkage

gcc -o pi pi.c -lm; time ./pi; time ./pi 256
gcc -o pi pi.c -lm; time ./pi; time ./pi 256

[ to be continued  ... ]

Keine Kommentare:

Kommentar veröffentlichen