reserve q,th,r for Real,
  a,b,p for Real,
  w,z for Complex,
  k,l,m,n,n1,n2 for Nat,
  seq,seq1,seq2,cq1 for Complex_Sequence,
  rseq,rseq1,rseq2 for Real_Sequence,
  rr for set,
  hy1 for 0-convergent non-zero Real_Sequence;
reserve d for Real;
reserve th,th1,th2 for Real;

theorem Th62:
  cos is_differentiable_in p & diff(cos,p)=-sin.p
proof
  reconsider p as Element of REAL by XREAL_0:def 1;
  deffunc U(Real) =
  In(- $1* Im((Sum($1*<i> P_dt))* (cos.p+sin.p*<i>)),REAL);
  consider Cr being Function of REAL, REAL such that
A1: for th be Element of REAL holds Cr.th = U(th) from FUNCT_2:sch 4;
 for hy1 holds
  (hy1")(#)(Cr/*hy1) is convergent & lim ((hy1")(#)(Cr/*hy1)) = 0
  proof
    let hy1;
A2: for n holds ((hy1")(#)(Cr/*hy1)).n
    =-Im((Sum((hy1.n)*<i> P_dt))* (cos.p+sin.p*<i>))
    proof
      let n;
A3: n in NAT by ORDINAL1:def 12;
A4:   ((hy1")(#)(Cr/*hy1)).n=(hy1".n)*((Cr/*hy1).n) by SEQ_1:8
        .=(hy1.n)"*((Cr/*hy1).n) by VALUED_1:10;
   dom Cr = REAL by FUNCT_2:def 1;
then    rng hy1 c= dom Cr;
then A5:   ((hy1")(#)(Cr/*hy1)).n
         = (hy1.n)"*(Cr.(hy1.n)) by A4,FUNCT_2:108,A3
        .= (hy1.n)"*U(hy1.n) by A1
        .=-(hy1.n)"*(hy1.n)* Im((Sum((hy1.n)*<i> P_dt))*(cos.p+sin.p*<i>));
hy1.n<>0 by SEQ_1:5;
then
  ((hy1")(#)(Cr/*hy1)).n =-1*Im((Sum((hy1.n)*<i> P_dt))* (cos.p+sin.p*<i>))
      by A5,XCMPLX_0:def 7
        .=-Im((Sum((hy1.n)*<i> P_dt))* (cos.p+sin.p*<i>));
      hence thesis;
    end;
    deffunc U(Real) = -Im((Sum((hy1.$1)*<i> P_dt))*(cos.p+(sin.p)*<i>));
    consider rseq such that
A6: for n holds rseq.n= U(n) from SEQ_1:sch 1;
    deffunc U(Nat) =
    (Sum((hy1.$1)*<i> P_dt))*(cos.p+(sin.p)*<i>);
    consider cq1 such that
A7: for n holds cq1.n=U(n) from COMSEQ_1:sch 1;
A8: for q be Real
   st q>0 holds ex k st for m st k<=m holds |.cq1.m-0c.|<q
    proof
      let q be Real such that
A9:  q>0;
  ex k st for m st k<=m holds |.cq1.m-0c.|<q
      proof
        consider r such that
A10:    r>0 and
A11:    for z being Complex st |.z.|<r holds |.(Sum (z P_dt)).|<q
        by A9,Th57;
    hy1 is convergent & lim(hy1)=0;
        then consider k such that
A12:    for m st k<=m holds |.hy1.m-0.|<r by A10,SEQ_2:def 7;
A13:    now
          let m such that
A14:      k<=m;
A15:      |.cq1.m-0c.|= |.(Sum((hy1.m)*<i> P_dt))* (cos.p+(sin.p)*<i>)
          .| by A7
.= |.(Sum((hy1.m)*<i> P_dt)).|* |.cos.p+(sin.p)*<i>.| by COMPLEX1:65
            .= |.(Sum((hy1.m)*<i> P_dt)).|* |.Sum(p*<i> ExpSeq ).| by Lm3
            .=|.(Sum((hy1.m)*<i> P_dt)).|*1 by Lm5
            .=|.(Sum((hy1.m)*<i> P_dt)).|;
A16:      |.hy1.m-0.|<r by A12,A14;
      (hy1.m)*<i> = 0+(hy1.m)*<i>;
          then       Re
((hy1.m)*<i>)=0 & Im((hy1.m)*<i>)=hy1.m by COMPLEX1:12;
then       |.(hy1.m)*<i>.| =|.hy1.m.| by COMPLEX1:72;
          hence |.cq1.m-0c.|<q by A11,A15,A16;
        end;
        take k;
        thus thesis by A13;
      end;
      hence thesis;
    end;
then A17: cq1 is convergent by COMSEQ_2:def 5;
then  lim(cq1)=0c by A8,COMSEQ_2:def 6;
then A18: lim(-cq1)=-0c by A17,COMSEQ_2:22;
A19: for n being Element of NAT holds Im(-cq1).n= rseq.n
    proof
A20:  for n holds Im(-cq1).n=-Im((Sum((hy1.n)*<i> P_dt))* (cos.p+(sin.p)*<i>))
      proof
        let n;
    Im(-cq1).n=Im((-cq1).n) by COMSEQ_3:def 6
          .=Im(-cq1.n) by VALUED_1:8
          .=Im(-(Sum((hy1.n)*<i> P_dt))* (cos.p+(sin.p)*<i>)) by A7
          .=-Im((Sum((hy1.n)*<i> P_dt))* (cos.p+(sin.p)*<i>))
        by COMPLEX1:17;
        hence thesis;
      end;
      let n;
  rseq.n=-Im((Sum((hy1.n)*<i> P_dt))* (cos.p+(sin.p)*<i>)) by A6;
      hence thesis by A20;
    end;
 for n being Element of NAT holds rseq.n=((hy1")(#)(Cr/*hy1)).n
    proof
      let n be Element of NAT;
  rseq.n=-Im((Sum((hy1.n)*<i> P_dt))* (cos.p+(sin.p)*<i>)) by A6;
      hence thesis by A2;
    end;
then  rseq=(hy1")(#)(Cr/*hy1);
then  (hy1")(#)(Cr/*hy1)=Im(-cq1) by A19;
    hence thesis by A17,A18,COMPLEX1:4,COMSEQ_3:41;
  end;
  then reconsider PR = Cr as RestFunc by FDIFF_1:def 2;
  deffunc U1(Real) = In(-$1*sin.p,REAL);
  consider CL being Function of REAL, REAL such that
A21: for th be Element of REAL holds CL.th= U1(th) from FUNCT_2:sch 4;
 ex r st
for q holds CL.q=r*q
  proof
A22: for q holds CL.q=(-sin.p)*q
    proof
      let q;
      reconsider qq=q as Element of REAL by XREAL_0:def 1;
      CL.qq= U1(q) by A21
        .=(-sin.p)*q;
      hence thesis;
    end;
    take (-sin.p);
    thus thesis by A22;
  end;
  then reconsider PL = CL as LinearFunc by FDIFF_1:def 3;
A23: ex N being Neighbourhood of p st N c= dom cos & for r st r in N holds
  cos.r - cos.p = PL.(r-p) + PR.(r-p)
  proof
A24: for r st r in ].p-1,p+1 .[ holds cos.r - cos.p = PL.(r-p) + PR.(r-p)
    proof
      let r;
A25:   r-p in REAL by XREAL_0:def 1;
  r=p+(r-p);
then   cos.r - cos.p
      =-(r-p)*sin.p -(r-p)*Im((Sum((r-p)*<i> P_dt))* (cos.p+sin.p*<i>))
           by Th59
        .=-(r-p)*sin.p+U(r-p)
        .=-(r-p)*sin.p+Cr.(r-p) by A1,A25
        .=U1(r-p)+Cr.(r-p)
        .=PL.(r-p) + PR.(r-p) by A21,A25;
      hence thesis;
    end;
    take ].p-1,p+1 .[;
    thus thesis by A24,Th24,RCOMP_1:def 6;
  end;
then A26: cos is_differentiable_in p by FDIFF_1:def 4;
 PL.jj= U1(1) by A21
    .=-sin.p;
  hence thesis by A23,A26,FDIFF_1:def 5;
end;
