- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C++ program to implement Inverse Interpolation using Lagrange Formula
In this tutorial, we will be discussing a program to implement Inverse Interpolation using Lagrange formula.
Inverse Interpolation is defined as the method of finding the value of an independent variable from the given value of dependent value lying between two tabulated set of values for an unknown function.
Example
#include <bits/stdc++.h> using namespace std; //structuring the values of x and y struct Data { double x, y; }; //calculating inverse interpolation double calc_invinter(Data d[], int n, double y){ double x = 0; int i, j; for (i = 0; i < n; i++) { double xi = d[i].x; for (j = 0; j < n; j++) { if (j != i) { xi = xi * (y - d[j].y) / (d[i].y - d[j].y); } } x += xi; } return x; } int main(){ Data d[] = { { 1.27, 2.3 }, { 2.25, 2.95 }, { 2.5, 3.5 }, { 3.6, 5.1 } }; int n = 6; double y = 4.5; cout << "Value of x (y = 4.5) : " << calc_invinter(d, n, y) << endl; return 0; }
Output
Value of x (y = 4.5) : 2.51602
- Related Articles
- Lagrange Interpolation
- C++ Program to Implement Interpolation Search Algorithm
- How to implement ‘cubic’ 1-D interpolation using SciPy library?
- C++ Program to Implement Stack using array
- C++ Program to Implement Queue using Array
- C++ Program to Implement Stack using linked list
- C++ Program to Implement Queue using Linked List
- C++ Program to Implement Quick Sort Using Randomization
- C++ Program to Implement String Matching Using Vectors
- C++ Program to Implement Queue Using Two Stacks
- C++ Program to Implement Stack Using Two Queues
- C++ Program to Implement Dijkstra’s Algorithm Using Set
- Program to print Inverse Diamond pattern on C++
- C++ program to implement Run Length Encoding using Linked Lists
- C++ program to find cabs nearby using Great Circle Distance formula

Advertisements