From fbf14e4cdc683b742a7b4d411fe6b2a10dd593cd Mon Sep 17 00:00:00 2001 From: "scriptalert(\"suleyman\");/script" Date: Wed, 21 Aug 2024 23:39:35 +0300 Subject: [PATCH] Update docs --- poly/README.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/poly/README.md b/poly/README.md index 0e6855662..f0f21086d 100644 --- a/poly/README.md +++ b/poly/README.md @@ -153,3 +153,44 @@ Divides two polynomials: Uses polynomial long division algorithm. Returns `(q, r)` where `q` is the quotient and `r` is the remainder such that `a(x) = b(x) * q(x) + r(x)` and `degree(r) < degree(b)`. + +## Polynomial Degree and Coefficient Sums + +```v ignore +fn degree(c []f64) int +``` + +This function returns the degree of the given polynomial. +The polynomial is represented by the array `c`: + +```console +P(x) = c[0] + c[1] x + c[2] x^2 + ... + c[n] x^n +``` + +The function returns the index of the highest non-zero term. + +```v ignore +fn sum_odd_coeffs(c []f64) f64 +``` + +This function calculates the sum of the coefficients at odd indices +in the given polynomial. The polynomial is represented by the array `c`: + +```console +P(x) = c[0] + c[1] x + c[2] x^2 + ... + c[n] x^n +``` + +The function returns the sum of coefficients `c[1]`, `c[3]`, `c[5]`, etc. + +```v ignore +fn sum_even_coeffs(c []f64) f64 +``` + +This function calculates the sum of the coefficients at even indices +in the given polynomial. The polynomial is represented by the array `c`: + +```console +P(x) = c[0] + c[1] x + c[2] x^2 + ... + c[n] x^n +``` + +The function returns the sum of coefficients `c[0]`, `c[2]`, `c[4]`, etc.