Opened 5 years ago

Closed 3 years ago

#16491 closed defect (fixed)

doctest trigonometric functions for complex input

Reported by: ppurka Owned by:
Priority: major Milestone: sage-7.2
Component: symbolics Keywords:
Cc: burcin, kcrisman, rws Merged in:
Authors: Ralf Stephan Reviewers: Vincent Delecroix
Report Upstream: N/A Work issues:
Branch: 5e18f34 (Commits) Commit: 5e18f344b2016d6e7eea64c06d398017da851761
Dependencies: Stopgaps:

Description (last modified by ppurka)

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))
sage: sec(CDF(complex(1,1)))
0.498337030555 + 0.591083841721*I


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 5 years ago by ppurka

  • Description modified (diff)

comment:2 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:3 Changed 4 years ago by rws

  • Summary changed from Fix output of trigonometric functions for complex input to unify 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))
sage: acos(complex(1,1))
sage: asin(complex(1,1))
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 3 years ago by rws

  • Milestone changed from sage-6.4 to sage-duplicate/invalid/wontfix
  • Status changed from new to needs_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 3 years ago by vdelecroix

What about adding doctests?

comment:6 Changed 3 years ago by rws

  • Branch set to u/rws/unify_output_of_trigonometric_functions_for_complex_input

comment:7 Changed 3 years ago by rws

  • Authors set to Ralf Stephan
  • Commit set to 5e18f344b2016d6e7eea64c06d398017da851761
  • Milestone changed from sage-duplicate/invalid/wontfix to sage-7.2
  • Summary changed from unify output of trigonometric functions for complex input to doctest trigonometric functions for complex input

New commits:

5e18f3416491: doctest complex trig functions

comment:8 Changed 3 years ago by vdelecroix

  • Reviewers set to Vincent Delecroix
  • Status changed from needs_review to positive_review

comment:9 Changed 3 years ago by vbraun

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