code: public static BigDecimal sqrtUsingNewtonPrint(BigDecimal x, MathContext mathContext) {
  		switch (x.signum()) {
  		case 0:
  			return ZERO;
  		case -1:
  			throw new ArithmeticException("Illegal sqrt(x) for x < 0: x = " + x);
  		}
  
  		MathContext mc = new MathContext(mathContext.getPrecision() + 4, mathContext.getRoundingMode());
  		BigDecimal acceptableError = ONE.movePointLeft(mathContext.getPrecision() + 1);
  
  		BigDecimal result = BigDecimal.valueOf(Math.sqrt(x.doubleValue()));
  		BigDecimal last;
  
  		do {
  			last = result;
  			result = x.divide(result, mc).add(last).divide(TWO, mc);
  			System.out.printf("%5d, ", countSameCharacters(last.toPlainString(), result.toPlainString()));
  		} while (result.subtract(last).abs().compareTo(acceptableError) > 0);
  		
  		return result.round(mathContext);
  	}
docs: variations on sqrt()