I need to define a differentiation operator that acts over the indices of the elements x[t] of a time series. It should act this way: B x[t] --> x[t-1].
I have seen here that one can establish the dependency of a symbol over a variable by
depends (for example, depends(b, [R1, R2]);). This would allow to pass a function as an argument to another function. However, this doesn't work for my purpose, since if I want an expression like (1+B)^n involving the operator acting over a term x[t] it won't give the expected result.
Can this kind of operator be defined in maxima?
There isn't anything built-in, but it is possible to get something working via pattern matching rules. (Pattern matching in the sense of expression pattern matching -- stuff like
4*a - bmatchesx + ywithxequal to4*aandyequal to- b.)Here is what I came up with. This defines B as a "backup" operator.
announce_rules_firingis an undocumented Easter egg which can help make it clearer what's going on.Examples. It is assumed
shift_operator.maccontains the preceding stuff.This much is enough to get going -- maybe you can say more about what-all you need to do, and we can think about ways to extend this stuff.