Karl
Karl

Reputation: 223

Creating a defmatch in maxima

Inspired by the documentation, in particular the part that shows how to write a function that will check if an expression is a definite integral, I'm trying to write some code that will recognise whether an expression is an infinite sum.

matchdeclare(x, atom);
matchdeclare(n, atom);
simp: false;
defmatch (checkinfsum, 'sum (f, n, 1, inf));
'sum(cos(n*x)/n^2,n,1,inf);

returns false and I cannot quite figure out why. Any idea why?

Upvotes: 1

Views: 93

Answers (1)

slitvinov
slitvinov

Reputation: 5768

You are missign matchdeclare(f, all).

matchdeclare(n, atom)$
matchdeclare(f, all)$
defmatch(checkinfsum, 'sum (f, n, 1, inf)), simp = false$
e: 'sum(cos(n*x)/n^2,n,1,inf)$
checkinfsum(e);

returns

                                         cos(n x)
(%o5)                        [n = n, f = --------]
                                             2
                                            n

Upvotes: 1

Related Questions