| 1 | initial version |
Wildcards might help you here. For instance, I got this (not ideal) way to produce what you want:
x,y,t = var('x,y,t')
f = function('f'); g = function('g')
w0 = SR.wild(0); w1 = SR.wild(1)
pattern1 = w0*f(t).diff(t,2)(t = w0); pattern2 = w0*f(t).diff(t,2)(t = -w0)
eqn = f(x*y) + f(x*(1-y)) + f((1-x)*y) + f((1-x)*(1-y)) - f(x) - f(1-x) - f(y) -f(1-y)
eqn2d = eqn.diff(x,y)
eqn2d.subs( pattern1 == g(w0) - f(t).diff(t)(t=w0), pattern2 == g(-w0) + f(t).diff(t)(t=-w0) )
Now obviously it would be nice if Sage could just notice that pattern1 is related to pattern2, but I couldn't get it to work out (maybe someone better at Sage can?). It is worth noting that I also tried using
pattern = f(t).diff(t)(t = w0) + w0*f(t).diff(t,2)(t = w0)
but eqn2d seems to have no occurrences of that pattern: eqn2d.has(pattern) returns False. I would be curious to see if anyone has an explanation for this as well.
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.