reserve y for set,
  x,a,b for Real,
  n for Element of NAT,
  Z for open Subset of REAL,
  f,f1,f2,g for PartFunc of REAL,REAL;

theorem
  Z c= dom ((cos*f)(#)(( #Z n)*sin)) & n>=1 & (for x st x in Z holds f.x
=n*x) implies (cos*f)(#)(( #Z n)*sin) is_differentiable_on Z & for x st x in Z
  holds (((cos*f)(#)(( #Z n)*sin))`|Z).x =n*(sin.x) #Z (n-1) * cos.((n+1)*x)
proof
  assume that
A1: Z c= dom ((cos*f)(#)(( #Z n)*sin)) and
A2: n>=1 and
A3: for x st x in Z holds f.x=n*x;
A4: for x st x in Z holds f.x=n*x+0 by A3;
A5: Z c= dom (cos*f) /\ dom (( #Z n)*sin) by A1,VALUED_1:def 4;
  then
A6: Z c= dom (cos*f) by XBOOLE_1:18;
  then for y being object st y in Z holds y in dom f by FUNCT_1:11;
  then
A7: Z c= dom f;
  then
A8: f is_differentiable_on Z by A4,FDIFF_1:23;
  for x st x in Z holds cos*f is_differentiable_in x
  proof
    let x;
    assume x in Z;
    then
A9: f is_differentiable_in x by A8,FDIFF_1:9;
    cos is_differentiable_in f.x by SIN_COS:63;
    hence thesis by A9,FDIFF_2:13;
  end;
  then
A10: cos*f is_differentiable_on Z by A6,FDIFF_1:9;
A11: for x st x in Z holds ((cos*f)`|Z).x = -n* sin.(n*x)
  proof
    let x;
A12: cos is_differentiable_in f.x by SIN_COS:63;
    assume
A13: x in Z;
    then f is_differentiable_in x by A8,FDIFF_1:9;
    then diff(cos*f,x) = diff(cos, f.x)*diff(f,x) by A12,FDIFF_2:13
      .=(-sin.( f.x))*diff(f,x) by SIN_COS:63
      .=(-sin.(n*x))*diff(f,x) by A3,A13
      .=(-sin.(n*x))*(f`|Z).x by A8,A13,FDIFF_1:def 7
      .=(-sin.(n*x))*n by A7,A4,A13,FDIFF_1:23
      .=-n* sin.(n*x);
    hence thesis by A10,A13,FDIFF_1:def 7;
  end;
A14: Z c= dom (( #Z n)*sin) by A5,XBOOLE_1:18;
  now
    let x;
    assume x in Z;
    sin is_differentiable_in x by SIN_COS:64;
    hence ( #Z n)*sin is_differentiable_in x by TAYLOR_1:3;
  end;
  then
A15: ( #Z n)*sin is_differentiable_on Z by A14,FDIFF_1:9;
A16: for x st x in Z holds ((( #Z n)*sin)`|Z).x =n*((sin.x) #Z (n-1)) *cos.x
  proof
    let x;
    sin is_differentiable_in x by SIN_COS:64;
    then
A17: diff((( #Z n)*sin),x) =(n*((sin.x) #Z (n-1)) * diff(sin,x)) by TAYLOR_1:3
      .=n*((sin.x) #Z (n-1)) *cos.x by SIN_COS:64;
    assume x in Z;
    hence thesis by A15,A17,FDIFF_1:def 7;
  end;
  now
    let x;
A18: n-1 is Element of NAT by A2,NAT_1:21;
    assume
A19: x in Z;
    then
    (((cos*f)(#)(( #Z n)*sin))`|Z).x =(( #Z n)*sin).x*diff(cos*f,x)+(cos*
    f).x*diff((( #Z n)*sin),x) by A1,A10,A15,FDIFF_1:21
      .=(( #Z n).(sin.x))*diff(cos*f,x)+(cos*f).x*diff((( #Z n)*sin),x) by A14
,A19,FUNCT_1:12
      .=((sin.x) #Z n)*diff(cos*f,x)+(cos*f).x*diff((( #Z n)*sin),x) by
TAYLOR_1:def 1
      .=((sin.x) #Z n)*((cos*f)`|Z).x+(cos*f).x*diff((( #Z n)*sin),x) by A10
,A19,FDIFF_1:def 7
      .=((sin.x) #Z n)*(-n* sin.(n*x))+(cos*f).x*diff((( #Z n)*sin),x) by A11
,A19
      .=((sin.x) #Z n)*(-n* sin.(n*x))+(cos.(f.x))*diff((( #Z n)*sin),x) by A6
,A19,FUNCT_1:12
      .=((sin.x) #Z n)*(-n* sin.(n*x))+(cos.(n*x))*diff((( #Z n)*sin),x) by A3
,A19
      .=((sin.x) #Z n)*(-n* sin.(n*x))+(cos.(n*x))*((( #Z n)*sin)`|Z).x by A15
,A19,FDIFF_1:def 7
      .=((sin.x) #Z n)*(-n* sin.(n*x))+ (cos.(n*x))*(n*((sin.x) #Z (n-1)) *
    cos.x) by A16,A19
      .=((sin.x) #Z ((n-1)+1))*(-n* sin.(n*x))+ cos.(n*x)*n*((sin.x) #Z (n-1
    )) *cos.x
      .=(((sin.x) #Z (n-1))*((sin.x) #Z 1))*(-n* sin.(n*x))+ (cos.(n*x)*n*((
    sin.x) #Z (n-1)) *cos.x) by A18,TAYLOR_1:1
      .=(((sin.x) #Z (n-1))*(sin.x))*(-n* sin.(n*x))+ (cos.(n*x)*n*((sin.x)
    #Z (n-1)) *cos.x) by PREPOWER:35
      .= n*((sin.x) #Z (n-1))*(cos.(n*x)*cos.x-sin.x*sin.(n*x))
      .= n*((sin.x) #Z (n-1))*(cos.(x+n*x)) by SIN_COS:74
      .= n*((sin.x) #Z (n-1))*cos.((n+1)*x);
    hence (((cos*f)(#)(( #Z n)*sin))`|Z).x = n*(sin.x) #Z (n-1) *cos.((n+1)*x);
  end;
  hence thesis by A1,A10,A15,FDIFF_1:21;
end;
