Cube root

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brock

    Cube root

    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!
  • =?Utf-8?B?QU1lcmNlcg==?=

    #2
    RE: Cube root

    the cube root of positive x is
    x ^ (1 / 3)

    "Brock" wrote:
    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!
    >

    Comment

    • jch

      #3
      Re: Cube root

      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.


      Brock wrote:
      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!

      Comment

      • Andrew Morton

        #4
        Re: Cube root

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

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

        Andrew


        Comment

        • =?Utf-8?B?QU1lcmNlcg==?=

          #5
          Re: Cube root

          Console.WriteLi ne( -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.

          Comment

          • Andrew Morton

            #6
            Re: Cube root

            AMercer wrote:
            >Console.WriteL ine( -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.
            <blush>

            Andrew


            Comment

            Working...