GithubHelp home page GithubHelp logo

Comments (6)

athas avatar athas commented on June 3, 2024 1

I get the same result on NixOS, so it's probably just how glibc is implemented. I also get that result in the Futhark interpreter, which uses Haskell's pow (but which is probably implemented via the C library). macOS uses a C library developed as part of the LLVM project. I have no reason to know which is more accurate.

Anyway, Futhark intentionally doesn't implement any of these numerical primitives itself, but just dispatches to whatever the platform does. That is overall a good idea, but sometimes this leads to small inconsistencies. You'll see even larger differences once you start running this on GPUs - they really push the allowable bounds on accuracy.

I'll close the issue as I don't think Futhark is doing anything wrong.

from futhark.

athas avatar athas commented on June 3, 2024

Are you sure it's a discrepancy in ** and not the other operations (which I guess would have to be the square root)? In any case, Futhark compiles those to pow in the platform C library, which I suppose can vary between platforms.

from futhark.

Woogachaka avatar Woogachaka commented on June 3, 2024

I would have to assume its in ** as that is the only difference in calculations between xyf2 and xyf2SQ

from futhark.

athas avatar athas commented on June 3, 2024

What happens if you say xi*xi+yi*yi instead of xi**2+yi**2, and use f64.sqrt instead of **0.5?

from futhark.

athas avatar athas commented on June 3, 2024

I really think it's just a tiny variance in the precision of pow() across different implementation (and I don't know which one is most accurate). Computing

map(\(xi,yi) -> ((xi**2+yi**2)**0.5-((0.5 + tol2)*diameter))) (zip x y)

I see some numbers very close to zero, and it wouldn't take much nudging to push them over the line.

from futhark.

Woogachaka avatar Woogachaka commented on June 3, 2024

I suspect you're correct in that. When testing your request, I see consistency with the other sets that seem to match. It appears that the failure case (the inconsistency with xf2) is an accumulated error/inconsistency in pow() in ubuntu 22.04

(venv) zerbeba1@TALOS:~/futhark-tracer/examples$ gcc --version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

from futhark.

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.