Opened 8 years ago

Closed 7 years ago

#16491 closed defect (fixed)

doctest trigonometric functions for complex input

Reported by: Punarbasu Purkayastha Owned by:
Priority: major Milestone: sage-7.2
Component: symbolics Keywords:
Cc: Burcin Erocal, Karl-Dieter Crisman, Ralf Stephan Merged in:
Authors: Ralf Stephan Reviewers: Vincent Delecroix
Report Upstream: N/A Work issues:
Branch: 5e18f34 (Commits, GitHub, GitLab) Commit: 5e18f344b2016d6e7eea64c06d398017da851761
Dependencies: Stopgaps:

Status badges

Description (last modified by Punarbasu Purkayastha)

This is a follow up to #16439.

  1. The functions atan, acos, asin give TypeError on Python complex input.
  1. The output of trigonometric functions are inconsistent depending on whether complex or CDF or CC is used as the input type.

From #16439 discussion by @kcrisman:

Just one point - almost certainly some of those digits are 'extra' from Python. Compare (after this):

sage: sec(1.+i)
0.498337030555187 + 0.591083841721045*I
sage: sec(complex(1,1))
(0.49833703055518686+0.5910838417210451j)
sage: sec(CDF(complex(1,1)))
0.498337030555 + 0.591083841721*I

Interesting.

Here is something else I don't know what to do with.

sage: arccot(1.+i)
arccot(1.00000000000000 + 1.00000000000000*I)  # in SR
sage: cot(1.+i)
0.217621561854403 - 0.868014142895925*I

One would think this should be the same type of output.

That said, SR is useful for some other cases of exact input.

I'm wondering whether we want to try to fix all of this here, though.

Change History (9)

comment:1 Changed 8 years ago by Punarbasu Purkayastha

Description: modified (diff)

comment:2 Changed 8 years ago by For batch modifications

Milestone: sage-6.3sage-6.4

comment:3 Changed 8 years ago by Ralf Stephan

Summary: Fix output of trigonometric functions for complex inputunify output of trigonometric functions for complex input

Everything except point 2 seems to be fixed so I'm changing the title.

sage: atan(complex(1,1))
(1.0172219678978514+0.4023594781085251j)
sage: acos(complex(1,1))
(0.9045568943023814-1.0612750619050357j)
sage: asin(complex(1,1))
(0.6662394324925152+1.0612750619050357j)
sage: asin(CDF(complex(1,1)))
0.6662394324925152 + 1.0612750619050357*I
sage: asin(CC(complex(1,1)))
0.666239432492515 + 1.06127506190504*I
sage: arccot(1.+i)
arccot(i + 1.00000000000000)
sage: cot(1.+i)
cot(i + 1.00000000000000)

comment:4 Changed 7 years ago by Ralf Stephan

Milestone: sage-6.4sage-duplicate/invalid/wontfix
Status: newneeds_review

I get now:

sage: arccot(1.+i)
0.553574358897045 - 0.402359478108525*I
sage: cot(1.+i)
0.217621561854403 - 0.868014142895925*I

So this seems fixed.

comment:5 Changed 7 years ago by Vincent Delecroix

What about adding doctests?

comment:6 Changed 7 years ago by Ralf Stephan

Branch: u/rws/unify_output_of_trigonometric_functions_for_complex_input

comment:7 Changed 7 years ago by Ralf Stephan

Authors: Ralf Stephan
Commit: 5e18f344b2016d6e7eea64c06d398017da851761
Milestone: sage-duplicate/invalid/wontfixsage-7.2
Summary: unify output of trigonometric functions for complex inputdoctest trigonometric functions for complex input

New commits:

5e18f3416491: doctest complex trig functions

comment:8 Changed 7 years ago by Vincent Delecroix

Reviewers: Vincent Delecroix
Status: needs_reviewpositive_review

comment:9 Changed 7 years ago by Volker Braun

Branch: u/rws/unify_output_of_trigonometric_functions_for_complex_input5e18f344b2016d6e7eea64c06d398017da851761
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.