Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

How would one find a real value for $x$ that satisfies

$$\tau=\log_x\left(\frac{x+1}{2}\right),$$

given $0 < \tau < 1$ and $\tau \neq \frac{1}{2}$

(PS I'm not that good with math, so if this is impossible, please explain it to me like I'm 5). I don't need an exact solution, just a method of estimating one. Thanks!

Context:

I'm trying to create a nonlinear slider for the UI in a program I'm writing. I want to be able to specify the logarithmic scale by specifying the what the output value should be at the midpoint. If I map all the values into a (0,1) range, I need to find an invertible function $f(y)$ such that $0 < \tau < 1$, $f(0) = 0$, $f(1) = 1$, $f(\frac{1}{2}) = \tau$, and $f'(y) > 0$ for all $0 < y < 1$, which also has a nice curve so it doesn't seem jumpy to the user. I realized one such function is:

$$f(y) = \log_\alpha\left(1+y\left(\alpha-1\right)\right)$$

Now I just need to find the base $\alpha$ given the midpoint $\tau$, which is where all this comes in. I'm not 100% sure my reasoning on this is correct, but it seems like a plausible starting point.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

There is no algebraic method to find $x$ but we can approximate it well.

Using the change of base rule for logs, we see $$\log_x \left( \frac{x+1}{2} \right) = \frac{ \ln \left( \frac{x+1}{2} \right)}{\ln x}$$ so if we rearrange, we get the equation $$ \tau \ln x - \ln \left( \frac{x+1}{2}\right) =0.$$

The reason I rewrote it in this because now we have a root finding problem, which is well studied. In particular, we want to find a value $x$ such that $f(x)=0$ where $f$ is defined by $f(z) = \tau \ln z - \ln \left( \frac{z+1}{2}\right).$ There are many ways to find the roots of a function, the simplest examples being the Bisection Method and the Newton-Raphson method.

For this particular problem, $f$ is quite well behaved and has a simple derivative, so trying Newton-Raphson isn't a bad idea. We compute $f'(x) =\displaystyle \frac{\tau}{x}-\frac{1}{x+1}.$

So Newtwon-Raphson iteration gives $$x_{n+1}= x_n - \frac{ \tau \ln x_n - \ln \left( \frac{x_n+1}{2}\right)}{\frac{\tau}{x_n}-\frac{1}{x_n+1}} .$$

As for an initial estimate, for $0<\tau<1,$ $x_0=2$ isn't a bad start. So once you specify $\tau$ you can start approximating $x.$

share|improve this answer
    
Thanks for your answer! You sort of lost me at the second part, but I'll see what Google turns up for "Newtwon-Raphson iteration" :-) –  OverMachoGrande Jun 13 '12 at 13:23
    
@Fraser What accuracy do you require $x$ to? If you only need around 4 or 5 decimal places then I'd recommend the Bisection method - it is more stable and easier to implement/understand. –  Ragib Zaman Jun 13 '12 at 13:24
    
@Fraser Also, in practice is your $\tau$ going to be (hopefully) between say 0.1 and 0.9? Or is it essential that $\tau$ can be quite close to 0 or 1? Because then this problem becomes difficult, the value of $x$ which solves the problem becomes huge if $\tau$ is near $1$ (eg if $\tau=0.98, x\approx 10^{15}$) and extremely small if $\tau$ is near 0 (eg $\tau=0.01, x\approx 10^{-31}$). So computers will find it very hard to find $x$ to any decent accuracy. Perhaps another choice for your function or another approach would be more viable. –  Ragib Zaman Jun 13 '12 at 13:31
    
I tried implementing the equation you gave and it always goes to 1, usually in a few iterations. I'll check if everything is going right. Yes, the $\tau$ will usually be between 0.1 and 0.9, at least for now. –  OverMachoGrande Jun 13 '12 at 13:50
    
@Fraser If problems continue to occur with the Newton iteration, just try bisection. –  Ragib Zaman Jun 13 '12 at 14:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.