README.txt 94 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721
  1. /* acoshf.c
  2. *
  3. * Inverse hyperbolic cosine
  4. *
  5. *
  6. *
  7. * SYNOPSIS:
  8. *
  9. * float x, y, acoshf();
  10. *
  11. * y = acoshf( x );
  12. *
  13. *
  14. *
  15. * DESCRIPTION:
  16. *
  17. * Returns inverse hyperbolic cosine of argument.
  18. *
  19. * If 1 <= x < 1.5, a polynomial approximation
  20. *
  21. * sqrt(z) * P(z)
  22. *
  23. * where z = x-1, is used. Otherwise,
  24. *
  25. * acosh(x) = log( x + sqrt( (x-1)(x+1) ).
  26. *
  27. *
  28. *
  29. * ACCURACY:
  30. *
  31. * Relative error:
  32. * arithmetic domain # trials peak rms
  33. * IEEE 1,3 100000 1.8e-7 3.9e-8
  34. * IEEE 1,2000 100000 3.0e-8
  35. *
  36. *
  37. * ERROR MESSAGES:
  38. *
  39. * message condition value returned
  40. * acoshf domain |x| < 1 0.0
  41. *
  42. */
  43. /* airy.c
  44. *
  45. * Airy function
  46. *
  47. *
  48. *
  49. * SYNOPSIS:
  50. *
  51. * float x, ai, aip, bi, bip;
  52. * int airyf();
  53. *
  54. * airyf( x, _&ai, _&aip, _&bi, _&bip );
  55. *
  56. *
  57. *
  58. * DESCRIPTION:
  59. *
  60. * Solution of the differential equation
  61. *
  62. * y"(x) = xy.
  63. *
  64. * The function returns the two independent solutions Ai, Bi
  65. * and their first derivatives Ai'(x), Bi'(x).
  66. *
  67. * Evaluation is by power series summation for small x,
  68. * by rational minimax approximations for large x.
  69. *
  70. *
  71. *
  72. * ACCURACY:
  73. * Error criterion is absolute when function <= 1, relative
  74. * when function > 1, except * denotes relative error criterion.
  75. * For large negative x, the absolute error increases as x^1.5.
  76. * For large positive x, the relative error increases as x^1.5.
  77. *
  78. * Arithmetic domain function # trials peak rms
  79. * IEEE -10, 0 Ai 50000 7.0e-7 1.2e-7
  80. * IEEE 0, 10 Ai 50000 9.9e-6* 6.8e-7*
  81. * IEEE -10, 0 Ai' 50000 2.4e-6 3.5e-7
  82. * IEEE 0, 10 Ai' 50000 8.7e-6* 6.2e-7*
  83. * IEEE -10, 10 Bi 100000 2.2e-6 2.6e-7
  84. * IEEE -10, 10 Bi' 50000 2.2e-6 3.5e-7
  85. *
  86. */
  87. /* asinf.c
  88. *
  89. * Inverse circular sine
  90. *
  91. *
  92. *
  93. * SYNOPSIS:
  94. *
  95. * float x, y, asinf();
  96. *
  97. * y = asinf( x );
  98. *
  99. *
  100. *
  101. * DESCRIPTION:
  102. *
  103. * Returns radian angle between -pi/2 and +pi/2 whose sine is x.
  104. *
  105. * A polynomial of the form x + x**3 P(x**2)
  106. * is used for |x| in the interval [0, 0.5]. If |x| > 0.5 it is
  107. * transformed by the identity
  108. *
  109. * asin(x) = pi/2 - 2 asin( sqrt( (1-x)/2 ) ).
  110. *
  111. *
  112. * ACCURACY:
  113. *
  114. * Relative error:
  115. * arithmetic domain # trials peak rms
  116. * IEEE -1, 1 100000 2.5e-7 5.0e-8
  117. *
  118. *
  119. * ERROR MESSAGES:
  120. *
  121. * message condition value returned
  122. * asinf domain |x| > 1 0.0
  123. *
  124. */
  125. /* acosf()
  126. *
  127. * Inverse circular cosine
  128. *
  129. *
  130. *
  131. * SYNOPSIS:
  132. *
  133. * float x, y, acosf();
  134. *
  135. * y = acosf( x );
  136. *
  137. *
  138. *
  139. * DESCRIPTION:
  140. *
  141. * Returns radian angle between -pi/2 and +pi/2 whose cosine
  142. * is x.
  143. *
  144. * Analytically, acos(x) = pi/2 - asin(x). However if |x| is
  145. * near 1, there is cancellation error in subtracting asin(x)
  146. * from pi/2. Hence if x < -0.5,
  147. *
  148. * acos(x) = pi - 2.0 * asin( sqrt((1+x)/2) );
  149. *
  150. * or if x > +0.5,
  151. *
  152. * acos(x) = 2.0 * asin( sqrt((1-x)/2) ).
  153. *
  154. *
  155. * ACCURACY:
  156. *
  157. * Relative error:
  158. * arithmetic domain # trials peak rms
  159. * IEEE -1, 1 100000 1.4e-7 4.2e-8
  160. *
  161. *
  162. * ERROR MESSAGES:
  163. *
  164. * message condition value returned
  165. * acosf domain |x| > 1 0.0
  166. */
  167. /* asinhf.c
  168. *
  169. * Inverse hyperbolic sine
  170. *
  171. *
  172. *
  173. * SYNOPSIS:
  174. *
  175. * float x, y, asinhf();
  176. *
  177. * y = asinhf( x );
  178. *
  179. *
  180. *
  181. * DESCRIPTION:
  182. *
  183. * Returns inverse hyperbolic sine of argument.
  184. *
  185. * If |x| < 0.5, the function is approximated by a rational
  186. * form x + x**3 P(x)/Q(x). Otherwise,
  187. *
  188. * asinh(x) = log( x + sqrt(1 + x*x) ).
  189. *
  190. *
  191. *
  192. * ACCURACY:
  193. *
  194. * Relative error:
  195. * arithmetic domain # trials peak rms
  196. * IEEE -3,3 100000 2.4e-7 4.1e-8
  197. *
  198. */
  199. /* atanf.c
  200. *
  201. * Inverse circular tangent
  202. * (arctangent)
  203. *
  204. *
  205. *
  206. * SYNOPSIS:
  207. *
  208. * float x, y, atanf();
  209. *
  210. * y = atanf( x );
  211. *
  212. *
  213. *
  214. * DESCRIPTION:
  215. *
  216. * Returns radian angle between -pi/2 and +pi/2 whose tangent
  217. * is x.
  218. *
  219. * Range reduction is from four intervals into the interval
  220. * from zero to tan( pi/8 ). A polynomial approximates
  221. * the function in this basic interval.
  222. *
  223. *
  224. *
  225. * ACCURACY:
  226. *
  227. * Relative error:
  228. * arithmetic domain # trials peak rms
  229. * IEEE -10, 10 100000 1.9e-7 4.1e-8
  230. *
  231. */
  232. /* atan2f()
  233. *
  234. * Quadrant correct inverse circular tangent
  235. *
  236. *
  237. *
  238. * SYNOPSIS:
  239. *
  240. * float x, y, z, atan2f();
  241. *
  242. * z = atan2f( y, x );
  243. *
  244. *
  245. *
  246. * DESCRIPTION:
  247. *
  248. * Returns radian angle whose tangent is y/x.
  249. * Define compile time symbol ANSIC = 1 for ANSI standard,
  250. * range -PI < z <= +PI, args (y,x); else ANSIC = 0 for range
  251. * 0 to 2PI, args (x,y).
  252. *
  253. *
  254. *
  255. * ACCURACY:
  256. *
  257. * Relative error:
  258. * arithmetic domain # trials peak rms
  259. * IEEE -10, 10 100000 1.9e-7 4.1e-8
  260. * See atan.c.
  261. *
  262. */
  263. /* atanhf.c
  264. *
  265. * Inverse hyperbolic tangent
  266. *
  267. *
  268. *
  269. * SYNOPSIS:
  270. *
  271. * float x, y, atanhf();
  272. *
  273. * y = atanhf( x );
  274. *
  275. *
  276. *
  277. * DESCRIPTION:
  278. *
  279. * Returns inverse hyperbolic tangent of argument in the range
  280. * MINLOGF to MAXLOGF.
  281. *
  282. * If |x| < 0.5, a polynomial approximation is used.
  283. * Otherwise,
  284. * atanh(x) = 0.5 * log( (1+x)/(1-x) ).
  285. *
  286. *
  287. *
  288. * ACCURACY:
  289. *
  290. * Relative error:
  291. * arithmetic domain # trials peak rms
  292. * IEEE -1,1 100000 1.4e-7 3.1e-8
  293. *
  294. */
  295. /* bdtrf.c
  296. *
  297. * Binomial distribution
  298. *
  299. *
  300. *
  301. * SYNOPSIS:
  302. *
  303. * int k, n;
  304. * float p, y, bdtrf();
  305. *
  306. * y = bdtrf( k, n, p );
  307. *
  308. *
  309. *
  310. * DESCRIPTION:
  311. *
  312. * Returns the sum of the terms 0 through k of the Binomial
  313. * probability density:
  314. *
  315. * k
  316. * -- ( n ) j n-j
  317. * > ( ) p (1-p)
  318. * -- ( j )
  319. * j=0
  320. *
  321. * The terms are not summed directly; instead the incomplete
  322. * beta integral is employed, according to the formula
  323. *
  324. * y = bdtr( k, n, p ) = incbet( n-k, k+1, 1-p ).
  325. *
  326. * The arguments must be positive, with p ranging from 0 to 1.
  327. *
  328. *
  329. *
  330. * ACCURACY:
  331. *
  332. * Relative error (p varies from 0 to 1):
  333. * arithmetic domain # trials peak rms
  334. * IEEE 0,100 2000 6.9e-5 1.1e-5
  335. *
  336. * ERROR MESSAGES:
  337. *
  338. * message condition value returned
  339. * bdtrf domain k < 0 0.0
  340. * n < k
  341. * x < 0, x > 1
  342. *
  343. */
  344. /* bdtrcf()
  345. *
  346. * Complemented binomial distribution
  347. *
  348. *
  349. *
  350. * SYNOPSIS:
  351. *
  352. * int k, n;
  353. * float p, y, bdtrcf();
  354. *
  355. * y = bdtrcf( k, n, p );
  356. *
  357. *
  358. *
  359. * DESCRIPTION:
  360. *
  361. * Returns the sum of the terms k+1 through n of the Binomial
  362. * probability density:
  363. *
  364. * n
  365. * -- ( n ) j n-j
  366. * > ( ) p (1-p)
  367. * -- ( j )
  368. * j=k+1
  369. *
  370. * The terms are not summed directly; instead the incomplete
  371. * beta integral is employed, according to the formula
  372. *
  373. * y = bdtrc( k, n, p ) = incbet( k+1, n-k, p ).
  374. *
  375. * The arguments must be positive, with p ranging from 0 to 1.
  376. *
  377. *
  378. *
  379. * ACCURACY:
  380. *
  381. * Relative error (p varies from 0 to 1):
  382. * arithmetic domain # trials peak rms
  383. * IEEE 0,100 2000 6.0e-5 1.2e-5
  384. *
  385. * ERROR MESSAGES:
  386. *
  387. * message condition value returned
  388. * bdtrcf domain x<0, x>1, n<k 0.0
  389. */
  390. /* bdtrif()
  391. *
  392. * Inverse binomial distribution
  393. *
  394. *
  395. *
  396. * SYNOPSIS:
  397. *
  398. * int k, n;
  399. * float p, y, bdtrif();
  400. *
  401. * p = bdtrf( k, n, y );
  402. *
  403. *
  404. *
  405. * DESCRIPTION:
  406. *
  407. * Finds the event probability p such that the sum of the
  408. * terms 0 through k of the Binomial probability density
  409. * is equal to the given cumulative probability y.
  410. *
  411. * This is accomplished using the inverse beta integral
  412. * function and the relation
  413. *
  414. * 1 - p = incbi( n-k, k+1, y ).
  415. *
  416. *
  417. *
  418. *
  419. * ACCURACY:
  420. *
  421. * Relative error (p varies from 0 to 1):
  422. * arithmetic domain # trials peak rms
  423. * IEEE 0,100 2000 3.5e-5 3.3e-6
  424. *
  425. * ERROR MESSAGES:
  426. *
  427. * message condition value returned
  428. * bdtrif domain k < 0, n <= k 0.0
  429. * x < 0, x > 1
  430. *
  431. */
  432. /* betaf.c
  433. *
  434. * Beta function
  435. *
  436. *
  437. *
  438. * SYNOPSIS:
  439. *
  440. * float a, b, y, betaf();
  441. *
  442. * y = betaf( a, b );
  443. *
  444. *
  445. *
  446. * DESCRIPTION:
  447. *
  448. * - -
  449. * | (a) | (b)
  450. * beta( a, b ) = -----------.
  451. * -
  452. * | (a+b)
  453. *
  454. * For large arguments the logarithm of the function is
  455. * evaluated using lgam(), then exponentiated.
  456. *
  457. *
  458. *
  459. * ACCURACY:
  460. *
  461. * Relative error:
  462. * arithmetic domain # trials peak rms
  463. * IEEE 0,30 10000 4.0e-5 6.0e-6
  464. * IEEE -20,0 10000 4.9e-3 5.4e-5
  465. *
  466. * ERROR MESSAGES:
  467. *
  468. * message condition value returned
  469. * betaf overflow log(beta) > MAXLOG 0.0
  470. * a or b <0 integer 0.0
  471. *
  472. */
  473. /* cbrtf.c
  474. *
  475. * Cube root
  476. *
  477. *
  478. *
  479. * SYNOPSIS:
  480. *
  481. * float x, y, cbrtf();
  482. *
  483. * y = cbrtf( x );
  484. *
  485. *
  486. *
  487. * DESCRIPTION:
  488. *
  489. * Returns the cube root of the argument, which may be negative.
  490. *
  491. * Range reduction involves determining the power of 2 of
  492. * the argument. A polynomial of degree 2 applied to the
  493. * mantissa, and multiplication by the cube root of 1, 2, or 4
  494. * approximates the root to within about 0.1%. Then Newton's
  495. * iteration is used to converge to an accurate result.
  496. *
  497. *
  498. *
  499. * ACCURACY:
  500. *
  501. * Relative error:
  502. * arithmetic domain # trials peak rms
  503. * IEEE 0,1e38 100000 7.6e-8 2.7e-8
  504. *
  505. */
  506. /* chbevlf.c
  507. *
  508. * Evaluate Chebyshev series
  509. *
  510. *
  511. *
  512. * SYNOPSIS:
  513. *
  514. * int N;
  515. * float x, y, coef[N], chebevlf();
  516. *
  517. * y = chbevlf( x, coef, N );
  518. *
  519. *
  520. *
  521. * DESCRIPTION:
  522. *
  523. * Evaluates the series
  524. *
  525. * N-1
  526. * - '
  527. * y = > coef[i] T (x/2)
  528. * - i
  529. * i=0
  530. *
  531. * of Chebyshev polynomials Ti at argument x/2.
  532. *
  533. * Coefficients are stored in reverse order, i.e. the zero
  534. * order term is last in the array. Note N is the number of
  535. * coefficients, not the order.
  536. *
  537. * If coefficients are for the interval a to b, x must
  538. * have been transformed to x -> 2(2x - b - a)/(b-a) before
  539. * entering the routine. This maps x from (a, b) to (-1, 1),
  540. * over which the Chebyshev polynomials are defined.
  541. *
  542. * If the coefficients are for the inverted interval, in
  543. * which (a, b) is mapped to (1/b, 1/a), the transformation
  544. * required is x -> 2(2ab/x - b - a)/(b-a). If b is infinity,
  545. * this becomes x -> 4a/x - 1.
  546. *
  547. *
  548. *
  549. * SPEED:
  550. *
  551. * Taking advantage of the recurrence properties of the
  552. * Chebyshev polynomials, the routine requires one more
  553. * addition per loop than evaluating a nested polynomial of
  554. * the same degree.
  555. *
  556. */
  557. /* chdtrf.c
  558. *
  559. * Chi-square distribution
  560. *
  561. *
  562. *
  563. * SYNOPSIS:
  564. *
  565. * float df, x, y, chdtrf();
  566. *
  567. * y = chdtrf( df, x );
  568. *
  569. *
  570. *
  571. * DESCRIPTION:
  572. *
  573. * Returns the area under the left hand tail (from 0 to x)
  574. * of the Chi square probability density function with
  575. * v degrees of freedom.
  576. *
  577. *
  578. * inf.
  579. * -
  580. * 1 | | v/2-1 -t/2
  581. * P( x | v ) = ----------- | t e dt
  582. * v/2 - | |
  583. * 2 | (v/2) -
  584. * x
  585. *
  586. * where x is the Chi-square variable.
  587. *
  588. * The incomplete gamma integral is used, according to the
  589. * formula
  590. *
  591. * y = chdtr( v, x ) = igam( v/2.0, x/2.0 ).
  592. *
  593. *
  594. * The arguments must both be positive.
  595. *
  596. *
  597. *
  598. * ACCURACY:
  599. *
  600. * Relative error:
  601. * arithmetic domain # trials peak rms
  602. * IEEE 0,100 5000 3.2e-5 5.0e-6
  603. *
  604. * ERROR MESSAGES:
  605. *
  606. * message condition value returned
  607. * chdtrf domain x < 0 or v < 1 0.0
  608. */
  609. /* chdtrcf()
  610. *
  611. * Complemented Chi-square distribution
  612. *
  613. *
  614. *
  615. * SYNOPSIS:
  616. *
  617. * float v, x, y, chdtrcf();
  618. *
  619. * y = chdtrcf( v, x );
  620. *
  621. *
  622. *
  623. * DESCRIPTION:
  624. *
  625. * Returns the area under the right hand tail (from x to
  626. * infinity) of the Chi square probability density function
  627. * with v degrees of freedom:
  628. *
  629. *
  630. * inf.
  631. * -
  632. * 1 | | v/2-1 -t/2
  633. * P( x | v ) = ----------- | t e dt
  634. * v/2 - | |
  635. * 2 | (v/2) -
  636. * x
  637. *
  638. * where x is the Chi-square variable.
  639. *
  640. * The incomplete gamma integral is used, according to the
  641. * formula
  642. *
  643. * y = chdtr( v, x ) = igamc( v/2.0, x/2.0 ).
  644. *
  645. *
  646. * The arguments must both be positive.
  647. *
  648. *
  649. *
  650. * ACCURACY:
  651. *
  652. * Relative error:
  653. * arithmetic domain # trials peak rms
  654. * IEEE 0,100 5000 2.7e-5 3.2e-6
  655. *
  656. * ERROR MESSAGES:
  657. *
  658. * message condition value returned
  659. * chdtrc domain x < 0 or v < 1 0.0
  660. */
  661. /* chdtrif()
  662. *
  663. * Inverse of complemented Chi-square distribution
  664. *
  665. *
  666. *
  667. * SYNOPSIS:
  668. *
  669. * float df, x, y, chdtrif();
  670. *
  671. * x = chdtrif( df, y );
  672. *
  673. *
  674. *
  675. *
  676. * DESCRIPTION:
  677. *
  678. * Finds the Chi-square argument x such that the integral
  679. * from x to infinity of the Chi-square density is equal
  680. * to the given cumulative probability y.
  681. *
  682. * This is accomplished using the inverse gamma integral
  683. * function and the relation
  684. *
  685. * x/2 = igami( df/2, y );
  686. *
  687. *
  688. *
  689. *
  690. * ACCURACY:
  691. *
  692. * Relative error:
  693. * arithmetic domain # trials peak rms
  694. * IEEE 0,100 10000 2.2e-5 8.5e-7
  695. *
  696. * ERROR MESSAGES:
  697. *
  698. * message condition value returned
  699. * chdtri domain y < 0 or y > 1 0.0
  700. * v < 1
  701. *
  702. */
  703. /* clogf.c
  704. *
  705. * Complex natural logarithm
  706. *
  707. *
  708. *
  709. * SYNOPSIS:
  710. *
  711. * void clogf();
  712. * cmplxf z, w;
  713. *
  714. * clogf( &z, &w );
  715. *
  716. *
  717. *
  718. * DESCRIPTION:
  719. *
  720. * Returns complex logarithm to the base e (2.718...) of
  721. * the complex argument x.
  722. *
  723. * If z = x + iy, r = sqrt( x**2 + y**2 ),
  724. * then
  725. * w = log(r) + i arctan(y/x).
  726. *
  727. * The arctangent ranges from -PI to +PI.
  728. *
  729. *
  730. * ACCURACY:
  731. *
  732. * Relative error:
  733. * arithmetic domain # trials peak rms
  734. * IEEE -10,+10 30000 1.9e-6 6.2e-8
  735. *
  736. * Larger relative error can be observed for z near 1 +i0.
  737. * In IEEE arithmetic the peak absolute error is 3.1e-7.
  738. *
  739. */
  740. /* cexpf()
  741. *
  742. * Complex exponential function
  743. *
  744. *
  745. *
  746. * SYNOPSIS:
  747. *
  748. * void cexpf();
  749. * cmplxf z, w;
  750. *
  751. * cexpf( &z, &w );
  752. *
  753. *
  754. *
  755. * DESCRIPTION:
  756. *
  757. * Returns the exponential of the complex argument z
  758. * into the complex result w.
  759. *
  760. * If
  761. * z = x + iy,
  762. * r = exp(x),
  763. *
  764. * then
  765. *
  766. * w = r cos y + i r sin y.
  767. *
  768. *
  769. * ACCURACY:
  770. *
  771. * Relative error:
  772. * arithmetic domain # trials peak rms
  773. * IEEE -10,+10 30000 1.4e-7 4.5e-8
  774. *
  775. */
  776. /* csinf()
  777. *
  778. * Complex circular sine
  779. *
  780. *
  781. *
  782. * SYNOPSIS:
  783. *
  784. * void csinf();
  785. * cmplxf z, w;
  786. *
  787. * csinf( &z, &w );
  788. *
  789. *
  790. *
  791. * DESCRIPTION:
  792. *
  793. * If
  794. * z = x + iy,
  795. *
  796. * then
  797. *
  798. * w = sin x cosh y + i cos x sinh y.
  799. *
  800. *
  801. *
  802. * ACCURACY:
  803. *
  804. * Relative error:
  805. * arithmetic domain # trials peak rms
  806. * IEEE -10,+10 30000 1.9e-7 5.5e-8
  807. *
  808. */
  809. /* ccosf()
  810. *
  811. * Complex circular cosine
  812. *
  813. *
  814. *
  815. * SYNOPSIS:
  816. *
  817. * void ccosf();
  818. * cmplxf z, w;
  819. *
  820. * ccosf( &z, &w );
  821. *
  822. *
  823. *
  824. * DESCRIPTION:
  825. *
  826. * If
  827. * z = x + iy,
  828. *
  829. * then
  830. *
  831. * w = cos x cosh y - i sin x sinh y.
  832. *
  833. *
  834. *
  835. * ACCURACY:
  836. *
  837. * Relative error:
  838. * arithmetic domain # trials peak rms
  839. * IEEE -10,+10 30000 1.8e-7 5.5e-8
  840. */
  841. /* ctanf()
  842. *
  843. * Complex circular tangent
  844. *
  845. *
  846. *
  847. * SYNOPSIS:
  848. *
  849. * void ctanf();
  850. * cmplxf z, w;
  851. *
  852. * ctanf( &z, &w );
  853. *
  854. *
  855. *
  856. * DESCRIPTION:
  857. *
  858. * If
  859. * z = x + iy,
  860. *
  861. * then
  862. *
  863. * sin 2x + i sinh 2y
  864. * w = --------------------.
  865. * cos 2x + cosh 2y
  866. *
  867. * On the real axis the denominator is zero at odd multiples
  868. * of PI/2. The denominator is evaluated by its Taylor
  869. * series near these points.
  870. *
  871. *
  872. * ACCURACY:
  873. *
  874. * Relative error:
  875. * arithmetic domain # trials peak rms
  876. * IEEE -10,+10 30000 3.3e-7 5.1e-8
  877. */
  878. /* ccotf()
  879. *
  880. * Complex circular cotangent
  881. *
  882. *
  883. *
  884. * SYNOPSIS:
  885. *
  886. * void ccotf();
  887. * cmplxf z, w;
  888. *
  889. * ccotf( &z, &w );
  890. *
  891. *
  892. *
  893. * DESCRIPTION:
  894. *
  895. * If
  896. * z = x + iy,
  897. *
  898. * then
  899. *
  900. * sin 2x - i sinh 2y
  901. * w = --------------------.
  902. * cosh 2y - cos 2x
  903. *
  904. * On the real axis, the denominator has zeros at even
  905. * multiples of PI/2. Near these points it is evaluated
  906. * by a Taylor series.
  907. *
  908. *
  909. * ACCURACY:
  910. *
  911. * Relative error:
  912. * arithmetic domain # trials peak rms
  913. * IEEE -10,+10 30000 3.6e-7 5.7e-8
  914. * Also tested by ctan * ccot = 1 + i0.
  915. */
  916. /* casinf()
  917. *
  918. * Complex circular arc sine
  919. *
  920. *
  921. *
  922. * SYNOPSIS:
  923. *
  924. * void casinf();
  925. * cmplxf z, w;
  926. *
  927. * casinf( &z, &w );
  928. *
  929. *
  930. *
  931. * DESCRIPTION:
  932. *
  933. * Inverse complex sine:
  934. *
  935. * 2
  936. * w = -i clog( iz + csqrt( 1 - z ) ).
  937. *
  938. *
  939. * ACCURACY:
  940. *
  941. * Relative error:
  942. * arithmetic domain # trials peak rms
  943. * IEEE -10,+10 30000 1.1e-5 1.5e-6
  944. * Larger relative error can be observed for z near zero.
  945. *
  946. */
  947. /* cacosf()
  948. *
  949. * Complex circular arc cosine
  950. *
  951. *
  952. *
  953. * SYNOPSIS:
  954. *
  955. * void cacosf();
  956. * cmplxf z, w;
  957. *
  958. * cacosf( &z, &w );
  959. *
  960. *
  961. *
  962. * DESCRIPTION:
  963. *
  964. *
  965. * w = arccos z = PI/2 - arcsin z.
  966. *
  967. *
  968. *
  969. *
  970. * ACCURACY:
  971. *
  972. * Relative error:
  973. * arithmetic domain # trials peak rms
  974. * IEEE -10,+10 30000 9.2e-6 1.2e-6
  975. *
  976. */
  977. /* catan()
  978. *
  979. * Complex circular arc tangent
  980. *
  981. *
  982. *
  983. * SYNOPSIS:
  984. *
  985. * void catan();
  986. * cmplxf z, w;
  987. *
  988. * catan( &z, &w );
  989. *
  990. *
  991. *
  992. * DESCRIPTION:
  993. *
  994. * If
  995. * z = x + iy,
  996. *
  997. * then
  998. * 1 ( 2x )
  999. * Re w = - arctan(-----------) + k PI
  1000. * 2 ( 2 2)
  1001. * (1 - x - y )
  1002. *
  1003. * ( 2 2)
  1004. * 1 (x + (y+1) )
  1005. * Im w = - log(------------)
  1006. * 4 ( 2 2)
  1007. * (x + (y-1) )
  1008. *
  1009. * Where k is an arbitrary integer.
  1010. *
  1011. *
  1012. *
  1013. * ACCURACY:
  1014. *
  1015. * Relative error:
  1016. * arithmetic domain # trials peak rms
  1017. * IEEE -10,+10 30000 2.3e-6 5.2e-8
  1018. *
  1019. */
  1020. /* cmplxf.c
  1021. *
  1022. * Complex number arithmetic
  1023. *
  1024. *
  1025. *
  1026. * SYNOPSIS:
  1027. *
  1028. * typedef struct {
  1029. * float r; real part
  1030. * float i; imaginary part
  1031. * }cmplxf;
  1032. *
  1033. * cmplxf *a, *b, *c;
  1034. *
  1035. * caddf( a, b, c ); c = b + a
  1036. * csubf( a, b, c ); c = b - a
  1037. * cmulf( a, b, c ); c = b * a
  1038. * cdivf( a, b, c ); c = b / a
  1039. * cnegf( c ); c = -c
  1040. * cmovf( b, c ); c = b
  1041. *
  1042. *
  1043. *
  1044. * DESCRIPTION:
  1045. *
  1046. * Addition:
  1047. * c.r = b.r + a.r
  1048. * c.i = b.i + a.i
  1049. *
  1050. * Subtraction:
  1051. * c.r = b.r - a.r
  1052. * c.i = b.i - a.i
  1053. *
  1054. * Multiplication:
  1055. * c.r = b.r * a.r - b.i * a.i
  1056. * c.i = b.r * a.i + b.i * a.r
  1057. *
  1058. * Division:
  1059. * d = a.r * a.r + a.i * a.i
  1060. * c.r = (b.r * a.r + b.i * a.i)/d
  1061. * c.i = (b.i * a.r - b.r * a.i)/d
  1062. * ACCURACY:
  1063. *
  1064. * In DEC arithmetic, the test (1/z) * z = 1 had peak relative
  1065. * error 3.1e-17, rms 1.2e-17. The test (y/z) * (z/y) = 1 had
  1066. * peak relative error 8.3e-17, rms 2.1e-17.
  1067. *
  1068. * Tests in the rectangle {-10,+10}:
  1069. * Relative error:
  1070. * arithmetic function # trials peak rms
  1071. * IEEE cadd 30000 5.9e-8 2.6e-8
  1072. * IEEE csub 30000 6.0e-8 2.6e-8
  1073. * IEEE cmul 30000 1.1e-7 3.7e-8
  1074. * IEEE cdiv 30000 2.1e-7 5.7e-8
  1075. */
  1076. /* cabsf()
  1077. *
  1078. * Complex absolute value
  1079. *
  1080. *
  1081. *
  1082. * SYNOPSIS:
  1083. *
  1084. * float cabsf();
  1085. * cmplxf z;
  1086. * float a;
  1087. *
  1088. * a = cabsf( &z );
  1089. *
  1090. *
  1091. *
  1092. * DESCRIPTION:
  1093. *
  1094. *
  1095. * If z = x + iy
  1096. *
  1097. * then
  1098. *
  1099. * a = sqrt( x**2 + y**2 ).
  1100. *
  1101. * Overflow and underflow are avoided by testing the magnitudes
  1102. * of x and y before squaring. If either is outside half of
  1103. * the floating point full scale range, both are rescaled.
  1104. *
  1105. *
  1106. * ACCURACY:
  1107. *
  1108. * Relative error:
  1109. * arithmetic domain # trials peak rms
  1110. * IEEE -10,+10 30000 1.2e-7 3.4e-8
  1111. */
  1112. /* csqrtf()
  1113. *
  1114. * Complex square root
  1115. *
  1116. *
  1117. *
  1118. * SYNOPSIS:
  1119. *
  1120. * void csqrtf();
  1121. * cmplxf z, w;
  1122. *
  1123. * csqrtf( &z, &w );
  1124. *
  1125. *
  1126. *
  1127. * DESCRIPTION:
  1128. *
  1129. *
  1130. * If z = x + iy, r = |z|, then
  1131. *
  1132. * 1/2
  1133. * Im w = [ (r - x)/2 ] ,
  1134. *
  1135. * Re w = y / 2 Im w.
  1136. *
  1137. *
  1138. * Note that -w is also a square root of z. The solution
  1139. * reported is always in the upper half plane.
  1140. *
  1141. * Because of the potential for cancellation error in r - x,
  1142. * the result is sharpened by doing a Heron iteration
  1143. * (see sqrt.c) in complex arithmetic.
  1144. *
  1145. *
  1146. *
  1147. * ACCURACY:
  1148. *
  1149. * Relative error:
  1150. * arithmetic domain # trials peak rms
  1151. * IEEE -10,+10 100000 1.8e-7 4.2e-8
  1152. *
  1153. */
  1154. /* coshf.c
  1155. *
  1156. * Hyperbolic cosine
  1157. *
  1158. *
  1159. *
  1160. * SYNOPSIS:
  1161. *
  1162. * float x, y, coshf();
  1163. *
  1164. * y = coshf( x );
  1165. *
  1166. *
  1167. *
  1168. * DESCRIPTION:
  1169. *
  1170. * Returns hyperbolic cosine of argument in the range MINLOGF to
  1171. * MAXLOGF.
  1172. *
  1173. * cosh(x) = ( exp(x) + exp(-x) )/2.
  1174. *
  1175. *
  1176. *
  1177. * ACCURACY:
  1178. *
  1179. * Relative error:
  1180. * arithmetic domain # trials peak rms
  1181. * IEEE +-MAXLOGF 100000 1.2e-7 2.8e-8
  1182. *
  1183. *
  1184. * ERROR MESSAGES:
  1185. *
  1186. * message condition value returned
  1187. * coshf overflow |x| > MAXLOGF MAXNUMF
  1188. *
  1189. *
  1190. */
  1191. /* dawsnf.c
  1192. *
  1193. * Dawson's Integral
  1194. *
  1195. *
  1196. *
  1197. * SYNOPSIS:
  1198. *
  1199. * float x, y, dawsnf();
  1200. *
  1201. * y = dawsnf( x );
  1202. *
  1203. *
  1204. *
  1205. * DESCRIPTION:
  1206. *
  1207. * Approximates the integral
  1208. *
  1209. * x
  1210. * -
  1211. * 2 | | 2
  1212. * dawsn(x) = exp( -x ) | exp( t ) dt
  1213. * | |
  1214. * -
  1215. * 0
  1216. *
  1217. * Three different rational approximations are employed, for
  1218. * the intervals 0 to 3.25; 3.25 to 6.25; and 6.25 up.
  1219. *
  1220. *
  1221. * ACCURACY:
  1222. *
  1223. * Relative error:
  1224. * arithmetic domain # trials peak rms
  1225. * IEEE 0,10 50000 4.4e-7 6.3e-8
  1226. *
  1227. *
  1228. */
  1229. /* ellief.c
  1230. *
  1231. * Incomplete elliptic integral of the second kind
  1232. *
  1233. *
  1234. *
  1235. * SYNOPSIS:
  1236. *
  1237. * float phi, m, y, ellief();
  1238. *
  1239. * y = ellief( phi, m );
  1240. *
  1241. *
  1242. *
  1243. * DESCRIPTION:
  1244. *
  1245. * Approximates the integral
  1246. *
  1247. *
  1248. * phi
  1249. * -
  1250. * | |
  1251. * | 2
  1252. * E(phi\m) = | sqrt( 1 - m sin t ) dt
  1253. * |
  1254. * | |
  1255. * -
  1256. * 0
  1257. *
  1258. * of amplitude phi and modulus m, using the arithmetic -
  1259. * geometric mean algorithm.
  1260. *
  1261. *
  1262. *
  1263. * ACCURACY:
  1264. *
  1265. * Tested at random arguments with phi in [0, 2] and m in
  1266. * [0, 1].
  1267. * Relative error:
  1268. * arithmetic domain # trials peak rms
  1269. * IEEE 0,2 10000 4.5e-7 7.4e-8
  1270. *
  1271. *
  1272. */
  1273. /* ellikf.c
  1274. *
  1275. * Incomplete elliptic integral of the first kind
  1276. *
  1277. *
  1278. *
  1279. * SYNOPSIS:
  1280. *
  1281. * float phi, m, y, ellikf();
  1282. *
  1283. * y = ellikf( phi, m );
  1284. *
  1285. *
  1286. *
  1287. * DESCRIPTION:
  1288. *
  1289. * Approximates the integral
  1290. *
  1291. *
  1292. *
  1293. * phi
  1294. * -
  1295. * | |
  1296. * | dt
  1297. * F(phi\m) = | ------------------
  1298. * | 2
  1299. * | | sqrt( 1 - m sin t )
  1300. * -
  1301. * 0
  1302. *
  1303. * of amplitude phi and modulus m, using the arithmetic -
  1304. * geometric mean algorithm.
  1305. *
  1306. *
  1307. *
  1308. *
  1309. * ACCURACY:
  1310. *
  1311. * Tested at random points with phi in [0, 2] and m in
  1312. * [0, 1].
  1313. * Relative error:
  1314. * arithmetic domain # trials peak rms
  1315. * IEEE 0,2 10000 2.9e-7 5.8e-8
  1316. *
  1317. *
  1318. */
  1319. /* ellpef.c
  1320. *
  1321. * Complete elliptic integral of the second kind
  1322. *
  1323. *
  1324. *
  1325. * SYNOPSIS:
  1326. *
  1327. * float m1, y, ellpef();
  1328. *
  1329. * y = ellpef( m1 );
  1330. *
  1331. *
  1332. *
  1333. * DESCRIPTION:
  1334. *
  1335. * Approximates the integral
  1336. *
  1337. *
  1338. * pi/2
  1339. * -
  1340. * | | 2
  1341. * E(m) = | sqrt( 1 - m sin t ) dt
  1342. * | |
  1343. * -
  1344. * 0
  1345. *
  1346. * Where m = 1 - m1, using the approximation
  1347. *
  1348. * P(x) - x log x Q(x).
  1349. *
  1350. * Though there are no singularities, the argument m1 is used
  1351. * rather than m for compatibility with ellpk().
  1352. *
  1353. * E(1) = 1; E(0) = pi/2.
  1354. *
  1355. *
  1356. * ACCURACY:
  1357. *
  1358. * Relative error:
  1359. * arithmetic domain # trials peak rms
  1360. * IEEE 0, 1 30000 1.1e-7 3.9e-8
  1361. *
  1362. *
  1363. * ERROR MESSAGES:
  1364. *
  1365. * message condition value returned
  1366. * ellpef domain x<0, x>1 0.0
  1367. *
  1368. */
  1369. /* ellpjf.c
  1370. *
  1371. * Jacobian Elliptic Functions
  1372. *
  1373. *
  1374. *
  1375. * SYNOPSIS:
  1376. *
  1377. * float u, m, sn, cn, dn, phi;
  1378. * int ellpj();
  1379. *
  1380. * ellpj( u, m, _&sn, _&cn, _&dn, _&phi );
  1381. *
  1382. *
  1383. *
  1384. * DESCRIPTION:
  1385. *
  1386. *
  1387. * Evaluates the Jacobian elliptic functions sn(u|m), cn(u|m),
  1388. * and dn(u|m) of parameter m between 0 and 1, and real
  1389. * argument u.
  1390. *
  1391. * These functions are periodic, with quarter-period on the
  1392. * real axis equal to the complete elliptic integral
  1393. * ellpk(1.0-m).
  1394. *
  1395. * Relation to incomplete elliptic integral:
  1396. * If u = ellik(phi,m), then sn(u|m) = sin(phi),
  1397. * and cn(u|m) = cos(phi). Phi is called the amplitude of u.
  1398. *
  1399. * Computation is by means of the arithmetic-geometric mean
  1400. * algorithm, except when m is within 1e-9 of 0 or 1. In the
  1401. * latter case with m close to 1, the approximation applies
  1402. * only for phi < pi/2.
  1403. *
  1404. * ACCURACY:
  1405. *
  1406. * Tested at random points with u between 0 and 10, m between
  1407. * 0 and 1.
  1408. *
  1409. * Absolute error (* = relative error):
  1410. * arithmetic function # trials peak rms
  1411. * IEEE sn 10000 1.7e-6 2.2e-7
  1412. * IEEE cn 10000 1.6e-6 2.2e-7
  1413. * IEEE dn 10000 1.4e-3 1.9e-5
  1414. * IEEE phi 10000 3.9e-7* 6.7e-8*
  1415. *
  1416. * Peak error observed in consistency check using addition
  1417. * theorem for sn(u+v) was 4e-16 (absolute). Also tested by
  1418. * the above relation to the incomplete elliptic integral.
  1419. * Accuracy deteriorates when u is large.
  1420. *
  1421. */
  1422. /* ellpkf.c
  1423. *
  1424. * Complete elliptic integral of the first kind
  1425. *
  1426. *
  1427. *
  1428. * SYNOPSIS:
  1429. *
  1430. * float m1, y, ellpkf();
  1431. *
  1432. * y = ellpkf( m1 );
  1433. *
  1434. *
  1435. *
  1436. * DESCRIPTION:
  1437. *
  1438. * Approximates the integral
  1439. *
  1440. *
  1441. *
  1442. * pi/2
  1443. * -
  1444. * | |
  1445. * | dt
  1446. * K(m) = | ------------------
  1447. * | 2
  1448. * | | sqrt( 1 - m sin t )
  1449. * -
  1450. * 0
  1451. *
  1452. * where m = 1 - m1, using the approximation
  1453. *
  1454. * P(x) - log x Q(x).
  1455. *
  1456. * The argument m1 is used rather than m so that the logarithmic
  1457. * singularity at m = 1 will be shifted to the origin; this
  1458. * preserves maximum accuracy.
  1459. *
  1460. * K(0) = pi/2.
  1461. *
  1462. * ACCURACY:
  1463. *
  1464. * Relative error:
  1465. * arithmetic domain # trials peak rms
  1466. * IEEE 0,1 30000 1.3e-7 3.4e-8
  1467. *
  1468. * ERROR MESSAGES:
  1469. *
  1470. * message condition value returned
  1471. * ellpkf domain x<0, x>1 0.0
  1472. *
  1473. */
  1474. /* exp10f.c
  1475. *
  1476. * Base 10 exponential function
  1477. * (Common antilogarithm)
  1478. *
  1479. *
  1480. *
  1481. * SYNOPSIS:
  1482. *
  1483. * float x, y, exp10f();
  1484. *
  1485. * y = exp10f( x );
  1486. *
  1487. *
  1488. *
  1489. * DESCRIPTION:
  1490. *
  1491. * Returns 10 raised to the x power.
  1492. *
  1493. * Range reduction is accomplished by expressing the argument
  1494. * as 10**x = 2**n 10**f, with |f| < 0.5 log10(2).
  1495. * A polynomial approximates 10**f.
  1496. *
  1497. *
  1498. *
  1499. * ACCURACY:
  1500. *
  1501. * Relative error:
  1502. * arithmetic domain # trials peak rms
  1503. * IEEE -38,+38 100000 9.8e-8 2.8e-8
  1504. *
  1505. * ERROR MESSAGES:
  1506. *
  1507. * message condition value returned
  1508. * exp10 underflow x < -MAXL10 0.0
  1509. * exp10 overflow x > MAXL10 MAXNUM
  1510. *
  1511. * IEEE single arithmetic: MAXL10 = 38.230809449325611792.
  1512. *
  1513. */
  1514. /* exp2f.c
  1515. *
  1516. * Base 2 exponential function
  1517. *
  1518. *
  1519. *
  1520. * SYNOPSIS:
  1521. *
  1522. * float x, y, exp2f();
  1523. *
  1524. * y = exp2f( x );
  1525. *
  1526. *
  1527. *
  1528. * DESCRIPTION:
  1529. *
  1530. * Returns 2 raised to the x power.
  1531. *
  1532. * Range reduction is accomplished by separating the argument
  1533. * into an integer k and fraction f such that
  1534. * x k f
  1535. * 2 = 2 2.
  1536. *
  1537. * A polynomial approximates 2**x in the basic range [-0.5, 0.5].
  1538. *
  1539. *
  1540. * ACCURACY:
  1541. *
  1542. * Relative error:
  1543. * arithmetic domain # trials peak rms
  1544. * IEEE -127,+127 100000 1.7e-7 2.8e-8
  1545. *
  1546. *
  1547. * See exp.c for comments on error amplification.
  1548. *
  1549. *
  1550. * ERROR MESSAGES:
  1551. *
  1552. * message condition value returned
  1553. * exp underflow x < -MAXL2 0.0
  1554. * exp overflow x > MAXL2 MAXNUMF
  1555. *
  1556. * For IEEE arithmetic, MAXL2 = 127.
  1557. */
  1558. /* expf.c
  1559. *
  1560. * Exponential function
  1561. *
  1562. *
  1563. *
  1564. * SYNOPSIS:
  1565. *
  1566. * float x, y, expf();
  1567. *
  1568. * y = expf( x );
  1569. *
  1570. *
  1571. *
  1572. * DESCRIPTION:
  1573. *
  1574. * Returns e (2.71828...) raised to the x power.
  1575. *
  1576. * Range reduction is accomplished by separating the argument
  1577. * into an integer k and fraction f such that
  1578. *
  1579. * x k f
  1580. * e = 2 e.
  1581. *
  1582. * A polynomial is used to approximate exp(f)
  1583. * in the basic range [-0.5, 0.5].
  1584. *
  1585. *
  1586. * ACCURACY:
  1587. *
  1588. * Relative error:
  1589. * arithmetic domain # trials peak rms
  1590. * IEEE +- MAXLOG 100000 1.7e-7 2.8e-8
  1591. *
  1592. *
  1593. * Error amplification in the exponential function can be
  1594. * a serious matter. The error propagation involves
  1595. * exp( X(1+delta) ) = exp(X) ( 1 + X*delta + ... ),
  1596. * which shows that a 1 lsb error in representing X produces
  1597. * a relative error of X times 1 lsb in the function.
  1598. * While the routine gives an accurate result for arguments
  1599. * that are exactly represented by a double precision
  1600. * computer number, the result contains amplified roundoff
  1601. * error for large arguments not exactly represented.
  1602. *
  1603. *
  1604. * ERROR MESSAGES:
  1605. *
  1606. * message condition value returned
  1607. * expf underflow x < MINLOGF 0.0
  1608. * expf overflow x > MAXLOGF MAXNUMF
  1609. *
  1610. */
  1611. /* expnf.c
  1612. *
  1613. * Exponential integral En
  1614. *
  1615. *
  1616. *
  1617. * SYNOPSIS:
  1618. *
  1619. * int n;
  1620. * float x, y, expnf();
  1621. *
  1622. * y = expnf( n, x );
  1623. *
  1624. *
  1625. *
  1626. * DESCRIPTION:
  1627. *
  1628. * Evaluates the exponential integral
  1629. *
  1630. * inf.
  1631. * -
  1632. * | | -xt
  1633. * | e
  1634. * E (x) = | ---- dt.
  1635. * n | n
  1636. * | | t
  1637. * -
  1638. * 1
  1639. *
  1640. *
  1641. * Both n and x must be nonnegative.
  1642. *
  1643. * The routine employs either a power series, a continued
  1644. * fraction, or an asymptotic formula depending on the
  1645. * relative values of n and x.
  1646. *
  1647. * ACCURACY:
  1648. *
  1649. * Relative error:
  1650. * arithmetic domain # trials peak rms
  1651. * IEEE 0, 30 10000 5.6e-7 1.2e-7
  1652. *
  1653. */
  1654. /* facf.c
  1655. *
  1656. * Factorial function
  1657. *
  1658. *
  1659. *
  1660. * SYNOPSIS:
  1661. *
  1662. * float y, facf();
  1663. * int i;
  1664. *
  1665. * y = facf( i );
  1666. *
  1667. *
  1668. *
  1669. * DESCRIPTION:
  1670. *
  1671. * Returns factorial of i = 1 * 2 * 3 * ... * i.
  1672. * fac(0) = 1.0.
  1673. *
  1674. * Due to machine arithmetic bounds the largest value of
  1675. * i accepted is 33 in single precision arithmetic.
  1676. * Greater values, or negative ones,
  1677. * produce an error message and return MAXNUM.
  1678. *
  1679. *
  1680. *
  1681. * ACCURACY:
  1682. *
  1683. * For i < 34 the values are simply tabulated, and have
  1684. * full machine accuracy.
  1685. *
  1686. */
  1687. /* fdtrf.c
  1688. *
  1689. * F distribution
  1690. *
  1691. *
  1692. *
  1693. * SYNOPSIS:
  1694. *
  1695. * int df1, df2;
  1696. * float x, y, fdtrf();
  1697. *
  1698. * y = fdtrf( df1, df2, x );
  1699. *
  1700. *
  1701. *
  1702. * DESCRIPTION:
  1703. *
  1704. * Returns the area from zero to x under the F density
  1705. * function (also known as Snedcor's density or the
  1706. * variance ratio density). This is the density
  1707. * of x = (u1/df1)/(u2/df2), where u1 and u2 are random
  1708. * variables having Chi square distributions with df1
  1709. * and df2 degrees of freedom, respectively.
  1710. *
  1711. * The incomplete beta integral is used, according to the
  1712. * formula
  1713. *
  1714. * P(x) = incbet( df1/2, df2/2, (df1*x/(df2 + df1*x) ).
  1715. *
  1716. *
  1717. * The arguments a and b are greater than zero, and x
  1718. * x is nonnegative.
  1719. * ACCURACY:
  1720. *
  1721. * Relative error:
  1722. * arithmetic domain # trials peak rms
  1723. * IEEE 0,100 5000 2.2e-5 1.1e-6
  1724. *
  1725. * ERROR MESSAGES:
  1726. *
  1727. * message condition value returned
  1728. * fdtrf domain a<0, b<0, x<0 0.0
  1729. *
  1730. */
  1731. /* fdtrcf()
  1732. *
  1733. * Complemented F distribution
  1734. *
  1735. *
  1736. *
  1737. * SYNOPSIS:
  1738. *
  1739. * int df1, df2;
  1740. * float x, y, fdtrcf();
  1741. *
  1742. * y = fdtrcf( df1, df2, x );
  1743. *
  1744. *
  1745. *
  1746. * DESCRIPTION:
  1747. *
  1748. * Returns the area from x to infinity under the F density
  1749. * function (also known as Snedcor's density or the
  1750. * variance ratio density).
  1751. *
  1752. *
  1753. * inf.
  1754. * -
  1755. * 1 | | a-1 b-1
  1756. * 1-P(x) = ------ | t (1-t) dt
  1757. * B(a,b) | |
  1758. * -
  1759. * x
  1760. *
  1761. * (See fdtr.c.)
  1762. *
  1763. * The incomplete beta integral is used, according to the
  1764. * formula
  1765. *
  1766. * P(x) = incbet( df2/2, df1/2, (df2/(df2 + df1*x) ).
  1767. *
  1768. *
  1769. * ACCURACY:
  1770. *
  1771. * Relative error:
  1772. * arithmetic domain # trials peak rms
  1773. * IEEE 0,100 5000 7.3e-5 1.2e-5
  1774. *
  1775. * ERROR MESSAGES:
  1776. *
  1777. * message condition value returned
  1778. * fdtrcf domain a<0, b<0, x<0 0.0
  1779. *
  1780. */
  1781. /* fdtrif()
  1782. *
  1783. * Inverse of complemented F distribution
  1784. *
  1785. *
  1786. *
  1787. * SYNOPSIS:
  1788. *
  1789. * float df1, df2, x, y, fdtrif();
  1790. *
  1791. * x = fdtrif( df1, df2, y );
  1792. *
  1793. *
  1794. *
  1795. *
  1796. * DESCRIPTION:
  1797. *
  1798. * Finds the F density argument x such that the integral
  1799. * from x to infinity of the F density is equal to the
  1800. * given probability y.
  1801. *
  1802. * This is accomplished using the inverse beta integral
  1803. * function and the relations
  1804. *
  1805. * z = incbi( df2/2, df1/2, y )
  1806. * x = df2 (1-z) / (df1 z).
  1807. *
  1808. * Note: the following relations hold for the inverse of
  1809. * the uncomplemented F distribution:
  1810. *
  1811. * z = incbi( df1/2, df2/2, y )
  1812. * x = df2 z / (df1 (1-z)).
  1813. *
  1814. *
  1815. *
  1816. * ACCURACY:
  1817. *
  1818. * arithmetic domain # trials peak rms
  1819. * Absolute error:
  1820. * IEEE 0,100 5000 4.0e-5 3.2e-6
  1821. * Relative error:
  1822. * IEEE 0,100 5000 1.2e-3 1.8e-5
  1823. *
  1824. * ERROR MESSAGES:
  1825. *
  1826. * message condition value returned
  1827. * fdtrif domain y <= 0 or y > 1 0.0
  1828. * v < 1
  1829. *
  1830. */
  1831. /* ceilf()
  1832. * floorf()
  1833. * frexpf()
  1834. * ldexpf()
  1835. *
  1836. * Single precision floating point numeric utilities
  1837. *
  1838. *
  1839. *
  1840. * SYNOPSIS:
  1841. *
  1842. * float x, y;
  1843. * float ceilf(), floorf(), frexpf(), ldexpf();
  1844. * int expnt, n;
  1845. *
  1846. * y = floorf(x);
  1847. * y = ceilf(x);
  1848. * y = frexpf( x, &expnt );
  1849. * y = ldexpf( x, n );
  1850. *
  1851. *
  1852. *
  1853. * DESCRIPTION:
  1854. *
  1855. * All four routines return a single precision floating point
  1856. * result.
  1857. *
  1858. * sfloor() returns the largest integer less than or equal to x.
  1859. * It truncates toward minus infinity.
  1860. *
  1861. * sceil() returns the smallest integer greater than or equal
  1862. * to x. It truncates toward plus infinity.
  1863. *
  1864. * sfrexp() extracts the exponent from x. It returns an integer
  1865. * power of two to expnt and the significand between 0.5 and 1
  1866. * to y. Thus x = y * 2**expn.
  1867. *
  1868. * sldexp() multiplies x by 2**n.
  1869. *
  1870. * These functions are part of the standard C run time library
  1871. * for many but not all C compilers. The ones supplied are
  1872. * written in C for either DEC or IEEE arithmetic. They should
  1873. * be used only if your compiler library does not already have
  1874. * them.
  1875. *
  1876. * The IEEE versions assume that denormal numbers are implemented
  1877. * in the arithmetic. Some modifications will be required if
  1878. * the arithmetic has abrupt rather than gradual underflow.
  1879. */
  1880. /* fresnlf.c
  1881. *
  1882. * Fresnel integral
  1883. *
  1884. *
  1885. *
  1886. * SYNOPSIS:
  1887. *
  1888. * float x, S, C;
  1889. * void fresnlf();
  1890. *
  1891. * fresnlf( x, _&S, _&C );
  1892. *
  1893. *
  1894. * DESCRIPTION:
  1895. *
  1896. * Evaluates the Fresnel integrals
  1897. *
  1898. * x
  1899. * -
  1900. * | |
  1901. * C(x) = | cos(pi/2 t**2) dt,
  1902. * | |
  1903. * -
  1904. * 0
  1905. *
  1906. * x
  1907. * -
  1908. * | |
  1909. * S(x) = | sin(pi/2 t**2) dt.
  1910. * | |
  1911. * -
  1912. * 0
  1913. *
  1914. *
  1915. * The integrals are evaluated by power series for small x.
  1916. * For x >= 1 auxiliary functions f(x) and g(x) are employed
  1917. * such that
  1918. *
  1919. * C(x) = 0.5 + f(x) sin( pi/2 x**2 ) - g(x) cos( pi/2 x**2 )
  1920. * S(x) = 0.5 - f(x) cos( pi/2 x**2 ) - g(x) sin( pi/2 x**2 )
  1921. *
  1922. *
  1923. *
  1924. * ACCURACY:
  1925. *
  1926. * Relative error.
  1927. *
  1928. * Arithmetic function domain # trials peak rms
  1929. * IEEE S(x) 0, 10 30000 1.1e-6 1.9e-7
  1930. * IEEE C(x) 0, 10 30000 1.1e-6 2.0e-7
  1931. */
  1932. /* gammaf.c
  1933. *
  1934. * Gamma function
  1935. *
  1936. *
  1937. *
  1938. * SYNOPSIS:
  1939. *
  1940. * float x, y, gammaf();
  1941. * extern int sgngamf;
  1942. *
  1943. * y = gammaf( x );
  1944. *
  1945. *
  1946. *
  1947. * DESCRIPTION:
  1948. *
  1949. * Returns gamma function of the argument. The result is
  1950. * correctly signed, and the sign (+1 or -1) is also
  1951. * returned in a global (extern) variable named sgngamf.
  1952. * This same variable is also filled in by the logarithmic
  1953. * gamma function lgam().
  1954. *
  1955. * Arguments between 0 and 10 are reduced by recurrence and the
  1956. * function is approximated by a polynomial function covering
  1957. * the interval (2,3). Large arguments are handled by Stirling's
  1958. * formula. Negative arguments are made positive using
  1959. * a reflection formula.
  1960. *
  1961. *
  1962. * ACCURACY:
  1963. *
  1964. * Relative error:
  1965. * arithmetic domain # trials peak rms
  1966. * IEEE 0,-33 100,000 5.7e-7 1.0e-7
  1967. * IEEE -33,0 100,000 6.1e-7 1.2e-7
  1968. *
  1969. *
  1970. */
  1971. /* lgamf()
  1972. *
  1973. * Natural logarithm of gamma function
  1974. *
  1975. *
  1976. *
  1977. * SYNOPSIS:
  1978. *
  1979. * float x, y, lgamf();
  1980. * extern int sgngamf;
  1981. *
  1982. * y = lgamf( x );
  1983. *
  1984. *
  1985. *
  1986. * DESCRIPTION:
  1987. *
  1988. * Returns the base e (2.718...) logarithm of the absolute
  1989. * value of the gamma function of the argument.
  1990. * The sign (+1 or -1) of the gamma function is returned in a
  1991. * global (extern) variable named sgngamf.
  1992. *
  1993. * For arguments greater than 6.5, the logarithm of the gamma
  1994. * function is approximated by the logarithmic version of
  1995. * Stirling's formula. Arguments between 0 and +6.5 are reduced by
  1996. * by recurrence to the interval [.75,1.25] or [1.5,2.5] of a rational
  1997. * approximation. The cosecant reflection formula is employed for
  1998. * arguments less than zero.
  1999. *
  2000. * Arguments greater than MAXLGM = 2.035093e36 return MAXNUM and an
  2001. * error message.
  2002. *
  2003. *
  2004. *
  2005. * ACCURACY:
  2006. *
  2007. *
  2008. *
  2009. * arithmetic domain # trials peak rms
  2010. * IEEE -100,+100 500,000 7.4e-7 6.8e-8
  2011. * The error criterion was relative when the function magnitude
  2012. * was greater than one but absolute when it was less than one.
  2013. * The routine has low relative error for positive arguments.
  2014. *
  2015. * The following test used the relative error criterion.
  2016. * IEEE -2, +3 100000 4.0e-7 5.6e-8
  2017. *
  2018. */
  2019. /* gdtrf.c
  2020. *
  2021. * Gamma distribution function
  2022. *
  2023. *
  2024. *
  2025. * SYNOPSIS:
  2026. *
  2027. * float a, b, x, y, gdtrf();
  2028. *
  2029. * y = gdtrf( a, b, x );
  2030. *
  2031. *
  2032. *
  2033. * DESCRIPTION:
  2034. *
  2035. * Returns the integral from zero to x of the gamma probability
  2036. * density function:
  2037. *
  2038. *
  2039. * x
  2040. * b -
  2041. * a | | b-1 -at
  2042. * y = ----- | t e dt
  2043. * - | |
  2044. * | (b) -
  2045. * 0
  2046. *
  2047. * The incomplete gamma integral is used, according to the
  2048. * relation
  2049. *
  2050. * y = igam( b, ax ).
  2051. *
  2052. *
  2053. * ACCURACY:
  2054. *
  2055. * Relative error:
  2056. * arithmetic domain # trials peak rms
  2057. * IEEE 0,100 5000 5.8e-5 3.0e-6
  2058. *
  2059. * ERROR MESSAGES:
  2060. *
  2061. * message condition value returned
  2062. * gdtrf domain x < 0 0.0
  2063. *
  2064. */
  2065. /* gdtrcf.c
  2066. *
  2067. * Complemented gamma distribution function
  2068. *
  2069. *
  2070. *
  2071. * SYNOPSIS:
  2072. *
  2073. * float a, b, x, y, gdtrcf();
  2074. *
  2075. * y = gdtrcf( a, b, x );
  2076. *
  2077. *
  2078. *
  2079. * DESCRIPTION:
  2080. *
  2081. * Returns the integral from x to infinity of the gamma
  2082. * probability density function:
  2083. *
  2084. *
  2085. * inf.
  2086. * b -
  2087. * a | | b-1 -at
  2088. * y = ----- | t e dt
  2089. * - | |
  2090. * | (b) -
  2091. * x
  2092. *
  2093. * The incomplete gamma integral is used, according to the
  2094. * relation
  2095. *
  2096. * y = igamc( b, ax ).
  2097. *
  2098. *
  2099. * ACCURACY:
  2100. *
  2101. * Relative error:
  2102. * arithmetic domain # trials peak rms
  2103. * IEEE 0,100 5000 9.1e-5 1.5e-5
  2104. *
  2105. * ERROR MESSAGES:
  2106. *
  2107. * message condition value returned
  2108. * gdtrcf domain x < 0 0.0
  2109. *
  2110. */
  2111. /* hyp2f1f.c
  2112. *
  2113. * Gauss hypergeometric function F
  2114. * 2 1
  2115. *
  2116. *
  2117. * SYNOPSIS:
  2118. *
  2119. * float a, b, c, x, y, hyp2f1f();
  2120. *
  2121. * y = hyp2f1f( a, b, c, x );
  2122. *
  2123. *
  2124. * DESCRIPTION:
  2125. *
  2126. *
  2127. * hyp2f1( a, b, c, x ) = F ( a, b; c; x )
  2128. * 2 1
  2129. *
  2130. * inf.
  2131. * - a(a+1)...(a+k) b(b+1)...(b+k) k+1
  2132. * = 1 + > ----------------------------- x .
  2133. * - c(c+1)...(c+k) (k+1)!
  2134. * k = 0
  2135. *
  2136. * Cases addressed are
  2137. * Tests and escapes for negative integer a, b, or c
  2138. * Linear transformation if c - a or c - b negative integer
  2139. * Special case c = a or c = b
  2140. * Linear transformation for x near +1
  2141. * Transformation for x < -0.5
  2142. * Psi function expansion if x > 0.5 and c - a - b integer
  2143. * Conditionally, a recurrence on c to make c-a-b > 0
  2144. *
  2145. * |x| > 1 is rejected.
  2146. *
  2147. * The parameters a, b, c are considered to be integer
  2148. * valued if they are within 1.0e-6 of the nearest integer.
  2149. *
  2150. * ACCURACY:
  2151. *
  2152. * Relative error (-1 < x < 1):
  2153. * arithmetic domain # trials peak rms
  2154. * IEEE 0,3 30000 5.8e-4 4.3e-6
  2155. */
  2156. /* hypergf.c
  2157. *
  2158. * Confluent hypergeometric function
  2159. *
  2160. *
  2161. *
  2162. * SYNOPSIS:
  2163. *
  2164. * float a, b, x, y, hypergf();
  2165. *
  2166. * y = hypergf( a, b, x );
  2167. *
  2168. *
  2169. *
  2170. * DESCRIPTION:
  2171. *
  2172. * Computes the confluent hypergeometric function
  2173. *
  2174. * 1 2
  2175. * a x a(a+1) x
  2176. * F ( a,b;x ) = 1 + ---- + --------- + ...
  2177. * 1 1 b 1! b(b+1) 2!
  2178. *
  2179. * Many higher transcendental functions are special cases of
  2180. * this power series.
  2181. *
  2182. * As is evident from the formula, b must not be a negative
  2183. * integer or zero unless a is an integer with 0 >= a > b.
  2184. *
  2185. * The routine attempts both a direct summation of the series
  2186. * and an asymptotic expansion. In each case error due to
  2187. * roundoff, cancellation, and nonconvergence is estimated.
  2188. * The result with smaller estimated error is returned.
  2189. *
  2190. *
  2191. *
  2192. * ACCURACY:
  2193. *
  2194. * Tested at random points (a, b, x), all three variables
  2195. * ranging from 0 to 30.
  2196. * Relative error:
  2197. * arithmetic domain # trials peak rms
  2198. * IEEE 0,5 10000 6.6e-7 1.3e-7
  2199. * IEEE 0,30 30000 1.1e-5 6.5e-7
  2200. *
  2201. * Larger errors can be observed when b is near a negative
  2202. * integer or zero. Certain combinations of arguments yield
  2203. * serious cancellation error in the power series summation
  2204. * and also are not in the region of near convergence of the
  2205. * asymptotic series. An error message is printed if the
  2206. * self-estimated relative error is greater than 1.0e-3.
  2207. *
  2208. */
  2209. /* i0f.c
  2210. *
  2211. * Modified Bessel function of order zero
  2212. *
  2213. *
  2214. *
  2215. * SYNOPSIS:
  2216. *
  2217. * float x, y, i0();
  2218. *
  2219. * y = i0f( x );
  2220. *
  2221. *
  2222. *
  2223. * DESCRIPTION:
  2224. *
  2225. * Returns modified Bessel function of order zero of the
  2226. * argument.
  2227. *
  2228. * The function is defined as i0(x) = j0( ix ).
  2229. *
  2230. * The range is partitioned into the two intervals [0,8] and
  2231. * (8, infinity). Chebyshev polynomial expansions are employed
  2232. * in each interval.
  2233. *
  2234. *
  2235. *
  2236. * ACCURACY:
  2237. *
  2238. * Relative error:
  2239. * arithmetic domain # trials peak rms
  2240. * IEEE 0,30 100000 4.0e-7 7.9e-8
  2241. *
  2242. */
  2243. /* i0ef.c
  2244. *
  2245. * Modified Bessel function of order zero,
  2246. * exponentially scaled
  2247. *
  2248. *
  2249. *
  2250. * SYNOPSIS:
  2251. *
  2252. * float x, y, i0ef();
  2253. *
  2254. * y = i0ef( x );
  2255. *
  2256. *
  2257. *
  2258. * DESCRIPTION:
  2259. *
  2260. * Returns exponentially scaled modified Bessel function
  2261. * of order zero of the argument.
  2262. *
  2263. * The function is defined as i0e(x) = exp(-|x|) j0( ix ).
  2264. *
  2265. *
  2266. *
  2267. * ACCURACY:
  2268. *
  2269. * Relative error:
  2270. * arithmetic domain # trials peak rms
  2271. * IEEE 0,30 100000 3.7e-7 7.0e-8
  2272. * See i0f().
  2273. *
  2274. */
  2275. /* i1f.c
  2276. *
  2277. * Modified Bessel function of order one
  2278. *
  2279. *
  2280. *
  2281. * SYNOPSIS:
  2282. *
  2283. * float x, y, i1f();
  2284. *
  2285. * y = i1f( x );
  2286. *
  2287. *
  2288. *
  2289. * DESCRIPTION:
  2290. *
  2291. * Returns modified Bessel function of order one of the
  2292. * argument.
  2293. *
  2294. * The function is defined as i1(x) = -i j1( ix ).
  2295. *
  2296. * The range is partitioned into the two intervals [0,8] and
  2297. * (8, infinity). Chebyshev polynomial expansions are employed
  2298. * in each interval.
  2299. *
  2300. *
  2301. *
  2302. * ACCURACY:
  2303. *
  2304. * Relative error:
  2305. * arithmetic domain # trials peak rms
  2306. * IEEE 0, 30 100000 1.5e-6 1.6e-7
  2307. *
  2308. *
  2309. */
  2310. /* i1ef.c
  2311. *
  2312. * Modified Bessel function of order one,
  2313. * exponentially scaled
  2314. *
  2315. *
  2316. *
  2317. * SYNOPSIS:
  2318. *
  2319. * float x, y, i1ef();
  2320. *
  2321. * y = i1ef( x );
  2322. *
  2323. *
  2324. *
  2325. * DESCRIPTION:
  2326. *
  2327. * Returns exponentially scaled modified Bessel function
  2328. * of order one of the argument.
  2329. *
  2330. * The function is defined as i1(x) = -i exp(-|x|) j1( ix ).
  2331. *
  2332. *
  2333. *
  2334. * ACCURACY:
  2335. *
  2336. * Relative error:
  2337. * arithmetic domain # trials peak rms
  2338. * IEEE 0, 30 30000 1.5e-6 1.5e-7
  2339. * See i1().
  2340. *
  2341. */
  2342. /* igamf.c
  2343. *
  2344. * Incomplete gamma integral
  2345. *
  2346. *
  2347. *
  2348. * SYNOPSIS:
  2349. *
  2350. * float a, x, y, igamf();
  2351. *
  2352. * y = igamf( a, x );
  2353. *
  2354. *
  2355. *
  2356. * DESCRIPTION:
  2357. *
  2358. * The function is defined by
  2359. *
  2360. * x
  2361. * -
  2362. * 1 | | -t a-1
  2363. * igam(a,x) = ----- | e t dt.
  2364. * - | |
  2365. * | (a) -
  2366. * 0
  2367. *
  2368. *
  2369. * In this implementation both arguments must be positive.
  2370. * The integral is evaluated by either a power series or
  2371. * continued fraction expansion, depending on the relative
  2372. * values of a and x.
  2373. *
  2374. *
  2375. *
  2376. * ACCURACY:
  2377. *
  2378. * Relative error:
  2379. * arithmetic domain # trials peak rms
  2380. * IEEE 0,30 20000 7.8e-6 5.9e-7
  2381. *
  2382. */
  2383. /* igamcf()
  2384. *
  2385. * Complemented incomplete gamma integral
  2386. *
  2387. *
  2388. *
  2389. * SYNOPSIS:
  2390. *
  2391. * float a, x, y, igamcf();
  2392. *
  2393. * y = igamcf( a, x );
  2394. *
  2395. *
  2396. *
  2397. * DESCRIPTION:
  2398. *
  2399. * The function is defined by
  2400. *
  2401. *
  2402. * igamc(a,x) = 1 - igam(a,x)
  2403. *
  2404. * inf.
  2405. * -
  2406. * 1 | | -t a-1
  2407. * = ----- | e t dt.
  2408. * - | |
  2409. * | (a) -
  2410. * x
  2411. *
  2412. *
  2413. * In this implementation both arguments must be positive.
  2414. * The integral is evaluated by either a power series or
  2415. * continued fraction expansion, depending on the relative
  2416. * values of a and x.
  2417. *
  2418. *
  2419. *
  2420. * ACCURACY:
  2421. *
  2422. * Relative error:
  2423. * arithmetic domain # trials peak rms
  2424. * IEEE 0,30 30000 7.8e-6 5.9e-7
  2425. *
  2426. */
  2427. /* igamif()
  2428. *
  2429. * Inverse of complemented imcomplete gamma integral
  2430. *
  2431. *
  2432. *
  2433. * SYNOPSIS:
  2434. *
  2435. * float a, x, y, igamif();
  2436. *
  2437. * x = igamif( a, y );
  2438. *
  2439. *
  2440. *
  2441. * DESCRIPTION:
  2442. *
  2443. * Given y, the function finds x such that
  2444. *
  2445. * igamc( a, x ) = y.
  2446. *
  2447. * Starting with the approximate value
  2448. *
  2449. * 3
  2450. * x = a t
  2451. *
  2452. * where
  2453. *
  2454. * t = 1 - d - ndtri(y) sqrt(d)
  2455. *
  2456. * and
  2457. *
  2458. * d = 1/9a,
  2459. *
  2460. * the routine performs up to 10 Newton iterations to find the
  2461. * root of igamc(a,x) - y = 0.
  2462. *
  2463. *
  2464. * ACCURACY:
  2465. *
  2466. * Tested for a ranging from 0 to 100 and x from 0 to 1.
  2467. *
  2468. * Relative error:
  2469. * arithmetic domain # trials peak rms
  2470. * IEEE 0,100 5000 1.0e-5 1.5e-6
  2471. *
  2472. */
  2473. /* incbetf.c
  2474. *
  2475. * Incomplete beta integral
  2476. *
  2477. *
  2478. * SYNOPSIS:
  2479. *
  2480. * float a, b, x, y, incbetf();
  2481. *
  2482. * y = incbetf( a, b, x );
  2483. *
  2484. *
  2485. * DESCRIPTION:
  2486. *
  2487. * Returns incomplete beta integral of the arguments, evaluated
  2488. * from zero to x. The function is defined as
  2489. *
  2490. * x
  2491. * - -
  2492. * | (a+b) | | a-1 b-1
  2493. * ----------- | t (1-t) dt.
  2494. * - - | |
  2495. * | (a) | (b) -
  2496. * 0
  2497. *
  2498. * The domain of definition is 0 <= x <= 1. In this
  2499. * implementation a and b are restricted to positive values.
  2500. * The integral from x to 1 may be obtained by the symmetry
  2501. * relation
  2502. *
  2503. * 1 - incbet( a, b, x ) = incbet( b, a, 1-x ).
  2504. *
  2505. * The integral is evaluated by a continued fraction expansion.
  2506. * If a < 1, the function calls itself recursively after a
  2507. * transformation to increase a to a+1.
  2508. *
  2509. * ACCURACY:
  2510. *
  2511. * Tested at random points (a,b,x) with a and b in the indicated
  2512. * interval and x between 0 and 1.
  2513. *
  2514. * arithmetic domain # trials peak rms
  2515. * Relative error:
  2516. * IEEE 0,30 10000 3.7e-5 5.1e-6
  2517. * IEEE 0,100 10000 1.7e-4 2.5e-5
  2518. * The useful domain for relative error is limited by underflow
  2519. * of the single precision exponential function.
  2520. * Absolute error:
  2521. * IEEE 0,30 100000 2.2e-5 9.6e-7
  2522. * IEEE 0,100 10000 6.5e-5 3.7e-6
  2523. *
  2524. * Larger errors may occur for extreme ratios of a and b.
  2525. *
  2526. * ERROR MESSAGES:
  2527. * message condition value returned
  2528. * incbetf domain x<0, x>1 0.0
  2529. */
  2530. /* incbif()
  2531. *
  2532. * Inverse of imcomplete beta integral
  2533. *
  2534. *
  2535. *
  2536. * SYNOPSIS:
  2537. *
  2538. * float a, b, x, y, incbif();
  2539. *
  2540. * x = incbif( a, b, y );
  2541. *
  2542. *
  2543. *
  2544. * DESCRIPTION:
  2545. *
  2546. * Given y, the function finds x such that
  2547. *
  2548. * incbet( a, b, x ) = y.
  2549. *
  2550. * the routine performs up to 10 Newton iterations to find the
  2551. * root of incbet(a,b,x) - y = 0.
  2552. *
  2553. *
  2554. * ACCURACY:
  2555. *
  2556. * Relative error:
  2557. * x a,b
  2558. * arithmetic domain domain # trials peak rms
  2559. * IEEE 0,1 0,100 5000 2.8e-4 8.3e-6
  2560. *
  2561. * Overflow and larger errors may occur for one of a or b near zero
  2562. * and the other large.
  2563. */
  2564. /* ivf.c
  2565. *
  2566. * Modified Bessel function of noninteger order
  2567. *
  2568. *
  2569. *
  2570. * SYNOPSIS:
  2571. *
  2572. * float v, x, y, ivf();
  2573. *
  2574. * y = ivf( v, x );
  2575. *
  2576. *
  2577. *
  2578. * DESCRIPTION:
  2579. *
  2580. * Returns modified Bessel function of order v of the
  2581. * argument. If x is negative, v must be integer valued.
  2582. *
  2583. * The function is defined as Iv(x) = Jv( ix ). It is
  2584. * here computed in terms of the confluent hypergeometric
  2585. * function, according to the formula
  2586. *
  2587. * v -x
  2588. * Iv(x) = (x/2) e hyperg( v+0.5, 2v+1, 2x ) / gamma(v+1)
  2589. *
  2590. * If v is a negative integer, then v is replaced by -v.
  2591. *
  2592. *
  2593. * ACCURACY:
  2594. *
  2595. * Tested at random points (v, x), with v between 0 and
  2596. * 30, x between 0 and 28.
  2597. * arithmetic domain # trials peak rms
  2598. * Relative error:
  2599. * IEEE 0,15 3000 4.7e-6 5.4e-7
  2600. * Absolute error (relative when function > 1)
  2601. * IEEE 0,30 5000 8.5e-6 1.3e-6
  2602. *
  2603. * Accuracy is diminished if v is near a negative integer.
  2604. * The useful domain for relative error is limited by overflow
  2605. * of the single precision exponential function.
  2606. *
  2607. * See also hyperg.c.
  2608. *
  2609. */
  2610. /* j0f.c
  2611. *
  2612. * Bessel function of order zero
  2613. *
  2614. *
  2615. *
  2616. * SYNOPSIS:
  2617. *
  2618. * float x, y, j0f();
  2619. *
  2620. * y = j0f( x );
  2621. *
  2622. *
  2623. *
  2624. * DESCRIPTION:
  2625. *
  2626. * Returns Bessel function of order zero of the argument.
  2627. *
  2628. * The domain is divided into the intervals [0, 2] and
  2629. * (2, infinity). In the first interval the following polynomial
  2630. * approximation is used:
  2631. *
  2632. *
  2633. * 2 2 2
  2634. * (w - r ) (w - r ) (w - r ) P(w)
  2635. * 1 2 3
  2636. *
  2637. * 2
  2638. * where w = x and the three r's are zeros of the function.
  2639. *
  2640. * In the second interval, the modulus and phase are approximated
  2641. * by polynomials of the form Modulus(x) = sqrt(1/x) Q(1/x)
  2642. * and Phase(x) = x + 1/x R(1/x^2) - pi/4. The function is
  2643. *
  2644. * j0(x) = Modulus(x) cos( Phase(x) ).
  2645. *
  2646. *
  2647. *
  2648. * ACCURACY:
  2649. *
  2650. * Absolute error:
  2651. * arithmetic domain # trials peak rms
  2652. * IEEE 0, 2 100000 1.3e-7 3.6e-8
  2653. * IEEE 2, 32 100000 1.9e-7 5.4e-8
  2654. *
  2655. */
  2656. /* y0f.c
  2657. *
  2658. * Bessel function of the second kind, order zero
  2659. *
  2660. *
  2661. *
  2662. * SYNOPSIS:
  2663. *
  2664. * float x, y, y0f();
  2665. *
  2666. * y = y0f( x );
  2667. *
  2668. *
  2669. *
  2670. * DESCRIPTION:
  2671. *
  2672. * Returns Bessel function of the second kind, of order
  2673. * zero, of the argument.
  2674. *
  2675. * The domain is divided into the intervals [0, 2] and
  2676. * (2, infinity). In the first interval a rational approximation
  2677. * R(x) is employed to compute
  2678. *
  2679. * 2 2 2
  2680. * y0(x) = (w - r ) (w - r ) (w - r ) R(x) + 2/pi ln(x) j0(x).
  2681. * 1 2 3
  2682. *
  2683. * Thus a call to j0() is required. The three zeros are removed
  2684. * from R(x) to improve its numerical stability.
  2685. *
  2686. * In the second interval, the modulus and phase are approximated
  2687. * by polynomials of the form Modulus(x) = sqrt(1/x) Q(1/x)
  2688. * and Phase(x) = x + 1/x S(1/x^2) - pi/4. Then the function is
  2689. *
  2690. * y0(x) = Modulus(x) sin( Phase(x) ).
  2691. *
  2692. *
  2693. *
  2694. *
  2695. * ACCURACY:
  2696. *
  2697. * Absolute error, when y0(x) < 1; else relative error:
  2698. *
  2699. * arithmetic domain # trials peak rms
  2700. * IEEE 0, 2 100000 2.4e-7 3.4e-8
  2701. * IEEE 2, 32 100000 1.8e-7 5.3e-8
  2702. *
  2703. */
  2704. /* j1f.c
  2705. *
  2706. * Bessel function of order one
  2707. *
  2708. *
  2709. *
  2710. * SYNOPSIS:
  2711. *
  2712. * float x, y, j1f();
  2713. *
  2714. * y = j1f( x );
  2715. *
  2716. *
  2717. *
  2718. * DESCRIPTION:
  2719. *
  2720. * Returns Bessel function of order one of the argument.
  2721. *
  2722. * The domain is divided into the intervals [0, 2] and
  2723. * (2, infinity). In the first interval a polynomial approximation
  2724. * 2
  2725. * (w - r ) x P(w)
  2726. * 1
  2727. * 2
  2728. * is used, where w = x and r is the first zero of the function.
  2729. *
  2730. * In the second interval, the modulus and phase are approximated
  2731. * by polynomials of the form Modulus(x) = sqrt(1/x) Q(1/x)
  2732. * and Phase(x) = x + 1/x R(1/x^2) - 3pi/4. The function is
  2733. *
  2734. * j0(x) = Modulus(x) cos( Phase(x) ).
  2735. *
  2736. *
  2737. *
  2738. * ACCURACY:
  2739. *
  2740. * Absolute error:
  2741. * arithmetic domain # trials peak rms
  2742. * IEEE 0, 2 100000 1.2e-7 2.5e-8
  2743. * IEEE 2, 32 100000 2.0e-7 5.3e-8
  2744. *
  2745. *
  2746. */
  2747. /* y1.c
  2748. *
  2749. * Bessel function of second kind of order one
  2750. *
  2751. *
  2752. *
  2753. * SYNOPSIS:
  2754. *
  2755. * double x, y, y1();
  2756. *
  2757. * y = y1( x );
  2758. *
  2759. *
  2760. *
  2761. * DESCRIPTION:
  2762. *
  2763. * Returns Bessel function of the second kind of order one
  2764. * of the argument.
  2765. *
  2766. * The domain is divided into the intervals [0, 2] and
  2767. * (2, infinity). In the first interval a rational approximation
  2768. * R(x) is employed to compute
  2769. *
  2770. * 2
  2771. * y0(x) = (w - r ) x R(x^2) + 2/pi (ln(x) j1(x) - 1/x) .
  2772. * 1
  2773. *
  2774. * Thus a call to j1() is required.
  2775. *
  2776. * In the second interval, the modulus and phase are approximated
  2777. * by polynomials of the form Modulus(x) = sqrt(1/x) Q(1/x)
  2778. * and Phase(x) = x + 1/x S(1/x^2) - 3pi/4. Then the function is
  2779. *
  2780. * y0(x) = Modulus(x) sin( Phase(x) ).
  2781. *
  2782. *
  2783. *
  2784. *
  2785. * ACCURACY:
  2786. *
  2787. * Absolute error:
  2788. * arithmetic domain # trials peak rms
  2789. * IEEE 0, 2 100000 2.2e-7 4.6e-8
  2790. * IEEE 2, 32 100000 1.9e-7 5.3e-8
  2791. *
  2792. * (error criterion relative when |y1| > 1).
  2793. *
  2794. */
  2795. /* jnf.c
  2796. *
  2797. * Bessel function of integer order
  2798. *
  2799. *
  2800. *
  2801. * SYNOPSIS:
  2802. *
  2803. * int n;
  2804. * float x, y, jnf();
  2805. *
  2806. * y = jnf( n, x );
  2807. *
  2808. *
  2809. *
  2810. * DESCRIPTION:
  2811. *
  2812. * Returns Bessel function of order n, where n is a
  2813. * (possibly negative) integer.
  2814. *
  2815. * The ratio of jn(x) to j0(x) is computed by backward
  2816. * recurrence. First the ratio jn/jn-1 is found by a
  2817. * continued fraction expansion. Then the recurrence
  2818. * relating successive orders is applied until j0 or j1 is
  2819. * reached.
  2820. *
  2821. * If n = 0 or 1 the routine for j0 or j1 is called
  2822. * directly.
  2823. *
  2824. *
  2825. *
  2826. * ACCURACY:
  2827. *
  2828. * Absolute error:
  2829. * arithmetic range # trials peak rms
  2830. * IEEE 0, 15 30000 3.6e-7 3.6e-8
  2831. *
  2832. *
  2833. * Not suitable for large n or x. Use jvf() instead.
  2834. *
  2835. */
  2836. /* jvf.c
  2837. *
  2838. * Bessel function of noninteger order
  2839. *
  2840. *
  2841. *
  2842. * SYNOPSIS:
  2843. *
  2844. * float v, x, y, jvf();
  2845. *
  2846. * y = jvf( v, x );
  2847. *
  2848. *
  2849. *
  2850. * DESCRIPTION:
  2851. *
  2852. * Returns Bessel function of order v of the argument,
  2853. * where v is real. Negative x is allowed if v is an integer.
  2854. *
  2855. * Several expansions are included: the ascending power
  2856. * series, the Hankel expansion, and two transitional
  2857. * expansions for large v. If v is not too large, it
  2858. * is reduced by recurrence to a region of best accuracy.
  2859. *
  2860. * The single precision routine accepts negative v, but with
  2861. * reduced accuracy.
  2862. *
  2863. *
  2864. *
  2865. * ACCURACY:
  2866. * Results for integer v are indicated by *.
  2867. * Error criterion is absolute, except relative when |jv()| > 1.
  2868. *
  2869. * arithmetic domain # trials peak rms
  2870. * v x
  2871. * IEEE 0,125 0,125 30000 2.0e-6 2.0e-7
  2872. * IEEE -17,0 0,125 30000 1.1e-5 4.0e-7
  2873. * IEEE -100,0 0,125 3000 1.5e-4 7.8e-6
  2874. */
  2875. /* k0f.c
  2876. *
  2877. * Modified Bessel function, third kind, order zero
  2878. *
  2879. *
  2880. *
  2881. * SYNOPSIS:
  2882. *
  2883. * float x, y, k0f();
  2884. *
  2885. * y = k0f( x );
  2886. *
  2887. *
  2888. *
  2889. * DESCRIPTION:
  2890. *
  2891. * Returns modified Bessel function of the third kind
  2892. * of order zero of the argument.
  2893. *
  2894. * The range is partitioned into the two intervals [0,8] and
  2895. * (8, infinity). Chebyshev polynomial expansions are employed
  2896. * in each interval.
  2897. *
  2898. *
  2899. *
  2900. * ACCURACY:
  2901. *
  2902. * Tested at 2000 random points between 0 and 8. Peak absolute
  2903. * error (relative when K0 > 1) was 1.46e-14; rms, 4.26e-15.
  2904. * Relative error:
  2905. * arithmetic domain # trials peak rms
  2906. * IEEE 0, 30 30000 7.8e-7 8.5e-8
  2907. *
  2908. * ERROR MESSAGES:
  2909. *
  2910. * message condition value returned
  2911. * K0 domain x <= 0 MAXNUM
  2912. *
  2913. */
  2914. /* k0ef()
  2915. *
  2916. * Modified Bessel function, third kind, order zero,
  2917. * exponentially scaled
  2918. *
  2919. *
  2920. *
  2921. * SYNOPSIS:
  2922. *
  2923. * float x, y, k0ef();
  2924. *
  2925. * y = k0ef( x );
  2926. *
  2927. *
  2928. *
  2929. * DESCRIPTION:
  2930. *
  2931. * Returns exponentially scaled modified Bessel function
  2932. * of the third kind of order zero of the argument.
  2933. *
  2934. *
  2935. *
  2936. * ACCURACY:
  2937. *
  2938. * Relative error:
  2939. * arithmetic domain # trials peak rms
  2940. * IEEE 0, 30 30000 8.1e-7 7.8e-8
  2941. * See k0().
  2942. *
  2943. */
  2944. /* k1f.c
  2945. *
  2946. * Modified Bessel function, third kind, order one
  2947. *
  2948. *
  2949. *
  2950. * SYNOPSIS:
  2951. *
  2952. * float x, y, k1f();
  2953. *
  2954. * y = k1f( x );
  2955. *
  2956. *
  2957. *
  2958. * DESCRIPTION:
  2959. *
  2960. * Computes the modified Bessel function of the third kind
  2961. * of order one of the argument.
  2962. *
  2963. * The range is partitioned into the two intervals [0,2] and
  2964. * (2, infinity). Chebyshev polynomial expansions are employed
  2965. * in each interval.
  2966. *
  2967. *
  2968. *
  2969. * ACCURACY:
  2970. *
  2971. * Relative error:
  2972. * arithmetic domain # trials peak rms
  2973. * IEEE 0, 30 30000 4.6e-7 7.6e-8
  2974. *
  2975. * ERROR MESSAGES:
  2976. *
  2977. * message condition value returned
  2978. * k1 domain x <= 0 MAXNUM
  2979. *
  2980. */
  2981. /* k1ef.c
  2982. *
  2983. * Modified Bessel function, third kind, order one,
  2984. * exponentially scaled
  2985. *
  2986. *
  2987. *
  2988. * SYNOPSIS:
  2989. *
  2990. * float x, y, k1ef();
  2991. *
  2992. * y = k1ef( x );
  2993. *
  2994. *
  2995. *
  2996. * DESCRIPTION:
  2997. *
  2998. * Returns exponentially scaled modified Bessel function
  2999. * of the third kind of order one of the argument:
  3000. *
  3001. * k1e(x) = exp(x) * k1(x).
  3002. *
  3003. *
  3004. *
  3005. * ACCURACY:
  3006. *
  3007. * Relative error:
  3008. * arithmetic domain # trials peak rms
  3009. * IEEE 0, 30 30000 4.9e-7 6.7e-8
  3010. * See k1().
  3011. *
  3012. */
  3013. /* knf.c
  3014. *
  3015. * Modified Bessel function, third kind, integer order
  3016. *
  3017. *
  3018. *
  3019. * SYNOPSIS:
  3020. *
  3021. * float x, y, knf();
  3022. * int n;
  3023. *
  3024. * y = knf( n, x );
  3025. *
  3026. *
  3027. *
  3028. * DESCRIPTION:
  3029. *
  3030. * Returns modified Bessel function of the third kind
  3031. * of order n of the argument.
  3032. *
  3033. * The range is partitioned into the two intervals [0,9.55] and
  3034. * (9.55, infinity). An ascending power series is used in the
  3035. * low range, and an asymptotic expansion in the high range.
  3036. *
  3037. *
  3038. *
  3039. * ACCURACY:
  3040. *
  3041. * Absolute error, relative when function > 1:
  3042. * arithmetic domain # trials peak rms
  3043. * IEEE 0,30 10000 2.0e-4 3.8e-6
  3044. *
  3045. * Error is high only near the crossover point x = 9.55
  3046. * between the two expansions used.
  3047. */
  3048. /* log10f.c
  3049. *
  3050. * Common logarithm
  3051. *
  3052. *
  3053. *
  3054. * SYNOPSIS:
  3055. *
  3056. * float x, y, log10f();
  3057. *
  3058. * y = log10f( x );
  3059. *
  3060. *
  3061. *
  3062. * DESCRIPTION:
  3063. *
  3064. * Returns logarithm to the base 10 of x.
  3065. *
  3066. * The argument is separated into its exponent and fractional
  3067. * parts. The logarithm of the fraction is approximated by
  3068. *
  3069. * log(1+x) = x - 0.5 x**2 + x**3 P(x).
  3070. *
  3071. *
  3072. *
  3073. * ACCURACY:
  3074. *
  3075. * Relative error:
  3076. * arithmetic domain # trials peak rms
  3077. * IEEE 0.5, 2.0 100000 1.3e-7 3.4e-8
  3078. * IEEE 0, MAXNUMF 100000 1.3e-7 2.6e-8
  3079. *
  3080. * In the tests over the interval [0, MAXNUM], the logarithms
  3081. * of the random arguments were uniformly distributed over
  3082. * [-MAXL10, MAXL10].
  3083. *
  3084. * ERROR MESSAGES:
  3085. *
  3086. * log10f singularity: x = 0; returns -MAXL10
  3087. * log10f domain: x < 0; returns -MAXL10
  3088. * MAXL10 = 38.230809449325611792
  3089. */
  3090. /* log2f.c
  3091. *
  3092. * Base 2 logarithm
  3093. *
  3094. *
  3095. *
  3096. * SYNOPSIS:
  3097. *
  3098. * float x, y, log2f();
  3099. *
  3100. * y = log2f( x );
  3101. *
  3102. *
  3103. *
  3104. * DESCRIPTION:
  3105. *
  3106. * Returns the base 2 logarithm of x.
  3107. *
  3108. * The argument is separated into its exponent and fractional
  3109. * parts. If the exponent is between -1 and +1, the base e
  3110. * logarithm of the fraction is approximated by
  3111. *
  3112. * log(1+x) = x - 0.5 x**2 + x**3 P(x)/Q(x).
  3113. *
  3114. * Otherwise, setting z = 2(x-1)/x+1),
  3115. *
  3116. * log(x) = z + z**3 P(z)/Q(z).
  3117. *
  3118. *
  3119. *
  3120. * ACCURACY:
  3121. *
  3122. * Relative error:
  3123. * arithmetic domain # trials peak rms
  3124. * IEEE exp(+-88) 100000 1.1e-7 2.4e-8
  3125. * IEEE 0.5, 2.0 100000 1.1e-7 3.0e-8
  3126. *
  3127. * In the tests over the interval [exp(+-88)], the logarithms
  3128. * of the random arguments were uniformly distributed.
  3129. *
  3130. * ERROR MESSAGES:
  3131. *
  3132. * log singularity: x = 0; returns MINLOGF/log(2)
  3133. * log domain: x < 0; returns MINLOGF/log(2)
  3134. */
  3135. /* logf.c
  3136. *
  3137. * Natural logarithm
  3138. *
  3139. *
  3140. *
  3141. * SYNOPSIS:
  3142. *
  3143. * float x, y, logf();
  3144. *
  3145. * y = logf( x );
  3146. *
  3147. *
  3148. *
  3149. * DESCRIPTION:
  3150. *
  3151. * Returns the base e (2.718...) logarithm of x.
  3152. *
  3153. * The argument is separated into its exponent and fractional
  3154. * parts. If the exponent is between -1 and +1, the logarithm
  3155. * of the fraction is approximated by
  3156. *
  3157. * log(1+x) = x - 0.5 x**2 + x**3 P(x)
  3158. *
  3159. *
  3160. *
  3161. * ACCURACY:
  3162. *
  3163. * Relative error:
  3164. * arithmetic domain # trials peak rms
  3165. * IEEE 0.5, 2.0 100000 7.6e-8 2.7e-8
  3166. * IEEE 1, MAXNUMF 100000 2.6e-8
  3167. *
  3168. * In the tests over the interval [1, MAXNUM], the logarithms
  3169. * of the random arguments were uniformly distributed over
  3170. * [0, MAXLOGF].
  3171. *
  3172. * ERROR MESSAGES:
  3173. *
  3174. * logf singularity: x = 0; returns MINLOG
  3175. * logf domain: x < 0; returns MINLOG
  3176. */
  3177. /* mtherr.c
  3178. *
  3179. * Library common error handling routine
  3180. *
  3181. *
  3182. *
  3183. * SYNOPSIS:
  3184. *
  3185. * char *fctnam;
  3186. * int code;
  3187. * void mtherr();
  3188. *
  3189. * mtherr( fctnam, code );
  3190. *
  3191. *
  3192. *
  3193. * DESCRIPTION:
  3194. *
  3195. * This routine may be called to report one of the following
  3196. * error conditions (in the include file math.h).
  3197. *
  3198. * Mnemonic Value Significance
  3199. *
  3200. * DOMAIN 1 argument domain error
  3201. * SING 2 function singularity
  3202. * OVERFLOW 3 overflow range error
  3203. * UNDERFLOW 4 underflow range error
  3204. * TLOSS 5 total loss of precision
  3205. * PLOSS 6 partial loss of precision
  3206. * EDOM 33 Unix domain error code
  3207. * ERANGE 34 Unix range error code
  3208. *
  3209. * The default version of the file prints the function name,
  3210. * passed to it by the pointer fctnam, followed by the
  3211. * error condition. The display is directed to the standard
  3212. * output device. The routine then returns to the calling
  3213. * program. Users may wish to modify the program to abort by
  3214. * calling exit() under severe error conditions such as domain
  3215. * errors.
  3216. *
  3217. * Since all error conditions pass control to this function,
  3218. * the display may be easily changed, eliminated, or directed
  3219. * to an error logging device.
  3220. *
  3221. * SEE ALSO:
  3222. *
  3223. * math.h
  3224. *
  3225. */
  3226. /* nbdtrf.c
  3227. *
  3228. * Negative binomial distribution
  3229. *
  3230. *
  3231. *
  3232. * SYNOPSIS:
  3233. *
  3234. * int k, n;
  3235. * float p, y, nbdtrf();
  3236. *
  3237. * y = nbdtrf( k, n, p );
  3238. *
  3239. *
  3240. *
  3241. * DESCRIPTION:
  3242. *
  3243. * Returns the sum of the terms 0 through k of the negative
  3244. * binomial distribution:
  3245. *
  3246. * k
  3247. * -- ( n+j-1 ) n j
  3248. * > ( ) p (1-p)
  3249. * -- ( j )
  3250. * j=0
  3251. *
  3252. * In a sequence of Bernoulli trials, this is the probability
  3253. * that k or fewer failures precede the nth success.
  3254. *
  3255. * The terms are not computed individually; instead the incomplete
  3256. * beta integral is employed, according to the formula
  3257. *
  3258. * y = nbdtr( k, n, p ) = incbet( n, k+1, p ).
  3259. *
  3260. * The arguments must be positive, with p ranging from 0 to 1.
  3261. *
  3262. *
  3263. *
  3264. * ACCURACY:
  3265. *
  3266. * Relative error:
  3267. * arithmetic domain # trials peak rms
  3268. * IEEE 0,100 5000 1.5e-4 1.9e-5
  3269. *
  3270. */
  3271. /* nbdtrcf.c
  3272. *
  3273. * Complemented negative binomial distribution
  3274. *
  3275. *
  3276. *
  3277. * SYNOPSIS:
  3278. *
  3279. * int k, n;
  3280. * float p, y, nbdtrcf();
  3281. *
  3282. * y = nbdtrcf( k, n, p );
  3283. *
  3284. *
  3285. *
  3286. * DESCRIPTION:
  3287. *
  3288. * Returns the sum of the terms k+1 to infinity of the negative
  3289. * binomial distribution:
  3290. *
  3291. * inf
  3292. * -- ( n+j-1 ) n j
  3293. * > ( ) p (1-p)
  3294. * -- ( j )
  3295. * j=k+1
  3296. *
  3297. * The terms are not computed individually; instead the incomplete
  3298. * beta integral is employed, according to the formula
  3299. *
  3300. * y = nbdtrc( k, n, p ) = incbet( k+1, n, 1-p ).
  3301. *
  3302. * The arguments must be positive, with p ranging from 0 to 1.
  3303. *
  3304. *
  3305. *
  3306. * ACCURACY:
  3307. *
  3308. * Relative error:
  3309. * arithmetic domain # trials peak rms
  3310. * IEEE 0,100 5000 1.4e-4 2.0e-5
  3311. *
  3312. */
  3313. /* ndtrf.c
  3314. *
  3315. * Normal distribution function
  3316. *
  3317. *
  3318. *
  3319. * SYNOPSIS:
  3320. *
  3321. * float x, y, ndtrf();
  3322. *
  3323. * y = ndtrf( x );
  3324. *
  3325. *
  3326. *
  3327. * DESCRIPTION:
  3328. *
  3329. * Returns the area under the Gaussian probability density
  3330. * function, integrated from minus infinity to x:
  3331. *
  3332. * x
  3333. * -
  3334. * 1 | | 2
  3335. * ndtr(x) = --------- | exp( - t /2 ) dt
  3336. * sqrt(2pi) | |
  3337. * -
  3338. * -inf.
  3339. *
  3340. * = ( 1 + erf(z) ) / 2
  3341. * = erfc(z) / 2
  3342. *
  3343. * where z = x/sqrt(2). Computation is via the functions
  3344. * erf and erfc.
  3345. *
  3346. *
  3347. * ACCURACY:
  3348. *
  3349. * Relative error:
  3350. * arithmetic domain # trials peak rms
  3351. * IEEE -13,0 50000 1.5e-5 2.6e-6
  3352. *
  3353. *
  3354. * ERROR MESSAGES:
  3355. *
  3356. * See erfcf().
  3357. *
  3358. */
  3359. /* erff.c
  3360. *
  3361. * Error function
  3362. *
  3363. *
  3364. *
  3365. * SYNOPSIS:
  3366. *
  3367. * float x, y, erff();
  3368. *
  3369. * y = erff( x );
  3370. *
  3371. *
  3372. *
  3373. * DESCRIPTION:
  3374. *
  3375. * The integral is
  3376. *
  3377. * x
  3378. * -
  3379. * 2 | | 2
  3380. * erf(x) = -------- | exp( - t ) dt.
  3381. * sqrt(pi) | |
  3382. * -
  3383. * 0
  3384. *
  3385. * The magnitude of x is limited to 9.231948545 for DEC
  3386. * arithmetic; 1 or -1 is returned outside this range.
  3387. *
  3388. * For 0 <= |x| < 1, erf(x) = x * P(x**2); otherwise
  3389. * erf(x) = 1 - erfc(x).
  3390. *
  3391. *
  3392. *
  3393. * ACCURACY:
  3394. *
  3395. * Relative error:
  3396. * arithmetic domain # trials peak rms
  3397. * IEEE -9.3,9.3 50000 1.7e-7 2.8e-8
  3398. *
  3399. */
  3400. /* erfcf.c
  3401. *
  3402. * Complementary error function
  3403. *
  3404. *
  3405. *
  3406. * SYNOPSIS:
  3407. *
  3408. * float x, y, erfcf();
  3409. *
  3410. * y = erfcf( x );
  3411. *
  3412. *
  3413. *
  3414. * DESCRIPTION:
  3415. *
  3416. *
  3417. * 1 - erf(x) =
  3418. *
  3419. * inf.
  3420. * -
  3421. * 2 | | 2
  3422. * erfc(x) = -------- | exp( - t ) dt
  3423. * sqrt(pi) | |
  3424. * -
  3425. * x
  3426. *
  3427. *
  3428. * For small x, erfc(x) = 1 - erf(x); otherwise polynomial
  3429. * approximations 1/x P(1/x**2) are computed.
  3430. *
  3431. *
  3432. *
  3433. * ACCURACY:
  3434. *
  3435. * Relative error:
  3436. * arithmetic domain # trials peak rms
  3437. * IEEE -9.3,9.3 50000 3.9e-6 7.2e-7
  3438. *
  3439. *
  3440. * ERROR MESSAGES:
  3441. *
  3442. * message condition value returned
  3443. * erfcf underflow x**2 > MAXLOGF 0.0
  3444. *
  3445. *
  3446. */
  3447. /* ndtrif.c
  3448. *
  3449. * Inverse of Normal distribution function
  3450. *
  3451. *
  3452. *
  3453. * SYNOPSIS:
  3454. *
  3455. * float x, y, ndtrif();
  3456. *
  3457. * x = ndtrif( y );
  3458. *
  3459. *
  3460. *
  3461. * DESCRIPTION:
  3462. *
  3463. * Returns the argument, x, for which the area under the
  3464. * Gaussian probability density function (integrated from
  3465. * minus infinity to x) is equal to y.
  3466. *
  3467. *
  3468. * For small arguments 0 < y < exp(-2), the program computes
  3469. * z = sqrt( -2.0 * log(y) ); then the approximation is
  3470. * x = z - log(z)/z - (1/z) P(1/z) / Q(1/z).
  3471. * There are two rational functions P/Q, one for 0 < y < exp(-32)
  3472. * and the other for y up to exp(-2). For larger arguments,
  3473. * w = y - 0.5, and x/sqrt(2pi) = w + w**3 R(w**2)/S(w**2)).
  3474. *
  3475. *
  3476. * ACCURACY:
  3477. *
  3478. * Relative error:
  3479. * arithmetic domain # trials peak rms
  3480. * IEEE 1e-38, 1 30000 3.6e-7 5.0e-8
  3481. *
  3482. *
  3483. * ERROR MESSAGES:
  3484. *
  3485. * message condition value returned
  3486. * ndtrif domain x <= 0 -MAXNUM
  3487. * ndtrif domain x >= 1 MAXNUM
  3488. *
  3489. */
  3490. /* pdtrf.c
  3491. *
  3492. * Poisson distribution
  3493. *
  3494. *
  3495. *
  3496. * SYNOPSIS:
  3497. *
  3498. * int k;
  3499. * float m, y, pdtrf();
  3500. *
  3501. * y = pdtrf( k, m );
  3502. *
  3503. *
  3504. *
  3505. * DESCRIPTION:
  3506. *
  3507. * Returns the sum of the first k terms of the Poisson
  3508. * distribution:
  3509. *
  3510. * k j
  3511. * -- -m m
  3512. * > e --
  3513. * -- j!
  3514. * j=0
  3515. *
  3516. * The terms are not summed directly; instead the incomplete
  3517. * gamma integral is employed, according to the relation
  3518. *
  3519. * y = pdtr( k, m ) = igamc( k+1, m ).
  3520. *
  3521. * The arguments must both be positive.
  3522. *
  3523. *
  3524. *
  3525. * ACCURACY:
  3526. *
  3527. * Relative error:
  3528. * arithmetic domain # trials peak rms
  3529. * IEEE 0,100 5000 6.9e-5 8.0e-6
  3530. *
  3531. */
  3532. /* pdtrcf()
  3533. *
  3534. * Complemented poisson distribution
  3535. *
  3536. *
  3537. *
  3538. * SYNOPSIS:
  3539. *
  3540. * int k;
  3541. * float m, y, pdtrcf();
  3542. *
  3543. * y = pdtrcf( k, m );
  3544. *
  3545. *
  3546. *
  3547. * DESCRIPTION:
  3548. *
  3549. * Returns the sum of the terms k+1 to infinity of the Poisson
  3550. * distribution:
  3551. *
  3552. * inf. j
  3553. * -- -m m
  3554. * > e --
  3555. * -- j!
  3556. * j=k+1
  3557. *
  3558. * The terms are not summed directly; instead the incomplete
  3559. * gamma integral is employed, according to the formula
  3560. *
  3561. * y = pdtrc( k, m ) = igam( k+1, m ).
  3562. *
  3563. * The arguments must both be positive.
  3564. *
  3565. *
  3566. *
  3567. * ACCURACY:
  3568. *
  3569. * Relative error:
  3570. * arithmetic domain # trials peak rms
  3571. * IEEE 0,100 5000 8.4e-5 1.2e-5
  3572. *
  3573. */
  3574. /* pdtrif()
  3575. *
  3576. * Inverse Poisson distribution
  3577. *
  3578. *
  3579. *
  3580. * SYNOPSIS:
  3581. *
  3582. * int k;
  3583. * float m, y, pdtrf();
  3584. *
  3585. * m = pdtrif( k, y );
  3586. *
  3587. *
  3588. *
  3589. *
  3590. * DESCRIPTION:
  3591. *
  3592. * Finds the Poisson variable x such that the integral
  3593. * from 0 to x of the Poisson density is equal to the
  3594. * given probability y.
  3595. *
  3596. * This is accomplished using the inverse gamma integral
  3597. * function and the relation
  3598. *
  3599. * m = igami( k+1, y ).
  3600. *
  3601. *
  3602. *
  3603. *
  3604. * ACCURACY:
  3605. *
  3606. * Relative error:
  3607. * arithmetic domain # trials peak rms
  3608. * IEEE 0,100 5000 8.7e-6 1.4e-6
  3609. *
  3610. * ERROR MESSAGES:
  3611. *
  3612. * message condition value returned
  3613. * pdtri domain y < 0 or y >= 1 0.0
  3614. * k < 0
  3615. *
  3616. */
  3617. /* polevlf.c
  3618. * p1evlf.c
  3619. *
  3620. * Evaluate polynomial
  3621. *
  3622. *
  3623. *
  3624. * SYNOPSIS:
  3625. *
  3626. * int N;
  3627. * float x, y, coef[N+1], polevlf[];
  3628. *
  3629. * y = polevlf( x, coef, N );
  3630. *
  3631. *
  3632. *
  3633. * DESCRIPTION:
  3634. *
  3635. * Evaluates polynomial of degree N:
  3636. *
  3637. * 2 N
  3638. * y = C + C x + C x +...+ C x
  3639. * 0 1 2 N
  3640. *
  3641. * Coefficients are stored in reverse order:
  3642. *
  3643. * coef[0] = C , ..., coef[N] = C .
  3644. * N 0
  3645. *
  3646. * The function p1evl() assumes that coef[N] = 1.0 and is
  3647. * omitted from the array. Its calling arguments are
  3648. * otherwise the same as polevl().
  3649. *
  3650. *
  3651. * SPEED:
  3652. *
  3653. * In the interest of speed, there are no checks for out
  3654. * of bounds arithmetic. This routine is used by most of
  3655. * the functions in the library. Depending on available
  3656. * equipment features, the user may wish to rewrite the
  3657. * program in microcode or assembly language.
  3658. *
  3659. */
  3660. /* polynf.c
  3661. * polyrf.c
  3662. * Arithmetic operations on polynomials
  3663. *
  3664. * In the following descriptions a, b, c are polynomials of degree
  3665. * na, nb, nc respectively. The degree of a polynomial cannot
  3666. * exceed a run-time value MAXPOLF. An operation that attempts
  3667. * to use or generate a polynomial of higher degree may produce a
  3668. * result that suffers truncation at degree MAXPOL. The value of
  3669. * MAXPOL is set by calling the function
  3670. *
  3671. * polinif( maxpol );
  3672. *
  3673. * where maxpol is the desired maximum degree. This must be
  3674. * done prior to calling any of the other functions in this module.
  3675. * Memory for internal temporary polynomial storage is allocated
  3676. * by polinif().
  3677. *
  3678. * Each polynomial is represented by an array containing its
  3679. * coefficients, together with a separately declared integer equal
  3680. * to the degree of the polynomial. The coefficients appear in
  3681. * ascending order; that is,
  3682. *
  3683. * 2 na
  3684. * a(x) = a[0] + a[1] * x + a[2] * x + ... + a[na] * x .
  3685. *
  3686. *
  3687. *
  3688. * sum = poleva( a, na, x ); Evaluate polynomial a(t) at t = x.
  3689. * polprtf( a, na, D ); Print the coefficients of a to D digits.
  3690. * polclrf( a, na ); Set a identically equal to zero, up to a[na].
  3691. * polmovf( a, na, b ); Set b = a.
  3692. * poladdf( a, na, b, nb, c ); c = b + a, nc = max(na,nb)
  3693. * polsubf( a, na, b, nb, c ); c = b - a, nc = max(na,nb)
  3694. * polmulf( a, na, b, nb, c ); c = b * a, nc = na+nb
  3695. *
  3696. *
  3697. * Division:
  3698. *
  3699. * i = poldivf( a, na, b, nb, c ); c = b / a, nc = MAXPOL
  3700. *
  3701. * returns i = the degree of the first nonzero coefficient of a.
  3702. * The computed quotient c must be divided by x^i. An error message
  3703. * is printed if a is identically zero.
  3704. *
  3705. *
  3706. * Change of variables:
  3707. * If a and b are polynomials, and t = a(x), then
  3708. * c(t) = b(a(x))
  3709. * is a polynomial found by substituting a(x) for t. The
  3710. * subroutine call for this is
  3711. *
  3712. * polsbtf( a, na, b, nb, c );
  3713. *
  3714. *
  3715. * Notes:
  3716. * poldivf() is an integer routine; polevaf() is float.
  3717. * Any of the arguments a, b, c may refer to the same array.
  3718. *
  3719. */
  3720. /* powf.c
  3721. *
  3722. * Power function
  3723. *
  3724. *
  3725. *
  3726. * SYNOPSIS:
  3727. *
  3728. * float x, y, z, powf();
  3729. *
  3730. * z = powf( x, y );
  3731. *
  3732. *
  3733. *
  3734. * DESCRIPTION:
  3735. *
  3736. * Computes x raised to the yth power. Analytically,
  3737. *
  3738. * x**y = exp( y log(x) ).
  3739. *
  3740. * Following Cody and Waite, this program uses a lookup table
  3741. * of 2**-i/16 and pseudo extended precision arithmetic to
  3742. * obtain an extra three bits of accuracy in both the logarithm
  3743. * and the exponential.
  3744. *
  3745. *
  3746. *
  3747. * ACCURACY:
  3748. *
  3749. * Relative error:
  3750. * arithmetic domain # trials peak rms
  3751. * IEEE -10,10 100,000 1.4e-7 3.6e-8
  3752. * 1/10 < x < 10, x uniformly distributed.
  3753. * -10 < y < 10, y uniformly distributed.
  3754. *
  3755. *
  3756. * ERROR MESSAGES:
  3757. *
  3758. * message condition value returned
  3759. * powf overflow x**y > MAXNUMF MAXNUMF
  3760. * powf underflow x**y < 1/MAXNUMF 0.0
  3761. * powf domain x<0 and y noninteger 0.0
  3762. *
  3763. */
  3764. /* powif.c
  3765. *
  3766. * Real raised to integer power
  3767. *
  3768. *
  3769. *
  3770. * SYNOPSIS:
  3771. *
  3772. * float x, y, powif();
  3773. * int n;
  3774. *
  3775. * y = powif( x, n );
  3776. *
  3777. *
  3778. *
  3779. * DESCRIPTION:
  3780. *
  3781. * Returns argument x raised to the nth power.
  3782. * The routine efficiently decomposes n as a sum of powers of
  3783. * two. The desired power is a product of two-to-the-kth
  3784. * powers of x. Thus to compute the 32767 power of x requires
  3785. * 28 multiplications instead of 32767 multiplications.
  3786. *
  3787. *
  3788. *
  3789. * ACCURACY:
  3790. *
  3791. *
  3792. * Relative error:
  3793. * arithmetic x domain n domain # trials peak rms
  3794. * IEEE .04,26 -26,26 100000 1.1e-6 2.0e-7
  3795. * IEEE 1,2 -128,128 100000 1.1e-5 1.0e-6
  3796. *
  3797. * Returns MAXNUMF on overflow, zero on underflow.
  3798. *
  3799. */
  3800. /* psif.c
  3801. *
  3802. * Psi (digamma) function
  3803. *
  3804. *
  3805. * SYNOPSIS:
  3806. *
  3807. * float x, y, psif();
  3808. *
  3809. * y = psif( x );
  3810. *
  3811. *
  3812. * DESCRIPTION:
  3813. *
  3814. * d -
  3815. * psi(x) = -- ln | (x)
  3816. * dx
  3817. *
  3818. * is the logarithmic derivative of the gamma function.
  3819. * For integer x,
  3820. * n-1
  3821. * -
  3822. * psi(n) = -EUL + > 1/k.
  3823. * -
  3824. * k=1
  3825. *
  3826. * This formula is used for 0 < n <= 10. If x is negative, it
  3827. * is transformed to a positive argument by the reflection
  3828. * formula psi(1-x) = psi(x) + pi cot(pi x).
  3829. * For general positive x, the argument is made greater than 10
  3830. * using the recurrence psi(x+1) = psi(x) + 1/x.
  3831. * Then the following asymptotic expansion is applied:
  3832. *
  3833. * inf. B
  3834. * - 2k
  3835. * psi(x) = log(x) - 1/2x - > -------
  3836. * - 2k
  3837. * k=1 2k x
  3838. *
  3839. * where the B2k are Bernoulli numbers.
  3840. *
  3841. * ACCURACY:
  3842. * Absolute error, relative when |psi| > 1 :
  3843. * arithmetic domain # trials peak rms
  3844. * IEEE -33,0 30000 8.2e-7 1.2e-7
  3845. * IEEE 0,33 100000 7.3e-7 7.7e-8
  3846. *
  3847. * ERROR MESSAGES:
  3848. * message condition value returned
  3849. * psi singularity x integer <=0 MAXNUMF
  3850. */
  3851. /* rgammaf.c
  3852. *
  3853. * Reciprocal gamma function
  3854. *
  3855. *
  3856. *
  3857. * SYNOPSIS:
  3858. *
  3859. * float x, y, rgammaf();
  3860. *
  3861. * y = rgammaf( x );
  3862. *
  3863. *
  3864. *
  3865. * DESCRIPTION:
  3866. *
  3867. * Returns one divided by the gamma function of the argument.
  3868. *
  3869. * The function is approximated by a Chebyshev expansion in
  3870. * the interval [0,1]. Range reduction is by recurrence
  3871. * for arguments between -34.034 and +34.84425627277176174.
  3872. * 1/MAXNUMF is returned for positive arguments outside this
  3873. * range.
  3874. *
  3875. * The reciprocal gamma function has no singularities,
  3876. * but overflow and underflow may occur for large arguments.
  3877. * These conditions return either MAXNUMF or 1/MAXNUMF with
  3878. * appropriate sign.
  3879. *
  3880. * ACCURACY:
  3881. *
  3882. * Relative error:
  3883. * arithmetic domain # trials peak rms
  3884. * IEEE -34,+34 100000 8.9e-7 1.1e-7
  3885. */
  3886. /* shichif.c
  3887. *
  3888. * Hyperbolic sine and cosine integrals
  3889. *
  3890. *
  3891. *
  3892. * SYNOPSIS:
  3893. *
  3894. * float x, Chi, Shi;
  3895. *
  3896. * shichi( x, &Chi, &Shi );
  3897. *
  3898. *
  3899. * DESCRIPTION:
  3900. *
  3901. * Approximates the integrals
  3902. *
  3903. * x
  3904. * -
  3905. * | | cosh t - 1
  3906. * Chi(x) = eul + ln x + | ----------- dt,
  3907. * | | t
  3908. * -
  3909. * 0
  3910. *
  3911. * x
  3912. * -
  3913. * | | sinh t
  3914. * Shi(x) = | ------ dt
  3915. * | | t
  3916. * -
  3917. * 0
  3918. *
  3919. * where eul = 0.57721566490153286061 is Euler's constant.
  3920. * The integrals are evaluated by power series for x < 8
  3921. * and by Chebyshev expansions for x between 8 and 88.
  3922. * For large x, both functions approach exp(x)/2x.
  3923. * Arguments greater than 88 in magnitude return MAXNUM.
  3924. *
  3925. *
  3926. * ACCURACY:
  3927. *
  3928. * Test interval 0 to 88.
  3929. * Relative error:
  3930. * arithmetic function # trials peak rms
  3931. * IEEE Shi 20000 3.5e-7 7.0e-8
  3932. * Absolute error, except relative when |Chi| > 1:
  3933. * IEEE Chi 20000 3.8e-7 7.6e-8
  3934. */
  3935. /* sicif.c
  3936. *
  3937. * Sine and cosine integrals
  3938. *
  3939. *
  3940. *
  3941. * SYNOPSIS:
  3942. *
  3943. * float x, Ci, Si;
  3944. *
  3945. * sicif( x, &Si, &Ci );
  3946. *
  3947. *
  3948. * DESCRIPTION:
  3949. *
  3950. * Evaluates the integrals
  3951. *
  3952. * x
  3953. * -
  3954. * | cos t - 1
  3955. * Ci(x) = eul + ln x + | --------- dt,
  3956. * | t
  3957. * -
  3958. * 0
  3959. * x
  3960. * -
  3961. * | sin t
  3962. * Si(x) = | ----- dt
  3963. * | t
  3964. * -
  3965. * 0
  3966. *
  3967. * where eul = 0.57721566490153286061 is Euler's constant.
  3968. * The integrals are approximated by rational functions.
  3969. * For x > 8 auxiliary functions f(x) and g(x) are employed
  3970. * such that
  3971. *
  3972. * Ci(x) = f(x) sin(x) - g(x) cos(x)
  3973. * Si(x) = pi/2 - f(x) cos(x) - g(x) sin(x)
  3974. *
  3975. *
  3976. * ACCURACY:
  3977. * Test interval = [0,50].
  3978. * Absolute error, except relative when > 1:
  3979. * arithmetic function # trials peak rms
  3980. * IEEE Si 30000 2.1e-7 4.3e-8
  3981. * IEEE Ci 30000 3.9e-7 2.2e-8
  3982. */
  3983. /* sindgf.c
  3984. *
  3985. * Circular sine of angle in degrees
  3986. *
  3987. *
  3988. *
  3989. * SYNOPSIS:
  3990. *
  3991. * float x, y, sindgf();
  3992. *
  3993. * y = sindgf( x );
  3994. *
  3995. *
  3996. *
  3997. * DESCRIPTION:
  3998. *
  3999. * Range reduction is into intervals of 45 degrees.
  4000. *
  4001. * Two polynomial approximating functions are employed.
  4002. * Between 0 and pi/4 the sine is approximated by
  4003. * x + x**3 P(x**2).
  4004. * Between pi/4 and pi/2 the cosine is represented as
  4005. * 1 - x**2 Q(x**2).
  4006. *
  4007. *
  4008. * ACCURACY:
  4009. *
  4010. * Relative error:
  4011. * arithmetic domain # trials peak rms
  4012. * IEEE +-3600 100,000 1.2e-7 3.0e-8
  4013. *
  4014. * ERROR MESSAGES:
  4015. *
  4016. * message condition value returned
  4017. * sin total loss x > 2^24 0.0
  4018. *
  4019. */
  4020. /* cosdgf.c
  4021. *
  4022. * Circular cosine of angle in degrees
  4023. *
  4024. *
  4025. *
  4026. * SYNOPSIS:
  4027. *
  4028. * float x, y, cosdgf();
  4029. *
  4030. * y = cosdgf( x );
  4031. *
  4032. *
  4033. *
  4034. * DESCRIPTION:
  4035. *
  4036. * Range reduction is into intervals of 45 degrees.
  4037. *
  4038. * Two polynomial approximating functions are employed.
  4039. * Between 0 and pi/4 the cosine is approximated by
  4040. * 1 - x**2 Q(x**2).
  4041. * Between pi/4 and pi/2 the sine is represented as
  4042. * x + x**3 P(x**2).
  4043. *
  4044. *
  4045. * ACCURACY:
  4046. *
  4047. * Relative error:
  4048. * arithmetic domain # trials peak rms
  4049. * IEEE -8192,+8192 100,000 3.0e-7 3.0e-8
  4050. */
  4051. /* sinf.c
  4052. *
  4053. * Circular sine
  4054. *
  4055. *
  4056. *
  4057. * SYNOPSIS:
  4058. *
  4059. * float x, y, sinf();
  4060. *
  4061. * y = sinf( x );
  4062. *
  4063. *
  4064. *
  4065. * DESCRIPTION:
  4066. *
  4067. * Range reduction is into intervals of pi/4. The reduction
  4068. * error is nearly eliminated by contriving an extended precision
  4069. * modular arithmetic.
  4070. *
  4071. * Two polynomial approximating functions are employed.
  4072. * Between 0 and pi/4 the sine is approximated by
  4073. * x + x**3 P(x**2).
  4074. * Between pi/4 and pi/2 the cosine is represented as
  4075. * 1 - x**2 Q(x**2).
  4076. *
  4077. *
  4078. * ACCURACY:
  4079. *
  4080. * Relative error:
  4081. * arithmetic domain # trials peak rms
  4082. * IEEE -4096,+4096 100,000 1.2e-7 3.0e-8
  4083. * IEEE -8192,+8192 100,000 3.0e-7 3.0e-8
  4084. *
  4085. * ERROR MESSAGES:
  4086. *
  4087. * message condition value returned
  4088. * sin total loss x > 2^24 0.0
  4089. *
  4090. * Partial loss of accuracy begins to occur at x = 2^13
  4091. * = 8192. Results may be meaningless for x >= 2^24
  4092. * The routine as implemented flags a TLOSS error
  4093. * for x >= 2^24 and returns 0.0.
  4094. */
  4095. /* cosf.c
  4096. *
  4097. * Circular cosine
  4098. *
  4099. *
  4100. *
  4101. * SYNOPSIS:
  4102. *
  4103. * float x, y, cosf();
  4104. *
  4105. * y = cosf( x );
  4106. *
  4107. *
  4108. *
  4109. * DESCRIPTION:
  4110. *
  4111. * Range reduction is into intervals of pi/4. The reduction
  4112. * error is nearly eliminated by contriving an extended precision
  4113. * modular arithmetic.
  4114. *
  4115. * Two polynomial approximating functions are employed.
  4116. * Between 0 and pi/4 the cosine is approximated by
  4117. * 1 - x**2 Q(x**2).
  4118. * Between pi/4 and pi/2 the sine is represented as
  4119. * x + x**3 P(x**2).
  4120. *
  4121. *
  4122. * ACCURACY:
  4123. *
  4124. * Relative error:
  4125. * arithmetic domain # trials peak rms
  4126. * IEEE -8192,+8192 100,000 3.0e-7 3.0e-8
  4127. */
  4128. /* sinhf.c
  4129. *
  4130. * Hyperbolic sine
  4131. *
  4132. *
  4133. *
  4134. * SYNOPSIS:
  4135. *
  4136. * float x, y, sinhf();
  4137. *
  4138. * y = sinhf( x );
  4139. *
  4140. *
  4141. *
  4142. * DESCRIPTION:
  4143. *
  4144. * Returns hyperbolic sine of argument in the range MINLOGF to
  4145. * MAXLOGF.
  4146. *
  4147. * The range is partitioned into two segments. If |x| <= 1, a
  4148. * polynomial approximation is used.
  4149. * Otherwise the calculation is sinh(x) = ( exp(x) - exp(-x) )/2.
  4150. *
  4151. *
  4152. *
  4153. * ACCURACY:
  4154. *
  4155. * Relative error:
  4156. * arithmetic domain # trials peak rms
  4157. * IEEE +-MAXLOG 100000 1.1e-7 2.9e-8
  4158. *
  4159. */
  4160. /* spencef.c
  4161. *
  4162. * Dilogarithm
  4163. *
  4164. *
  4165. *
  4166. * SYNOPSIS:
  4167. *
  4168. * float x, y, spencef();
  4169. *
  4170. * y = spencef( x );
  4171. *
  4172. *
  4173. *
  4174. * DESCRIPTION:
  4175. *
  4176. * Computes the integral
  4177. *
  4178. * x
  4179. * -
  4180. * | | log t
  4181. * spence(x) = - | ----- dt
  4182. * | | t - 1
  4183. * -
  4184. * 1
  4185. *
  4186. * for x >= 0. A rational approximation gives the integral in
  4187. * the interval (0.5, 1.5). Transformation formulas for 1/x
  4188. * and 1-x are employed outside the basic expansion range.
  4189. *
  4190. *
  4191. *
  4192. * ACCURACY:
  4193. *
  4194. * Relative error:
  4195. * arithmetic domain # trials peak rms
  4196. * IEEE 0,4 30000 4.4e-7 6.3e-8
  4197. *
  4198. *
  4199. */
  4200. /* sqrtf.c
  4201. *
  4202. * Square root
  4203. *
  4204. *
  4205. *
  4206. * SYNOPSIS:
  4207. *
  4208. * float x, y, sqrtf();
  4209. *
  4210. * y = sqrtf( x );
  4211. *
  4212. *
  4213. *
  4214. * DESCRIPTION:
  4215. *
  4216. * Returns the square root of x.
  4217. *
  4218. * Range reduction involves isolating the power of two of the
  4219. * argument and using a polynomial approximation to obtain
  4220. * a rough value for the square root. Then Heron's iteration
  4221. * is used three times to converge to an accurate value.
  4222. *
  4223. *
  4224. *
  4225. * ACCURACY:
  4226. *
  4227. *
  4228. * Relative error:
  4229. * arithmetic domain # trials peak rms
  4230. * IEEE 0,1.e38 100000 8.7e-8 2.9e-8
  4231. *
  4232. *
  4233. * ERROR MESSAGES:
  4234. *
  4235. * message condition value returned
  4236. * sqrtf domain x < 0 0.0
  4237. *
  4238. */
  4239. /* stdtrf.c
  4240. *
  4241. * Student's t distribution
  4242. *
  4243. *
  4244. *
  4245. * SYNOPSIS:
  4246. *
  4247. * float t, stdtrf();
  4248. * short k;
  4249. *
  4250. * y = stdtrf( k, t );
  4251. *
  4252. *
  4253. * DESCRIPTION:
  4254. *
  4255. * Computes the integral from minus infinity to t of the Student
  4256. * t distribution with integer k > 0 degrees of freedom:
  4257. *
  4258. * t
  4259. * -
  4260. * | |
  4261. * - | 2 -(k+1)/2
  4262. * | ( (k+1)/2 ) | ( x )
  4263. * ---------------------- | ( 1 + --- ) dx
  4264. * - | ( k )
  4265. * sqrt( k pi ) | ( k/2 ) |
  4266. * | |
  4267. * -
  4268. * -inf.
  4269. *
  4270. * Relation to incomplete beta integral:
  4271. *
  4272. * 1 - stdtr(k,t) = 0.5 * incbet( k/2, 1/2, z )
  4273. * where
  4274. * z = k/(k + t**2).
  4275. *
  4276. * For t < -1, this is the method of computation. For higher t,
  4277. * a direct method is derived from integration by parts.
  4278. * Since the function is symmetric about t=0, the area under the
  4279. * right tail of the density is found by calling the function
  4280. * with -t instead of t.
  4281. *
  4282. * ACCURACY:
  4283. *
  4284. * Relative error:
  4285. * arithmetic domain # trials peak rms
  4286. * IEEE +/- 100 5000 2.3e-5 2.9e-6
  4287. */
  4288. /* struvef.c
  4289. *
  4290. * Struve function
  4291. *
  4292. *
  4293. *
  4294. * SYNOPSIS:
  4295. *
  4296. * float v, x, y, struvef();
  4297. *
  4298. * y = struvef( v, x );
  4299. *
  4300. *
  4301. *
  4302. * DESCRIPTION:
  4303. *
  4304. * Computes the Struve function Hv(x) of order v, argument x.
  4305. * Negative x is rejected unless v is an integer.
  4306. *
  4307. * This module also contains the hypergeometric functions 1F2
  4308. * and 3F0 and a routine for the Bessel function Yv(x) with
  4309. * noninteger v.
  4310. *
  4311. *
  4312. *
  4313. * ACCURACY:
  4314. *
  4315. * v varies from 0 to 10.
  4316. * Absolute error (relative error when |Hv(x)| > 1):
  4317. * arithmetic domain # trials peak rms
  4318. * IEEE -10,10 100000 9.0e-5 4.0e-6
  4319. *
  4320. */
  4321. /* tandgf.c
  4322. *
  4323. * Circular tangent of angle in degrees
  4324. *
  4325. *
  4326. *
  4327. * SYNOPSIS:
  4328. *
  4329. * float x, y, tandgf();
  4330. *
  4331. * y = tandgf( x );
  4332. *
  4333. *
  4334. *
  4335. * DESCRIPTION:
  4336. *
  4337. * Returns the circular tangent of the radian argument x.
  4338. *
  4339. * Range reduction is into intervals of 45 degrees.
  4340. *
  4341. *
  4342. *
  4343. *
  4344. * ACCURACY:
  4345. *
  4346. * Relative error:
  4347. * arithmetic domain # trials peak rms
  4348. * IEEE +-2^24 50000 2.4e-7 4.8e-8
  4349. *
  4350. * ERROR MESSAGES:
  4351. *
  4352. * message condition value returned
  4353. * tanf total loss x > 2^24 0.0
  4354. *
  4355. */
  4356. /* cotdgf.c
  4357. *
  4358. * Circular cotangent of angle in degrees
  4359. *
  4360. *
  4361. *
  4362. * SYNOPSIS:
  4363. *
  4364. * float x, y, cotdgf();
  4365. *
  4366. * y = cotdgf( x );
  4367. *
  4368. *
  4369. *
  4370. * DESCRIPTION:
  4371. *
  4372. * Range reduction is into intervals of 45 degrees.
  4373. * A common routine computes either the tangent or cotangent.
  4374. *
  4375. *
  4376. *
  4377. * ACCURACY:
  4378. *
  4379. * Relative error:
  4380. * arithmetic domain # trials peak rms
  4381. * IEEE +-2^24 50000 2.4e-7 4.8e-8
  4382. *
  4383. *
  4384. * ERROR MESSAGES:
  4385. *
  4386. * message condition value returned
  4387. * cot total loss x > 2^24 0.0
  4388. * cot singularity x = 0 MAXNUMF
  4389. *
  4390. */
  4391. /* tanf.c
  4392. *
  4393. * Circular tangent
  4394. *
  4395. *
  4396. *
  4397. * SYNOPSIS:
  4398. *
  4399. * float x, y, tanf();
  4400. *
  4401. * y = tanf( x );
  4402. *
  4403. *
  4404. *
  4405. * DESCRIPTION:
  4406. *
  4407. * Returns the circular tangent of the radian argument x.
  4408. *
  4409. * Range reduction is modulo pi/4. A polynomial approximation
  4410. * is employed in the basic interval [0, pi/4].
  4411. *
  4412. *
  4413. *
  4414. * ACCURACY:
  4415. *
  4416. * Relative error:
  4417. * arithmetic domain # trials peak rms
  4418. * IEEE +-4096 100000 3.3e-7 4.5e-8
  4419. *
  4420. * ERROR MESSAGES:
  4421. *
  4422. * message condition value returned
  4423. * tanf total loss x > 2^24 0.0
  4424. *
  4425. */
  4426. /* cotf.c
  4427. *
  4428. * Circular cotangent
  4429. *
  4430. *
  4431. *
  4432. * SYNOPSIS:
  4433. *
  4434. * float x, y, cotf();
  4435. *
  4436. * y = cotf( x );
  4437. *
  4438. *
  4439. *
  4440. * DESCRIPTION:
  4441. *
  4442. * Returns the circular cotangent of the radian argument x.
  4443. * A common routine computes either the tangent or cotangent.
  4444. *
  4445. *
  4446. *
  4447. * ACCURACY:
  4448. *
  4449. * Relative error:
  4450. * arithmetic domain # trials peak rms
  4451. * IEEE +-4096 100000 3.0e-7 4.5e-8
  4452. *
  4453. *
  4454. * ERROR MESSAGES:
  4455. *
  4456. * message condition value returned
  4457. * cot total loss x > 2^24 0.0
  4458. * cot singularity x = 0 MAXNUMF
  4459. *
  4460. */
  4461. /* tanhf.c
  4462. *
  4463. * Hyperbolic tangent
  4464. *
  4465. *
  4466. *
  4467. * SYNOPSIS:
  4468. *
  4469. * float x, y, tanhf();
  4470. *
  4471. * y = tanhf( x );
  4472. *
  4473. *
  4474. *
  4475. * DESCRIPTION:
  4476. *
  4477. * Returns hyperbolic tangent of argument in the range MINLOG to
  4478. * MAXLOG.
  4479. *
  4480. * A polynomial approximation is used for |x| < 0.625.
  4481. * Otherwise,
  4482. *
  4483. * tanh(x) = sinh(x)/cosh(x) = 1 - 2/(exp(2x) + 1).
  4484. *
  4485. *
  4486. *
  4487. * ACCURACY:
  4488. *
  4489. * Relative error:
  4490. * arithmetic domain # trials peak rms
  4491. * IEEE -2,2 100000 1.3e-7 2.6e-8
  4492. *
  4493. */
  4494. /* ynf.c
  4495. *
  4496. * Bessel function of second kind of integer order
  4497. *
  4498. *
  4499. *
  4500. * SYNOPSIS:
  4501. *
  4502. * float x, y, ynf();
  4503. * int n;
  4504. *
  4505. * y = ynf( n, x );
  4506. *
  4507. *
  4508. *
  4509. * DESCRIPTION:
  4510. *
  4511. * Returns Bessel function of order n, where n is a
  4512. * (possibly negative) integer.
  4513. *
  4514. * The function is evaluated by forward recurrence on
  4515. * n, starting with values computed by the routines
  4516. * y0() and y1().
  4517. *
  4518. * If n = 0 or 1 the routine for y0 or y1 is called
  4519. * directly.
  4520. *
  4521. *
  4522. *
  4523. * ACCURACY:
  4524. *
  4525. *
  4526. * Absolute error, except relative when y > 1:
  4527. *
  4528. * arithmetic domain # trials peak rms
  4529. * IEEE 0, 30 10000 2.3e-6 3.4e-7
  4530. *
  4531. *
  4532. * ERROR MESSAGES:
  4533. *
  4534. * message condition value returned
  4535. * yn singularity x = 0 MAXNUMF
  4536. * yn overflow MAXNUMF
  4537. *
  4538. * Spot checked against tables for x, n between 0 and 100.
  4539. *
  4540. */
  4541. /* zetacf.c
  4542. *
  4543. * Riemann zeta function
  4544. *
  4545. *
  4546. *
  4547. * SYNOPSIS:
  4548. *
  4549. * float x, y, zetacf();
  4550. *
  4551. * y = zetacf( x );
  4552. *
  4553. *
  4554. *
  4555. * DESCRIPTION:
  4556. *
  4557. *
  4558. *
  4559. * inf.
  4560. * - -x
  4561. * zetac(x) = > k , x > 1,
  4562. * -
  4563. * k=2
  4564. *
  4565. * is related to the Riemann zeta function by
  4566. *
  4567. * Riemann zeta(x) = zetac(x) + 1.
  4568. *
  4569. * Extension of the function definition for x < 1 is implemented.
  4570. * Zero is returned for x > log2(MAXNUM).
  4571. *
  4572. * An overflow error may occur for large negative x, due to the
  4573. * gamma function in the reflection formula.
  4574. *
  4575. * ACCURACY:
  4576. *
  4577. * Tabulated values have full machine accuracy.
  4578. *
  4579. * Relative error:
  4580. * arithmetic domain # trials peak rms
  4581. * IEEE 1,50 30000 5.5e-7 7.5e-8
  4582. *
  4583. *
  4584. */
  4585. /* zetaf.c
  4586. *
  4587. * Riemann zeta function of two arguments
  4588. *
  4589. *
  4590. *
  4591. * SYNOPSIS:
  4592. *
  4593. * float x, q, y, zetaf();
  4594. *
  4595. * y = zetaf( x, q );
  4596. *
  4597. *
  4598. *
  4599. * DESCRIPTION:
  4600. *
  4601. *
  4602. *
  4603. * inf.
  4604. * - -x
  4605. * zeta(x,q) = > (k+q)
  4606. * -
  4607. * k=0
  4608. *
  4609. * where x > 1 and q is not a negative integer or zero.
  4610. * The Euler-Maclaurin summation formula is used to obtain
  4611. * the expansion
  4612. *
  4613. * n
  4614. * - -x
  4615. * zeta(x,q) = > (k+q)
  4616. * -
  4617. * k=1
  4618. *
  4619. * 1-x inf. B x(x+1)...(x+2j)
  4620. * (n+q) 1 - 2j
  4621. * + --------- - ------- + > --------------------
  4622. * x-1 x - x+2j+1
  4623. * 2(n+q) j=1 (2j)! (n+q)
  4624. *
  4625. * where the B2j are Bernoulli numbers. Note that (see zetac.c)
  4626. * zeta(x,1) = zetac(x) + 1.
  4627. *
  4628. *
  4629. *
  4630. * ACCURACY:
  4631. *
  4632. * Relative error:
  4633. * arithmetic domain # trials peak rms
  4634. * IEEE 0,25 10000 6.9e-7 1.0e-7
  4635. *
  4636. * Large arguments may produce underflow in powf(), in which
  4637. * case the results are inaccurate.
  4638. *
  4639. * REFERENCE:
  4640. *
  4641. * Gradshteyn, I. S., and I. M. Ryzhik, Tables of Integrals,
  4642. * Series, and Products, p. 1073; Academic Press, 1980.
  4643. *
  4644. */