solving an equation with $\ln$

89 Views Asked by At

I need to solve this for $q\in\mathbb{Q}$

$$ d\ln\left(\frac{n-(d+1)q}{n-dq}\right)=\ln\left(\frac{q}{n-(d+1)q}\right) $$

where $d$ and $n$ are positive integers.

I first get rid of the $\ln$ using $a\ln(b)=\ln(b^a)$ so I get

$$ \left(\frac{n-(d+1)q}{n-dq}\right)^d=\frac{q}{n-(d+1)q} $$

then I use the variable change $q=\alpha\cdot\frac{n}{d+1}$ to get rid of the $n$ and I obtained

$$ \left(\frac{(d+1)(1-\alpha)}{d(1-\alpha)+1}\right)^d=\frac{\alpha}{(d+1)(1-\alpha)} $$

And now I need to solve it for $\alpha$. but I don't know what else should I do.

2

There are 2 best solutions below

3
On BEST ANSWER

You can make the problem looking (at least) simpler defining $$\frac q{n - dq}=x \implies q=\frac{n x}{1+d x}$$ which makes the equation to become $$(d+1)\log(1-x)=\log(x)$$In the most general case, as John Glenn answered, you will need a numerical method.

Consider that you look for the zero of function $$f(x)= (d+1)\log(1-x)-\log(x)$$ $$f'(x)=-\frac{d+1}{1-x}-\frac{1}{x}$$ So, Newton iterates will be given by $$x_{k+1}=x_k+\frac{(d+1) \log (1-x_k)-\log (x_k)}{\frac{d+1}{1-x_k}+\frac{1}{x_k}}$$ An interesting point is that $f\left(\frac{1}{2}\right)=-d \log (2)$; so, if $d>0$ the solution will be between $0$ and $\frac{1}{2}$.

For ilustration purposes, let us try using $d=\pi$ and apply Newton method using $x_0=\frac{1}{2}$. Since $f''\left(\frac{1}{2}\right)=-4d$, $f\left(\frac{1}{2}\right) \times f''\left(\frac{1}{2}\right)=4d^2\log(2) >0$ and, by Darboux theorem, we should reach the solution without any overshoot.

For this specific case, Newton iterates will then be $$\left( \begin{array}{cc} k & x_k \\ 0 & 0.5000000000 \\ 1 & 0.2882381747 \\ 2 & 0.2705572670 \\ 3 & 0.2706324735 \\ 4 & 0.2706324752 \end{array} \right)$$ which is the solution for ten significant figures.

In fact, instead of $\frac 12$ as a starting guess, you could use $$x_0^{(1)}=\frac 12 -\frac{d \log (2) }{2 (d+2)}$$ which corresponds to the first iterate of Newton method or $$x_0^{(2)}=\frac 12 -\frac{d (d+2) \log (2)}{2 (d+2)^2-d^2 \log (2)}$$ which corresponds to the first iterate of Halley method.

Once you solved for $x$, go back to $q=\frac{n x}{1+d x}$.

Edit

You could be amazed (as I have been) by the fact that, for $d>0$, a quick and dirty regression of the model $$x=\frac{1}{2 (1+\alpha\, d^{\beta })}$$ gives very good results $(R^2=0.999907)$ $$\begin{array}{clclclclc} \text{} & \text{Estimate} & \text{Standard Error} & \text{Confidence Interval} \\ \alpha & 0.312957 & 0.000692 & \{0.311597,0.314318\} \\ \beta & 0.850644 & 0.001303 & \{0.848084,0.853204\} \\ \end{array}$$ For the test example $(d=\pi)$, it would give $x=0.273422$ while the exact solution was $0.270632$.

For $d=98.765$, it would give $0.030182$ while the exact solution would be $0.033476$.

Using this empirical formula for generating the initial guess $x_0$, Newton method would converge in a couple of iterations.

0
On

As mentioned in the comments, there probably is no analytic solution. But you can always use a numerical method like NR to solve it.

Given: $$f(q):=d \log \left(\frac{n-(d+1) q}{n-d q}\right)-\log \left(\frac{q}{n-(d+1) q}\right)$$

You can numerically solve for $q$ using the recurrence relation: $$\begin{align} q_{n+1}&=q_n-\frac{f(q_n)}{f'(q_n)}\\ &=q_n-\frac{d \log \left(\frac{n-(d+1) q_n}{n-d q_n}\right)-\log \left(\frac{q_n}{n-(d+1) q_n}\right)}{-\frac{n^2}{q_n (d q_n-n) (d q_n-n+q_n)}}\\ &=\frac{q_n \left(d \left(-n (2 d q_n+q_n)+d (d+1) q_n^2+n^2\right) \log \left(\frac{d q_n-n+q_n}{d q_n-n}\right)-\left(-n (2 d q_n+q_n)+d (d+1) q_n^2+n^2\right) \log \left(\frac{q_n}{-d q_n+n-q_n}\right)+n^2\right)}{n^2} \end{align}$$