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 Th37:
  (Z c= dom (tan+sec) & for x st x in Z holds (1+sin.x)<>0 & (1-
sin.x)<>0) implies tan+sec is_differentiable_on Z & for x st x in Z holds ((tan
  +sec)`|Z).x = 1/(1-sin.x)
proof
  assume that
A1: Z c= dom (tan+sec) and
A2: for x st x in Z holds 1+sin.x<>0 & 1-sin.x<>0;
  Z c= dom tan /\ dom (cos^) by A1,VALUED_1:def 1;
  then
A3: Z c= dom tan by XBOOLE_1:18;
  then
A4: for x st x in Z holds cos.x<>0 by FDIFF_8:1;
  then
A5: cos^ is_differentiable_on Z by FDIFF_4:39;
  for x st x in Z holds tan is_differentiable_in x
  proof
    let x;
    assume x in Z;
    then cos.x<>0 by A3,FDIFF_8:1;
    hence thesis by FDIFF_7:46;
  end;
  then
A6: tan is_differentiable_on Z by A3,FDIFF_1:9;
  for x st x in Z holds ((tan+sec)`|Z).x = 1/(1-sin.x)
  proof
    let x;
    assume
A7: x in Z;
    then
A8: cos.x<>0 by A3,FDIFF_8:1;
A9: 1+sin.x<>0 by A2,A7;
    ((tan+sec)`|Z).x = diff(tan,x) + diff(cos^,x) by A1,A5,A6,A7,FDIFF_1:18
      .=1/(cos.x)^2 + diff(cos^,x) by A8,FDIFF_7:46
      .=1/(cos.x)^2 + ((cos^)`|Z).x by A5,A7,FDIFF_1:def 7
      .=1/(cos.x)^2 + sin.x/(cos.x)^2 by A4,A7,FDIFF_4:39
      .=(1+sin.x)/((cos.x)^2+(sin.x)^2-(sin.x)^2) by XCMPLX_1:62
      .=(1+sin.x)/(1-(sin.x)^2) by SIN_COS:28
      .=(1+sin.x)/((1+sin.x)*(1-sin.x))
      .=(1+sin.x)/(1+sin.x)/(1-sin.x) by XCMPLX_1:78
      .=1/(1-sin.x) by A9,XCMPLX_1:60;
    hence thesis;
  end;
  hence thesis by A1,A5,A6,FDIFF_1:18;
end;
