transcendental equation solving

165 views
Skip to first unread message

Luv Agarwal

unread,
Jan 5, 2015, 5:45:06 PM1/5/15
to sy...@googlegroups.com
While reading solvers doc I came across following:

If solve returns [] or raises NotImplementedError, it doesn't mean that the equation has no solutions. It just means that it couldn't find any. Often this means that the solutions cannot be represented symbolically. For example, the equation x = cos(x) has a solution, but it cannot be represented symbolically using standard functions.

>>> solve(x - cos(x), x)
Traceback (most recent call last):
...
NotImplementedError: multiple generators [x, exp(I*x)]
No algorithms are implemented to solve equation exp(I*x)

Why SymPy is not returning numerical solution if it is not able to return the solution in symbolic form? (In the above case it should have returned x = 0.739085)

Luv Agarwal

unread,
Jan 5, 2015, 5:50:32 PM1/5/15
to sy...@googlegroups.com
Also, it can sometimes be more useful to have a numeric solution than a solution represented in symbolic form.

Sudhanshu Mishra

unread,
Jan 5, 2015, 6:35:03 PM1/5/15
to sy...@googlegroups.com
Also, it can sometimes be more useful to have a numeric solution than a solution represented in symbolic form.

And that's why we have libraries like scipy/numpy :)

Regards
Sudhanshu Mishra

On Tue, Jan 6, 2015 at 4:20 AM, Luv Agarwal <luvagarw...@gmail.com> wrote:
Also, it can sometimes be more useful to have a numeric solution than a solution represented in symbolic form.

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/33ca1963-260c-499c-a244-b38da6a4ae1a%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Aaron Meurer

unread,
Jan 6, 2015, 2:40:53 AM1/6/15
to sy...@googlegroups.com
SymPy does have nsolve, which uses mpmath, but in general, numerical algorithms are not represented well in SymPy, and you're better off using other libraries if that's what you're interested in. 

Aaron Meurer

On Mon, Jan 5, 2015 at 4:34 PM, Sudhanshu Mishra <mrs...@gmail.com> wrote:
Also, it can sometimes be more useful to have a numeric solution than a solution represented in symbolic form.

And that's why we have libraries like scipy/numpy :)

Regards
Sudhanshu Mishra

On Tue, Jan 6, 2015 at 4:20 AM, Luv Agarwal <luvagarw...@gmail.com> wrote:
Also, it can sometimes be more useful to have a numeric solution than a solution represented in symbolic form.

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/33ca1963-260c-499c-a244-b38da6a4ae1a%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.

Luv Agarwal

unread,
Jan 6, 2015, 11:16:42 AM1/6/15
to sy...@googlegroups.com
Thanks for the response :-). I have a few questions as follows:
  1. In GSoC last year there was a project on improvising solvers. I wanted to know how much of that is implemented (the ideas page of this year is not updated yet) as I am interested in working on solvers.
  2. what are the other solvers that need to implemented in this year GSoC and some references to the algorithms that will be used in implementing those solvers.
  3. when will this ideas page be updated.
Regards
Luv Agarwal

--
You received this message because you are subscribed to a topic in the Google Groups "sympy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sympy/SVN6EOBgFeQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sympy+un...@googlegroups.com.

To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.

Sergey Kirpichev

unread,
Jan 6, 2015, 12:03:29 PM1/6/15
to sy...@googlegroups.com
On Tuesday, January 6, 2015 7:16:42 PM UTC+3, Luv Agarwal wrote:
In GSoC last year there was a project on improvising solvers. I wanted to know how much of that is implemented (the ideas page of this year is not updated yet) as I am interested in working on solvers.

Aaron Meurer

unread,
Jan 6, 2015, 4:07:49 PM1/6/15
to sy...@googlegroups.com, Harsh Gupta
On Tue, Jan 6, 2015 at 9:16 AM, Luv Agarwal <luvagarw...@gmail.com> wrote:
Thanks for the response :-). I have a few questions as follows:
  1. In GSoC last year there was a project on improvising solvers. I wanted to know how much of that is implemented (the ideas page of this year is not updated yet) as I am interested in working on solvers.
  2. what are the other solvers that need to implemented in this year GSoC and some references to the algorithms that will be used in implementing those solvers.
  3. when will this ideas page be updated.

Harsh, could you update the ideas page? You know better than anyone what still needs to be implemented.

Aaron Meurer
 

Richard Fateman

unread,
Jan 6, 2015, 6:49:58 PM1/6/15
to sy...@googlegroups.com, gupta....@gmail.com
There has been extensive discussion over the years and continuing to today about
what should be done when a computer algebra system is asked to "solve" sometime.
The Maxima system mailing list, Mathematica stackexchange, and years of, well, 
mulling over what to do when (say) there are an infinite set of solutions, or when
the so-called solutions have to be checked, etc.

I don't know whether the GSoC project people studied this, but if not,
there are lots of ideas out there.  some really bad options have been
explored.
RJF

Harsh Gupta

unread,
Jan 7, 2015, 2:48:38 AM1/7/15
to Richard Fateman, sy...@googlegroups.com
> Thanks for the response :-). I have a few questions as follows:
> what are the other solvers that need to implemented in this year GSoC and some references to the algorithms that will be used in implementing those solvers.
> when will this ideas page be updated.
> Regards
> Luv Agarwal

> In GSoC last year there was a project on improvising solvers. I wanted to
> know how much of that is implemented (the ideas page of this year is not
> updated yet) as I am interested in working on solvers.

Great to hear you are interesting in working on solvers. Briefly here's what have been done in the summer:

