herbie icon indicating copy to clipboard operation
herbie copied to clipboard

missed optimization: acos(1-x) -> 2 * asin(sqrt(x/2)) [on 0 <= x < 0.5?]

Open jepler opened this issue 5 years ago • 1 comments

Source: personal investigation in 2014, inspiration from freebsd math library

image

http://herbie.uwplse.org/demo/8a0cc529ad30320a1d61220a6aefb0d36298cb3c.4ba6b6e49c51088fa31e3dbc4e15bf82b3c31626/graph.html

jepler avatar Aug 07 '20 02:08 jepler

Huh, that's an interesting rewrite, thanks for the suggestion. I'll think about how best to add this.

(Herbie has a list of rewrite rules it knows about, and I could add this directly, but I'm thinking about whether there's maybe some way to break this down into simpler steps that could be useful elsewhere.)

pavpanchekha avatar Aug 07 '20 19:08 pavpanchekha

Herbie still doesn't handle this one well, and frankly we have no clear plans to make Herbie much better at trig, so I'm going to add this to our benchmark suite (#521) and close this issue.

pavpanchekha avatar Nov 27 '22 23:11 pavpanchekha

That's fine! I reported this while kicking the tires of herbie but it's not actually vexing me in my real life.

jepler avatar Nov 28 '22 14:11 jepler