c-f-h / baryrat

A Python package for barycentric rational and polynomial interpolation and approximation.
BSD 2-Clause "Simplified" License
38 stars 6 forks source link

Received error when using brasil with deg = (m,n), m != n #9

Open dimitargslavchev opened 1 month ago

dimitargslavchev commented 1 month ago

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

c-f-h commented 2 weeks ago

Hi @dimitargslavchev, are you sure you are using the latest version (2.1)? I just ran this code and I received

In [7]: r = baryrat.brasil(lambda x: x**0.5, (0, 1), (7,6), tol=eps, npi=-30, maxiter=10000)
warning: BRASIL did not converge; dev=6.36e-12, err=6.98e-05
dimitargslavchev commented 2 weeks ago

Hi Clemence,
Indeed I was using an older version. I have updated to 2.1 but I still get an error. Here is the full code
---------------- #!/usr/bin/env python3

from baryrat import brasil from mpmath import mp import argparse import numpy as np

mp.dps = 100

parser = argparse.ArgumentParser(description="Generate BURA coefficients") parser.add_argument("k", type=int, help="BURA degree") parser.add_argument("alpha", type=float, help="fractional power") args = parser.parse_args()

eps = np.finfo(np.double).eps r = brasil(lambda x: x**args.alpha, (0.5, 1), (args.k, args.k-1), tol=eps, npi=-30, maxiter=10000)

------------------ First variable is k and second is fractional power. I use mpmath, may be that causes some error I called it with 7 and 0.5 and get this results:

$ ./bura_mul_interval.py 7 0.5 /home/dslavchev/.local/lib/python3.10/site-packages/baryrat.py:903: RuntimeWarning: divide by zero encountered in double_scalars

deviation = max_err / local_max.min() - 1 warning: BRASIL did not converge; dev=1.0, err=4.44e-16 Traceback (most recent call last):

File "/home/dslavchev/NuclearTesting/0_local_tests/2024_multiplicative_BURA_with_BRASIL/python_code/./bura_mul_interval.py", line 22, in

d = np.flip(np.sort(np.real(r.poles(True))))

File "/home/dslavchev/.local/lib/python3.10/site-packages/baryrat.py", line 262, in poles

return _compute_roots(self.weights, self.nodes, use_mp=True)

File "/home/dslavchev/.local/lib/python3.10/site-packages/baryrat.py", line 45, in _compute_roots

assert flamp, 'flamp package is not installed' AssertionError: flamp package is not installed


Greetings from Sozopol, Dimitar

-------- Оригинално писмо --------

От: Clemens @.***

Относно: Re: [c-f-h/baryrat] Received error when using brasil with deg = (m,n), m != n (Issue #9)

До: c-f-h/baryrat

Изпратено на: 17.06.2024 15:42

Hi @dimitargslavchev , are you sure you are using the latest version (2.1)? I just ran this code and I received
In [7]: r = baryrat.brasil(lambda x: x**0.5, (0, 1), (7,6), tol=eps, npi=-30, maxiter=10000) warning: BRASIL did not converge; dev=6.36e-12, err=6.98e-05

— Reply to this email directly, view it on GitHub , or unsubscribe . You are receiving this because you were mentioned. Message ID: @ github . com>

------=_Part_871626_1102343272.1718650167092 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable

Hi Clemence,

Indeed I was using an older vers= ion. I have updated to 2.1 but I still get an error. Here is the full code<= /div>

----------------
#!/usr/bin/env python3<= br>
from baryrat import brasil
from mpmath import mp
import argpar= se
import numpy as np

mp.dps =3D 100

parser =3D argparse.A= rgumentParser(description=3D"Generate BURA coefficients")
parser.add_arg= ument("k", type=3Dint, help=3D"BURA degree")
parser.add_argument("alpha"= , type=3Dfloat, help=3D"fractional power")
args =3D parser.parse_args()<= br>
eps =3D np.finfo(np.double).eps
r =3D brasil(lambda x: x**= args.alpha, (0.5, 1), (args.k, args.k-1), tol=3Deps, npi=3D-30, maxiter=3D1= 0000)

------------------
First variable is k and second is= fractional power. I use mpmath, may be that causes some error
I called it with 7 and 0.5 and get this results:

---------
$ ./bura_mul_interval.py 7 0.5
/home/dslavchev/.loca= l/lib/python3.10/site-packages/baryrat.py:903: RuntimeWarning: divide by ze= ro encountered in double_scalars
  deviation =3D max_err / local_ma= x.min() - 1
warning: BRASIL did not converge; dev=3D1.0, err=3D4.44e-16<= br>Traceback (most recent call last):
  File "/home/dslavchev/Nucle= arTesting/0_local_tests/2024_multiplicative_BURA_with_BRASIL/python_code/./= bura_mul_interval.py", line 22, in <module>
    d = =3D np.flip(np.sort(np.real(r.poles(True))))
  File "/home/dslavche= v/.local/lib/python3.10/site-packages/baryrat.py", line 262, in poles
&n= bsp;   return _compute_roots(self.weights, self.nodes, use_mp=3DT= rue)
  File "/home/dslavchev/.local/lib/python3.10/site-packages/ba= ryrat.py", line 45, in _compute_roots
    assert flamp, '= flamp package is not installed'
AssertionError: flamp package is not ins= talled

---------------

Greetings from Sozopol= ,
Dimitar

>-------- =D0=9E=D1=80=D0=B8=D0=B3=D0=B8=D0=BD=D0=B0=D0=BB=D0=BD=D0=BE = =D0=BF=D0=B8=D1=81=D0=BC=D0=BE --------
>=D0=9E=D1=82: Clemens ***@***.***
>=D0=9E=D1=82=D0=BD=D0=BE=D1=81=D0=BD=D0=BE: Re: [c-f-h/baryrat] Re= ceived error when using brasil with deg =3D (m,n), m !=3D n (Issue #9)
>=D0=94=D0=BE: c-f-h/baryrat ***@***.***>
>=D0=98=D0=B7=D0=BF=D1=80=D0=B0=D1=82=D0=B5=D0=BD=D0=BE =D0=BD=D0= =B0: 17.06.2024 15:42

=20 =20

=20

Hi @= dimitargslavchev, are you sure you are using the latest version (2.1)? = I just ran this code and I received

=20
In [7]: r =3D baryrat.brasil(lambda x: x**0.5, (0, 1), (7,6), =
tol=3Deps, npi=3D-30, maxiter=3D10000)
warning: BRASIL did not converge; dev=3D6.36e-12, err=3D6.98e-05
=20

=E2=80=94
Reply to this em= ail directly, view it on GitHub, or unsubscribe.
You are receiving this because y= ou were mentioned.3D"=Message ID: <c-f-h/ba= ryrat/issues/9/2173300973@github.com>

=20 =20

------=_Part_871626_1102343272.1718650167092--

c-f-h commented 2 weeks ago

"AssertionError: flamp package is not installed"

It seems you are missing the flamp package?