abax 0.1.31

A lightweight Rust library providing high-precision mathematical constants and special functions, including Bernoulli numbers, Riemann Zeta values, robust incomplete gamma functions, and probability distribution functions like normal and lognormal CDF.
Documentation
#![allow(dead_code)]

pub(crate) const BERNOULLI_NUMBER: [f64; 101] = [
    1.0,
    -5.0e-1,
    1.6666666666666666666666666666666666666666666666666666666666666666666666666666667e-1,
    0.0,
    -3.3333333333333333333333333333333333333333333333333333333333333333333333333333333e-2,
    0.0,
    2.3809523809523809523809523809523809523809523809523809523809523809523809523809524e-2,
    0.0,
    -3.3333333333333333333333333333333333333333333333333333333333333333333333333333333e-2,
    0.0,
    7.5757575757575757575757575757575757575757575757575757575757575757575757575757576e-2,
    0.0,
    -2.5311355311355311355311355311355311355311355311355311355311355311355311355311355e-1,
    0.0,
    1.1666666666666666666666666666666666666666666666666666666666666666666666666666667,
    0.0,
    -7.0921568627450980392156862745098039215686274509803921568627450980392156862745098,
    0.0,
    5.4971177944862155388471177944862155388471177944862155388471177944862155388471178e1,
    0.0,
    -5.2912424242424242424242424242424242424242424242424242424242424242424242424242424e2,
    0.0,
    6.1921231884057971014492753623188405797101449275362318840579710144927536231884058e3,
    0.0,
    -8.6580253113553113553113553113553113553113553113553113553113553113553113553113553e4,
    0.0,
    1.4255171666666666666666666666666666666666666666666666666666666666666666666666667e6,
    0.0,
    -2.7298231067816091954022988505747126436781609195402298850574712643678160919540230e7,
    0.0,
    6.0158087390064236838430386817483591677140064236838430386817483591677140064236838e8,
    0.0,
    -1.5116315767092156862745098039215686274509803921568627450980392156862745098039216e10,
    0.0,
    4.2961464306116666666666666666666666666666666666666666666666666666666666666666667e11,
    0.0,
    -1.3711655205088332772159087948561632772159087948561632772159087948561632772159088e13,
    0.0,
    4.8833231897359316666666666666666666666666666666666666666666666666666666666666667e14,
    0.0,
    -1.9296579341940068148632668144863266814486326681448632668144863266814486326681449e16,
    0.0,
    8.4169304757368261500055370985603543743078626799557032115171650055370985603543743e17,
    0.0,
    -4.0338071854059455413076811594202898550724637681159420289855072463768115942028986e19,
    0.0,
    2.1150748638081991605601453900709219858156028368794326241134751773049645390070922e21,
    0.0,
    -1.2086626522296525934602731193708252531781943546649429002370178840767076061193708e23,
    0.0,
    7.5008667460769643668557200757575757575757575757575757575757575757575757575757576e24,
    0.0,
    -5.0387781014810689141378930305220125786163522012578616352201257861635220125786164e26,
    0.0,
    3.6528776484818123335110430842971177944862155388471177944862155388471177944862155e28,
    0.0,
    -2.8498769302450882226269146432910678160919540229885057471264367816091954022988506e30,
    0.0,
    2.3865427499683627644645981919219214971751412429378531073446327683615819209039548e32,
    0.0,
    -2.1399949257225333665810744765191097392674151161723874574218307692659887265915822e34,
    0.0,
    2.0500975723478097569921733095672310251666666666666666666666666666666666666666667e36,
    0.0,
    -2.0938005911346378409095185290027970184709215686274509803921568627450980392156863e38,
    0.0,
    2.2752696488463515559649260352769264581469965405889805630233923549952102839838077e40,
    0.0,
    -2.6257710286239576047303049736158202081449000333333333333333333333333333333333333e42,
    0.0,
    3.2125082102718032518204792304264985243521941106167306871532223644899701237729407e44,
    0.0,
    -4.1598278166794710913917074495262358936689603011346470789224934863002635172786579e46,
    0.0,
    5.6920695482035280023883456219121058644480512971811666666666666666666666666666667e48,
    0.0,
    -8.2183629419784575692290653468617333014550892762886003333333333333333333333333333e50,
    0.0,
    1.2502904327166993016732339829702895524177196364448477501115129596142254370102471e53,
    0.0,
    -2.0015583233248370274925329198813298768724220132825915915207456197556627972696839e55,
    0.0,
    3.3674982915364374233396676903338753016219598947193843672321546184738955823293173e57,
    0.0,
    -5.9470970503135447718660496844051540840579071565106904990470431085212568773114082e59,
    0.0,
    1.1011910323627977559564130790437691604630511444223148862699949716666666666666667e62,
    0.0,
    -2.1355259545253501188658385019041065678973298739163469211804590304088047549259078e64,
    0.0,
    4.3328896986641192419616613059379206218451368511809109144986557880328480107894369e66,
    0.0,
    -9.1885528241669328226200555215501897138960388916271995959100448711343705460992908e68,
    0.0,
    2.0346896776329074493455027990220020065975140253378277023936918421410824116666667e71,
    0.0,
    -4.7003833958035731078575255535006060654596737369759057915139763564120483354322246e73,
    0.0,
    1.1318043445484249270675186257733934267890365954750747918178993541665491176373167e76,
    0.0,
    -2.8382249570693706959264156336481764738284680928012882128228531714464865111070281e78,
];

