reserve r,x,x0,a,b for Real;
reserve n,m for Element of NAT;
reserve A for non empty closed_interval Subset of REAL;
reserve Z for open Subset of REAL;
reserve f, f1, f2, f3 for PartFunc of REAL, REAL;

theorem Th53:
  (Z c= dom (id Z-tan+sec) & for x st x in Z holds (1+sin.x)<>0 &
  (1-sin.x)<>0) implies (id Z)-tan+sec is_differentiable_on Z & for x st x in Z
  holds ((id Z-tan+sec)`|Z).x = sin.x/(sin.x+1)
proof
  assume that
A1: Z c= dom (id Z-tan+sec) and
A2: for x st x in Z holds 1+sin.x<>0 & 1-sin.x<>0;
A3: Z c= dom (id Z-tan) /\ dom sec by A1,VALUED_1:def 1;
  then
A4: Z c= dom (id Z-tan) by XBOOLE_1:18;
  then
A5: Z c= dom id Z /\ dom tan by VALUED_1:12;
A6: Z c= dom (id Z);
A7: for x st x in Z holds (id Z).x = 1*x+0 by FUNCT_1:18;
  then
A8: (id Z) is_differentiable_on Z by A6,FDIFF_1:23;
A9: Z c= dom tan by A5,XBOOLE_1:18;
  for x st x in Z holds tan is_differentiable_in x
  proof
    let x;
    assume x in Z;
    then cos.x<>0 by A9,FDIFF_8:1;
    hence thesis by FDIFF_7:46;
  end;
  then
A10: tan is_differentiable_on Z by A9,FDIFF_1:9;
  then
A11: id Z-tan is_differentiable_on Z by A4,A8,FDIFF_1:19;
A12: Z c= dom sec by A3,XBOOLE_1:18;
  then
A13: sec is_differentiable_on Z by FDIFF_9:4;
A14: for x st x in Z holds ((id Z - tan)`|Z).x = -(sin.x)^2/(cos.x)^2
  proof
    let x;
    assume
A15: x in Z;
    then
A16: cos.x<>0 by A9,FDIFF_8:1;
    then
A17: (cos.x)^2 >0 by SQUARE_1:12;
    ((id Z - tan)`|Z).x = diff(id Z,x) - diff(tan,x) by A4,A10,A8,A15,
FDIFF_1:19
      .=((id Z)`|Z).x - diff(tan,x) by A8,A15,FDIFF_1:def 7
      .=1-diff(tan,x) by A6,A7,A15,FDIFF_1:23
      .=1-1/(cos.x)^2 by A16,FDIFF_7:46
      .=1-((cos.x)^2+(sin.x)^2)/(cos.x)^2 by SIN_COS:28
      .=1-((cos.x)^2/(cos.x)^2+(sin.x)^2/(cos.x)^2) by XCMPLX_1:62
      .=1-(1+(sin.x)^2/(cos.x)^2) by A17,XCMPLX_1:60
      .=-(sin.x)^2/(cos.x)^2;
    hence thesis;
  end;
  for x st x in Z holds ((id Z-tan+sec)`|Z).x = sin.x/(sin.x+1)
  proof
    let x;
    assume
A18: x in Z;
    then
A19: 1-sin.x<>0 by A2;
    ((id Z-tan+sec)`|Z).x=diff((id Z-tan),x) +diff(sec,x) by A1,A13,A11,A18,
FDIFF_1:18
      .=((id Z-tan)`|Z).x+diff(sec,x) by A11,A18,FDIFF_1:def 7
      .=-(sin.x)^2/(cos.x)^2+diff(sec,x) by A14,A18
      .=-(sin.x)^2/(cos.x)^2+((sec)`|Z).x by A13,A18,FDIFF_1:def 7
      .=-(sin.x)^2/(cos.x)^2+sin.x/(cos.x)^2 by A12,A18,FDIFF_9:4
      .=sin.x/(cos.x)^2-(sin.x)^2/(cos.x)^2
      .=(sin.x-(sin.x)*(sin.x))/(cos.x)^2 by XCMPLX_1:120
      .=(sin.x)*(1-sin.x)/((cos.x)^2+(sin.x)^2-(sin.x)^2)
      .=(sin.x)*(1-sin.x)/(1-(sin.x)^2) by SIN_COS:28
      .=(sin.x)*(1-sin.x)/((1-sin.x)*(1+sin.x))
      .=(sin.x)*(1-sin.x)/(1-sin.x)/(1+sin.x) by XCMPLX_1:78
      .=(sin.x)*((1-sin.x)/(1-sin.x))/(1+sin.x) by XCMPLX_1:74
      .=(sin.x)*1/(1+sin.x) by A19,XCMPLX_1:60
      .=sin.x/(1+sin.x);
    hence thesis;
  end;
  hence thesis by A1,A13,A11,FDIFF_1:18;
end;
