Skip to content

feat: detect non-polynomial dependence on the variables - #80

Merged
oameye merged 2 commits into
mainfrom
feat/polynomial-check
Jul 27, 2026
Merged

feat: detect non-polynomial dependence on the variables#80
oameye merged 2 commits into
mainfrom
feat/polynomial-check

Conversation

@oameye

@oameye oameye commented Jul 27, 2026

Copy link
Copy Markdown
Member

Averaging only makes sense for equations that are polynomial in the variables. Harmonic balance replaces each variable by a truncated Fourier series, and only sums, products and non-negative integer powers keep that series finite. A term like sin(x) or 1/x produces an infinite spectrum instead, and the Fourier projection then discards every harmonic of it.

Nothing here could spot that. is_harmonic reasons about time dependence, and it cannot see sin(x(t)) at all: get_variables(sin(x(t))) yields x(t) and never t, so get_independent calls the term t-independent and an equation built from it looks free of time dependence.

nonpolynomial_terms(x, vars) walks the expression and returns every subexpression where a variable sits under something other than +, * or a non-negative integer power, recursing through derivatives and flagging state-dependent denominators along with negative, fractional and symbolic exponents. is_polynomial is the predicate on top, and a DifferentialEquation method checks a whole system at once.

oameye added 2 commits July 27, 2026 20:38
Averaging only makes sense for equations that are polynomial in the variables,
and nothing here could check for that. `is_harmonic` reasons about time
dependence and cannot see `sin(x(t))` at all, because `get_variables(sin(x(t)))`
yields `x(t)` and never `t`, so `get_independent` calls the term t-independent.

`nonpolynomial_terms` returns every subexpression where a variable sits under
something other than `+`, `*` or a non-negative integer power, with
`is_polynomial` as the predicate on top and a method for a whole
`DifferentialEquation`.
@oameye
oameye merged commit c76fe76 into main Jul 27, 2026
2 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant