arthanzel / evaluatex Goto Github PK
View Code? Open in Web Editor NEWLatex and ASCIIMath evaluator for Javascript.
Home Page: http://arthanzel.github.io/evaluatex
License: MIT License
Latex and ASCIIMath evaluator for Javascript.
Home Page: http://arthanzel.github.io/evaluatex
License: MIT License
I identified a wild console.log
coming from src/Node.js
while I was debugging my web app.
Whenever I evaluate anything with this library that has a -: in it, it breaks and gives me the error in the title, please help me. For example, if I try to evaluate 1(1)/(5)-:-1(1)/(3)
it throws Lexer error: can't match any token.
Given an equation string like "x^2 + y", I need to find out the list of its unknown variables such as ["x", "y"]
in this example. I feel this is something already being done somewhere in evaluatex code, but I couldn't find a public function or the correspondent internal code. This function should work with any valid evaluatex expression. Is that something useful to add to the interface? If not, could you point me out the file where I can find this logic so I can abstract that in my codebase?
First off,
This library seems great! ~80 commits, all by one person, and works really well! I don't know why this isn't getting more attention!
On a 'not quite there yet' note, despite the partial LaTeX support (the reason why I am here). There seem to be some issues with very basic functionality. See below.
>>> evaluatex('a \\times b', options={latex: true})
Thrown: Parsing error: Expected end of input, but got COMMAND undefined
I haven't done any sort of entensive testing yet, but I had hoped that I would be able to use this to make a VS Code extension that evaluates lines of math in LaTeX code.
I still hope I will, since this seems to have all the groundwork done, but would be all the better for an extra few steps ๐
Evaluatex should be able to evalute latex like 2\frac{2}{3} which is a mixed number of fractional value 8/3.
requiring babel-register is causing trouble when bundling this package using webpack for lambdas: https://github.com/arthanzel/evaluatex/blob/master/index.js#L8
Module not found: Error: Can't resolve 'babel-register' in 'app/node_modules/evaluatex'
Module not found: Error: Can't resolve './src/evaluatex' in 'app/node_modules/evaluatex'
can we only keep the transpiled code? and avoid transpiling on the fly?
How can I make \pi a constant in evaluatex? I get a weird error:
evaluatex("\\pi", { "\\pi": 3.14 }, {latex: true});
Uncaught TypeError: this.value.apply is not a function
The following error occurs when running the build
script. I've tried Node 14.5.0 and 12.x and same error occurs. It looks like index.js falls back to src/evaluatex
so it might still work fine, but figured we should get this build script working if it needs to remain.
evaluatex$ npm run build
> [email protected] build /Users/lancewhatley/nodejs/evaluatex
> babel -d dist src && webpack dist/minifier.js -o dist/evaluatex.min.js
src/Node.js -> dist/Node.js
src/Token.js -> dist/Token.js
src/evaluatex.js -> dist/evaluatex.js
src/lexer.js -> dist/lexer.js
src/minifier.js -> dist/minifier.js
src/parser.js -> dist/parser.js
src/util/arities.js -> dist/util/arities.js
src/util/isNumber.js -> dist/util/isNumber.js
src/util/localFunctions.js -> dist/util/localFunctions.js
src/util/replaceToken.js -> dist/util/replaceToken.js
/Users/lancewhatley/nodejs/evaluatex/node_modules/webpack-cli/bin/config-yargs.js:89
describe: optionsSchema.definitions.output.properties.path.description,
^
TypeError: Cannot read property 'properties' of undefined
at module.exports (/Users/lancewhatley/nodejs/evaluatex/node_modules/webpack-cli/bin/config-yargs.js:89:48)
at /Users/lancewhatley/nodejs/evaluatex/node_modules/webpack-cli/bin/webpack.js:60:27
at Object.<anonymous> (/Users/lancewhatley/nodejs/evaluatex/node_modules/webpack-cli/bin/webpack.js:515:3)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `babel -d dist src && webpack dist/minifier.js -o dist/evaluatex.min.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/lancewhatley/.npm/_logs/2020-07-12Txxxxxxxxx-debug.log
hey,
First off, was overjoyed to find this lib.
(2*arctan((36/(2*85))))*(180/PI)
= Error!
(2*atan((36/(2*85))))*(180/pi)
= Error!
(2*atan((36/(2*85))))*(180/PI)
= 23.913
ideally:
(2*arctan((36/(2*85))))*(180/pi)
= 23.913
Using the http://asciimath.org/ reference, arctan would ideally be mapped to the correct function, along with all of the others: sin, cos, tan, sec, csc, cot, arcsin, arccos, arctan, sinh, cosh, tanh, sech, csch, coth, exp, log, ln, det, dim, mod, gcd, lcm, lub, glb, min, max, f, g.
Thanks!
For example given A=1
and E=5
, A+E
is evaluated by evaluatex to an unexpected result.
\sqrt[n]{expression}
creates the nth root syntax but the program is producing a wrong output for the nth root
I have been using evaluatex for evaluating expressions written in LaTeX through MathQuill. I have noticed some generated expressions such as ones involving the \times
and \cdot
operators like "2\\times3"
or "4\\cdotx"
are not supported (attempting to compile them will throw a Parsing error), while "\\frac{1}{x}"
works fine. Is it the goal of the project to eventually support all valid LaTeX constructs? If so, what would be the process of adding more of them?
Tried this
var evaluatex = require("evaluatex")
exp_function = evaluatex("a*(x+b)")
exp_function({a:10,x:"x",b:"10"})
and got
/home/simha/maths_testing/node_modules/evaluatex/dist/Node.js:90
throw new Error("Symbol " + this.value + " is undefined or not a number");
^
Error: Symbol x is undefined or not a number
at Node.evaluate (/home/simha/maths_testing/node_modules/evaluatex/dist/Node.js:90:27)
at /home/simha/maths_testing/node_modules/evaluatex/dist/Node.js:83:44
at Array.reduce (<anonymous>)
at Node.evaluate (/home/simha/maths_testing/node_modules/evaluatex/dist/Node.js:82:44)
at /home/simha/maths_testing/node_modules/evaluatex/dist/Node.js:78:48
at Array.reduce (<anonymous>)
at Node.evaluate (/home/simha/maths_testing/node_modules/evaluatex/dist/Node.js:77:44)
at fn (/home/simha/maths_testing/node_modules/evaluatex/dist/evaluatex.js:33:20)
at evalmachine.<anonymous>:1:1
at Script.runInThisContext (vm.js:124:20)
I am creating various expressions with some variables. to show for students.
eg:
10*x + 100
How can i do this
Also Sometime i only want to substitute
i.e
10*(x + 10)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.