Math.js expression syntax

86 Views Asked by At

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

There are 1 best solutions below

0
swatchai On

I will attempt to write a live code to answer the question. And it is

-nthRoot(x+4,3)-4

as commented by @Luuk.

// Use this function to show values of matrix and etc.
function print (value) {
  const precision = 14
  console.log(math.format(value, precision))
}
print("Start MathJS test.")
//print(math.round(math.e, 3))     // 2.718
let x = 23
print( -math.nthRoot(x+4,3) -4 )   // -7
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/11.3.1/math.js"></script>