Opened 4 years ago

Closed 4 years ago

#18954 closed defect (fixed)

doctest special values of trig. functions with arguments (m/n)*pi

Reported by: rws Owned by:
Priority: major Milestone: sage-6.9
Component: symbolics Keywords:
Cc: Merged in:
Authors: Ralf Stephan Reviewers: Vincent Delecroix
Report Upstream: N/A Work issues:
Branch: e7ce7ce (Commits) Commit: e7ce7ce90a010ec3b617fa23af893f19a6f00bca
Dependencies: #18980 Stopgaps:

Description (last modified by rws)

Sage immediately returns exact expressions for trig. functions with argument a multiple of pi/3, pi/4, pi/6 and some of pi/5 because they are just square roots. The other values of e.g. sin(n*pi/5) are quite simple too, but they are roots of 4-degree so they were not added.

sage: sin(3*pi/4)
1/2*sqrt(2)
sage: sec(3*pi/5)
-4/(sqrt(5) - 1)
sage: cos(3*pi/5)
-1/4*sqrt(5) + 1/4
sage: sin(3*pi/5)
sin(3/5*pi)
sage: tan(3*pi/5)
tan(3/5*pi)
sage: cot(3*pi/5)
cot(3/5*pi)
sage: cos(pi/6)
1/2*sqrt(3)

However, people expect this so they should be added.

Change History (8)

comment:1 Changed 4 years ago by rws

  • Description modified (diff)

comment:2 Changed 4 years ago by rws

  • Dependencies set to pynac-0.4.3
  • Report Upstream changed from N/A to Fixed upstream, but not in a stable release.

New code in Pynac does the following:

sage: sin(pi/5)
1/4*sqrt(-2*sqrt(5) + 10)
sage: sin(pi/8)
1/2*sqrt(-sqrt(2) + 2)
sage: sin(pi/24)
1/4*sqrt(-2*sqrt(6) - 2*sqrt(2) + 8)
sage: sin(pi/30)
-1/8*sqrt(5) + 1/4*sqrt(-3/2*sqrt(5) + 15/2) - 1/8
sage: cos(pi/8)
1/2*sqrt(sqrt(2) + 2)
sage: cos(pi/10)
1/2*sqrt(1/2*sqrt(5) + 5/2)
sage: cos(pi/12)
1/12*sqrt(6)*(sqrt(3) + 3)
sage: cos(pi/15)
1/8*sqrt(5) + 1/4*sqrt(3/2*sqrt(5) + 15/2) - 1/8
sage: cos(pi/24)
1/4*sqrt(2*sqrt(6) + 2*sqrt(2) + 8)
sage: tan(pi/5)
sqrt(-2*sqrt(5) + 5)
sage: tan(pi/8)
sqrt(2) - 1
sage: tan(pi/10)
sqrt(-2/5*sqrt(5) + 1)
sage: tan(pi/16)
-sqrt(2) + sqrt(2*sqrt(2) + 4) - 1
sage: tan(pi/20)
sqrt(5) - 1/2*sqrt(8*sqrt(5) + 20) + 1
sage: tan(pi/24)
sqrt(6) - sqrt(-2*sqrt(6) + 5) - 2

sage: all(sin(rat*pi).n(200)-sin(rat*pi,hold=True).n(200) < 1e-30 for rat in [1/5,2/5,1/30,7/30,11/30,13/30,1/8,3/8,1/24,5/24,7/24,11/24])
True
sage: all(cos(rat*pi).n(200)-cos(rat*pi,hold=True).n(200) < 1e-30 for rat in [1/10,3/10,1/12,5/12,1/15,2/15,4/15,7/15,1/8,3/8,1/24,5/24,11/24])
True
sage: all(tan(rat*pi).n(200)-tan(rat*pi,hold=True).n(200) < 1e-30 for rat in [1/5,2/5,1/10,3/10,1/20,3/20,7/20,9/20,1/8,3/8,1/16,3/16,5/16,7/16,1/24,5/24,7/24,11/24])
True

This ticket should merge them as doctests.

comment:3 Changed 4 years ago by rws

  • Summary changed from special values of trig. functions with arguments n*pi/5 to special values of trig. functions with arguments (m/n)*pi

comment:4 Changed 4 years ago by vdelecroix

This is fine with #18980. Could you add doctests for them

sage: sin(pi/5)
1/4*sqrt(-2*sqrt(5) + 10)
sage: sin(2*pi/5)
1/4*sqrt(2*sqrt(5) + 10)

comment:5 Changed 4 years ago by rws

  • Branch set to u/rws/special_values_of_trig__functions_with_arguments__m_n__pi

comment:6 Changed 4 years ago by rws

  • Authors set to Ralf Stephan
  • Commit set to e7ce7ce90a010ec3b617fa23af893f19a6f00bca
  • Dependencies changed from pynac-0.4.3 to #18980
  • Milestone changed from sage-6.8 to sage-6.9
  • Report Upstream changed from Fixed upstream, but not in a stable release. to N/A
  • Status changed from new to needs_review
  • Summary changed from special values of trig. functions with arguments (m/n)*pi to doctest special values of trig. functions with arguments (m/n)*pi

New commits:

e7ce7ce18954: doctest special values of trig. functions with arguments (m/n)*pi

comment:7 Changed 4 years ago by vdelecroix

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

The patchbot is not happy because it is not able to apply #18980. But it is fine for me.

comment:8 Changed 4 years ago by vbraun

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