herbie-fp / herbie

Optimize floating-point expressions for accuracy
https://herbie.uwplse.org
Other
774 stars 33 forks source link

/alternatives endpoint gives incorrect response for sqrt(x*x) #1058

Open elmisback opened 1 week ago

elmisback commented 1 week ago

Odyssey obtains x (not |x|) as a rewriting for sqrt(x*x). I confirmed that this is what comes back from the /alternatives call. I can obtain this for any input range, and the accuracy is correctly given as 1.6%. Surprisingly, the Herbie demo doesn't suffer from this problem: https://herbie.uwplse.org/demo/2d0618bf426ea87944ccd749e3bbdec293310a98.1a83c9f5186db102b678a2d5f869f99992469071/graph.html

I'm not sure why only the alternatives endpoint would have this problem.

Related Odyssey issue reported by a user from SC: https://github.com/herbie-fp/odyssey/issues/220

zaneenders commented 6 days ago

I started working on this current status is explained in this PR. Not sure what the fix should be, but I think it will involve changes to both Odyssey and Herbie.