How to use the mathjs.bignumber function in mathjs

To help you get started, we’ve selected a few mathjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github KyberNetwork / smart-contracts / test / helper.js View on Github external
module.exports.exp = function(num1,num2) {
    const num1Math = Math.bignumber(new BigNumber(num1).toString(10));
    const num2Math = Math.bignumber(new BigNumber(num2).toString(10));

    const result = Math.pow(num1Math,num2Math);

    return new BigNumber(result.toString());
};
github hashgraph / hedera-mirror-node / hedera-mirror-rest / monitoring / monitor_apis / balance_tests.js View on Github external
if (undefined === balances) {
    var message = `balances is undefined`;
    currentTestResult.failureMessages.push(message);
    acctestutils.addTestResult(classResults, currentTestResult, false);
    return;
  }

  if (balances.length !== 1) {
    var message = `balances.length of ${balances.length} was expected to be 1`;
    currentTestResult.failureMessages.push(message);
    acctestutils.addTestResult(classResults, currentTestResult, false);
    return;
  }

  let plusOne = math.add(math.bignumber(balancesResponse.timestamp), math.bignumber(1));
  let minusOne = math.subtract(math.bignumber(balancesResponse.timestamp), math.bignumber(1));
  let paq = `${balancesPath}?timestamp=gt:${minusOne.toString()}` + `&timestamp=lt:${plusOne.toString()}&limit=1`;

  url = acctestutils.getUrl(server, paq);
  currentTestResult.url = url;
  balances = await getBalances(url, currentTestResult);

  if (undefined === balances) {
    var message = `balances is undefined`;
    currentTestResult.failureMessages.push(message);
    acctestutils.addTestResult(classResults, currentTestResult, false);
    return;
  }

  if (balances.length !== 1) {
    var message = `balances.length of ${balances.length} was expected to be 1`;
    currentTestResult.failureMessages.push(message);
github NeoNextClub / neoline / src / app / core / services / global.service.ts View on Github external
public mathmul(a: number, b: number): number {
        return parseFloat(multiply(bignumber(a), bignumber(b)).toString());
    }
    public mathDiv(a: number, b: number): number {
github blocknetdx / block-dx / index.js View on Github external
  const calculateBackupTotal = (price, size) => math.round(math.multiply(math.bignumber(price), math.bignumber(size)), 6).toNumber().toFixed(6);
github devalpha-io / devalpha-node / lib / reducers / util.js View on Github external
export function buildSharpeRatio(returns) {
  const DAILY = 252
  const WEEKLY = 52
  const MONTLY = 12

  const riskFreeReturn = 0
  const riskAdjusted = math.subtract(b(returns), b(riskFreeReturn))

  const meanReturn = math.mean(b(riskAdjusted))
  const standardDeviation = math.std(b(riskAdjusted))
  const annualizationFactor = math.sqrt(b(DAILY))

  return n(chain(b(meanReturn))
    .divide(b(standardDeviation)).multiply(b(annualizationFactor)).done()
  )
}
github devalpha-io / devalpha-node / lib / reducers / util.js View on Github external
export function buildSharpeRatio(returns) {
  const DAILY = 252
  const WEEKLY = 52
  const MONTLY = 12

  const riskFreeReturn = 0
  const riskAdjusted = math.subtract(b(returns), b(riskFreeReturn))

  const meanReturn = math.mean(b(riskAdjusted))
  const standardDeviation = math.std(b(riskAdjusted))
  const annualizationFactor = math.sqrt(b(DAILY))

  return n(chain(b(meanReturn))
    .divide(b(standardDeviation)).multiply(b(annualizationFactor)).done()
  )
}
github antoniodeluca / dn2a / assets / networks / alpha.js View on Github external
function(
                                synapse,
                                synapseIndex,
                                synapses
                            ) {
                                synapse.previousWeightChange = synapse.weightChange;
                                synapse.weightChange = add(
                                    multiply(
                                        bignumber(learningRate),
                                        multiply(
                                            layerNeuron.delta,
                                            synapse.incomingConnection.output
                                        )
                                    ),
                                    multiply(
                                        bignumber(momentumRate),
                                        synapse.previousWeightChange
                                    )
                                );
                                synapse.previousWeight = synapse.weight;
                                synapse.weight = add(
                                    synapse.weight,
                                    synapse.weightChange
                                );
                            }

mathjs

Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with dif

Apache-2.0
Latest version published 8 days ago

Package Health Score

92 / 100
Full package analysis