Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

math: trigonometry still wrong for huge arguments #37839

Closed
nsajko opened this issue Mar 13, 2020 · 3 comments
Closed

math: trigonometry still wrong for huge arguments #37839

nsajko opened this issue Mar 13, 2020 · 3 comments

Comments

@nsajko
Copy link
Contributor

nsajko commented Mar 13, 2020

What version of Go are you using (go version)?

$ go version
go version devel +ae3f98c51b Sat Mar 7 00:35:52 2020 +0000 linux/amd64

Does this issue reproduce with the latest release?

Dunno. Probably.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/tmp/freedesktopCache/go-build"
GOENV="/home/nsajko/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/nsajko"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/nsajko/goNew"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/nsajko/goNew/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build573035198=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Calculated sines, cosines, etc. of all kind of values, including huge ones. I had a different goal, but in the process I discovered this bug, because I compared Go's math functions' outputs with FriCAS (it can calculate with, e.g., 15000 digits of precision, which provides an effectively accurate result).

What did you expect to see?

Normally, I would just brush aside the meaningless results given huge arguments, but it seems Go actually supports that, having looked at some commit histories, Github issues, and src/math/huge_test.go. In particular, see 98521a5 @bmkessler and #6794.

Thus I would expect math.Sin and company to be accurate up to the last couple of bits of the mantissa (e.g., ULP error < 1000).

What did you see instead?

It seems the Payne-Hanek range reduction is not working properly as some inputs produce meaningless results given arguments above 10^31.

Some data for math.Sin, see attached file for more rangeReductionFailures.txt. Each line records a point where math.Sin is wrong in about 37 bits of the mantissa or more:

EDIT: added excerpt from the file for inputs around 2.6e+307

