From e08c4aadc28be3eec1b89921ad42cce41355ae89 Mon Sep 17 00:00:00 2001 From: Lumi Pakkanen Date: Thu, 28 Dec 2023 11:10:12 +0200 Subject: [PATCH] Fix typo "radicant" -> "radicand" --- src/__tests__/approximation.spec.ts | 8 ++++---- src/approximation.ts | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/__tests__/approximation.spec.ts b/src/__tests__/approximation.spec.ts index c3e6a4c..fd65f25 100644 --- a/src/__tests__/approximation.spec.ts +++ b/src/__tests__/approximation.spec.ts @@ -130,14 +130,14 @@ describe('Convergent calculator', () => { describe('Radical approximator', () => { it("finds Ramanujan's approximation to pi", () => { - const {index, radicant} = approximateRadical(Math.PI); + const {index, radicand} = approximateRadical(Math.PI); expect(index).toBe(4); - expect(radicant.toFraction()).toBe('2143/22'); + expect(radicand.toFraction()).toBe('2143/22'); }); it('works with a random value without crashing', () => { const value = Math.random() * 1000 - 100; - const {index, radicant} = approximateRadical(value); - expect(radicant.valueOf() ** (1 / index) / value).toBeCloseTo(1); + const {index, radicand} = approximateRadical(value); + expect(radicand.valueOf() ** (1 / index) / value).toBeCloseTo(1); }); }); diff --git a/src/approximation.ts b/src/approximation.ts index a9737f4..a43fbd1 100644 --- a/src/approximation.ts +++ b/src/approximation.ts @@ -311,8 +311,8 @@ export function continuedFraction(value: number) { * Approximate a value with a radical expression. * @param value Value to approximate. * @param maxIndex Maximum index of the radical. 2 means square root, 3 means cube root, etc. - * @param maxHeight Maximum Benedetti height of the radicant in the approximation. - * @returns Object with index of the radical and the radicant. Result is "index'th root or radicant". + * @param maxHeight Maximum Benedetti height of the radicand in the approximation. + * @returns Object with index of the radical and the radicand. Result is "index'th root or radicand". */ export function approximateRadical( value: number, @@ -320,7 +320,7 @@ export function approximateRadical( maxHeight = 50000 ) { let index = 1; - let radicant = new Fraction(1); + let radicand = new Fraction(1); let bestError = Math.abs(value - 1); for (let i = 1; i <= maxIndex; ++i) { const cf = continuedFraction(value ** i); @@ -339,11 +339,11 @@ export function approximateRadical( const error = Math.abs(candidate.valueOf() ** (1 / i) - value); if (error < bestError) { index = i; - radicant = candidate; + radicand = candidate; bestError = error; } } } - return {index, radicant}; + return {index, radicand}; }