# RationalVectorFitting.jl for rational approximation of complex-domain responses

**URL:** https://discourse.julialang.org/t/rationalvectorfitting-jl-for-rational-approximation-of-complex-domain-responses/121071
**Category:** Package Announcements
**Tags:** signal-processing
**Created:** [October 8, 2024, 10:14pm UTC](https://discourse.julialang.org/t/rationalvectorfitting-jl-for-rational-approximation-of-complex-domain-responses/121071 "2024-10-08T22:14:39Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![pedrohnv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pedrohnv/32/212503_2.png) [@pedrohnv](https://discourse.julialang.org/u/pedrohnv)
#### Post date: [October 8, 2024, 10:14pm UTC](https://discourse.julialang.org/t/rationalvectorfitting-jl-for-rational-approximation-of-complex-domain-responses/121071/1 "2024-10-08T22:14:39Z")

</div>

Given a transfer function f(s) = y, the Vector Fitting algorithm tries to find a rational approximation

f(s) \approx \sum\_{n=1}^N \frac{r\_n}{s - a\_n} + d + s h

where s is the complex frequency, r\_n are the complex residues, a\_n are the complex poles, d and h are real constants.

The transfer function can be a vector f(s) = [y\_1, \dots, y\_m] and the Vector Fitting algorithm will fit the response using the same set of poles a\_n for all y\_m.

A rational representation of a transfer function makes it easier to find a [state space canonical realization](https://en.wikipedia.org/wiki/Realization_(systems)#Canonical_realizations) of a system and to [perform convolutions](https://doi.org/10.4236/jamp.2022.106144). I imagine this can be useful for folks using [ControlSystems.jl](https://juliacontrol.github.io/ControlSystems.jl/stable/), for example.

I invite you to [read the docs to see some examples](https://pedrohnv.github.io/RationalVectorFitting.jl/stable/).

Many of my peers in electrical engineering are still using MATLAB due to legacy code, one of which is the [VFIT3](https://www.sintef.no/en/software/vector-fitting/downloads/vfit3/). So, I decided to build this package to be very similar to VFIT3 without being just a cheap translation of it. So far it is just a implementation of the classical algorithm presented in [1-3], but I intend to build upon it and incorporate recent improvements to the algorithm, like in [4].

Unfortunately, Vector Fitting is an algorithm that relies heavily on user input, trial and error. An alternative seems to be [RationalFunctionApproximation.jl](https://complexvariables.github.io/RationalFunctionApproximation.jl/stable/), which is built with a completely different algorithm.

# Bibliography

[1] B. Gustavsen and A. Semlyen, “Rational approximation of frequency domain responses by vector fitting,” in IEEE Transactions on Power Delivery, vol. 14, no. 3, pp. 1052-1061, July 1999, [doi: 10.1109/61.772353](https://doi.org/10.1109/61.772353).

[2] B. Gustavsen, “Improving the pole relocating properties of vector fitting,” in IEEE Transactions on Power Delivery, vol. 21, no. 3, pp. 1587-1592, July 2006, [doi: 10.1109/TPWRD.2005.860281](https://doi.org/10.1109/TPWRD.2005.860281).

[3] D. Deschrijver, M. Mrozowski, T. Dhaene and D. De Zutter, “Macromodeling of Multiport Systems Using a Fast Implementation of the Vector Fitting Method,” in IEEE Microwave and Wireless Components Letters, vol. 18, no. 6, pp. 383-385, June 2008, [doi: 10.1109/LMWC.2008.922585](https://doi.org/10.1109/LMWC.2008.922585).

[4] A. M. Smith, S. D’Arco, J. A. Suul and B. Gustavsen, “Improved Pole Placement and Compaction of MIMO Vector Fitting Applied to System Identification,” in IEEE Transactions on Power Delivery, vol. 39, no. 2, pp. 1259-1270, April 2024, [doi: 10.1109/TPWRD.2024.3364836.](https://doi.org/10.1109/TPWRD.2024.3364836)

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [October 8, 2024, 10:34pm UTC](https://discourse.julialang.org/t/rationalvectorfitting-jl-for-rational-approximation-of-complex-domain-responses/121071/2 "2024-10-08T22:34:38Z")

</div>

It seems like it should be possible to adapt the AAA algorithm for this problem as well, though I don’t know if the Julia implementations (BaryRational.jl and RationalFunctionApproximation.jl) support vector-valued functions.
