SERVING THE QUANTITATIVE FINANCE COMMUNITY

Polter
Posts: 2526
Joined: April 29th, 2008, 4:55 pm

### ISO C++11 published

Polter
Posts: 2526
Joined: April 29th, 2008, 4:55 pm

### ISO C++11 published

That's a pretty interesting idea -- add warnings or errors when using a numerically unstable floating point expression: http://github.com/mcarton/rust-herbie-lint

Cuchulainn
Posts: 60757
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### ISO C++11 published

QuoteOriginally 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'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? Quotetest.rs:40:5: 40:18 warning: Numerically unstable expression, #[warn(herbie)] on by defaulttest.rs:40 (a/b + c) * b; ^~~~~~~~~~~~~test.rs:40:5: 40:18 help: Try thistest.rs: (c * b) + a;I agree with this one. But the algorithm should never get that far in the first place.
Last edited by Cuchulainn on January 24th, 2016, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik

Polter
Posts: 2526
Joined: April 29th, 2008, 4:55 pm

### ISO C++11 published

QuoteOriginally 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)%5d

Cuchulainn
Posts: 60757
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### ISO C++11 published

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.
Last edited by Cuchulainn on January 25th, 2016, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik

Cuchulainn
Posts: 60757
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### ISO C++11 published

I think this is the official/accepted term:Loss of significance
Last edited by Cuchulainn on January 25th, 2016, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik

Cuchulainn
Posts: 60757
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### ISO C++11 published

Does this class walk, talk and quack like an abstract class?
Last edited by Cuchulainn on February 3rd, 2016, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik

Cuchulainn
Posts: 60757
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### ISO C++11 published

QuoteType generators are sometimes viewed as a workaround for the lack of templated typedefs'' in C++.
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik

Cuchulainn
Posts: 60757
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### ISO C++11 published

what is the status of the uckly duckling std::valarray in C++11?
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik

Cuchulainn
Posts: 60757
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

### ISO C++11 published

You can see that this code is wrong, but why?
http://www.datasimfinancial.com
http://www.datasim.nl

Approach your problem from the right end and begin with the answers. Then one day, perhaps you will find the final question..
R. van Gulik

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...

 JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...

GZIP: On