GithubHelp home page GithubHelp logo

abhinandkrishna20 / algebra-for-you Goto Github PK

View Code? Open in Web Editor NEW

This project forked from razaahmad333/algebra-for-you

0.0 0.0 0.0 1.56 MB

This a npm package to help you with algebra from 5th grade to advanced level

Home Page: https://www.npmjs.com/package/algebra-for-you

License: MIT License

JavaScript 100.00%

algebra-for-you's Introduction

Algebra-for-you

this is for 5th grade to advanced level for solving algebra problems

How to install it using npm

 npm install algebra-for-you

How to use it

with module

means in package.json

 ...
 "type":"module",
 ...
import algebra from 'algebra-for-you';

// do basic maths
console.log(algebra.sum(1, 2));
console.log(algebra.sub(10, 2));
console.log(algebra.mult(4, 2));
console.log(algebra.div(8, 2));

// solve linear equation in two variables (x and y)
const { solveLinearEquation } = algebra;

const solution = solveLinearEquation("2x + y = 1","x + y = 1");
// { x: 0, y: 1, type: 'Unique solution ( Consistent and Independent) ' }

with commonjs

means in package.json

 ...
 "type":"commonjs",
 ...

*or if there is no such field of "type"

const algebra = require('algebra-for-you');

const solution = algebra.solveLinearEquation("2x + y = 1","x + y = 1");

// { x: 0, y: 1, type: 'Unique solution ( Consistent and Independent) ' }

now you can mathjs utilities with algebra.mathjs

const math = algebra.mathjs;

math.round(math.e, 3)                // 2.718
math.atan2(3, -3) / math.pi          // 0.75
math.log(10000, 10)                  // 4
math.sqrt(-4)                        // 2i
math.derivative('x^2 + x', 'x')      // 2*x+1

*NOTE: algebra is just a placeholder, you can use any name you want. algebra-for-you has default export.



How to use it in the browser

just paste this line in header of your html file

<script src="https://unpkg.com/algebra-for-you@latest/dist/index.umd.js"></script>

Here is the full code

<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Algebra For You </title>
        <script src="https://unpkg.com/algebra-for-you@latest/dist/index.umd.js"></script>
    </head>

    <body>

        <h2>Addition</h2>
        <h3 id="sumOfTwoNumbers"></h3>

        <h2>Solving system of Linear equations</h2>

        <h3>Equation1 => x + y = 3</h3>
        <h3>Equation2 => x - y = 1</h3>

        <h3 id="solution"></h3>

        <script>

            // use the basic arithematic utils

            const sumOfTwoNumbers = AlgebraForYou.sum(1, 2);
            document.getElementById('sumOfTwoNumbers').innerHTML = `1 + 2 = ${sumOfTwoNumbers}`;

            //similarly 
            const substraction = AlgebraForYou.sub(6, 2); // 4
            const multiplication = AlgebraForYou.mult(3, 2); // 6
            const division = AlgebraForYou.div(10, 2); // 5

            // lets solve system of linear equations

            const equation1 = "x + y = 3";
            const equation2 = "x - y = 1";

            const solution = AlgebraForYou.solveLinearEquation(equation1, equation2);
            const textToEmbed = `Solution: x = ${solution.x}, y = ${solution.y}, type = ${solution.type}`;
            document.getElementById('solution').innerHTML = textToEmbed;
            console.log(solution);

            const math = AlgebraForYou.mathjs;

            math.round(math.e, 3)                // 2.718
            math.atan2(3, -3) / math.pi          // 0.75
            math.log(10000, 10)                  // 4
            math.sqrt(-4)                        // 2i
            math.derivative('x^2 + x', 'x')      // 2*x+1



        </script>

    </body>

</html>

Feel free to raise issues or contribute

mathjs : the library I'm using to do stuff which it can simplify for me.

algebra-for-you's People

Contributors

razaahmad333 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.