Asymptotes Fit Function

\(\def\|{&}\DeclareMathOperator{\D}{\bigtriangleup\!} \DeclareMathOperator{\d}{\text{d}\!}\)

\( \newcommand{\Matrix}[1]{\left( \begin{matrix} #1 \end{matrix} \right)} \)

This page explains how to find a function that has two or more predefined non-vertical asymptotes. This doesn't have an immediate astronomical application, but can be usedful if you need a relatively simple approximation formula for a series of values.

Suppose you're looking for a function \( f(x) \) that has two non-vertical asymptotes that intersect in the point \( (x_1,y_1) \) and of which the first asymptote (in ascending order of \( x \)) has slope \( a_1 \) and the second one has slope \( a_2 \).

\begin{eqnarray} A_1(x) \| = \| a_1 (x − x_1) + y_1 \label{eq:def} \\ A_2(x) \| = \| a_2 (x − x_1) + y_1 \\ A(x) \| = \| A_1(x) \| \qquad (x ≤ x_1) \\ A(x) \| = \| A_2(x) \| \qquad (r ≤ x_1) \end{eqnarray}

so \( f(x) \) must approach \( A_1(x) \) ever more closely when \( x \) goes toward −∞, and must approach \( A_2(x) \) ever more closely when \( x \) goes toward +∞.

Also, we want the vertical distance of function \( f(x) \) from the intersection of asymptotes (at \( (x_1, y_1) \)) to be equal to \( d \). How do we arrange that?

We begin by rewriting the asymptote function \( A(x) \) as

\begin{equation} A(x) = p |x − x_1| + s x + t \end{equation}

Then we must have

\begin{eqnarray} a_1 \| = \| s − p \\ a_2 \| = \| s + p \\ A(x_1) \| = \| y_1 \end{eqnarray}

so

\begin{eqnarray} s \| = \| \frac{a_2 + a_1}{2} \label{eq:two} \\ p \| = \| \frac{a_2 − a_1}{2} \\ t \| = \| y_1 − s x_1 \end{eqnarray}

To transform \( A(x) \) into \( f(x) \) we replace \( |x − x_1| \) by \( \sqrt{q + (x − x_1)^2} \):

\begin{equation} f(x) = p \sqrt{q + (x − x_1)^2} + s x + t \end{equation}

The vertical distance of \( f(x) \) from \( A(x) \) at \( x = x_1 \) must be \( d \), so

\begin{eqnarray} |f(x) − A(x)| \| = \| d \\ |p\sqrt{q}| \| = \| d \\ q = \left( \frac{d}{p} \right)^2 \end{eqnarray}

Summarizing:

\begin{eqnarray} f(x) \| = \| p\sqrt{q + (x − x_1)^2} + s (x − x_1) + y_1 \\ p \| = \| \frac{a_2 − a_1}{2} \\ s \| = \| \frac{a_2 + a_1}{2} \\ q \| = \| \left( \frac{d}{p} \right)^2 \end{eqnarray}

For example, which \( f(x) \) has asymptote \( y = x \) for very negative \( x \), has asymptote \( y = 3 \) for very positive \( x \), and has the intersection of asymptotes 2 units above or below \( f(x) \)?

Those asymptotes intersect in \((3,3)\) so \( x_1 = 3, y_1 = 3 \). Moreover, \( a_1 = 1, a_2 = 0, d = 2 \) so

\begin{eqnarray*} p \| = \| \frac{0 − 1}{2} = −\frac{1}{2} \\ q \| = \| \left( \frac{2}{−1/2} \right)^2 = 16 \\ s \| = \| \frac{0 + 1}{2} = \frac{1}{2} \end{eqnarray*}

so

\[ f(x) = −\frac{1}{2}\sqrt{16 + (x − 3)^2} + \frac{1}{2} (x − 3) + 3 \]

And what if we want to have the intersection only 1 unit above or below \( f(x) \)? Then \( d = 1 \) and \( q = 4 \) so

\[ f(x) = −\frac{1}{2}\sqrt{4 + (x − 3)^2} + \frac{1}{2} (x − 3) + 3 \]

And if we want \( f(x) \) to pass through the intersection? Then \( d = 0 \) so \( q = 0 \) and

\begin{split} f(x) \| = −\frac{1}{2}\sqrt{(x − 3)^2} + \frac{1}{2} (x − 3) + 3 \\ \| = −\frac{1}{2}|x − 3| + \frac{1}{2} (x − 3) + 3 \end{split}

All three of these functions are displayed in Figure 1.

Fig. 1: Example with 2 asymptotes

We can add more intersections and in that way have more than two asymptotes. Suppose that we have \( n \) asymptotes, with \( n − 1 \) intersections \( (x_i, y_i) \) (for \( i \) from 1 through \( n − 1 \)) sorted in ascending order of \( x \), so with \( x_i \lt x_{i+1} \). Asymptote 1 applies from \( x = −∞ \) to \( x = x_1 \), asymptote 2 from \( x = x_1 \) to \( x = x_2 \), and so on. Asymptote \( n \) applies from \( x = x_{n−1} \) to \( x = +∞ \).

The \( (x_i, y_i) \) fix all asymptotes except for the first one and the last one. Those two are fixed if we know their slope. We call the slopes of the asymptotes \( a_i \), so the slope of the first asymptote is \( a_1 \) and the slope of the last asymptote is \( a_n \).

The slope of asymptote \( i \) (for \( 2 ≤ i ≤ n − 1\)) is

\begin{equation} a_i = \frac{y_{i+1} − y_i}{x_{i+1} − x_i} \end{equation}

The asymptote function is

\begin{equation} A(x) = \left\{ \sum_i p_i |x − x_i| \right\} + s x + t \end{equation}

where \( \sum_i \) is the sum over \( i \) from 1 through \( n − 1 \).

How do we find \( p_i, s, t \)? We need to have for all \( j \) from 1 through \( n − 1 \) that

\begin{equation} A(x_j) = y_j \end{equation}

so

\begin{equation} \left\{ \sum_i p_i |x_j − x_i| \right\} + s x_j + t = y_j \end{equation}

That yields \( n − 1 \) equation linear in \( p_i, s, t \), but we need two more because we need to determine the value of \( n + 1 \) variables. Fortunately we still have \( a_1 \) and \( a_n \). For \( x \lt x_1 \) we have

\begin{eqnarray} A(x) \| = \| \left\{ \sum_i p_i (x_i − x) \right\} + sx + t \\ A'(x) \| = \| −\left\{ \sum_i p_i \right\} + s \end{eqnarray}

which must be equal to \( a_1 \), so

\begin{equation} a_1 = s − \left\{ \sum_i p_i \right\} \end{equation}

For \( x \gt x_{n−1} \) we have

\begin{eqnarray} A(x) \| = \| \left\{ \sum_i p_i (x − x_i) \right\} + sx + t \\ A'(x) \| = \| \left\{ \sum_i p_i \right\} + s \end{eqnarray}

which must be equal to \( a_n \), so

\begin{equation} a_n = s + \left\{ \sum_i p_i \right\} \end{equation}

Now we have \( n + 1 \) independent linear equations from which we need to deduce the values of \( n + 1 \) variables. That can be done using standard methods from linear algebra.

The solution is:

\begin{eqnarray} p_i \| = \| \frac{1}{2} (a_{i+1} − a_{i}) \| \qquad (1 ≤ i ≤ n − 1) \\ s \| = \| \frac{1}{2} (a_1 + a_n) \\ t \| = \| \frac{1}{2} (y_1 + y_{n−1} − a_1 x_1 − a_n x_{n−1}) \end{eqnarray}

Let's check: If \( n = 1 \) then we find

\begin{eqnarray} p_1 \| = \| \frac{1}{2} (a_2 − a_1) \\ s \| = \| \frac{1}{2} (a_1 + a_2) \\ t \| = \| \frac{1}{2} (y_1 + y_1 − a_1 x_1 − a_2 x_1) = y_1 − sx_1 \end{eqnarray}

just like in Eq. \eqref{eq:two}ff.

We again transform asymptote function \( A(x) \) into the sought function \( f(x) \) by replacing \( |x − x_i| \) with \( \sqrt{q_i + (x − x_i)^2} \):

\begin{equation} f(x) = \left\{ \sum_i p_i \sqrt{q_i + (x − x_i)^2} \right\} + s x + t \end{equation}

We'd like function \( f(x) \) at intersection \( k \) to be at a distance \( d_k \) above or below the asymptote function, but that would mean

\begin{equation} d_k = |f(x_k) − A(x_k)| = \left| p_k \sqrt{q_k} + \left\{ \sum_{i≠k} p_i \left( \sqrt{q_i + (x_k − x_i)^2} − |x_k − x_i| \right) \right\} \right| \label{eq:dtough} \end{equation}

for all \( k \), so then the distance for intersection \( k \) depends also on all other intersections, and that set of equations is not easy to solve for all \( q_k \) ― and perhaps not at all.

We have to make do with a simpler way. For intersection \( k \) we take into account only the contribution of that intersection to \( A(x) \) and \( f(x) \). Then all terms with \( i ≠ k \) drop out and we're left with

\begin{eqnarray} d_k \| = \| |p_k\sqrt{q_k}| \\ q_k \| = \| \left( \frac{d_k}{p_k} \right)^2 \end{eqnarray}

Now \( d_k \) is merely an approximation for the vertical distance between the function and the intersection. If the intersections are widely enough spaced horizontally then the approximation will be good, and otherwise it will be less good.

Let's add an intersection at \( (10,3) \) to the previous example, with vertical distance \( 1 \), and let's give the third asymptote a slope of +1. Then \( d_1 = 2 \) and \( d_2 = 1 \), and

\begin{eqnarray*} x_1 \| = \| 3 \\ y_1 \| = \| 3 \\ x_2 \| = \| 10 \\ y_2 \| = \| 3 \\ a_1 \| = \| 1 \\ a_2 \| = \| \frac{3 − 3}{10 − 3} = 0 \\ a_3 \| = \| 1 \\ p_1 \| = \| \frac{0 − 1}{2} = −\frac{1}{2} \\ p_2 \| = \| \frac{1 − 0}{2} = \frac{1}{2} \\ s \| = \| \frac{1 + 1}{2} = 1 \\ t \| = \| \frac{3 + 3 − 1×3 − 1×10}{2} = \frac{−7}{2} \\ q_1 \| = \| \left( \frac{2}{−1/2} \right)^2 = 16 \\ q_2 \| = \| \left( \frac{1}{1/2} \right)^2 = 4 \end{eqnarray*}

so the asymptote function is

\[ A(x) = \frac{−|x − 3| + |x − 10| − 7}{2} + x \]

and the desired function is

\[ f(x) = \frac{−\sqrt{16 + (x − 3)^2} + \sqrt{4 + (x − 10)^2} − 7}{2} + x \]

The "distances" \( d_1 \) and \( d_2 \) are fairly large, compared to the horizontal distance (7) between the intersections, which keeps \( f(x) \) rather far away from the asymptote function in between the intersections. If we reduce \( d_1 \) and \( d_2 \) by a factor of 3, then we find

\begin{eqnarray*} q_1 \| = \| \left( \frac{2/3}{−1/2} \right)^2 = \frac{16}{9} \\ q_2 \| = \| \left( \frac{1/3}{−1/2} \right)^2 = \frac{4}{9} \\ f(x) \| = \| \frac{−\sqrt{(16/9) + (x − 3)^2} − \sqrt{(4/9) + (x − 10)^2} − 7}{2} + x \end{eqnarray*}

All three functions (\( A(x) \) and the two \( f(x) \)) are displayed in Fig. 2.

Fig. 2: Example with 3 Asymptotes

*//aa.quae.nl/en/reken/asymptootaanpassingsfunctie.html;
Last updated: 2021-07-19
*