Discussion:
[sage-support] nth root
Timothy Clemans
2007-02-09 06:59:47 UTC
Permalink
Does SAGE support finding the nth root of something?
The cube root of 27 is 3, 8 is 2, 64 is 4

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-***@googlegroups.com
To unsubscribe from this group, send email to sage-support-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---
David Joyner
2007-02-09 12:37:03 UTC
Permalink
Post by Timothy Clemans
Does SAGE support finding the nth root of something?
The cube root of 27 is 3, 8 is 2, 64 is 4
One way is
ZZ(gap.eval("RootInt( 64, 3 )"))
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-***@googlegroups.com
To unsubscribe from this group, send email to sage-support-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---
Dirk Laurie
2007-02-09 12:10:46 UTC
Permalink
Post by Timothy Clemans
Post by Timothy Clemans
Does SAGE support finding the nth root of something?
The cube root of 27 is 3, 8 is 2, 64 is 4
One way is
ZZ(gap.eval("RootInt( 64, 3 )"))
Or:
(x^n-a).roots()[0][0]

Dirk

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-***@googlegroups.com
To unsubscribe from this group, send email to sage-support-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---
Alec Mihailovs
2007-02-09 17:28:50 UTC
Permalink
----- Original Message -----
Post by Dirk Laurie
Post by Timothy Clemans
Post by Timothy Clemans
Does SAGE support finding the nth root of something?
The cube root of 27 is 3, 8 is 2, 64 is 4
One way is
ZZ(gap.eval("RootInt( 64, 3 )"))
(x^n-a).roots()[0][0]
Or
{{{
sage: exp(log(64)/3)
4.0
}}}

Alec


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-***@googlegroups.com
To unsubscribe from this group, send email to sage-support-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---
Dirk Laurie
2007-02-12 07:02:12 UTC
Permalink
Post by Alec Mihailovs
----- Original Message -----
Post by Dirk Laurie
Post by Timothy Clemans
Post by Timothy Clemans
Does SAGE support finding the nth root of something?
The cube root of 27 is 3, 8 is 2, 64 is 4
One way is
ZZ(gap.eval("RootInt( 64, 3 )"))
(x^n-a).roots()[0][0]
Or
{{{
sage: exp(log(64)/3)
4.0
}}}
Well, that works for the cube root of 64. But note it's 4.0, not 4.
This exposes one to roundoff errors, which the other two methods
avoid.

sage: a=2^54
sage: b=(a-1)^3
sage: exp(log(b)/3)
_3 = 18014398509482004
sage: (x^3-b).roots()[0][0]
_4 = 18014398509481983
sage: a-1
_5 = 18014398509481983

Dirk



--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-***@googlegroups.com
To unsubscribe from this group, send email to sage-support-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---
Alec Mihailovs
2007-02-12 15:41:56 UTC
Permalink
----- Original Message -----
Post by Dirk Laurie
Post by Alec Mihailovs
{{{
sage: exp(log(64)/3)
4.0
}}}
Well, that works for the cube root of 64. But note it's 4.0, not 4.
This exposes one to roundoff errors, which the other two methods
avoid.
Well, that can be avoided by increasing the number of digits. Anyway, the
winner is 64.nth_root(3) suggested by Didier Deshommes in another thread.

I'd like to make a suggestion to add th_root method to all domains where
nth_root is implemented, working as 3.th_root(64) in this example, with
aliases st_root, nd_root and rd_root, so that it could be executed as
3.rd_root(64) that looks more natural to me than 64.nth_root(3).

Alec



--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-***@googlegroups.com
To unsubscribe from this group, send email to sage-support-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---
Timothy Clemans
2007-02-12 15:46:54 UTC
Permalink
radical(n,body)
Post by Alec Mihailovs
----- Original Message -----
Post by Dirk Laurie
Post by Alec Mihailovs
{{{
sage: exp(log(64)/3)
4.0
}}}
Well, that works for the cube root of 64. But note it's 4.0, not 4.
This exposes one to roundoff errors, which the other two methods
avoid.
Well, that can be avoided by increasing the number of digits. Anyway, the
winner is 64.nth_root(3) suggested by Didier Deshommes in another thread.
I'd like to make a suggestion to add th_root method to all domains where
nth_root is implemented, working as 3.th_root(64) in this example, with
aliases st_root, nd_root and rd_root, so that it could be executed as
3.rd_root(64) that looks more natural to me than 64.nth_root(3).
Alec
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-***@googlegroups.com
To unsubscribe from this group, send email to sage-support-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---
David Kohel
2007-02-13 05:22:52 UTC
Permalink
For integers, Pari also has an ispower function. I think that
it is useful to have an n.is_power(k) member function
for integers (or more general for ring elements which admit
unique factorization of polynomials), and prefer the syntax
n.root(k) rather than n.nth_root(k)

--David

P.S. Back in 1998, when some of my elliptic curve functions
were incorporated into Magma, I naively introduced, or accepted,
the syntax nTorsionSubgroup, after which mTorsionSubgroup, and
pTorsionSubgroup were introduced to cover all of the "natural"
spellings that users were missing. It took years to drop the
nonsensical leading letters and settle on TorsionSubgroup(E,p)
rather than the Trinity of [nmp]TorsionSubgroup(E,p).



--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-***@googlegroups.com
To unsubscribe from this group, send email to sage-support-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---

Loading...