> On 6/22/2010 10:45 AM, Robert Dodier wrote:
> > On Tue, Jun 22, 2010 at 11:04 AM, Grigory Sarnitskiy
> > wrote:
> >
> >
> >> Imagine I need a function f, such that
> >>
> >> f(a*b) = f(g(a) * g(b))
> >>
> >> I don't want maxima to evaluate it ad infinitum, only n steps
> >>
> >> so if
> >>
> >> n = 1 then f(a*b) = f(g(a) * g(b))
> >> n = 2 then f(a*b) = f(g(g(a)) * g(g(b)))
> >> n = 3 then f(a*b) = f(g(g(g(a))) * g(g(g(b))))
> >>
> >
>
> You want to do a simplification that depends on context without carrying
> along the context.
>
> How about this:
> f(a,b,n):= if n<0 then f(g(a),g(b),n-1);
>
> Here you express the context as an extra argument.
> Think about it this way and see where it goes.
>
>
> RJF
I like the idea, but how do I implement the additivity? For one argument I can use
matchdeclare (sumexp, lambda ([e], not atom(e) and op(e) = "+"))
tellsimp (f (sumexp), map (f, sumexp))
I've tried
tellsimp (f (sumexp, n), map (lambda ([e], f(e, n)), sumexp))$
but it doesn't work.