Code Monkey home page Code Monkey logo

Comments (1)

JoelTrent avatar JoelTrent commented on July 19, 2024

The culprit is likely to be line 29 in src/matrix_to_parameters.jl which subtracts cos(α)^4 - sin(α)^4. When alpha is 0.25pi and 1.25pi cos(α) is equal to sin(α). However due to numerical issues, both when calculating alpha and when calculating the subtraction of the 4th power of these functions, the actual value is not quite a zero:

println(cos(0.25pi)^4 - sin(0.25pi)^4); println(cos(α)^4 - sin(α)^4)
1.3877787807814457e-16
1.3877787807814457e-16

The behaviour has also been noted for negative values of alpha close to -0.25pi and -1.25pi.

We can fix this issue by enhancing the precision of our calculations using BigFloat on the normalised matrix Hw on line 26. A precision of 64 gives a satisfactory result, however, it does impact the performance of the function by about 40 times. Lower precision values also gave good results for this test case, however, the additional precision was valuable when the magnitude of the two variables is significantly different.

A satisfactory compromise is to selectively enhance the precision if alpha is detected to be close to these problematic values using: isapprox(abs(rem(α/pi, 1)), 0.25, atol=1e-2)

from ellipsesampling.jl.

Related Issues (7)

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.