Ruud H.G. van Tol on Sun, 20 Nov 2022 13:46:34 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

symbol manipulation



I'm looking for a simpler way to investigate how a formula evolves, for formulas with inner loops.

My test-formula:
A071521(n)= my(t=1/3; sum(k=0, logint(n, 3), t*=3; logint(n\t, 2)+1)

{
f(n)=my( t= 1/3
, add_(v1,v2)=  Str("((",v1,")+(",v2,"))")
, mul_(v1,v2)=  Str("((",v1,")*(",v2,"))")
, idiv_(v1,v2)= Str("((",v1,")\\(",v2,"))")
, logint_(v,b)= Str("logint(",v,",",b,")")
, sum_(f,t,s)=  Str("sum(k_=",f,",",t,",",s,")")
, a_(n)= sum_(
    k=0, logint_(n,3), add_(logint_(idiv_(n, (mul_(t,3))), 2), 1))
);
a_(n)
}

my(f_); eval(Str("f_()=",f(2))); f_
%3 = ()->my(f_);sum(k_=0,logint(5,3),((logint(((5)\(((1/3)*(3)))),2))+(1)))

a. I think I'm doing things here that PARI already can do better itself;
b. I want a result with the "superfluous" brackets and operations already resolved; c. Also, it should unloop/inline what sum() does, which is code that I can easily generate if I remain on this path.

All hints welcome.

-- Ruud