Math steps

Step by step math solutions for everyone

README

A step by step solver for math

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

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

Requirements


Mathsteps requires Node version > 6.0.0

Usage


To install mathsteps using npm:

    npm install mathsteps

  1. ``` js
  2. const mathsteps = require('mathsteps');

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

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

To solve an equation:
  1. ``` js
  2. const steps = mathsteps.solveEquation('2x + 3x = 35');

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

(if you're using mathsteps v0.1.6 or lower, use .print() instead of .ascii())

To see all the change types:
  1. ``` js
  2. const changes = mathsteps.ChangeTypes;
  3. ```



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