Page 1 sur 2
Exception en point flottant (core dumped)
Posté : lun. 28 juin 2010, 15:24
par maurice
Bonjour,
lorsque je compile :
Code : Tout sélectionner
pair f(pair z) {return z^5-1;}
int i=0;
pair z=c;
do {
++i;
z=z-((z^5+1)/(5*z^4));
} while ....
j'obtiens le message d'erreur suivant :
Code : Tout sélectionner
$ asy Newton.asy
Newton.asy: 18.7: runtime: Exception en point flottant (core dumped)
Quelqu'un peut-il m'éclairer sur la signification (et la cause probable) de ce message.
Merci d'avance
Maurice
Re: Exception en point flottant (core dumped)
Posté : lun. 28 juin 2010, 15:26
par GM
Comment veux-tu que l'on teste ????

Re: Exception en point flottant (core dumped)
Posté : lun. 28 juin 2010, 15:27
par OG
Il faudrait le code entier, la variable c n'est pas définie...
Sinon asymptote possède une fonction Newton-Raphson.
A+
O.G.
Re: Exception en point flottant (core dumped)
Posté : lun. 28 juin 2010, 15:30
par maurice
GM a écrit :Comment veux-tu que l'on teste ????

avec ca :
Code : Tout sélectionner
//Méthode de Newton avec Asymptote 1.98
//Fonction étudiée et ses zéros
pair f(pair z) {return z^5-1;}
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), real r, int count=50) {
int i=0;
pair z=c;
do {
++i;
z=z-((z^5+1)/(5*z^4));
} 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(c.x,c.y)*sq,p,p);}
else {
if (length(z-racine[1])<=r){p=(i/count)*red;
filldraw(shift(c.x,c.y)*sq,p,p);}
else {
if (length(z-racine[2])<=r) {p=(i/count)*blue;
filldraw(shift(c.x,c.y)*sq,p,p);}
else {
if (length(z-racine[3])<=r) {p=(i/count)*yellow;
filldraw(shift(c.x,c.y)*sq,p,p);}
else {
if (length(z-racine[4])<=r) {p=(i/count)*orange;
filldraw(shift(c.x,c.y)*sq,p,p);}
else filldraw(shift(c.x,c.y)*sq,black,black);
}
}
}
}
}
//
real r=0.1;
real step=.05;
real xmin=-1, xmax=1;
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,r);}
y += step;
}
x += step;
y=ymin;
}
Brouillon de la méthode de Newton largement inspiré de Philippe Ivaldi :
http://www.piprime.fr/821/Fractals-with-asymptote-fig0080/maurice
Re: Exception en point flottant (core dumped)
Posté : lun. 28 juin 2010, 15:37
par GM
maurice a écrit :avec ca :
... si c'est cela qui a produit l'erreur pour toi, je précise que moi, je n'ai pas d'erreur mais je ne comprends pas ce que je j'obtiens.
Re: Exception en point flottant (core dumped)
Posté : lun. 28 juin 2010, 15:48
par maurice
Il y a une erreur dans le code (c'est un brouillon), il faut remplacer les :
par :
Cela ne marche toujours pas chez moi.
Maurice
Re: Exception en point flottant (core dumped)
Posté : lun. 28 juin 2010, 16:02
par GM
J'obtiens cela (en ayant ajouté un size(5cm)) :

- 2010-06-28_170143.png (3.13 Kio) Vu 12967 fois
C'est ce qu'il faut ?
Pas d'erreur de compilation en tout cas.
Re: Exception en point flottant (core dumped)
Posté : lun. 28 juin 2010, 16:08
par maurice
GM a écrit :J'obtiens cela (en ayant ajouté un size(5cm)) :
C'est ce qu'il faut ?
Pas d'erreur de compilation en tout cas.
Non, pas vraiment, je vais regarder de plus près.
Et toujours une erreur de compilation ici.
Maurice
Re: Exception en point flottant (core dumped)
Posté : lun. 28 juin 2010, 18:58
par maurice
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
Re: Exception en point flottant (core dumped)
Posté : lun. 28 juin 2010, 19:36
par chellier
maurice a écrit :C'est donc que les nombres sont trop grands ?!
Comment cela se fait-il que le code marche chez Gaétan ?
Maurice
Chez moi ça fonctionne bien aussi, pas de problème de nombres trop grands (asymptote 2.00svn)
Christophe