[
https://issues.apache.org/jira/browse/MATH-341?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12830314#action_12830314
]
Luc Maisonobe commented on MATH-341:
------------------------------------
I think there are no bugs here.
The first part of the test (method testfirstDerivativeComparison) runs without
error.
The second part of the test (method testfirstDerivativeComparisonFullPower)
prints coefficients that do not match.
However, the coefficients computed seem wrong to me because
* the getCoefficients method returns an array in increasing degree order (i.e.
coeff[0] is the constant term)
* the coefficients array length is d+1 when d is the degree
This implies that the g_coeff array which should contain the coefficients of
the derivative must have length myPolyNom.degree() and not myPolyNom.degree()-1
and the following loop should match. Also the computation of the coefficients
of the derivative shoud be:
g_coeff[i] = f_coeff[i+1] * (i + 1);
instead of
g_coeff[i] = f_coeff[i]*(myPolyNom.degree()-i);
With these changes, the automatic computation of derivative works.
A first comment on this case is that using polynomial fitting for such
functions with large numbers of points shows very large Gibbs oscillations near
the interval ends. One way to see this is to draw the curve from the sample
points and from evaluation of myPolyNom with x varying from 5 to 30 with a 0.1
step. You will see that the polynomial fits the sample points perfectly, but
near interval ends it has HUGE oscillations.
Another comment is that extracting the coefficients from the lagrangian form
should be used with caution. Unfortunately, this is written only in the
protected computationCoefficients() method javadoc, not in the public
getCoefficients() method javadoc ... The computation is ill-conditioned and in
fact the coefficients returned in your case are really bad. This could be seen
by evaluating the original lagrangian form polynomial and the one reconstructed
from the coefficients. The original does match the expected points, the
reconstructed one does not.
So I think there is only a documentation problem: we should warn the user about
extracting coefficients in this implementation.
Do you agree with this analysis ?
> Test for firsst Derivative in PolynomialFunction ERROR
> ------------------------------------------------------
>
> Key: MATH-341
> URL: https://issues.apache.org/jira/browse/MATH-341
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 2.0
> Reporter: Roger BAll
> Attachments: FirstDerivativePolyNomTest.java
>
>
> I have written the attached test using our data for generating a curve
> function
> However the first derivative test fails see:
> testfirstDerivativeComparisonFullPower
> Either my test is in error or there is a bug in PolynomialFunction class.
> Roger Ball
> Creoss Business Solutions
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.