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
  Z c= dom (ln(#)cosec) implies (ln(#)cosec) is_differentiable_on Z &
  for x st x in Z holds ((ln(#)cosec)`|Z).x = 1/sin.x/x-ln.x*cos.x/(sin.x)^2
proof
  assume
A1: Z c= dom (ln(#)cosec);
  then
A2: Z c= dom ln /\ dom cosec by VALUED_1:def 4;
  then
A3: Z c= dom cosec by XBOOLE_1:18;
A4: 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 A3,RFUNCT_1:3;
    hence thesis by Th2;
  end;
  then for x st x in Z holds cosec is_differentiable_in x;
  then
A5: cosec is_differentiable_on Z by A3,FDIFF_1:9;
A6: Z c= dom ln by A2,XBOOLE_1:18;
A7: for x st x in Z holds x>0
  proof
    let x;
    assume x in Z;
    then x in right_open_halfline(0) by A6,TAYLOR_1:18;
    then ex g being Real st x=g & 0<g by Lm1;
    hence thesis;
  end;
  then for x st x in Z holds ln is_differentiable_in x by TAYLOR_1:18;
  then
A8: ln is_differentiable_on Z by A6,FDIFF_1:9;
A9: for x st x in Z holds diff(ln,x) = 1/x
  proof
    let x;
    assume x in Z;
    then x>0 by A7;
    then x in right_open_halfline(0) by Lm1;
    hence thesis by TAYLOR_1:18;
  end;
  for x st x in Z holds ((ln(#)cosec)`|Z).x = 1/sin.x/x-ln.x*cos.x/(sin.x )^2
  proof
    let x;
    assume
A10: x in Z;
    then
    ((ln(#)cosec)`|Z).x= (cosec.x)*diff(ln,x)+(ln.x)*diff(cosec,x) by A1,A8,A5,
FDIFF_1:21
      .=(cosec.x)*(1/x)+(ln.x)*diff(cosec,x) by A9,A10
      .=(cosec.x)*(1/x)+(ln.x)*(-cos.x/(sin.x)^2) by A4,A10
      .=1/sin.x/x-ln.x*cos.x/(sin.x)^2 by A3,A10,RFUNCT_1:def 2;
    hence thesis;
  end;
  hence thesis by A1,A8,A5,FDIFF_1:21;
end;
