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

math_operations_kit

v2.0.7

Published

A module providing basic and advanced mathematical functions.

Downloads

2

Readme

📊 math_operations_kit(basic_math)

A Node.js module providing a comprehensive set of basic and advanced mathematical functions, including arithmetic, trigonometry, logarithmic operations, matrix operations, and more.

✨ Features

  • Basic Arithmetic Operations: Addition, Subtraction, Multiplication, Division, Modulus
  • Advanced Arithmetic Operations: Power, Square Root, Absolute Value, Factorial
  • Trigonometric Functions: Sine, Cosine, Tangent, Arcsine, Arccosine, Arctangent
  • Logarithmic and Exponential Functions: Natural Logarithm, Logarithm Base 10, Exponential
  • Miscellaneous Functions: Maximum, Minimum, Sum, Mean, Median, Standard Deviation, Variance
  • Additional Functions: GCD, LCM, Prime Check, Fibonacci Sequence, Combination (nCr), Permutation (nPr), Quadratic Equation Solver
  • Matrix Operations: Addition, Multiplication, Transpose

📦 Installation

To install the module, run:

npm install math_operations_kit

📚 Usage

Here are some examples of how to use the functions provided by the math_operations_kit module:

➕ Basic Arithmetic Functions

Importing Individual Functions

You can import individual functions directly from the module:

const add = require('math_operations_kit/add'); // Importing add function directly
const sub = require('math_operations_kit/sub');
const div = require('math_operations_kit/div');

console.log(add(1, 2)); // Expected: 3
console.log(sub(5, 3)); // Expected: 2
console.log(div(10, 2)); // Expected: 5

Importing the Entire Module

Alternatively, you can import the entire module and access functions through it:

const add = require('math_operations_kit');
console.log(math.add(2, 3)); // Output: 5
console.log(math.subtract(5, 2)); // Output: 3
console.log(math.multiply(4, 3)); // Output: 12
console.log(math.divide(10, 2)); // Output: 5
console.log(math.modulus(10, 3)); // Output: 1

🚀 Advanced Arithmetic Functions

console.log(math.power(2, 3)); // Output: 8
console.log(math.sqrt(16)); // Output: 4
console.log(math.abs(-5)); // Output: 5
console.log(math.factorial(5)); // Output: 120

📐 Trigonometric Functions

console.log(math.sine(Math.PI / 2)); // Output: 1
console.log(math.cosine(Math.PI)); // Output: -1
console.log(math.tangent(Math.PI / 4)); // Output: 1

📈 Logarithmic and Exponential Functions

console.log(math.naturalLog(Math.E)); // Output: 1
console.log(math.logBase10(100)); // Output: 2
console.log(math.exponential(1)); // Output: 2.718281828459045

📊 Miscellaneous Functions

console.log(math.max(1, 2, 3, 4, 5)); // Output: 5
console.log(math.min(1, 2, 3, 4, 5)); // Output: 1
console.log(math.sum([1, 2, 3, 4, 5])); // Output: 15
console.log(math.mean([1, 2, 3, 4, 5])); // Output: 3
console.log(math.median([1, 2, 3, 4, 5])); // Output: 3
console.log(math.standardDeviation([1, 2, 3, 4, 5])); // Output: ~1.414
console.log(math.variance([1, 2, 3, 4, 5])); // Output: 2

⚙️ Additional Functions

console.log(math.gcd(8, 12)); // Output: 4
console.log(math.lcm(8, 12)); // Output: 24
console.log(math.isPrime(17)); // Output: true
console.log(math.fibonacci(10)); // Output: [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
console.log(math.combination(5, 2)); // Output: 10
console.log(math.permutation(5, 2)); // Output: 20
console.log(math.solveQuadratic(1, -3, 2)); // Output: [2, 1]

Solve Quadratic Equation

To solve a quadratic equation of the form a(x^2) + bx + c = 0 , you can use the solveQuadratic function:

const [root1, root2] = math.solveQuadratic(1, -3, 2);
console.log('Roots of the quadratic equation:');
console.log(`Root 1: ${root1}`); // Output: 2
console.log(`Root 2: ${root2}`); // Output: 1

🧮 Matrix Operations

const { Matrix } = require('math_operations_kit');

for matrix applications , you have import this additionally ,

const matrix1 = new math.Matrix([[1, 2], [3, 4]]);
const matrix2 = new math.Matrix([[5, 6], [7, 8]]);
const matrixSum = matrix1.add(matrix2);
console.log(matrixSum.data); // Output: [[6, 8], [10, 12]]

const matrixProduct = matrix1.multiply(matrix2);
console.log(matrixProduct.data); // Output: [[19, 22], [43, 50]]

const matrixTranspose = matrix1.transpose();
console.log(matrixTranspose.data); // Output: [[1, 3], [2, 4]]

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🤝 Contributing

Please feel free to use the module and connect with me if you encounter any errors or have suggestions for improvements. You can reach me at [[email protected]].

🔗 GitHub Repository

Find the source code and contribute on GitHub.