# Thread: Solve x^y=0.5 for y.

1. ## [solved] Solve x^y=0.5 for y.

Part of a project I'm working on involves calculating a gamma correction value for a color. My question is: Given x, how do I solve x^y=0.5 for y? I know that 0 < x < 1 and y > 0.

Right now I'm doing a binary search to solve for y, but I'd rather have a direct, exact solution and I can't figure it out.

Thanks!
J

2. ## Re: Solve x^y=0.5 for y.

Originally Posted by jasonc2
Part of a project I'm working on involves calculating a gamma correction value for a color. My question is: Given x, how do I solve x^y=0.5 for y? I know that 0 < x < 1 and y > 0.

Right now I'm doing a binary search to solve for y, but I'd rather have a direct, exact solution and I can't figure it out.
$x^y = \frac12$

$\Rightarrow\ln x^y = \ln\frac12$

$\Rightarrow y\ln x = -\ln2$

$\Rightarrow y = -\frac{\ln2}{\ln x}$

3. ## Re: Solve x^y=0.5 for y.

Awesome, thank you so much! =)

4. ## Re: Solve x^y=0.5 for y.

Originally Posted by Reckoner
$x^y = \frac12$

$\Rightarrow\ln x^y = \ln\frac12$

$\Rightarrow y\ln x = -\ln2$

$\Rightarrow y = -\frac{\ln2}{\ln x}$
Or just \displaystyle \begin{align*} y = \log_{x}{\frac{1}{2}} = -\log_x{2} \end{align*}.

5. ## Re: Solve x^y=0.5 for y.

Thanks. I don't have logx available to use, only ln and log10.