Input:   2.197000000000063281250000000000e+13     Have:   2.559435063127277198979925287858e-01     Want:   2.562412708565855457010229656589e-01     Diff:   2.977645438578258030304368730867e-04     ULP diff:        5364049155049
Input:   2.197000000000063671875000000000e+13     Have:   2.597176836301987035149352323060e-01     Want:   2.600151377550460329857173746859e-01     Diff:   2.974541248473294707821423799032e-04     ULP diff:        5358457143289
Input:   2.197000000000064062500000000000e+13     Have:   2.634878979753585426237805222627e-01     Want:   2.637850371424114159779605870426e-01     Diff:   2.971391670528733541800647799391e-04     ULP diff:        5352783368066
Input:   2.197000000000064453125000000000e+13     Have:   2.672540918193749837072914488090e-01     Want:   2.675509114946553190783617992565e-01     Diff:   2.968196752803353710703504475532e-04     ULP diff:        5347027915955
Input:   2.197000000000064843750000000000e+13     Have:   2.710162076947636444756994933414e-01     Want:   2.713127033491684048094327863510e-01     Diff:   2.964956544047603337332930095727e-04     ULP diff:        5341190874777
Input:   2.197000000000065234375000000000e+13     Have:   2.747741881962650345450072109088e-01     Want:   2.750703553056352279604368504806e-01     Diff:   2.961671093701934154296395718120e-04     ULP diff:        5335272333596
Input:   2.197000000000065625000000000000e+13     Have:   2.785279759817201883365100911760e-01     Want:   2.788238100269102015538180694421e-01     Diff:   2.958340451900132173079782660352e-04     ULP diff:        5329272382725
Input:   2.197000000000066015625000000000e+13     Have:   2.822775137729460204205622630980e-01     Want:   2.825730102398922305440009949962e-01     Diff:   2.954964669462101234387318982044e-04     ULP diff:        5323191113713
Input:   2.197000000000066406250000000000e+13     Have:   2.860227443566089600146540306014e-01     Want:   2.863178987363989014269805011281e-01     Diff:   2.951543797899414123264705267502e-04     ULP diff:        5317028619355
Input:   2.197000000000066796875000000000e+13     Have:   2.897636105850983079257332519774e-01     Want:   2.900584183740392285599796196038e-01     Diff:   2.948077889409206342463676264742e-04     ULP diff:        5310784993681
Input:   2.197000000000067187500000000000e+13     Have:   2.935000553773978726468385502812e-01     Want:   2.937945120770856788361413691746e-01     Diff:   2.944566996878061893028188933386e-04     ULP diff:        5304460331963
Input:   2.197000000000067578125000000000e+13     Have:   2.972320217199572733868251361855e-01     Want:   2.975261228373449751138934971095e-01     Diff:   2.941011173877017270683609240223e-04     ULP diff:        5298054730706
Input:   2.197000000000067968750000000000e+13     Have:   3.009594526675616332767049243557e-01     Want:   3.012531937150280669790447518608e-01     Diff:   2.937410474664337023398275050567e-04     ULP diff:        5291568287653
Input:   2.197000000000068359375000000000e+13     Have:   3.046822913442007729756255685061e-01     Want:   3.049756678396189357727052993141e-01     Diff:   2.933764954181627970797308080364e-04     ULP diff:        5285001101778
Input:   2.197000000000068750000000000000e+13     Have:   3.084004809439368499646150212357e-01     Want:   3.086934884107423449073337451409e-01     Diff:   2.930074668054949427187239052728e-04     ULP diff:        5278353273288
Input:   2.197000000000069140625000000000e+13     Have:   3.121139647317711651730576249975e-01     Want:   3.124065986990305909820619945094e-01     Diff:   2.926339672594258090043695119675e-04     ULP diff:        5271624903622
Input:   2.197000000000069531250000000000e+13     Have:   3.158226860445099704044480404264e-01     Want:   3.161149420469889781415417928656e-01     Diff:   2.922560024790077370937524392502e-04     ULP diff:        5264816095445
Input:   2.197000000000069921875000000000e+13     Have:   3.195265882916290545168180869950e-01     Want:   3.198184618698606818121277228784e-01     Diff:   2.918735782316272953096358833136e-04     ULP diff:        5257926952653
Input:   2.197000000000070312500000000000e+13     Have:   3.232256149561371638689877272554e-01     Want:   3.235171016564896695477671073604e-01     Diff:   2.914867003525056787793801049702e-04     ULP diff:        5250957580364
Input:   2.197000000000070703125000000000e+13     Have:   3.269197095954384790772451196972e-01     Want:   3.272108049701833998312849871581e-01     Diff:   2.910953747449207540398674609605e-04     ULP diff:        5243908084922
Input:   2.197000000000071093750000000000e+13     Have:   3.306088158421937039932458901603e-01     Want:   3.308995154495738555411321613065e-01     Diff:   2.906996073801515478862711461261e-04     ULP diff:        5236778573896
Input:   2.197000000000071484375000000000e+13     Have:   3.342928774051804885480976281542e-01     Want:   3.345831768094775227062598332850e-01     Diff:   2.902994042970341581622051307932e-04     ULP diff:        5229569156072
Input:   2.197000000000071875000000000000e+13     Have:   3.379718380701520197284537516680e-01     Want:   3.382617328417540925045159383444e-01     Diff:   2.898947716020727760621866764268e-04     ULP diff:        5222279941455
Input:   2.197000000000072265625000000000e+13     Have:   3.416456417006948353964901343716e-01     Want:   3.419351274161644971272266957385e-01     Diff:   2.894857154696617307365613669390e-04     ULP diff:        5214911041273
Input:   2.197000000000072656250000000000e+13     Have:   3.453142322390856389091595701757e-01     Want:   3.456033044812270027534850669326e-01     Diff:   2.890722421413638443254967569374e-04     ULP diff:        5207462567964
Input:   2.197000000000073046875000000000e+13     Have:   3.489775537071463928917580687994e-01     Want:   3.492662080650726919017756699759e-01     Diff:   2.886543579262990100176011765143e-04     ULP diff:        5199934635183
Input:   2.197000000000073437500000000000e+13     Have:   3.526355502070986358553739137278e-01     Want:   3.529237822762995024916676811699e-01     Diff:   2.882320692008666362937674421119e-04     ULP diff:        5192327357797
Input:   2.197000000000073828125000000000e+13     Have:   3.562881659224163555244047074666e-01     Want:   3.565759713048250456601806490653e-01     Diff:   2.878053824086901357759415986948e-04     ULP diff:        5184640851884
Input:   2.197000000000074218750000000000e+13     Have:   3.599353451186776964298985603818e-01     Want:   3.602227194227382023328232207859e-01     Diff:   2.873743040605059029246604040964e-04     ULP diff:        5176875234731
Input:   2.197000000000074609375000000000e+13     Have:   3.635770321444153907464169606101e-01     Want:   3.638639709851493875270023181656e-01     Diff:   2.869388407339967805853575555375e-04     ULP diff:        5169030624831
Input:   2.197000000000075000000000000000e+13     Have:   3.672131714319659123724193250382e-01     Want:   3.674996704310397599435589199857e-01     Diff:   2.864989990738475711395949474536e-04     ULP diff:        5161107141884
Input:   2.197000000000075390625000000000e+13     Have:   3.708437074983175207876229251269e-01     Want:   3.711297622841088772460693689936e-01     Diff:   2.860547857913564584464438667055e-04     ULP diff:        5153104906790
Input:   2.197000000000075781250000000000e+13     Have:   3.744685849459565285535234124836e-01     Want:   3.747541911536214076505757475388e-01     Diff:   2.856062076648790970523350551957e-04     ULP diff:        5145024041657
Input:   2.197000000000076171875000000000e+13     Have:   3.780877484637129581912518005993e-01     Want:   3.783729017352519541361743904417e-01     Diff:   2.851532715389959449225898424629e-04     ULP diff:        5136864669786
Input:   2.197000000000076562500000000000e+13     Have:   3.817011428276043116802895838191e-01     Want:   3.819858388119293790552433165431e-01     Diff:   2.846959843250673749537327239523e-04     ULP diff:        5128626915681
Input:   2.197000000000076953125000000000e+13     Have:   3.853087129016783407564616936725e-01     Want:   3.855929472546790193199228724552e-01     Diff:   2.842343530006785634611787827453e-04     ULP diff:        5120310905039
Input:   2.197000000000077343750000000000e+13     Have:   3.889104036388542073865437487257e-01     Want:   3.891941720234640134101766761887e-01     Diff:   2.837683846098060236329274630407e-04     ULP diff:        5111916764753
Input:   2.197000000000077734375000000000e+13     Have:   3.925061600817626450421471417940e-01     Want:   3.927894581680250740696180855593e-01     Diff:   2.832980862624290274709437653655e-04     ULP diff:        5103444622905
Input:   2.197000000000078125000000000000e+13     Have:   3.960959273635842325944622643874e-01     Want:   3.963787508287190952671608101809e-01     Diff:   2.828234651348626726985457935371e-04     ULP diff:        5094894608772
Input:   2.197000000000078515625000000000e+13     Have:   3.996796507088869465640357248049e-01     Want:   3.999619952373561493352838169812e-01     Diff:   2.823445284692027712480921763927e-04     ULP diff:        5086266852816
Input:   2.197000000000078906250000000000e+13     Have:   4.032572754344617149691032409464e-01     Want:   4.035391367180350963295154542720e-01     Diff:   2.818612835733813604122133256169e-04     ULP diff:        5077561486685
Input:   2.197000000000079296875000000000e+13     Have:   4.068287469501569164620491392270e-01     Want:   4.071101206879781386760441819206e-01     Diff:   2.813737378212222139950426935684e-04     ULP diff:        5068778643214
Input:   2.197000000000079687500000000000e+13     Have:   4.103940107597113806647826095286e-01     Want:   4.106748926583633219067337449815e-01     Diff:   2.808818986519412419511354528368e-04     ULP diff:        5059918456416
Input:   2.197000000000080078125000000000e+13     Have:   4.139530124615858341918794849335e-01     Want:   4.142333982351563137491723409767e-01     Diff:   2.803857735704795572928560432047e-04     ULP diff:        5050981061488
Input:   2.197000000000080468750000000000e+13     Have:   4.175056977497930699172457025270e-01     Want:   4.177855831199401848152774618939e-01     Diff:   2.798853701471148980317593668588e-04     ULP diff:        5041966594804
Input:   2.197000000000080859375000000000e+13     Have:   4.210520124147266174396975202399e-01     Want:   4.213313931107439680445736485126e-01     Diff:   2.793806960173506048761282727355e-04     ULP diff:        5032875193913
Input:   2.197000000000081250000000000000e+13     Have:   4.245919023439879147474584897282e-01     Want:   4.248707741028697748575382320269e-01     Diff:   2.788717588818601100797422986943e-04     ULP diff:        5023706997538
Input:   2.197000000000081640625000000000e+13     Have:   4.281253135232118145481194915192e-01     Want:   4.284036720897182459744101379329e-01     Diff:   2.783585665064314262906464136904e-04     ULP diff:        5014462145575
Input:   2.197000000000082031250000000000e+13     Have:   4.316521920368910913978766075161e-01     Want:   4.319300331636128920109740647604e-01     Diff:   2.778411267218006130974572442938e-04     ULP diff:        5005140779090
Input:   2.197000000000082421875000000000e+13     Have:   4.351724840691988394070222057053e-01     Want:   4.354498035166222691394466437487e-01     Diff:   2.773194474234297324244380433811e-04     ULP diff:        4995743040315
Input:   2.197000000000082812500000000000e+13     Have:   4.386861359048098707447138622229e-01     Want:   4.389629294413812665709428983973e-01     Diff:   2.767935365713958262290361744817e-04     ULP diff:        4986269072646
Input:   2.197000000000083203125000000000e+13     Have:   4.421930939297200602311477268813e-01     Want:   4.424693573319106731922545350244e-01     Diff:   2.762634021906129611068081430858e-04     ULP diff:        4976719020647
Input:   2.197000000000083593750000000000e+13     Have:   4.456933046320648017513121885713e-01     Want:   4.459690336844349678457888330740e-01     Diff:   2.757290523701660944766445027199e-04     ULP diff:        4967093030038
Input:   2.197000000000083984375000000000e+13     Have:   4.491867146029351332003898278344e-01     Want:   4.494619050981988328530292164942e-01     Diff:   2.751904952636996526393886597361e-04     ULP diff:        4957391247702
Input:   2.197000000000084375000000000000e+13     Have:   4.526732705371930287618909005687e-01     Want:   4.529479182762818356700051936059e-01     Diff:   2.746477390888069081142930372152e-04     ULP diff:        4947613821674
Input:   2.197000000000084765625000000000e+13     Have:   4.561529192342845817620400339365e-01     Want:   4.564270200264119448085864405584e-01     Diff:   2.741007921273630465464066219283e-04     ULP diff:        4937760901147
Input:   2.197000000000085156250000000000e+13     Have:   4.596256075990518552565333720850e-01     Want:   4.598991572617768808228788657289e-01     Diff:   2.735496627250255663454936438939e-04     ULP diff:        4927832636463
Input:   2.197000000000085546875000000000e+13     Have:   4.630912826425429562604563216155e-01     Want:   4.633642770018343015614448177075e-01     Diff:   2.729943592913453009884960920317e-04     ULP diff:        4917829179115
Input:   2.197000000000085937500000000000e+13     Have:   4.665498914828206666882692843501e-01     Want:   4.668223263731203220849863555486e-01     Diff:   2.724348902996553967170711985091e-04     ULP diff:        4907750681745
Input:   2.197000000000086328125000000000e+13     Have:   4.700013813457693534481052211049e-01     Want:   4.702732526100561472048866562545e-01     Diff:   2.718712642867937567814351496054e-04     ULP diff:        4897597298139
Input:   2.197000000000086718750000000000e+13     Have:   4.734456995659002132015302777290e-01     Want:   4.737170030557530941983657157834e-01     Diff:   2.713034898528809968354380544042e-04     ULP diff:        4887369183223
Input:   2.197000000000087109375000000000e+13     Have:   4.768827935871549072999187046662e-01     Want:   4.771535251628164497894601936423e-01     Diff:   2.707315756615424895414889761014e-04     ULP diff:        4877066493067
Input:   2.197000000000087500000000000000e+13     Have:   4.803126109637074758751396075240e-01     Want:   4.805827664941468846393490821356e-01     Diff:   2.701555304394087642094746115617e-04     ULP diff:        4866689384876
Input:   2.197000000000087890625000000000e+13     Have:   4.837350993607645865957067599084e-01     Want:   4.840046747237408131248059817153e-01     Diff:   2.695753629762265290992218069732e-04     ULP diff:        4856238016992
Input:   2.856100000000115000000000000000e+14     Have:   3.675982770314665804001208471163e-01     Want:   3.513038755892304854100416378060e-01     Diff:  -1.629440144223609499007920931035e-02     ULP diff:      293533841053919
Input:   2.856100000000115625000000000000e+14     Have:   4.249667541022760230973176476255e-01     Want:   4.090962128301270372965348087746e-01     Diff:  -1.587054127214898580078283885086e-02     ULP diff:      285898255037673
Input:   2.856100000000116250000000000000e+14     Have:   4.806757450926888997067010222963e-01     Want:   4.652910381146620477643693902792e-01     Diff:  -1.538470697802685194233163201716e-02     ULP diff:      277146242453784
Input:   2.856100000000116875000000000000e+14     Have:   5.345077075850710457416425924748e-01     Want:   5.196689118526798267794220009819e-01     Diff:  -1.483879573239121896222059149295e-02     ULP diff:      133655989862048
Input:   2.856100000000117500000000000000e+14     Have:   5.862524289179044112430005952774e-01     Want:   5.720174896109305739955175340583e-01     Diff:  -1.423493930697383724748306121910e-02     ULP diff:      128216934717058
Input:   2.856100000000118125000000000000e+14     Have:   6.357078470617316678925590167637e-01     Want:   6.221323513135383898031705030007e-01     Diff:  -1.357549574819327808938851376297e-02     ULP diff:      122277195185866
Input:   2.856100000000118750000000000000e+14     Have:   6.826808396670568379605015252309e-01     Want:   6.698177994980224481125219426758e-01     Diff:  -1.286304016903438984797958255513e-02     ULP diff:      115859965824230
Input:   2.856100000000119375000000000000e+14     Have:   7.326595164261566761609856257564e-01     Want:   7.148876235097005871210740224342e-01     Diff:  -1.777189291645608903991160332225e-02     ULP diff:      160074980632440
Input:   2.856100000000120000000000000000e+14     Have:   7.737385279645031532780308225483e-01     Want:   7.571658266503101808453379817365e-01     Diff:  -1.657270131419297243269284081180e-02     ULP diff:      149273622926244
Input:   2.856100000000120625000000000000e+14     Have:   8.117961071093062752623836786370e-01     Want:   7.964873134413491539973506405659e-01     Diff:  -1.530879366795712126503303807112e-02     ULP diff:      137889354917007
Input:   2.856100000000121250000000000000e+14     Have:   8.466836398284449671791662694886e-01     Want:   8.326985343183861409954715782078e-01     Diff:  -1.398510551005882618369469128083e-02     ULP diff:      125966631927676
Input:   2.856100000000121875000000000000e+14     Have:   8.782648910532515618143634128501e-01     Want:   8.656580852388235935990223879344e-01     Diff:  -1.260680581442796821534102491569e-02     ULP diff:      113552011936380
Input:   2.856100000000122500000000000000e+14     Have:   9.064165366735379425477958648116e-01     Want:   8.952372598616580301467138269800e-01     Diff:  -1.117927681187991240108203783166e-02     ULP diff:      100693973768508
Input:   2.856100000000123125000000000000e+14     Have:   9.310286451156077891511131383595e-01     Want:   9.213205521429876920791457450832e-01     Diff:  -9.708092972620097071967393276282e-03     ULP diff:       87442727787940
Input:   2.856100000000123750000000000000e+14     Have:   9.520051066226988822904786502477e-01     Want:   9.438061073846414350541067506128e-01     Diff:  -8.198999238057447236371899634833e-03     ULP diff:       73850019826653
Input:   2.856100000000124375000000000000e+14     Have:   9.692640085615263911833494603343e-01     Want:   9.626061199745959973128606179671e-01     Diff:  -6.657888586930393870488842367195e-03     ULP diff:       59968929118348
Input:   2.856100000000125000000000000000e+14     Have:   9.827379552893630298981975101924e-01     Want:   9.776471762660116082699346407026e-01     Diff:  -5.090779023351421628262869489845e-03     ULP diff:       45853661025182
Input:   2.856100000000125625000000000000e+14     Have:   9.923743313325819048742459926871e-01     Want:   9.888705412559519736248603294371e-01     Diff:  -3.503790076629931249385663249996e-03     ULP diff:       31559335366990
Input:   2.856100000000126250000000000000e+14     Have:   9.981355068489545789844896717113e-01     Want:   9.962323879443134577726937095576e-01     Diff:  -1.903118904641121211795962153701e-03     ULP diff:       17141771179567
Input:   2.856100000000126875000000000000e+14     Have:   9.999989845713798120030446625606e-01     Want:   9.997039684773230128200793842552e-01     Diff:  -2.950160940567991829652783053461e-04     ULP diff:        2657268742525
Input:   2.856100000000127500000000000000e+14     Have:   9.979574876592303134259509533877e-01     Want:   9.992717264072917826567277188587e-01     Diff:   1.314238748061469230776765471091e-03     ULP diff:       11837610272091
Input:   2.856100000000128125000000000000e+14     Have:   9.920189881142597032592789219052e-01     Want:   9.949373496302532648982719365449e-01     Diff:   2.918361515993561638993014639709e-03     ULP diff:       26286263671922
Input:   2.856100000000128750000000000000e+14     Have:   9.822066756501059980877244015574e-01     Want:   9.867177637947651680505600779725e-01     Diff:   4.511088144659169962835676415125e-03     ULP diff:       40632269774645
Input:   2.856100000000129375000000000000e+14     Have:   9.685588671369561586388385876489e-01     Want:   9.746450662076142634759889915586e-01     Diff:   6.086199070658104837150403909618e-03     ULP diff:       54819607733437
Input:   2.856100000000130000000000000000e+14     Have:   9.511288569749883903270415430597e-01     Want:   9.587664004945203322094471332093e-01     Diff:   7.637543519531941882405590149574e-03     ULP diff:       68792876297180
Input:   2.856100000000130625000000000000e+14     Have:   9.299847089808793709764245249971e-01     Want:   9.391437725052864671226870996179e-01     Diff:   9.159063524407096146262574620778e-03     ULP diff:       82497510151165
Input:   2.856100000000131250000000000000e+14     Have:   9.052089906000573282796040075482e-01     Want:   9.158538081822823473387984449801e-01     Diff:   1.064481758222501905919443743187e-02     ULP diff:       95879992993471
Input:   2.856100000000131875000000000000e+14     Have:   8.768984504825939607641771544877e-01     Want:   8.889874543377795923504436359508e-01     Diff:   1.208900385518563158626648146310e-02     ULP diff:      108888066514989
Input:   2.856100000000132500000000000000e+14     Have:   8.451636406817967239746280938562e-01     Want:   8.586496235085955275323499336082e-01     Diff:   1.348598282679880355772183975205e-02     ULP diff:      121470934466992
Input:   2.856100000000133125000000000000e+14     Have:   8.101284849508065821765967484680e-01     Want:   8.249587842748826727046207452076e-01     Diff:   1.483029932407609052802399673965e-02     ULP diff:      133579461019404
Input:   2.856100000000133750000000000000e+14     Have:   7.719297948229938421960127925558e-01     Want:   7.880464986428579177157871527015e-01     Diff:   1.611670381986407551977436014568e-02     ULP diff:      145166362635161
Input:   2.856100000000134375000000000000e+14     Have:   7.307167353658479136413461674238e-01     Want:   7.480569082979842132630210471689e-01     Diff:   1.734017293213629962167487974511e-02     ULP diff:      156186392711418
Input:   2.856100000000135000000000000000e+14     Have:   7.250279616505225233069609203085e-01     Want:   7.051461717347730084881618495274e-01     Diff:  -1.988178991574951481879907078110e-02     ULP diff:      179079243312056
Input:   2.856100000000135625000000000000e+14     Have:   6.805954064596974051326583321497e-01     Want:   6.594818544612054411757640082214e-01     Diff:  -2.111355199849196395689432392828e-02     ULP diff:      190173969825752
Input:   2.856100000000136250000000000000e+14     Have:   6.335051407715237559159504598938e-01     Want:   6.112422746590092659246806761075e-01     Diff:  -2.226286611251448999126978378627e-02     ULP diff:      200526071057039
Input:   2.856100000000136875000000000000e+14     Have:   5.839410510657729869166132630198e-01     Want:   5.606158068549755846277093951358e-01     Diff:  -2.332524421079740228890386788407e-02     ULP diff:      210095122272146
Input:   2.856100000000137500000000000000e+14     Have:   5.320966840520646723433628721978e-01     Want:   5.078001463224627309855918610992e-01     Diff:  -2.429653772960194135777101109852e-02     ULP diff:      218843756530857
Input:   2.856100000000138125000000000000e+14     Have:   4.781744908741075161806577398238e-01     Want:   4.530015370855843825914632816421e-01     Diff:  -2.517295378852313358919445818174e-02     ULP diff:      453475621207230
Input:   2.856100000000138750000000000000e+14     Have:   4.223850365423159614053361110564e-01     Want:   3.964339665407096147120569185063e-01     Diff:  -2.595107000160634669327919255011e-02     ULP diff:      467492916756400
Input:   2.856100000000139375000000000000e+14     Have:   3.649461776819502012436657878425e-01     Want:   3.383183298402588357056686163560e-01     Diff:  -2.662784784169136553799717148650e-02     ULP diff:      479684662470078
Input:   2.856100000000140000000000000000e+14     Have:   3.060822118076569897660021979391e-01     Want:   2.788815673018611995814808324212e-01     Diff:  -2.720064450579579018452136551787e-02     ULP diff:      490003249842157
Input:   2.856100000000140625000000000000e+14     Have:   2.460230014464748760083523393405e-01     Want:   2.183557782112706679988889391097e-01     Diff:  -2.766722323520420800946340023074e-02     ULP diff:      996816770019536
Input:   2.856100000000141250000000000000e+14     Have:   1.850030765295853363294753535229e-01     Want:   1.569773144796220432084510321147e-01     Diff:  -2.802576204996329312102432140819e-02     ULP diff:     1009734492199911
Input:   2.856100000000141875000000000000e+14     Have:   1.232607185579502745431668131459e-01     Want:   9.498585769427617120364004676958e-02     Diff:  -2.827486086367410333952676637637e-02     ULP diff:     2037418445593525
Input:   2.856100000000142500000000000000e+14     Have:   6.103703011815024559449938124089e-02     Want:   3.262348316735033670887844436947e-02     Diff:  -2.841354695079990888562093687142e-02     ULP diff:     4094823662716690
Input:   2.856100000000143125000000000000e+14     Have:  -1.425006618056619050668998305298e-03     Want:  -2.986628536319499080398109924772e-02     Diff:  -2.844127874513837153647166644532e-02     ULP diff:    20051086077311832
Input:   2.856100000000143750000000000000e+14     Have:  -6.388147873391539222076573878439e-02     Want:  -9.223942668854147319823510997594e-02     Diff:  -2.835794795462608097746937119155e-02     ULP diff:     2043405501463135
Input:   2.856100000000144375000000000000e+14     Have:  -1.260884950423945549680126987369e-01     Want:  -1.542523750266112103624038809357e-01     Diff:  -2.816387998421665539439118219889e-02     ULP diff:     1014710715217804
Input:   2.856100000000145000000000000000e+14     Have:  -1.878031384760519284515822846515e-01     Want:  -2.156629711412334504672116963775e-01     Diff:  -2.785983266518152201562941172597e-02     ULP diff:     1003756256076127
Input:   2.856100000000145625000000000000e+14     Have:  -2.487844146729847605303831414858e-01     Want:  -2.762314079687795409512318656198e-01     Diff:  -2.744699329579478042084872413398e-02     ULP diff:      516339113620659
Input:   2.856100000000146250000000000000e+14     Have:  -3.087941930546553859215919146664e-01     Want:  -3.357211670596144115208403491124e-01     Diff:  -2.692697400495902559924843444605e-02     ULP diff:      485073240379794
Input:   2.856100000000146875000000000000e+14     Have:  -3.675981367207045158451705901825e-01     Want:  -3.938999421775811193846550395392e-01     Diff:  -2.630180545687660353948444935668e-02     ULP diff:      473811205019043
Input:   2.856100000000147500000000000000e+14     Have:  -4.249666175295323533589453290915e-01     Want:  -4.505405464508811519408482126892e-01     Diff:  -2.557392892134879858190288359765e-02     ULP diff:      460698947042344
Input:   2.856100000000148125000000000000e+14     Have:  -4.806756127912772402765995138907e-01     Want:  -5.054217995319475464910397022322e-01     Diff:  -2.474618674067030621444018834154e-02     ULP diff:      396952440832981
Input:   2.856100000000148750000000000000e+14     Have:  -5.345075800716255765010487266409e-01     Want:  -5.583293913019684584497781543178e-01     Diff:  -2.382181123034288194872942767688e-02     ULP diff:      214567800360525
Input:   2.856100000000149375000000000000e+14     Have:  -5.862523066903625457158000244817e-01     Want:  -6.090567187473149290966034641315e-01     Diff:  -2.280441205695238338080343964975e-02     ULP diff:      205403883284188
Input:   2.856100000000150000000000000000e+14     Have:  -6.357077305973891645507478642685e-01     Want:  -6.574056927398875815882206552487e-01     Diff:  -2.169796214249841703747279098025e-02     ULP diff:      195437868439310
Input:   2.856100000000150625000000000000e+14     Have:  -6.887193757671621341387435677461e-01     Want:  -7.031875115709231849336902087089e-01     Diff:  -1.446813580376105079494664096273e-02     ULP diff:      130317382029128
Input:   2.856100000000151250000000000000e+14     Have:  -7.326594137418229735203567543067e-01     Want:  -7.462233982176265101315948413685e-01     Diff:  -1.356398447580353661123808706179e-02     ULP diff:      122173510861776
Input:   2.856100000000151875000000000000e+14     Have:  -7.737384323848787159860762585595e-01     Want:  -7.863452984636187803602069834596e-01     Diff:  -1.260686607874006437413072490017e-02     ULP diff:      113552554749047
Input:   2.856100000000152500000000000000e+14     Have:  -8.117960190076275450721254856035e-01     Want:  -8.233965371470558514133131211565e-01     Diff:  -1.160051813942830634118763555307e-02     ULP diff:      104488178340068
Input:   2.856100000000153125000000000000e+14     Have:  -8.466835595487471888276331810630e-01     Want:  -8.572324299737829056411442252283e-01     Diff:  -1.054887042503571681351104416535e-02     ULP diff:       95015777830741
Input:   2.856100000000153750000000000000e+14     Have:  -8.782648189090251911181894683978e-01     Want:  -8.877208485064063125946631771512e-01     Diff:  -9.456029597381121476473708753474e-03     ULP diff:       85172342742340
Input:   2.856100000000154375000000000000e+14     Have:  -9.064164729465047365408736368408e-01     Want:  -9.147427361230143771919642858848e-01     Diff:  -8.326263176509640651090649043908e-03     ULP diff:       74996311478235
Input:   1.461920290375737126573582162330e+31     Have:   7.408872655117226813104025495704e-01     Want:   2.401457595212431669895458696828e-02     Diff:  -7.168726895595983750197888184630e-01     ULP diff:    22269587102812117
Input:   1.461920290375737351753563530854e+31     Have:  -2.030728511215038056825221701729e-01     Want:  -6.082962058834183727284994347428e-01     Diff:  -4.052233547619145670459772645700e-01     ULP diff:     7169773853916941
Input:   1.461920290375737576933544899379e+31     Have:  -9.468766486679395244507873030670e-01     Want:   6.864670207863401429904115502723e-01     Diff:   1.633343669454279556418896390824e+00     ULP diff:  9221026475448593287
Input:   1.003517226963376623173225369743e+98     Have:  -4.506479397199250613859078384849e-01     Want:  -8.305869905436233935347445367370e-01     Diff:  -3.799390508236983321488366982521e-01     ULP diff:     3866710576000839
Input:   1.003517226963376774944232574878e+98     Have:   7.740446839024237579707232725923e-01     Want:  -9.709601679804962248709898631205e-01     Diff:  -1.745004851882919982841713135713e+00     ULP diff:  9221598379853340832
Input:   1.003517226963376926715239780013e+98     Have:   7.856165374785243349364804998913e-01     Want:  -9.942309933187718495872786661494e-01     Diff:  -1.779847530797296073501456703525e+00     ULP diff:  9221493004883603333
Input:   1.003517226963377078486246985148e+98     Have:  -4.340683551349220348214430487133e-01     Want:  -8.975928958336639729154171618575e-01     Diff:  -4.635245406987419380939741131442e-01     ULP diff:     4768917360028447
Input:   1.003517226963377230257254190283e+98     Have:  -9.734600448040724440801341188489e-01     Want:  -6.927008835172894229970097512705e-01     Diff:   2.807591612867830210831243675784e-01     ULP diff:     2528853708304018
Input:   1.003517226963377382028261395418e+98     Have:   1.280256394301604143393102930304e-02     Want:  -4.042658944283801236707631687750e-01     Diff:  -4.170684583713961668394176740549e-01     ULP diff:  9200951607433902027
Input:   1.003517226963377533799268600553e+98     Have:   9.790003669339090164314143294177e-01     Want:  -6.707454161626057176359694267376e-02     Diff:  -1.046074908550169491050496617390e+00     ULP diff:  9205876416687290664
Input:   1.003517226963377685570275805688e+98     Have:   4.108608070960971803131656088226e-01     Want:   2.782063156350947918937777103565e-01     Diff:  -1.326544914610023884193878984661e-01     ULP diff:     2389690873251172
Input:   1.003517226963377837341283010823e+98     Have:  -8.011999488326005947058661149640e-01     Want:   5.899341858495928958561194122012e-01     Diff:   1.391134134682193490561985527165e+00     ULP diff:  9221469124031882974
Input:   1.003517226963377989112290215959e+98     Have:  -7.575808724438353181085403775796e-01     Want:   1.489026238367884558133624750553e-01     Diff:   9.064834962806237461663272370060e-01     ULP diff:  9212905938140159469
Input:   1.003517226963378140883297421094e+98     Have:   4.733560816648008096052535620402e-01     Want:  -1.982701352523188464971326538944e-01     Diff:  -6.716262169171196561023862159345e-01     ULP diff:  9217484646593337020
Input:   1.003517226963378292654304626229e+98     Have:   9.624261820406536660499341451214e-01     Want:  -5.215305857271145262288314370380e-01     Diff:  -1.483956767767768081256463119644e+00     ULP diff:  9219400802368241913
Input:   1.003517226963378444425311831364e+98     Have:  -5.686520542882406853424370751782e-02     Want:  -7.818920004906626530782887130044e-01     Diff:  -7.250267950618385359717876781360e-01     ULP diff:    16861915778242263
Input:   1.003517226963378596196319036499e+98     Have:  -9.870346555821488676585317989520e-01     Want:  -9.479535712812361403223349043401e-01     Diff:   3.908108430091272733619689461193e-02     ULP diff:      352011113389651
Input:   1.003517226963378747967326241634e+98     Have:  -3.702750119196270839339035774174e-01     Want:  -9.996874934843469340250976529205e-01     Diff:  -6.294124815647198500911940755032e-01     ULP diff:     6837702450833242
Input:   1.003517226963378899738333446769e+98     Have:   8.267977802347802329663295495266e-01     Want:  -9.308544133416729593477612070274e-01     Diff:  -1.757652193576453303336393219070e+00     ULP diff:  9222434778026604547
Input:   1.003517226963379051509340651904e+98     Have:   7.280725639664793469307824125281e-01     Want:  -7.497559232899705383701416394615e-01     Diff:  -1.477828487256449996323226514505e+00     ULP diff:  9223176730516836977
Input:   1.003517226963379203280347857039e+98     Have:  -5.117236625639410840804544022831e-01     Want:  -4.782333509613166944163253901934e-01     Diff:   3.349031160262438966412901208969e-02     ULP diff:      497710454707639
Input:   1.003517226963379355051355062174e+98     Have:  -9.495214819084649704450384888332e-01     Want:  -1.490335925890341195465538248754e-01     Diff:   8.004878893194308231429090483289e-01     ULP diff:    12190227382550197
Input:   1.003517226963379506822362267309e+98     Have:   1.008173079940538618970435891242e-01     Want:   1.981403163296903136014748270100e-01     Diff:   9.732300833563645170443123788573e-02     ULP diff:     4377704214253940
Input:   1.003517226963379658593369472444e+98     Have:   9.931502710350913476489154163573e-01     Want:   5.214175734052951538544107279449e-01     Diff:  -4.717326976297961937945046884124e-01     ULP diff:     4248990402528058
Input:   1.003517226963379810364376677580e+98     Have:   3.289694479526278358960666992061e-01     Want:   2.298507968660201961075273402457e-01     Diff:  -9.911865108660763978853935896041e-02     ULP diff:     2148538655300465
Input:   1.003517226963379962135383882715e+98     Have:  -8.507884190932164525378311736858e-01     Want:  -1.168591414145243173594579388919e-01     Diff:   7.339292776786920935450098113506e-01     ULP diff:    12753431124841569
Input:   1.003517226963380113906391087850e+98     Have:  -6.971489725455978225809872128593e-01     Want:  -4.494753189259471093386366646882e-01     Diff:   2.476736536196507132423505481711e-01     ULP diff:     2685931818018132
Input:   1.003517226963380265677398292985e+98     Have:   5.490965160042143855534391150286e-01     Want:  -7.278826639927079567016221517406e-01     Diff:  -1.276979179996922342255061266769e+00     ULP diff:  9221761674395855836
Input:   1.003517226963380417448405498120e+98     Have:   9.347710295472195785038138637901e-01     Want:  -9.185039444852409751263166981516e-01     Diff:  -1.853274974032460553630130561942e+00     ULP diff:  9223225515978328746
Input:   1.003517226963380569219412703255e+98     Have:  -1.445734341917100651553340640021e-01     Want:  -9.983493395624399857624098331144e-01     Diff:  -8.537759053707298928515001534834e-01     ULP diff:    12790723767191296
Input:   1.003517226963380720990419908390e+98     Have:  -9.973353252932866119806476490339e-01     Want:  -9.577891199355853535379878849199e-01     Diff:   3.954620535770125844265976411407e-02     ULP diff:      356200551425721
Input:   1.003517226963380872761427113525e+98     Have:  -2.870244080986484869200126013311e-01     Want:  -8.017150384041965560655285116809e-01     Diff:  -5.146906303055480691455159103498e-01     ULP diff:     6554234654362179
Input:   1.003517226963381024532434318660e+98     Have:   8.731252305755298204203995737771e-01     Want:  -5.489503615158266569551415159367e-01     Diff:  -1.422075592091356366353238627198e+00     ULP diff:  9220452129215775491
Input:   1.304572395052395574725776142474e+99     Have:  -7.746188852460255125365051753761e-01     Want:  -9.215319367103936842866573897481e-01     Diff:  -1.469130514643681717501522143721e-01     ULP diff:     1323275127661582
Input:   1.304572395052395817559387670691e+99     Have:   5.125030677273919588188277884910e-01     Want:  -9.848402683971800852802402914676e-01     Diff:  -1.497343336124572044099068079959e+00     ULP diff:  9219117601572916446
Input:   1.304572395052396060392999198907e+99     Have:  -1.889396881988479048875007038077e-01     Want:  -8.658139219941526354418215305486e-01     Diff:  -6.768742337953047583098964423698e-01     ULP diff:     9998488092728466
Input:   1.304572395052396303226610727123e+99     Have:  -1.572769863786680766271075526674e-01     Want:  -3.414014983868754460338834633149e-01     Diff:  -1.841245120082073694067759106474e-01     ULP diff:     4987241653054548
Input:   1.304572395052396546060222255339e+99     Have:   4.846366277366762620459894606029e-01     Want:   3.428598380952896929052542418503e-01     Diff:  -1.417767896413865691407352187525e-01     ULP diff:     2554023587994935
Input:  2.647738350613641276917555217142e+307     Have:  -5.822149887759020363275919152102e-03     Want:   2.697399481573612978202447720832e-01     Diff:   2.755620980451203294592232850846e-01     ULP diff:  9198203717979160830
Input:  2.647738350613641775877632600822e+307     Have:  -4.633161064643914195393392674305e-01     Want:  -9.781979989546780718256968611968e-01     Diff:  -5.148818924902867077975088250241e-01     ULP diff:     4968062936833073
Input:  2.647738350613642274837709984502e+307     Have:   8.244837056559448651427146614878e-01     Want:  -1.447605612526073060042364204492e-01     Diff:  -9.692442669085521433913754663081e-01     ULP diff:  9212154097458625987
Input:  2.647738350613642773797787368182e+307     Have:  -9.935145621877253807596730439400e-01     Want:   9.966933201602750092007454441045e-01     Diff:   1.990207882348000278938116025529e+00     ULP diff:  9223343405148334457
Input:  2.647738350613643272757864751862e+307     Have:   9.310179179886934885956861762679e-01     Want:   1.741812115478588024464201566843e-02     Diff:  -9.135997968339075736565746410633e-01     ULP diff:    25883430421610728
Input:  2.647738350613643771717942135542e+307     Have:  -6.515579197620460227824423782295e-01     Want:  -9.989187449774226124077358690556e-01     Diff:  -3.473608252153765896252934908262e-01     ULP diff:     3128748166006156
Input:  2.647738350613644270678019519222e+307     Have:   2.202596068440736687410463900960e-01     Want:   1.102086501618143032921182111750e-01     Diff:  -1.100509566822593654489281789211e-01     ULP diff:     4497918121004397
Input:  2.647738350613644769638096902902e+307     Have:   2.623677537048322849777548526617e-01     Want:   9.848379458513325523938419792103e-01     Diff:   7.224701921465002119049358952907e-01     ULP diff:     8647833968006801
Input:  2.647738350613645268598174286582e+307     Have:  -6.838532320916130835541935084620e-01     Want:  -2.360363893358540798850242481421e-01     Diff:   4.478168427557590036691692603199e-01     ULP diff:     6662694416718150
Input:  2.647738350613645767558251670262e+307     Have:   9.459743330260754756722008096403e-01     Want:  -9.546807759757748312878788965463e-01     Diff:  -1.900655109001850195937777243671e+00     ULP diff:  9223293616188327831
Input:  2.647738350613646266518329053942e+307     Have:  -9.876466540264590143749501294224e-01     Want:   3.580111001803967796242034182796e-01     Diff:   1.345657754206855738488002316444e+00     ULP diff:  9216421861650778501
Input:  2.647738350613646765478406437622e+307     Have:   7.991589249231293434760914351500e-01     Want:   9.089395171984548937871295493096e-01     Diff:   1.097805922753255503110381141596e-01     ULP diff:      988815668927337
Input:  2.647738350613647264438483821302e+307     Have:  -4.244361111857667401281446473149e-01     Want:  -4.741416828583002729402551267412e-01     Diff:  -4.970557167253353281211047942634e-02     ULP diff:      895415976250638
Input:  2.647738350613647763398561204982e+307     Have:  -4.919680994484608438366279870024e-02     Want:  -8.483608440740537659507936041337e-01     Diff:  -7.991640341292076676893429976190e-01     ULP diff:    18565746154043610
Input:  2.647738350613648262358638588662e+307     Have:   5.113649625819026711681658525777e-01     Want:   5.825324363455064435868280270370e-01     Diff:   7.116747376360377241866217445931e-02     ULP diff:      641019616645331
Input:  2.647738350613648761318715972342e+307     Have:  -8.543652074157898068662575497001e-01     Want:   7.739336352427185206082071999845e-01     Diff:   1.628298842658508327474464749685e+00     ULP diff:  9222647573657840874
Input:  2.647738350613649260278793356021e+307     Have:   9.982651584917640041894060232153e-01     Want:   5.121574273593497705903132555250e-01     Diff:  -4.861077311324142335990927676903e-01     ULP diff:     4378469193579716
Input:  2.647738350613649759238870739701e+307     Have:  -9.095305352910352247874925524229e-01     Want:  -8.898551229426597819482935847191e-01     Diff:   1.967541234837544283919896770385e-02     ULP diff:      177220359441009
Input:  2.647738350613650258198948123381e+307     Have:   6.088399532258583768395965307718e-01     Want:  -3.984651607443360776805718614924e-01     Diff:  -1.007305113970194510031319623522e+00     ULP diff:  9220562604652246087
Input:  2.647738350613650757159025507061e+307     Have:  -1.662660026823717662747270651380e-01     Want:   9.407649914416227332480957556982e-01     Diff:   1.107030994123994416256095973949e+00     ULP diff:  9211881543932033107
Input:  2.647738350613651256119102890741e+307     Have:  -3.150543875436753737950823506253e-01     Want:   2.782683989665830082138597845187e-01     Diff:   5.933227865102583820089421351440e-01     ULP diff:  9222709359396982814
Input:  2.647738350613651755079180274421e+307     Have:   7.229548625330083355677857070987e-01     Want:  -9.763179305551511477645476588805e-01     Diff:  -1.699272793088159483332333365979e+00     ULP diff:  9221089945217307872
Input:  2.647738350613652254039257658101e+307     Have:  -9.623787606970602981348861248989e-01     Want:  -1.535292188463071305637441810177e-01     Diff:   8.088495418507531953267175595101e-01     ULP diff:    12144063448576416
Input:  2.647738350613652752999335041781e+307     Have:   9.775310098075119524807519155729e-01     Want:   9.959335785772100990698163514026e-01     Diff:   1.840256876969814658906443582964e-02     ULP diff:      165755603707745
Input:  2.647738350613653251959412425461e+307     Have:  -7.648805470088084756952184761758e-01     Want:   2.628384706937674994420284235730e-02     Diff:   7.911643940781851735977170392289e-01     ULP diff:  9201540410352460233
Input:  2.647738350613653750919489809141e+307     Have:   3.739831936797730072008505430858e-01     Want:  -9.992917321368568472905735688983e-01     Diff:  -1.373274925816629910002575343242e+00     ULP diff:  9216604699769229595
@robpike
Copy link
Contributor

