# Curve_xfromY

## Description

Get interpolated/extrapolated X value of Curve at specified Y value.

## Syntax

double Curve_xfromY( curvebase * pcrvData, double dY )


## Parameters

pcrvData
[input] Pointer to Curve
dY
[input] Value of Y

## Return

For given Curve returns interpolated/extrapolated value of X at specified value of Y.

Since the function uses extrapolation/interpolation, the out-of-range error will not occur.

## Examples

EX1

// This is a self contained sample program for the function Curve_xfromY,
// Its sample data is created at the beginning of the program.
// To run the program, enter the following command in the Script window:
//   Curve_xfromY_ex1
// It returns like the following two lines, one for interpolation, and the
// other for extrapolation:
//  Find X at y=6.000000 ==> FOUND: x=3.000000
//  Find X at y=20.000000 ==> FOUND: x=10.000000

void Curve_xfromY_ex1()
{
double dXfromY, dY;
Worksheet wks;
wks.Create();
Dataset myXDs(wks,0);
Dataset myYDs(wks,1);

//******* Create sample data *****************
myXDs.SetSize(4);
myYDs.SetSize(4);
myXDs=1;    myYDs=2;
myXDs=2;    myYDs=4;
myXDs=4;    myYDs=8;
myXDs=8;    myYDs=16;
//******** End of Sample Data Creation *******

Curve crvData( myXDs, myYDs );    // Create Curve object

dY=6.0;
dXfromY = Curve_xfromY(&crvData,dY); // Demonstartion of Curve_xfromY
printf( "Find X at y=%f ==> FOUND: x=%f\n",dY,dXfromY);

dY=20.0;
dXfromY = Curve_xfromY(&crvData,dY); // Demonstartion of Curve_xfromY
printf( "Find X at y=%f ==> FOUND: x=%f\n",dY,dXfromY);
}


## Remark

The function used for fitting function parameter initialization.