

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 Linear Extrapolation
In this tutorial, we will be discussing a program to implement Linear Extrapolation.
Extrapolation is defined as a process in which the required value for a certain function is beyond the lower or the upper limits of the function definition.
In the case of Linear Extrapolation, the value beyond the scope is found using the tangent made on the graph of the function to determine the required value. Linear Extrapolation gives quite accurate results when applied.
Example
#include <bits/stdc++.h> using namespace std; //structuring the values of x and y struct Data { double x, y; }; //calculating the linear extrapolation double calc_extrapolate(Data d[], double x){ double y; y = d[0].y + (x - d[0].x) / (d[1].x - d[0].x) * (d[1].y - d[0].y); return y; } int main(){ Data d[] = { { 1.2, 2.7 }, { 1.4, 3.1 } }; double x = 2.1; cout << "Value of y (x = 2.1) : " << calc_extrapolate(d, x) << endl; return 0; }
Output
Value of y (x = 2.1) : 4.5
- Related Questions & Answers
- Java program to implement linear search
- C++ Program to Implement Hash Tables with Linear Probing
- C++ Program to Implement the linear congruential generator for Pseudo Random Number Generation
- 8085 Program to perform linear search
- C program to compute linear regression
- Python Program for Linear Search
- Linear Search in Python Program
- C++ Program to Implement Vector
- C# program to implement FizzBuzz
- C++ Program to Implement Stack
- C++ Program to Implement Dequeue
- C++ Program to Implement Queue
- C++ Program to Implement Treap
- C++ Program to Implement Trie
- Java Program to Implement LinkedList
Advertisements