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

@pie-framework/math-validation

v1.2.2

Published

New math validation

Downloads

192

Readme

math-validation

  • an api
  • a large set of test data
  • aims to determine if two mathematical expressions are equal, either having the same form or not
  • have a public website where you can add some math and check if it works - also the link should be shareable

demo

yarn demo

Then go to http://localhost:$PORT/demo

Tests

yarn jest

Runs all the tests

There is one test that runs fixture data located here: src/fixtures/latex-equal/*.ts. To filter the fixtures you run here you can use the -t flag:

yarn jest src/__tests__/latex-equal.spec.ts -t src/fixtures/latex-equal/7119.ts --reporters default

Next Steps

  • Check that api we expose will support what is needed.
  • Do triage on the test failures, add a note to failing test so we can build a picture of the work needed

Test failure triage

| theme | notes | |----------------------------|------------------------------------------------------------------------| | latex parsing | seems like we aren't able to parse all the inputs in the test cases | | math evaluation | math.js is not seeing things as being equal - need more detail on that | | incomplete literal support | we haven't really set up literal options support yet | | incorrect test data | sometimes the test data is not quite right |

Goals

  • we parse from latex -> ast -> mathjs
  • clean up symbolic evaluation (in progress)
  • avoid the use of string manipulation/regex (in progress)
  • more advanced literal validation (todo)
  • block input that is clearly too large/unrelated (eg: a user can type in gobbledy-gook - we should just abort if we see that)

Capabilities

It can determine mathematical equivalence between:

  • linear equations in one variable
  • linear equations in two variables
  • quadratic equations
  • 2-way inequalities in one or two variables
  • compound inequalities in one variable
  • trigonometric identities and functions
  • inverse trigonometric functions
  • similar notation for logarithms and based logarithms

It can also handle degrees, radians and gradians

things that'd be great (but we may have to park until we have more time)

  • a faster latex parser
  • faster math evaluation

Modes

There are 2 modes - literal and symbolic

Literal: is at its most basic a tuned version of a string validation

By default - ignores spaces and parentheses as long as they do not change the meaning of operations (ex. “a+7 +b” will validate against “ ((a) + (7))+b ”) - ignores leading zeros: “0.1” will validate against “.1” - accepts commas for decimal marks. For example “1,000” will be equivalent with 1000

Literal Validation offers two configuration options that can be used to validate some variety of forms for an expression:

Ignore trailing zeros option; allows the evaluation to accept zeros to the right of the decimal place “4.5” will validate against “4.50000000000000” Ignore order option; makes validation indifferent to the variables order, as long as it does not change operations meaning. In this case “a+7 +b*c” will validate against “7 + a+bc”, but not against “ac+7+b”; without it “a+7 +b” will not validate against “7 + a+b”

Symbolic: attempts to decide if expressions are mathematically equivalent or not

By default, it offers all configurations presented for literal validation, exceeding it by quite a lot In order to check equivalence between 2 expressions, we have to reduce both expressions to the simplest one. Then distribute all coefficients, combine any like terms on each side of the expression, and arrange them in the same order.

Notes

  • @babel/runtime is a devDependency if you ever need to link this repo to another package for testing

TODO

  • set up api that is compatible w/ ui component options
  • derivatives kind of work and kind of not - how to use?

CI

We use circleci - see .circleci/config.yml

debugging tests

vscode

add the following to configurations array in launch.json

    {
      "name": "Attach",
      "port": 9229,
      "request": "attach",
      "skipFiles": [
        "<node_internals>/**"
      ],
      "type": "pwa-node"
    }
node --inspect-brk ./node_modules/.bin/jest --runInBand #and any other flags you want

The launch debug using 'Attach' command above.

semantic-release