reserve x,r,a,x0,p for Real;
reserve n,i,m for Element of NAT;
reserve Z for open Subset of REAL;
reserve f,f1,f2 for PartFunc of REAL,REAL;
reserve k for Nat;

theorem
  x in Z implies (diff(r(#)cos,Z).n).x = r*cos.(x + n*PI/2)
proof
  assume
A1: x in Z;
A2: cos is_differentiable_on n, Z by TAYLOR_2:21;
  per cases;
  suppose
    n>0;
    then 0<0+n;
    then 1<=n by NAT_1:19;
    then reconsider i=n-1 as Element of NAT by INT_1:5;
A3: diff(cos,Z ).i is_differentiable_on Z by A2;
    dom (diff(cos,Z ).n) = dom(diff(cos,Z ).(i+1))
      .= dom((diff(cos,Z ).i)`|Z ) by TAYLOR_1:def 5
      .= Z by A3,FDIFF_1:def 7;
    then
A4: x in dom (r (#) diff(cos,Z).n) by A1,VALUED_1:def 5;
    (diff(r(#)cos,Z ).n).x = (r (#) diff(cos,Z).n).x by A2,Th21
      .= r* (diff(cos,Z).n).x by A4,VALUED_1:def 5
      .= r* (cos.(x + n*PI/2)) by A1,Th14;
    hence thesis;
  end;
  suppose
A5: n=0;
A6: dom(r(#) (cos|Z )) = dom(cos|Z) by VALUED_1:def 5
      .= Z by Th1;
    (diff(r(#)cos,Z ).n).x=(r (#) diff(cos,Z ).0).x by A2,A5,Th21
      .=(r (#) (cos|Z)).x by TAYLOR_1:def 5
      .=r*(cos|Z).x by A1,A6,VALUED_1:def 5
      .=r* (cos.(x + n*PI/2)) by A1,A5,FUNCT_1:49;
    hence thesis;
  end;
end;
