Ruud H.G. van Tol on Sun, 20 Nov 2022 16:51:00 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: symbol manipulation |
On 2022-11-20 15:09, Bill Allombert wrote:
On Sun, Nov 20, 2022 at 01:45:26PM +0100, Ruud H.G. van Tol wrote: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)))This does not seem quite right, since this does not depend on k.
In this case the k is only used as an iteration count. Do you mean that in such a case, sum() is not the best function to use? Compare: [sum(k=0, logint(n, 3), 1+logint(3*n\(t*=3),2)) |n<-[1..20]; t<-[1]]
The ultimately desired return value is "logint(x,2)". How feasible/doable is that?It is unclear what purpose this would serve you.
"code lineage". For example to show per call what the inner loop looks like when it would be pre-resolved/inlined.
One trick is to convert functional values to variables this way: ? eval(Str("'logint_",x,"_",2)) %3 = logint_x_2 that you can then add and multiply as needed.
Thanks. -- Ruud