Re: [sage-edu] cube roots in Sage

2014-07-19 Thread Norbert Domes
Provided L (the list of roots) is always in ascending order we could do: return L[-1] But the main issue of my solution is: it is too slow and even worse it gulps so much memory that it fails For example: *nth_real_root_2(4,2000)* Traceback (click to the left of this block for traceback) ...

Re: [sage-edu] cube roots in Sage

2014-07-17 Thread Dan Drake
On Thu, 17 Jul 2014 at 10:29AM -0700, Martin Flashman wrote: > On naming the function: eventually a shorter name would be helpful if this > is to become a core real function: > perhaps r_rootn(x,n) or simply rootn(x,n). I would argue that the longer name is more helpful. With "real_nth_root" it'

Re: [sage-edu] cube roots in Sage

2014-07-17 Thread Martin Flashman
Norbert's solution is short but unfortunately for nth_real_root(4,2) gives a result of -2 instead of what the TC MITS expected result of 2. One slight modification handles that issue to give results that match these expectations- Unfortunately- this function doesn't seem to plot!???: def nth_r

Re: [sage-edu] cube roots in Sage

2014-07-14 Thread Norbert Domes
My suggestion for nth real root: def nth_real_root(a,n): p = x^n - a L = p.roots(ring=RR,multiplicities=False) if L: return L[0] # return L ? else: raise RuntimeError("no real root") -- You received this message because you are subscribed to the Google Gr

Re: [sage-edu] cube roots in Sage

2014-07-10 Thread gregory . bard1977
I think kcrisman was referring to Sage for Undergraduates, my book, perhaps?. That's what sparked this original conversation about the plot of the cuberoot. If people are curious, Sage for Undergraduates will be submitted any day now to the American Mathematical Society. It is long over due. Th

Re: [sage-edu] cube roots in Sage

2014-07-10 Thread gregory . bard1977
You are definitely correct about assert versus try/except. The assert is a debugging-stage tool, and once the code is fully debugged, some asserts will disappear and others will become try/catch, for the purpose of making a human-readable error message. I did not open a ticket. I wanted to wait

Re: [sage-edu] cube roots in Sage

2014-07-09 Thread David Smith
Does "you" mean me? As best I can recall, the answer is no. But it's never too late for our book -- even though it's "published" (and has been for 4 years), we're constantly making improvements, ranging from fixing typos to replacing interacts with prettier or more effective ones for the same

Re: [sage-edu] cube roots in Sage

