10

I must have a mental block, but I simply can't find the reverse of this math function:

x = pow(y, 5);

I have x and 5, how do I find y ?

Here is a snip of my current code:

+(float) linearVolumeToVolumeCurve:(float)volume
{
    return pow(volume, 5);
}

+(float) volumeCurveToLinearVolume:(float)volume
{
    return ???
}
Benjamin
  • 618
  • 2
  • 6
  • 17
  • 3
    I guess it called root of nth power. – Victor Sorokin Feb 16 '12 at 10:05
  • 1
    Nope, it would be a logarithm if the base were 5 and the exponent were the y. –  Feb 16 '12 at 10:05
  • I knew I could count on you all here on StackOverflow! Thank you all for all the answers! – Benjamin Feb 16 '12 at 10:21
  • @H2CO3 nope, it'd be logarithm if it was `x = pow(5,y)`, realized that after spending 20 minutes writing an answer about logarithm definition :) – Vyktor Feb 16 '12 at 10:34
  • 1
    Haven't I said that? pow(5, y) means 5 is the base, y is the exponent. see my 1st comment. –  Feb 16 '12 at 10:56
  • 2
    @H2CO3, but the question is NOT to invert pow(5,Y), but pow(y,5). So your comment is not at all relevant to the question at hand. You might as well have told us that Mr Green did it, in the library, with the lead pipe, but again, it would not be relevant. –  Feb 16 '12 at 15:07
  • Slightly related question: http://stackoverflow.com/questions/4016213/whats-the-opposite-of-javascripts-math-pow – wip Feb 06 '14 at 03:52

5 Answers5

20

Try this (pseudo-code): y = pow (x, 1.0 / 5);

Victor Sorokin
  • 11,878
  • 2
  • 35
  • 51
  • 2
    wrong, 1/5 will evaluate to 0 because it's integer division (no matter the 'pow' function takes a double). –  Feb 16 '12 at 10:05
  • 6
    @H2CO3 I've mention that it's pseudo-code -- I don't know Objective C. Though, have to admin it's pretty obvious thing for any C-derived language. – Victor Sorokin Feb 16 '12 at 10:06
8

You have to find the 5th root of y, which is the 1/5th power:

return pow(volume, 1.0/5);
5

Try this

Y=Math.Log(x) / Math.Log(5)
Sagar
  • 399
  • 4
  • 11
  • This does not work for me. But Math.Pow(x,0.333333333333333D) does work to get a reverse of a power of 3. – Krythic Apr 26 '18 at 18:38
1

E.g.:

5 = pow(y, 5);

=>

   double y = pow(5, (1.0 / 5.0));
Jeb
  • 3,689
  • 5
  • 28
  • 45
0

you can use this.

if x=y^5

then y =x^1/5 means y=x^0.2

+(float) volumeCurveToLinearVolume:(float)volume
{
    return powf(volume, 0.2);
}
Mudit Bajpai
  • 3,010
  • 19
  • 34