Ask Your Question

erfc for arbitrary precision real field

asked 2020-07-17 06:22:20 -0500

WhatsUp gravatar image

The following code raised a runtime error:

R = RealField(500)


/home/sc_serv/sage/local/lib/python3.7/site-packages/sage/rings/real_mpfr.pyx in sage.rings.real_mpfr.RealNumber.erfc (build/cythonized/sage/rings/real_mpfr.c:31648)()
   5047         """
   5048         cdef RealNumber x = self._new()
-> 5049         sig_on()
   5050         mpfr_erfc(x.value, self.value, (<RealField_class>self._parent).rnd)
   5051         sig_off()

RuntimeError: Aborted

However, it would work if the RealField is removed:




Is there a way to make erfc work also for arbitrary precision real fields?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2020-07-17 15:39:22 -0500

jaydfox gravatar image

updated 2020-07-17 15:47:27 -0500

The issue is not the RealField. The issue seems to have something to do with the precision. 28.0 is simply a RealNumber with the default precision of 53 bits. Here are my results for various precisions:

sage: erfc(RealField(53)(28))
sage: erfc(RealField(64)(28))
sage: erfc(RealField(128)(28))
sage: erfc(RealField(192)(28))
sage: erfc(RealField(256)(28))
uceil_log2.c:40: MPFR assertion failed: exp < 1023
RuntimeError                              Traceback (most recent call last)

The real error is the "MPRF assertion failed: exp < 1023". This probably has something to do with the C implementation of mpfr_erfc, which is a third party library. I.e., it is used by SAGE, but it was not written by the SAGE team. I believe the MPFR library is still actively maintained, so maybe the SAGE team can reach out to the MPFR developers?

Edit: By the way, if you want to test with a standard double precision floating point number, put a letter 'r' after the number:

sage: isinstance(28.0, sage.rings.real_mpfr.RealNumber)
sage: isinstance(28.0r, float)
sage: erfc(28.0)
sage: erfc(28.0r)
edit flag offensive delete link more

answered 2020-07-19 05:04:03 -0500

tmonteil gravatar image

It works for me on 9.2.beta5 compiled from source, but with MPFR coming from my distro (libmpfr-dev package from Debian buster x86_64):

sage: R = RealField(5000)
....: print(erfc(R(28.0)))

So there might be a compilation issue somewhere in your build.

Note that mpmath and gmpy2 might be responsible too.

Could you please (both) give us some informations so that someone can try to understand:

  • which version of Sage did you use ?
  • which OS ?
  • did you install Sage from the distribution, and which package ?
  • did you install Sage from the binaries, and which ones ?
  • did you compile Sage yourself ?
  • if you compiled Sage, was a libmpfr-dev library installed on your ditstro ?
  • ... ?
edit flag offensive delete link more


I'm running version 9.0 on Windows. The name of the installer file was SageMath-9.0-Installer-v0.6.0.exe. Below is the output I see in sage, when I check the version:

sage: version()
'SageMath version 9.0, Release Date: 2020-01-01'

I have not recompiled, and it's running on top of cygwin, so I'm not sure if the MPFR library is part of cygwin or part of the sagemath installation.

jaydfox gravatar imagejaydfox ( 2020-07-19 20:15:00 -0500 )edit

I'm running on the sage cell server and the version() command gives 'SageMath version 9.1, Release Date: 2020-05-20'. Still it doesn't work at this moment. If the issue is solved in version 9.2, then I would be happy to wait for the sage cell server to update to 9.2.

WhatsUp gravatar imageWhatsUp ( 2020-08-01 10:53:27 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2020-07-17 06:22:20 -0500

Seen: 46 times

Last updated: Jul 19