Initial Basics – Algebra – Problem #3

IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive

Difficulty: Hard

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)]

Back to Lab Problems
Initial Basics/Algebra/Problem #3

Lab Problem Statement

Specifications & Problem DetailsIIT Kharagpur PDS Archive
Loading question...

Interactive C Compiler · Problem #3

WASM In-Browser

Runs directly on your machine · Zero remote server dependency

Compiler downloads on first Run (large, saved in your browser after that)
main.cCtrl + Enter to run
1
2
3
4
5
6
7
Input (stdin)given to scanf / cin
Output

Output appears here. Press Run to compile and execute.