2 root - root of a number
10 eps nonzero real, defaults to epsilon()
15 For real x and positive integer n, n being odd if x is negative,
16 root(x,n,eps) returns a multiple of eps differing from the
17 real n-th root of x (nonnegative if x is positive) by less than
18 0.75 eps, usually by less than 0.5 eps. If the n-th root of
19 x is a multiple of eps, it will be returned exactly.
21 For complex x and positive integer n, or negative x with positive even
22 n, root(x, n, eps) returns a real or complex numbers whose real
23 and imaginary parts are multiples of eps differing from the real
24 and imaginary parts of the principal n-th root of x by less than
25 0.75 eps, usually by less than 0.5 eps.
27 For negative x and odd n, the principal n-th root of x may be
28 obtained by using power(x, 1/n, eps).
31 ; print root(7, 4, 1e-5), root(7, 4, 1e-10), root(7, 4, 1e-15)
32 1.62658 1.6265765617 1.626576561697786
34 ; print root(1+3i, 3, 1e-5), root(1 + 3i, 3, 1e-10)
35 1.34241+.59361i 1.3424077452+.5936127825i
37 ; print root(-8, 3, 1e-5), root(-8, 34, 1e-5)
38 -2 ~1.05853505050032399594+~.09807874962631613016i
40 ; print root(1i, 100, 1e-20)
41 .99987663248166059864+.01570731731182067575i
48 void rootvalue(VALUE *x, VALUE *n, VALUE *eps, VALUE *result)
49 NUMBER *qroot(NUMBER *x, NUMBER *n, NUMBER *eps)
50 COMPLEX *c_root(COMPLEX *x, NUMBER *n, NUMBER *eps)
55 ## Copyright (C) 1999 Landon Curt Noll
57 ## Calc is open software; you can redistribute it and/or modify it under
58 ## the terms of the version 2.1 of the GNU Lesser General Public License
59 ## as published by the Free Software Foundation.
61 ## Calc is distributed in the hope that it will be useful, but WITHOUT
62 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
63 ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
64 ## Public License for more details.
66 ## A copy of version 2.1 of the GNU Lesser General Public License is
67 ## distributed with calc under the filename COPYING-LGPL. You should have
68 ## received a copy with calc; if not, write to Free Software Foundation, Inc.
69 ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
71 ## @(#) $Revision: 30.1 $
72 ## @(#) $Id: root,v 30.1 2007/03/16 11:10:42 chongo Exp $
73 ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/root,v $
75 ## Under source code control: 1995/10/25 04:03:46
76 ## File existed as early as: 1995
78 ## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
79 ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/