Opened 7 years ago

Closed 6 years ago

document use of lambda for non-symbolic functions

Reported by: Owned by: rws major sage-6.4 documentation Ralf Stephan Karl-Dieter Crisman N/A 1172f62 (Commits) 1172f6253c3a4cd6b9d80b91657ef00a006b8f4c

Previous title "polar_plot crash with expressions containing non-symbolic functions".

Reported on sage-support:

```sage: polar_plot((1+cos(fibonacci(floor(alpha)))), (alpha, -3*pi/2,pi/2))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-d55fb7d2b898> in <module>()
----> 1 polar_plot((Integer(1)+cos(fibonacci(floor(alpha)))), (alpha, -Integer(3)*pi/Integer(2),pi/Integer(2)))

/home/ralf/sage/local/lib/python2.7/site-packages/sage/combinat/combinat.pyc in fibonacci(n, algorithm)
500         TypeError: no conversion of this rational to integer
501     """
--> 502     n = ZZ(n)
503     if algorithm == 'pari':
504         return ZZ(pari(n).fibonacci())

/home/ralf/sage/local/lib/python2.7/site-packages/sage/structure/parent.so in sage.structure.parent.Parent.__call__ (sage/structure/parent.c:8905)()

/home/ralf/sage/local/lib/python2.7/site-packages/sage/structure/coerce_maps.so in sage.structure.coerce_maps.NamedConvertMap._call_ (sage/structure/coerce_maps.c:5442)()

/home/ralf/sage/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression._integer_ (sage/symbolic/expression.cpp:6142)()

TypeError: unable to convert x (=floor(alpha)) to an integer
```

comment:1 Changed 7 years ago by rws

• Summary changed from polar_plot crash with expressions containing floor to polar_plot crash with expressions containing fibonacci

comment:2 Changed 7 years ago by rws

• Summary changed from polar_plot crash with expressions containing fibonacci to polar_plot crash with expressions containing floor

comment:3 Changed 7 years ago by rws

• Summary changed from polar_plot crash with expressions containing floor to polar_plot crash with expressions containing non-symbolic functions

comment:4 Changed 7 years ago by nbruin

Close as won't fix? `polar_plot` never gets its argument, since `fibonacci` isn't symbolic:

```sage: fibonacci(floor(tan((abs(alpha+pi/2)^0.22))))
TypeError: unable to convert x (=floor(tan(abs(1/2*pi + alpha)^0.220000000000000))) to an integer
```

Apart from hobbling sage by equipping every conceivable function in sage with a symbolic equivalent, we can't really do something about this (perhaps document somewhere where newbies will look?)

comment:5 Changed 7 years ago by kcrisman

Could be worth adding examples of how to use lambda functions for precisely this contingency in several place in the docs. Though see #8383 for some actual use cases (and how do other systems handle this?) suggesting to make symbolic versions of everything.

comment:6 Changed 7 years ago by rws

• Milestone changed from sage-6.3 to sage-duplicate/invalid/wontfix
• Status changed from new to needs_review

Thanks. I think it best to move the discussion to #8383 where some arguments have been weighed already.

comment:7 Changed 7 years ago by kcrisman

• Milestone changed from sage-duplicate/invalid/wontfix to sage-6.3

Sorry, I must not have made it clear that if we aren't going to fix the symbolic equivalents thing (which seems reasonable) then we should document how to do this with lambdas for someone who might want to do this plot (for instance) nonetheless.

comment:8 Changed 7 years ago by rws

• Component changed from symbolics to documentation
• Description modified (diff)
• Status changed from needs_review to needs_work
• Summary changed from polar_plot crash with expressions containing non-symbolic functions to document use of lambda for non-symbolic functions

comment:9 Changed 7 years ago by rws

• Branch set to u/rws/document_use_of_lambda_for_non_symbolic_functions

comment:10 Changed 7 years ago by rws

• Commit set to 1172f6253c3a4cd6b9d80b91657ef00a006b8f4c
• Status changed from needs_work to needs_review

I have added a note to the plot documentation. Where else do you think it's needed?

New commits:

 ​1172f62 `16459: add note in documentation`

comment:11 Changed 6 years ago by vbraun_spam

• Milestone changed from sage-6.3 to sage-6.4

comment:12 Changed 6 years ago by kcrisman

• Authors set to Ralf Stephan
• Reviewers set to Karl-Dieter Crisman
• Status changed from needs_review to positive_review

This is terse, but I think is a good start on this. Merges and looks nice in output.

comment:13 Changed 6 years ago by vbraun

• Branch changed from u/rws/document_use_of_lambda_for_non_symbolic_functions to 1172f6253c3a4cd6b9d80b91657ef00a006b8f4c
• Resolution set to fixed
• Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.