Opened 3 years ago
Last modified 3 years ago
#24299 needs_work defect
Systematic doctest for function return type
Reported by:  zimmerma  Owned by:  

Priority:  major  Milestone:  sage8.2 
Component:  symbolics  Keywords:  
Cc:  jdemeyer  Merged in:  
Authors:  Ralf Stephan  Reviewers:  Paul Zimmermann 
Report Upstream:  N/A  Work issues:  
Branch:  u/rws/24299 (Commits, GitHub, GitLab)  Commit:  0b52ecd01cd3c8aa28f10ef9627276b674aadda6 
Dependencies:  #24318, #24329, #24604  Stopgaps: 
Description (last modified by )
sage: sinh(CIF(1)) [1.1752011936438013 .. 1.1752011936438017] sage: asinh(CIF(1)) 0.881373587019543
The second command should return a (complex) interval.
Also:
sage: asin(CIF(0.6)) ... TypeError: unable to convert '0.59999999999999998?' to a real number
Change History (18)
comment:1 Changed 3 years ago by
 Cc jdemeyer added
comment:2 Changed 3 years ago by
 Component changed from basic arithmetic to symbolics
comment:3 Changed 3 years ago by
As an explanation, the handling of inexact function arguments has several layers. The fallback layer (if the arg has no suitable member function and exact evaluation has no tricks) is to call the helper functions in libs/pynac/pynac.pyx
which use member functions of RR and CC. There is in most cases no automatic backconversion to the argument type so, as fallback, you at least get Real/ComplexField
elements.
There is work ongoing in Pynac to use arb instead of RR
and CC
because of speed and ease of conversion to e.g. interval field elements. It's just that inverse hyperbolic functions are still waiting for it. Of course one could state it's the responsibility of CIF to implement inverse hyperbolic functions (and inverse trig functions, for that matter) but I'm not holding my breath. CIF is a math programming exercise, Pynac tries to solve real calculus problems, so we'll implement it in Pynac0.7.14.
comment:4 Changed 3 years ago by
 Description modified (diff)
 Milestone changed from sage8.1 to sage8.2
 Summary changed from asinh(CIF(1)) returns an element of CC instead of CIF to Bugs with inverse trig and hyperbolic functions of CIF argument
comment:5 Changed 3 years ago by
 Dependencies set to #24317
comment:6 Changed 3 years ago by
 Dependencies changed from #24317 to #24318, pynac0.7.14
comment:7 Changed 3 years ago by
 Branch set to u/rws/bugs_with_inverse_trig_and_hyperbolic_functions_of_cif_argument
comment:8 Changed 3 years ago by
 Commit set to 0dad6addf34653b2dbf55dda93dc22b3ff209a8a
 Dependencies changed from #24318, pynac0.7.14 to #24318, #24329
 Status changed from new to needs_review
 Summary changed from Bugs with inverse trig and hyperbolic functions of CIF argument to Doctest: inverse trig and hyperbolic functions of CIF argument
New commits:
0dad6ad  24299: Bugs with inverse trig and hyperbolic functions of CIF argument

comment:9 followup: ↓ 10 Changed 3 years ago by
I'd like to review this, but I see only nonregression tests in commit 0dad6ad, and no changes in the source code. How could the results change?
comment:10 in reply to: ↑ 9 Changed 3 years ago by
Replying to zimmerma:
I'd like to review this, but I see only nonregression tests in commit 0dad6ad, and no changes in the source code. How could the results change?
Functions can be either coded in Python (BuiltinFunction
) or C++ (GinacFunction
in Pynac). FP evaluation first looks if CIF has a member for asinh
and, as there isn't, the function's evalf
member is called. As trig and hyperbolic functions are GinacFunction
s the changes needed to be done in Pynac, and they became effect with #24329 which was introduced in beta0 I think. So, in order to see the doctests fail you need to go back to 8.1.
comment:11 followup: ↓ 16 Changed 3 years ago by
 Reviewers set to Paul Zimmermann
 Status changed from needs_review to needs_work
I'm not sure about this:
sage: acoth(CIF(0.6)) 0.693147180559945?
since we get with CC:
sage: acoth(CC(0.6)) 0.693147180559945  1.57079632679490*I
comment:12 Changed 3 years ago by
Agreed, still buggy.
comment:13 Changed 3 years ago by
I did a systematic search and found these additional issues:
sage: log_gamma(complex(1.7)) 0.09580769740706588 sage: psi(complex(1.7)) 0.2085478748734939
Also dickman_rho
can't handle anything other than float.
The code I used will go into tests/symbolicfunctions.py
.
comment:14 Changed 3 years ago by
 Branch changed from u/rws/bugs_with_inverse_trig_and_hyperbolic_functions_of_cif_argument to u/rws/24299
comment:15 Changed 3 years ago by
 Commit changed from 0dad6addf34653b2dbf55dda93dc22b3ff209a8a to 0b52ecd01cd3c8aa28f10ef9627276b674aadda6
 Dependencies changed from #24318, #24329 to #24318, #24329, #24604
 Summary changed from Doctest: inverse trig and hyperbolic functions of CIF argument to Systematic doctest for function return type
New commits:
0b52ecd  24299: Systematic doctest for function return type

comment:16 in reply to: ↑ 11 Changed 3 years ago by
Replying to zimmerma:
I'm not sure about this:
sage: acoth(CIF(0.6)) 0.693147180559945?
This one is now fixed in Pynac0.7.16.
comment:17 Changed 3 years ago by
Now with Pynac0.7.16 still failing.
comment:18 Changed 3 years ago by
Update: the correct arccoth(RR(0.7))>CC
, elliptic_eu(7,CC(1.7))
, jacobi_am(7,CC(1.7))
are flagged wrong. Still failing: dickman_rho(all types)
.
That's a symbolic function evaluation issue, not the fault of CIF.