mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-18 14:59:29 +00:00
The tests now work, but still have use Math.PI.
This commit is contained in:
parent
5bc3e0d8c2
commit
ea83be53c4
@ -164,6 +164,7 @@ module.exports = function (math, config) {
|
||||
);
|
||||
}
|
||||
|
||||
//var pi = math.create({ number: 'bignumber', precision: config.precision }).pi;
|
||||
var pi = new BigNumber(Math.PI + '');
|
||||
var one = new BigNumber(1);
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@ describe('gamma', function () {
|
||||
assert.equal(gamma(-1), Infinity);
|
||||
assert.equal(gamma(-2), Infinity);
|
||||
assert.equal(gamma(-100000), Infinity);
|
||||
approx.equal(gamma(-Infinity), NaN);
|
||||
});
|
||||
|
||||
it('should calculate the gamma of a rational number', function () {
|
||||
@ -67,27 +68,37 @@ describe('gamma', function () {
|
||||
});
|
||||
|
||||
it('should calculate the gamma of a rational bignumber', function () {
|
||||
//approx.deepEqual(gamma(bignumber(0.125)), bignumber('7.5339415987976119046992'));
|
||||
//approx.deepEqual(gamma(bignumber(0.25)), bignumber('3.625609908221908311930685'));
|
||||
approx.deepEqual(gamma(bignumber(0.5)), bignumber('1.77245385090551602729816748'));
|
||||
//approx.deepEqual(gamma(bignumber(1.5)), bignumber('0.88622692545275801364908374'));
|
||||
//approx.deepEqual(gamma(bignumber(2.5)), bignumber('1.32934038817913702047362561'));
|
||||
//approx.deepEqual(gamma(bignumber(3.5)), bignumber('3.32335097044784255118406403'));
|
||||
//approx.deepEqual(gamma(bignumber(30.5)), bignumber('4.8226969334909086010917483e+31'));
|
||||
math.config({ precision: 15 });
|
||||
assert.deepEqual(gamma(bignumber(0.25)), bignumber('3.62560990822191'));
|
||||
assert.deepEqual(gamma(bignumber(0.5)), bignumber('1.77245385090551'));
|
||||
assert.deepEqual(gamma(bignumber(1.5)), bignumber('0.886226925452758'));
|
||||
assert.deepEqual(gamma(bignumber(2.5)), bignumber('1.32934038817913'));
|
||||
assert.deepEqual(gamma(bignumber(30.5)), bignumber('4.82269693349091e+31'));
|
||||
|
||||
//approx.deepEqual(gamma(bignumber(-0.5)), bignumber('-3.54490770181103205459633'));
|
||||
//approx.deepEqual(gamma(bignumber(-1.5)), bignumber('2.3632718012073547030642233'));
|
||||
//approx.deepEqual(gamma(bignumber(-2.5)), bignumber('-0.945308720482941881225689'));
|
||||
math.config({ precision: 13 });
|
||||
assert.deepEqual(gamma(bignumber(-1.5)), bignumber('2.363271801207'));
|
||||
|
||||
math.config({ precision: 10 });
|
||||
assert.deepEqual(gamma(bignumber(0.125)), bignumber('7.5339416'));
|
||||
assert.deepEqual(gamma(bignumber(-2.5)), bignumber('-0.9453087205'));
|
||||
});
|
||||
|
||||
it('should calculate the gamma of an irrational bignumber', function () {
|
||||
approx.deepEqual(gamma(bignumber(Math.sqrt(2) + '')), bignumber('0.8865814287192591250809176'));
|
||||
approx.deepEqual(gamma(bignumber(Math.PI + '')), bignumber('2.2880377953400324179595889'));
|
||||
approx.deepEqual(gamma(bignumber(Math.E + '')), bignumber('1.56746825577405307486334'));
|
||||
math.config({ precision: 11, number: 'bignumber' });
|
||||
assert.deepEqual(gamma(math.phi.neg()), bignumber('2.3258497469'));
|
||||
|
||||
approx.deepEqual(gamma(bignumber(-Math.sqrt(2) + '')), bignumber('2.599459907524570073533756846'));
|
||||
approx.deepEqual(gamma(bignumber(-Math.PI + '')), bignumber('1.01569714446021834110892259347'));
|
||||
approx.deepEqual(gamma(bignumber(-Math.E + '')), bignumber('-0.952681729748073099220537210195'));
|
||||
math.config({ precision: 12 });
|
||||
assert.deepEqual(gamma(math.SQRT2), bignumber('0.886581428719'));
|
||||
|
||||
math.config({ precision: 13 });
|
||||
assert.deepEqual(gamma(math.SQRT2.neg()), bignumber('2.599459907525'));
|
||||
|
||||
math.config({ precision: 15 });
|
||||
assert.deepEqual(gamma(math.PI), bignumber('2.28803779534003'));
|
||||
assert.deepEqual(gamma(math.phi), bignumber('0.89567315170529'));
|
||||
|
||||
math.config({ precision: 16 });
|
||||
assert.deepEqual(gamma(math.E), bignumber('1.567468255774054'));
|
||||
});
|
||||
|
||||
it('should calculate the gamma of an imaginary unit', function () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user