Skip to content

Function library #2

@BystrickyK

Description

@BystrickyK

The dynamics of multiple pendulum systems are described by trigonometric functions, the function library (~regression matrix) must therefore contain trigonometric functions for successful model identification. The trigonometric terms for a double pendulum look like this:
image
The library has to contain sine/cosine functions of many different pendulum angle sums. First, I create the angle sum signals; I multiply the angles by numbers from -2 to 2 and then create all possible sums (combinations). These sum angle signals are then used for calculating the respective sine/cosine signals. The resulting trigonometric signals for a double pendulum system look like this:
image
where x[2] and x[3] are the angles of the first and second pendulums.
This crude way of producing trigonometric functions creates one major problem. Two different angle sums inside a trigonometric function might create perfectly correlated signals because of the oddness/evenness of trigonometric functions. For example, the signals sin(x1 - 2x2) will be perfectly negatively correlated with sin(-x1 + 2x2). The presence of perfectly correlated regressors is a problem, because it creates ambiguity and trivial solutions (when LHS is guessed as a term that has a perfectly correlated term in the library, the RHS is just the twin term).
One way to solve this is to create the angle sums with the oddness/evenness problem in mind - this requires manually specifying the sum rules and lengthy IF statements to make sure no "twin" angle sum is created. I attempted this at first, but it gets quite complicated and convoluted when working with 3 or more angles. I thought of re-defining the trigonometric functions into complex exponential functions using Euler's formula, as the problem might be easier to deal with in the exponential formulation, but I found a "dumber", simpler, engineer's solution.
A simpler way to remove twin terms is to create the trig functions by all angle sum combinations just as before, and then calculating a huge correlation matrix and removing all signals that have a 1 or -1 in the lower triangular part of the correlation matrix. This method of removing twin signals scales well for any number of angles and doesn't require as much mathematical rigor.

Correlation matrix of trigonometric terms for a triple pendulum:
full_identities
Note the two "lines" crossing the main diagonal, one black (all -1 values) and one yellow (all 1 values), these indicate twin coupling between the two signals. The axis labels are supposed to be signal labels describing the regressor, but they're overlapping. Here's a picture zoomed on the upper line crossing of the main diagonal:
zoom_identities

Removing these problematic twin terms and calculating the correlation matrix again results in a diagonally dominant correlation matrix. Here's the correlation matrix after removing all terms that were -1 or 1 on the lower triangular (excluding main diagonal) correlation matrix:
full_no_identities
zoom_no_identities

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions