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

Rational function #335

Merged
merged 52 commits into from
Apr 20, 2021
Merged

Rational function #335

merged 52 commits into from
Apr 20, 2021

Conversation

jverzani
Copy link
Member

This adds an AbstractRationalFunction type for holding rational functions. In #308 it was suggested that this could be useful. Construction of the primaryRationalFunction type borrows the // syntax from the Rational type of Base. Other subtypes are possible.

The https://github.com/andreasvarga/DescriptorSystems.jl/blob/main/src/types/RationalFunction.jl implementation is mostly realized as a subtype of AbstractRationalFunction as an example (for now it isn't included when the package is loaded).

The https://github.com/aytekinar/RationalFunctions.jl package was a guide, but the main RationalFunction implementation does not include information about conjugated variables.

The conj method has not (yet) been defined.

The new exports are poles and residues. The "zeros" are found by roots. As well, the function lowest_terms is exported to cancel common factors. (The name cancel is used in SymPy and Mathematica, but wasn't used for this as it seemed like a useful generic elsewhere, though it is tempting.)

There is a simple implementation for fitting rational functions using least squares, fit(RationalFunction, xs, ys, m, n). (There are more accurate and robust fitting implementations elsewhere in the package ecosystem, such as BaryRational.) As for fitting, this provides a natural home for the Pade function that is still available via PolyCompat, and now re-implemented by fit(RationalFunction, p::Polynomial, m,n).

The plot recipe seems to do an okay job of plotting basic rational functions, though perhaps it could be tweaked in places.

@codecov
Copy link

codecov bot commented Apr 12, 2021

Codecov Report

Merging #335 (fa950a6) into master (e9f59d7) will decrease coverage by 8.69%.
The diff coverage is 44.90%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #335      +/-   ##
==========================================
- Coverage   91.54%   82.85%   -8.70%     
==========================================
  Files          16       21       +5     
  Lines        1963     2420     +457     
==========================================
+ Hits         1797     2005     +208     
- Misses        166      415     +249     
Impacted Files Coverage Δ
src/rational-functions/plot-recipes.jl 0.00% <0.00%> (ø)
...c/rational-functions/rational-transfer-function.jl 0.00% <0.00%> (ø)
src/polynomials/multroot.jl 92.38% <50.00%> (+0.07%) ⬆️
src/rational-functions/common.jl 56.04% <56.04%> (ø)
src/rational-functions/rational-function.jl 60.00% <60.00%> (ø)
src/polynomials/ngcd.jl 95.68% <66.66%> (-0.60%) ⬇️
src/rational-functions/fit.jl 71.23% <71.23%> (ø)
src/common.jl 90.74% <100.00%> (+0.33%) ⬆️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e9f59d7...fa950a6. Read the comment docs.

@jverzani jverzani merged commit 8e66c4e into JuliaMath:master Apr 20, 2021
@jverzani jverzani deleted the rational_function branch April 20, 2021 21:45
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