From 6b6ae1383ca8cd75eddaaa7dc8e607ca07b6bf84 Mon Sep 17 00:00:00 2001 From: jos Date: Wed, 15 May 2019 10:54:02 +0200 Subject: [PATCH] Dropped fake BigNumber support from function `erf` --- HISTORY.md | 1 + src/function/special/erf.js | 7 ------ test/function/special/erf.test.js | 38 ------------------------------- 3 files changed, 1 insertion(+), 45 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 1cc568eba..28779f2de 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -87,6 +87,7 @@ `math.Unit` and `math.Parser` respectively. - Fixed #1428: transform iterating over replaced nodes. New behavior is that it stops iterating when a node is replaced. +- Dropped fake BigNumber support of function `erf`. - Removed all index.js files used to load specific functions instead of all, like: ``` diff --git a/src/function/special/erf.js b/src/function/special/erf.js index ef7d0664e..0ce29124c 100644 --- a/src/function/special/erf.js +++ b/src/function/special/erf.js @@ -50,13 +50,6 @@ export const createErf = /* #__PURE__ */ factory(name, dependencies, ({ typed }) return sign(x) * (1 - erfc3(y)) }, - // TODO: Not sure if there's a way to guarantee some degree of accuracy here. - // Perhaps it would be best to set the precision of the number to that which - // is guaranteed by erf() - 'BigNumber': function (n) { - return new n.constructor(erf(n.toNumber())) - }, - 'Array | Matrix': function (n) { return deepMap(n, erf) } diff --git a/test/function/special/erf.test.js b/test/function/special/erf.test.js index b82eb145e..464d8fc93 100644 --- a/test/function/special/erf.test.js +++ b/test/function/special/erf.test.js @@ -1,10 +1,6 @@ import assert from 'assert' import math from '../../../src/bundleAny' import actualErfValues from './erf.values.json' -const bignumber = math.bignumber -const subtract = math.subtract -const abs = math.abs -const smaller = math.smaller const erf = math.erf const DIFF_THRESH = 5e-16 @@ -58,40 +54,6 @@ describe('erf', function () { assert.ok(Math.abs(erf(-3) - actualErfValues['-3.0']) < DIFF_THRESH) }) - it('should calculate the erf of a rational bignumber', function () { - assert.ok(smaller( - abs(subtract(erf(bignumber(0.1)), bignumber(actualErfValues['0.1']))), - DIFF_THRESH - )) - assert.ok(smaller( - abs(subtract(erf(bignumber(0.2)), bignumber(actualErfValues['0.2']))), - DIFF_THRESH - )) - assert.ok(smaller( - abs(subtract(erf(bignumber(0.3)), bignumber(actualErfValues['0.3']))), - DIFF_THRESH - )) - assert.ok(smaller( - abs(subtract(erf(bignumber(1.5)), bignumber(actualErfValues['1.5']))), - DIFF_THRESH - )) - assert.ok(smaller( - abs(subtract(erf(bignumber(2.5)), bignumber(actualErfValues['2.5']))), - DIFF_THRESH - )) - - const bigmath = math.create({ precision: 15 }) - assert.ok(smaller( - abs(subtract(bigmath.erf(bignumber(-1.5)), bigmath.bignumber(actualErfValues['-1.5']))), - DIFF_THRESH - )) - bigmath.config({ precision: 13 }) - assert.ok(smaller( - abs(subtract(bigmath.erf(bignumber(-1.5)), bigmath.bignumber(actualErfValues['-1.5']))), - DIFF_THRESH - )) - }) - it('should calculate the erf of a boolean (true = 1, false = 0)', function () { assert.ok(Math.abs(erf(true) - actualErfValues['1.0']) < DIFF_THRESH) assert.ok(Math.abs(erf(false) - actualErfValues['0.0']) < DIFF_THRESH)