CSC212 Numerical Method

Numerical MethodUnit 1011 min read

Numerical Techniques for Polynomials: Roots, Evaluation & Special Functions

Unit 10 of Numerical Method covers polynomial root-finding (Newton-Raphson, bisection), Horner’s rule for efficient evaluation, finite differences for derivatives, and least-squares curve fitting—essential tools for approximating solutions to polynomial equations and tabulated data.

TAKEAWAYS

  • Root-finding methods (Newton-Raphson, bisection) iteratively approximate polynomial roots, with Newton’s method requiring derivatives and bisection guaranteeing convergence if bracketing is correct.
  • Horner’s rule rewrites polynomials as nested multiplication for faster evaluation (O(n) time) and is foundational for root-finding algorithms.
  • Finite differences approximate derivatives of tabulated functions using forward/backward/central difference formulas, with error proportional to or .
  • Least-squares fitting minimizes error for overdetermined systems (e.g., linear regression ) by solving normal equations .
  • Special functions (e.g., Bessel, Legendre) often require numerical evaluation via series expansions or recurrence relations, with truncation errors controlled by term limits.
  • Extrapolation vs. interpolation: Extrapolation predicts beyond given data points (risky) while interpolation fits within them; Lagrange and Newton polynomials are common tools.

1. Polynomial Root-Finding Methods

Polynomial equations often lack analytical solutions, so numerical methods approximate roots iteratively. Two key techniques appear in exams:

1.1 Bisection Method

Definition: A bracketing method that repeatedly halves an interval where (sign change guarantees a root by Intermediate Value Theorem).

Algorithm:

  1. Choose such that .
  2. Compute midpoint .
  3. If , return .
  4. Else, replace or with based on or sign, and repeat.

Worked Example: Find a root of to 3 significant figures.

  • Step 1: Find bracket: , . Sign change → root in .
  • Step 2: Iterate:
    • , → new bracket .
    • , → .
    • , → .
    • , → .
    • Stop: → root ≈ 1.66.

Advantages/Disadvantages:

Pros Cons
Guaranteed convergence if bracketing is correct. Slow (linear convergence).
No derivative needed. Requires initial bracket.

Mermaid Diagram: Bisection Method Flow

flowchart TD
    A["Start: Choose [a,b] with P(a)P(b) < 0"] --> B["Compute c = (a+b)/2"]
    B --> C["Check |P(c)| < tolerance?"]
    C -->|Yes| D["Return c as root"]
    C -->|No| E["Update bracket:"]
    E --> F["If P(c)P(a) < 0, set a = c"]
    E --> G["Else set b = c"]
    F --> B
    G --> B

1.2 Newton-Raphson Method

Definition: Uses the tangent line at to approximate the root: Requirements: must exist, and initial guess must be close to the root.

Worked Example: Find a real negative root of .

  • Step 1: Guess .
  • Step 2: Compute .
  • Step 3: → .
  • Step 4: .
  • Iterate:
    • .
    • .
    • Converged: (true root ≈ ).

Advantages/Disadvantages:

Pros Cons
Fast (quadratic convergence near roots). Requires and good initial guess.
Works for nonlinear equations. May diverge if is poor.

Comparison Table:

Method Convergence Rate Needs Derivative? Guaranteed Convergence? Initial Guess Sensitivity
Bisection Linear No Yes (if bracketed) Low
Newton-Raphson Quadratic Yes No High

2. Polynomial Evaluation: Horner’s Rule

Definition: Rewrites as nested multiplication: Advantages:

  • Reduces multiplications from to .
  • Minimizes rounding errors.

Worked Example: Evaluate at using Horner’s rule.

  • Step 1: Rewrite as .
  • Step 2: Compute:
  • Result: .

Algorithm:

def horner(p, x):
    result = 0
    for coeff in reversed(p):  # p = [a_n, ..., a_0]
        result = result * x + coeff
    return result

Mermaid Diagram: Horner’s Rule Evaluation

flowchart TD
    A["Initialize: result = 0"] --> B["For each coefficient from a_n to a_0:"]
    B --> C["result = result * x + coeff"]
    C --> D["Return result"]

3. Finite Differences for Derivatives

For tabulated functions , derivatives are approximated using:

3.1 Forward Difference

3.2 Central Difference

3.3 Second Derivative

Worked Example: Given at with , estimate using central difference ():

Algorithm for :

def central_diff(f, x, h):
    return (f(x + h) - f(x - h)) / (2 * h)

4. Least-Squares Curve Fitting

Fits a model to data by minimizing .

4.1 Linear Regression ()

Solve the normal equations:

Worked Example: Fit to (from past exam).

  • Compute sums:
  • Solve:
  • Solution: , → .

Mermaid Diagram: Least-Squares Steps

flowchart TD
    A["Given data (x_i, y_i)"] --> B["Choose model (e.g., y = a + bx)"]
    B --> C["Compute sums: n, Σx, Σy, Σx², Σxy"]
    C --> D["Form normal equations Aβ = B"]
    D --> E["Solve for β (coefficients)"]
    E --> F["Return fitted model"]

5. Special Functions and Numerical Evaluation

Special functions (e.g., Bessel , Legendre ) often require numerical methods:

5.1 Series Expansions

  • Bessel Function (first kind): Truncate at where terms .

  • Legendre Polynomials: Recurrence relation:

Worked Example: Approximate using 3 terms:


6. Interpolation vs. Extrapolation

Interpolation Extrapolation
Fits data within given range. Predicts beyond given data.
Stable (error bounded). Unstable (error grows).
Example: Lagrange polynomials. Example: Predicting from .

Lagrange Interpolation Example: Given , find : At :


Exam Tip

  1. Root-Finding:

    • For Newton-Raphson, always show the derivative calculation and iteration steps.
    • For bisection, justify the initial bracket and show convergence to required precision (e.g., 3 significant figures).
    • Common Pitfall: Forgetting to check for bisection or for Newton-Raphson.
  2. Horner’s Rule:

    • Rewrite the polynomial in nested form before evaluation.
    • Exam Trick: If asked to evaluate a polynomial at multiple points, use Horner’s rule to avoid recomputing powers.
  3. Finite Differences:

    • Use central differences for better accuracy unless at endpoints (use forward/backward).
    • Formula Sheet: Memorize the and error terms.
  4. Least-Squares:

    • Set up the normal equations correctly (transpose matrices).
    • For linear regression, solve the 2×2 system by substitution or Cramer’s rule.
    • Shortcut: Use the formulas:
  5. Special Functions:

    • For series expansions, show the first 2–3 terms and the truncation error.
    • For recurrence relations, write out the first few terms explicitly.
  6. Interpolation:

    • For Lagrange, use the product form and simplify before substituting .
    • Warning: Extrapolation is unreliable—only interpolate within the data range.
  7. Numerical Integration (Bonus):

    • Although primarily in Unit 6, Simpson’s 1/3 and 3/8 rules often appear here. For tabulated data:
      • Simpson’s 1/3: Requires even number of intervals ( even).
      • Simpson’s 3/8: Uses 3 intervals ( divisible by 3).
    • Worked Example: For , (even) → use Simpson’s 1/3: Here, :

Final Checklist for Exams:

  • For root-finding, show all iterations until convergence.
  • For Horner’s rule, rewrite the polynomial in nested form.
  • For least-squares, verify the normal equations before solving.
  • For interpolation, substitute carefully into the Lagrange formula.
  • For numerical integration, count intervals to choose the correct Simpson’s rule.

Based on the TU BSc CSIT syllabus for Numerical Method (CSC212), unit 10.

Discussion

Loading…