T=[ 0.4 0.5 0.1;
    0.3 0.4 0.3;
    0.3 0.3 0.4];

[M,N]=size(T);

T

D=cake_division(T)

V=T*D'

V_diag=diag(V);

if min(V_diag)>=1/M,
    disp('fair')
else
    disp('error: not fair')
end;
    
if max(V_diag)<=min(V_diag)+10^(-6),
    disp('equitable')
else
    disp('error: not equitable');
end;

err=0;
for i=1:M,
    if max(V(i,:))>V(i,i)+10^(-6),
        err=1;
    end;
end;
if err==1,
    disp('not envy-free');
else
    disp('envy-free');
end;
    

    