I agree with all of this, as Ondrej noted.  Only, I think your Maple  
example should be something like:
solve(cos(x)=x,x);
                             RootOf(_Z - cos(_Z))

Of course, sinx=-x when x=0.

Aaron Meurer
On May 17, 2009, at 11:49 PM, Ondrej Certik wrote:

>
> Hi,
>
> we were just discussing with Aaron on #sympy IRC what should the
> solve() and dsolve() return. Here is what Mathematica is doing and I
> like that a lot:
>
> solve(whatever) return a list of dicts. You can find lots of  
> examples here:
>
> http://reference.wolfram.com/mathematica/ref/Solve.html
>
> to translate to sympy syntax, use this table:
>
> Mathematica: {a, b, c, d}
> sympy: [a, b, c, d]
>
> Mathematica: {a -> b, c -> d}
> sympy: {a: b, c: d}
>
> So here are some particular examples using sympy syntax:
>
>>>> solve(Eq(x**2, 1), x)
> [{x: 1}, {x: -1}]
>>>> solve(Eq(x**2, 0), x)
> [{x: 0}, {x: 0}]
>
> More tricky is if solve() can't do it, either because sympy can't do
> it, or because it's algebraically not possible. Mathematica returns an
> instance of a Solve() class (talking in sympy language) Like:
>
>>>> solve(Eq(sin(x)+x, 0), x)
> Solve(Eq(sin(x)+x), x)
>
> and it also prints bunch of warnings (that can be suppressed), like:
>
> Solve::tdep: The equations appear to involve the variables to be  
> solved for in
>    an essentially non-algebraic way.
>
> But both me and Aaron like what Maple is doing:
>
>>>> solve(Eq(sin(x)+x, 0), x)
> [RootOf(Eq(sin(x)+x), x, 1)]
>
>
> At least sometimes you know the number of roots (one in the case
> above), so that's why the "1" above. I am not sure currently if even
> the number of roots is unknown. Then I think it should return:
>
>>>> solve(Eq(sin(x)+x, 0), x)
> RootsOf(Eq(sin(x)+x), x)
>
> which could behave like a dictionary. These RootOf and RootsOf classes
> can have some features, e.g. sometimes you know how to do some
> operation on the root (like squaring it), even without having an
> explicit formula for it.
>
>
>
> As to dsolve(), in mathematica it returns a list of dicts, examples:
>
> http://reference.wolfram.com/mathematica/ref/DSolve.html
>
> so in sympy syntax:
>
>>>> dsolve(Eq(y(x).diff(x, 2) + y(x), 0), [y(x)])
> [{y(x): sin(x)}, {y(x): cos(x)}]
>
> sometimes it returns things using integration constants:
>
> [{y(x): C(1)*sin(x) + C(2)*cos(x)}]
>
> You can see from the docs above that Mathematica is returning both
> ways, I am not sure at the moment when it returns what. In any case,
> it's a list of dicts.
>
> Sometimes the solution to the ODE can only be returned in an implicit
> form. Mathematica just calls solve() for the equation and returns
> whatever it returns (see above). So I think we should do the same in
> sympy.
>
> This means changing the behavior of solve() as described above, e.g.
> not returning NotImplementedError() exceptions, but rather RootsOf, or
> a list of RootOf.
>
>
> Before Aaron changes the dsolve() and solve() behavior, do you all
> agree the above is the way to go? If not, let's discuss it. Not that
> it's a backward incompatible change, both in solve() and dsolve(), but
> I think we should do it.
>
> Ondrej
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com
To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to