Farey sequence



Barton Willis a ?crit :
> -----maxima-bounces at math.utexas.edu wrote: -----
>
>   
>> I have found :
>>     
>
>   
>> http://magma.maths.usyd.edu.au/magma/Examples/node6.html
>>     
>
> A Maxima implementation of the third method is 
>
>   ff(n) := setify(xreduce('append, makelist(makelist(i/j,i,0,j), j,1, n)));
>
> I can think of ways that might speed this up--say n = 10. Then the inner makelist
> could skip j = 2 and j = 5, for example. But then the code would no longer be a
> one-liner :(
>   
One way to speed it up is to notice that   i/j = 2i/2j  hence you may 
keep only the j>n/2 ; this should be 25% faster.

ff2(n) := setify(xreduce('append, makelist(makelist(i/j,i,0,j), j,floor(n/2), n)));

My 2c.

Eric
> --Barton
>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>