J'ai modifié le script pour faire apparaitre les calculs :
Code : Tout sélectionner
//Fonction étudiée et ses zéros
pair f(pair z) {return z^5-1;}
pair fprime(pair z) {return 5*z^4;}
pair[] racine;
racine[0]=(-0.809,0.588);
racine[1]=(0.309,0.951);
racine[2]=(1,0);
racine[3]=(0.309,-0.951);
racine[4]=(-0.809,-0.588);
//Coloration des solutions
void newton(pair c, pair[] racine, pair f(pair z), pair fprime(pair z), real r, int count=50) {
int i=0;
pair z=c;
do {
++i;
z=z-(f(z)/fprime(z));
write("Re(z)"+string(z.x));
write("Im(z)"+string(z.y));
} while (length(z-racine[0])>r && length(z-racine[1])>r && length(z-racine[2])>r && length(z-racine[3])>r && length(z-racine[4])>r && i<count);
pen p;
real step=0.01;
path sq=scale(step)*unitsquare;
if (length(z-racine[0])<=r) {p=(i/count)*green;
//filldraw(shift(z.x,z.y)*sq,p,p);}
write("z0="+string(length(z)));}
else {
if (length(z-racine[1])<=r){p=(i/count)*red;
//filldraw(shift(z.x,z.y)*sq,p,p);}
write("z1="+string(length(z)));}
else {
if (length(z-racine[2])<=r) {p=(i/count)*blue;
//filldraw(shift(z.x,z.y)*sq,p,p);}
write("z2="+string(length(z)));}
else {
if (length(z-racine[3])<=r) {p=(i/count)*yellow;
//filldraw(shift(z.x,z.y)*sq,p,p);}
write("z3="+string(length(z)));}
else {
if (length(z-racine[4])<=r) {p=(i/count)*orange;
//filldraw(shift(z.x,z.y)*sq,p,p);}
write("z4 = "+string(length(z)));}
else //filldraw(shift(z.x,z.y)*sq,black,black);
write("aucun"+string(length(z)));
}
}
}
}
}
//
real r=0.1;
real step=.01;
real xmin=-1.5, xmax=1.5;
real ymin=-1, ymax=1;
real x=xmin, y=ymin;
int xloop=round((xmax-xmin)/step);
int yloop=round((ymax-ymin)/step);
for(int i=0; i < xloop; ++i) {
for(int j=0; j < yloop; ++j) {
if((x,y)!=(0,0)) {
newton((x,y),racine,f,fprime,r,30);}
y += step;
}
x += step;
y=ymin;
}
J'obtiens :
Code : Tout sélectionner
$asy assai.asy
....
Im(z)-1.23942180300241e-05
aucun30948.5009821438
Re(z)-3.12614582236207e+58
Im(z)-3.90525278483203e+58
essai.asy: 17.7: runtime: Exception en point flottant (core dumped)
puis avec
Code : Tout sélectionner
$ asy
Welcome to Asymptote version 2.00 (to view the manual, type help)
> (-3.13e+58,-3.91e+58)-((-3.13e+58,-3.91e+58)^5-1)/(5*(-3.13e+58,-3.91e+58)^4)
(-nan,-nan)
C'est donc que les nombres sont trop grands ?!
Comment cela se fait-il que le code marche chez Gaétan ?
Maurice