/// B_{2n} for n = 0..50
pub(crate) const BERNOULLI_EVEN: [f64; 50] = {
    let mut xs = [0.0; 50];
    let mut i = 0;
    while i < 50 {
        xs[i] = BERNOULLI_NUMBER[i * 2];
        i += 1;
    }
    xs
};

/// Stirling Series for n = 1..=16: B_{2n} / (2 * n * (2 * n - 1))
pub(crate) const STIRLING_ASYMPTOTIC_SERIES: [f64; 16] = [
    BERNOULLI_EVEN[1] / (2.0 * 1.0), //0.083333333333333333333333333333333,
    BERNOULLI_EVEN[2] / (4.0 * 3.0), //-0.0027777777777777777777777777777778
    BERNOULLI_EVEN[3] / (6.0 * 5.0), //0.00079365079365079365079365079365079
    BERNOULLI_EVEN[4] / (8.0 * 7.0), //-0.00059523809523809523809523809523810
    BERNOULLI_EVEN[5] / (10.0 * 9.0), //0.00084175084175084175084175084175084
    BERNOULLI_EVEN[6] / (12.0 * 11.0), //-0.0019175269175269175269175269175269
    BERNOULLI_EVEN[7] / (14.0 * 13.0), //0.0064102564102564102564102564102564
    BERNOULLI_EVEN[8] / (16.0 * 15.0), //-0.029550653594771241830065359477124
    BERNOULLI_EVEN[9] / (18.0 * 17.0), //0.17964437236883057316493849001589
    BERNOULLI_EVEN[10] / (20.0 * 19.0), //-1.3924322169059011164274322169059
    BERNOULLI_EVEN[11] / (22.0 * 21.0), //13.402864044168391994478951000690
    BERNOULLI_EVEN[12] / (24.0 * 23.0), //-156.84828462600201730636513245209
    BERNOULLI_EVEN[13] / (26.0 * 25.0), //2193.1033333333333333333333333333
    BERNOULLI_EVEN[14] / (28.0 * 27.0), //-36108.771253724989357173265219242
    BERNOULLI_EVEN[15] / (30.0 * 29.0), //691472.26885131306710839525077567
    BERNOULLI_EVEN[16] / (32.0 * 31.0), //-1.5238221539407416192283364958887*10^7
];

/// f64::ln(std::f64::consts::TAU) or f64::ln(2.0 * std::f64::consts::PI)
pub(crate) const LN_2PI: f64 = 1.8378770664093454835606594728112352797227949472755668256343030810;

