derivative of a Boolean

76 views
Skip to first unread message

Chris Smith

unread,
Sep 19, 2017, 9:19:47 AM9/19/17
to sympy
In PR #13204 I encountered the question of what to do with the derivative if a Boolean. A Boolean is true or false but may contain expressions within relationals, For example, `x**2 < y` depends on x and y but the Boolean value is a "square wave" for this relational. Does a derivative wrt x or y even make sense? Should an error, 0 or something else be done for a return value?

/c

Aaron Meurer

unread,
Sep 19, 2017, 4:25:01 PM9/19/17
to sy...@googlegroups.com
I'm not sure the derivative really makes sense. I would either error
or leave it unevaluated.

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 https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/13fc1fdc-caba-4336-a7df-148efa2f716a%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Alan Bromborsky

unread,
Sep 19, 2017, 5:06:04 PM9/19/17
to sy...@googlegroups.com

Chris Smith

unread,
Sep 20, 2017, 12:57:51 PM9/20/17
to sympy
I will need some help interpreting that. Here's my attempt:

>>> f = eq = ITE(x<1,x,Eq(y,1)).to_nnf(); eq
(xx1)(y=1x<1)
>>> eq.subs(x, 0)
False
>>> eq.subs(x, 1)
y
= 1


I'm not sure how I am supposed to add these mod 2. Maybe `(0 + ITE(Eq(y,1), 1, 0)) % 2`? So does x change the value of f? The answer depends on y, doesn't it? If y is 0 then the value of x doesn't change f but it it is 1 then it does. So is the derivative wrt x `Eq(y, 1)`?

Alan Bromborsky

unread,
Sep 20, 2017, 1:50:22 PM9/20/17
to sy...@googlegroups.com
I afraid I can't help there.  I am good at finding things with google.  This might help, maybe?

http://pyeda.readthedocs.io/en/latest/reference/boolalg/boolfunc.html

Aaron Meurer

unread,
Sep 20, 2017, 2:58:29 PM9/20/17
to sy...@googlegroups.com
The definition given by Alan is the derivative of a boolean function
wrt a boolean variable. In Chris's expression, the variable is real,
not boolean.

Aaron Meurer
> https://groups.google.com/d/msgid/sympy/bb2fbf12-55d8-fcbe-23f6-1406d7cac078%40gmail.com.
Reply all
Reply to author
Forward
0 new messages