2
$\begingroup$

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.

1 Answers 1

3

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.$

  • 0
    @Fr$a$ser If problems continue to occur with the Newton iteration, just try bisection.2012-06-13