Interpolation with logaritmic function

258 Views Asked by At

I want to interpolate with the function $$f(x) = a\ln(x+b)+c$$ That is, I assume some sort of logarithmic relationship, but there might be an offset.

I assume that I need 3 datapoints, as there are 3 parameters $a,b,c$. Let's say $f(x_1) = y_1; f(x_2) = y_2; f(x_3) = y_3$. Now I want to determine $a$, $b$ and $c$.

$$ y_1 = a\ln(x_1+b)+c; y_2 = a\ln(x_2+b)+c; y_3 = a\ln(x_3+b)+c $$ Thus $$ a\ln(x_1+b) - y_1 = a\ln(x_2+b) - y_2 = a\ln(x_3+b) - y_3 $$ Thus $$ \frac{\ln(x_1+b) - \ln(x_2+b)}{y_1 - y_2} = \frac{\ln(x_1+b) - \ln(x_3+b)}{ y_1 - y_3} $$ Thus $$ (x_1+b)^{y_3-y_2} \cdot (x_2+b)^{y_1-y_3} \cdot (x_3+b)^{y_2-y_1} = 1$$ Now I am stuck and don't know how to solve this for $b$.

Is my derivation correct?

Is there a solution in closed form?

If not, is it possible to make some assumptions regarding $x_1$ $x_2$ and $x_3$ so that there is a solution in closed form?

Would it be easier, if $b$ was assumed known? (We would need only 2 datapoints in this case.)

1

There are 1 best solutions below

1
On

Your derivation is correct, but not going in the right direction. You should view your three data points as giving you three equations in the three unknowns $ a,b,c$, which you are trying to evaluate. You are correct that you won't get there analytically because of $b$. If you fix $b$, it is easy. You have $y_1-a\log(x_1+b)=y_2-a\log(x_2+b)$, which you can solve for $a$, then get $c$. If you do want to fit for $b$, I would pretend $b$ is fixed, follow the above to get $a,c$, and check the error at your third point. Feed this error function to your favorite root finder to get $b$