Programmeren in Maple: differentiatieschema

versie 1.0 voor Maple V release 5

G.J. Bex, dept. WNI, Limburgs Universitair Centrum

> deelDiff := proc(x::list,f::list)
option remember;
if nops(x) = 1 then
f[1];
else
(deelDiff(x[2..-1],f[2..-1]) -
deelDiff(x[1..-2],f[1..-2]))/(x[-1] - x[1]);
fi;
end:

> deelDiff([seq(x[i],i=1..5)],[seq(f[i],i=1..5)]);

[Maple Math]

> diffSchema := proc(x::list,f::list)
local S, i, j, k, r;
r := nops(x);
k := r + 1;
S := array(sparse,
[x,
f,
seq([seq(deelDiff(x[j..i+j-2],f[j..i+j-2]),j=1..k+1-i)],
i=3..k)
]);
linalg[transpose](S);
end:

> diffSchema([seq(x[i],i=1..4)],[seq(f[i],i=1..4)]);

[Maple Math]

> A := diffSchema([1,3/2,0,2],[3,13/4,3,5/3]);

[Maple Math]