Issue 3699 in sympy: solve() should be able to tell you when it knows it's found all the solutions

1 view
Skip to first unread message

sy...@googlecode.com

unread,
Mar 16, 2013, 9:17:10 PM3/16/13
to sympy-...@googlegroups.com
Status: Valid
Owner: ----
Labels: Type-Enhancement Priority-Medium Solvers

New issue 3699 by asme...@gmail.com: solve() should be able to tell you
when it knows it's found all the solutions
http://code.google.com/p/sympy/issues/detail?id=3699

Currently, solve() has zero guarantees about how many solutions its found.
However, in a few cases, we have algorithms that we know are complete, so
we can assert with confidence that the solutions returned are all the
solutions. We could also do this for simple inversions (e.g.,
solve(log(x), x)).

What should the API look like for this? The current API is a mess, so this
might need to wait on issue 3650. Also, what would be a nice API for
inversions? We already have the inverse() method to tell what the inverse
function is. This should be generalized for one-to-many functions.

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

sy...@googlecode.com

unread,
Mar 16, 2013, 9:20:00 PM3/16/13
to sympy-...@googlegroups.com
Updates:
Blockedon: -sympy:3650 sympy:3560

Comment #1 on issue 3699 by asme...@gmail.com: solve() should be able to
tell you when it knows it's found all the solutions
http://code.google.com/p/sympy/issues/detail?id=3699

Make that issue 3560.

sy...@googlecode.com

unread,
Mar 16, 2013, 9:31:54 PM3/16/13
to sympy-...@googlegroups.com
Issue 3699: solve() should be able to tell you when it knows it's found all
the solutions
http://code.google.com/p/sympy/issues/detail?id=3699

This issue is now blocking issue sympy:3698.
See http://code.google.com/p/sympy/issues/detail?id=3698

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

sy...@googlecode.com

unread,
Apr 3, 2013, 3:22:18 AM4/3/13
to sympy-...@googlegroups.com

Comment #3 on issue 3699 by smi...@gmail.com: solve() should be able to
tell you when it knows it's found all the solutions
http://code.google.com/p/sympy/issues/detail?id=3699

see also https://code.google.com/p/sympy/issues/detail?id=1234

sy...@googlecode.com

unread,
May 3, 2013, 8:03:53 AM5/3/13
to sympy-...@googlegroups.com

Comment #4 on issue 3699 by thilina....@gmail.com: solve() should be able
to tell you when it knows it's found all the solutions
http://code.google.com/p/sympy/issues/detail?id=3699

I am no expert here but couldn't we return True or False with the set of
solutions as a tuple, depending on whether solutions are complete or
incomplete?

sy...@googlecode.com

unread,
May 3, 2013, 11:59:06 AM5/3/13
to sympy-...@googlegroups.com

Comment #5 on issue 3699 by thilina....@gmail.com: solve() should be able
to tell you when it knows it's found all the solutions
http://code.google.com/p/sympy/issues/detail?id=3699

Another work around is to return oo if the solution is incomplete. Since
solve doesn't return oo as a solution to any kind of equation, having oo in
the solution set could tell the incompleteness of solution set. Granted
this has it's draw backs but I think it's better than my first suggestion.

sy...@googlecode.com

unread,
May 3, 2013, 2:36:06 PM5/3/13
to sympy-...@googlegroups.com

Comment #6 on issue 3699 by thilina....@gmail.com: solve() should be able
to tell you when it knows it's found all the solutions
http://code.google.com/p/sympy/issues/detail?id=3699

Another work around is to return oo along with the solution set if the
solution is incomplete. Since solve doesn't return oo as a solution to any
kind of equation, having oo in the solution set could imply incompleteness
of the solution. Granted this has it's draw backs but I think it's better

sy...@googlecode.com

unread,
May 14, 2013, 5:35:55 PM5/14/13
to sympy-...@googlegroups.com
Updates:
Labels: Assumptions

Comment #7 on issue 3699 by asme...@gmail.com: solve() should be able to
tell you when it knows it's found all the solutions
http://code.google.com/p/sympy/issues/detail?id=3699

