Given task is to find the value of x for a given y of an unknown function y = f(x) where values of some points (x, y) pairs are given.
Let, y = f(x) be an unknown function where x in an independent variable.
For different values of x, say values of respective given.
The process of finding the value of the independent variable x for a given value of y lying between two tabulated values with the help of the given set of observation for an unknown function is known as Inverse Interpolation.
This is often used to check whether the correctness of output y for an unknown function f i.e how much argument x for this output y differs from the original input.
The problem of inverse interpolation can be solved using Lagrange’s Formula.
The formula for inverse interpolation is similar to interpolation formula but few changes.
Here to solve the problem of inverse interpolation the places of x and y are interchanged. The formula for inverse interpolation is:
This method can even be used when the points are unequally spaced. Here x is expressed as a function of y.
Input: Find the value of x where y = 4.5 and the given points are:
Explanation: Here num of data points given = 4 and y = 4.5
So, putting the values of all x and y in the inverse interpolation formula given above we get,
From here we get,
The value of x = 2.79501 where the value of y = 4.5
Here, data is a list of points consisting of x and y and n is the num of data points.
STEP – 1 : Initialize the final value x = 0
STEP – 2 : FOR i = 1 to n do
STEP – 3 : Initialize xi = data[i].x
STEP – 4 : FOR j = 1 to n do
STEP – 5 : IF i != j do
STEP – 6 : Multiply xi by ( y – data[j].y ) and divide by ( data[i].y – data[j].y )
STEP – 7 : Add xi to x
STEP – 8 : Return final value of x
STEP – 9 : END
Value of x at y = 4.5 : 2.79501
Complexity: The time complexity of the given solution is O(n^2) and space complexity is O(1)
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Lagrange's Interpolation
- Program for Stirling Interpolation Formula
- Newton's Divided Difference Interpolation Formula
- Lagrange's four square theorem
- Print first n Fibonacci Numbers using direct formula
- Roots of the quadratic equation when a + b + c = 0 without using Shridharacharya formula
- Newton Forward And Backward Interpolation
- Bessel's Interpolation
- Section formula (Point that divides a line in given ratio)
- Haversine formula to find distance between two points on a sphere
- Legendre's formula (Given p and n, find the largest x such that p^x divides n!)
- Chinese Remainder Theorem | Set 2 (Inverse Modulo based Implementation)
- Adjoint and Inverse of a Matrix
- Fast method to calculate inverse square root of a floating point number in IEEE 754 format
- Modular multiplicative inverse from 1 to n
- Fast inverse square root
- Decimal Equivalent of Gray Code and its Inverse
- Find sum of inverse of the divisors when sum of divisors and the number is given
- Find the value of P and modular inverse of Q modulo 998244353
- Check if the given array is same as its inverse permutation
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.