[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Axiom-developer] [recurrence relation operator] (nouveau)
From: |
kratt6 |
Subject: |
[Axiom-developer] [recurrence relation operator] (nouveau) |
Date: |
Fri, 01 Apr 2005 04:58:07 -0600 |
Changes
http://page.axiom-developer.org/zope/mathaction/RecurrenceRelationOperator/diff
--
Here is a simple implemention of a recurrence relation operator. It is far
from finished, but might serve as a starting point. I experienced the following
difficulties:
- The operator model in Axiom is quite restrictive: all arguments have to be
from the same domain. This leads to problems elsewhere, too. I don't think
that the following can be justified mathematically:
\begin{axiom}
sum(k,k=1.0..2.5)
\end{axiom}
- dummy variables are only supported in a very limited fashion: for the
recurrence relation operator it would be good to have also "dummy
operators"...
Things to
do:
- a proper operation analogous to 'sum', 'rootOf' or the like needs to be
written.
The operation 'evalRec' is just for a start
- evalRec needs to be speeded up
\begin{axiom}
)abbrev package RECOP RecurrenceOperator
RecurrenceOperator(R, F): Exports == Implementation where
R: Join(OrderedSet, IntegralDomain, RetractableTo Integer)
F: FunctionSpace R
Exports == with
evalRec: (BasicOperator, Symbol, F, F, F, List F) -> F
Implementation == add
ddrec: List F -> OutputForm
ddrec l ==
k := kernels(l.4)
op := operator(k.1)::OutputForm
values := reverse l
vals: List OutputForm
:= cons(elt(op, [(l.3)::OutputForm]) = eval(l.1, l.2,
l.3)::OutputForm,
[elt(op, [i::OutputForm]) = (values.i)::OutputForm
for i in 1..#values-4])
bracket(hconcat([operator(k.1)(l.3)::OutputForm,
": ",
commaSeparate vals]))
oprecur := operator("rootOfRec"::Symbol)$BasicOperator
setProperty(oprecur, "%specialDisp",
ddrec@(List F -> OutputForm) pretend None)
setProperty(oprecur, "%dummyVar", 2 pretend None)
-- this implies that the second and third arguments of oprecur are dummy
-- variables and affects tower$ES:
-- the second argument will not appear in tower$ES, if it does not appear in
-- any argument but the first and second.
-- the third argument will not appear in tower$ES, if it does not appear in any
-- other argument. (%defsum is a good example)
-- The arguments of rootOfRec are as follows:
-- 1. next, i.e., f(dummy+1)
-- 2. dummy
-- 3. variable, i.e., for display
-- 4. operatorname(argument)
-- 5.- values in reversed order
-- maybe "values" should be preceded by the index of the first given
-- value. Currently, the last value is interpreted as f(1)
evalRec (op, argsym, argdisp, arg, next, values) ==
if ((n := retractIfCan(arg)@Union(Integer, "failed")) case "failed")
or (n < 1)
then
kernel(oprecur,
append([next, argsym::F, argdisp, op(arg)], values))
else
len := #values
if n <= len
then values.(len-n+1)
else
nextval := eval(next, argsym::F, (len+1)::F)
newval := eval(nextval, op,
evalRec(op, argsym, argdisp, #1, next, values))
evalRec(op, argsym, argdisp, arg, next, cons(newval, values))
irecur: List F -> F
-- This is just a wrapper that allows us to write a recurrence relation as an
-- operator.
irecur l ==
k := kernels(l.4)
evalRec(operator(k.1),
retract(l.2)@Symbol, l.3,
argument(k.1).1, l.1, rest(l, 4))
evaluate(oprecur, irecur)$BasicOperatorFunctions1(F)
\end{axiom}
Here is an example:
\begin{axiom}
argsym := new()$Symbol;
argexp := argsym::Expression Integer;
op := operator new()$Symbol;
ne := elt(op, argexp - 1) + elt(op, argexp - 2::Expression Integer);
r:=evalRec(op, argsym, a::Expression Integer, a::Expression Integer, ne, [1,1])
$RecurrenceOperator(Integer, Expression Integer)
eval(r, a=7)
\end{axiom}
--
forwarded from http://page.axiom-developer.org/zope/mathaction/address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Axiom-developer] [recurrence relation operator] (nouveau),
kratt6 <=