From bd39ed4133d7c63b9a5e8804659e356f8e67b8e1 Mon Sep 17 00:00:00 2001 From: Theodore Kruczek Date: Tue, 16 Jan 2024 22:03:27 -0500 Subject: [PATCH] refactor: :fire: move derivative function to ootk --- src/utils/functions.ts | 22 +--------------------- test/utils/functions.test.ts | 6 ------ 2 files changed, 1 insertion(+), 27 deletions(-) diff --git a/src/utils/functions.ts b/src/utils/functions.ts index 2f22ba0..a5bc793 100644 --- a/src/utils/functions.ts +++ b/src/utils/functions.ts @@ -1,7 +1,7 @@ /* eslint-disable require-jsdoc */ import { AngularDiameterMethod } from '../enums/AngularDiameterMethod'; import { AngularDistanceMethod } from '../enums/AngularDistanceMethod'; -import { DifferentiableFunction, EcfVec3, Kilometers, Radians, SpaceObjectType } from '../types/types'; +import { EcfVec3, Kilometers, Radians, SpaceObjectType } from '../types/types'; import { angularVelocityOfEarth, cKmPerSec } from './constants'; /** @@ -299,26 +299,6 @@ export function covariance(a: number[], b: number[], isSample = false): number { return result / (n - m); } -/** - * Calculates the derivative of a differentiable function. - * @param f The differentiable function. - * @param h The step size for numerical differentiation. Default value is 1e-3. - * @returns The derivative function. - */ -export function derivative(f: DifferentiableFunction, h = 1e-3): DifferentiableFunction { - /** - * @param x The value at which to calculate the derivative. - * @returns The derivative of the function at the given value. - */ - function df(x: number): number { - const hh = h * 0.5; - - return (f(x + hh) - f(x - hh)) / h; - } - - return df; -} - /** * Calculates the gamma function of a number. * @param n - The input number. diff --git a/test/utils/functions.test.ts b/test/utils/functions.test.ts index 0faa97e..c7e0188 100644 --- a/test/utils/functions.test.ts +++ b/test/utils/functions.test.ts @@ -12,7 +12,6 @@ import { createVec, csch, deg2rad, - derivative, gamma, linearInterpolate, log10, @@ -103,11 +102,6 @@ describe('functions', () => { expect(gamma(1)).toMatchSnapshot(); }); - // derivative - it('should be calculate derivative', () => { - expect(derivative((x: number) => x * x, 1)).toMatchSnapshot(); - }); - // covariance it('should be calculate covariance', () => { expect(covariance([1, 2, 3], [1, 2, 3])).toMatchSnapshot();