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
6
votes
5 answers

how to include and use math.js

I am trying to use math.js (http://mathjs.org/docs/reference/functions/inv.html) but I can't see how to include it in an HTML file. I have read that you can include it by adding this to the file: var math = require('mathjs'); but that didn't work…
fred
  • 117
  • 1
  • 1
  • 5
3
votes
1 answer

How to make a string safe to use as a math.js expression

I want to let users input a string that will be evaluated in math.js as an expression. What can I do to prevent malicious use of this feature?
Victor
  • 23,172
  • 30
  • 86
  • 125
2
votes
0 answers

How to render math symbols inside code block

I am an HTML newbie and use it to create a reveal.js presentation. I have a code block of pseudo-code and I wish to render math symbols as part of the code. How can I do it? (when I generate it outside of a code block, e.g.,

$\exists i \in…

Tom Ron
  • 5,906
  • 3
  • 22
  • 38
2
votes
1 answer

Transfer variables from javascript to math.js (getElementById())

I am trying to transfer a javascript variable to a math.js function. The variable (denexp) is obtained by getElementById as follows:
nikoscham
  • 33
  • 5
2
votes
0 answers

Include math.js to Google Sheets JavaScript?

I would like to use math.js functions in Google Sheets script editor. How can I make math.js accessible?
2
votes
2 answers

Equate equation to zero

I have been trying in vain to equate a linear equation to zero. I am using Math.js library to perform a first order differential on an equation I provided: const derivative = math.derivative(equation,"x"); This provides me with the…
Julius Knafl
  • 429
  • 3
  • 14
2
votes
1 answer

Solving Lotka–Volterra equations with math.js

There's one example on solving differential equations in math.js on the math.js homepage, but it's fairly complex and does not provide enough information for me personally to be able to apply math.js for other similar problems. So, what I'm trying…
Olle Härstedt
  • 3,799
  • 1
  • 24
  • 57
2
votes
2 answers

Why does math.bignumber() return an object? And how can I use it?

I am really confused using math.js's bignumber function. When I use their examples in both the console, and within script tags, math.bignumber() returns a Decimal object. How do I use this object to get an actual float to use? Example…
E.Arrowood
  • 750
  • 7
  • 17
2
votes
2 answers

Math.js access a single element in a matrix

It looks like a too basic job. However, I can't do it. I added math.js to my HTML code I define a matrix in firefox console: var M = math.matrix([[1,0,0,4],[0,1,0,2],[0,5,1,9],[11,2,3,1]]); So far everything…
ar2015
  • 5,558
  • 8
  • 53
  • 110
2
votes
1 answer

Using Imaginary Numbers in Javascript without math.js

I am new to programming in general and finally started to work on a small project -- that is to build a Quadratic Function Calculator and I've come across the problem of the language not supporting imaginary numbers and more specifically, negative…
1
vote
1 answer

Math.js expression syntax

How do you enter a power root in Math.js' expression syntax? In AsciiMath I can enter "-root(3)(x+4)-4". How can I get the same result in the expression syntax of Math.js? enter image description here
1
vote
1 answer

math.js + MathJax: show fraction as inline or slash for units like m/s or mi/h

Need help with math.js and LaTeX using MathJax. For example, at the moment: \frac{140.8~\mathrm{m}}{\mathrm{s}} Will result to: Which is not what I want. I want to force it to use slash (eg: 140.8 m/s) or display as 140.8 ms^(-1). I'm new in using…
smkso
  • 95
  • 1
  • 6
1
vote
2 answers

Compute Approximate Value of Matrix Operations With Math.js

I'm performing matrix calculations (e.g. computing determinants, eigenvalues, inverse matrices) in JavaScript using Math.js. I would like the computations to be performed more rapidly (it's computing them on 2X2 matrices, but it should be performing…
1
vote
1 answer

Using math.js in Postman

I am trying to use math.js in Postman. Already saw Tip#5 in their website. So, in one request I have postman.setGlobalVariable("mathjs", () => { \\ The full math.js library }); Specifically, this is the code of math.js that I copied, in case the…
plop
  • 283
  • 2
  • 10
1
vote
1 answer

SyntaxError: Value expected (char 1)

I'm trying to make a !calculate command in Discord.js v12. I'm using mathjs and this is my current code: client.on('message', msg => { if(!msg.content.startsWith('!')) return; const args = msg.content.split(/[\ ]/g); const cmd =…
1
2 3 4