
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
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 Articles
- 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
- How to implement linear classification with Python Scikit-learn?
- C++ Program to Implement Vector
- C# program to implement FizzBuzz
- C++ Program to Implement Trie
- C++ Program to Implement Stack
- C++ Program to Implement Treap
- C++ Program to Implement Dequeue
- C++ Program to Implement Queue
- Java Program to Implement LinkedList
- C program to implement CHECKSUM
- 8085 Program to perform linear search
- C program to compute linear regression

Advertisements