Opened 4 years ago
Closed 3 years ago
#22155 closed enhancement (fixed)
Doctest: Add more logic flags to more functions
Reported by:  rws  Owned by:  

Priority:  major  Milestone:  sage8.1 
Component:  symbolics  Keywords:  
Cc:  vdelecroix  Merged in:  
Authors:  Ralf Stephan  Reviewers:  Vincent Delecroix 
Report Upstream:  N/A  Work issues:  
Branch:  350580a (Commits)  Commit:  350580aa70a39f1227df71b00d976a2ebfdd6dff 
Dependencies:  #22219  Stopgaps: 
Description
Some functions are handled with some flags in https://github.com/pynac/pynac/blob/master/ginac/function.cpp#L1581
This should be extended (in Pynac) and doctests added (here). This ticket should list which questions can be answered definitely to the positive. To start:
 f(real).is_real() for f in sin/cos/tan/cot/sec/csc
Change History (23)
comment:1 Changed 4 years ago by
 Cc vdelecroix added
comment:2 Changed 4 years ago by
comment:3 Changed 4 years ago by
Hyperbolic trigonometric functions cosh/sinh/tanh
and inverses arccosh/arcsinh/arctanh
sage: cosh(3).is_real() False sage: cosh(3).is_positive() False
comment:4 Changed 4 years ago by
But instead of hardcoding all these informations in functions, it would be better to actually deduce it from some other properties (like Taylor series as I suggested before).
comment:5 followup: ↓ 6 Changed 4 years ago by
Will this approach be recursive, namely cos(exp(3) + log(2)).is_real()
?
comment:6 in reply to: ↑ 5 Changed 4 years ago by
Replying to vdelecroix:
it would be better to actually deduce it from some other properties (like Taylor series as I suggested before).
Not possible. Taylor series are determined in general by differentiation. There is no builtin formula which we can inspect.
Will this approach be recursive, namely
cos(exp(3) + log(2)).is_real()
?
Yes.
comment:7 followup: ↓ 8 Changed 4 years ago by
as discussed on sagedevelop, the best way IMHO would be to be able to return "Unknown" instead of false "False"...
comment:8 in reply to: ↑ 7 Changed 4 years ago by
comment:9 Changed 4 years ago by
 Dependencies set to pynac0.7.4
comment:10 Changed 4 years ago by
 Branch set to u/rws/add_more_logic_flags_to_more_functions
comment:11 followup: ↓ 13 Changed 4 years ago by
 Commit set to 4a7499bc3f8ef392d47f26fa8d2636856ce01a51
Nice! Could you add doctest to check
1) compatibility with assumptions
sage: x = SR.var('x') sage: assume(x, 'real') sage: cos(x).is_real()
2) complex stuff is actually False
cos(I).is_real() sin(2  I).is_real() etc
3) What is the current status of?
sage: x = SR.var('x') sage: assume(x, 'real') sage: (cos(x) + 1).is_positive()
New commits:
4a7499b  22155: doctest the improved domain logic

comment:12 Changed 4 years ago by
 Commit changed from 4a7499bc3f8ef392d47f26fa8d2636856ce01a51 to 6e1c056b5e39f6dece3f9c94a620c7fc2564e99f
Branch pushed to git repo; I updated commit sha1. New commits:
6e1c056  22155: address reviewer's comments

comment:13 in reply to: ↑ 11 Changed 4 years ago by
Replying to vdelecroix:
3) What is the current status of?
sage: x = SR.var('x') sage: assume(x, 'real') sage: (cos(x) + 1).is_positive()
Not possible using current machinery. Note the information kept is boolean (or maybe tristate in the future) for speed reasons, as it is routinely used with manipulation of expressions. Any slowdown like numeric computations that are potentially calling Python/Cython code from C++ should be avoided.
comment:14 Changed 4 years ago by
What does mean "dependencies pynac0.7.4"?
comment:15 Changed 4 years ago by
There is no ticket atm for the 0.7.4 upgrade. When there is I'll replace that with the ticket number.
comment:16 Changed 3 years ago by
 Commit changed from 6e1c056b5e39f6dece3f9c94a620c7fc2564e99f to fc0c64d7e7034121a3df09783c2773e5ea01033b
Branch pushed to git repo; I updated commit sha1. New commits:
fc0c64d  Merge branch 'develop' into t/22155/add_more_logic_flags_to_more_functions

comment:17 Changed 3 years ago by
 Dependencies changed from pynac0.7.4 to #22219
 Milestone changed from sage7.6 to sage8.1
 Status changed from new to needs_review
 Summary changed from Add more logic flags to more functions to Doctest: Add more logic flags to more functions
comment:18 Changed 3 years ago by
 Status changed from needs_review to needs_work
Two failing doctests.
comment:19 Changed 3 years ago by
Actually the doctests were wrong: real
^{positive} is not real but positve
^{positive} is. Also (cos(exp(real) + log(pos))^pos^)
is not real if the log argument is less than one. I replace the second pos with 8
. Sage teaches me math!
comment:20 Changed 3 years ago by
 Commit changed from fc0c64d7e7034121a3df09783c2773e5ea01033b to 350580aa70a39f1227df71b00d976a2ebfdd6dff
comment:21 Changed 3 years ago by
 Status changed from needs_work to needs_review
comment:22 Changed 3 years ago by
 Reviewers set to Vincent Delecroix
 Status changed from needs_review to positive_review
comment:23 Changed 3 years ago by
 Branch changed from u/rws/add_more_logic_flags_to_more_functions to 350580aa70a39f1227df71b00d976a2ebfdd6dff
 Resolution set to fixed
 Status changed from positive_review to closed
The gamma function
You might also want to deal with
is_positive
which would be easily handled for analytic functions whose power series have nonnegative coefficients.Are there flags in ginac for properties like: "power series with nonnegative coefficients", "power series with integer coefficients", etc?