###############################################################################
#This maple script shows that the integral (6) has the closed fom solution (7)

restart;
with(LinearAlgebra):

# vector field in first order approximation 
uf := u0 + u_x*x + u_y*y;
vf := v0 + v_x*x + v_y*y;

# we consider the line segment S = (x0,y0)->(x1,y1)
x0 := 0;
y0 := 0;

x1 := x0 + r*rx;
y1 := y0 + r*ry;

# we integrate S in the vector field and get the line segment SS = (xx0,yy0)->(xx1,yy1)
xx0 := x0 + al*eval(uf,{x=x0,y=y0});
yy0 := y0 + al*eval(vf,{x=x0,y=y0});

xx1 := x1 + al*eval(uf,{x=x1,y=y1});
yy1 := y1 + al*eval(vf,{x=x1,y=y1});

# we compare the lenth of S and SS: 
hh := factor((xx1-xx0)^2 + (yy1-yy0)^2 - (x1-x0)^2 - (y1-y0)^2);
hhh := limit(hh/(r^2*al),al=0);

# the error is the integration over all directions of S
#err is the integral (6)
err := factor(int((eval(hhh,{rx=cos(t),ry=sin(t)}))^2,t=0..2*Pi))/(2*Pi);

# Frobenius norm of J + J^T
frobeq := factor(
+(u_x + u_x)^2
+(u_y + v_x)^2
+(u_y + v_x)^2
+(v_y + v_y)^2
);

trac := u_x + v_y;

# the constant c = 1/4 in this case
eerr := (1/4)*(frobeq + 2*trac^2);

# we have to show that err=eerr:
factor(err-eerr);
