variables - Simpson's rule, declaration of user requested input not accepted? fortran -
I am working on this issue of getting the area under a tense curve using Simpson rules. However, I keep errors that I do not understand - even on various compilers such as Gafarran and Earport.
I know that I can make PE a parameter in the main body of the program, but I will only know where any help I am wrong will be greatly appreciated.
module consts! A global variable is actual (4), parameter :: pi = 3.1415927 end module program pi declare Simpson use consts any real field ::, j, sumo, sumum intecer (type = 4) :: I, j, K! Loop index, counter, number of real numbers (type = 4) :: red, tantab (0)! Radian variable, result array! K = Write the number of steps (6, *) "Please enter the required numbers (weird numbers)" READ (5, *) k (MOD (K, 2) == 1) then continue again (*, *) "Hey, I said as a strange number" READ (5, *) K.Endif H = (60.0) / (K-1)! Regarding the number of sample points, the size of the stage defines I = 1,61,1! Get a table of ten call Digotrade (i-1) * 1.0, rad). TantAb (J) = TAN (RD) J = J + 1 Write (*, *) "Tan (", I, ")", write Tantab (I) (*, *) "Tan (", J, ") ", Tantab (J) EDDO DO J = 1, K-1, HF (MOD (K, 2) == 1) then Sumo = Sumo + Tantab (J)! The function of the strange function is ELSE sume = sume + TanTab (j)! Even the sum of function area = (H / 3) * ((4 * sumo) + (2 * suum) + tan (1.047)) (6, *) field ENDIF ENDO END program Simpson
You have more mistakes in your code:
- According to the h , You are using degs and not rads
- upper bound of an integral part associated with the number of items in the tabt array
- for each phase of the field Calculation can not be done outside of do not loop
- Outside boundaries
You should start using the debugger and learn how to overcome problems in your code. The operating version is here:
Programmed Simpson is not indirectly: Area, H, Sumo, SUEEEGEF (Type = 4) :: I! Loop index integer, parameter :: K = 100 real (type = 4) :: Red, TanTab (K + 1)! Radian variable is calculated in subroutine, result array = 0.0 sume = 0.0 area = 0.0 H = 0.0174532925 * 60.0 / real (k)! Define phase size in relation to the number of sample digits I = 1, k + 1 rad = 0.0174532925 * 60.0 * Actual (i-1) / real (k) TanTab (i) = tan (rad)! Write (*, *) "tan (", i-1, ")", tantab (i) EDDO DOI = 2, IF (MOD (I, 2) == 1) then sumo = sumo + tantab ( I)! The odd jobs are ELSE sume = sume + TanTab (i)! Even the sum of ENDIF ENDDO tasks! Simson Area = (H / 3) * (Tantab (1) + (2 * Suum) + (4 * Sumo) + Tantab (K + 1)) Write (*, *) field! Integration Area = Log (1.0) - Log (by cos (0.0174532925 * 60.0) Write (*, *) Field and Program Simpson
Comments
Post a Comment