Polynomial-polynomial Addition/Subtraction in the Newton Basis with a Common Grid
The Newton basis depends on the set of generating points which in turn depends on the grid on which the polynomials live. In general, if two grids are the not the same then the Newton basis of the two grids will not be the same for the same multi-index set elements. Consequently, in the addition and subtraction of polynomials, the coefficients of matching multi-index set element cannot just be added/subtracted because they are of different monomials. This is why in Minterpy, the general polynomial-polynomial addition/subtraction in the Newton basis goes via the Lagrange coefficients first before transforming the coefficients to the Newton basis.
On the other hand, if two polynomials share a common underlying grid then the monomials would be the same; adding and subtracting between these polynomials can then resort to adding and subtracting coefficients of matching multi-index set elements without the need of transformation. This should handle the most obvious use case: adding and subtracting a polynomial with itself.
For instance, currently:
>>> nwt_poly + nwt_poly + nwt_poly == 3 * nwt_poly
False
They are close, but because of the transformation they (i.e., the coefficients) cannot be closer. Compare this to the polynomials in the canonical basis:
>>> can_poly + can_poly + can_poly == 3 * can_poly
True
Minterpy should handle the addition and subtraction of polynomials with a common grid differently so that the above test becomes True
.
This issue is part of refactoring and extending the support for arithmetic operations involving polynomial (see Issue #142 (closed)).