Cube root

  • Thread starter Thread starter Brock
  • Start date Start date
B

Brock

I routinely use sqrt(x) for getting a cube root in vb.net. does anyone
know of a way of getting the cube root? I tried cbrt(x) and that
didn't work.
thanks!
 
Maybe there's built-in VB function to do this but here's how I'd do it.

dblCubeRoot = dblNumber ^ (1/3)

You can change '3' to be whatever root you're trying to get. Ex: (1/2)
would give you the square root.
 
AMercer said:
the cube root of positive x is
x ^ (1 / 3)

Ahem! :-) The /real/ cube root of x is x^(1/3).

Console.WriteLine( -8 ^ (1 / 3)) correctly gives -2. The complex roots are,
of course, beyond my brain this early in the morning.

Andrew
 
Console.WriteLine( -8 ^ (1 / 3)) correctly gives -2.

The minus sign applies to the entire expression; it needs to apply to 8.
(-8) ^ (1 / 3) is NAN.
 
Back
Top