Git Product home page Git Product logo

mathsteps's Introduction

A step by step solver for math

Join the chat at https://gitter.im/mathsteps-chat/Lobby Build Status

https://www.youtube.com/watch?v=iCrargw1rrM

Requirements

Mathsteps requires Node version > 6.0.0

Usage

To install mathsteps using npm:

npm install mathsteps
const mathsteps = require('mathsteps');

const steps = mathsteps.simplifyExpression('2x + 2x + x + x');

steps.forEach(step => {
	console.log("before change: " + step.oldNode);         // before change: 2 x + 2 x + x + x
	console.log("change: " + step.changeType);             // change: ADD_POLYNOMIAL_TERMS
	console.log("after change: " + step.newNode);          // after change: 6 x
	console.log("# of substeps: " + step.substeps.length); // # of substeps: 3
});

To solve an equation:

const steps = mathsteps.solveEquation('2x + 3x = 35');

steps.forEach(step => {
    console.log("before change: " + step.oldEquation.print());  // e.g. before change: 2x + 3x = 35
    console.log("change: " + step.changeType);                  // e.g. change: SIMPLIFY_LEFT_SIDE
    console.log("after change: " + step.newEquation.print());   // e.g. after change: 5x = 35
    console.log("# of substeps: " + step.substeps.length);      // e.g. # of substeps: 2
});

To see all the change types:

const changes = mathsteps.ChangeTypes;

Contributing

Hi! If you're interested in working on this, that would be super awesome! Learn more here: CONTRIBUTING.md.

Build

First clone the project from github:

git clone https://github.com/socraticorg/mathsteps.git
cd mathsteps

Install the project dependencies:

npm install

Test

To execute tests for the library, install the project dependencies once:

npm install

Then, the tests can be executed:

npm test

mathsteps's People

Contributors

evykassirer avatar aelnaiem avatar raibaz avatar hmaurer avatar shirleymiao avatar tkosan avatar faheel avatar josdejong avatar karuppiah7890 avatar lexiross avatar mcarthurgill avatar michaelmior avatar nitin42 avatar cspanda avatar gitter-badger avatar biyasbasak avatar

Watchers

James Cloos 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.