Skip to content

Commit

Permalink
Add rtol/atol options for computing roots to avoid numerical errors
Browse files Browse the repository at this point in the history
  • Loading branch information
serenity4 committed Aug 17, 2024
1 parent 0c42cad commit 3cf433e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/frontend/MathFunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ function rotate_2d(v, angle)
typeof(v)(real(cv′), imag(cv′))
end

function compute_roots(a, b, c)
if isapprox(a, zero(a), atol = 1e-7)
function compute_roots(a, b, c; rtol = 1e-6F, atol = 0F)
if isapprox(a, zero(a); rtol, atol)
t₁ = t₂ = c / 2b
return (t₁, t₂)
end
Expand Down

0 comments on commit 3cf433e

Please sign in to comment.