Coder Social home page Coder Social logo

Comments (7)

vneiger avatar vneiger commented on July 16, 2024 2

Reading the provided code and the sagemath link, I think the following addition to the answer of @albinahlback might be useful for @rudolph-git-acc : observe what you get from the following piece of C,

printf("%.20f\n", 1.1);

It should yield 1.10000000000000008882. This is what is meant by "inexact" (not representable etc.) above, and this has nothing to do with arb or flint or sagemath. (Sorry for the noise if that was already clear to you.)

from flint.

rudolph-git-acc avatar rudolph-git-acc commented on July 16, 2024 2

@vneiger Thanks for the clarification. Your example is very helpful and I had never appreciated the "inexact" issue.

It is good to be aware of this though and maybe it is worthwhile mentioning it in the documentation of arb_set_d. I have for instance seen it being used in setting integral limits and there it could make a big difference e.g. in a lower limit close to zero. Or for instance in this issue on the old ARB GitHub : flintlib/arb#451 Replacing arb_set_d by are_set_str has an immediate impact on the result.

I most certainly don't want to blame FLINT/ARB for having "bugs" or being "wrong" and will include a link to this thread in my AskSageMath question.

from flint.

albinahlback avatar albinahlback commented on July 16, 2024

I don't know what you specifically mean by "wrong" here, or a "bug".

  1. arb_set_d will only convert a double to an arb_t. If the double is "inexact" (meaning that the original decimal number is not representable as a dyadic rational), that's on the user -- FLINT/Arb is not a compiler.
  2. arb_set_d will not impose some error bound since it doesn't know if the double is inexact or not. Once again, that's on the user.

As 1.1 is not representable as a dyadic rational, you should not expect Arb to give a "correct" number. It will only convert what is given to it, which is an approximation, which in turn an arb_t can represent.

from flint.

albinahlback avatar albinahlback commented on July 16, 2024

Yes, this should be documented. Thanks for bringing this up!

from flint.

albinahlback avatar albinahlback commented on July 16, 2024

Fixed in 0c07030

from flint.

rudolph-git-acc avatar rudolph-git-acc commented on July 16, 2024

Sorry to be a pain, but the same issue could be induced by the following commands:

image \

image \

image \

The latter is often used in setting integral limits. Probably good to update the documentation for these as well.

P.S.
I believe we should be good for fmpz-types:
image

from flint.

edgarcosta avatar edgarcosta commented on July 16, 2024

arf_set_d does not have this issue, one is converting between two equivalent representations.

from flint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.