Fix comment for evaluate_polynomial_in_evaluation_form to reflect that it can now also be used in the domain

This commit is contained in:
kevaundray 2023-03-04 19:20:01 +00:00 committed by GitHub
parent 86fb82b221
commit 1b4840c967
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -303,8 +303,10 @@ def compute_powers(x: BLSFieldElement, n: uint64) -> Sequence[BLSFieldElement]:
def evaluate_polynomial_in_evaluation_form(polynomial: Polynomial, def evaluate_polynomial_in_evaluation_form(polynomial: Polynomial,
z: BLSFieldElement) -> BLSFieldElement: z: BLSFieldElement) -> BLSFieldElement:
""" """
Evaluate a polynomial (in evaluation form) at an arbitrary point ``z`` that is not in the domain. Evaluate a polynomial (in evaluation form) at an arbitrary point ``z``.
Uses the barycentric formula: - When ``z`` is in the domain, the evaluation can be found by indexing the polynomial at the
position that ``z`` is in the domain.
- When ``z`` is not in the domain, the barycentric formula is used:
f(z) = (z**WIDTH - 1) / WIDTH * sum_(i=0)^WIDTH (f(DOMAIN[i]) * DOMAIN[i]) / (z - DOMAIN[i]) f(z) = (z**WIDTH - 1) / WIDTH * sum_(i=0)^WIDTH (f(DOMAIN[i]) * DOMAIN[i]) / (z - DOMAIN[i])
""" """
width = len(polynomial) width = len(polynomial)