MODULE const INTEGER, PARAMETER :: dp = KIND(1.0d0), sp = KIND(1.0e0) REAL(KIND=dp), PARAMETER :: dpi = 3.141592653589793d0 END MODULE const !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PROGRAM prog USE const IMPLICIT NONE ! Program to compute the sine, cosine and tangent of an ! angle. The angle is to input in degrees. ! ! The program then applies the appropriate inverse trig function ! to the output to recover the original angle. This needs to be ! converted from radians back to degrees REAL(kind=dp) :: angle,s,c,t,a1,a2,a3 WRITE(*,*) 'Input the angle' READ(*,*) angle ! The angle needs to be in radians. Here, I am overwriting the ! degree angle with it's radian equivalent angle = angle*dpi/180 s = SIN(angle) c = COS(angle) t = TAN(angle) WRITE(*,*) 'SIN = ',s WRITE(*,*) 'COS = ',c WRITE(*,*) 'TAN = ',t ! Now take the appropriate inverse trig function for each ! of the above answers. This will give an angle in radians ! that will need to be converted back to degrees. a1 = ASIN(s)*180/dpi a2 = ACOS(c)*180/dpi a3 = ATAN(t)*180/dpi WRITE(*,*) 'ASIN(SIN(angle)) = ',a1 WRITE(*,*) 'ACOS(COS(angle)) = ',a2 WRITE(*,*) 'ATAN(TAN(angle)) = ',a3 END PROGRAM prog !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! Input the angle ! 30 ! SIN = 0.49999999999999994 ! COS = 0.86602540378443871 ! TAN = 0.57735026918962573 ! ASIN(SIN(angle)) = 29.999999999999996 ! ACOS(COS(angle)) = 29.999999999999993 ! ATAN(TAN(angle)) = 29.999999999999996 ! ! Input the angle ! 210 ! SIN = -0.50000000000000011 ! COS = -0.86602540378443860 ! TAN = 0.57735026918962595 ! ASIN(SIN(angle)) = -30.000000000000011 ! ACOS(COS(angle)) = 150.00000000000003 ! ATAN(TAN(angle)) = 30.000000000000011