On Tue, Aug 26, 2008 at 12:22 AM, Burcin Erocal <[EMAIL PROTECTED]> wrote:
>
> On Mon, 25 Aug 2008 16:50:43 -0700 (PDT)
> Jason Merrill <[EMAIL PROTECTED]> wrote:
>
>>
>> On Aug 25, 12:50 pm, "William Stein" <[EMAIL PROTECTED]> wrote:
> <snip>
>> >
>> > Burcin -- I did actually mostly implement pattern matching in Pynac.
>> > Some examples:
> <snip examples>
>
>> >             sage: (sin(x)^2 + cos(x)^2).subs(sin(w0)^2+cos(w0)^2==1)
>> >             1
>> >             sage: (1 + sin(x)^2 + cos(x)^2).subs(sin(w0)^2+cos(w0)^2==1)
>> >             sin(x)^2 + cos(x)^2 + 1
>> >             sage: (17*x + sin(x)^2 + cos(x)^2).subs(w1 +
>> > sin(w0)^2+cos(w0)^2 == w1 + 1)
>> >             17*x + 1
>> >             sage: ((x-1)*(sin(x)^2 + cos(x)^2)^2).subs(sin(w0)^2+cos(w0)^2 
>> > == 1)
>> >             x - 1
>>
>> Awesome.  Thanks for making all this happen.  I'm really excited about
>> where Sage is going.  I've only been watching for a couple weeks now,
>> but I think I chose a fun time to find out about it.
>>
>> Is the syntax for this stuff set in stone?  I'm not sure I like the
>> equality inside the subs call.  Equality is reflexive, but
>> substitution is a one way operation.  What about a dictionary, sage: (a
>> +2*b).subs({a+b:x}), or even just a single equal sign, like keyword
>> args, sage: (a+2*b).subs(a+b=x).  The double equals would work too,
>> but now is probably a better time for discussion than later.
>
> I am also in favor of the dictionary and/or keyword arguments (which are
> equivalent from the programming pov). This is also the current
> interface for other subs functions in Sage.
>
> I realized that William had already wrapped these functions right after
> I wrote the message saying I'll get to it soon. Though when I tried
> using them, I expected them to work with keyword arguments, and had to
> look in the docs.
>
> I suggest we change this back to be consistent with the already
> existing objects in Sage.
>
> Comments?

Yes, definitely definitely change subs to take a dictionary and also **args,
just like the current calculus subs!

I think it might be good to leave in an _subs method that
works with relationals as input.  The *only* reason I implemented
something taking relationals as input is that I was simply directly wrapping the
GiNaC api as is, and doing so pretty much in autopilot after about 15 hours
of nonstop coding.  I don't think it's actually a good idea.  That said,
maybe there is some value to at least providing a direct way to use that
function in the "GiNaC way".

 -- William

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to