@@ -55,18 +55,22 @@ template <> struct SqrtConfig<unsigned fract> {
55
55
// Linear approximation for the initial values, with errors bounded by:
56
56
// max(1.5 * 2^-11, eps)
57
57
// Generated with Sollya:
58
- // > for i from 4 to 15 do {
58
+ // > for i from 4 to 14 do {
59
59
// P = fpminimax(sqrt(x), 1, [|16, 16|], [i * 2^-4, (i + 1)*2^-4],
60
60
// fixed, absolute);
61
61
// print("{", coeff(P, 1), "ur,", coeff(P, 0), "ur},");
62
62
// };
63
+ // For the last interval [15/16, 1), we choose the linear function Q such that
64
+ // Q(1) = 1 and Q(15/16) = P(15/16),
65
+ // where P is the polynomial generated by Sollya above for [14/16, 15/16].
66
+ // This is to prevent overflow in the last interval [15/16, 1).
63
67
static constexpr Type FIRST_APPROX[12 ][2 ] = {
64
68
{0x1 .e378p -1ur, 0x1 .0ebp-2ur}, {0x1 .b512p -1ur, 0x1 .2b94p-2ur},
65
69
{0x1 .91fp-1ur, 0x1 .45dcp-2ur}, {0x1 .7622p-1ur, 0x1 .5e24p-2ur},
66
70
{0x1 .5f5ap-1ur, 0x1 .74e4p-2ur}, {0x1 .4c58p-1ur, 0x1 .8a4p-2ur},
67
71
{0x1 .3c1ep-1ur, 0x1 .9e84p-2ur}, {0x1 .2e0cp-1ur, 0x1 .b1d8p -2ur},
68
72
{0x1 .21aap-1ur, 0x1 .c468p -2ur}, {0x1 .16bap-1ur, 0x1 .d62cp -2ur},
69
- {0x1 .0cfp-1ur, 0x1 .e74cp -2ur}, {0x1 .0418p -1ur, 0x1 .f7ep -2ur},
73
+ {0x1 .0cfp-1ur, 0x1 .e74cp -2ur}, {0x1 .039p -1ur, 0x1 .f8ep -2ur},
70
74
};
71
75
};
72
76
@@ -77,11 +81,15 @@ template <> struct SqrtConfig<unsigned long fract> {
77
81
// Linear approximation for the initial values, with errors bounded by:
78
82
// max(1.5 * 2^-11, eps)
79
83
// Generated with Sollya:
80
- // > for i from 4 to 15 do {
84
+ // > for i from 4 to 14 do {
81
85
// P = fpminimax(sqrt(x), 1, [|32, 32|], [i * 2^-4, (i + 1)*2^-4],
82
86
// fixed, absolute);
83
87
// print("{", coeff(P, 1), "ulr,", coeff(P, 0), "ulr},");
84
88
// };
89
+ // For the last interval [15/16, 1), we choose the linear function Q such that
90
+ // Q(1) = 1 and Q(15/16) = P(15/16),
91
+ // where P is the polynomial generated by Sollya above for [14/16, 15/16].
92
+ // This is to prevent overflow in the last interval [15/16, 1).
85
93
static constexpr Type FIRST_APPROX[12 ][2 ] = {
86
94
{0x1 .e3779b98p -1ulr, 0x1 .0eaff788p-2ulr},
87
95
{0x1 .b5167872p -1ulr, 0x1 .2b908ad4p-2ulr},
@@ -94,7 +102,7 @@ template <> struct SqrtConfig<unsigned long fract> {
94
102
{0x1 .21b05c0ap-1ulr, 0x1 .c45e023p -2ulr},
95
103
{0x1 .16becd02p-1ulr, 0x1 .d624031p -2ulr},
96
104
{0x1 .0cf49fep-1ulr, 0x1 .e743b844p -2ulr},
97
- {0x1 .04214e9cp -1ulr, 0x1 .f7ce2c3cp -2ulr},
105
+ {0x1 .038cdfcp -1ulr, 0x1 .f8e6408p -2ulr},
98
106
};
99
107
};
100
108
0 commit comments