Initial Basics – Algebra – Problem #3
IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive
Problem Statement
Here we will check equivalence between coefficient representation and point-value representation of a polynomial. Consider {{α1, m(α1)}, {α2, m(α2)}, {α3, m(α3)}} from the second part of the assignment. Compute the polynomial m(x) in coefficient representation from the point-value representation (Use the Lagrange interpolation for this purpose). Print m(x) and h(x) in coefficient representation to check whether they are equivalent. If they are not equivalent print an error mes- sage. Lagrange Interpolation: Consider a degree two polynomial f(x). Let {{α1, f(α1)}, {α2, f(α2)}, {α3, f(α3)}} be one point value representation of f(x). Then we can write f(x) as: f(x) = f(α1) ·[(x − α2)(x − α3)]/[(α1 − α2)(α1 − α3)]+ f(α2) ·[(x − α1)(x − α3)]/[(α2 − α1)(α2 − α3)] + f(α3) ·[(x − α1)(x − α2)]/[(α3 − α1)(α3 − α2)]