Hello Astronomy

Automatic translation; Simplified Chinese is the reference text.

If the recording time is not neat, can I still fill in the data in between?

There is no need to forcibly move the record to the hour, so that every real input position can be included in the calculation.

General Algorithms and Numerical Computing

Sometimes you don't record at the same time, and the abscissa of the table may not be sorted. First put them into the graph as they are, and then use Lagrange interpolation; if it happens to be the midpoint of four equally spaced data, there is a simple special formula.

Open interactive lesson →

Guess first

Does Lagrange interpolation require records to be recorded at certain equal intervals?

Show answer and explanation

Not required, but the abscissa cannot be repeated — It directly uses each record's own abscissa, allowing unequal spacing and disordering.

Then connect experience and science

Each record retains its own abscissa

The spacing between points is different, which is not an error; there is no need to sort the input list first.

First read it as different xᵢ and the corresponding yᵢ

Construct a contribution for each point

Each basis function is equal to 1 at its own point and equal to 0 at other known points; after weighted addition, it passes through all known points.

y(x)=Σ yᵢ∏(x−xⱼ)/(xᵢ−xⱼ)

Equally spaced midpoints can be simplified

When four points are equally spaced, the two middle values ​​have a weight of 9, and the outer values ​​have a weight of −1, divided by 16. Not a common average.

y中 = [9(y₂+y₃)−y₁−y₄]/16

Repeated abscissas must be processed first

The same x cannot be subtracted from 0 in the denominator. If the observations give different readings at the same time, you need to decide how to deal with the errors first, and interpolation cannot be applied rigidly.

All xᵢ must be distinct from each other

For each i, the product goes over all j≠i, and the individual yᵢ weighted terms are added. All xᵢ must be different from each other and have the same unit; the four-point midpoint formula is only applicable to its specific equal interval conditions and cannot be used for any scattered points.

give it a try

30° of an unequal sine corresponds to about 43.097% of the position; 50% of the lunar surface is exactly 11h TD, which can be compared with the general interpolation and half-interval formulas.

Take a look at it →

No need to memorize symbols

xᵢ / yᵢ
Each known input and output
Lᵢ(x)
Lagrange basis polynomials
y(x)
Interpolation polynomial through all given points

Algorithm, accuracy and scope of application

Supplementary Chapter 3 3.12 and 3.13: The midpoint weight of four equally spaced samples is (-1,9,9,-1)/16; the unequal Lagrange item-by-item product method allows the input to be out of order, and the x values ​​must be different from each other. The sine table comes from the six-point exercise on printed page 34. The query for 30° is about 0.5; the lunar right ascension is from Example 3.f. When the y unit is seconds relative to 10 hours, the query for 11h yields 1540.0014375s (rounded to 1540.001s in the book). The interface only queries within the given data range and does not extrapolate high-order polynomials as reliable predictions; cubic polynomials in 3.g of the original book are also used for independent verification. No userform input is provided, and the core pure function accepts unequal spaced data and rejects duplicate x's.

my understanding check

If the input list is not sorted by x, is the Lagrange result necessarily wrong?

Won't be wrong just because of disorder — The interpolation weight is calculated from the actual coordinates of each point, regardless of the input order.

Two points have the same x but different y. Can we directly apply the formula?

Can't — The denominator will be zero, and the observational implications of repeated abscissas should be resolved first.

Does passing all samples ensure that distant extrapolation is accurate?

No guarantee — High-order interpolating polynomials do not automatically provide the true physical laws at a distance.

The true position of each record is preserved; unequal intervals can be interpolated, but repeated x and long-distance extrapolation require additional processing.

Jean Meeus · Astronomical Algorithms, 2nd ed. · No. 3 chapter

General Algorithms and Numerical Computing · All interactive courses