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:  ghYapadcoi  Owned by:  

Priority:  major  Milestone:  sage9.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: 
Description (last modified by )
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
comment:2 Changed 6 months ago by
 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.
comment:3 Changed 6 months ago by
 Description modified (diff)
comment:4 Changed 4 months ago by
OK, I've tested the pynac patch, it seems to work. Now the full doctest...
comment:5 Changed 4 months ago by
OK, this works. I'm merging this upstream.
comment:6 Changed 4 months ago by
 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
 Status changed from needs_review to positive_review
comment:8 Changed 4 months ago by
Should we add doctests though?
comment:9 Changed 4 months ago by
 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
 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.
Followup Pynac issue for the case c = 1 at
New commits:
c3ab10e  31739: Doctest exp(c*f(x)) with f inverse hyperbolic function

comment:11 Changed 3 months ago by
 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
 Milestone changed from sage9.4 to sage9.5
comment:13 Changed 4 weeks ago by
 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
 Branch changed from public/31739 to c3ab10ea5c1ccf67611ef950192942e8cb0afa9d
 Resolution set to fixed
 Status changed from positive_review to closed
This is likely a Pynac bug. Please report at