QuoteOriginally posted by: PolterQuoteOriginally posted by: CuchulainnQuoteOriginally posted by: PolterThat's a pretty interesting idea -- add warnings or errors when using a numerically unstable floating point expression:
http://github.com/mcarton/rust-herbie-lintWhat is the definition of 'numerically unstable thing'From the paper, the goal seems to be the following:QuoteTo correct inaccurate formulas, programmers must rearrange their computations to avoid rounding error. These rearrangements are often based on identities of real-number arithmetic. For example, to avoid catastrophic cancellation in (1+x)-x , one could reassociateinto 1+(x-x) , which simplifies to 1 and is exactly accurate.Quotetest.rs:155:5: 155:30 warning: Numerically unstable expression, #[warn(herbie)] on by defaulttest.rs:155 (a+b).sin() - (a+b).cos(); ^~~~~~~~~~~~~~~~~~~~~~~~~test.rs:155:5: 155:30 help: Try thistest.rs: (b.sin() * (a.sin() + a.cos())) - ((a.cos() - a.sin()) * b.cos());Take b = 0, the answers are not even the same. Am I missing something subtle? Was it machine-produced code or written on the fly?Seems to reduce to the same thing:
http://www.wolframalpha.com/input/?i=Fu ... y%5bsin(b)+*+(sin(a)+%2b+cos(a))+-+(cos(a)+-+sin(a))+*+cos(b)%5dWhat if you do it by hand?? BTW I agree with Wolfram. I TAKE IT BACK it's notation!!!!(a+b)cos() == cos(a+b)LOL==It is not consistent with accepted mathematical notation, which is bad.