Questions tagged [math.js]

Math.js is an extensive math library for JavaScript and Node.js.

Math.js is an extensive math library for JavaScript and Node.js.

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.
  • Open source.
55 questions
1
vote
0 answers

Is it possible to do pseudo inverse for matrix in math.js?

I have searched math.js documentation and could not find a way to do pseudo inverse of a non-invertible matrix. May I ask if it is possible to do it on math.js or anyway else? Thank you! (Equivalent of pinv in matlab) const XtXInv =…
atjw94
  • 529
  • 1
  • 6
  • 22
1
vote
1 answer

Efficient encoding for float constants in JavaScript

I am writing a signal processing demo in JavaScript. For that, I need to store relatively large vectors of floats. If I do it in a naive way (using the mathjs library): var vector = math.matrix([-35.545806884765625, -3.1195175647735596, ...]); it…
Jindřich
  • 10,270
  • 2
  • 23
  • 44
1
vote
1 answer

Can't display fractions in React project. Child error instead even with mathjs

I want to create my own recipe converter and needed partial quantities of measurements like cups and teaspoons in fractions. When I attempted to insert these as portions into an object as shown below, it displays a decimal on the webpage instead of…
A-Bro
  • 103
  • 1
  • 11
1
vote
1 answer

How to set initial position of draggable points in JSXGraph in an equation graph?

I'm developing a web software that plots an interactive polynomial equation with 2 variables on JSXGraph, I need that every point where the derivative of the equation is 0 to have a draggable point, and that when I drag one point, only the interval…
1
vote
2 answers

Can't get Lotka-Volterra equations to oscillate stable with math.js

I'm trying to implement a simple Lotka-Volterra system in JavaScript, but get different result from what I see in academic papers and slides. This is my equations: sim2.eval("dxdt(x, y) = (2 * x) - (x * y)"); sim2.eval("dydt(x, y) = (-0.25 * y) + (x…
Olle Härstedt
  • 3,799
  • 1
  • 24
  • 57
1
vote
1 answer

Equation evaluation in math.js

I am new in math js library and I was trying to solve this expression: var x_res = math.simplify('(x-'+x1+')^2 + ('+y_part+' - '+y1+')^2 - 197.5^2'); With simplify method i simplified it, but how can I do to know the "x" value ? Thanks in advance.
Pierpaolo Ercoli
  • 1,028
  • 2
  • 11
  • 32
1
vote
1 answer

math.js acting unexpectedly

Chrome 57.0.2987.110 (64-bit) math.js v3.10.0 Using the code below I get false. Am I not doing this right? math.config({'number': 'BigNumber'}); console.log(math.largerEq('120', '2')); https://jsfiddle.net/z2jmLndn/1/
MonkeyZeus
  • 20,375
  • 4
  • 36
  • 77
1
vote
1 answer

Why math.simplify("1e-10").toString() of math.js returns 0?

I have question about the function simplify from math.js library for JavaScript. The function returns 0 for very small numbers. e.g.: math.simplify("1e-10").toString(); // returns 0 math.simplify("sin(1.5)*1e-10").toString(); // returns 0 It is…
Sten
  • 25
  • 2
1
vote
1 answer

Javascript Julia Fractal slow and not detailed

I am trying to generate a Julia fractal in a canvas in javascript using math.js Unfortunately every time the fractal is drawn on the canvas, it is rather slow and not very detailed. Can anyone tell me if there is a specific reason this script is so…
Willempje2
  • 43
  • 2
1
vote
4 answers

Java Script INFINITY property

I see var r = INFINITY; in v8/math.js But it doesn't work in the console. What is the source of INFINITY property? How is it implemented internally?
Charlie
  • 22,886
  • 11
  • 59
  • 90
1
vote
1 answer

How to implement NOR, NAND, XNOR in math.js?

I would like to somebody help me. There is a very good JS library math.js. It implements boolean logical operators NOT, OR, AND, XOR. I need the others ones: NOR, NAND, XNOR. I know that NOR is NOT OR, but; there is a problem I need this operators…
user3380558
  • 33
  • 1
  • 5
0
votes
1 answer

Iterate through object and its child objects and update values based on expressions every time a value changes in a child object

I'm using Angular 15 with PrimeNG. { id: 1, data: { value: "Lorem ipsum" }, expression: null, subElements: [ { id: 2, data: { value: 2 }, expression:…
Death Dog
  • 1
  • 2
0
votes
0 answers

Javascript decimal calculation for the pre assume value as like Numi app

The attached diagram shows the correct results in Numi app in IOS. When i calculate the same calculation, it calculates differently. I want the same way as how Numi did on the image. amount = 4; commission = 0.5;  round = 6; result = amount / (1 +…
0
votes
0 answers

How can I fix cannot convert number with >15 digits to a bigNumber while calculating pi?

The code is: const c = mult(426880, sqrt(10005)) let calc = bn(0); for (let k = 0; k < 20; k++) { const m = div(fac(mult(bn(6), k)), mult(fac(mult(bn(3), k)), pow(fac(k), bn(3)))) const l = add(mult(bn(545140134), k), bn(13591409)) …
0
votes
1 answer

Can i convert math.js object into JavaScript function?

I'm developing simple js neural network and need to create javascript function (derivative of entered by user) before learning starts. I know about evaluate(), but i think it'll be slowly than simple function. That is what i want: const derivative =…
shumik_UA
  • 117
  • 7