Lines Matching +full:y +full:-

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2012 Stephen Montgomery-Smith <stephen@FreeBSD.ORG>
33 * Mathematical Software, Volume 23 Issue 3, 1997, Pages 299-335,
60 FOUR_SQRT_MIN = 0x1p-61,
62 m_e = 2.7182818285e0, /* 0xadf854.0p-22 */
63 m_ln2 = 6.9314718056e-1, /* 0xb17218.0p-24 */
64 pio2_hi = 1.5707962513e0, /* 0xc90fda.0p-23 */
66 SQRT_3_EPSILON = 5.9801995673e-4, /* 0x9cc471.0p-34 */
67 SQRT_6_EPSILON = 8.4572793338e-4, /* 0xddb3d7.0p-34 */
68 SQRT_MIN = 0x1p-63;
71 pio2_lo = 7.5497899549e-8, /* 0xa22169.0p-47 */
72 tiny = 0x1p-100;
80 return ((hypot_a_b - b) / 2); in f()
87 do_hard_work(float x, float y, float *rx, int *B_is_usable, float *B, in do_hard_work() argument
93 R = hypotf(x, y + 1); in do_hard_work()
94 S = hypotf(x, y - 1); in do_hard_work()
101 if (y == 1 && x < FLT_EPSILON * FLT_EPSILON / 128) { in do_hard_work()
103 } else if (x >= FLT_EPSILON * fabsf(y - 1)) { in do_hard_work()
104 Am1 = f(x, 1 + y, R) + f(x, 1 - y, S); in do_hard_work()
106 } else if (y < 1) { in do_hard_work()
107 *rx = x / sqrtf((1 - y) * (1 + y)); in do_hard_work()
109 *rx = log1pf((y - 1) + sqrtf((y - 1) * (y + 1))); in do_hard_work()
112 *rx = logf(A + sqrtf(A * A - 1)); in do_hard_work()
115 *new_y = y; in do_hard_work()
117 if (y < FOUR_SQRT_MIN) { in do_hard_work()
120 *new_y = y * (2 / FLT_EPSILON); in do_hard_work()
124 *B = y / A; in do_hard_work()
129 if (y == 1 && x < FLT_EPSILON / 128) { in do_hard_work()
130 *sqrt_A2my2 = sqrtf(x) * sqrtf((A + y) / 2); in do_hard_work()
131 } else if (x >= FLT_EPSILON * fabsf(y - 1)) { in do_hard_work()
132 Amy = f(x, y + 1, R) + f(x, y - 1, S); in do_hard_work()
133 *sqrt_A2my2 = sqrtf(Amy * (A + y)); in do_hard_work()
134 } else if (y > 1) { in do_hard_work()
135 *sqrt_A2my2 = x * (4 / FLT_EPSILON / FLT_EPSILON) * y / in do_hard_work()
136 sqrtf((y + 1) * (y - 1)); in do_hard_work()
137 *new_y = y * (4 / FLT_EPSILON / FLT_EPSILON); in do_hard_work()
139 *sqrt_A2my2 = sqrtf((1 - y) * (1 + y)); in do_hard_work()
147 float x, y, ax, ay, rx, ry, B, sqrt_A2my2, new_y; in casinhf() local
152 y = cimagf(z); in casinhf()
154 ay = fabsf(y); in casinhf()
156 if (isnan(x) || isnan(y)) { in casinhf()
158 return (CMPLXF(x, y + y)); in casinhf()
159 if (isinf(y)) in casinhf()
160 return (CMPLXF(y, x + x)); in casinhf()
161 if (y == 0) in casinhf()
162 return (CMPLXF(x + x, y)); in casinhf()
163 return (CMPLXF(nan_mix(x, y), nan_mix(x, y))); in casinhf()
170 w = clog_for_large_values(-z) + m_ln2; in casinhf()
172 copysignf(cimagf(w), y))); in casinhf()
175 if (x == 0 && y == 0) in casinhf()
188 return (CMPLXF(copysignf(rx, x), copysignf(ry, y))); in casinhf()
202 float x, y, ax, ay, rx, ry, B, sqrt_A2mx2, new_x; in cacosf() local
208 y = cimagf(z); in cacosf()
210 sy = signbit(y); in cacosf()
212 ay = fabsf(y); in cacosf()
214 if (isnan(x) || isnan(y)) { in cacosf()
216 return (CMPLXF(y + y, -INFINITY)); in cacosf()
217 if (isinf(y)) in cacosf()
218 return (CMPLXF(x + x, -y)); in cacosf()
220 return (CMPLXF(pio2_hi + pio2_lo, y + y)); in cacosf()
221 return (CMPLXF(nan_mix(x, y), nan_mix(x, y))); in cacosf()
229 ry = -ry; in cacosf()
233 if (x == 1 && y == 0) in cacosf()
234 return (CMPLXF(0, -y)); in cacosf()
239 return (CMPLXF(pio2_hi - (x - pio2_lo), -y)); in cacosf()
246 rx = acosf(-B); in cacosf()
251 rx = atan2f(sqrt_A2mx2, -new_x); in cacosf()
254 ry = -ry; in cacosf()
279 float x, y; in clog_for_large_values() local
283 y = cimagf(z); in clog_for_large_values()
285 ay = fabsf(y); in clog_for_large_values()
293 return (CMPLXF(logf(hypotf(x / m_e, y / m_e)) + 1, in clog_for_large_values()
294 atan2f(y, x))); in clog_for_large_values()
297 return (CMPLXF(logf(hypotf(x, y)), atan2f(y, x))); in clog_for_large_values()
299 return (CMPLXF(logf(ax * ax + ay * ay) / 2, atan2f(y, x))); in clog_for_large_values()
303 sum_squares(float x, float y) in sum_squares() argument
306 if (y < SQRT_MIN) in sum_squares()
309 return (x * x + y * y); in sum_squares()
313 real_part_reciprocal(float x, float y) in real_part_reciprocal() argument
321 GET_FLOAT_WORD(hy, y); in real_part_reciprocal()
323 #define BIAS (FLT_MAX_EXP - 1) in real_part_reciprocal()
325 if (ix - iy >= CUTOFF << 23 || isinf(x)) in real_part_reciprocal()
327 if (iy - ix >= CUTOFF << 23) in real_part_reciprocal()
328 return (x / y / y); in real_part_reciprocal()
329 if (ix <= (BIAS + FLT_MAX_EXP / 2 - CUTOFF) << 23) in real_part_reciprocal()
330 return (x / (x * x + y * y)); in real_part_reciprocal()
331 SET_FLOAT_WORD(scale, 0x7f800000 - ix); in real_part_reciprocal()
333 y *= scale; in real_part_reciprocal()
334 return (x / (x * x + y * y) * scale); in real_part_reciprocal()
340 float x, y, ax, ay, rx, ry; in catanhf() local
343 y = cimagf(z); in catanhf()
345 ay = fabsf(y); in catanhf()
347 if (y == 0 && ax <= 1) in catanhf()
348 return (CMPLXF(atanhf(x), y)); in catanhf()
351 return (CMPLXF(x, atanf(y))); in catanhf()
353 if (isnan(x) || isnan(y)) { in catanhf()
355 return (CMPLXF(copysignf(0, x), y + y)); in catanhf()
356 if (isinf(y)) in catanhf()
358 copysignf(pio2_hi + pio2_lo, y))); in catanhf()
359 return (CMPLXF(nan_mix(x, y), nan_mix(x, y))); in catanhf()
363 return (CMPLXF(real_part_reciprocal(x, y), in catanhf()
364 copysignf(pio2_hi + pio2_lo, y))); in catanhf()
372 rx = (m_ln2 - logf(ay)) / 2; in catanhf()
374 rx = log1pf(4 * ax / sum_squares(ax - 1, ay)) / 4; in catanhf()
377 ry = atan2f(2, -ay) / 2; in catanhf()
379 ry = atan2f(2 * ay, (1 - ax) * (1 + ax)) / 2; in catanhf()
381 ry = atan2f(2 * ay, (1 - ax) * (1 + ax) - ay * ay) / 2; in catanhf()
383 return (CMPLXF(copysignf(rx, x), copysignf(ry, y))); in catanhf()