Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- f64 NormalValues[] = {
- 0.82981006368785004135L,
- 0.3946389489976506L,
- 9.99999999999999954748e-8L, //0.0000001L
- 0.99999830000000000663L,
- 0.16760932829569819003L,
- 0.0997680529077115L,
- };
- f64 HalfPiValues[] = {
- -1.3528578242776663L,
- 1.54429663234196290489L,
- 1.0000001L,
- -1.0000001L,
- };
- f64 PiValues[] = {
- -2.93270853041948909024L,
- -1.8576054803775690L,
- -3.09047547364271268933L,
- 2.2576982172404999L,
- 1.5947303745826045L
- };
- f64 SinInputs[ArrayCount(NormalValues) + ArrayCount(HalfPiValues) + ArrayCount(PiValues)];
- f64 CosInputs[ArrayCount(NormalValues) + ArrayCount(HalfPiValues)];
- for (umm NormalIndex = 0; NormalIndex < ArrayCount(NormalValues); ++NormalIndex)
- {
- f64 NormalValue = NormalValues[NormalIndex];
- SinInputs[NormalIndex] = NormalValue;
- CosInputs[NormalIndex] = NormalValue;
- }
- for (umm HalfPiIndex = 0; HalfPiIndex < ArrayCount(HalfPiValues); ++HalfPiIndex)
- {
- f64 HalfPiValue = HalfPiValues[HalfPiIndex];
- umm InputIndex = HalfPiIndex + ArrayCount(NormalValues);
- Assert(InputIndex < ArrayCount(SinInputs) && InputIndex < ArrayCount(CosInputs));
- SinInputs[InputIndex] = HalfPiValue;
- CosInputs[InputIndex] = HalfPiValue;
- }
- for (umm PiIndex = 0; PiIndex < ArrayCount(PiValues); ++PiIndex)
- {
- f64 PiValue = PiValues[PiIndex];
- umm InputIndex = PiIndex + ArrayCount(NormalValues) + ArrayCount(HalfPiValues);
- Assert(InputIndex < ArrayCount(SinInputs));
- SinInputs[InputIndex] = PiValue;
- }
- flint_64 SinAnswers[] = {
- { 0x3FE79C15671C10A8L }, // 0.7378031743869728 //NormalValues
- { 0x3FD89B3CAC680372L }, // 0.3844749148993777
- { 0x3E7AD7F29ABCAF3BL }, // 9.99999999999998288081e-8
- { 0x3FEAED52A1E94A9FL }, // 0.8414700662927607
- { 0x3FC55A8B0D1EE780L }, // 0.16682565823230888
- { 0x3FB97F8EC3B8B32FL }, // 0.0997680529077115
- //
- { 0xBFEF3E3867909F45L }, //-0.9763452551605744 //HalfPiValues
- { 0x3FEFFD1FB2943722L }, // 0.9996489036436496
- { 0x3FEAED54AC0AE885L }, // 0.8414710388381229
- { 0xBFEAED54AC0AE885L }, //-0.8414710388381229
- //
- { 0xBFCA8B0C49D4AC3AL }, //-0.20736840825097308 //PiValues
- { 0xBFEEB15E54830DA2L }, //-0.9591514254211015
- { 0xBFAA291D12A22F8FL }, //-0.05109492161235983775
- { 0x3FE8BE2C114F65B9L }, // 0.7732143724526203
- { 0x3FEFFDA75D234936L } // 0.9997135943506581
- };
- flint_64 CosAnswers[] = {
- { 0x3FE599BAF611469AL }, //0.6750159078603304 //NormalValues
- { 0x3FED8A535559210BL }, //0.9231354395824679
- { 0x3FEFFFFFFFFFFFD3L }, //0.999999999999995
- { 0x3FE14A2B0FB36F12L }, //0.5403037363680332
- { 0x3FEF8D335EE5D97DL }, //0.9859864095185881
- { 0x3FEFD7437B1B968BL }, //0.9950272945831825
- { 0x3FCBAD0298F38751L }, //0.21621735065769568 //HalfPiValues
- { 0x3F9B21EC42AD6FDFL }, //0.02649659306494800159
- { 0x3FE14A27E287EFA0L }, //0.5403022217210385
- { 0x3FE14A27E287EFA0L }, //0.5403022217210385
- };
- flint_64 ASinAnswers[] = {
- { 0x3FEF520FABFE83E0L }, //0.97876723854653491477 //NormalValues
- { 0x3FD9F693BF444FA0L }, //0.4056748740997538
- { 0x3E7AD7F29ABCAF55L }, //1.0000000000000017e-7
- { 0x3FF91A6DD9AC0E3AL }, //1.5689524176422212
- { 0x3FC58E44BC4C704EL }, //0.16840419000880264059
- { 0x3FB9954B79DC1102L }, //0.0999343082913278
- };
- flint_64 SqrtAnswers[] = {
- { 0x3FED2669C738D163L }, //0.9109391108564008 //NormalValues
- { 0x3FE41A3D13CD6ADEL }, //0.6282029520765169
- { 0x3F34B96BE9C2DA2CL }, //0.00031622776601683794
- { 0x3FEFFFFE37A8D704L }, //0.9999991499996388
- { 0x3FDA33A104873FB1L }, //0.4094011825773079
- { 0x3FD437104500AA57L }, //0.31586081255469395
- };
- for (umm InputIndex = 0; InputIndex < ArrayCount(SinInputs); ++InputIndex) {
- f64 InputValue = SinInputs[InputIndex];
- flint_64 ExpectedSin = SinAnswers[InputIndex];
- f64 OutputValue = sin(InputValue);
- RecordError(InputValue, OutputValue, ExpectedSin.F64, &SinMinimax);
- }
- for (umm InputIndex = 0; InputIndex < ArrayCount(CosInputs); ++InputIndex) {
- f64 InputValue = CosInputs[InputIndex];
- flint_64 ExpectedCos = CosAnswers[InputIndex];
- f64 OutputValue = cos(InputValue);
- RecordError(InputValue, OutputValue, ExpectedCos.F64, &CosMinimax);
- }
- for (umm InputIndex = 0; InputIndex < ArrayCount(NormalValues); ++InputIndex) {
- f64 InputValue = NormalValues[InputIndex];
- flint_64 ExpectedASin = ASinAnswers[InputIndex];
- f64 OutputAsin = asin(InputValue);
- RecordError(InputValue, OutputAsin, ExpectedASin.F64, &ASinMinimax);
- flint_64 ExpectedSqrt = SqrtAnswers[InputIndex];
- f64 OutputSqrt = sqrt(InputValue);
- RecordError(InputValue, OutputSqrt, ExpectedSqrt.F64, &SqrtMinimax);
- }
- /*
- // I don't recall what this exactly was. It is something like making 128 equidistant values between 0 and 1/8,
- // avoiding those values. But I'm not sure how I picked the exact values, and it seems to be slightly inaccurate
- f64 TurnExtremals[128] = {
- 0.12499999254941944064L, 0.12402343010762706094L, 0.12304686766583472188L, 0.12207030522404238282L,
- 0.12109374278225004376L, 0.1201171803404577047L, 0.11914061789866536564L, 0.11816405545687302658L,
- 0.11718749301508068752L, 0.11621093057328834846L, 0.1152343681314960094L, 0.11425780568970367034L,
- 0.11328124324791133128L, 0.11230468080611899222L, 0.11132811836432665316L, 0.1103515559225343141L,
- 0.10937499348074197504L, 0.10839843103894963598L, 0.10742186859715729692L, 0.10644530615536495786L,
- 0.1054687437135726188L, 0.10449218127178027974L, 0.10351561882998794068L, 0.10253905638819560162L,
- 0.10156249394640326256L, 0.1005859315046109235L, 0.09960936906281858444L, 0.09863280662102624538L,
- 0.09765624417923390632L, 0.09667968173744156726L, 0.0957031192956492282L, 0.09472655685385688914L,
- 0.09374999441206455008L, 0.09277343197027221102L, 0.09179686952847987196L, 0.0908203070866875329L,
- 0.08984374464489519384L, 0.08886718220310285478L, 0.08789061976131051572L, 0.08691405731951817666L,
- 0.0859374948777258376L, 0.08496093243593349854L, 0.08398436999414115948L, 0.08300780755234882042L,
- 0.08203124511055648136L, 0.0810546826687641423L, 0.08007812022697180324L, 0.07910155778517946418L,
- 0.07812499534338712512L, 0.07714843290159478606L, 0.076171870459802447L, 0.07519530801801010794L,
- 0.07421874557621776888L, 0.07324218313442542982L, 0.07226562069263309076L, 0.0712890582508407517L,
- 0.07031249580904841264L, 0.06933593336725607358L, 0.06835937092546373452L, 0.06738280848367139546L,
- 0.0664062460418790564L, 0.06542968360008671734L, 0.06445312115829437828L, 0.06347655871650203922L,
- 0.06249999627470970016L, 0.0615234338329173611L, 0.06054687139112502204L, 0.05957030894933268298L,
- 0.05859374650754034392L, 0.05761718406574800486L, 0.0566406216239556658L, 0.05566405918216332674L,
- 0.05468749674037098768L, 0.05371093429857864862L, 0.05273437185678630956L, 0.0517578094149939705L,
- 0.05078124697320163144L, 0.04980468453140929238L, 0.04882812208961695332L, 0.04785155964782461426L,
- 0.0468749972060322752L, 0.04589843476423993614L, 0.04492187232244759708L, 0.04394530988065525802L,
- 0.04296874743886291896L, 0.0419921849970705799L, 0.04101562255527824084L, 0.04003906011348590178L,
- 0.03906249767169356272L, 0.03808593522990122366L, 0.0371093727881088846L, 0.03613281034631654554L,
- 0.03515624790452420648L, 0.03417968546273186742L, 0.03320312302093952836L, 0.0322265605791471893L,
- 0.03124999813735485024L, 0.03027343569556251118L, 0.02929687325377017212L, 0.02832031081197783306L,
- 0.027343748370185494L, 0.02636718592839315494L, 0.02539062348660081588L, 0.02441406104480847682L,
- 0.02343749860301613776L, 0.0224609361612237987L, 0.02148437371943145964L, 0.02050781127763912058L,
- 0.01953124883584678152L, 0.01855468639405444246L, 0.0175781239522621034L, 0.01660156151046976434L,
- 0.01562499906867742528L, 0.01464843662688508622L, 0.01367187418509274716L, 0.0126953117433004081L,
- 0.01171874930150806904L, 0.01074218685971572998L, 0.00976562441792339092L, 0.00878906197613105186L,
- 0.0078124995343387128L, 0.00683593709254637374L, 0.00585937465075403468L, 0.00488281220896169562L,
- 0.00390624976716935656L, 0.0029296873253770175L, 0.00195312488358467844L, 0.00097656244179233938L
- };
- f64 Sin128Answers[128] = { //Slightly inaccurate
- 0.70710674808448932248L, 0.70275471141287160359L, 0.69837621642672182625L, 0.69397142797388183231L,
- 0.68954051189212750533L, 0.68508363500292507287L, 0.68060096510515037328L, 0.67609267096877132361L,
- 0.67155892232849382649L, 0.66699988987737135514L, 0.66241574526037845716L, 0.65780666106794841898L,
- 0.65317281082947533443L, 0.64851436900678082187L, 0.64383151098754563601L, 0.63912441307870642163L,
- 0.63439325249981785789L, 0.62963820737638044302L, 0.62485945673313417071L, 0.62005718048731835067L,
- 0.61523155944189782703L, 0.61038277527875584972L, 0.60551101055185385509L, 0.60061644868035841323L,
- 0.59569927394173560088L, 0.59075967146481305977L, 0.58579782722281000178L, 0.5808139280263354231L,
- 0.57580816151635479132L, 0.57078071615712546992L, 0.56573178122910114635L, 0.5606615468218055308L,
- 0.55557020382667559391L, 0.55045794392987461293L, 0.54532495960507529686L, 0.54017144410621326233L,
- 0.53499759146021113301L, 0.52980359645967353653L, 0.52458965465555327386L, 0.51935596234978893737L,
- 0.51410271658791425465L, 0.50883011515163943641L, 0.50353835655140480782L, 0.49822764001890700345L,
- 0.49289816549959800745L, 0.48755013364515732114L, 0.48218374580593754164L, 0.47679920402338363575L,
- 0.47139671102242619469L, 0.46597647020384895592L, 0.46053868563663087954L, 0.45508356205026306746L,
- 0.44961130482704081471L, 0.44412211999433108301L, 0.4386162142168156878L, 0.43309379478871049069L,
- 0.42755506962596089032L, 0.42200024725841390547L, 0.41642953682196714512L, 0.41084314805069496105L,
- 0.40524129126895207942L, 0.39962417738345500863L, 0.3939920178753415216L, 0.38834502479220851142L,
- 0.38268341074012852009L, 0.37700738887564524107L, 0.3713171728977482968L, 0.36561297703982759349L,
- 0.35989501606160755605L, 0.35416350524106154679L, 0.34841866036630677238L, 0.34266069772747998418L,
- 0.33688983410859427777L, 0.33110628677937729843L, 0.32531027348709115956L, 0.31950201244833438244L,
- 0.31368172234082616549L, 0.30784962229517329281L, 0.30200593188661999162L, 0.29615087112678104944L,
- 0.2902846604553585021L, 0.28440752073184220456L, 0.27851967322719459693L, 0.27262133961551997879L,
- 0.26671274196571860547L, 0.26079410273312592043L, 0.25486564475113723863L, 0.24892759122281819614L,
- 0.2429801657125012819L, 0.23702359213736876792L, 0.23105809475902235495L, 0.22508389817503985096L,
- 0.21910122731051920023L, 0.21311030740961018161L, 0.20711136402703409458L, 0.20110462301959175246L,
- 0.19509031053766010258L, 0.18906865301667779337L, 0.18303987716862000913L, 0.17700420997346289332L,
- 0.17096187867063788174L, 0.16491311075047626741L, 0.1588581339456443192L, 0.15279717622256927666L,
- 0.14673046577285654395L, 0.14065823100469840585L, 0.13458070053427458943L, 0.12849810317714499521L,
- 0.12241066793963492157L, 0.11631862401021310717L, 0.11022220075086291557L, 0.10412162768844698731L,
- 0.09801713450606568423L, 0.09190895103440965162L, 0.08579730724310682364L, 0.07968243323206419785L,
- 0.07356455922280470476L, 0.06744391554979949872L, 0.0613207326517959962L, 0.05519524106314198833L,
- 0.04906767140510615398L, 0.04293825437719530036L, 0.0368072207484686581L, 0.03067480134884955753L,
- 0.02454122706043481366L, 0.01840672880880214669L, 0.01227153755431596564L, 0.00613588428343184214L
- };
- f64 Cos128Answers[128] = { //Slightly inaccurate
- 0.7071068142886041767L, 0.71143222838652140296L, 0.71573085746633601127L, 0.72000253968711203447L,
- 0.72424711422244739683L, 0.7284644212665289365L, 0.73265430204014900327L, 0.73681659879668340535L,
- 0.74095115482803047986L, 0.74505781447051106361L, 0.74913642311072914189L, 0.75318682719139295485L,
- 0.75720887421709634192L, 0.7612024127600601071L, 0.76516729246583318851L, 0.76910336405895341783L,
- 0.7730104793485676564L, 0.77688849123401109646L, 0.78073725371034551734L, 0.78455662187385628821L,
- 0.78834645192750791039L, 0.79210660118635789382L, 0.79583692808292876387L, 0.79953729217253799618L,
- 0.803207554138585679L, 0.80684757579779970375L, 0.81045722010543828655L, 0.81403635116044962463L,
- 0.81758483421058849354L, 0.82110253565748959239L, 0.82458932306169744623L, 0.82804506514765267606L,
- 0.83146963180863444886L, 0.83486289411165892154L, 0.8382247243023334943L, 0.84155499580966669075L,
- 0.8448535832508334836L, 0.84812036243589588663L, 0.8513552103724786351L, 0.85455800527039977858L,
- 0.85772862654625601197L, 0.86086695482796257188L, 0.86397287195924752765L, 0.8670462610041002977L,
- 0.87008700625117422364L, 0.87309499321814303663L, 0.87607010865601105168L, 0.87901224055337692787L,
- 0.88192127814065083377L, 0.8847971118942248594L, 0.88763963354059651768L, 0.8904487360604451801L,
- 0.89322431369266129319L, 0.89596626193832822405L, 0.89867447756465658499L, 0.90134885860887088928L,
- 0.90398930438204839156L, 0.90659571547290996839L, 0.90916799375156289629L, 0.91170604237319538631L,
- 0.914209765781722736L, 0.91667906971338496159L, 0.91911386120029577482L, 0.92151404857394277091L,
- 0.92387954146863869584L, 0.92621025082492366299L, 0.92850608889291819104L, 0.93076696923562693698L,
- 0.93299280673219299974L, 0.93518351758110267193L, 0.93733901930334051911L, 0.93945923074549466774L,
- 0.9415440720828121849L, 0.94359346482220443473L, 0.94560733180520229857L, 0.94758559721086114729L,
- 0.94952818655861545672L, 0.95143502671108295848L, 0.95330604587681822075L, 0.95514117361301555533L,
- 0.9569403408281611491L, 0.95870347978463432017L, 0.96043052410125780074L, 0.96212140875579695055L,
- 0.96377607008740780701L, 0.96539444579903387971L, 0.96697647495975159909L, 0.968522098007064331L,
- 0.97003125674914487078L, 0.97150389436702633239L, 0.97293995541674135017L, 0.97433938583140951259L,
- 0.9757021329232729495L, 0.97702814538567999624L, 0.97831737329501685978L, 0.97956976811258721441L,
- 0.98078528268643965595L, 0.98196387125314294587L, 0.98310548943950897843L, 0.98421009426426340591L,
- 0.9852776441396638591L, 0.98630809887306570213L, 0.98730141966843526263L, 0.98825756912781048027L,
- 0.9891765112527089188L, 0.99005821144548308831L, 0.99090263651062302703L, 0.99170975465600609332L,
- 0.99247953549409392099L, 0.99321195004307649281L, 0.99390697072796328916L, 0.99456457138162147068L,
- 0.99518472724576105594L, 0.99576741497186705694L, 0.99631261262207853743L, 0.99682029967001456082L,
- 0.99729045700154699678L, 0.99772306691552015725L, 0.99811811312441723485L, 0.99847558075497351868L,
- 0.99879545634873636417L, 0.99907772786257189621L, 0.99932238466911842629L, 0.99952941755718656655L,
- 0.99969881873210602591L, 0.99983058181601907486L, 0.99992470184812066824L, 0.99998117528484521673L,
- };
- for (umm ExtremalIndex = 0; ExtremalIndex < ArrayCount(TurnExtremals); ++ExtremalIndex) {
- f64 InputValue = TurnExtremals[ExtremalIndex] * (f64)6.28318530717958647693L;
- f64 ExpectedSin = Sin128Answers[ExtremalIndex];
- f64 OutputSin = sin(InputValue);
- RecordError(InputValue, OutputSin, ExpectedSin, &SinMinimax);
- f64 ExpectedCos = Cos128Answers[ExtremalIndex];
- f64 OutputCos = cos(InputValue);
- RecordError(InputValue, OutputCos, ExpectedCos, &CosMinimax);
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement