reserve Z for open Subset of REAL;

theorem Th22:
  for r be Real st r > 0
   ex r1,r2 be Real st r1 >= 0 & r2 >= 0 &
for n be Nat
for x,s be Real st x in ].-r,r.[ & 0 < s & s < 1
holds |.(diff(sin,].-r,r.[).n).(s*x) * x |^ n / (n!).| <= r1 * r2 |^ n / (n!)
  & |.(diff(cos,].-r,r.[).n).(s*x) * x |^ n / (n!).| <= r1 * r2 |^ n / (n!)
proof
  let r be Real such that
A1: r > 0;
  take r1 = 1;
  take r2 = r;
  thus r1 >= 0 & r2 >= 0 by A1;
    let n be Nat;
    let x,s be Real such that
A2: x in ].-r,r.[ and
A3: s > 0 and
A4: s < 1;
    x in ].0-r,0+r.[ by A2;
    then
A5: |.x-0.| < r by RCOMP_1:1;
A6: |.x.| |^ n / (n!) <= r2 |^ n / (n!)
    proof
      defpred P[Nat] means |.x.| |^ $1 / ($1!) <= r2 |^ $1 / ($1!);
A7:   for k be Nat st P[k] holds P[k+1]
      proof
        let k be Nat such that
A8:     P[k];
A9:     |.x.| |^ (k+1) / ((k+1)!) = |.x.| |^ k * |.x.| / ((k+1)!) by
NEWTON:6
          .= |.x.| |^ k * |.x.| / (k! * (k+1)) by NEWTON:15
          .= |.x.| |^ k * (|.x.| / (k! * (k+1))) by XCMPLX_1:74
          .= |.x.| |^ k * (|.x.| / (k!) / (k+1)) by XCMPLX_1:78
          .= |.x.| |^ k * (1 / ((k!) / |.x.|) / (k+1)) by XCMPLX_1:57
          .= |.x.| |^ k * (1 / (k!) * |.x.| / (k+1)) by XCMPLX_1:82
          .= (|.x.| |^ k * (1 / (k!) * |.x.|)) / (k+1) by XCMPLX_1:74
          .= (|.x.| |^ k * (1 / (k!))) * |.x.| / (k+1)
          .= (|.x.| |^ k * 1) / (k!) * |.x.| / (k+1) by XCMPLX_1:74
          .= |.x.| |^ k / (k!) * |.x.| / (k+1);
        |.x.| |^ k / (k!) = |.x |^ k.| / (k!) by Th1
          .= |.x |^ k.| / |.k!.| by ABSVALUE:def 1
          .= |.x |^ k / (k!).| by COMPLEX1:67;
        then
A10:    |.x.| |^ k / (k!) >= 0 by COMPLEX1:46;
A11:    r2 |^ (k+1) / ((k+1)!) = r2 |^ k * r2 / ((k+1)!) by NEWTON:6
          .= r2 |^ k * r2 / (k! * (k+1)) by NEWTON:15
          .= r2 |^ k * (r2 / (k! * (k+1))) by XCMPLX_1:74
          .= r2 |^ k * (r2 / (k!) / (k+1)) by XCMPLX_1:78
          .= r2 |^ k * (1 / ((k!) / r2) / (k+1)) by XCMPLX_1:57
          .= r2 |^ k * (1 / (k!) * r2 / (k+1)) by XCMPLX_1:82
          .= (r2 |^ k * (1 / (k!) * r2)) / (k+1) by XCMPLX_1:74
          .= (r2 |^ k * (1 / (k!))) * r2 / (k+1)
          .= (r2 |^ k * 1) / (k!) * r2 / (k+1) by XCMPLX_1:74
          .= r2 |^ k / (k!) * r2 / (k+1);
        |.x.| >= 0 by COMPLEX1:46;
        then
        |.x.| |^ k / (k!) * |.x.| <= r2 |^ k / (k!) * r2 by A5,A8,A10,
XREAL_1:66;
        hence thesis by A9,A11,XREAL_1:72;
      end;
      |.x.| |^ 0 / (0!) = 1 / (0!) by NEWTON:4
        .= r2 |^ 0 / (0!) by NEWTON:4;
      then
A12:  P[0];
      for i be Nat holds P[i] from NAT_1:sch 2(A12,A7);
      hence thesis;
    end;
    |.x.| >= 0 by COMPLEX1:46;
    then s * |.x.| < 1 * r by A3,A4,A5,XREAL_1:97;
    then |.s.| * |.x.| < r by A3,ABSVALUE:def 1;
    then |.s*x - 0.| < r by COMPLEX1:65;
    then
A13: (s*x) in ].0-r,0+r.[ by RCOMP_1:1;
A14: for k be Nat holds |.(-1) |^ k.| = 1
    proof
      let k be Nat;
      per cases;
      suppose
        k is even;
        then consider j be Nat such that
A15:    k = 2*j by ABIAN:def 2;
        thus |.(-1) |^ k.| = |.((-1) |^ (1+1)) |^ j.| by A15,NEWTON:9
          .= |.((-1) |^ 1 * (-1)) |^ j.| by NEWTON:6
          .= |.((-1) * (-1)) |^ j.|
          .= |.1.|
          .= 1 by ABSVALUE:def 1;
      end;
      suppose
        k is odd;
        then consider j be Nat such that
A16:    k = 2*j+1 by ABIAN:9;
        thus |.(-1) |^ k.| = |.(-1) |^ (2*j) * (-1).| by A16,NEWTON:6
          .= |.((-1) |^ (1+1)) |^ j * (-1).| by NEWTON:9
          .= |.((-1) |^ 1 * (-1)) |^ j * (-1).| by NEWTON:6
          .= |.((-1) * (-1)) |^ j * (-1).|
          .= |.1 * (-1).|
          .= |.1.| by COMPLEX1:52
          .= 1 by ABSVALUE:def 1;
      end;
    end;
A17: |.(diff(sin,].-r,r.[).n).(s*x).| <= r1
    proof
      per cases;
      suppose
        n is even;
        then consider k be Nat such that
A18:    n = 2*k by ABIAN:def 2;
A19:    dom(((-1) |^ k) (#) (sin | ].-r,r.[)) = dom(sin | ].-r,r.[) by
VALUED_1:def 5
          .= ].-r,r.[ by Th17;
A20:    (s*x) in dom(sin | ].-r,r.[) by A13,Th17;
A21:    |.sin (s*x).| <= 1 by SIN_COS:27;
        |.(diff(sin,].-r,r.[).n).(s*x).| = |.((-1) |^ k (#) sin | ].-r
        ,r.[).(s*x).| by A18,Th19
          .= |.((-1) |^ k) * ((sin | ].-r,r.[).(s*x)).| by A13,A19,
VALUED_1:def 5
          .= |.(-1) |^ k.| * |.(sin | ].-r,r.[).(s*x).| by COMPLEX1:65
          .= 1 * |.(sin | ].-r,r.[).(s*x).| by A14
          .= |.sin.(s*x).| by A20,FUNCT_1:47;
        hence thesis by A21,SIN_COS:def 17;
      end;
      suppose
        n is odd;
        then consider k be Nat such that
A22:    n = 2*k+1 by ABIAN:9;
A23:    dom(((-1) |^ k) (#) (cos | ].-r,r.[)) = dom(cos | ].-r,r.[) by
VALUED_1:def 5
          .= ].-r,r.[ by Th17;
A24:    (s*x) in dom(cos | ].-r,r.[) by A13,Th17;
A25:    |.cos (s*x).| <= 1 by SIN_COS:27;
        |.(diff(sin,].-r,r.[).n).(s*x).| = |.((-1) |^ k (#) cos | ].-r
        ,r.[).(s*x).| by A22,Th19
          .= |.((-1) |^ k) * ((cos | ].-r,r.[).(s*x)).| by A13,A23,
VALUED_1:def 5
          .= |.(-1) |^ k.| * |.(cos | ].-r,r.[).(s*x).| by COMPLEX1:65
          .= 1 * |.(cos | ].-r,r.[).(s*x).| by A14
          .= |.cos.(s*x).| by A24,FUNCT_1:47;
        hence thesis by A25,SIN_COS:def 19;
      end;
    end;
A26: |.(diff(cos,].-r,r.[).n).(s*x).| <= r1
    proof
      per cases;
      suppose
        n is even;
        then consider k be Nat such that
A27:    n = 2*k by ABIAN:def 2;
A28:    dom(((-1) |^ k) (#) (cos | ].-r,r.[)) = dom(cos | ].-r,r.[) by
VALUED_1:def 5
          .= ].-r,r.[ by Th17;
A29:    (s*x) in dom(cos | ].-r,r.[) by A13,Th17;
A30:    |.cos (s*x).| <= 1 by SIN_COS:27;
        |.(diff(cos,].-r,r.[).n).(s*x).| = |.((-1) |^ k (#) cos | ].-r
        ,r.[).(s*x).| by A27,Th19
          .= |.((-1) |^ k) * ((cos | ].-r,r.[).(s*x)).| by A13,A28,
VALUED_1:def 5
          .= |.(-1) |^ k.| * |.(cos | ].-r,r.[).(s*x).| by COMPLEX1:65
          .= 1 * |.(cos | ].-r,r.[).(s*x).| by A14
          .= |.cos.(s*x).| by A29,FUNCT_1:47;
        hence thesis by A30,SIN_COS:def 19;
      end;
      suppose
        n is odd;
        then consider k be Nat such that
A31:    n = 2*k+1 by ABIAN:9;
A32:    dom(((-1) |^ (k+1)) (#) (sin | ].-r,r.[)) = dom(sin | ].-r,r.[)
        by VALUED_1:def 5
          .= ].-r,r.[ by Th17;
A33:    (s*x) in dom(sin | ].-r,r.[) by A13,Th17;
A34:    |.sin (s*x).| <= 1 by SIN_COS:27;
        |.(diff(cos,].-r,r.[).n).(s*x).| = |.((-1) |^ (k+1) (#) sin |
        ].-r,r.[).(s*x).| by A31,Th19
          .= |.((-1) |^ (k+1)) * ((sin | ].-r,r.[).(s*x)).| by A13,A32,
VALUED_1:def 5
          .= |.(-1) |^ (k+1).| * |.(sin | ].-r,r.[).(s*x).| by COMPLEX1:65
          .= 1 * |.(sin | ].-r,r.[).(s*x).| by A14
          .= |.sin.(s*x).| by A33,FUNCT_1:47;
        hence thesis by A34,SIN_COS:def 17;
      end;
    end;
A35: |.x |^ n / (n!).| = |.x |^ n.| / |.n!.| by COMPLEX1:67
      .= |.x |^ n.| / (n!) by ABSVALUE:def 1
      .= |.x.| |^ n / (n!) by Th1;
    then
A36: |.x.| |^ n / (n!) >= 0 by COMPLEX1:46;
A37: |.(diff(cos,].-r,r.[).n).(s*x) * x |^ n / (n!).| = |.(diff(cos,].-
    r,r.[).n).(s*x) * (x |^ n / (n!)).| by XCMPLX_1:74
      .= |.(diff(cos,].-r,r.[).n).(s*x).| * |.x |^ n / (n!).| by COMPLEX1:65
      .= |.(diff(cos,].-r,r.[).n).(s*x).| * |.x.| |^ n / (n!) by A35,
XCMPLX_1:74;
A38: |.(diff(sin,].-r,r.[).n).(s*x) * x |^ n / (n!).| = |.(diff(sin,].-
    r,r.[).n).(s*x) * (x |^ n / (n!)).| by XCMPLX_1:74
      .= |.(diff(sin,].-r,r.[).n).(s*x).| * |.x |^ n / (n!).| by COMPLEX1:65
      .= |.(diff(sin,].-r,r.[).n).(s*x).| * |.x.| |^ n / (n!) by A35,
XCMPLX_1:74;
    |.(diff(cos,].-r,r.[).n).(s*x).| >= 0 by COMPLEX1:46;
    then
A39: |.(diff(cos,].-r,r.[).n).(s*x).| * (|.x.| |^ n / (n!)) <= r1*(r2 |^
    n / (n!)) by A36,A26,A6,XREAL_1:66;
    |.(diff(sin,].-r,r.[).n).(s*x).| >= 0 by COMPLEX1:46;
    then
    |.(diff(sin,].-r,r.[).n).(s*x).| * (|.x.| |^ n / (n!)) <= r1*(r2 |^
    n / (n!)) by A36,A17,A6,XREAL_1:66;
    hence
    |.(diff(sin,].-r,r.[).n).(s*x) * x |^ n / (n!).| <= r1*r2 |^ n / (n!
) & |.(diff(cos,].-r,r.[).n).(s*x) * x |^ n / (n!).| <= r1*r2 |^ n / (n!) by
A38,A37,A39,XCMPLX_1:74;
end;
