reserve n for Nat,
  i for Integer,
  p, x, x0, y for Real,
  q for Rational,
  f for PartFunc of REAL,REAL;

theorem Th28:
  for n be Nat, f be PartFunc of REAL,REAL, Z be Subset
  of REAL st Z c= dom f & f is_differentiable_on n,Z
  for a,b be Real st a < b &
[.a,b.] c=Z & (diff(f,Z).n)|[.a,b.] is continuous & f is_differentiable_on (n+1
), ].a,b.[ holds for l be Real, g be PartFunc of REAL,REAL st dom(g)=[#]REAL &
( for x be Real
  holds g.x = f.a-Partial_Sums(Taylor(f,Z,x,a)).n -l*(a-x) |^ (n+
1) /((n+1)!) ) & f.a-Partial_Sums(Taylor(f,Z,b,a)).n-l*(a-b) |^ (n+1)/((n+1)!)
  =0 holds g is_differentiable_on ].a,b.[ & g.b=0 & g.a=0 & g|[.a,b.] is
continuous & for x be Real st x in ].a,b.[ holds diff(g,x) = -(diff(f,].a,b.[).
  (n+1)).x * (a-x) |^ n /(n!) +l* (a-x) |^ n /((n)!)
proof
  let n be Nat;
  let f be PartFunc of REAL,REAL;
  let Z be Subset of REAL such that
A1: Z c= dom f & f is_differentiable_on n, Z;
  let a,b be Real such that
A2: a < b and
A3: [.a,b.] c=Z and
A4: (diff(f,Z).n)|[.a,b.] is continuous & f is_differentiable_on (n+1),
  ].a,b.[;
  let l be Real;
  consider p be PartFunc of REAL,REAL such that
A5: dom(p)=[#]REAL and
A6: for x be Real holds p.x=l*(a-x) |^ (n+1) /((n+1)!) and
A7: for x be Real holds p is_differentiable_in x & diff(p,x)=-l* (a-x)
  |^ (n) /((n)!) by Lm6;
  consider h be PartFunc of REAL,REAL such that
A8: dom(h)=Z and
A9: for x be Real st x in Z holds h.x=f.a-Partial_Sums(Taylor(f,Z,x,a)) . n and
A10: h.a=0 and
A11: h|[.a,b.] is continuous and
A12: h is_differentiable_on ].a,b.[ and
A13: for x be Real st x in ].a,b.[ holds diff(h,x)=-(diff(f,].a,b.[).(n+
  1 )).x * (a-x) |^ (n) /(n!) by A1,A2,A3,A4,Lm11;
A14: [.a,b.] c= dom h /\ dom p by A3,A8,A5,XBOOLE_1:19;
  let g be PartFunc of REAL,REAL such that
A15: dom(g)=[#]REAL and
A16: for x be Real
   holds g.x=f.a-Partial_Sums(Taylor(f,Z,x,a)).n -l*(a-x)
  |^ (n+1) /((n+1)!) and
A17: f.a-Partial_Sums(Taylor(f,Z,b,a)).n -l*(a-b) |^ (n+1) /((n+1)!) =0;
  set hp=h-p;
A18: dom(hp)=dom(h) /\ dom(p) by VALUED_1:12
    .=Z by A8,A5,XBOOLE_1:28;
A19: for x be object st x in dom(hp) holds hp.x=g.x
  proof
    let x be object such that
A20: x in dom(hp);
    reconsider xx=x as Real by A20;
    thus hp.x=h.xx-p.xx by A20,VALUED_1:13
      .=(f.a-Partial_Sums(Taylor(f,Z,xx,a)).n) -p.xx by A9,A18,A20
      .=(f.a-Partial_Sums(Taylor(f,Z,xx,a)).n) -(l*(a-xx) |^ (n+1)/((n+1)!))
    by A6
      .=g.x by A16;
  end;
  for x be Real st x in REAL holds p is_differentiable_in x by A7;
  then p is_differentiable_on REAL by A5,FDIFF_1:9;
  then p|REAL is continuous by FDIFF_1:25;
  then
A21: p|[.a,b.] is continuous by FCONT_1:16;
  ].a,b.[ c=[.a,b.] by XXREAL_1:25;
  then
A22: ].a,b.[ c= Z by A3,XBOOLE_1:1;
A23: dom(hp)=dom(g) /\ Z by A15,A18,XBOOLE_1:28;
  then
A24: hp|].a,b.[ = (g|Z)|].a,b.[ by A19,FUNCT_1:46
    .= g|].a,b.[ by A22,FUNCT_1:51;
A25: for x be Real st x in ].a,b.[ holds hp is_differentiable_in x & diff(hp
  ,x)=-(diff(f,].a,b.[).(n+1)).x * (a-x) |^ n /(n!) +l* (a-x) |^ n /(n!)
  proof
    let x be Real such that
A26: x in ].a,b.[;
A27: h is_differentiable_in x by A12,A26,FDIFF_1:9;
A28: p is_differentiable_in x by A7;
    hence hp is_differentiable_in x by A27,FDIFF_1:14;
    thus diff(hp,x)=diff(h,x)-diff(p,x) by A27,A28,FDIFF_1:14
      .=-(diff(f,].a,b.[).(n+1)).x * (a-x) |^ (n) /(n!) -diff(p,x) by A13,A26
      .=-(diff(f,].a,b.[).(n+1)).x * (a-x) |^ (n) /(n!) -(-l* (a-x) |^ (n) /
    ((n)!)) by A7
      .=-(diff(f,].a,b.[).(n+1)).x * (a-x) |^ (n) /(n!) +l* (a-x) |^ (n) /((
    n)!);
  end;
  then for x be Real st x in ].a,b.[ holds hp is_differentiable_in x;
  then
A29: hp is_differentiable_on ].a,b.[ by A18,A22,FDIFF_1:9;
  then for x be Real st x in ].a,b.[
   holds hp|].a,b.[ is_differentiable_in x by FDIFF_1:def 6;
  hence
A30: g is_differentiable_on ].a,b.[ by A15,A24,FDIFF_1:def 6;
  thus g.b=0 by A16,A17;
A31: a in [.a,b.] by A2,XXREAL_1:1;
  then g.a=hp.a by A3,A18,A19
    .=h.a-p.a by A3,A18,A31,VALUED_1:13
    .=0-(l*(a-a) |^ (n+1)/((n+1)!)) by A10,A6
    .=0-(l*(0|^ n*0)/((n+1)!)) by NEWTON:6
    .=0;
  hence g.a=0;
  hp|[.a,b.] = (g|Z)|[.a,b.] by A23,A19,FUNCT_1:46
    .= g|[.a,b.] by A3,FUNCT_1:51;
  hence g|[.a,b.] is continuous by A11,A14,A21,FCONT_1:18;
  thus for x be Real st x in ].a,b.[ holds diff(g,x) = -(diff(f,].a,b.[).(n+1)
  ).x * (a-x) |^ n /((n)!)+l* (a-x) |^ n /((n)!)
  proof
    let x be Real such that
A32: x in ].a,b.[;
    thus diff(g,x) = (g`|].a,b.[).x by A30,A32,FDIFF_1:def 7
      .=((g|].a,b.[)`|].a,b.[).x by A30,FDIFF_2:16
      .=(hp`|].a,b.[).x by A24,A29,FDIFF_2:16
      .=diff(hp,x) by A29,A32,FDIFF_1:def 7
      .=-(diff(f,].a,b.[).(n+1)).x * (a-x) |^ (n) /(n!) +l* (a-x) |^ (n) /((
    n)!) by A25,A32;
  end;
end;
