Factorized barycentric Lagrange-to-Newton does not work for higher dimension (m > 3)
The factorized form of the barycentric Lagrange-to-Newton transformation operator does not work for problems in higher dimension (m > 3).
Specifically, the resulting transformation matrix does not equal to the result of the DDS (minterpy.dds.dds()
) on the identity matrix (and to the result of the dictionary form).
For example, the following assertion fails:
import minterpy as mp
import numpy as np
# Problem setup
m = 5
p = 5
lp = 2
mi = mp.MultiIndexSet.from_degree(m, p, lp)
# L2N from factorized barycentric form
lag_poly = mp.LagrangePolynomial(mi)
l2n_trans = mp.LagrangeToNewton(lag_poly)
l2n_trans_operator = l2n_trans.transformation_operator
l2n_matrix = l2n_trans_operator.array_repr_full
# L2N from original DDS
X1 = np.eye(len(mi))
X1 = mp.dds.dds(X1, lag_poly.grid.tree)
assert np.allclose(X1, l2n_matrix)
with the largest difference:
np.max(np.abs(X1 - l2n_matrix))
# 12.8
The problem has not been previously captured because the unit tests do not cover problems with dimensions higher than 3.
The test fixture in /tests/conftest.py
line 142:
spatial_dimensions = [1,3]
Changing the upper limit of the test dimension to at least 4 will cause the unit test to fail.
The cause of the problem is that the correspondence between the left and right subtrees in the minterpy.schemes.barycentric.precomp.leaf_node_dds
and minterpy.schemes.barycentric.precomp.update_leaves
is not correctly determined.
Specifically in minterpy.schemes.barycentric.precomp.update_leaves
line 260:
# special property: the amount of leaves determines the match -> just use the length of the right slice
nr_leaves_r = len(v_right)
v_left = v_left[:nr_leaves_r]
This special property is most probably incorrect for problems with dimension higher than 3 because the split exponents in the right slice (subtree) do not directly correspond to the split exponents in the left subtree simply by the length (as confirmed by hand calculation for dimension 4). Masking is therefore still required to determine the correspondence between the left and right subtrees, but not like the one used in the original DDS as the DDS in the factorized form operates directly only on the relevant split nodes and not on all leaves nodes in the multi-index tree.