• Preparing search index...
  • The search index is not available
emath.js
  • emath.js
  • classes/numericalAnalysis/sum
  • calculateSum

Function calculateSum

  • calculateSum(f, b, a?, epsilon?, iterations?): Decimal
  • Calculates the sum of f(n) from a to b using either the trapezoidal rule or a basic loop depending on the size of b - a.

    Parameters

    • f: ((n: Decimal) => Decimal)

      The function f(n) to calculate the sum.

        • (n): Decimal
        • Parameters

          • n: Decimal

          Returns Decimal

    • b: DecimalSource

      The upper limit for the sum.

    • a: DecimalSource = 0

      The lower limit for the sum. Defaults to 0. The order is reversed because a is optional. Deal with it.

    • Optionalepsilon: DecimalSource

      The maximum error tolerance, geometrically. Defaults to DEFAULT_TOLERANCE. Only used if b - a is less than or equal to DEFAULT_ITERATIONS.

    • Optionaliterations: number

      The amount of iterations to perform. Defaults to DEFAULT_ITERATIONS. Only used if b - a is greater than DEFAULT_ITERATIONS.

    Returns Decimal

    • The calculated sum of f(n), as a Decimal.

    Example

    const f = (x) => x.pow(2);
    const sum = calculateSum(f, 10);
    console.log(sum); // ~385
    • Defined in classes/numericalAnalysis/sum.ts:162

Settings

Member Visibility
emath.js
  • Loading...

Generated using TypeDoc