简体   繁体   English

js 数学 function 为 y√(x)?

[英]js math function for y√(x)?

3 √(9) = 2.0800838231, or Y √x 3 √(9) = 2.0800838231,或Y √x

is there any Math function in vanilla js for calculation above the formula? vanilla js中是否有任何Math function用于公式以上的计算?

Can you try this:你可以试试这个:

 console.log(Math.pow(9, 1/3)); // replace "3" with the root // "9" with your number

This is what i think will work:这就是我认为可行的方法:

 document.write(Math.pow(9, 1 / 3));

pow raises the second argument to the power of first argument. pow将第二个参数提高到第一个参数的幂。

Now from basic math we know 3√(9) = (9)^(1/3)现在从基础数学我们知道3√(9) = (9)^(1/3)

The Math.cbrt() function returns the cube root of a number. Math.cbrt() function 返回数字的立方根。

Math.cbrt(x) returns y where x is a number and y * y * y = x. Math.cbrt(x) 返回 y,其中 x 是一个数字,y * y * y = x。

For example, cube root of 27 = 3, cube root of 8 = 2.例如,27 的立方根 = 3,8 的立方根 = 2。

Math.cbrt(27) = 3. Here x = 27 and y = 3. So, y * y * y = x. Math.cbrt(27) = 3。这里 x = 27 和 y = 3。所以,y * y * y = x。 So, 3 * 3 * 3 = 27.所以,3 * 3 * 3 = 27。

 console.log(Math.cbrt(8),2); console.log(Math.cbrt(27),3); console.log(Math.cbrt(9),2.080083823051904);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM