Opened 6 months ago

Closed 3 weeks ago

#31739 closed defect (fixed)

Doctest exp(2*f(x)) with f in {atanh, acoth, asinh, acosh, asech, acsch}

Reported by: gh-Yapadcoi Owned by:
Priority: major Milestone: sage-9.5
Component: calculus Keywords:
Cc: dimpase, slelievre, mjo Merged in:
Authors: Samuel Lelièvre Reviewers: Dima Pasechnik, Michael Orlitzky
Report Upstream: Fixed upstream, in a later stable release. Work issues:
Branch: c3ab10e (Commits, GitHub, GitLab) Commit: c3ab10ea5c1ccf67611ef950192942e8cb0afa9d
Dependencies: Stopgaps:

Status badges

Description (last modified by slelievre)

In Sage 9.3.rc4, we get the incorrect

sage: exp(2*atanh(x))
(x + 1)/(x - 1)

The correct answer is (1 + x)/(1 - x) so we expect:

sage: exp(2*atanh(x))
-(x + 1)/(x - 1)

Similarly, we get the incorrect

sage: exp(2*acoth(x))
(x - 1)/(x + 1)

while we expect:

sage: exp(2*acoth(x))
(x + 1)/(x - 1)

The bug is in Pynac. A fix is provided at

The upgrade to Pynac 0.7.29, which has the change, is done in #31694, merged in Sage 9.4.beta5.

This ticket adds doctests as examples.

Change History (14)

comment:1 Changed 6 months ago by slelievre

This is likely a Pynac bug. Please report at

comment:2 Changed 6 months ago by slelievre

  • Cc dimpase slelievre added
  • Description modified (diff)
  • Priority changed from major to critical
  • Type changed from PLEASE CHANGE to defect

I proposed a fix to Pynac, see link in ticket description.

We should either apply it here as a patch or wait for a new Pynac release with the fix.

We should also add doctests.

Last edited 6 months ago by slelievre (previous) (diff)

comment:3 Changed 6 months ago by slelievre

  • Description modified (diff)

comment:4 Changed 4 months ago by dimpase

OK, I've tested the pynac patch, it seems to work. Now the full doctest...

comment:5 Changed 4 months ago by dimpase

OK, this works. I'm merging this upstream.

comment:6 Changed 4 months ago by dimpase

  • Authors set to Samuel Lelievre
  • Report Upstream changed from N/A to Fixed upstream, in a later stable release.
  • Reviewers set to Dima Pasechnik
  • Status changed from new to needs_review

comment:7 Changed 4 months ago by dimpase

  • Status changed from needs_review to positive_review

comment:8 Changed 4 months ago by slelievre

Should we add doctests though?

comment:9 Changed 4 months ago by dimpase

  • Dependencies set to #31694
  • Status changed from positive_review to needs_work

Could you add doctests here, on top of #31694?

comment:10 Changed 3 months ago by slelievre

  • Branch set to public/31739
  • Commit set to c3ab10ea5c1ccf67611ef950192942e8cb0afa9d
  • Dependencies #31694 deleted
  • Description modified (diff)
  • Status changed from needs_work to needs_review
  • Summary changed from Problem with exponential of arctanh and arcosh to Doctest exp(2*f(x)) with f in {atanh, acoth, asinh, acosh, asech, acsch}

Thanks Dima for merging my pull request in Pynac.

I'm adding examples in src/sage/functions/hyperbolic.py. Having added the examples in the file's main docstring, I skipped mentioning the ticket number, which I would have done if I had put the doctests in TESTS blocks. Hope that's okay.

Follow-up Pynac issue for the case c = 1 at


New commits:

c3ab10e31739: Doctest exp(c*f(x)) with f inverse hyperbolic function

comment:11 Changed 3 months ago by slelievre

  • Authors changed from Samuel Lelievre to Samuel Lelièvre
  • Priority changed from critical to major

Lowering priority as the fix is in and we merely add doctests here.

comment:12 Changed 2 months ago by mkoeppe

  • Milestone changed from sage-9.4 to sage-9.5

comment:13 Changed 4 weeks ago by mjo

  • Cc mjo added
  • Reviewers changed from Dima Pasechnik to Dima Pasechnik, Michael Orlitzky
  • Status changed from needs_review to positive_review

For robust test cases, something like

sage: bool(exp(2*atanh(x)) == -(x + 1)/(x - 1))
True

would be preferable as it does not depend on an exact string representation. But with examples, it's hard to avoid. And now that we've officially adopted pynac I guess it's OK to doctest this here, rather than in pynac "upstream."

comment:14 Changed 3 weeks ago by vbraun

  • Branch changed from public/31739 to c3ab10ea5c1ccf67611ef950192942e8cb0afa9d
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.