Opened 10 years ago

Closed 7 years ago

# Add another cube root plotting example to plot doc

Reported by: Owned by: kcrisman mvngu minor sage-6.5 documentation was, jason, rbeezer Karl-Dieter Crisman, Gregory Bard Nathann Cohen N/A 3fe2da9

### Description

Gregory Bard of the University of Wisconsin, Stout has the following solution for the always-vexing cube-root plotting issue.

```def cuberoot(x):
return sign(x)*((x*sign(x))^(1/3))

plot( cuberoot(x), -4, 4)
```

Probably just adding `plot(sign(x)*(x*sign(x))^(1/3))` or something to the plot doc (search for 'cube') as another example would be sufficient for now. I don't know whether we would want to add a whole new function, since we'd then need one for every odd integer root function... or? Maybe that would be ok, `real_nth_root()`...

Putting under documentation component, feel free to change if graphics is more appropriate.

### comment:1 follow-up: ↓ 3 Changed 10 years ago by jason

Can I suggest `plot(sign(x)*(x*sign(x))^(1/3), (x,-4,4))` as the code to add?

### comment:2 Changed 10 years ago by jason

I guess I've always used: `plot(lambda x: RDF(x).nth_root(3), (x, -4, 4))`

### comment:3 in reply to: ↑ 1 ; follow-up: ↓ 4 Changed 10 years ago by kcrisman

Can I suggest `plot(sign(x)*(x*sign(x))^(1/3), (x,-4,4))` as the code to add?

That's what I attempted to suggest above.

The point of adding this example was that a number of users (including the originator of this example) thought that students wouldn't know what lambda functions were - not to mention the dot notation. I guess I view them as equally complicated, though the `sign` solution has the advantage that most of use probably implicitly use this when discussing the absolute value function as a piecewise linear function and not just "make it positive" early in any course where cube roots would be plotted.

### comment:4 in reply to: ↑ 3 ; follow-up: ↓ 5 Changed 10 years ago by jason

Can I suggest `plot(sign(x)*(x*sign(x))^(1/3), (x,-4,4))` as the code to add?

That's what I attempted to suggest above.

Right---I just added the `(x,-4,4)` notation for the range, since we need to specify the variable because it is a symbolic expression instead of a callable function :).

The point of adding this example was that a number of users (including the originator of this example) thought that students wouldn't know what lambda functions were - not to mention the dot notation. I guess I view them as equally complicated, though the `sign` solution has the advantage that most of use probably implicitly use this when discussing the absolute value function as a piecewise linear function and not just "make it positive" early in any course where cube roots would be plotted.

Yeah, adding both examples wouldn't be a bad idea. I thought the nth_root example was already there...

### comment:5 in reply to: ↑ 4 Changed 10 years ago by kcrisman

Can I suggest `plot(sign(x)*(x*sign(x))^(1/3), (x,-4,4))` as the code to add?

That's what I attempted to suggest above.

Right---I just added the `(x,-4,4)` notation for the range, since we need to specify the variable because it is a symbolic expression instead of a callable function :).

Naturally, I was just being terse.

The point of adding this example was that a number of users (including the originator of this example) thought that students wouldn't know what lambda functions were - not to mention the dot notation. I guess I view them as equally complicated, though the `sign` solution has the advantage that most of use probably implicitly use this when discussing the absolute value function as a piecewise linear function and not just "make it positive" early in any course where cube roots would be plotted.

Yeah, adding both examples wouldn't be a bad idea. I thought the nth_root example was already there...

I meant adding this example; you are right that the other one is already there. Ideally, they'd be together.

Ideally, we'd also have time to create some nice document that answers all such questions, perhaps cribbed from our PREP documents... which we should really finally make ready for the Sage documentation this summer. Not that you don't have other things to do.

Anyway, any thoughts on adding some such function (with a name making it clear it's really just for this purpose) globally for plotting/pedagogical purposes only? This has been discussed before without resolution, just raising the question again.

### comment:6 Changed 10 years ago by jason

We need more than you and me to address the question of adding a top-level function :). Maybe a post to sage-devel (which will probably just have a few answers, but then at least people can't say they weren't warned).

### comment:7 Changed 10 years ago by benjaminfjones

Greg Bard and I are colleagues. I definitely support adding this example to the plot documentation next to the lambda function example. I don't think there's any need for a top-level function, though. I think it's better to acknowledge the subtlety rather than sweep it under the rug.

### comment:8 Changed 10 years ago by jason

After thinking about it, +1 to benjaminfjones' comment.

### comment:9 Changed 9 years ago by jdemeyer

• Milestone changed from sage-5.11 to sage-5.12

### comment:10 Changed 8 years ago by vbraun_spam

• Milestone changed from sage-6.1 to sage-6.2

### comment:11 Changed 8 years ago by vbraun_spam

• Milestone changed from sage-6.2 to sage-6.3

### comment:12 Changed 8 years ago by vbraun_spam

• Milestone changed from sage-6.3 to sage-6.4

### comment:13 Changed 8 years ago by kcrisman

Huh, this seems to have gotten lost. There was recently yet another discussion about this somewhere, but I forget where.

### comment:14 Changed 8 years ago by kcrisman

• Authors set to Karl-Dieter Crisman, Gregory Bard
• Branch set to u/kcrisman/cuberootfaq
• Commit set to 3fe2da9b9b7452542ffefa67ce857c58420d9d56
• Status changed from new to needs_review

Okay, adding an example and a slight reorganization of that section (there are already two examples! but starts with lambda, yuck) and also adding to FAQ, since this is a very FAQ.

New commits:

 ​3fe2da9 `Added even more plot cube root info, incl. to FAQ`

### comment:15 Changed 7 years ago by ncohen

• Reviewers set to Nathann Cohen
• Status changed from needs_review to positive_review

Good to go !

Nathann

### comment:16 Changed 7 years ago by vbraun

• Branch changed from u/kcrisman/cuberootfaq to 3fe2da9b9b7452542ffefa67ce857c58420d9d56
• Resolution set to fixed
• Status changed from positive_review to closed

### comment:17 Changed 7 years ago by kcrisman

• Commit 3fe2da9b9b7452542ffefa67ce857c58420d9d56 deleted
• Milestone changed from sage-6.4 to sage-6.5
Note: See TracTickets for help on using tickets.