0

I want to calculate the stationary points of a derivative in JavaScript with the external library math.js.

So if I have f(x) = x^2, the derivative is 2x and the stationary points can be calculated making 2x = 0 so x = 0 . But the function in math.js that is math.eval needs to assign a value to x.

For example:

let scope = {
  a: 3,
  b: 4
}
const c = math.eval('a * b', scope);
console.log(c); // 12
<script src="https://unpkg.com/mathjs@5.0.4/dist/math.min.js"></script>

So how can I calculate 2x + 2 = 0 for example? I want that the result given to me is x = -1.

zero298
  • 25,467
  • 10
  • 75
  • 100
  • 1
    I don't think this library has solver capabilities. I think you have to isolate terms yourself. – zero298 Jul 24 '18 at 20:47
  • MathJS can only solve linear equations involving matrices. Search [this page](http://mathjs.org/docs/reference/functions.html) for "solve". It won't solve any algebraic equation. –  Jul 24 '18 at 21:11
  • @Amy how can I do that? –  Jul 26 '18 at 05:34

0 Answers0