From 3e52a9d645b7e1f0c67639ae26dcf6cede0b8547 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; } }); }