uwplse / herbgrind

A Valgrind tool for Herbie
GNU General Public License v3.0
90 stars 7 forks source link

Problems in use #64

Closed zuoyanzhang closed 1 year ago

zuoyanzhang commented 1 year ago

Can we measure the maximum error of the expression in the specified interval? For example, I want to measure the maximum error of 1/(x+1) in the [1,2] interval. What should I do if I can,Thanks

HazardousPeach commented 1 year ago

Hmm, well Herbgrind is designed for analyzing running floating point programs. The problem you're describing of finding the max error of a program under some constraints isn't quite in Herbgrind's domain.

But Herbie, a related tool to Herbgrind, can help you with this problem. First, enter that program and precondition into Herbie's web demo. In the input language of Herbie, that's this: (FPCore (x) :pre (< 1 x 2) (/ 1 (+ x 1))) . Then it generates this page: http://herbie.uwplse.org/demo/eb86d5ed250a278b55b40766ea7c477f2c833ff4.1.6/graph.html, which has on it an error graph. That graph uses thousands of sampled points to estimate the maximum possible error in the input region, and says that it has almost no error. It also proposes an alternative way to write the program that can improve the error, but not by much because their isn't much error in the first place.