%1 simplex
u=[1 -1];
U=u;
syms x1 x2 t1 t2 positive;
syms J F g real;
x=[x1;x2];t=[t1;t2];
F = x.*t; 
F = F/sum(F);
F=sqrt(F);
J = simple(jacobian(F,[x1 x2]));
JN = J* (sum(x.*t))^(1.5);
g=simplify(U*JN*JN'*U');
dg=simple(det(g));
pretty(dg)

%2 simplex
u1=[1 0 -1];u1=u1/norm(u1);
u2=[0  1  -1];u2=u2/norm(u2);
U=[u1;u2];

syms x1 x2 x3 t1 t2 t3 positive;
syms J F g real;
x=[x1;x2;x3];t=[t1;t2;t3];
F = x.*t; 
F = F/sum(F);
F=sqrt(F);
J = simplify(jacobian(F,[x1 x2 x3]));
JN = J* (sum(x.*t))^(1.5);
dvec= diag(sqrt(x(1:end-1) ./ t(1:end-1))) * 1/sum(t.*x);
JtildeNorm = dvec * U * JN;
g=simplify(U*JN*JN'*U');
g=simple(JtildeNorm * JtildeNorm');
dg=simple(det(g));
pretty(dg)




%3 simplex
u1=[1 -1 0 0];u1=u1/norm(u1);
u2=[0 0 1 -1];u2=u2/norm(u2);
u3=[.5 .5 -.5 -.5];u3=u3/norm(u3);
U=[u1;u3;u2];

syms x1 x2 x3 x4 t1 t2 t3 t4 positive;
syms Phi Phi2 Fs1 Fs2 G G2 real;
x=[x1;x2;x3;x4];t=[t1;t2;t3;t4];
F = x.*t; F=sqrt(F/sum(F));
J = simplify(jacobian(F,[x1 x2 x3 x4]));
JN = 2*J* (sum(x.*t))^(1.5);
g=simplify(U*JN*JN'*U');
g=factor(det(g));
pretty(g)



I=eye(3);
vv=sqrt(t./x) ./ (2*sqrt(sum(t.*x)));
Lambda=diag(vv);
J= (I-t*x'/sum(t.*x)) * Lambda;