Opened 2 years ago
Closed 2 years ago
#29409 closed defect (fixed)
error when evaluating symbolic expression involving cotangent of a complex number
Reported by: | gh-DaveWitteMorris | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-9.1 |
Component: | symbolics | Keywords: | cotangent, complex |
Cc: | Merged in: | ||
Authors: | Dave Morris | Reviewers: | Kwankyu Lee |
Report Upstream: | N/A | Work issues: | |
Branch: | b941d30 (Commits, GitHub, GitLab) | Commit: | b941d30f8437eb34f0be57befe73fbf174e4f5dd |
Dependencies: | Stopgaps: |
Description
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.
Change History (11)
comment:1 Changed 2 years ago by
- Branch set to public/29409
comment:2 Changed 2 years ago by
- Commit set to 9b59968ab98ed9e169507eba3354fad69fe59630
- Status changed from new to needs_review
comment:3 Changed 2 years ago by
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
comment:4 Changed 2 years ago by
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.
comment:5 Changed 2 years ago by
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)
comment:6 Changed 2 years ago by
- Commit changed from 9b59968ab98ed9e169507eba3354fad69fe59630 to b941d30f8437eb34f0be57befe73fbf174e4f5dd
Branch pushed to git repo; I updated commit sha1. New commits:
b941d30 | include ticket number in comments
|
comment:7 Changed 2 years ago by
Yes, that's better than what I wrote. Thanks for the correction.
comment:9 Changed 2 years ago by
Thanks for the review. Does the ticket need a reviewer name, or can that be left blank?
comment:10 Changed 2 years ago by
- Reviewers set to Kwankyu Lee
comment:11 Changed 2 years ago by
- Branch changed from public/29409 to b941d30f8437eb34f0be57befe73fbf174e4f5dd
- Resolution set to fixed
- Status changed from positive_review to closed
I changed the name of the
cotan
method of theComplexNumber
class tocot
. This eliminates the error:For consistency, I made the same change to the class
MPComplexNumber
, which I think is the only other occurrence of acotan
function in the sage source. To preserve backwards compatibility, I addedcotan
as an alias for each of these methods.New commits:
change cotan to tan