robpike commented Mar 13, 2020

I believe this is a dup of #31566, for which https://go-review.googlesource.com/c/go/+/172838 is underway.

@nsajko
Copy link
Contributor Author

nsajko commented Mar 13, 2020

I am not an expert, but #31566 says package math is not using Payne-Hanek enough, while my issue is about Payne-Hanek (or the implementation) being wrong. https://go-review.googlesource.com/c/go/+/172838 likewise just expands the use of Payne-Hanek (by lowering the threshhold), while the fix for my issue would presumably belong to either func trigReduce or var mPi4. Thus these issues are actually complementary, or even opposite. EDIT: since this bug happens with the entire possible range of exponents, var mPi4 is probably correct and func trigReduce is probably wrong.

BTW, I uploaded the entire file with the diffs now, so the input values in it now go up to +Inf, approximately. And, BTW, the file does not list all the points for which this bug happens. And to repeat my self for clarity, it features results for math.Sin in every line.

@nsajko
Copy link
Contributor Author

nsajko commented Mar 13, 2020

Oops: turns out converting from the high precision floating point type to binary64 and back again fixes the Fricas results. In other words I did sin(HUGEFLOATVAL) instead of sin(HUGEFLOATVAL::DoubleFLoat::Float) in Fricas, where HUGEFLOATVAL was obtained from Go's fmt.Printf("%35.30e", ...), and this greatly affects results for huge arguments.

@nsajko nsajko closed this as completed Mar 13, 2020
@golang golang locked and limited conversation to collaborators Mar 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants