Thread: radicals?

    #1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2002
    Posts
    421
    Rep Power
    13

    radicals?


    If I wanted to calculated the radical of 5/4 how would i do that in C++? Not sure of the syntax and I don't believe math.h has a radical function. Thanks.
    -andy
    hmmm...
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2002
    Posts
    421
    Rep Power
    13
    nevermind..im an idiot..its in math.h
    hmmm...
  4. #3
  5. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,255
    Rep Power
    2222
    I'm not sure what you are asking here. By "calculat[ing] the radical", I assume that you want to find any real root of any floating-point value.

    The pow(double x, double y) function in math.h should do it, along with its long double cousin, powl(). They both calculate the value of x raised to the y power.

    Pardon the explanation, but I don't know how far you had gotten in math. To take the n-th root of a number, x, you raise x to the 1/n power. Eg, the square root of x would be pow(x,0.5) and the 10th root of x would be pow(x,0.1).

    Otherwise, you could use the log() and exp() functions:
    x_to_the_n = exp(log(x)/n);


    If I assumed wrong about your question, please let us know.

IMN logo majestic logo threadwatch logo seochat tools logo