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
