use of com.revolsys.geometry.math.DD in project com.revolsys.open by revolsys.
the class DDBasicTest method testAddMult2.
public void testAddMult2() {
checkAddMult2(new DD(3));
checkAddMult2(DD.PI);
}
use of com.revolsys.geometry.math.DD in project com.revolsys.open by revolsys.
the class DDComputeTest method testPiByMachin.
public void testPiByMachin() {
// System.out.println("--------------------------------");
// System.out.println("Computing Pi by Machin's rule");
final DD testE = computePiByMachin();
final double err = Math.abs(testE.subtract(DD.PI).doubleValue());
// System.out.println("Difference from DoubleDouble.PI = " + err);
assertTrue(err < 8 * DD.EPS);
}
use of com.revolsys.geometry.math.DD in project com.revolsys.open by revolsys.
the class DDComputeTest method computeEByTaylorSeries.
/**
* Uses Taylor series to compute e
*
* e = 1 + 1 + 1/2! + 1/3! + 1/4! + ...
*
* @return an approximation to e
*/
private DD computeEByTaylorSeries() {
DD s = DD.valueOf(2.0);
DD t = DD.valueOf(1.0);
double n = 1.0;
int i = 0;
while (t.doubleValue() > DD.EPS) {
i++;
n += 1.0;
t = t.divide(DD.valueOf(n));
s = s.add(t);
// System.out.println(i + ": " + s);
}
return s;
}
use of com.revolsys.geometry.math.DD in project com.revolsys.open by revolsys.
the class DDComputeTest method testEByTaylorSeries.
public void testEByTaylorSeries() {
// System.out.println("--------------------------------");
// System.out.println("Computing e by Taylor series");
final DD testE = computeEByTaylorSeries();
final double err = Math.abs(testE.subtract(DD.E).doubleValue());
// System.out.println("Difference from DoubleDouble.E = " + err);
assertTrue(err < 64 * DD.EPS);
}
Aggregations