function babydecouple global m n m=2;n=2; while 1 a = randinseg(0,1); b = randinseg(0,a); phi = randlip(2,2); [lhs, rhs] = babycheck(a,b,phi); v0 = rhs - lhs; v1 = abpoly(a,b,phi); good = abs(v0-v1)<1e-9 if ~good keyboard end end return function v = abpoly(a,b,x) A1 = - x(c2i([0 0])) + x(c2i([1 0])) + 3*x(c2i([0 1])) + x(c2i([1 1])); B1 = x(c2i([0 0])) - x(c2i([1 0])) - 3*x(c2i([0 1])) - x(c2i([1 1])); A2 = x(c2i([0 0])) + x(c2i([1 0])) - x(c2i([0 1])) - x(c2i([1 1])); B2 = - x(c2i([0 0])) - x(c2i([1 0])) + x(c2i([0 1])) + x(c2i([1 1])); %v = a*A1 + b*B1 + a^2*A2 + b^2*B2; mu = a-b; nu = a+b; v = A1*mu + A2*mu*nu; %A1 = - x00 + x10 + 3*x01 + x11 %B1 = x00 - x10 - 3*x01 - x11 %A2 = x00 + x10 - x01 - x11 %B2 = - x00 - x10 + x01 + x11 %d = A1^2 - 4*A2*(B1*b+B2*b^2) % 2 %Out[12]= ((-1 + 2 b) x00 + (3 - 2 b) x01 + x10 + 2 b x10 + x11 - 2 b x11) % %d = (-1 + 2 b) x00 + (3 - 2 b) x01 + x10 + 2 b x10 + x11 - 2 b x11 % a=b % OR % -2 ((-1 + b) x00 - (-3 + b) x01 + x10 + b x10 + x11 - b x11) %Out[15]= ------------------------------------------------------------ % x00 - x01 + x10 - x11 return function [lhs, rhs] = babycheck(a,b,x) lhs = 2 * ( a*x(c2i([0 0])) + (1-a)*x(c2i([0 1])) + b*x(c2i([1 0])) + (1-b)*x(c2i([1 1])) ); rhs = (1+(a-b)) * ((a+b)*(x(c2i([0 0]))+x(c2i([1 0]))) + (2-a-b)*(x(c2i([0 1]))+x(c2i([1 1])))); return function i=c2i(c) global m n dims = repmat(m,[1 n]); i = coord2ind(c+1,dims); return