Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,9 @@
def naive_agm(a; g; tolerance):
def abs: if . < 0 then -. else . end;
def _agm:
# state [an,gn]
if ((.[0] - .[1])|abs) > tolerance
then [add/2, ((.[0] * .[1])|sqrt)] | _agm
else .
end;
[a, g] | _agm | .[0] ;

View file

@ -0,0 +1,16 @@
def agm(a; g; tolerance):
def abs: if . < 0 then -. else . end;
def _agm:
# state [an,gn, delta]
((.[0] - .[1])|abs) as $delta
| if $delta == .[2] and $delta < 10e-16 then .
elif $delta > tolerance
then [ .[0:2]|add / 2, ((.[0] * .[1])|sqrt), $delta] | _agm
else .
end;
if tolerance <= 0 then error("specified tolerance must be > 0")
else [a, g, 0] | _agm | .[0]
end ;
# Example:
agm(1; 1/(2|sqrt); 1e-100)