npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

quadratic-solver

v0.2.4

Published

Quadratic Equation Solver

Downloads

71

Readme

Quadratic Equation Solver

npm Drone Status Travis Status Codecov Dependencies

This JavaScript library-slash-module brings the ability of finding roots of a quadratic equation by simply requiring it :)

Example Usage

Browser Import

<script src="https://unpkg.com/quadratic-solver"></script>
<script>
    console.log(qs.getVersion());
    const rootsArr = qs.quadSolver(2, 5, -3);
    rootsArr.map(root => console.log(`Root: ${root}`));
</script>

NodeJS Module

const { quadSolver, getVersion } = require("quadratic-solver");
console.log(getVersion());
const rootsArr = quadSolver(2, 5, -3);
rootsArr.map(root => console.log(`Root: ${root}`));

Methods

quadSolver(a, b, c)

Arguments

  • a: coefficent of the squared term.
  • b: coefficient of the linear term.
  • c: constant with its sign.

Return Value

  • when both roots are real: Array[2] with the roots of the equation.
  • when only one root is real: Array[2] wherein the first element is the real root and the other element is a warning.
  • when both roots are imaginary: Array[2] in which both elements are warnings.

Note: If a is equal to 0, quadSolverCitardauq() will be called automatically with the arguments as provided.

completeSquare(a, b, c)

Arguments

  • a: coefficent of the squared term.
  • b: coefficient of the linear term.
  • c: constant with its sign.

Return Value

  • when both roots are real: Array[2] with the solutions for the equation.
  • when both roots are imaginary: Array[2] with both elements are in which both elements are NaN.

quadSolverCitardauq(a, b, c)

Arguments

Same as quadSolver(a, b, c).

Return Value

Same as quadSolver(a, b, c).

getVersion()

Arguments

No arguments are required.

Return Value

String containing name and version of the package in quadratic-solver v0.x.x format.

ES6 Classes

Solver(a, b, c)

Properties

  • a: coefficent of the squared term; default: 2.
  • b: coefficient of the linear term; default: 5.
  • c: constant with its sign; default: -3.

Methods

  • solve(): returns output of quadSolver() with properties of the instance.
  • completeSquare(): returns output of completeSquare() with properties of the instance.
  • versionMethod(): returns the output of getVersion().

MatrixSolver([[a, b, c], [d, e, f], ...])

Properties

  • matrix: array of arrays containing the coefficients of the quadratic and linear terms, followed by the constant (in that order); default: [[2, 5, -3]].

Methods

  • solveAll(): returns output of quadSolver() for each array in an array of arrays.
  • completeSquareAll(): returns output of completeSquare() for each array in an array of arrays.
  • versionMethod(): returns the output of getVersion().

Author

Sudipto Ghosh sudipto(at)ghosh(dot)pro

License

Source code distributed under the MIT License.