Padé interpolation is the best rational function that minimizes that the squared distance to multiple points.
When the explanatory and objective variables are x and y,
a rational function with maximum coefficients m and n in the numerator and denominator is defined by the following equation:
The error for a single point is defined by the following equation:
The weighted squared error for multiple points is given by the following equation in the definition.
If it is not weighted, it can be interpreted as if all w were 1.
The parameter that minimizes the error is the point at which the partial derivative of each parameter is 0.
Fortunately, it can be solved as a linear problem.
The matrix representation is as follows. Note that the matrix is symmetric.
When the y-intercept is not fixed:
When the y-intercept(p0=a) is fixed:
See below for an example implementation.
Since this is a calculation that produces many digit loss, the double precision does not produce the expected results.
MultiPrecisionCurveFitting