
with degrees as (
select generate_series(89.99998, 90.00002, 0.00001)
union all select generate_series(44.99998, 45.00002, 0.00001)
union all select generate_series(29.99998, 30.00002, 0.00001)
union all select generate_series(-0.00002, 0.00002, 0.00001)
union all select generate_series(59.99998, 60.00002, 0.00001))
SELECT x, cosd(x), sind(x), tand(x) FROM degrees as deg(x);
    x     |         cosd          |         sind          |         tand          
----------+-----------------------+-----------------------+-----------------------
 89.99998 |  3.49065850509657e-07 |     0.999999999999939 |      2864788.97474468
 89.99999 |  1.74532925254831e-07 |     0.999999999999985 |      5729577.94948953
 90.00000 |                     0 |                     1 |              Infinity
 90.00001 | -1.74532925254831e-07 |     0.999999999999985 |     -5729577.94948953
 90.00002 | -3.49065850509657e-07 |     0.999999999999939 |     -2864788.97474468
 44.99998 |     0.707107028013334 |     0.707106534359675 |     0.999999301868543
 44.99999 |     0.707106904599952 |     0.707106657773122 |     0.999999650934211
 45.00000 |     0.707106781186547 |     0.707106781186547 |                     1
 45.00001 |     0.707106657773122 |     0.707106904599952 |      1.00000034906591
 45.00002 |     0.707106534359675 |     0.707107028013334 |      1.00000069813194
 29.99998 |     0.866025578317311 |     0.499999697700076 |     0.577349803768586
 29.99999 |     0.866025491050888 |     0.499999848850045 |     0.577350036479082
 30.00000 |     0.866025403784439 |                   0.5 |     0.577350269189626
 30.00001 |     0.866025316517963 |     0.500000151149939 |     0.577350501900216
 30.00002 |     0.866025229251461 |     0.500000302299863 |     0.577350734610853
 -0.00002 |     0.999999999999939 | -3.49065850398859e-07 |  -3.4906585039888e-07
 -0.00001 |     0.999999999999985 | -1.74532925199432e-07 | -1.74532925199435e-07
  0.00000 |                     1 |                     0 |                     0
  0.00001 |     0.999999999999985 |  1.74532925199432e-07 |  1.74532925199435e-07
  0.00002 |     0.999999999999939 |  3.49065850398859e-07 |   3.4906585039888e-07
 59.99998 |     0.500000302299863 |     0.866025229251461 |      1.73204941130632
 59.99999 |     0.500000151149939 |     0.866025316517963 |      1.73205010943739
 60.00000 |                   0.5 |     0.866025403784439 |      1.73205080756888
 60.00001 |     0.499999848850045 |     0.866025491050888 |      1.73205150570079
 60.00002 |     0.499999697700076 |     0.866025578317311 |      1.73205220383312
(25 rows)

with degrees as (
select generate_series(89.9999998, 90.0000002, 0.0000001)
union all select generate_series(44.9999998, 45.0000002, 0.0000001)
union all select generate_series(29.9999998, 30.0000002, 0.0000001)
union all select generate_series(-0.0000002, 0.0000002, 0.0000001)
union all select generate_series(59.9999998, 60.0000002, 0.0000001))
SELECT x, cosd(x), sind(x), tand(x) FROM degrees as deg(x);

     x      |         cosd          |         sind          |         tand          
