Comments (7)
Ok, so there are actually a few things going on.
First of all, the original program is only inaccurate for a relatively small range, for x and y between 5 and 28. For larger values, erf(x) - erf(y)
returns 0, which is actually the closest floating-point result for the correct answer. Since the range is small, Herbie doesn't sample many points in it (only one in (2048/3)^2 β 466k points falls into this range) and ends up basically ignoring it. So Herbie was "correctly" determining that the original expression had very little error and didn't need any changes. The best way to fix this is to add a precondition, either using :pre
(if on the command line) or by clicking the "Additional options" link (if on the web version).
Second of all, one of Herbie's rewrite rules (erfc-erf
) was less general than it should have been. I've tweaked that in the last commit.
from herbie.
Great question, I'll look into it. I think I know why but give me a moment to prove out my theory.
from herbie.
Awesome! Thanks for taking a look. Actually I'm trying to find a robust expression to compute the variance of a truncated normal (https://en.wikipedia.org/wiki/Truncated_normal_distribution#Two_sided_truncation[2]).
My manual attempts have failed so far.
Will you release a new version of Herbie with the erf
rules fix so I can try it? Thanks!
Edit: I'll try compiling from master.
from herbie.
I tried erf(x) - erf(y)
with precondition x > y
on Herbie master but I still don't get a transformation to erfc
. Maybe I need to do something else?
from herbie.
Hi @cossio, I got good results when I specified the precondition 5 < x < 28 and 5 < y < 28
. I bet reasonably similar bounds on x
and y
would work.
from herbie.
Thanks. I get
Don't know why it doesn't simplify the square root.
In fact, it seems that Herbie gets to (βerfc(x))+erfc(y)
as an intermediate expression, but then applies a couple of rules that introduce the square roots (which seem superfluous to me).
from herbie.
Yeah, Herbie does that sometimes, and I don't know why. I've been meaning to look into it. In some cases, that may twiddle some low-order bit in just the right way to minutely increase accuracy, but it might also be totally useless. I'll add it to my list of things to look into.
from herbie.
Related Issues (20)
- Optimized output sometimes contains (cbrt (pow x 3)) HOT 2
- Unexpected (?) results for difference of squares in web demo HOT 3
- Not a valid expression! given: 'E.f64 HOT 2
- unknown preprocess #s(symmetry-group (a b c)) HOT 2
- Variable names matter? HOT 1
- add-sqr-sqrt, really? HOT 3
- Online demo currently giving a 502 error HOT 1
- A question about herbie web version HOT 4
- How to get the bits error in the result HOT 2
- Incorrect optimization for x-sin(x) HOT 6
- Question about 8000 sampling points HOT 9
- question to confirm HOT 2
- How Herbie generates the equivalent expressions? HOT 8
- Which expressions are the set of equivalent expressions generated by Herbie for the input expression? HOT 1
- Better Cost Estimates & Free Optimizations HOT 1
- Any way to install a specific Herbie version using Racket ? HOT 24
- Clarificaitons for command-line options HOT 5
- Build issue: expected `i8`, found `u8` HOT 7
- Missing mailing list HOT 1
- 404 links HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from herbie.