Socket
Socket
Sign inDemoInstall

calculess

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    calculess

calculus, but less


Version published
Weekly downloads
8
increased by100%
Maintainers
1
Install size
8.53 kB
Created
Weekly downloads
 

Readme

Source

Calculess.js

A calculus library for javascript and NPM. Created by Blake Sanie.

Install

$ npm install calculess

Getting Started

Import package and create Calc object for future use

var Calculess = require('calculess');
var Calc = Calculess.prototype;

Documentation

Limits

Evaluate a limit

Calc.limAt( x , function );

Evaluate a limit from the left

Calc.limLeftOf( x , function );

Evaluate a limit from the right

Calc.limRightOf( x , function );

Methods:

  • Accept ±Infinity as x value (parameter)
  • Can output ±Infinity
  • Output NaN when the limit does not exist

Examples:

function recip(x) {
    return 1 / x;
}

Calc.limLeftOf(0, recip); // -Infinity
Calc.limRightOf(0, recip); // Infinity
Calc.limAt(0, recip); // NaN
Calc.limAt(1, recip); // 1

Derivatives

Evaluate f'(x)

  • Note: If the given function is not continuous or differentiable at the target, NaN is returned
Calc.deriv( x , function );

Evaluate a derivative to the nth degree of x

  • Note: as the degree increases, .nthDeriv() becomes less accurate. Also, continuity and differentiability are not checked.
Calc.nthDeriv( degree, x , function );

Examples:

function para(x) {
    return x * x;
}

Calc.deriv(3, para); // 6
Calc.nthDeriv(2, 3, para); // 2
Calc.nthDeriv(3, 3, para); // 0

function sharp(x) {
    return Math.abs(x);
}

Calc.deriv(1, sharp); // 1
Calc.nthDeriv(2, 1, para); // 0
Calc.deriv(0, sharp); // NaN

Integrals

Evaluate an integral using trapezoidal Riemann Sums

Calc.integral( start , end , function , numSubintervals );

Evaluate a function's average value

Calc.averageValue( start , end , function , numSubintervals );

Note: As the number of subintervals increases, .intregral() becomes more accurate, though more time is required for calculations

Examples
function sin(x) {
    return Math.sin(x);
}

Calc.integral(0, Math.PI, sin, 5); // 1.9337655980928052
Calc.integral(0, Math.PI, sin, 10); // 1.9835235375094546
Calc.integral(0, Math.PI, sin, 100); // 1.999835503887445
Calc.integral(0, Math.PI, sin, 1000); // 1.9999983550656886
Calc.integral(0, Math.PI, sin, 10000); // 1.999999983550358

Keywords

FAQs

Last updated on 22 Aug 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc