Julia Controls

Partial fraction decomposition

Early in Ogata, I found examples of partial fraction decomposition and couldn't find a good Julia project that has this implemented. As a short description of what partial fraction decomposition is, if you have a fraction of two functions, like f(x)/g(x), you can decompose this into a series of smaller, easier to manage functions. For example, from the Wikipedia entry on partial fraction decomposition, we can take:

Screen Shot 2017-09-19 at 3.48.37 PM.png

And convert it to:

Screen Shot 2017-09-19 at 3.49.03 PM.png

The final equation is easier to work with because, even though it's now in more pieces, each piece is way more manageable.

The problem arose when I wanted to find a way to do this in Julia. There seemed to be a way to do this using symbolic variables in the SymPy package, but I wanted something more natively Julia in case this did become a useful tool in the ControlSystems package. That led me, eventually to the RationalFunctions package, which is an extension of the Polynomials package that ControlSystems uses. After some coding, debugging, and back and forth with the package owners, I had my first pull request accepted into an open source project! For those of you wondering, you can find it here.

Overall, I'm satisfied with the work for now. It's not perfect; there's still some issues around numerical stability that already existed in the Polynomials package that I'd like to address in the future, and I'm not convinced that my approach for solving the problem is the most robust either. Still, it's functionality where it didn't really exist before, so I'll still call it movement in the right direction.

David PernerComment

As I mentioned in my JuliaCon recap, one of the projects presented at the conference was Modia, an effort to extend the Modelica language implemented in Julia. Although Modia itself has yet to be published publicly, I was directed to a controls project at Lund University in Sweden as a potential pathway for adding controls capability to Modia once it becomes available. It of course doesn't hurt that the lead for Modia is based in Lund and knows the University team, but I digress.

This project, called ControlSystems, is very similar to the Matlab Controls Toolbox, which makes some sense due to Matlab/Simulink's prominence as a controls development tool. In order to familiarize myself with it, as well as get a much needed refresher on the topic, I broke out my old college textbook, System Dynamics by Ogata. The book has many Matlab examples scattered throughout, so my thought has been that as I'm reading through I'll try to replicate the examples in Julia, and note any differences or shortcomings where maybe I could contribute to the project.

And it didn't take all that long for me to start finding differences. So far, this has mostly been in very early material in the book that is more about partial fraction decomposition, which is useful in solving differential equations, but not critical for the rest of the book. I did, however, write a function to do partial fraction decomposition and got it merged into another Julia package, which I'll talk about in a later post.

Otherwise, I'm continuing to work through the book and note changes. I haven't get contributed anything to ControlSystems itself, but I have a few ideas on changes that could be helpful. As I submit them, I'll do my best to talk about them here.

David PernerComment