diagrams / diagrams-solve

Miscellaneous solver code for diagrams (low-degree polynomials, tridiagonal matrices)
Other
9 stars 6 forks source link

Fix tolerance issue in cubForm #8

Closed jaspervdj closed 4 years ago

jaspervdj commented 4 years ago

Hi Brent, I was seeing another (smaller) artefact in the code that produced #7 and and your quick response prompted me to look into this further.

I thought there was another issue in quartForm, but after tracing it down a lot further, it turned out that the actual problem was in cubForm. I got the resolvent cubic. This was:

1 * x^3 + -886.7970773009183 * x^2 + 262148.4783430062 * x + -264000817.775054

Which wolfram alpha solves as 915.4538593912 but the code was returning 911.5670525972223 -- that's too big a difference to be the result of floating point precision.

It turns out that disc can get extremely small but the sign of qq will still be meaningful. Simplifying the branches there got me the expected result.

byorgey commented 4 years ago

Fantastic, thanks so much!

byorgey commented 4 years ago

By the way, I just made a new release to Hackage (diagrams-solve-0.1.2) including these improvements.

jaspervdj commented 4 years ago

Thanks!