|
84 | 84 | end |
85 | 85 | end |
86 | 86 |
|
| 87 | +# Temme expansions for ind=1 (iop==2) and the ind=2 wide band (iop==3): reference |
| 88 | +# values from mpmath at 80+ digits (DLMF 8.7.1 series and 8.9.2 continued fraction). |
| 89 | +@testset "incomplete gamma ratios: Temme iop 2/3 expansions" begin |
| 90 | + @testset "ind=1 iop=2: a=$a, x=$x" for (a, x, p, q) in ( |
| 91 | + (14.0, 13.911135637064119, 0.5261046500921642, 0.4738953499078358), |
| 92 | + (14.0, 14.088864362935881, 0.5449404484556186, 0.4550595515443813), |
| 93 | + (100.0, 99.7625, 0.5038214442269839, 0.4961785557730161), |
| 94 | + (100.0, 100.2375, 0.522753673458071, 0.477246326541929), |
| 95 | + (1000.0, 999.24895905571, 0.4947284864885412, 0.5052715135114588), |
| 96 | + (1000.0, 1000.7510409442899, 0.5136748881127599, 0.4863251118872402), |
| 97 | + (10000.0, 9997.625, 0.4918547737457385, 0.5081452262542615), |
| 98 | + (10000.0, 10002.374999999998, 0.5108025931978544, 0.48919740680214563), |
| 99 | + (10000000.0, 9999924.895905571, 0.4905680282181972, 0.5094319717818028), |
| 100 | + (10000000.0, 10000075.104094429, 0.5095160050557511, 0.4904839949442488), |
| 101 | + (14.0, 13.906552106765321, 0.525615807496999, 0.474384192503001), |
| 102 | + ) |
| 103 | + @test gamma_inc(a, x, 1)[1] ≈ p rtol=5e-7 |
| 104 | + @test gamma_inc(a, x, 1)[2] ≈ q rtol=5e-7 |
| 105 | + end |
| 106 | + @testset "ind=2 wide band: a=$a, x=$x" for (a, x, p, q) in ( |
| 107 | + (10.0, 6.5, 0.12261595071018043, 0.8773840492898196), |
| 108 | + (10.0, 13.5, 0.8647360050511872, 0.1352639949488128), |
| 109 | + (25.0, 16.25, 0.02613839150563149, 0.9738616084943685), |
| 110 | + (25.0, 33.75, 0.9499593482838966, 0.05004065171610339), |
| 111 | + (100.0, 65.0, 3.372775722939482e-05, 0.9999662722427706), |
| 112 | + (100.0, 135.0, 0.999292148107214, 0.0007078518927860074), |
| 113 | + (1000.0, 650.0, 2.957759012559303e-37, 1.0), |
| 114 | + (1000.0, 1350.0, 1.0, 7.635408516228592e-24), |
| 115 | + ) |
| 116 | + @test gamma_inc(a, x, 2)[1] ≈ p rtol=5e-4 |
| 117 | + @test gamma_inc(a, x, 2)[2] ≈ q rtol=5e-4 |
| 118 | + end |
| 119 | + @testset "ind=2 narrow band: a=$a, x=$x" for (a, x, p, q) in ( |
| 120 | + (10.0, 9.778640563788214, 0.5140881193058611, 0.485911880694139), |
| 121 | + (10.0, 10.221359436211785, 0.5694405131522309, 0.43055948684776907), |
| 122 | + (100000.0, 99977.86405637882, 0.47251429019620883, 0.5274857098037912), |
| 123 | + (100000.0, 100022.13594362116, 0.5283205849613148, 0.4716794150386851), |
| 124 | + ) |
| 125 | + @test gamma_inc(a, x, 2)[1] ≈ p rtol=5e-4 |
| 126 | + @test gamma_inc(a, x, 2)[2] ≈ q rtol=5e-4 |
| 127 | + end |
| 128 | + @testset "ind=0 unchanged: a=$a, x=$x" for (a, x, p, q) in ( |
| 129 | + (14.0, 13.911135637064119, 0.5261046500921642, 0.4738953499078358), |
| 130 | + (14.0, 14.088864362935881, 0.5449404484556186, 0.4550595515443813), |
| 131 | + (100.0, 99.7625, 0.5038214442269839, 0.4961785557730161), |
| 132 | + (100.0, 100.2375, 0.522753673458071, 0.477246326541929), |
| 133 | + (1000.0, 999.24895905571, 0.4947284864885412, 0.5052715135114588), |
| 134 | + (1000.0, 1000.7510409442899, 0.5136748881127599, 0.4863251118872402), |
| 135 | + (10000.0, 9997.625, 0.4918547737457385, 0.5081452262542615), |
| 136 | + (10000.0, 10002.374999999998, 0.5108025931978544, 0.48919740680214563), |
| 137 | + (10000000.0, 9999924.895905571, 0.4905680282181972, 0.5094319717818028), |
| 138 | + (10000000.0, 10000075.104094429, 0.5095160050557511, 0.4904839949442488), |
| 139 | + (14.0, 13.906552106765321, 0.525615807496999, 0.474384192503001), |
| 140 | + ) |
| 141 | + @test gamma_inc(a, x)[1] ≈ p rtol=1e-12 |
| 142 | + @test gamma_inc(a, x)[2] ≈ q rtol=1e-12 |
| 143 | + end |
| 144 | +end |
| 145 | + |
87 | 146 | @testset "inverse of incomplete gamma ratios" begin |
88 | 147 | #Compared with Scipy.special.gammaincinv |
89 | 148 | @test gamma_inc_inv(1.0,0.5,0.5) ≈ 0.69314718055994529 |
|
0 commit comments