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
2 answers

JS fractions for big numbers with no precision lose

Big numbers with fraction support: I want to perform math operation with no precision loss. How can I do it using JavaScript? First I tried decimal.js, but it does not preserve precision as you see in next example: import {Decimal} from…
valerii15298
  • 737
  • 4
  • 15
0
votes
1 answer

Cannot find type definition file for 'mathjs'

I have a new install of VSCode on Windows 11. I open a previous project and create a hello_world.js file. The contents of the hello world are simply: console.log('hello world'); In my jsconfig.json I have this error message: Cannot find type…
D.L
  • 4,339
  • 5
  • 22
  • 45
0
votes
0 answers

Can user inputted mathematical function verified by math.js expression parser cause arbitrary code execution?

I am making a graphing calculator, and need a fast way to run a user inputted mathematical function (e.g. y = x^3 + 2). Previously I was using the math.js evaluate function, however this was very slow. Now I have switched to using the JavaScript new…
0
votes
1 answer

How to use npm library in NestJs

I'm new into NestJs and I've been trying to use the mathjs library inside a custom decorator in order to verify that a string is a valid unit of measurement (would also appreciate guidance on this) but I've been getting the following error, and I'm…
0
votes
0 answers

Mathjs parse back to expression after using stringify on MathNode

I have for example expression like: const expression = 'delta(var(123), 20)' Then I use math.parse on that to validate it with mathjs. Output of parsing with mathjs: "mathjs": "FunctionNode", "fn": { "mathjs": "SymbolNode", …
YOZA
  • 13
  • 3
0
votes
2 answers

How to import mathjs module in Nodejs using ES6 Module syntax?

The following works for me: import { zeros } from "mathjs"; const w = zeros(5, 5); but I'm trying to do something like: math.zeros(5, 5) as what I saw in the documentation https://mathjs.org/docs/reference/functions/zeros.html which will allow me…
Nadirspam
  • 161
  • 7
0
votes
0 answers

Show the steps of integration using mathJS

I'm making an integration calculator for my website. For this purpose, I'm using mathJS library. It gives the answer easily. But I want to show intermediate steps from question to answer. But I'm not able to figure it out. Can you provide me any…
0
votes
2 answers

properly override toJSON for mathjs bignumber

I am trying to override mathjs Bignumber using: import * as math from 'mathjs'; export const bgn = (v: number | math.BigNumber) => { const z = math.bignumber(v) as math.BigNumber; (z as any).toJSON = () => { return Number(math.larger(100,…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
1 answer

Need good calculation to get right index by x from width

Here, I made a canvas app with total width is (742px), so here what I need, I just want to calculate and get right section (Index) by X only. Example, I got 393.9015504531791 as X calculated with whole width, So X here it's 0.5x in real, how do I…
cair71
  • 13
  • 1
0
votes
1 answer

Using mathjs expressions with ag-grid

ag-grid allows string expressions in column valueGetters. For example: { field: 'r', headerName: 'Radius' }, { field: 'circumference', valueGetter: 'Math.PI * data.r ** 2', } I am wondering if the expression parser can be switched to mathjs…
Naresh
  • 23,937
  • 33
  • 132
  • 204
0
votes
0 answers

Crazy number, sum two numbers but it show result 3e-7

Probably this question is already existed somewhere but can't find my specific issue. I have a two numbers that I want to add and I don't want to use round(number,7) I user with mathjs and decimal number but still make me crazy For example let a =…
0
votes
1 answer

Mathjs eval function behaving differently with and without string

When I am evaluating Arithmetic operation without quotes in math.eval function null is ignored and I get proper results. Where as if I put quotes to same function it throws error. Problem is I cannot work without string, as I have some custom…
Goofy
  • 210
  • 1
  • 3
  • 17
0
votes
1 answer

Math.evaluate is not a function

im trying to do some Math in a js function while using MathJs & getting this error :Math.evaluate is not a function Do-Math :
AAA
  • 13
  • 1
0
votes
1 answer

How can I add "deg" after all numbers in trig functions?

I'm using Node.js with the mathjs package. Mathjs uses radians in its trig functions. I want to include a degree mode for a calculator I'm making. How can I add "deg" after every number within any sin/cos/tan function in a string? This way, mathjs…
OIRNOIR
  • 33
  • 6
0
votes
1 answer

mathjs evaluate two variables without operator in between (e.g xy instead of x*y)

Im trying to do a function where I enter two different algebraic expressions and have a variable list to change them into numbers. However, it do not recognise the variables if they do not have an operator in between them like in this case: let exp1…