/// Riemann Zeta
pub(crate) const RIEMANN_ZETA_MINUS_1: [f64; 101] = [
    /*0*/-1.5,
    /*1*/f64::NAN, // complex infinity
    /*2*/6.449340668482264364724151666460251892189499012067984377355582293700074704032008738336289006197587053040043189623371906796287247e-1,
    /*3*/2.020569031595942853997381615114499907649862923404988817922715553418382057863130901864558736093352581461991577952607194184919960e-1,
    /*4*/8.23232337111381915160036965411679027747509519187269076829762154441206161869688465569096359416999172329908139080427424145840716e-2,
    /*5*/3.69277551433699263313654864570341680570809195019128119741926779038035897862814845600431065571333363796203414665566090428009618e-2,
    /*6*/1.73430619844491397145179297909205279018174900328535618424086640043321829019578978827739779385351705302791911622545588673981814e-2,
    /*7*/8.3492773819228268397975498497967595998635605652387064172831365716014783173557353460969689138513239689614536514910748872867774e-3,
    /*8*/4.0773561979443393786852385086524652589607906498500203291102026525829525747488143952872303723719711245236484702826900263542995e-3,
    /*9*/2.0083928260822144178527692324120604856058513948887565485966159097850533902583989503930691271695861574086047658470602614253740e-3,
    /*10*/9.945751278180853371459589003190170060195315644775172577889946362914651519129543970419686103856527540068920632053076773680902e-4,
    /*11*/4.941886041194645587022825264699364686064357582086171191414361000540597982198147025918430235606298355060729481412986032997979e-4,
    /*12*/2.460865533080482986379980477396709604160884580034045330409521332520196819409130490428085519006994745429809452663142695012493e-4,
    /*13*/1.227133475784891467518365263573957142751058955098451367026716208967268298442098128927139532681355390234484052117973406407649e-4,
    /*14*/6.12481350587048292585451051353337474816961691545494827552022528629410231774208766597829719984675128804906172087285080543162e-5,
    /*15*/3.05882363070204935517285106450625876279487068581775065699328933322671563422795730723343470175484943669684442492832530297758e-5,
    /*16*/1.52822594086518717325714876367220232373889904715311531052035887870870279531517862856048463224623462712187572789564380958406e-5,
    /*17*/7.6371976378997622736002935630292130882490902626790953798439729356432902824593420817386369166712096026615971011037260139196e-6,
    /*18*/3.8172932649998398564616446219397304546972189533311431744299876300395426500456380019686689896495493092104923169617616619210e-6,
    /*19*/1.9082127165539389256569577951013532585711448386302359330467618239497053413093126642271180763027067164825596661845609758534e-6,
    /*20*/9.539620338727961131520386834493459437941874105957500564898511375137311439002578360979763874789548515880868154509894190627e-7,
    /*21*/4.769329867878064631167196043730459664466947849376002074873765968390878981598338766385644972561326638121189938008974874973e-7,
    /*22*/2.384505027277329900036481867529949350418217796582698496031164744589356229148213161561677439854546762889873687437813270705e-7,
    /*23*/1.192199259653110730677887188823263872549977845198586032257972362437304274351231743133522358598376394514960036686305383144e-7,
    /*24*/5.96081890512594796124402079358012275039188373027958642469723217244953554685448482068328250036138899686000939602578235132e-8,
    /*25*/2.98035035146522801860637050693660118447309195433123986813390133844607674640820691715628962004337884609498228718862056819e-8,
    /*26*/1.49015548283650412346585066306986288647881678859105474359687899712967448625102584861794056546209745855663655522551206324e-8,
    /*27*/7.4507117898354294919810041706041194547190318825658299932395783521476062715708679008371003135237649339518303948243863281e-9,
    /*28*/3.7253340247884570548192040184024232328930592958115197693347061696049603043649737388019300665288723944363090262317345801e-9,
    /*29*/1.8626597235130490064039099454169480616653304692006657748938055580916932658178773814745210048071719673331841809967350872e-9,
    /*30*/9.313274324196681828717647350212198135679551368161850086133604419606729404963635036246040279290863121233880472910078672e-10,
    /*31*/4.656629065033784072989233251220071062691853369473073729716933711756698898095826495821914066709509473392851990940381802e-10,
    /*32*/2.328311833676505492001455975940495024829822845303110776022583879121893921705867907147218379583534840013350252782358739e-10,
    /*33*/1.164155017270051977592973835456309516522471727635932565177399470291246245675486739349743760088108709128457742138295134e-10,
    /*34*/5.82077208790270088924368598910630541731226046172159550716881241630713961792082659604553745058800537060697869711090375e-11,
    /*35*/2.91038504449709968692942522788404641069819874330322562102548256404889014082043385691172442894620300450850137727479948e-11,
    /*36*/1.45519218910419842359296322453184209838088941240380691395422185717458650302201529989423295781853630847913399997790929e-11,
    /*37*/7.2759598350574810145208690123380592648509255554661077057969426384383704393347101141837932623403266363870348438656085e-12,
    /*38*/3.6379795473786511902372363558732735126460283848974699479515940427142498169090369970169606837637347292197915595099715e-12,
    /*39*/1.8189896503070659475848321007300850305893096186640705352512533565093161524071499801682896819052946685011871151619653e-12,
    /*40*/9.094947840263889282533118386949087538600009908788285054797101120253686956071035306072205287331384902727431401990215e-13,
    /*41*/4.547473783042154026799112029488570339045299114386280812340359050026025268609889204931332244584835627288423307433114e-13,
    /*42*/2.273736845824652515226821577978691213829821989158725805336478822229597123402711641480437404838149631599218477509541e-13,
    /*43*/1.136868407680227849349104838025906437435902842517998990122763093591120891085116497156876927328431071493522124914630e-13,
    /*44*/5.68434198762758560927718296752406855305715889938835168064444404635900639192464579938387143613883264079743167257994e-14,
    /*45*/2.84217097688930185545507370494266207436882653098338276290627817566949828395298842402236802648447435554701889903015e-14,
    /*46*/1.42108548280316067698343071417395376786986056339519574517002442090074882057280000658483297467423203305781809303690e-14,
    /*47*/7.1054273952108527128773544799568000227420435936876883638288877509537793213547029975040034513985465719212602062967e-15,
    /*48*/3.5527136913371136732984695340593429921456555030626150125179340475796013212817078172211909089656612933136370459936e-15,
    /*49*/1.7763568435791203274733490144002795701555085753269519787592412332731210570663013816316798571385327818455678873961e-15,
    /*50*/8.881784210930815903096091386391386325608871464644666449769899008384098575211059078611793784389192700115796463174e-16,
    /*51*/4.440892103143813364197770940268121336459603070244180285978311534148487451448533368113912140098658002328251742283e-16,
    /*52*/2.220446050798041983999320094204653964236654329438934392366540425603322082857263082844161081125623346144761860535e-16,
    /*53*/1.110223025141066133720544569921382702483222900442625934092333308882470134479379957338432876466770838837126254134e-16,
    /*54*/5.55111512484548124372373659050943028167235506165268095853680751599195791182923122544000954151897573428699366435e-17,
    /*55*/2.77555756213612417258163245385406976898489037436902721879633648834134048925159678409720475509822972719627843778e-17,
    /*56*/1.38777878097252327628390949065002219077186246861588673480249342302666229030186627558047227362043835310334675201e-17,
    /*57*/6.9388939045441536974460853262498092748358741793471311336545161803572473280581604669538018391744708133203440681e-18,
    /*58*/3.4694469521659226247442714961093346219504706270058062440003428132183384754529220299115266894193502387449244415e-18,
    /*59*/1.7347234760475765720489729699375959074780544789072966328902467056371734928971685459390964369918282827309217252e-18,
    /*60*/8.673617380119933728342055067342951487907141457406328937108723795403640654634049352546313345859726113250385478e-19,
    /*61*/4.336808690020650487497023565906241361254780116485805599268596366070850306458285707683371794887765940157208533e-19,
    /*62*/2.168404344997219785013910168320984576157401040523618972977843886382165833194543845261749079541072297898034875e-19,
    /*63*/1.084202172494241406301271116546138258936474378031654563870400207411221472197802537238798558154077761157016481e-19,
    /*64*/5.42101086245664541091870040438863371506342238942403905838900460353749079195711293166403329382629400828420997e-20,
    /*65*/2.71050543122346883195462131194977643188872816805013655961641922814885638439089120703159012243357316112143586e-20,
    /*66*/1.35525271561011645814852339968269283289818772850375763697773580849655827364892895805687274743510894239336166e-20,
    /*67*/6.7762635780451890979952987415566862059812585701795616682893950239691336163213400620310738718786207629485844e-21,
    /*68*/3.3881317890207968180857031004508368340311585066194047909785618730605584073832098435950849255378194192214578e-21,
    /*69*/1.6940658945097991654064927471248619403036417555219718010178662138149211479361943423298886165298059436285218e-21,
    /*70*/8.470329472546998348246992609182167522283864158034291248613545961370363883891289691397311922302379137927298e-22,
    /*71*/4.235164736272833347862270483357934408810971668658101546719077233063789633368960435001352641490522946960948e-22,
    /*72*/2.117582368136194731844209439818002586941761237670536436900825113336195496715042752624848902318006095157885e-22,
    /*73*/1.058791184068023385226500153923839847069990214914266480095802274388463136138069179815953954748753705291406e-22,
    /*74*/5.29395592033987032381391230291850558663756285704594087366797219222303989818071485098579010588863617987491e-23,
    /*75*/2.64697796016985296113411668420387155925561336910067940434408789376855584568729640255555982740818054124409e-23,
    /*76*/1.32348898008489908030945102509449896843238262720171364754268948537269674402054568534364217773209485346648e-23,
    /*77*/6.6174449004244040673552453323082200147137974916175394160879173944661934615164058228248983434414103054534e-24,
    /*78*/3.3087224502121715889469563843144048092764894035909708891326309630393594087878052635949648327920961787744e-24,
    /*79*/1.6543612251060756462299236771810488297723588866643175828567454414374090238458006692582548089730301309912e-24,
    /*80*/8.271806125530344403671105616744072404009681112297828911634240702948673833268263801251794903859145412801e-25,
    /*81*/4.135903062765160926009382455508141285257587325443093977498823757753920215658537278201483091404263299402e-25,
    /*82*/2.067951531382576704395967919346895044336531236879601447785006415193289405563037073141918979212912887405e-25,
    /*83*/1.033975765691287099328409559174586091107960627178061852831749166337393102845297929187685834976527612996e-25,
    /*84*/5.16987882845643132041013321663555128936081638105226933008030402393318033941172355163094907781271372308e-26,
    /*85*/2.58493941422821426812776177084502222691211587134157963833447432459941915459627068718969446735379951984e-26,
    /*86*/1.29246970711410667003811261183318653092997787037817093150891775892134062743940758242515079156777071661e-26,
    /*87*/6.4623485355705318034380021611221670660356863512863912765627954406498745141258334502214308481466774214e-27,
    /*88*/3.2311742677852653861348141180266574173608295689387337620485847769342267596110105103301139367473335997e-27,
    /*89*/1.6155871338926325212060114057052272720509148261864297975320571270689684886108518300849420221764766625e-27,
    /*90*/8.077935669463162033158738186340899739868484689462901448504395375856631649586463591822853689599408007e-28,
    /*91*/4.038967834731580825622262812985813037947969961879913171928746677524758290424920301990374887597747849e-28,
    /*92*/2.019483917365790349158762646567304751890372848094760720937170918480931645455867018052545421325215861e-28,
    /*93*/1.009741958682895153361925070009104414453843240054765763927467895533023121174094177783248051564985460e-28,
    /*94*/5.04870979341447569608477117254866043608987346230843064447034666146710859695975160472788418804543532e-29,
    /*95*/2.52435489670723782446743419379661756483986926583039666283893136022996541497712053006454958808177663e-29,
    /*96*/1.26217744835361890437539996607771487106327646871219202072576196182259924639764177358960164899609756e-29,
    /*97*/6.3108872417680944956826093943332037500694711983569390032686012815448958133720152876121919572799530e-30,
    /*98*/3.1554436208840472391098412184847972814371269529650498226167845043747694646698228291648130168933674e-30,
    /*99*/1.5777218104420236166444327830159601782237092386241527759142745731418309191810865219995060715542413e-30,
    /*100*/7.888609052210118073520537827660413687896253431459412623465793379703382980313343644095982889526514e-31
];

pub(crate) const RIEMANN_ZETA: [f64; 101] = {
    let mut zeta = [0.0; 101];
    let mut i = 0;
    while i < 101 {
        zeta[i] = RIEMANN_ZETA_MINUS_1[i] + 1.0;
        i += 1;
    }
    zeta
};


/// \lim _{n\to \infty }\left(\sum _{k=1}^{n}{\frac {1}{k}}-\log n\right)
pub(crate) const EULER_MASCHERONI: f64 =
    0.5772156649015328606065120900824024310421593359399235988057672349;

pub(crate) const SQRT_2PI: f64 = 2.506628274631000502415765284811045253006986740609938316629923576;