I need to take a root of a number, N being the number, x being the root.
2^(1/x)
^ being a power, not XOR.
I've tried using the POW function, but whenever I try to put a variable as the second argument, it hates me real bad.
#include <stdio.h>
#include <math.h>
int main(int argc, char **argv)
{
double root = 4;
double root_result = 0;
root_result = pow(2,1/root);
printf("%f",root_result);
return 0;
}
Linker error:
untitled.c:(.text+0x34): undefined reference to `pow'
There is probably a better option out there. The only other function I can find is exp
, but those are base e functions, which is not really helpful in my case.
Would something like this work?
exp(log(abs(1))/n))
n being the root I would want.