liveBook · Manning

Odd polynomial

As explained in Geometry for Programmers

An odd polynomial is a polynomial satisfying P(x) = -P(-x), so all of its nonzero terms have odd degree.

An odd polynomial satisfies P(x) = -P(-x). Its nonzero terms therefore have odd degrees, so it contains powers such as x, x³, and x⁵, but no constant or even-power terms. section 7.1.2

This symmetry is useful when approximating an antisymmetric function such as sine. Modeling only the positive side removes redundant equations and produces a smaller, faster polynomial. section 7.1.2

An odd sine approximation

A fifth-degree model can be written as a*x**5 + b*x**3 + c*x. Its coefficients are determined from sine(pi/2) = 1, the derivative at zero, and the derivative at pi/2. The resulting model is tiny and fast, with mean error 0.00017. section 7.1.2

Listing 7.4 Modeling the odd sine without specifying anything for x < 0
from sympy import *
from math import pi
 
x, a, b, c = symbols('x a b c')   #1
 
sine = a*x**5 + b*x**3 + c*x      #2
sine_d = diff(sine, x)
 
the_system = [                    #3
    sine.subs(x, pi / 2) - 1,
    sine_d.subs(x, 0) - 1,
    sine_d.subs(x, pi / 2),
]
 
res = solve(the_system, (a, b, c))
 
for var, value in res.items():
    print(var, value)

Inspect the SymPy implementation that omits even powers and negative-domain constraints. section 7.1.2

How Geometry for Programmers covers it

How deep it goes
Defines the symmetry, derives the reduced polynomial model, and compares its computational simplicity with approximation accuracy.
Examples
Uses a fifth-degree sine approximation with x⁵, x³, and x terms, supported by SymPy coefficient-solving code.
What it assumes
Assumes polynomial coefficients and derivatives, while introducing antisymmetry through the identity P(x) = -P(-x).
What you can do after
Build it from scratch as a smaller antisymmetric polynomial approximation and assess its error against alternative models.
How it connects
Connects odd polynomials with antisymmetry, sine, polynomial interpolation, derivatives, integration, and Maclaurin series.

This explainer was generated by Manning's knowledge graph from the text of Geometry for Programmers. The section links point to the parts of the book it draws on.