c-f-h / baryrat Goto Github PK
View Code? Open in Web Editor NEWA Python package for barycentric rational and polynomial interpolation and approximation.
License: BSD 2-Clause "Simplified" License
A Python package for barycentric rational and polynomial interpolation and approximation.
License: BSD 2-Clause "Simplified" License
If I want to calculate the AAA with complex numbers it gets a wrong solution.
I think this is due to the fact, that scipys SVD does calculate U,S,V^H whereas Matlab calculates U,S,V.
This should be solved by editing line
Line 212 in 3b45fa9
to
wj = Vh[-1, :].conj()
I'm trying to use BRASIL for function approximation with a fraction of polynomials.
Once I approximated a function and got a BarycentricRational
object, how do I represent this object as a fraction of polynomials, e.g. (c0 + c1 * x + c2 * x^2) / (k0 + k1 * x + k2 * x^2)
? How do I get c0
, c1
, c2
, k0
, k1
, k2
from the barycentric representation?
Hello and thanks for making this package available! I get an error trying to use BRASIL with mpmath. This is my sample code:
from baryrat import brasil
import mpmath as mp
mp.dps = 150
r = brasil(lambda x: mp.sqrt(x), interval=[0.0, 1.0], deg=(7,7))
and the error:
TypeError: cannot create mpf from array([0.00273905, 0.02447174, 0.0669873 , 0.12842759, 0.20610737,
0.29663168, 0.39604415, 0.5 , 0.60395585, 0.70336832,
0.79389263, 0.87157241, 0.9330127 , 0.97552826, 0.99726095])
Is this not possible? Or am I doing something wrong?
Hello,
I'm trying to fit a multivariate function. While I've had success with PolyRat, implementing the resulting fit in embedded code is rather ... complex. (And using a rational function converted from that unfortunately fails hard in numerical instability.)
After some digging, it seems that the baricentric formulae used in BaryRat are much more friendly to have a go at, while still offering (hopefully) enough numerical stability.
Q: May I ask if it is possible to do such a thing with BaryRat? And if so, how?
Q: The function I'm working with takes 2 real-valued inputs, for one output. Could it perhaps be possible to treat the inputs as a complex number and fit that?
Thank you,
Tom
Hi,
I have attempted to approximate a univariate complex function with a complex argument using BRASIL. However, it appears that the BRASIL method does not support this type of approximation. Can you provide guidance on the implementation of this functionality? If so, I would be really happy to help and attempt to contribute a little something back to this nice project.
Hello,
I want to generate rational approximation of degree (m,n) m!=n.
I invoke brasil with:
eps = np.finfo(np.double).eps
r = brasil(lambda x: x**args.alpha, (0, 1), (7,6), tol=eps, npi=-30, maxiter=10000)
where alpha is the fractional power.
I get the following error:
Traceback (most recent call last):
File "./python_code/./bura_mul_k1.py", line 20, in
r = brasil(lambda x: x**args.alpha, (0, 1), (m,n), tol=eps, npi=-30, maxiter=10000)
File "./python_code/baryrat.py", line 513, in brasil
n = 2 * deg + 1 # number of interpolation nodes
TypeError: can only concatenate tuple (not "int") to tuple
Best Regards,
Dimitar
Some other packages have derivatives and I'm not sure if integrals have a efficient representation.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.