code: public static BigDecimal log(BigDecimal x, MathContext mathContext) {
  		checkMathContext(mathContext);
  		if (x.signum() <= 0) {
  			throw new ArithmeticException("Illegal log(x) for x <= 0: x = " + x);
  		}
  		if (x.compareTo(ONE) == 0) {
  			return ZERO;
  		}
  		
  		BigDecimal result;
  		switch (x.compareTo(TEN)) {
  		case 0:
  			result = logTen(mathContext);
  			break;
  		case 1:
  			result = logUsingExponent(x, mathContext);
  			break;
  		default :
  			result = logUsingTwoThree(x, mathContext);
  		}
  
  		return round(result, mathContext);
  	}
docs: Calculates the natural logarithm of {@link BigDecimal} x.
  
  <p>See: <a href="http://en.wikipedia.org/wiki/Natural_logarithm">Wikipedia: Natural logarithm</a></p>
  
  @param x the {@link BigDecimal} to calculate the natural logarithm for
  @param mathContext the {@link MathContext} used for the result
  @return the calculated natural logarithm {@link BigDecimal} with the precision specified in the <code>mathContext</code>
  @throws ArithmeticException if x &lt;= 0
  @throws UnsupportedOperationException if the {@link MathContext} has unlimited precision