------------+-----------------------+-----------------------+-----------------------
 89.9999998 |  3.49065854478083e-09 |                     1 |      286478894.217591
 89.9999999 |  1.74532914837732e-09 |                     1 |      572957829.146284
 90.0000000 |                     0 |                     1 |              Infinity
 90.0000001 | -1.74532914837732e-09 |                     1 |     -572957829.146284
 90.0000002 | -3.49065854478083e-09 |                     1 |     -286478894.217591
 44.9999998 |     0.707106783654816 |     0.707106778718279 |     0.999999993018683
 44.9999999 |     0.707106782420682 |     0.707106779952413 |     0.999999996509342
 45.0000000 |     0.707106781186547 |     0.707106781186547 |                     1
 45.0000001 |     0.707106779952413 |     0.707106782420682 |      1.00000000349066
 45.0000002 |     0.707106778718279 |     0.707106783654816 |      1.00000000698132
 29.9999998 |     0.866025405529768 |     0.499999996977001 |     0.577350264535415
 29.9999999 |     0.866025404657103 |     0.499999998488501 |      0.57735026686252
 30.0000000 |     0.866025403784439 |                   0.5 |     0.577350269189626
 30.0000001 |     0.866025402911774 |     0.500000001511499 |     0.577350271516731
 30.0000002 |     0.866025402039109 |     0.500000003022999 |     0.577350273843837
 -0.0000002 |                     1 | -3.49065850398866e-09 | -3.49065850398866e-09
 -0.0000001 |                     1 | -1.74532925199433e-09 | -1.74532925199433e-09
  0.0000000 |                     1 |                     0 |                     0
  0.0000001 |                     1 |  1.74532925199433e-09 |  1.74532925199433e-09
  0.0000002 |                     1 |  3.49065850398866e-09 |  3.49065850398866e-09
 59.9999998 |     0.500000003022999 |     0.866025402039109 |      1.73205079360624
 59.9999999 |     0.500000001511499 |     0.866025402911774 |      1.73205080058756
 60.0000000 |                   0.5 |     0.866025403784439 |      1.73205080756888
 60.0000001 |     0.499999998488501 |     0.866025404657103 |      1.73205081455019
 60.0000002 |     0.499999996977001 |     0.866025405529768 |      1.73205082153151
(25 rows)

with degrees as (
select generate_series(89.999999998, 90.000000002, 0.000000001)
union all select generate_series(44.999999998, 45.000000002, 0.000000001)
union all select generate_series(29.999999998, 30.000000002, 0.000000001)
union all select generate_series(-0.000000002, 0.000000002, 0.000000001)
union all select generate_series(59.999999998, 60.000000002, 0.000000001))
SELECT x, cosd(x), sind(x), tand(x) FROM degrees as deg(x);
      x       |         cosd          |         sind          |         tand          
--------------+-----------------------+-----------------------+-----------------------
 89.999999998 |  3.49064639149682e-11 |                     1 |      28647989164.2989
 89.999999999 |  1.74533559705863e-11 |                     1 |      57295571217.6659
 90.000000000 |                     0 |                     1 |              Infinity
 90.000000001 | -1.74533559705863e-11 |                     1 |     -57295571217.6659
 90.000000002 | -3.49064639149682e-11 |                     1 |     -28647989164.2989
 44.999999998 |      0.70710678121123 |     0.707106781161865 |     0.999999999930187
 44.999999999 |     0.707106781198889 |     0.707106781174206 |     0.999999999965093
 45.000000000 |     0.707106781186547 |     0.707106781186547 |                     1
 45.000000001 |     0.707106781174206 |     0.707106781198889 |      1.00000000003491
 45.000000002 |     0.707106781161865 |      0.70710678121123 |      1.00000000006981
 29.999999998 |     0.866025403801892 |      0.49999999996977 |     0.577350269143084
 29.999999999 |     0.866025403793165 |     0.499999999984885 |     0.577350269166355
 30.000000000 |     0.866025403784439 |                   0.5 |     0.577350269189626
 30.000000001 |     0.866025403775712 |     0.500000000015115 |     0.577350269212897
 30.000000002 |     0.866025403766985 |      0.50000000003023 |     0.577350269236168
 -0.000000002 |                     1 | -3.49065850398866e-11 | -3.49065850398866e-11
 -0.000000001 |                     1 | -1.74532925199433e-11 | -1.74532925199433e-11
  0.000000000 |                     1 |                     0 |                     0
  0.000000001 |                     1 |  1.74532925199433e-11 |  1.74532925199433e-11
  0.000000002 |                     1 |  3.49065850398866e-11 |  3.49065850398866e-11
 59.999999998 |      0.50000000003023 |     0.866025403766985 |      1.73205080742925
 59.999999999 |     0.500000000015115 |     0.866025403775712 |      1.73205080749906
 60.000000000 |                   0.5 |     0.866025403784439 |      1.73205080756888
 60.000000001 |     0.499999999984885 |     0.866025403793165 |      1.73205080763869
 60.000000002 |      0.49999999996977 |     0.866025403801892 |       1.7320508077085
(25 rows)

