Re: Maxima - computing number of components in M-set
- From: Peter Pein <petsie@xxxxxxxxxx>
- Date: Fri, 26 Jan 2007 01:11:22 +0100
adam majewski schrieb:
Hi
I'm trying to compute number of components for given period
of mandelbrot set . See:
http://republika.pl/fraktal/mset_components.html
My code is :
=================
N(p):=
if p=1
then 2^(p-1)
else if primep(p)
then 2^(p-1)-1
else block
(
[d:divisors(p)],
[l:length(d)],
[array[s,l]],
for i:0 thru l-2 step 1 do
block(
s[i]:N(first(d)),
display(s[i]),
d:delete(first(d),d)
),
b:sum(s[j],j,0,l-2),
display(b),
return(2^(p-1)-b)
);
===========================================
It works good for prime numbers or 1, but for composite number it works
only for 4. For 8 it gives 126 but should 120.
I see that line:
b:sum(s[j],j,0,l-2)
does not give proper result, but I don't know why.
Can you tell me why ?
Regards
Adam Majewski
Hi Adam,
It is late in the night in germany and my brain doesn't manage any more
for-loops, indices starting at 0 and deleting elements from sets - sorry.
Therefore I do not understand, why the value of b is wrong, but as long as my
tired eyes are not completely shut, I think your code shall do the same as
N(p):=
if p=1
then 1
else 2^(p-1) - apply("+",map(N,listify(disjoin(p,divisors(p))))) $
does:
map(N,makelist(i,i,1,16));
[1,1,3,6,15,27,63,120,252,495,1023,2010,4095,8127,16365,32640]
Peter
.
- Follow-Ups:
- Re: Maxima - computing number of components in M-set
- From: adam majewski
- Re: Maxima - computing number of components in M-set
- From: Peter Pein
- Re: Maxima - computing number of components in M-set
- References:
- Maxima - computing number of components in M-set
- From: adam majewski
- Maxima - computing number of components in M-set
- Prev by Date: Re: Maxima - computing number of components in M-set
- Next by Date: Re: Maxima - computing number of components in M-set
- Previous by thread: Re: Maxima - computing number of components in M-set
- Next by thread: Re: Maxima - computing number of components in M-set
- Index(es):
Relevant Pages
|
|