September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -1,25 +1,23 @@
/*
* Arithmetic-Geometric Mean of 1 & 1/sqrt(2)
* Brendan Shaklovitz
* 5/29/12
*/
public class ArithmeticGeometricMean {
Arithmetic-Geometric Mean of 1 & 1/sqrt(2)
Brendan Shaklovitz
5/29/12
*/
public class ArithmeticMean {
public static void agm (double a, double g){
double a1 = a;
double g1 = g;
while (Math.abs(a1-g1) >= Math.pow(10, -14)){
double aTemp = (a1+g1)/2.0;
g1 = Math.sqrt(a1*g1);
a1 = aTemp;
}
System.out.println(a1);
public static double agm(double a, double g) {
double a1 = a;
double g1 = g;
while (Math.abs(a1 - g1) >= 1.0e-14) {
double arith = (a1 + g1) / 2.0;
double geom = Math.sqrt(a1 * g1);
a1 = arith;
g1 = geom;
}
return a1;
}
public static void main(String[] args){
agm(1,1/Math.sqrt(2));
}
public static void main(String[] args) {
System.out.println(agm(1.0, 1.0 / Math.sqrt(2.0)));
}
}