Interpolation / Point Fitting onto a Logarithmic Line Segment

Interpolation / Point Fitting onto a Logarithmic Line Segment
$\begingroup$

I have figure which is logarithmic scale on both axis. There's a line on that figure, I know two points on that line and want to interpolate a third point on that line based on the two known points.

(What you see basically is a curve which is constituted of linear segments. I'll only do interpolation within such a linear segment, knowing the two boundary points of the segment. The input value (flow) is on the $y$ axis, and I'm looking for the $x$ value related to that.

There's a linear interpolation (by computing fractions), but my recent try on logarithmic interpolation sometimes produces worse results than the linear one. Disappointing.

First I tried to follow which was a disaster.

Then I tried to think (My Take: on the Google Drawing). What am I missing? The outcome is close to the curve, but I want an interpolation which fits a point spot on to the line segment. Mathematically that should be possible.

I feel like I'm missing an logarithmic/exponential part somewhere, but I don't know where.

My Take if the two end point of the line segment is $(x_1, y_1)$ and $(x_2, y_2)$, the measurement $y_3$, and I want to know $x_3$ (see Google Drawing): \begin{align} y_1 &= 10^{ax_1 + b}\\ y_2 &= 10^{ax_2 + b}\\ \log(y_1) &= ax_1 + b \\ \to b &= \log(y_1) - ax_1\\ \log(y_2) &= ax_2 + b \\ \to a &= \frac{\log(y_2) - b}{x_2}\\ &= \frac{\log(y_2) - (\log(y_1) - ax_1)}{x_2}\\ a &= \frac{\log(y_2) - \log(y_1) + ax_1}{x_2}\\ ax_2 - ax_1 &= \log(y_2) - \log(y_1)\\ a &= \frac{\log(y_2) - \log(y_1)}{x_2 - x_1}\\ y_3 &= 10^{ax_3 + b}\\ x_3 &= \frac{\log(y_3) - b}{a} \end{align}


@John pointed to the right direction and the Wiki article helped. The difference is that I'm looking for $x_3$. So the

$$y_3 = y_1 * \left(\frac{x_3 }{ x_1}\right) ^ m$$

equation transforms to:

$$x_3 = x_1 * \left(\frac{y_3 }{ y_1}\right) ^ {1/m}$$

$\endgroup$
2

1 Answer

$\begingroup$

I think you're using the wrong form of the base equation.

From

the relationship should be of the form $y = a * x ^ k$. Working through the "Finding the Function from the Log-Log Plot" section of the wiki page, I found that calculating

$$ k = \frac{\log_{10}(y_2 / y_1) }{ \log_{10}(x_2 / x_1)} $$

Allowed me to return

$$y_3 = y_1 * \left(\frac{x_3 }{ x_1}\right) ^ m$$

which looks correct on my graphs. Sorry for the formatting. Hope that helps. The math on the wiki is much more insightful than this answer.

$\endgroup$
4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

James H. Sterling
Author

James H. Sterling

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.