Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • What is the value of episilon(1d0) for your compiler? Commented Jan 26, 2018 at 9:35
  • The value is ~ 2.2e-16? Commented Jan 26, 2018 at 9:37
  • 2
    Sounds plausible. Assume that both sin and cos are accurate to within 7E-017. That gives you the answer for cos. 1-7E-017 is equal to 1. [You say you understand the "usual floating point issues". Do you need this aspect explaining, or do you call this a slight oversight?] Commented Jan 26, 2018 at 9:43
  • 1
    You can avoid the multiplication in the definition of PI by using PI = ACOS(-1.d0). Intrinsic function like the trig functions do not need the double precision specific version. ATAN would be enough just like you used sin and cos instead of dsin and dcos. Fortran will link the correct version according to the arguments. Also to be formally correct, your literals should be double precision: print*, sin(PI/2.d0), cos(PI/2.d0). Commented Jan 26, 2018 at 15:33