This is also tied to assumptions, at least in the implementation. For
example solve(re(x) - I, x) cannot possibly have any solutions because
re(x) is always real.

sy...@googlecode.com

unread,
May 21, 2013, 12:43:13 AM5/21/13
to sympy-...@googlegroups.com

Comment #8 on issue 3699 by smi...@gmail.com: solve() should be able to
tell you when it knows it's found all the solutions
http://code.google.com/p/sympy/issues/detail?id=3699

Are we going to have a None possibility? Is it possible to know if you have
all solutions or not? e.g. x*cos(3) - 3*cos(x) has a solution of x =
3...would this have been detected by the not-yet-written algorithm that
seeks to answer that question? It seems reminiscent of the impossibility of
proving that A == B with a fixed algorithm. Perhaps if an expression
doesn't involve trascendentals, then we know. Or if it contains a single or
certain types of transcendental functions (exp(x), log(x)) then we know,
otherwise we won't/can't/don't know?

sy...@googlecode.com

unread,
May 21, 2013, 5:32:59 AM5/21/13
to sympy-...@googlegroups.com

Comment #9 on issue 3699 by smi...@gmail.com: solve() should be able to
tell you when it knows it's found all the solutions
http://code.google.com/p/sympy/issues/detail?id=3699

Here's another issue to consider -- what if P(x) returns a polynomial and
F(x) returns an expression that has no solution that can be written
explicitly in terms of x. What should P(F(x)) return? Instead of saying
NotImplemented it could return the values that F(x) must have. RootOf
cannot contain such a thing, so perhaps a NumericalRootOf class should be
used, e.g. solve(x*(x - cos(x)) -> [0, NumericalRootOf(x - cos(x))]. If
Intervals (of some sort) gets smart enough perhaps an expression like that
can be analyzed and intervals for roots reported.

sy...@googlecode.com

unread,
May 23, 2013, 9:37:21 PM5/23/13
to sympy-...@googlegroups.com

Comment #10 on issue 3699 by asme...@gmail.com: solve() should be able to
tell you when it knows it's found all the solutions
http://code.google.com/p/sympy/issues/detail?id=3699

Yes, None is necessary, because we will always have algorithms that are
heuristic (we don't know if they get all the solutions or not). The
algorithm works conservatively. It splits the expression apart
multiplicatively (factoring), and does a fuzzy all on the solutions
returned by each factor.

A UnknownSolution class, which would generalize RootOf to non-polynomials,
would be useful. How would evalf work, though? We have to know at least
something about the solution we want to numerically evaluate it (to make
sure we get the right one). Anyhow, I think that's a separate issue.

sy...@googlecode.com

unread,
Jun 10, 2013, 8:33:57 AM6/10/13
to sympy-...@googlegroups.com

Comment #11 on issue 3699 by smi...@gmail.com: solve() should be able to
tell you when it knows it's found all the solutions
http://code.google.com/p/sympy/issues/detail?id=3699

One way something can be learned about the function is to check its series:

>>> eq=(sinh(x)*sinh (sinh (x))+cosh (x)*cosh (sinh (x))-3)
>>> eq.series(2)
sinh(x)*sinh(sinh(x)) + cosh(x)*cosh(sinh(x)) - 3
>>> eq.series(3)
sinh(x)*sinh(sinh(x)) + cosh(x)*cosh(sinh(x)) - 3
>>> eq.series()
-2 + 2*x**2 + x**4 + O(x**6)
>>> solve(_.removeO())
[-I*sqrt(1 + sqrt(3)), I*sqrt(1 + sqrt(3)), -sqrt(-1 + sqrt(3)), sqrt(-1 +
sqrt(3))]
>>> [w.n() for w in _]
[-1.65289165028107*I, 1.65289165028107*I, -0.855599677167352,
0.855599677167352]
>>> sol=_
>>> nsolve(eq, x, sol[-1])
mpf('0.83173851663805556')
>>> nsolve(eq, x, sol[-2])
mpf('-0.83173851663805556')

Perhaps this will only work well if there is a root near 0.
Reply all
Reply to author
Forward
0 new messages