-- checks for acosd, asind, atand
with degrees as (
select generate_series((sqrt(3) / 3 - 0.00001)::numeric, (sqrt(3) / 3 + 0.00001)::numeric, 0.000001)
union all select generate_series((sqrt(3) / 2 - 0.00001)::numeric, (sqrt(3) / 2 + 0.00001)::numeric, 0.000001)
union all select generate_series(0.5 - 0.00001, 0.5 + 0.00001, 0.000001)
union all select generate_series(0, 0.00001, 0.000001)
union all select generate_series(0.99999, 1, 0.000001))
select x, acosd(x), asind(x), atand(x) from degrees as deg(x);
         x         |       acosd        |        asind         |        atand         
-------------------+--------------------+----------------------+----------------------
 0.577340269189626 |   54.7363120413279 |     35.2636879586721 |     29.9995702797929
 0.577341269189626 |   54.7362418691931 |     35.2637581308069 |     29.9996132519811
 0.577342269189626 |   54.7361716969976 |     35.2638283030024 |     29.9996562241321
 0.577343269189626 |   54.7361015247412 |     35.2638984752588 |     29.9996991962458
 0.577344269189626 |   54.7360313524241 |     35.2639686475759 |     29.9997421683223
 0.577345269189626 |   54.7359611800462 |     35.2640388199538 |     29.9997851403617
 0.577346269189626 |   54.7358910076076 |     35.2641089923924 |     29.9998281123638
 0.577347269189626 |   54.7358208351082 |     35.2641791648918 |     29.9998710843286
 0.577348269189626 |    54.735750662548 |      35.264249337452 |     29.9999140562563
 0.577349269189626 |   54.7356804899271 |     35.2643195100729 |     29.9999570281468
 0.577350269189626 |   54.7356103172453 |     35.2643896827547 |                   30
 0.577351269189626 |   54.7355401445028 |     35.2644598554972 |      30.000042971816
 0.577352269189626 |   54.7354699716996 |     35.2645300283004 |     30.0000859435949
 0.577353269189626 |   54.7353997988355 |     35.2646002011645 |     30.0001289153365
 0.577354269189626 |   54.7353296259107 |     35.2646703740893 |     30.0001718870408
 0.577355269189626 |   54.7352594529251 |     35.2647405470749 |      30.000214858708
 0.577356269189626 |   54.7351892798788 |     35.2648107201212 |      30.000257830338
 0.577357269189626 |   54.7351191067716 |     35.2648808932284 |     30.0003008019307
 0.577358269189626 |   54.7350489336037 |     35.2649510663963 |     30.0003437734862
 0.577359269189626 |   54.7349787603751 |     35.2650212396249 |     30.0003867450045
 0.577360269189626 |   54.7349085870856 |     35.2650914129144 |     30.0004297164856
 0.866015403784439 |   30.0011458957432 |     59.9988541042568 |     40.8930672430563
 0.866016403784439 |    30.001031307955 |      59.998968692045 |     40.8930999838096
 0.866017403784439 |   30.0009167197699 |     59.9990832802301 |     40.8931327245305
 0.866018403784439 |    30.000802131188 |      59.999197868812 |     40.8931654652189
 0.866019403784439 |   30.0006875422091 |     59.9993124577909 |      40.893198205875
 0.866020403784439 |   30.0005729528332 |     59.9994270471668 |     40.8932309464987
 0.866021403784439 |   30.0004583630605 |     59.9995416369395 |     40.8932636870899
 0.866022403784439 |   30.0003437728908 |     59.9996562271092 |     40.8932964276488
 0.866023403784439 |   30.0002291823241 |     59.9997708176759 |     40.8933291681752
 0.866024403784439 |   30.0001145913605 |     59.9998854086395 |     40.8933619086693
 0.866025403784439 |                 30 |                   60 |     40.8933946491309
 0.866026403784439 |   29.9998854082425 |     60.0001145917575 |     40.8934273895602
 0.866027403784439 |    29.999770816088 |      60.000229183912 |      40.893460129957
 0.866028403784439 |   29.9996562235366 |     60.0003437764634 |     40.8934928703214
 0.866029403784439 |   29.9995416305882 |     60.0004583694118 |     40.8935256106534
 0.866030403784439 |   29.9994270372428 |     60.0005729627572 |      40.893558350953
 0.866031403784439 |   29.9993124435004 |     60.0006875564996 |     40.8935910912203
 0.866032403784439 |   29.9991978493611 |     60.0008021506389 |     40.8936238314551
 0.866033403784439 |   29.9990832548247 |     60.0009167451753 |     40.8936565716575
 0.866034403784439 |   29.9989686598914 |     60.0010313401086 |     40.8936893118275
 0.866035403784439 |   29.9988540645611 |     60.0011459354389 |      40.893722051965
           0.49999 |   60.0006615924692 |     29.9993384075308 |     26.5645928090084
          0.499991 |   60.0005954334208 |     29.9994045665792 |     26.5646386459804
          0.499992 |   60.0005292743282 |     29.9994707256718 |     26.5646844829157
          0.499993 |   60.0004631151916 |     29.9995368848084 |     26.5647303198143
          0.499994 |   60.0003969560108 |     29.9996030439892 |     26.5647761566763
          0.499995 |   60.0003307967859 |     29.9996692032141 |     26.5648219935016
          0.499996 |   60.0002646375169 |      29.999735362483 |     26.5648678302902
          0.499997 |   60.0001984782039 |     29.9998015217961 |     26.5649136670421
          0.499998 |   60.0001323188467 |     29.9998676811533 |     26.5649595037574
          0.499999 |   60.0000661594454 |     29.9999338405546 |      26.565005340436
          0.500000 |                 60 |                   30 |      26.565051177078
          0.500001 |   59.9999338405105 |     30.0000661594895 |     26.5650970136833
          0.500002 |   59.9998676809769 |     30.0001323190231 |     26.5651428502519
          0.500003 |   59.9998015213992 |     30.0001984786008 |     26.5651886867838
          0.500004 |   59.9997353617774 |     30.0002646382226 |     26.5652345232791
          0.500005 |   59.9996692021114 |     30.0003307978886 |     26.5652803597377
          0.500006 |   59.9996030424014 |     30.0003969575986 |     26.5653261961596
          0.500007 |   59.9995368826472 |     30.0004631173528 |     26.5653720325449
          0.500008 |    59.999470722849 |      30.000529277151 |     26.5654178688935
          0.500009 |   59.9994045630066 |     30.0005954369934 |     26.5654637052054
          0.500010 |   59.9993384031202 |     30.0006615968798 |     26.5655095414806
                 0 |                 90 |                    0 |                    0
          0.000001 |   89.9999427042205 | 5.72957795130919e-05 | 5.72957795130632e-05
          0.000002 |    89.999885408441 | 0.000114591559026241 | 0.000114591559026012
          0.000003 |   89.9998281126615 | 0.000171887338539505 | 0.000171887338538731
          0.000004 |   89.9997708168819 |  0.00022918311805294 | 0.000229183118051107
          0.000005 |   89.9997135211024 | 0.000286478897566605 | 0.000286478897563024
          0.000006 |   89.9996562253229 | 0.000343774677080557 | 0.000343774677074369
          0.000007 |   89.9995989295434 | 0.000401070456594852 | 0.000401070456585025
          0.000008 |   89.9995416337639 | 0.000458366236109548 |  0.00045836623609488
          0.000009 |   89.9994843379844 | 0.000515662015624702 | 0.000515662015603818
          0.000010 |   89.9994270422049 | 0.000572957795140373 | 0.000572957795111725
           0.99999 |  0.256234729158844 |     89.7437652708412 |       44.99971351967
          0.999991 |  0.243085587677338 |     89.7569144123227 |     44.9997421678319
          0.999992 |  0.229183270841464 |     89.7708167291585 |     44.9997708159652
          0.999993 |  0.214381301701661 |     89.7856186982983 |     44.9997994640698
          0.999994 |  0.198478501590361 |     89.8015214984096 |     44.9998281121458
          0.999995 |   0.18118523907065 |     89.8188147609294 |     44.9998567601931
          0.999996 |  0.162056990927388 |     89.8379430090726 |     44.9998854082118
          0.999997 |  0.140345459307862 |     89.8596545406921 |     44.9999140562018
          0.999998 |  0.114591578123233 |     89.8854084218768 |     44.9999427041632
          0.999999 | 0.0810284752076785 |     89.9189715247923 |     44.9999713520959
          1.000000 |                  0 |                   90 |                   45
(85 rows)
