New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question about 8000 sampling points #501
Comments
That calculation looks correct to me. I wrote the code that's reporting those values, but not the code that does the actual translation from the internal sample point representation to the ordinals you're seeing. I'll have a look at the data from that expression to see if I can figure out what's going on, probably ask someone more knowledgeable, and get back to you. Regarding your question about the maximum error input, I doubt Herbie will necessarily find that input point, since it's using a uniform sample. |
Sorry, I just forgot how these are laid out. Basically, these values are used as a positive, monotonically increasing index over the floats. This is different from what you get if you just directly convert from a signed integer. Checking the reported values for the ticks which are used to lay out the plot for a simple function that covers the whole range like
These values are approximately matched by a javascript function like this. (The part you'd care about is the last couple lines): function herbie_ordinal_to_real(ordinal) {
// (approximate) -- using mathjs
function real_from_signed_int (signed) {
const buffer = new ArrayBuffer(8)
const view = new DataView(buffer)
view.setBigInt64(0, signed)
return view.getFloat64(0)
}
function to_signed_int (float64) {
const buffer = new ArrayBuffer(8)
const view = new DataView(buffer)
view.setFloat64(0, float64)
return view.getBigInt64(0)
}
const straight_conversion = real_from_signed_int(BigInt(ordinal)) // conversion you were doing
const zero = math.bignumber(to_signed_int(-0.0).toString())
// Flip the sign, then the negative half of the range is also reflected
return - straight_conversion < 0 ? - real_from_signed_int(math.subtract(zero, math.bignumber(ordinal))) : - straight_conversion
} |
Thank you very much for your patient answer, first of all the herbie tool is doing very well. |
Maybe @pavpanchekha might have more insight into this question, since I'm not sure how to do the MPFR comparison myself. One possibility I can think of is that the point being stored in the JSON might be slightly different from the actually sampled and tested point due to some kind of truncation when storing it as a number rather than a string. I didn't really worry about this issue when writing the code since I assumed the points were just going to be used for plotting. For Pavel--the point in question is at index 4907 in the arrays of the |
Hi all, I'll definitely take a look when I have a moment. |
Ok, so here's how Herbie is getting the answer it's getting. This is a transcription of a live REPL session launched in
I know you said you also used MPFR to confirm the correct answer, and got something different, and I'm not sure why or how. Can you explain further? |
Good to know how the given point error of the herbie tool is calculated. Sorry, I double-checked and it was my mpfr program that was written wrong. Thank you for your patience in answering. |
Always happy to have such diligent users! |
@pavpanchekha Dear Professor Pavel Panchekha, I have a question to confirm. The specific experimental process is as follows: For the benchmark NMSEproblem331, the expression is (1.0 / (x + 1.0)) - (1.0 / x), the test interval I chose is [0.01, 100000], and the corresponding fpcore program is: |
I passed herbie test ((35000000.0 + ((0.401 * (1000.0 / x)) * (1000.0 / x))) * (x - (1000.0 * 4.27e-5))) - ((1.3806503e-23 * 1000.0) * 300.0) expression, the maximum error given is 6.6bits, the test interval is [0.01, 100000], the corresponding input x to find this point is 13809681318699300000, I speculate that x here should be decimal, convert it to hexadecimal The hexadecimal number is 0xbfa5d7fe166b74a0. When converting the hexadecimal number to the corresponding floating-point number, it is -0.042663517224107. Why is the corresponding negative number here? My test range is obviously a positive number. I would like to know how each point of herbie's 8000 sampling points is converted into a corresponding floating point number, or whether herbie can give the input corresponding to the maximum error in a given interval. Maybe I didn't understand what 13809681318699300000 is here, I hope to get your reply, thank you
The text was updated successfully, but these errors were encountered: