Skip to content

Commit

Permalink
Trac #22155: Doctest: Add more logic flags to more functions
Browse files Browse the repository at this point in the history
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

URL: https://trac.sagemath.org/22155
Reported by: rws
Ticket author(s): Ralf Stephan
Reviewer(s): Vincent Delecroix
  • Loading branch information
Release Manager authored and vbraun committed Sep 3, 2017
2 parents 971d77f + 350580a commit 651b53d
Showing 1 changed file with 54 additions and 1 deletion.
55 changes: 54 additions & 1 deletion src/sage/symbolic/expression.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1977,11 +1977,31 @@ cdef class Expression(CommutativeRingElement):
False
sage: (t0*t1).is_real()
True
sage: t2 = SR.symbol("t1", domain='positive')
sage: t2 = SR.symbol("t2", domain='positive')
sage: (t1**t2).is_real()
True
sage: (t0*x).is_real()
False
sage: (t0^t1).is_real()
False
sage: (t1^t2).is_real()
True
sage: gamma(pi).is_real()
True
sage: cosh(-3).is_real()
True
sage: cos(exp(-3) + log(2)).is_real()
True
sage: gamma(t1).is_real()
True
sage: (x^pi).is_real()
False
sage: (cos(exp(t0) + log(t1))^8).is_real()
True
sage: cos(I).is_real()
False
sage: sin(2 - I).is_real()
False
sage: (2^t0).is_real()
True
Expand All @@ -1996,6 +2016,8 @@ cdef class Expression(CommutativeRingElement):
sage: assume(x, 'real')
sage: x.is_real()
True
sage: cosh(x).is_real()
True
sage: forget()
The real domain is also set with the integer domain::
Expand Down Expand Up @@ -2039,11 +2061,42 @@ cdef class Expression(CommutativeRingElement):
sage: assume(x>0)
sage: x.is_positive()
True
sage: cosh(x).is_positive()
True
sage: f = function('f')(x)
sage: assume(f>0)
sage: f.is_positive()
True
sage: forget()
::
sage: cosh(x).is_positive()
False
sage: cosh(real(x)).is_positive()
True
sage: (cosh(real(x))^2).is_positive()
True
sage: ((real(x))^2).is_positive()
False
sage: gamma(x^2).is_positive()
False
sage: gamma(x^2+1).is_positive()
False
sage: gamma(cosh(real(x))).is_positive()
True
sage: (real(x)^2).is_positive()
False
sage: (real(x)^2+1).is_positive()
True
sage: (abs(x)^2+1).is_positive()
True
sage: gamma(real(x)^2+1).is_positive()
True
sage: cos(I).is_positive()
False
sage: sin(2 - I).is_positive()
False
"""
return self._gobj.info(info_positive)

Expand Down

0 comments on commit 651b53d

Please sign in to comment.