Instead of making changes in the current `solve` function we rewrote solvers in a new submodule named solveset. Though it borrows ideas and tests from the `solve` submodule.

* `solveset` has a cleaner input and output interface: We now return a set object. For input only takes the equation and the variables for which the equations has to be solved.

* `solveset` can return infinitely many solutions. For example solving for `sin(x) = 0` returns {2⋅n⋅π | n ∊ ℤ} ∪ {2⋅n⋅π + π | n ∊ ℤ} Whereas `solve` only returns [0, π]

* There is a clear code level and interface level separation between solvers for equations in complex domain and equations in real domain. For example solving `exp(x) = 1` when x is complex returns the set of all solutions that is {2⋅n⋅ⅈ⋅π | n ∊ ℤ} . Whereas if x is a real symbol then only {0} is returned.

* There are cases like finding the maxima and minima of function using critical points where it is important to know if it has returned all the solutions. `solve` does not guarantee this. `solveset` fixes that issue.


There had been a lot of discussion during and before the project and you should know why we did what we did. Here are some links:

* My blog for GSoC: http://hargup.github.io/
* solveset pull request as mentioned by Sergey: https://github.com/sympy/sympy/pull/7523

I used to have biweekly gitter meeting with Matthew and Sergey. You can try to dig the gitter archives to have a look at them. Here is the link to the logs of the first meeting https://gitter.im/sympy/sympy/archives/2014/05/07

Here's a brief list of things that needs to be done:
* Implement multivariate solvers for solveset
* Implement more equation solvers for univariate algebraic equations. For example equations solvable by LambertW function
* Build the set infrastructure: This includes implementing complex sets and functions to handle multidimentional ImageSet etc., This part must go hand in hand with the improvements in the solvers as set module can be a universe in itself. Also there can be fundamental limits on the things you can do.

This list might appear small but there is a lot of work that needs to be done which can easily fill up the summer or probably beyond it. This can be fun project but as it is mentioned in the ideas of 2014 it requires a good deal of thought during the application phase.

Richard, I have gone through some of your paper written on solvers in CAS and also used in them solveset. Thanks for them. It would be great if you can also provide us with some curated list of resources on solvers.

Aaron can we support more than one student to work on solvers? As far as I remember there were one or two other students who were also interested in solvers.

Joachim Durchholz

unread,
Jan 7, 2015, 4:11:48 AM1/7/15
to sy...@googlegroups.com
Am 07.01.2015 um 08:48 schrieb Harsh Gupta:
> * `solveset` can return infinitely many solutions. For example solving for
> `sin(x) = 0` returns {2⋅n⋅π | n ∊ ℤ} ∪ {2⋅n⋅π + π | n ∊ ℤ} Whereas `solve`
> only returns [0, π]

Awesome.

Is it able to simplify to {n⋅π | n ∊ ℤ} ?
(Though I guess you don't always want that.)

Is that result a data structure, or a string?
(A data structure would be preferable since it could be used as input
for more activities.)

> * There is a clear code level and interface level separation between
> solvers for equations in complex domain and equations in real domain. For
> example solving `exp(x) = 1` when x is complex returns the set of all
> solutions that is {2⋅n⋅ⅈ⋅π | n ∊ ℤ} . Whereas if x is a real symbol then
> only {0} is returned.

Sweet.

It would be nice if this were extensible to more domains, such as
integers, vectors etc.
I can imagine things like a linear algebra solver that can find the
quaternion that reproduces a given point-to-point mapping. That would
make SymPy useful for the 3D graphics crowd, even application
programmers hit questions like "at what point on his route will A be
able to see B"; the usual graphics engines cannot answer parametrized
questions like that, they need concrete points A and B.

I don't know whether this makes sense with the current architecture, and
I don't have the time nor enough mathematical background to implement
any of this. It would just be a nice enabler if people come along who'd
like to work on a linalg solver. Or a diophantine solver. Or a solver
for whatever other domains are out there (I bet there's a host of them).

Harsh Gupta

unread,
Jan 7, 2015, 6:53:41 AM1/7/15
to sy...@googlegroups.com
> Is that result a data structure, or a string?

It is a pretty printed ImageSet object.

> (A data structure would be preferable since it could be used as input
> for more activities.)

That is an important property and internally `solveset` heavily rely on that.

> Is it able to simplify to {n⋅π | n ∊ ℤ} ?
> (Though I guess you don't always want that.)

No we cannot, I made an attempt at https://github.com/sympy/sympy/pull/7673 but the approach wasn't generalised enough. By the we can simplify a lot of interesection of ImageSets using Diophantine solvers. See https://github.com/sympy/sympy/pull/7587

Sergey Kirpichev

unread,
Jan 7, 2015, 8:49:37 AM1/7/15
to sy...@googlegroups.com, fat...@gmail.com
On Wednesday, January 7, 2015 10:48:38 AM UTC+3, Harsh Gupta wrote:
* There is a clear code level and interface level separation between solvers for equations in complex domain and equations in real domain.

To be fair - this is a very subjective sentence.

The clear advantage is new output format, but even here we still have unresolved issues.
For example: how to represent solutions for equations with parameters,
like a*x**2+b*x+c.  Perhaps, that fits in "Build the set infrastructure" item.

Aaron Meurer

unread,
Jan 14, 2015, 3:00:00 PM1/14/15
to sy...@googlegroups.com
This is a good writeup. It would be great if you could add this or something similar to the GSoC ideas page.

Aaron Meurer

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
Reply all
Reply to author
Forward
0 new messages