reserve x,a,b,c for Real,
  n for Nat,
  Z for open Subset of REAL,
  f, f1,f2 for PartFunc of REAL,REAL;

theorem
  not 0 in Z & Z c= dom ((id Z)^(#)cosec) implies ((id Z)^(#)cosec)
  is_differentiable_on Z & for x st x in Z holds (((id Z)^(#)cosec)`|Z).x = -1/
  sin.x/x^2-cos.x/x/(sin.x)^2
proof
  set f = id Z;
  assume that
A1: not 0 in Z and
A2: Z c= dom (f^(#)cosec);
A3: f^ is_differentiable_on Z by A1,FDIFF_5:4;
A4: Z c= dom (f^) /\ dom cosec by A2,VALUED_1:def 4;
  then
A5: Z c= dom cosec by XBOOLE_1:18;
A6: for x st x in Z holds cosec is_differentiable_in x & diff(cosec, x)=-cos
  .x/(sin.x)^2
  proof
    let x;
    assume x in Z;
    then sin.x<>0 by A5,RFUNCT_1:3;
    hence thesis by Th2;
  end;
  then for x st x in Z holds cosec is_differentiable_in x;
  then
A7: cosec is_differentiable_on Z by A5,FDIFF_1:9;
A8: Z c= dom (f^) by A4,XBOOLE_1:18;
  for x st x in Z holds ((f^(#)cosec)`|Z).x = -1/sin.x/x^2-cos.x/x/(sin.x )^2
  proof
    let x;
    assume
A9: x in Z;
    then ((f^(#)cosec)`|Z).x= (cosec.x)*diff(f^,x)+((f^).x)*diff(cosec,x) by A2
,A3,A7,FDIFF_1:21
      .=(cosec.x)*((f^)`|Z).x+((f^).x)*diff(cosec,x) by A3,A9,FDIFF_1:def 7
      .=(cosec.x)*(-1/x^2)+((f^).x)*diff(cosec,x) by A1,A9,FDIFF_5:4
      .=-(cosec.x)*(1/x^2)+((f^).x)*(-cos.x/(sin.x)^2) by A6,A9
      .=-(sin.x)"*(1/x^2)+((f^).x)*((-cos.x)/(sin.x)^2) by A5,A9,RFUNCT_1:def 2
      .=-1/sin.x/x^2+(f.x)"*((-cos.x)/(sin.x)^2) by A8,A9,RFUNCT_1:def 2
      .=-1/sin.x/x^2+(1/x)*((-cos.x)/(sin.x)^2) by A9,FUNCT_1:18
      .=-1/sin.x/x^2+(-cos.x)/x/(sin.x)^2;
    hence thesis;
  end;
  hence thesis by A2,A3,A7,FDIFF_1:21;
end;
