Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,15 @@
public static double nthroot(int n, double x) {
assert (n > 1 && x > 0);
int np = n - 1;
double g1 = x;
double g2 = iter(g1, np, n, x);
while (g1 != g2) {
g1 = iter(g1, np, n, x);
g2 = iter(iter(g2, np, n, x), np, n, x);
}
return g1;
}
private static double iter(double g, int np, int n, double x) {
return (np * g + x / Math.pow(g, np)) / n;
}