Skip to content

Optimize computing several lagrange coefficients in a row #39

@survived

Description

@survived

Sometimes we have the same fixed set of polynomial points $\vec x$ and index $j$, and we're computing lagrange coefs $\text{coef}(j, x, \vec x)$ for different $x$. Recall that lagrange coef is computes as:

$$\text{coef}(j, x, \vec x) = \frac{\prod_{m \ne j} x - \vec x_m}{\prod_{m \ne j} \vec x_j - \vec x_m}$$

Note that denominator is independent of $x$. We can compute

$$\text{denom}_{j, \vec x} = (\prod_{m \ne j} \vec x_j - \vec x_m)^{-1}$$

then we can compute lagrange coef without doing modular inversion:

$$\text{coef}'(x, \text{denom}) = \text{denom} \cdot \prod_{m \ne j} x - \vec x_m$$

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions