1 /* Compute cubic root of double value.
2 Copyright (C) 1997 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Dirk Alboth <dirka@uni-paderborn.de> and
5 Ulrich Drepper <drepper@cygnus.com>, 1997.
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public License as
9 published by the Free Software Foundation; either version 2 of the
10 License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public
18 License along with the GNU C Library; see the file COPYING.LIB. If not,
19 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
23 #include "math_private.h"
26 #define CBRT2 1.2599210498948731648 /* 2^(1/3) */
27 #define SQR_CBRT2 1.5874010519681994748 /* 2^(2/3) */
29 /* We don't use long double values here since U need not be computed
30 with full precision. */
31 static const double factor
[5] =
42 __cbrtl (long double x
)
44 long double xm
, ym
, u
, t2
;
47 /* Reduce X. XM now is an range 1.0 to 0.5. */
48 xm
= __frexpl (fabs (x
), &xe
);
50 /* If X is not finite or is null return it (with raising exceptions
52 if (xe
== 0 && (x
== 0.0 || isnanl (x
) || isinfl (x
)))
55 u
= (0.338058687610520237
56 + (1.67595307700780102
57 + (-2.82414939754975962
58 + (4.09559907378707839 +
60 + (2.65298938441952296 +
61 (-0.988553671195413709
62 + 0.161617097923756032 * xm
)
72 ym
= u
* (t2
+ 2.0 * xm
) / (2.0 * t2
+ xm
) * factor
[2 + xe
% 3];
74 return __ldexpl (x
> 0.0 ? ym
: -ym
, xe
/ 3);
76 weak_alias (__cbrtl
, cbrtl
)