Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function library #2

Open
BystrickyK opened this issue Mar 8, 2021 · 1 comment
Open

Function library #2

BystrickyK opened this issue Mar 8, 2021 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@BystrickyK
Copy link
Owner

BystrickyK commented Mar 8, 2021

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

@BystrickyK
Copy link
Owner Author

BystrickyK commented Mar 8, 2021

Here's the correlation matrix of the regression matrix:
image
Some signals in the upper left corner are fully correlated, these are the second half of state variables (physically velocities) and the first half of state derivative variables; this is expected, as they're the same thing. This however creates an ambiguity issue in the regression, so one of the signals should be removed for good regression results.
The goal of identification is to find equations describing the evolution of state derivatives, so if one of the state derivative signals is perfectly correlated with another non-state derivative signal, we have a partial result. For example, in the case of double pendulum on a cart (6 state variables), 3 of the state derivative variables (dx1/dt, dx2/dt, dx3/dt) are pretty much by definition equal to state variables x4, x5 and x6 respectively. These complete causal relationships can be identified using the correlation matrix. The problem in this case is therefore simplified into finding equations describing the second half of state derivative variables (dx4/dt, dx5/dt and dx6/dt), which stand for the linear (cart) and angular (pendulums) accelerations physically.

@BystrickyK BystrickyK added the documentation Improvements or additions to documentation label Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant