/** * Calculates the natural logarithm of {@link BigComplex} x in the complex domain. * * <p>See: <a href="https://en.wikipedia.org/wiki/Complex_logarithm">Wikipedia: Complex logarithm</a></p> * * @param x the {@link BigComplex} to calculate the natural logarithm for * @param mathContext the {@link MathContext} used for the result * @return the calculated natural logarithm {@link BigComplex} with the precision specified in the <code>mathContext</code> */ public static BigComplex log(this BigComplex x, MathContext mathContext) { // https://en.wikipedia.org/wiki/Complex_logarithm MathContext mc1 = new MathContext(mathContext.getPrecision() + 20, mathContext.getRoundingMode()); MathContext mc2 = new MathContext(mathContext.getPrecision() + 5, mathContext.getRoundingMode()); return(BigComplex.valueOf( BigDecimalMath.log(x.abs(mc1), mc1).round(mathContext), x.angle(mc2)).round(mathContext)); }