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 (cot*(f1+c(#)f2)) & f2=#Z 2 & (for x st x in Z holds f1.x = a
+b*x) implies cot*(f1+c(#)f2) is_differentiable_on Z & for x st x in Z holds ((
  cot*(f1+c(#)f2))`|Z).x = -(b+2*c*x)/(sin.(a+b*x+c*x^2))^2
proof
  assume that
A1: Z c= dom (cot*(f1+c(#)f2)) and
A2: f2=#Z 2 and
A3: for x st x in Z holds f1.x = a+b*x;
  dom (cot*(f1+c(#)f2)) c= dom (f1+c(#)f2) by RELAT_1:25;
  then
A4: Z c= dom (f1+c(#)f2) by A1,XBOOLE_1:1;
  then
A5: (f1+c(#)f2) is_differentiable_on Z by A2,A3,FDIFF_4:12;
  Z c= dom f1 /\ dom (c(#)f2) by A4,VALUED_1:def 1;
  then
A6: Z c= dom (c(#)f2) by XBOOLE_1:18;
A7: for x st x in Z holds sin.((f1+c(#)f2).x)<>0
  proof
    let x;
    assume x in Z;
    then (f1+c(#)f2).x in dom (cos/sin) by A1,FUNCT_1:11;
    hence thesis by Th2;
  end;
A8: for x st x in Z holds cot*(f1+c(#)f2) is_differentiable_in x
  proof
    let x;
    assume
A9: x in Z;
    then sin.((f1+c(#)f2).x)<>0 by A7;
    then
A10: cot is_differentiable_in (f1+c(#)f2).x by FDIFF_7:47;
    (f1+c(#)f2) is_differentiable_in x by A5,A9,FDIFF_1:9;
    hence thesis by A10,FDIFF_2:13;
  end;
  then
A11: cot*(f1+c(#)f2) is_differentiable_on Z by A1,FDIFF_1:9;
  for x st x in Z holds ((cot*(f1+c(#)f2))`|Z).x = -(b+2*c*x)/(sin.(a+b*x
  +c*x^2))^2
  proof
    let x;
    assume
A12: x in Z;
    then
A13: (f1+c(#)f2).x=f1.x+(c(#)f2).x by A4,VALUED_1:def 1
      .=f1.x +c*f2.x by A6,A12,VALUED_1:def 5
      .=a+b*x +c*(f2.x) by A3,A12
      .=a+b*x +c*(x #Z 2) by A2,TAYLOR_1:def 1
      .=a+b*x +c*(x |^2) by PREPOWER:36
      .=a+b*x+c*x^2 by NEWTON:81;
A14: (f1+c(#)f2) is_differentiable_in x by A5,A12,FDIFF_1:9;
A15: sin.((f1+c(#)f2).x)<>0 by A7,A12;
    then cot is_differentiable_in (f1+c(#)f2).x by FDIFF_7:47;
    then
    diff(cot*(f1+c(#)f2),x) = diff(cot, (f1+c(#)f2).x)*diff((f1+c(#)f2),x
    ) by A14,FDIFF_2:13
      .=(-1/(sin.((f1+c(#)f2).x))^2)*diff((f1+c(#)f2),x) by A15,FDIFF_7:47
      .=-diff((f1+c(#)f2),x)/(sin.(a+b*x+c*x^2))^2 by A13
      .=-((f1+c(#)f2)`|Z).x/(sin.(a+b*x+c*x^2))^2 by A5,A12,FDIFF_1:def 7
      .=-(b+2*c*x)/(sin.(a+b*x+c*x^2))^2 by A2,A3,A4,A12,FDIFF_4:12;
    hence thesis by A11,A12,FDIFF_1:def 7;
  end;
  hence thesis by A1,A8,FDIFF_1:9;
end;
