You are working on ie_polation function
 
search
 


Contents:


swap function:
Swapping two values to change their addresses.
a

max function:

The largest number among two.
a

absolute value function:

The positive value of a number.
a

sorting function:

How to sort an array.
a

bisection function:

Bissection method used to solve equations by computing, example of cable strung ..
a

Newton-Raphson function:

To solve equations numerically, example of free fall motion ..
a

Secant function:

To solve equations numerically, example of free fall motion ..
a

isPrime function:

This function tests whether an integer is prime..
a

abundant function:

This function tests whether an integer is abundant..
a

factorial function:

Factorial of an integer..
a

quadratic function:

solving a quadratic equation ..
a

even_odd function:

To know if an integer is even or odd ..
a

mean value function:

To calculate the arithmetic mean of some values..
a

reverse function:

To reverse an integer and to know whether a string is palindrome..
a

least squares function :

To calculate the slope and the y_intercept of a linear equation ..
a

Monte Carlo method:

To calculate integrales or probabilities using Monte Carlo technique ..
a

2 and 3 equations systems solving :

To solve the 2 and 3 equations systems with 2 and 3 variables ..
a

Interpolation and Extrapolation :

To solve for lacking values in graphs or tables ..
a

Integer divisors :

Gives the divisors fo an integer and tests whether it is prime ..
a

Amicable pair :

Gives, if it exists, the amicable number of a given integer ..
a

Perfect numbers :

Tests whether a positive integer is perfect, and more ..
a

Periodic table of elements:

Periodic table of elements in C language, and more ..
a

Playing TicTacToe

Using some Fortran90 language funtionalities, and more ..
a


a
home

   Interpolation and extrapolation
Interpolation and extrapolation functions



	1. Definitions

	Using tables or graphs, interpolation is  the method to get values
	knowing others located  between given points. Extrapolation is
	a similar method, but the point whom we solve for values extends beyond
	the given data.

	

	The data x1, y1 of the points P1 and x2, y2 of P2, located on the same line,
	represented by a linear equation y = a x + b are measured. We can write for :
	- an extrapolation: (ye - y2)/(x2 - xe) = (y2 - y1)/(x2 - x1), and for
	- an interpolation: (yi - y1)/(xi - x1) = (y2 - y1)/(x2 - x1)

	Or:
	Knowing xe, xi and solving for ye, yi:
	- extrapolation: ye  = y2 + (x2 - xe)(y2 - y1)/(x2 - x1),
	- interpolation: yi  = y1 + (xi - x1)(y2 - y1)/(x2 - x1)

	Or:
	Knowing ye, yi and solving for xe, xi:

	- extrapolation: xe  = x2 - (ye - y2)(x2 - x1)/(y2 - y1)
	- interpolation: xi = x1 + yi - y1)(x2 - x1)/(y2 - y1)


	2. Example in C language:
	
	#include <stdio.h>
	#include <math.h>

	int main()
	{

	float x1, y1;
	printf("n Enter two coordinates of a point P1: x1 and y1:n");
	scanf("%f %f", &x1,&y1);

	float x2, y2;
	printf("n Enter two coordinates of a point P2: x2 and y2:n");
	scanf("%f %f", &x2,&y2);

	float xi, yi, xe, ye;

	printf("n Enter an x_coordinate xi of a point I(xi,yi) for interpolation:n");
	scanf("%f", &xi);
		yi  = y1 + (xi - x1)*(y2 - y1)/(x2 - x1);
	printf("n Its corresponding y_coordinate yi is %2.3fn",yi);

	printf("n Enter an x_coordinate xe of a point E(xe,ye) for extrapolation:n");
	scanf("%f", &xe);
		ye  = y2 + (x2 - xe)*(y2 - y1)/(x2 - x1);
	printf("n Its corresponding y_coordinate ye is %2.3fn",ye);


	// ----------------------

		printf("n Enter a y_coordinate yi of a point I(xi,yi) for interpolation:n");
	scanf("%f", &yi);
		xi = x1 + (yi - y1)*(x2 - x1)/(y2 - y1);
	printf("n Its corresponding x_coordinate xi is %2.3fn",xi);

	printf("n Enter a y_coordinate ye of a point E(xe,ye) for extrapolation:n");
	scanf("%f", &ye);
		xe  = x2 - (ye - y2)*(x2 - x1)/(y2 - y1);
	printf("n Its corresponding x_coordinate xe is %2.3fn",xe);

	return 0;
	}


	


Custom Search


© 2007. The scientificsentence . All rights reserved.