New methods to solve symbolic equations

128 views
Skip to first unread message

Harsh Gupta

unread,
Aug 6, 2015, 8:18:09 AM8/6/15
to sy...@googlegroups.com
Recently we implemented a ConditionSet [1] object which abstractly represents a set of elements satisfying a particular condition taken from another set S:

{x|Cond(x) is True for x in S}

ConditionSet gives us the ability to represent unevaluated equations and inequalities in forms like `{x|f(x)=0; x in S}` and `{x|f(x)>0; x in S}` but a more powerful thing about ConditionSet is that it allows us to write the intermediate steps as set to set transformation. Some of the transformations are:


Composition: `{x|f(g(x))=0;x in S} => {x|g(x)=y; x in S,y in {z|f(z)=0; z in S}}`

Polynomial Solver: `{x|P(x)=0;x in S} => {x_1,x_2, ... ,x_n}.intersection(S)` where `x_i` are roots of P(x)

Invert solver: `{x|f(x)=0;x in S} => {g(0)| all g such that f(g(x)) = x}`

logcombine: `{x| log(f(x)) + log(g(x));x in S}` => `{x| log(f(x)*g(x)); x in S}`  if f(x) > 0 and g(x) > 0
                                              => `{x| log(f(x)) + log(g(x));x in S}` otherwise
product solve: {x|f(x)*g(x)=0; x in S} => `{x|f(x)=0; x in S} U {x|g(x)=0; x in S}` given f(x) and g(x) are bounded
                                       => {x|f(x)*g(x)=0; x in S}


Since the output type is same as input type any composition of these transformations is also a valid transformation. And our aim is to find the right sequence of compositions (given the atoms) which transforms the given condition set to a set which is not a condition set i.e., FiniteSet, Interval, Set of Integers and their Union, Intersection, Complement or ImageSet [2]. We can assign a cost function to each set, such that, more desirable that form of set is to us, the less the value of cost function. This way our problem is now reduced to finding the path from the initial ConditionSet to of the lowest valued set on a graph where the atomic transformations forms the edges. I'm hoping this is a well-studied problem and someone on this mailing list can redirect us to existing literature.

Another good thing about this method is that we will be able to log and output the intermediate steps required to reach the final solution. These step-by-step solutions should be helpful in teaching and also to verify the final solution is correct or not.

Please lets us know what do think about this new proposed method.

[2]: ImageSet is abstract class in SymPy to represent sets like {f(x)| x in S} 

Shekhar Prasad Rajak

unread,
Mar 19, 2016, 1:18:11 AM3/19/16
to sympy
Hello,

`ConditionSet` is a better way to represent unevaluated equations.
We can use this in nested unevaluated equations.
I tried to do nested conditonSet :

```
>>> b= ConditionSet(y, And(Eq(y, x**2 -x-5)),S.Reals)
>>> b
⎧                         2         ⎫
⎨y | y ∊ ℝ ∧ y = x  - x - 5⎬
⎩                                    ⎭


>>> ConditionSet(x,b,S.Reals )
# it is not printing this correctly.

```


Can we use this in the system of equations/nested expressions, if sympy can't evaluate them (Is it a good idea)?

--
Shekhar Prasad Rajak
Reply all
Reply to author
Forward
0 new messages