name:
src/main/js/formulas/math/ACOSH.ts
-rw-r--r--
893
1import { NumException } from "../../errors/NumException";
2import { SheetColumnRowKey } from "../../models/common/SheetColumnRowKey";
3import { Complex } from "../../models/common/Types";
4import { Converters } from "../../utils/Converters";
5import { AbstractFormula } from "../AbstractFormula";
6import { FormulaName } from "../FormulaName";
7
8export class ACOSH extends AbstractFormula {
9 static SELF: ACOSH = new ACOSH();
10 NAME = FormulaName.ACOSH;
11
12 internal(origin: SheetColumnRowKey, ...values: Array<Complex>) {
13 AbstractFormula.checkLength(values.length, 1, this.NAME);
14 const value = Converters.toNumber(Converters.first(this.collateralLookup(origin, values[0])));
15 if (value < 1.0) {
16 return new NumException(
17 "ACOSH parameter 1 value is 0. It should be greater than or equal to 1."
18 );
19 }
20 return Math.log(value + Math.sqrt(value * value - 1));
21 }
22}