From ea648b38e751a3a9f9731d3b3e96889fdffffd10 Mon Sep 17 00:00:00 2001 From: Arthur Drobot Date: Thu, 27 Jul 2017 10:16:38 -0700 Subject: [PATCH] Modify exp to work properly with the new changes and support all reals. --- src/org/nwapw/abacus/plugin/StandardPlugin.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/org/nwapw/abacus/plugin/StandardPlugin.java b/src/org/nwapw/abacus/plugin/StandardPlugin.java index ac4eb76..694fcda 100755 --- a/src/org/nwapw/abacus/plugin/StandardPlugin.java +++ b/src/org/nwapw/abacus/plugin/StandardPlugin.java @@ -4,6 +4,7 @@ import org.nwapw.abacus.function.Function; import org.nwapw.abacus.number.NaiveNumber; import org.nwapw.abacus.number.NumberInterface; +import javax.print.attribute.standard.MediaSize; import java.util.function.BiFunction; /** @@ -116,7 +117,13 @@ public class StandardPlugin extends Plugin { @Override protected NumberInterface applyInternal(NumberInterface[] params) { - return sumSeries(params[0], StandardPlugin.this::getExpSeriesTerm, getNTermsExp(getMaxError(params[0]), params[0])); + boolean takeReciprocal = params[0].signum() == -1; + params[0] = StandardPlugin.this.getFunction("abs").apply(params[0]); + NumberInterface sum = sumSeries(params[0], StandardPlugin.this::getExpSeriesTerm, getNTermsExp(getMaxError(params[0]), params[0])); + if(takeReciprocal){ + sum = NaiveNumber.ONE.promoteTo(sum.getClass()).divide(sum); + } + return sum; } }); }