kill(all)$

appendix :maxima :fvm, first order ,finite differenc (central,forward,backward),version 1.0
peter.vlasschaert@gmail.com,20/10/2022

definition : central difference,forward difference,backward difference
-------------------------------------------------------------------------------------------

s1:f(x)=taylor(f(x), x, x0, 2);

with use : substution (=subst), we get truncate "taylor serie"

s1a:subst([x=x],s1);

s2:x-x0=Δx;

s2a:solve(s2,x)[1];

s2b:makelist(at(diff(f(x),x,i),x=x) =diff(f(x),x,i),i,0,2);

s3:subst([s2a],lhs(s1)) =subst([s2],rhs(s1));

s3a:subst([x0=x],s3);

s4:subst([Δx=-Δx],s3a);

→ central difference

s5:s3a-s4;

s5a:solve(s5,at('diff(f(x),x,1),x=x));

use : s2b

s5b:subst(s2b,s5a);

definition : central difference.

s5b1:s5b[1];

error :O(Δx^2) ?,see below how to do calculation.

→ forward difference

use :s3a -f(x)

s6:s3a-f(x);

s6a:lhs(s6/Δx)=expand(ratsimp(rhs(s6/Δx)));

use :s2b

s6b:lhs(s6a) =subst(s2b,rhs(s6a));

s6ba:reverse(s6b);

error :O(Δx)

s6b1:part(rhs(s6b),1);

final result : forward difference

→ approximation : Δx → 0

s6b2:'limit(lhs(s6ba),Δx,0) = rhs(s6ba);

definition : forward difference.

s6b3:ev(s6b2,nouns);

why approximation : Δx → 0, only on the lhs of "s6b2".

→ backward difference

use :f(x)-s4

s7:f(x)-s4;

s7a:lhs(s7)/Δx=expand(ratsimp(rhs(s7)/Δx));

use:s2b

s7b:subst(s2b,s7a);

s7b1:reverse(s7b);

error :O(Δx)

s7c:part(lhs(s7b1),2);

final result : backward difference

→ approximation : Δx → 0

s7c1:'limit(lhs(s7b1),Δx,0) = rhs(s7b1);

definition : backward difference.

s7c2:ev(s7c1,nouns);

why approximation : Δx → 0, only on the lhs of  "s7c2".

---------------------------------------------------------------------------------