- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am running two different FORTRAN codes which are exactly the same, except for the small difference that in one of the codes there is a term evaluated as 4*(pi*pi)*k*k and the other code has the same term evaluated as 4*pi*pi*k*k (where pi and k are double precision variables with the exact same values upto the last decimal). The two expressions give results which differ from each other in the 16th decimal place. Though this is a very minor issue, the PDE which I am trying to solve is so sensitive to numerical noise, that a small change such as the one mentioned above can cause a significant change in the solution. Could anyone explain how does the location of brackets in an expression affect the result of that expression?
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try adding either "-assume protect_parens" or "-fp_model source".
A compiler ought not to reorder operations across parentheses but ifort will do so with its default modes.
A compiler ought not to reorder operations across parentheses but ifort will do so with its default modes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Steve Lionel (Intel)
Try adding either "-assume protect_parens" or "-fp_model source".
A compiler ought not to reorder operations across parentheses but ifort will do so with its default modes.
A compiler ought not to reorder operations across parentheses but ifort will do so with its default modes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You might want to consider altering your method in a manner that reduces sensitivity to numerical noise. There is a difference between getting consistent results and getting better results.
For example, we know pi (assuming pi above is 3.141...) has a fraction part that extends beyond the precision of a REAL(8). We know that 4 can be expressed exactly. The k may or may not have an exact representation.
Knowing this, you might find better approximations using 4*((pi*k)**2), with option to honor parens.
Someone here may have a suggestion on a book with programming techniques that preserve more of the accuracy of your calculations by means of re-ordering steps within a program.
Jim Dempsey
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page