On Apr 5, 2014, at 9:14 AM, Richard Fateman <[email protected]> wrote:
On Saturday, April 5, 2014 12:23:30 AM UTC-7, F. B. wrote: > > > On Thursday, April 3, 2014 5:04:36 PM UTC+2, Aaron Meurer wrote: >> >> Some people on this list might be interested in this >> https://github.com/ContinuumIO/pyalge. >> > > > Indeed, that can be very powerful to symbolic math. > > I don't really like their style of putting the string of the expression > inside the dispatching decorator, but otherwise you can't easily freeze > expressions to an unevaluated state in Python. That's a point in favor of > Julia. > I didn't like that either. I was trying to convince the author not to do it that way. You can easily freeze expressions to unevaluated state by just not evaluating them. > In any case, in SymPy there are wildcards types, so a possible solution: > > x = symbols('x') > w = Wild('w') > > @patterndispatch(sin(w*x), assumptions=Q.positive(w)) > def foo(a): > a**2 > > @patterndispatch(sin(w*x)) > def foo(a): > a**3 > > # there should be a mechanism that understands which one is more specific. > foo(sin(3*x)) # ==> sin(3*x)**2 > foo(sin(-2*x)) # ==> sin(3*x)**3 > > What do you think about this approach? > I don't know about the details, but the "mechansim that understands ..." is computationally infeasible except for trivial cases. I think a (well-defined) heuristic would be fine. Assumedly each function definition would be mathematically correct, so the worst that would happen would be not computing so etching as well as you could. 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 [email protected]. To post to this group, send email to [email protected]. 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/85d52869-f7a3-4832-8d81-e250c9ba5bec%40googlegroups.com<https://groups.google.com/d/msgid/sympy/85d52869-f7a3-4832-8d81-e250c9ba5bec%40googlegroups.com?utm_medium=email&utm_source=footer> . 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 [email protected]. To post to this group, send email to [email protected]. 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/1400257476250452981%40unknownmsgid. For more options, visit https://groups.google.com/d/optout.
