Dnia Thu, 08 Sep 2011 23:25:09 -0400, Mario Rodriguez napisa?(a):
> On 09/07/2011 06:41 AM, Adam Majewski wrote:
>> Hi,
>>
>> I'm drawing circle l0 = {z:abs(z)=ER} and its preimages :
>> l1={z1=sqrt(z) }
>> l2={z2:sqrt(z1)}
>> ....
>>
>> Program is below.
>> It works.
>> I can join points with lines only for first circle l0. For its
>> preimages no probably because of bad order of points.
>>
>> Can I order point according to it's argument ?
>
> Yes,
>
> l2_ordered: sort(l2, lambda([z1,z2], is(carg(z1) < carg(z2))))$
Thx for answer. It works, ...
but for long lists it takes time.
Below is a improved ( I hope) version of program.
Can I run it faster ? ( for example sort inside own append function )
TIA
Adam
===========code begin ==========
kill(all);
/* ------------------ definitions ----------------------------*/
f(z,c):=z*z+c;
finverseplus(z):=float(rectform(sqrt(z-c)));
finverseminus(z):=-sqrt(z-c);
/* computes invese image of input points */
GivePreimage(OldList):=
block(
[NewL,NewLP,NewLN],
NewLP:map(finverseplus,OldList), /* positive preimages */
NewLN:map("-",NewLP), /* negative preimages */
NewL:append(NewLP,NewLN) /* output = all preimages as a list */
);
/* t is an angle in turns */
p(t):=radius*%e^(2*%pi*%i*t);
/* ------------------ compilation --------------------------------------
*/
compile(all);
/*------------------ constant values ---------------------------------- */
c:-0.11+0.65569999*%i;
radius:3; /* radius of initial circle */
iMax:100; /* number of points of initial circle */
/* second curve will have 2*iMax = 200 points,
third curve will have 2*2*iMax = 400 points .... */
dt:float(1/iMax); /* step of turn */
/* --------------------- main ------------------------------------------*/
/* point to point method of drawing */
/* compute points of curve and save points to the list */
/* points of initial circle l0={z:abs(z)=radius } */
l0:makelist (i*dt, i, 0, iMax); /* list of turns from 0 to 1 */
l0:map(p,l0); /* list of points of circle of fixed radius */
/* ---------- preimages of circle under fc = equipotential lines
--------------------*/
l1:GivePreimage(l0); /* first preimage */
l2:GivePreimage(l1)$ /* second preimage */
l3:GivePreimage(l2)$
l4:GivePreimage(l3)$
l5:GivePreimage(l4)$
l6:GivePreimage(l5)$
l7:GivePreimage(l6)$
l8:GivePreimage(l7)$
l9:GivePreimage(l8)$
l10:GivePreimage(l9)$
l11:GivePreimage(l10)$
l12:GivePreimage(l11)$
l13:GivePreimage(l12)$
l14:GivePreimage(l13)$
/* preimages :
- tend to Julia set as n increases
- tend to equipotential lines as ER tends to infinity */
/*--- order point according to it's argument to join them by lines --*/
/* thx to Mario Rodriguez */
l1: sort(l1, lambda([z1,z2], is(carg(z1) < carg(z2))))$
l2: sort(l2, lambda([z1,z2], is(carg(z1) < carg(z2))))$
l3: sort(l3, lambda([z1,z2], is(carg(z1) < carg(z2))))$
l4: sort(l4, lambda([z1,z2], is(carg(z1) < carg(z2))))$
l5: sort(l5, lambda([z1,z2], is(carg(z1) < carg(z2))))$
l6: sort(l6, lambda([z1,z2], is(carg(z1) < carg(z2))))$
l7: sort(l7, lambda([z1,z2], is(carg(z1) < carg(z2))))$
l8: sort(l8, lambda([z1,z2], is(carg(z1) < carg(z2))))$
l9: sort(l9, lambda([z1,z2], is(carg(z1) < carg(z2))))$
l10: sort(l10, lambda([z1,z2], is(carg(z1) < carg(z2))))$
l11: sort(l11, lambda([z1,z2], is(carg(z1) < carg(z2))))$
l12: sort(l12, lambda([z1,z2], is(carg(z1) < carg(z2))))$
l13: sort(l13, lambda([z1,z2], is(carg(z1) < carg(z2))))$
l14: sort(l14, lambda([z1,z2], is(carg(z1) < carg(z2))))$
/*----------------------- draw -----------------------------------*/
load(draw);
draw2d(
terminal = 'screen,
title= "Level curves of escape time for fc(z)=z*z+c made usung IIM ",
key = "LC0",
xlabel = "re ",
ylabel = "im",
points_joined = true,
point_type = dot,
point_size = 5,
color = green,
points(map(realpart, l0),map(imagpart, l0)),
color = black,
key = "LC1",
points(map(realpart, l1),map(imagpart, l1)),
key = "LC2",
points(map(realpart, l2),map(imagpart, l2)),
key = "LC3",
points(map(realpart, l3),map(imagpart, l3)),
key = "LC4",
points(map(realpart, l4),map(imagpart, l4)),
key = "LC5",
points(map(realpart, l5),map(imagpart, l5)),
color = red,
color = red,
key = "LC14",
points(map(realpart, l14),map(imagpart, l14))
);
========== code end =============