:: DIFF_1 semantic presentation

definition
let f be PartFunc of REAL , REAL ;
let h be real number ;
func Shift c1,c2 -> PartFunc of REAL , REAL means :Def1: :: DIFF_1:def 1
( dom it = (- h) + (dom f) & ( for x being Real st x in (- h) + (dom f) holds
it . x = f . (x + h) ) );
existence
ex b1 being PartFunc of REAL , REAL st
( dom b1 = (- h) + (dom f) & ( for x being Real st x in (- h) + (dom f) holds
b1 . x = f . (x + h) ) )
proof end;
uniqueness
for b1, b2 being PartFunc of REAL , REAL st dom b1 = (- h) + (dom f) & ( for x being Real st x in (- h) + (dom f) holds
b1 . x = f . (x + h) ) & dom b2 = (- h) + (dom f) & ( for x being Real st x in (- h) + (dom f) holds
b2 . x = f . (x + h) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def1 defines Shift DIFF_1:def 1 :
for f being PartFunc of REAL , REAL
for h being real number
for b3 being PartFunc of REAL , REAL holds
( b3 = Shift f,h iff ( dom b3 = (- h) + (dom f) & ( for x being Real st x in (- h) + (dom f) holds
b3 . x = f . (x + h) ) ) );

definition
let f be Function of REAL , REAL ;
let h be real number ;
redefine func Shift as Shift c1,c2 -> Function of REAL , REAL means :Def2: :: DIFF_1:def 2
for x being Real holds it . x = f . (x + h);
coherence
Shift f,h is Function of REAL , REAL
proof end;
compatibility
for b1 being Function of REAL , REAL holds
( b1 = Shift f,h iff for x being Real holds b1 . x = f . (x + h) )
proof end;
end;

:: deftheorem Def2 defines Shift DIFF_1:def 2 :
for f being Function of REAL , REAL
for h being real number
for b3 being Function of REAL , REAL holds
( b3 = Shift f,h iff for x being Real holds b3 . x = f . (x + h) );

definition
let f be PartFunc of REAL , REAL ;
let h be real number ;
func fD c1,c2 -> PartFunc of REAL , REAL equals :: DIFF_1:def 3
(Shift f,h) - f;
coherence
(Shift f,h) - f is PartFunc of REAL , REAL
;
end;

:: deftheorem Def3 defines fD DIFF_1:def 3 :
for f being PartFunc of REAL , REAL
for h being real number holds fD f,h = (Shift f,h) - f;

definition
let f be Function of REAL , REAL ;
let h be real number ;
redefine func fD as fD c1,c2 -> Function of REAL , REAL ;
coherence
fD f,h is Function of REAL , REAL
proof end;
end;

definition
let f be PartFunc of REAL , REAL ;
let h be real number ;
func bD c1,c2 -> PartFunc of REAL , REAL equals :: DIFF_1:def 4
f - (Shift f,(- h));
coherence
f - (Shift f,(- h)) is PartFunc of REAL , REAL
;
end;

:: deftheorem Def4 defines bD DIFF_1:def 4 :
for f being PartFunc of REAL , REAL
for h being real number holds bD f,h = f - (Shift f,(- h));

definition
let f be Function of REAL , REAL ;
let h be real number ;
redefine func bD as bD c1,c2 -> Function of REAL , REAL ;
coherence
bD f,h is Function of REAL , REAL
proof end;
end;

theorem Th1: :: DIFF_1:1
for h being Real
for f being PartFunc of REAL , REAL holds bD f,h = - (fD f,(- h))
proof end;

definition
let f be PartFunc of REAL , REAL ;
let h be real number ;
func cD c1,c2 -> PartFunc of REAL , REAL equals :: DIFF_1:def 5
(Shift f,(h / 2)) - (Shift f,(- (h / 2)));
coherence
(Shift f,(h / 2)) - (Shift f,(- (h / 2))) is PartFunc of REAL , REAL
;
end;

:: deftheorem Def5 defines cD DIFF_1:def 5 :
for f being PartFunc of REAL , REAL
for h being real number holds cD f,h = (Shift f,(h / 2)) - (Shift f,(- (h / 2)));

definition
let f be Function of REAL , REAL ;
let h be real number ;
redefine func cD as cD c1,c2 -> Function of REAL , REAL ;
coherence
cD f,h is Function of REAL , REAL
proof end;
end;

definition
let f be PartFunc of REAL , REAL ;
let h be real number ;
func forward_difference c1,c2 -> Functional_Sequence of REAL , REAL means :Def6: :: DIFF_1:def 6
( it . 0 = f & ( for n being Element of NAT holds it . (n + 1) = fD (it . n),h ) );
existence
ex b1 being Functional_Sequence of REAL , REAL st
( b1 . 0 = f & ( for n being Element of NAT holds b1 . (n + 1) = fD (b1 . n),h ) )
proof end;
uniqueness
for b1, b2 being Functional_Sequence of REAL , REAL st b1 . 0 = f & ( for n being Element of NAT holds b1 . (n + 1) = fD (b1 . n),h ) & b2 . 0 = f & ( for n being Element of NAT holds b2 . (n + 1) = fD (b2 . n),h ) holds
b1 = b2
proof end;
end;

:: deftheorem Def6 defines forward_difference DIFF_1:def 6 :
for f being PartFunc of REAL , REAL
for h being real number
for b3 being Functional_Sequence of REAL , REAL holds
( b3 = forward_difference f,h iff ( b3 . 0 = f & ( for n being Element of NAT holds b3 . (n + 1) = fD (b3 . n),h ) ) );

notation
let f be PartFunc of REAL , REAL ;
let h be real number ;
synonym fdif c1,c2 for forward_difference c1,c2;
end;

Lemma65: for h being Real
for f being Function of REAL , REAL holds fD f,h is Function of REAL , REAL
;

theorem Th2: :: DIFF_1:2
for h being Real
for f being Function of REAL , REAL
for n being Element of NAT holds (fdif f,h) . n is Function of REAL , REAL
proof end;

theorem Th3: :: DIFF_1:3
for h being Real
for f being Function of REAL , REAL
for x being Real holds (fD f,h) . x = (f . (x + h)) - (f . x)
proof end;

theorem Th4: :: DIFF_1:4
for h being Real
for f being Function of REAL , REAL
for x being Real holds (bD f,h) . x = (f . x) - (f . (x - h))
proof end;

theorem Th5: :: DIFF_1:5
for h being Real
for f being Function of REAL , REAL
for x being Real holds (cD f,h) . x = (f . (x + (h / 2))) - (f . (x - (h / 2)))
proof end;

theorem Th6: :: DIFF_1:6
for n being Element of NAT
for h being Real
for f being Function of REAL , REAL st f is constant holds
for x being Real holds ((fdif f,h) . (n + 1)) . x = 0
proof end;

theorem Th7: :: DIFF_1:7
for n being Element of NAT
for r, h, x being Real
for f being Function of REAL , REAL holds ((fdif (r (#) f),h) . (n + 1)) . x = r * (((fdif f,h) . (n + 1)) . x)
proof end;

theorem Th8: :: DIFF_1:8
for n being Element of NAT
for h, x being Real
for f1, f2 being Function of REAL , REAL holds ((fdif (f1 + f2),h) . (n + 1)) . x = (((fdif f1,h) . (n + 1)) . x) + (((fdif f2,h) . (n + 1)) . x)
proof end;

theorem Th9: :: DIFF_1:9
for n being Element of NAT
for h, x being Real
for f1, f2 being Function of REAL , REAL holds ((fdif (f1 - f2),h) . (n + 1)) . x = (((fdif f1,h) . (n + 1)) . x) - (((fdif f2,h) . (n + 1)) . x)
proof end;

theorem Th10: :: DIFF_1:10
for n being Element of NAT
for r1, r2, h being Real
for f, f1, f2 being Function of REAL , REAL st f = (r1 (#) f1) + (r2 (#) f2) holds
for x being Real holds ((fdif f,h) . (n + 1)) . x = (r1 * (((fdif f1,h) . (n + 1)) . x)) + (r2 * (((fdif f2,h) . (n + 1)) . x))
proof end;

theorem Th11: :: DIFF_1:11
for h being Real
for f being Function of REAL , REAL
for x being Real holds ((fdif f,h) . 1) . x = ((Shift f,h) . x) - (f . x)
proof end;

definition
let f be PartFunc of REAL , REAL ;
let h be real number ;
func backward_difference c1,c2 -> Functional_Sequence of REAL , REAL means :Def7: :: DIFF_1:def 7
( it . 0 = f & ( for n being Element of NAT holds it . (n + 1) = bD (it . n),h ) );
existence
ex b1 being Functional_Sequence of REAL , REAL st
( b1 . 0 = f & ( for n being Element of NAT holds b1 . (n + 1) = bD (b1 . n),h ) )
proof end;
uniqueness
for b1, b2 being Functional_Sequence of REAL , REAL st b1 . 0 = f & ( for n being Element of NAT holds b1 . (n + 1) = bD (b1 . n),h ) & b2 . 0 = f & ( for n being Element of NAT holds b2 . (n + 1) = bD (b2 . n),h ) holds
b1 = b2
proof end;
end;

:: deftheorem Def7 defines backward_difference DIFF_1:def 7 :
for f being PartFunc of REAL , REAL
for h being real number
for b3 being Functional_Sequence of REAL , REAL holds
( b3 = backward_difference f,h iff ( b3 . 0 = f & ( for n being Element of NAT holds b3 . (n + 1) = bD (b3 . n),h ) ) );

notation
let f be PartFunc of REAL , REAL ;
let h be real number ;
synonym bdif c1,c2 for backward_difference c1,c2;
end;

Lemma75: for h being Real
for f being Function of REAL , REAL holds bD f,h is Function of REAL , REAL
;

theorem Th12: :: DIFF_1:12
for h being Real
for f being Function of REAL , REAL
for n being Element of NAT holds (bdif f,h) . n is Function of REAL , REAL
proof end;

theorem Th13: :: DIFF_1:13
for n being Element of NAT
for h being Real
for f being Function of REAL , REAL st f is constant holds
for x being Real holds ((bdif f,h) . (n + 1)) . x = 0
proof end;

theorem Th14: :: DIFF_1:14
for n being Element of NAT
for r, h, x being Real
for f being Function of REAL , REAL holds ((bdif (r (#) f),h) . (n + 1)) . x = r * (((bdif f,h) . (n + 1)) . x)
proof end;

theorem Th15: :: DIFF_1:15
for n being Element of NAT
for h, x being Real
for f1, f2 being Function of REAL , REAL holds ((bdif (f1 + f2),h) . (n + 1)) . x = (((bdif f1,h) . (n + 1)) . x) + (((bdif f2,h) . (n + 1)) . x)
proof end;

theorem Th16: :: DIFF_1:16
for n being Element of NAT
for h, x being Real
for f1, f2 being Function of REAL , REAL holds ((bdif (f1 - f2),h) . (n + 1)) . x = (((bdif f1,h) . (n + 1)) . x) - (((bdif f2,h) . (n + 1)) . x)
proof end;

theorem Th17: :: DIFF_1:17
for n being Element of NAT
for r1, r2, h being Real
for f, f1, f2 being Function of REAL , REAL st f = (r1 (#) f1) + (r2 (#) f2) holds
for x being Real holds ((bdif f,h) . (n + 1)) . x = (r1 * (((bdif f1,h) . (n + 1)) . x)) + (r2 * (((bdif f2,h) . (n + 1)) . x))
proof end;

theorem Th18: :: DIFF_1:18
for h, x being Real
for f being Function of REAL , REAL holds ((bdif f,h) . 1) . x = (f . x) - ((Shift f,(- h)) . x)
proof end;

definition
let f be PartFunc of REAL , REAL ;
let h be real number ;
func central_difference c1,c2 -> Functional_Sequence of REAL , REAL means :Def8: :: DIFF_1:def 8
( it . 0 = f & ( for n being Element of NAT holds it . (n + 1) = cD (it . n),h ) );
existence
ex b1 being Functional_Sequence of REAL , REAL st
( b1 . 0 = f & ( for n being Element of NAT holds b1 . (n + 1) = cD (b1 . n),h ) )
proof end;
uniqueness
for b1, b2 being Functional_Sequence of REAL , REAL st b1 . 0 = f & ( for n being Element of NAT holds b1 . (n + 1) = cD (b1 . n),h ) & b2 . 0 = f & ( for n being Element of NAT holds b2 . (n + 1) = cD (b2 . n),h ) holds
b1 = b2
proof end;
end;

:: deftheorem Def8 defines central_difference DIFF_1:def 8 :
for f being PartFunc of REAL , REAL
for h being real number
for b3 being Functional_Sequence of REAL , REAL holds
( b3 = central_difference f,h iff ( b3 . 0 = f & ( for n being Element of NAT holds b3 . (n + 1) = cD (b3 . n),h ) ) );

notation
let f be PartFunc of REAL , REAL ;
let h be real number ;
synonym cdif c1,c2 for central_difference c1,c2;
end;

Lemma80: for h being Real
for f being Function of REAL , REAL holds cD f,h is Function of REAL , REAL
;

theorem Th19: :: DIFF_1:19
for h being Real
for f being Function of REAL , REAL
for n being Element of NAT holds (cdif f,h) . n is Function of REAL , REAL
proof end;

theorem Th20: :: DIFF_1:20
for n being Element of NAT
for h being Real
for f being Function of REAL , REAL st f is constant holds
for x being Real holds ((cdif f,h) . (n + 1)) . x = 0
proof end;

theorem Th21: :: DIFF_1:21
for n being Element of NAT
for r, h, x being Real
for f being Function of REAL , REAL holds ((cdif (r (#) f),h) . (n + 1)) . x = r * (((cdif f,h) . (n + 1)) . x)
proof end;

theorem Th22: :: DIFF_1:22
for n being Element of NAT
for h, x being Real
for f1, f2 being Function of REAL , REAL holds ((cdif (f1 + f2),h) . (n + 1)) . x = (((cdif f1,h) . (n + 1)) . x) + (((cdif f2,h) . (n + 1)) . x)
proof end;

theorem Th23: :: DIFF_1:23
for n being Element of NAT
for h, x being Real
for f1, f2 being Function of REAL , REAL holds ((cdif (f1 - f2),h) . (n + 1)) . x = (((cdif f1,h) . (n + 1)) . x) - (((cdif f2,h) . (n + 1)) . x)
proof end;

theorem Th24: :: DIFF_1:24
for n being Element of NAT
for r1, r2, h being Real
for f, f1, f2 being Function of REAL , REAL st f = (r1 (#) f1) + (r2 (#) f2) holds
for x being Real holds ((cdif f,h) . (n + 1)) . x = (r1 * (((cdif f1,h) . (n + 1)) . x)) + (r2 * (((cdif f2,h) . (n + 1)) . x))
proof end;

theorem Th25: :: DIFF_1:25
for h, x being Real
for f being Function of REAL , REAL holds ((cdif f,h) . 1) . x = ((Shift f,(h / 2)) . x) - ((Shift f,(- (h / 2))) . x)
proof end;

theorem Th26: :: DIFF_1:26
for n being Element of NAT
for h, x being Real
for f being Function of REAL , REAL holds ((fdif f,h) . n) . x = ((bdif f,h) . n) . (x + (n * h))
proof end;

theorem Th27: :: DIFF_1:27
for n being Element of NAT
for h, x being Real
for f being Function of REAL , REAL holds ((fdif f,h) . (2 * n)) . x = ((cdif f,h) . (2 * n)) . (x + (n * h))
proof end;

theorem Th28: :: DIFF_1:28
for n being Element of NAT
for h, x being Real
for f being Function of REAL , REAL holds ((fdif f,h) . ((2 * n) + 1)) . x = ((cdif f,h) . ((2 * n) + 1)) . ((x + (n * h)) + (h / 2))
proof end;

definition
let f be Function of REAL , REAL ;
let x0 be Real;
let x1 be Real;
func [!c1,c2,c3!] -> Real equals :Def9: :: DIFF_1:def 9
((f . x0) - (f . x1)) / (x0 - x1) if x0 <> x1
;
correctness
coherence
( x0 <> x1 implies ((f . x0) - (f . x1)) / (x0 - x1) is Real )
;
consistency
for b1 being Real holds verum
;
;
end;

:: deftheorem Def9 defines [! DIFF_1:def 9 :
for f being Function of REAL , REAL
for x0, x1 being Real st x0 <> x1 holds
[!f,x0,x1!] = ((f . x0) - (f . x1)) / (x0 - x1);

definition
let x0 be Real, x1 be Real, x2 be Real;
let f be Function of REAL , REAL ;
func [!c4,c1,c2,c3!] -> Real equals :Def10: :: DIFF_1:def 10
([!f,x0,x1!] - [!f,x1,x2!]) / (x0 - x2) if x0 <> x2
;
correctness
coherence
( x0 <> x2 implies ([!f,x0,x1!] - [!f,x1,x2!]) / (x0 - x2) is Real )
;
consistency
for b1 being Real holds verum
;
;
end;

:: deftheorem Def10 defines [! DIFF_1:def 10 :
for x0, x1, x2 being Real
for f being Function of REAL , REAL st x0 <> x2 holds
[!f,x0,x1,x2!] = ([!f,x0,x1!] - [!f,x1,x2!]) / (x0 - x2);

definition
let x0 be Real, x1 be Real, x2 be Real, x3 be Real;
let f be Function of REAL , REAL ;
func [!c5,c1,c2,c3,c4!] -> Real equals :: DIFF_1:def 11
([!f,x0,x1,x2!] - [!f,x1,x2,x3!]) / (x0 - x3) if x0 <> x3
;
correctness
coherence
( x0 <> x3 implies ([!f,x0,x1,x2!] - [!f,x1,x2,x3!]) / (x0 - x3) is Real )
;
consistency
for b1 being Real holds verum
;
;
end;

:: deftheorem Def11 defines [! DIFF_1:def 11 :
for x0, x1, x2, x3 being Real
for f being Function of REAL , REAL st x0 <> x3 holds
[!f,x0,x1,x2,x3!] = ([!f,x0,x1,x2!] - [!f,x1,x2,x3!]) / (x0 - x3);

theorem Th29: :: DIFF_1:29
for x0, x1 being Real
for f being Function of REAL , REAL st x0 <> x1 holds
[!f,x0,x1!] = [!f,x1,x0!]
proof end;

theorem Th30: :: DIFF_1:30
for x0, x1 being Real
for f being Function of REAL , REAL st f is constant & x0 <> x1 holds
[!f,x0,x1!] = 0
proof end;

theorem Th31: :: DIFF_1:31
for x0, x1, r being Real
for f being Function of REAL , REAL st x0 <> x1 holds
[!(r (#) f),x0,x1!] = r * [!f,x0,x1!]
proof end;

theorem Th32: :: DIFF_1:32
for x0, x1 being Real
for f1, f2 being Function of REAL , REAL st x0 <> x1 holds
[!(f1 + f2),x0,x1!] = [!f1,x0,x1!] + [!f2,x0,x1!]
proof end;

theorem Th33: :: DIFF_1:33
for x0, x1, r1, r2 being Real
for f1, f2 being Function of REAL , REAL st x0 <> x1 holds
[!((r1 (#) f1) + (r2 (#) f2)),x0,x1!] = (r1 * [!f1,x0,x1!]) + (r2 * [!f2,x0,x1!])
proof end;

theorem Th34: :: DIFF_1:34
for x0, x1, x2 being Real
for f being Function of REAL , REAL st x0 <> x1 & x0 <> x2 & x1 <> x2 holds
( [!f,x0,x1,x2!] = [!f,x1,x2,x0!] & [!f,x0,x1,x2!] = [!f,x2,x1,x0!] )
proof end;

theorem Th35: :: DIFF_1:35
for x0, x1, x2 being Real
for f being Function of REAL , REAL st x0 <> x1 & x0 <> x2 & x1 <> x2 holds
( [!f,x0,x1,x2!] = [!f,x2,x0,x1!] & [!f,x0,x1,x2!] = [!f,x1,x0,x2!] )
proof end;

theorem Th36: :: DIFF_1:36
for m, n being Element of NAT
for h, x being Real
for f being Function of REAL , REAL holds ((fdif ((fdif f,h) . m),h) . n) . x = ((fdif f,h) . (m + n)) . x
proof end;

definition
let S be Functional_Sequence of REAL , REAL ;
attr a1 is Sequence-yielding means :Def12: :: DIFF_1:def 12
for n being Element of NAT holds S . n is Real_Sequence;
end;

:: deftheorem Def12 defines Sequence-yielding DIFF_1:def 12 :
for S being Functional_Sequence of REAL , REAL holds
( S is Sequence-yielding iff for n being Element of NAT holds S . n is Real_Sequence );

Lemma96: ex S being Functional_Sequence of REAL , REAL st
for n being Element of NAT holds S . n is Real_Sequence
proof end;

registration
cluster Sequence-yielding Functional_Sequence of REAL , REAL ;
existence
ex b1 being Functional_Sequence of REAL , REAL st b1 is Sequence-yielding
proof end;
end;

definition
mode Seq_Sequence is Sequence-yielding Functional_Sequence of REAL , REAL ;
end;

definition
let S be Seq_Sequence;
let n be Element of NAT ;
redefine func . as c1 . c2 -> Real_Sequence;
coherence
S . n is Real_Sequence
by ;
end;

Lemma98: for h, x being Real
for f1, f2 being Function of REAL , REAL holds ((fdif (f1 (#) f2),h) . 1) . x = ((f1 . x) * (((fdif f2,h) . 1) . x)) + ((((fdif f1,h) . 1) . x) * (f2 . (x + h)))
proof end;

theorem Th37: :: DIFF_1:37
for h, x being Real
for f1, f2 being Function of REAL , REAL
for S being Seq_Sequence st ( for n, i being Element of NAT st i <= n holds
(S . n) . i = ((n choose i) * (((fdif f1,h) . i) . x)) * (((fdif f2,h) . (n -' i)) . (x + (i * h))) ) holds
( ((fdif (f1 (#) f2),h) . 1) . x = Sum (S . 1),1 & ((fdif (f1 (#) f2),h) . 2) . x = Sum (S . 2),2 )
proof end;