Questions tagged [mathjs]

Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser and offers an integrated solution to work with numbers, big numbers, complex numbers, units, and matrices.

Math JS Site

An extensive math library for JavaScript and Node.js

Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser and offers an integrated solution to work with numbers, big numbers, complex numbers, units, and matrices. Powerful and easy to use.

Features

-Supports numbers, big numbers, complex numbers, units, strings, arrays, and matrices.

-Is compatible with JavaScript’s built-in Math library.

-Contains a flexible expression parser.

-Supports chained operations.

-Comes with a large set of built-in functions and constants.

-Has no dependencies. Runs on any JavaScript engine.

-Is easily extensible

98 questions
0
votes
0 answers

MathJS parse values from input field

I'm trying to parse some values like x^2 and x from an input field, then dividing them using mathjs This is my JS function LDivide() { ldft = document.getElementById("LD1").value; ldst =…
Daniel R
  • 89
  • 1
  • 3
  • 13
0
votes
0 answers

Is there something about security I should be worried by using parser.evaluate() from math.js?

We've been advised to never use eval() for security reasons. Now that I've been building a calculator, and solving mathematical expressions is a big part of my project. I do have a function that check if the expression is mathematical expression…
jbz
  • 3
  • 3
0
votes
2 answers

How to format number correctly in a calculator app (React)?

This is my first time posting in SO, and I need help formatting numbers correctly in a calculator app that I've made using ReactJS. Here is the link on StackBlitz. Now, I want to achieve the formatting effect after numbers are pressed and shown in…
iamkyo
  • 71
  • 1
  • 2
  • 7
0
votes
2 answers

How to use mathjs in a normal JS file?

I am trying to use the node package mathjs in a calculator app I am creating. The problem is, I am not running it with node, it is a website I am creating. How can I use mathjs features in my JavaScript on my website?
TimTam
  • 63
  • 1
  • 8
0
votes
1 answer

Why Math.js default takes multiply as operator when calculation an expression?

//Require module const express = require('express'); const { evaluate, compile, parse } = require('mathjs'); // Express Initialize const app = express(); const port = 8000; app.listen(port, () => { console.log('listen port 8000'); }) //create…
0
votes
1 answer

How to process & calculate - two array objects without For Loop

I have two objects and I want to process them without use of for Loop and get the result. key is taken from obj1 "keyname" const obj1 = [{ _id: 5 f467650890a7444d8d9ea5b, keyname: 'fTime', PTag:…
Gunjan Anshul
  • 103
  • 1
  • 7
0
votes
2 answers

how to handle NaN value in mathjs.evaluate

console.log(mathjs.evaluate("(goodCount/(goodCount+reject_count))>0.99", { goodCount: 0, reject_count: 0, Total_Planned_time: 10 })) my problem is that if goodCount & reject_count zero this function return NaN but I want Either true or false…
0
votes
1 answer

Get distinct products of a sum-of-products expression mathjs/js

Is there a way using Mathjs or some other js lib or even plainjs to get the distinct products of a sum-of-products expression? F.e given this expression as a string: 7.30*7.40-2.10*1.30+8.10*(2.70+0.60+4.70)+0.30*0.60+…
user985409
  • 1,355
  • 3
  • 9
  • 18
0
votes
2 answers

Regex, Get sequence if not preceded by symbols

I'm using the math.js library and I need to take the exponent of some variables. I have the following…
aspeddro
  • 87
  • 3
0
votes
0 answers

How to handle decimals in Javascript with user defined calculations

I'm trying to come up with a solution to avoid decimal errors when doing calculations in my application. I've seen some solutions but still have questions. My understanding is that floating point numbers can't be accurately stored in Javascript,…
coder
  • 11
  • 2
0
votes
0 answers

Math: Is it possible walk a node tree and parse it using RPN?

I'm working on a problem where I need to parse a string math equation, and use RPN to solve it. Is it possible to get the tokenization step, and node tree from another library like this: https://mathjs.org/docs/reference/functions/parse.html And…
GN.
  • 8,672
  • 10
  • 61
  • 126
0
votes
0 answers

How to solve unknown in math.js?

I find math.js Don't have solve function for an unknown equation like the following equation var eq = (2.75501+x*0.0013016)+(1.89908+x*-0.0006573)-5 = 0 and when I try to simplify var simplify_eq…
0
votes
3 answers

NodeJS error with discord bot: UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message

So I'm trying to make a bot that does quick math for me via commands. My prefix is da$h and the command is payment. When I try the command da$h payment 1 + 1 for example, I'm presented with the same error every time. I'm using mathjs node btw. I've…
Vahagn
  • 11
  • 1
  • 1
0
votes
1 answer

math.js Uncaught TypeError: v is not a function with p5

I hate that I'm asking this question but I've been through every single stack overflow post tagged with mathjs or math.js and a whole load of posts with "x is not a function" but none of them are relevant or helpful. Here is the full stack trace I…
sam-pyt
  • 1,027
  • 15
  • 26
0
votes
1 answer

Does mathjs have any concept of null or undefined?

I think the answer is probably 'no' as from what I can tell maths libraries don't seem to handle null, but what I'd like to have is to be handle null in these scenarios: x=1 (y not defined) z = sum(x, y) with eval() ideally giving: z=1 However,…
John Stephenson
  • 499
  • 4
  • 13