Find logarithm fit to two points

178 Views Asked by At

Say I have an equation $f(x) = \log_b(ax+1)$, where $a$ and $b$ are constants. If I have two distinct points $(x_1,y_1)$ and $(x_2, y_2)$, where $x_2 > x_1$ and $y_2 > y_1$, how can I find values for $a$ and $b$ such that $f(x_1) = y_1$, and $f(x_2) = y_2$?

3

There are 3 best solutions below

0
On

Let $y_1=\log_{b}ax_1+1$ and $y_2=\log_{b}ax_2+1$ therefore$$b^{y_1}=ax_1+1\\b^{y_2}=ax_2+1$$then we have $$x_2b^{y_1}-x_1b^{y_2}=x_2-x_1$$ which doesn't have any analytic answer so doesn't for $a$

0
On

First, let’s rearrange things so the only logarithm we use is the natural logarithm.

Given that $y_1=f(x_1)=\log_b(ax_1+1),$ then $y_1 \ln b = \ln(ax_1+1).$ Similarly, $y_2 \ln b = \ln(ax_2+1).$ It follows that

$$ \ln b = \frac{\ln(ax_1+1)}{y_1} = \frac{\ln(ax_2+1)}{y_2}. $$

Let $$ h(t) = \frac{\ln(tx_1+1)}{y_1} - \frac{\ln(tx_2+1)}{y_2}. $$ Find $t$ such that $h(t)=0.$ I think you will have to use numeric methods to do this, since I do not think there is a standard closed form solution. Set $a$ to the value of $t$ that solves this equation.

Once you know $a,$ then you can set $$ b = (ax_1+1)^{1/y_1}. $$

0
On

Starting from Mostafa Ayaz's answer, suppose that $y_2=k y_1$ and let $z=b^{y_1}$ which makes the equation to be $$x_2 z-x_1 z^k=x_2-x_1$$ If $k$ is an integer $\leq 4$, it is at most a quartic equation that you can solve for $z$; then $b=z^{1/y_1}$ and $a=\frac{z-1}{x_1}$.

If $k$ does not fit this condition, only numerical methods will do the job.