Documentation for routine roots
assembled from the following pages:
Class: Numeric §
From Numeric
(Numeric) method roots §
multi method roots(Numeric: Int --> Positional)
Returns a list of the $n
complex roots, which evaluate to the original number when raised to the $n
th power.
Class: Cool §
From Cool
(Cool) routine roots §
Defined as:
multi sub roots(Numeric(Cool) , Int(Cool) )multi method roots(Int(Cool) )
Coerces the first argument (and in method form, the invocant) to Numeric and the second ($n
) to Int, and produces a list of $n
Complex $n
-roots, which means numbers that, raised to the $n
th power, approximately produce the original number.
For example
my = 16;my = .roots(4);say ; for -> # OUTPUT:«2+0i 1.22464679914735e-16+2i -2+2.44929359829471e-16i -3.67394039744206e-16-2i» # OUTPUT:«1.77635683940025e-15» # OUTPUT:«4.30267170434156e-15» # OUTPUT:«8.03651692704705e-15» # OUTPUT:«1.04441561648202e-14»