List of utility methods to do BigDecimal Square Root
BigDecimal | sqrtProcedure(MathContext mc, int digits, BigDecimal numberToBeSquareRooted, BigDecimal iteration1, BigDecimal iteration2, BigDecimal temp1, BigDecimal temp2) Square root by coupled Newton iteration, sqrtProcedure() is the iteration part I adopted the Algorithm from the book "Pi-unleashed", so now it looks more natural I give sparse math comments from the book, it assumes argument mc precision >= 1 temp1 = BigDecimal.ONE.subtract(TWO.multiply(iteration1, mc).multiply(iteration2, mc), mc); iteration2 = iteration2.add(temp1.multiply(iteration2, mc), mc); temp2 = numberToBeSquareRooted.subtract(iteration1.multiply(iteration1, mc), mc); iteration1 = iteration1.add(temp2.multiply(iteration2, mc), mc); int m = mc.getPrecision(); if (m < 2) m++; else ... |