home *** CD-ROM | disk | FTP | other *** search
/ Collection of Education / collectionofeducationcarat1997.iso / SCIENCE / DE118I.ZIP / ADAMS4.C < prev    next >
C/C++ Source or Header  |  1993-02-06  |  17KB  |  717 lines

  1. /* Adams-Bashforth-Moulton integration formulas.
  2.  *
  3.  * Reference:
  4.  * Shampine, L. F. and M. K. Gordon, _Computer Solution of
  5.  * Ordinary Differential Equations_, W. H. Freeman, 1975.
  6.  *
  7.  * Program by Steve Moshier.
  8.  */
  9.  
  10. #ifndef NOINCS
  11. #include "mconf.h"
  12. #include "prec.h"
  13. #include "int.h"
  14. #include "const.h"
  15. #endif
  16.  
  17. /* Divided differences */
  18. #define N 19
  19.  
  20.  
  21. /*Predictor coefficients:
  22.  1.0
  23.  1.0 / 2.0
  24.  5.0 / 12.0
  25.  3.0 / 8.0
  26.  251.0 / 720.0
  27.  95.0 / 288.0
  28.  19087.0 / 60480.0
  29.  5257.0 / 17280.0
  30.  1070017.0 / 3628800.0
  31.  25713.0 / 89600.0
  32.  26842253.0 / 95800320.0
  33.  4777223.0 / 17418240.0
  34.  703604254357.0 / 2615348736000.0
  35.  106364763817.0 / 402361344000.0
  36.  1166309819657.0 / 4483454976000.0
  37.  2.5221445e7 / 9.8402304e7
  38.  8.092989203533249e15 / 3.201186852864e16
  39.  8.5455477715379e13 / 3.4237292544e14
  40.  1.2600467236042756559e19 / 5.109094217170944e19
  41. */
  42.  
  43. /* Corrector coefficients:
  44.    1.0
  45.   -1.0 / 2.0
  46.   -1.0 / 12.0
  47.   -1.0 / 24.0
  48.   -19.0 / 720.0
  49.   -3.0 / 160.0
  50.   -863.0 / 60480.0
  51.   -275.0 / 24192.0
  52.   -33953.0 / 3628800.0
  53.   -8183.0 / 1036800.0
  54.   -3250433.0 / 479001600.0
  55.   -4671.0 / 788480.0
  56.   -13695779093.0 / 2615348736000.0
  57.   -2224234463.0 / 475517952000.0
  58.   -132282840127.0 / 31384184832000.0
  59.   -2639651053.0 / 689762304000.0
  60.   1.11956703448001e14 / 3.201186852864e16
  61.   5.0188465e7 / 1.5613165568e10
  62.   2.334028946344463e15 / 7.86014494949376e17
  63. */
  64. #if LDOUBLE
  65. #if IBMPC
  66. static short precof[] = {
  67. 0x0000,0x0000,0x0000,0x8000,0x3fff, XPD
  68. 0x0000,0x0000,0x0000,0x8000,0x3ffe, XPD
  69. 0x5555,0x5555,0x5555,0xd555,0x3ffd, XPD
  70. 0x0000,0x0000,0x0000,0xc000,0x3ffd, XPD
  71. 0xd27d,0x7d27,0x27d2,0xb27d,0x3ffd, XPD
  72. 0x38e4,0xe38e,0x8e38,0xa8e3,0x3ffd, XPD
  73. 0x5440,0xea99,0x43fe,0xa195,0x3ffd, XPD
  74. 0x3519,0x6dfc,0x518a,0x9bc3,0x3ffd, XPD
  75. 0xb126,0x0fb1,0xf045,0x96f8,0x3ffd, XPD
  76. 0x80bb,0x54d8,0x721a,0x92ee,0x3ffd, XPD
  77. 0x6246,0xcff2,0x02c2,0x8f75,0x3ffd, XPD
  78. 0xac15,0xb603,0x8869,0x8c6c,0x3ffd, XPD
  79. 0xdc52,0x2596,0x2625,0x89be,0x3ffd, XPD
  80. 0x2820,0xc6b2,0x0f57,0x8759,0x3ffd, XPD
  81. 0xf898,0xbc14,0x9903,0x8530,0x3ffd, XPD
  82. 0x4d10,0xe1e8,0xff92,0x833a,0x3ffd, XPD
  83. 0x883c,0x772e,0x97fc,0x8170,0x3ffd, XPD
  84. 0xe995,0xbf9f,0x86c4,0xff96,0x3ffc, XPD
  85. 0x78b9,0x72bf,0x1a81,0xfc8c,0x3ffc, XPD
  86. };
  87. static short corcof[] = {
  88. 0x0000,0x0000,0x0000,0x8000,0x3fff, XPD
  89. 0x0000,0x0000,0x0000,0x8000,0xbffe, XPD
  90. 0xaaab,0xaaaa,0xaaaa,0xaaaa,0xbffb, XPD
  91. 0xaaab,0xaaaa,0xaaaa,0xaaaa,0xbffa, XPD
  92. 0xd82e,0x2d82,0x82d8,0xd82d,0xbff9, XPD
  93. 0x999a,0x9999,0x9999,0x9999,0xbff9, XPD
  94. 0x9474,0x1e9c,0x473f,0xe9c9,0xbff8, XPD
  95. 0xe4e9,0x93a3,0x4e8f,0xba3e,0xbff8, XPD
  96. 0x7e46,0xc950,0x28ab,0x994c,0xbff8, XPD
  97. 0x0d67,0x5b26,0xc557,0x814f,0xbff8, XPD
  98. 0x9d4e,0x3987,0xd5e1,0xde5b,0xbff7, XPD
  99. 0x8c4d,0x7bad,0x9646,0xc21e,0xbff7, XPD
  100. 0xf0ac,0x1b33,0x9124,0xab98,0xbff7, XPD
  101. 0x0c7c,0xb92d,0xb357,0x9945,0xbff7, XPD
  102. 0xe201,0xa74b,0x9502,0x8a1d,0xbff7, XPD
  103. 0xc3dc,0x1655,0xb86d,0xfacc,0xbff6, XPD
  104. 0x6a55,0x5ce2,0xcb35,0xe533,0x3ff6, XPD
  105. 0xb891,0xaf49,0x4d0b,0xd2aa,0x3ff6, XPD
  106. 0x370d,0x381c,0x10d3,0xc29b,0x3ff6, XPD
  107. };
  108. #endif
  109. #if MIEEE
  110. static long precof[3*19] = {
  111. 0x3fff0000,0x80000000,0x00000000,
  112. 0x3ffe0000,0x80000000,0x00000000,
  113. 0x3ffd0000,0xd5555555,0x55555555,
  114. 0x3ffd0000,0xc0000000,0x00000000,
  115. 0x3ffd0000,0xb27d27d2,0x7d27d27d,
  116. 0x3ffd0000,0xa8e38e38,0xe38e38e4,
  117. 0x3ffd0000,0xa19543fe,0xea995440,
  118. 0x3ffd0000,0x9bc3518a,0x6dfc3519,
  119. 0x3ffd0000,0x96f8f045,0x0fb1b126,
  120. 0x3ffd0000,0x92ee721a,0x54d880bb,
  121. 0x3ffd0000,0x8f7502c2,0xcff26246,
  122. 0x3ffd0000,0x8c6c8869,0xb603ac15,
  123. 0x3ffd0000,0x89be2625,0x2596dc52,
  124. 0x3ffd0000,0x87590f57,0xc6b22820,
  125. 0x3ffd0000,0x85309903,0xbc14f898,
  126. 0x3ffd0000,0x833aff92,0xe1e84d10,
  127. 0x3ffd0000,0x817097fc,0x772e883c,
  128. 0x3ffc0000,0xff9686c4,0xbf9fe995,
  129. 0x3ffc0000,0xfc8c1a81,0x72bf78b9,
  130. };
  131. static long corcof[3*19] = {
  132. 0x3fff0000,0x80000000,0x00000000,
  133. 0xbffe0000,0x80000000,0x00000000,
  134. 0xbffb0000,0xaaaaaaaa,0xaaaaaaab,
  135. 0xbffa0000,0xaaaaaaaa,0xaaaaaaab,
  136. 0xbff90000,0xd82d82d8,0x2d82d82e,
  137. 0xbff90000,0x99999999,0x9999999a,
  138. 0xbff80000,0xe9c9473f,0x1e9c9474,
  139. 0xbff80000,0xba3e4e8f,0x93a3e4e9,
  140. 0xbff80000,0x994c28ab,0xc9507e46,
  141. 0xbff80000,0x814fc557,0x5b260d67,
  142. 0xbff70000,0xde5bd5e1,0x39879d4e,
  143. 0xbff70000,0xc21e9646,0x7bad8c4d,
  144. 0xbff70000,0xab989124,0x1b33f0ac,
  145. 0xbff70000,0x9945b357,0xb92d0c7c,
  146. 0xbff70000,0x8a1d9502,0xa74be201,
  147. 0xbff60000,0xfaccb86d,0x1655c3dc,
  148. 0x3ff60000,0xe533cb35,0x5ce26a55,
  149. 0x3ff60000,0xd2aa4d0b,0xaf49b891,
  150. 0x3ff60000,0xc29b10d3,0x381c370d,
  151. };
  152. #endif /* ldouble MIEEE */
  153. #else /* LDOUBLE */
  154. #if UNK
  155. static DOUBLE precof[19] = {
  156.  1.00000000000000000000E0,
  157.  5.00000000000000000000E-1,
  158.  4.16666666666666666667E-1,
  159.  3.75000000000000000000E-1,
  160.  3.48611111111111111111E-1,
  161.  3.29861111111111111111E-1,
  162.  3.15591931216931216931E-1,
  163.  3.04224537037037037037E-1,
  164.  2.94868000440917107584E-1,
  165.  2.86975446428571428571E-1,
  166.  2.80189596443936721714E-1,
  167.  2.74265540031599059377E-1,
  168.  2.69028846773648774310E-1,
  169.  2.64351348366606509794E-1,
  170.  2.60136396127601036937E-1,
  171.  2.56309496574389152514E-1,
  172.  2.52812146729039234860E-1,
  173.  2.49597650297715667409E-1,
  174.  2.46628202582257457797E-1,
  175. };
  176. static DOUBLE corcof[19] = {
  177.  1.00000000000000000000E0,
  178. -5.00000000000000000000E-1,
  179. -8.33333333333333333333E-2,
  180. -4.16666666666666666667E-2,
  181. -2.63888888888888888889E-2,
  182. -1.87500000000000000000E-2,
  183. -1.42691798941798941799E-2,
  184. -1.13673941798941798942E-2,
  185. -9.35653659611992945326E-3,
  186. -7.89255401234567901235E-3,
  187. -6.78584998463470685693E-3,
  188. -5.92405641233766233766E-3,
  189. -5.23669325795028506669E-3,
  190. -4.67749840704226451581E-3,
  191. -4.21495223900547285688E-3,
  192. -3.82689955321188442330E-3,
  193.  3.49734984534991765411E-3,
  194.  3.21449643132356745146E-3,
  195.  2.96944771545820961119E-3,
  196. };
  197. #endif /* double UNK */
  198. #if DEC
  199. static short precof[19*4] = {
  200. 0040200,0000000,0000000,0000000,
  201. 0040000,0000000,0000000,0000000,
  202. 0037725,0052525,0052525,0052525,
  203. 0037700,0000000,0000000,0000000,
  204. 0037662,0076447,0151175,0023722,
  205. 0037650,0161616,0034343,0107071,
  206. 0037641,0112503,0177352,0114524,
  207. 0037633,0141521,0105155,0176065,
  208. 0037626,0174360,0042417,0130661,
  209. 0037622,0167162,0015124,0154201,
  210. 0037617,0072402,0141317,0171142,
  211. 0037614,0066210,0064666,0001654,
  212. 0037611,0137046,0022445,0113334,
  213. 0037607,0054417,0053706,0131050,
  214. 0037605,0030231,0001674,0012371,
  215. 0037603,0035377,0111341,0164115,
  216. 0037601,0070227,0176167,0027210,
  217. 0037577,0113206,0142277,0117752,
  218. 0037574,0106032,0100562,0137571,
  219. };
  220. static short corcof[19*4] = {
  221. 0040200,0000000,0000000,0000000,
  222. 0140000,0000000,0000000,0000000,
  223. 0137252,0125252,0125252,0125253,
  224. 0137052,0125252,0125252,0125253,
  225. 0136730,0026602,0154055,0101330,
  226. 0136631,0114631,0114631,0114632,
  227. 0136551,0144507,0037436,0116224,
  228. 0136472,0037116,0107623,0121745,
  229. 0136431,0046050,0125711,0050176,
  230. 0136401,0047705,0053533,0023015,
  231. 0136336,0055725,0160471,0103635,
  232. 0136302,0017226,0043173,0126614,
  233. 0136253,0114221,0022033,0031761,
  234. 0136231,0042663,0053671,0026414,
  235. 0136212,0016625,0001247,0045742,
  236. 0136172,0146270,0066426,0052704,
  237. 0036145,0031713,0032534,0161152,
  238. 0036122,0125115,0005657,0044671,
  239. 0036102,0115420,0151470,0016067,
  240. };
  241. #endif /* double DEC */
  242. #if IBMPC
  243. static short precof[19*4] = {
  244. 0x0000,0x0000,0x0000,0x3ff0,
  245. 0x0000,0x0000,0x0000,0x3fe0,
  246. 0xaaab,0xaaaa,0xaaaa,0x3fda,
  247. 0x0000,0x0000,0x0000,0x3fd8,
  248. 0xa4fa,0xfa4f,0x4fa4,0x3fd6,
  249. 0x71c7,0xc71c,0x1c71,0x3fd5,
  250. 0x532b,0x7fdd,0x32a8,0x3fd4,
  251. 0xbf87,0x314d,0x786a,0x3fd3,
  252. 0xf636,0x08a1,0xdf1e,0x3fd2,
  253. 0x9b10,0x434a,0x5dce,0x3fd2,
  254. 0xfe4c,0x5859,0xeea0,0x3fd1,
  255. 0xc076,0x0d36,0x8d91,0x3fd1,
  256. 0xb2dc,0xc4a4,0x37c4,0x3fd1,
  257. 0xd645,0xeaf8,0xeb21,0x3fd0,
  258. 0x829f,0x2077,0xa613,0x3fd0,
  259. 0x3d0a,0xf25c,0x675f,0x3fd0,
  260. 0xe5d1,0xff8e,0x2e12,0x3fd0,
  261. 0xf3fd,0xd897,0xf2d0,0x3fcf,
  262. 0x57ef,0x502e,0x9183,0x3fcf,
  263. };
  264. static short corcof[19*4] = {
  265. 0x0000,0x0000,0x0000,0x3ff0,
  266. 0x0000,0x0000,0x0000,0xbfe0,
  267. 0x5555,0x5555,0x5555,0xbfb5,
  268. 0x5555,0x5555,0x5555,0xbfa5,
  269. 0xb05b,0x5b05,0x05b0,0xbf9b,
  270. 0x3333,0x3333,0x3333,0xbf93,
  271. 0xd393,0xe7e3,0x3928,0xbf8d,
  272. 0x747d,0xd1f2,0x47c9,0xbf87,
  273. 0x2a10,0x1579,0x2985,0xbf83,
  274. 0x64c2,0xaaeb,0x29f8,0xbf80,
  275. 0x30f4,0xbc27,0xcb7a,0xbf7b,
  276. 0x75b2,0xc8cf,0x43d2,0xbf78,
  277. 0x667e,0x2483,0x7312,0xbf75,
  278. 0x25a2,0x6af7,0x28b6,0xbf73,
  279. 0xe97c,0xa054,0x