function y = db2(x,Pc1,Pc2,C1,C2,mu1,mu2)

M = inv(C1);
N = inv(C2);
m = mu1;
n = mu2;
K = log(Pc2/Pc1) - log(det(C2)/det(C1));

      t3 = N(2,1)*x;
      t4 = M(2,1)*m(1);
      t5 = N(1,2)*n(1);
      t6 = M(2,1)*x;
      t7 = N(1,2)*x;
      t8 = N(2,1)*n(1);
      t9 = N(2,2)*n(2);
      t10 = M(2,2)*m(2);
      t11 = M(1,2)*x;
      t12 = M(1,2)*m(1);
      t13 = pow(N(2,1),2.0);
      t14 = pow(n(1),2.0);
      t16 = x*x;
      t17 = M(2,1)*t16;
      t19 = pow(M(2,1),2.0);
      t27 = N(2,2)*N(1,1);
      t29 = M(2,2)*N(1,1);
      t32 = M(2,2)*M(1,1);
      t34 = pow(m(1),2.0);
      t36 = pow(N(1,2),2.0);
      t39 = pow(M(1,2),2.0);
      t43 = N(2,2)*M(1,1);
      t45 = N(2,2)*M(2,2);
      t46 = pow(m(2),2.0);
      t48 = t13*t14-2.0*t17*N(1,2)-2.0*t19*m(1)*x+2.0*N(1,2)*t14*N(2,1)-2.0*N(1,2)*t16*M(1,2)+2.0*t17*M(1,2)-4.0*t27*t16+4.0*t29*t16+4.0*t29*t14-4.0*t32*t16-4.0*t32*t34-2.0*t36*n(1)*x+t39*t16-2.0*t39*x*m(1)+4.0*t43*t16+4.0*t45*t46;
      t50 = pow(n(2),2.0);
      t56 = N(2,1)*t16;
      t70 = 4.0*t43*t34+4.0*t45*t50-4.0*t27*t14+2.0*M(2,1)*t34*M(1,2)+8.0*N(2,2)*K-2.0*t56*M(1,2)-2.0*t13*x*n(1)+2.0*t56*N(1,2)-2.0*t56*M(2,1)-8.0*M(2,2)*K-8.0*t9*t10+4.0*t9*t11-2.0*t4*t8-4.0*t4*t9-2.0*t5*t12+4.0*t3*t10+2.0*t3*t12;
      t86 = x*n(1);
      t88 = N(2,2)*M(1,2);
      t89 = m(1)*m(2);
      t91 = N(2,2)*M(2,1);
      t92 = x*m(2);
      t94 = -2.0*t4*t5+2.0*t4*t7+2.0*t3*t4-4.0*t3*t5+t36*t16+4.0*t6*t9+2.0*t6*t8+2.0*t7*t12+4.0*t7*t10-2.0*t8*t12+2.0*t8*t11-4.0*t9*t12-4.0*t8*t10+t39*t34+8.0*t27*t86+4.0*t88*t89-4.0*t91*t92;
      t95 = x*m(1);
      t99 = M(2,2)*N(1,2);
      t100 = n(2)*n(1);
      t102 = n(2)*x;
      t105 = M(2,2)*N(2,1);
      t117 = -8.0*t43*t95+4.0*t91*t89+8.0*t32*t95+4.0*t99*t100-4.0*t99*t102-4.0*t4*t11+4.0*t105*t100-8.0*t29*t86-4.0*t105*t102-4.0*t88*t92+t36*t14+t13*t16+2.0*t5*t11-4.0*t5*t10+t19*t34+2.0*t5*t6+t19*t16;
      t120 = sqrt(t48+t70+t94+t117);
      t121 = t3+t4-t5-t6+t7-t8-2.0*t9+2.0*t10-t11+t12-t120;
      t123 = 1/(-N(2,2)+M(2,2))*t121/2;

y=t123;	  