Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doctest: Add more logic flags to more functions #22155

Closed
rwst opened this issue Jan 8, 2017 · 27 comments
Closed

Doctest: Add more logic flags to more functions #22155

rwst opened this issue Jan 8, 2017 · 27 comments

Comments

@rwst
Copy link

rwst commented Jan 8, 2017

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

Depends on #22219

CC: @videlec

Component: symbolics

Author: Ralf Stephan

Branch/Commit: 350580a

Reviewer: Vincent Delecroix

Issue created by migration from https://trac.sagemath.org/ticket/22155

@rwst rwst added this to the sage-7.6 milestone Jan 8, 2017
@videlec
Copy link
Contributor

videlec commented Jan 8, 2017

comment:2

The gamma function

sage: gamma(pi).is_real()
False

You might also want to deal with is_positive which would be easily handled for analytic functions whose power series have non-negative coefficients.

Are there flags in ginac for properties like: "power series with non-negative coefficients", "power series with integer coefficients", etc?

@videlec
Copy link
Contributor

videlec commented Jan 8, 2017

comment:3

Hyperbolic trigonometric functions cosh/sinh/tanh and inverses arccosh/arcsinh/arctanh

sage: cosh(-3).is_real()
False
sage: cosh(-3).is_positive()
False

@videlec
Copy link
Contributor

videlec commented Jan 8, 2017

comment:4

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).

@videlec
Copy link
Contributor

videlec commented Jan 8, 2017

comment:5

Will this approach be recursive, namely cos(exp(-3) + log(2)).is_real()?

@rwst
Copy link
Author

rwst commented Jan 8, 2017

comment:6

Replying to @videlec:

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.

@dimpase
Copy link
Member

dimpase commented Jan 9, 2017

comment:7

as discussed on sage-develop, the best way IMHO would be to be able to return
"Unknown" instead of false "False"...

@rwst
Copy link
Author

rwst commented Jan 10, 2017

comment:8

Replying to @dimpase:

as discussed on sage-develop, the best way IMHO would be to be able to return
"Unknown" instead of false "False"...

See #22162.

@rwst
Copy link
Author

rwst commented Jan 11, 2017

Dependencies: pynac-0.7.4

@rwst
Copy link
Author

rwst commented Jan 11, 2017

comment:9

Improvements in pynac/pynac@acec861

@rwst
Copy link
Author

rwst commented Jan 11, 2017

@videlec
Copy link
Contributor

videlec commented Jan 11, 2017

Commit: 4a7499b

@videlec
Copy link
Contributor

videlec commented Jan 11, 2017

comment:11

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()
  1. complex stuff is actually False
cos(I).is_real()
sin(2 - I).is_real()
etc
  1. What is the current status of?
sage: x = SR.var('x')
sage: assume(x, 'real')
sage: (cos(x) + 1).is_positive()

New commits:

4a7499b22155: doctest the improved domain logic

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 12, 2017

Changed commit from 4a7499b to 6e1c056

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 12, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

6e1c05622155: address reviewer's comments

@rwst
Copy link
Author

rwst commented Jan 12, 2017

comment:13

Replying to @videlec:

  1. 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 tri-state 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.

@videlec
Copy link
Contributor

videlec commented Jan 12, 2017

comment:14

What does mean "dependencies pynac-0.7.4"?

@rwst
Copy link
Author

rwst commented Jan 12, 2017

comment:15

There is no ticket atm for the 0.7.4 upgrade. When there is I'll replace that with the ticket number.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 5, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

fc0c64dMerge branch 'develop' into t/22155/add_more_logic_flags_to_more_functions

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 5, 2017

Changed commit from 6e1c056 to fc0c64d

@rwst
Copy link
Author

rwst commented Jun 5, 2017

Author: Ralf Stephan

@rwst
Copy link
Author

rwst commented Jun 5, 2017

Changed dependencies from pynac-0.7.4 to #22219

@rwst rwst changed the title Add more logic flags to more functions Doctest: Add more logic flags to more functions Jun 5, 2017
@rwst rwst modified the milestones: sage-7.6, sage-8.1 Jun 5, 2017
@rwst
Copy link
Author

rwst commented Aug 24, 2017

comment:18

Two failing doctests.

@rwst
Copy link
Author

rwst commented Aug 24, 2017

comment:19

Actually the doctests were wrong: realpositive is not real but positvepositive is. Also (cos(exp(real) + log(pos))<sup>pos</sup>) is not real if the log argument is less than one. I replace the second pos with 8. Sage teaches me math!

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 24, 2017

Changed commit from fc0c64d to 350580a

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 24, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

39f0336Merge branch 'develop' into t/22155/add_more_logic_flags_to_more_functions
350580a22155: fixes

@videlec
Copy link
Contributor

videlec commented Aug 26, 2017

Reviewer: Vincent Delecroix

@vbraun
Copy link
Member

vbraun commented Sep 2, 2017

Changed branch from u/rws/add_more_logic_flags_to_more_functions to 350580a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants