I am trying to natively do partial fraction decomposition in Julia. In MATLAB the necessary command to use is partfrac and in Mathematica it is Apart. I know I can probably use PyCall.jl to use its version of apart but that probably incurs some overhead..
I am wondering if anyone knows any packages/gists/codelets that lets you do this natively in Julia; i.e. get the equivalent of partfrac (MATLAB), Apart (Mathematica) or apart (SymPy).
The ones I found by Googling are here (which was last updated 6 years ago) and here which again seems outdated (if not deprecated).
I was expecting it to be part of some standard package in Julia. I found a mention of residues in Polynomials.jl but no other documentation of it ... it doesn't look like it is the equivalent of Apart, partfrac, or apart either.
The documentation for
residues()inPolynomialssayshelp?> ?residues search: residues
residues(pq::AbstractRationalFunction; method=:numerical, kwargs...)
If p/q =d + r/q, returns d and the residues of a rational fraction r/q.
First expresses p/q =d + r/q with r of lower degree than q through divrem. Then finds the poles of r/q. For a pole, λj of multiplicity k there are k residues, rⱼ[k]/(z-λⱼ)^k, rⱼ[k-1]/(z-λⱼ)^(k-1), rⱼ[k-2]/(z-λⱼ)^(k-2),
…, rⱼ[1]/(z-λⱼ). The residues are found using this formula: 1/j! * dʲ/dsʲ (F(s)(s - λⱼ)^k evaluated at λⱼ
(5-28 (https://stanford.edu/~boyd/ee102/rational.pdf)).
Here is an example:
it looks as if the residues of a division can be returned as floating point, so you may need to restore them to integer after the division.