Welcome to Approximations to Functions!

Hi there! Welcome to one of the most practical chapters in Numerical Methods. In the real world, scientists and engineers rarely have a perfect formula like \(y = x^2\). Instead, they usually have a list of data points—like the temperature of a chemical reaction recorded every ten minutes.

In this chapter, we are going to learn how to find a polynomial that passes exactly through those points. This allows us to "fill in the gaps" (interpolation) or predict what might happen next. Don't worry if the formulas look a bit long at first; once you see the patterns, they are actually quite repetitive and easy to follow!

1. The Foundation: What are we doing?

Imagine you have three dots on a piece of paper. There are infinitely many wiggly lines you could draw through them, but there is only one specific quadratic (a degree 2 polynomial) that hits all three perfectly. Our goal is to find the equation of that line using two clever methods: Newton’s Forward Difference and Lagrange’s Polynomial.

2. Newton’s Forward Difference Interpolation

This method is your best friend when your data points are spaced out equally. If your x-values are, for example, 1, 2, 3, 4... then this is the method for you!

The Difference Table

Before using the formula, we create a Difference Table. This is just a way of seeing how the y-values change.

First Differences (\(\Delta f(x)\)): Subtract the first y-value from the second, the second from the third, and so on. \( \Delta f(x) = f(x + h) - f(x) \).
Second Differences (\(\Delta^2 f(x)\)): Subtract the first differences from each other.
The Magic Rule: If you have a polynomial of degree \(n\), the \(n^{th}\) differences will be constant. For example, in a quadratic (\(x^2\)), the second differences are always the same!

The Formula

To find the value of a function at a point \(x\), we use:
\( f(x) = f(x_0) + \binom{p}{1}\Delta f(x_0) + \binom{p}{2}\Delta^2 f(x_0) + ... \)
Where \( p = \frac{x - x_0}{h} \). Here, \(h\) is the "step size" (the gap between x-values).

Quick Trick: Think of \(p\) as "how many steps am I away from the start?" If you want to find the value at \(x=1.5\) and your table starts at \(x=1\) with gaps of \(1\), then \(p\) is \(0.5\).

Did you know? This method was used heavily by astronomers in the 17th century to predict where planets would be without having to do massive calculations every single time!

Common Mistake to Avoid:

Check your intervals! Students often try to use Newton’s method when the x-values have different gaps (e.g., \(x = 1, 2, 5, 10\)). This only works if the gaps are identical. If they aren't, you must use the Lagrange method instead.

Key Takeaway: Newton’s method uses a difference table to "build" a polynomial step-by-step. It only works for equally spaced data.

3. Lagrange’s Interpolating Polynomial

If Newton’s method is a "step-by-step" builder, Lagrange’s method is a "custom-fit" suit. It works for any set of points, no matter how weird the gaps between the x-values are.

How it works (The Analogy)

Imagine you have three points: A, B, and C. Lagrange’s method creates three separate mini-polynomials:
1. One that equals the y-value of A at point A, but is zero at B and C.
2. One that equals the y-value of B at point B, but is zero at A and C.
3. One that equals the y-value of C at point C, but is zero at A and B.
When you add them all together, you get a curve that hits all three points perfectly!

The Pattern

For three points \((x_0, y_0), (x_1, y_1), (x_2, y_2)\), the formula is:
\( L(x) = y_0 \frac{(x - x_1)(x - x_2)}{(x_0 - x_1)(x_0 - x_2)} + y_1 \frac{(x - x_0)(x - x_2)}{(x_1 - x_0)(x_1 - x_2)} + y_2 \frac{(x - x_0)(x - x_1)}{(x_2 - x_0)(x_2 - x_1)} \)

Don't worry if this seems tricky! Just remember the "Ignore Me" Rule:
In the top of each fraction, use every \(x\) value except the one that matches the \(y\) out front. For example, if you have \(y_0\) out front, don't use \(x_0\) in the top brackets. In the bottom, you just replace the \(x\) from the top with that "ignored" value.

Quick Review: When to use which?

Newton: Use when the x-values are 1, 2, 3, 4 (Equal gaps). It's faster to calculate by hand if you have many points.
Lagrange: Use when the x-values are 1, 2, 5, 12 (Unequal gaps). It’s also easier to write down the whole polynomial in one go.

Key Takeaway: Lagrange polynomials are built by adding up terms that "turn on" at specific data points and "turn off" at others. They work for any spacing.

4. Accuracy and Errors

In Numerical Methods, we always care about how "wrong" we might be.
Error = Approximate Value - Exact Value

• Polynomials are great at approximating smooth curves (like \(e^x\) or \(\sin(x)\)).
• However, the further you get from your known data points (extrapolation), the more "wild" the polynomial can become. Always try to stay within the range of your data!

Summary Checklist

• Can I build a difference table? (Subtracting y-values correctly).
• Do I know the degree? (If the 3rd differences are constant, it's a cubic).
• Can I use the "Ignore Me" rule for Lagrange? (Pattern matching is key!).
• Am I using the right method? (Equal gaps = Newton; Any gaps = Lagrange).

You've got this! Approximating functions is just about finding the right pattern to connect the dots. Keep practicing those table subtractions, and the rest will fall into place.