Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when evaluating symbolic expression involving cotangent of a complex number #29409

Closed
DaveWitteMorris opened this issue Mar 26, 2020 · 14 comments

Comments

@DaveWitteMorris
Copy link
Member

This issue is split off from #29400. The command cot(1 + I).n() gives a TypeError:

sage: cot(1 + I).n()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-8ad83d3021de> in <module>()
----> 1 cot(Integer(1) + I).n()

    [snip]

/Users/dmorris/Documents/misc/Programs/sage3/local/lib/python3.7/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.numerical_approx (build/cythonized/sage/symbolic/expression.cpp:34715)()
   6054             res = x.pyobject()
   6055         else:
-> 6056             raise TypeError("cannot evaluate symbolic expression numerically")
   6057 
   6058         # Important -- the  we get might not be a valid output for numerical_approx in

TypeError: cannot evaluate symbolic expression numerically

There is no such error for sin, cos, tan, sec, or csc.

I believe this can be fixed by renaming the cotan method of the ComplexNumber class to cot, and I will upload a PR soon.

Component: symbolics

Keywords: cotangent, complex

Author: Dave Morris

Branch/Commit: b941d30

Reviewer: Kwankyu Lee

Issue created by migration from https://trac.sagemath.org/ticket/29409

@DaveWitteMorris
Copy link
Member Author

Branch: public/29409

@DaveWitteMorris
Copy link
Member Author

comment:2

I changed the name of the cotan method of the ComplexNumber class to cot. This eliminates the error:

sage: cot(1 + I).n()
0.217621561854403 - 0.868014142895925*I

For consistency, I made the same change to the class MPComplexNumber, which I think is the only other occurrence of a cotan function in the sage source. To preserve backwards compatibility, I added cotan as an alias for each of these methods.


New commits:

9b59968change cotan to tan

@DaveWitteMorris
Copy link
Member Author

Commit: 9b59968

@DaveWitteMorris
Copy link
Member Author

Author: Dave Morris

@seblabbe
Copy link
Contributor

comment:3

Do we want to deprecate cotan? If so there is deprecated_function_alias that you may use. You will find example by doing search_src('deprecated_function_alias').

from sage.misc.superseded import deprecated_function_alias

@DaveWitteMorris
Copy link
Member Author

comment:4

Yes, we should deprecate cotan. Thanks for the suggestion. I made a new ticket (#29412) for this, because cotangent is such a well known function that I don't feel comfortable making a possibly significant change to its behavior without announcing it, even though I don't think this will be controversial.

@kwankyu
Copy link
Collaborator

kwankyu commented Mar 27, 2020

comment:5

This is not official, but we usually do

cotan = cot  # provide this alias for backwards compatibility in #29409

instead of

cotan = cot # provide this alias for backwards compatibility (2020-3-25)

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 27, 2020

Branch pushed to git repo; I updated commit sha1. New commits:

b941d30include ticket number in comments

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 27, 2020

Changed commit from 9b59968 to b941d30

@DaveWitteMorris
Copy link
Member Author

comment:7

Yes, that's better than what I wrote. Thanks for the correction.

@kwankyu
Copy link
Collaborator

kwankyu commented Mar 27, 2020

comment:8

LGTM.

@DaveWitteMorris
Copy link
Member Author

comment:9

Thanks for the review. Does the ticket need a reviewer name, or can that be left blank?

@kwankyu
Copy link
Collaborator

kwankyu commented Mar 27, 2020

Reviewer: Kwankyu Lee

@vbraun
Copy link
Member

vbraun commented Apr 5, 2020

Changed branch from public/29409 to b941d30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants