I just wonder if there is difference equations support(package) in maxima
Subject: I just wonder if there is difference equations support(package) in maxima
From: Barton Willis
Date: Sun, 22 Feb 2009 06:20:45 -0600
-----maxima-bounces at math.utexas.edu wrote: -----
> Can?I?define?my?own?function?which?has?different?number?of parameters?
Yes, this is possible. The documentation is under ":=" (not so easy to
find):
"When the last or only function argument x_n is a list of one element,
the function defined by := accepts a variable number of
arguments. Actual arguments are assigned one-to-one to formal
arguments x_1, ..., x_(n - 1), and any further actual arguments, if
present, are assigned to x_n as a list."
Example:
(%i27) diff_rec2(exp,i, [n]) := (
n : if n = [] then 1 else first(n),
if integerp(n) and n > -1 then (
while n > 0 do (
exp : sublis([i = i + 1], exp) - exp,
n : n - 1),
exp)
else funmake('diff_rec2, [exp,i,n]))$
(%i29) diff_rec2(f(x),x,1);
(%o29) f(x+1)-f(x)
(%i30) diff_rec2(f(x),x,2);
(%o30) f(x+2)-2*f(x+1)+f(x)
Maybe the function should check that the length of n is 0 or 1:
(%i31) diff_rec2(f(x),x,2,a,b,c);
(%o31) f(x+2)-2*f(x+1)+f(x)
Barton