diagrams / diagrams-solve

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

Solve tolerance issue with quartForm #7

Closed jaspervdj closed 4 years ago

jaspervdj commented 4 years ago

I ported Polynomial.hs to Elm so I could use it for ray tracing a torus in a browser game I was working on. I noticed several artefacts in the result and traced it down to quartForm not returning any roots in a few cases.

The polynomial I used for debugging was:

1 * u^4 + -240 * u^3 + 25449 * u^2 + -1325880 * u + 26471900.25 = 0

Which has two roots according to Wolfram Alpha:

https://www.wolframalpha.com/input/?i=1+*+u%5E4+%2B+-240+*+u%5E3+%2B+25449+*+u%5E2+%2B+-1325880+*+u+++%2B+26471900.25

This patch fixes this specific issue and a few other artefacts I saw. It did not introduce any other glitches or artefacts into the ray tracer that I'm aware of.

byorgey commented 4 years ago

Thanks, this is super helpful! I have known for a long time that quartForm has some rough edges but I don't know much at all about numerics.