2014-07-08 Thread kcrisman
Ah, I missed all this. Did you ever open a ticket (with this or Nils' or other code)? I guess it's too late for your book (well, the 1st print edition, on the internet revision means something different, as a recent article I read on lit crit was pointing out...) > def nth_real_root( x, n

Re: [sage-edu] cube roots in Sage

2014-06-24 Thread 'Gerald Smith' via sage-edu
A sneaky workaround that I have found works rather well when exponentials to a negative base appear in something you want to be a real valued function.   First factor out -1^n from your  -b^n expression: -b^n =  -1^n * b^n  and then let -1^n -=  cos(Pi*n) .  A bit of basic calculus will show tha

Re: [sage-edu] cube roots in Sage

2014-06-20 Thread David Joyner
On Fri, Jun 20, 2014 at 9:10 PM, Gregory Bard wrote: > (Note: I have a lot of cube-root related emails to reply to today. I > promise that I will get to everyone, eventually.) > Thanks Greg. I think the summary is that some sort of real nth root function is supported by developers (provided it is

Re: [sage-edu] cube roots in Sage

2014-06-20 Thread Gregory Bard
It seems that the consensus on both Sage-devel and Sage-edu is to go with some sort of nth_real_root function. I propose the following, which I have tested for evaluation, plotting, differentiation, and integration. Sadly, the derivative has a Dirac delta in it, which is ... perhaps unavoidable bec

Re: [sage-edu] cube roots in Sage

2014-06-20 Thread Gregory Bard
(Note: I have a lot of cube-root related emails to reply to today. I promise that I will get to everyone, eventually.) For Gerald Smith's point, I think we have to clarify between nth_real_root( x, n ) having domain R x Z+ and range R (which I think is okay) and the undesirable option of nth_real_

Re: [sage-edu] cube roots in Sage

2014-06-20 Thread Gregory Bard
(Note: I have a lot of cube-root related emails to reply to today. I promise that I will get to everyone, eventually.) The phenomenon which Michel Paul has spoken of is extremely interesting. The way I would address the perplexed (or perhaps, intrigued) student---provided that they know what compl

Re: [sage-edu] cube roots in Sage

2014-06-20 Thread michel paul
Alpha shows the domain of y = x^(1/3) to be non-negative. However, it shows the domain of y = cube root of x to be all reals. Most high school texts present

Re: [sage-edu] cube roots in Sage

2014-06-20 Thread 'Gerald Smith' via sage-edu
Guys, please keep in mind that exponentials of negative bases are not really functions.  They give a mix of real and multivalued complex results. You cannot treat  x^(1/3) as a synonym for cuberoot (x) if x,0. The latter is a well defined function and the former is not.  Perhaps this might be a

Re: [sage-edu] cube roots in Sage

2014-06-19 Thread Robert Bradshaw
On Thu, Jun 19, 2014 at 9:39 AM, David Smith wrote: > I could live with nthroot -- but is cuberoot (or curt or cbrt) so different > from sqrt? Cubic roots are much less common. They don't even have their own (unparameterized) symbol. I think some kind of a (real?) nth root function makes sense.

Re: [sage-edu] cube roots in Sage

2014-06-19 Thread David Smith
I could live with nthroot -- but is cuberoot (or curt or cbrt) so different from sqrt? Anyway, it would be nice to have functions that resemble ones students see routinely without generating error messages. I'm very much aware of the difficulties involved in reaching that goal, and I'll be pa

Re: [sage-edu] cube roots in Sage

2014-06-18 Thread kcrisman
Just to chime in, as someone who has dealt with this question a lot (though, perhaps ironically, never in a classroom situation): I would be very against a "cuberoot" function, but an "nthroot" function where it was really clear what input was allowed could fly. I appreciate Greg's rationale.

Re: [sage-edu] cube roots in Sage

2014-06-18 Thread David Smith
Oops, sorry. I forgot about the change that requires clicking "Submit" to change the interval. When you try to integrate x^(1/3) from -2 to 2, you get the error message "negative number cannot be raised to a fractional power" -- which of course is false for some fractional powers. On Wednesda

Re: [sage-edu] cube roots in Sage

2014-06-18 Thread David Smith
No. I just checked a definite integral interact in our calculus text. It works fine to integrate x^(1/3) from 0 to 2, but when asked to integrate from -2 to 2, it returns the answer from 0 to 2. It would be a great help to me to be able to tell students that cuberoot(x) is a legitimate functi

Re: [sage-edu] cube roots in Sage

2014-06-18 Thread William Stein
Is this only something that comes up for plotting? On Jun 18, 2014 4:11 AM, "David Joyner" wrote: > > On Wed, Jun 18, 2014 at 2:34 AM, wrote: > > This has been brought up many times before, but I'd like to bring up > > the possibility of adding two commands to Sage: cuberoot(x) and > > nthroot(

Re: [sage-edu] cube roots in Sage

2014-06-18 Thread David Joyner
On Wed, Jun 18, 2014 at 2:34 AM, wrote: > This has been brought up many times before, but I'd like to bring up > the possibility of adding two commands to Sage: cuberoot(x) and > nthroot(x, n) > Just to be clear, if you defined nthroot in the obvious way, the code would check for each evaluatio

[sage-edu] cube roots in Sage

2014-06-17 Thread gregory . bard1977
This has been brought up many times before, but I'd like to bring up the possibility of adding two commands to Sage: cuberoot(x) and nthroot(x, n) The reason is that currently plot( x^(1/3), -5, 5) only shows values for x>0, and not for x<0. The current work-around recommended is plot(sign(x)*ab