##### Spotlight todayNovember 11, 2019

# Calculating Polynomial Interpolation Coefficients

Numerical Analysis Owner todayApril 17, 2019 21 share close

The interpolation of a dataset can be examined by polynomials, which is nice because polynomials are useful for complex curves approximations. In order to get the coefficients of the polynomial, since the dataset points are known, the below InterpolatingPolynomialCoefficients method can be used. This takes in a double array of tabulation points and polynomial points.

[cpp]
public: virtual Double __gc* InterpolatingPolynomialCoefficients(Double __gc* tabPoints __gc [], Double __gc* polyPoints __gc []) __gc []
{
Int32 __gc* length = Math::Min(tabPoints->Length, polyPoints->Length);
Double __gc* tempArray __gc [] = __gc new Double __gc*[length];
Double __gc* returnArray __gc [] = __gc new Double __gc*[length];
try
{
for (Int32 __gc* i = 0; (i < length); i++)
{
tempArray[i] = returnArray[i] = 0;
}
tempArray[(length – 1)] = -tabPoints;
PushToTempArray(tabPoints, length, tempArray);
PushToFinalArray(tabPoints, polyPoints, length, tempArray, returnArray);
}
catch (ArithmeticException __gc* exception)
{
}
return returnArray;
}

private: static void __gc* PushToFinalArray(Double __gc* tabPoints __gc [], Double __gc* polyPoints __gc [], Int32 __gc* length, Double __gc* tempArray __gc [], Double __gc* returnArray __gc [])
{
for (Int32 __gc* calcHold = 0; (calcHold < length); calcHold++)
{
Double __gc* lengthHold = length;
Int32 __gc* index = (length – 1);
while ((index >= 1))
{
lengthHold = ((index * tempArray[index]) + (tabPoints[calcHold] * lengthHold));
index–;
}
Double __gc* poolArrayAndHold = (polyPoints[calcHold] / lengthHold);
Double __gc* iArray = 1;
for (index = (length – 1); (index >= 0); index–)
{
returnArray[index] += (iArray * poolArrayAndHold);
iArray = (tempArray[index] + (tabPoints[calcHold] * iArray));
}
}
}
private: static void __gc* PushToTempArray(Double __gc* tabPoints __gc [], Int32 __gc* length, Double __gc* tempArray __gc [])
{
for (Int32 __gc* i = 1; (i < length); i++)
{
IntPtr __gc* x;
for (Int32 __gc* calcHold = ((length – 1) – i); (calcHold < (length – 1)); calcHold++)
{
tempArray[calcHold] -= (tabPoints[i] * tempArray[(calcHold + 1)]);
}
tempArray[*static_cast<__box Int32*>(x = *static_cast<__box IntPtr*>((length – 1)))] = (tempArray[*static_cast<__box Int32*>(x)] – tabPoints[i]);
}
}

[/cpp]

~~ These are the notes from my N.A. class @ UoM ~~

Written by: Owner

Tagged as: .

Rate it

###### Previous post todayApril 17, 2019

• 5
• 11
close
##### What Are The Biggest SharePoint API Mistakes?
The most prevalent SharePoint API mistake that I see is the lack of freaking Exist properties on proxy objects. What do I mean? One can't do this in order to [...]

###### Similar posts todayApril 17, 2019

• 21
close

Numerical Analysis Owner

##### Calculating Polynomial Interpolation Coefficients todayJanuary 8, 2019

• 12
close

Numerical Analysis Owner