Ĺadny brzuch
Mam pewien problem. Otóż, po skompilowaniu następujacego kodu:
//--------------------------------------------------------------------------- #include <vcl.h> #include <iostream.h> #include <cmath.h> #pragma hdrstop //--------------------------------------------------------------------------- #pragma argsused double f (double x) { return 4*pow(x,4.0)-pow(x,2.0)+5*x-6; } double muller(double xpp, double xp, double xo, double eps)//xi-2, xi-1, xi { double q,xn,A,B,C,dzielnik,pierwiastek; int licznik=0; do { q=(xo-xp)/(xp-xpp); A=q*f(xo)-q*(1+q)*f(xp)+pow(q,2)*f(xpp); B=(2*q+1)*f(xo)- pow((1+q),2.0)*f(xp)+pow(q,2.0)*f(xpp); C=(1+q)*f(xo); //znak podzielnika dobierany jest tak, by jego wartosc bezwzgledna byla janwieksza pierwiastek=pow(pow(B,2.0) - 4*A*C,1.0/2); dzielnik=fabs(B+pierwiastek) > fabs(B-pierwiastek) ? fabs(B+pierwiastek): fabs(B-pierwiastek); //xn=x nastepny (xi+1) xn=xo-(xo-xp)*(2*C/dzielnik); //nastepny krok xpp=xp; xp=xo; xo=xn; licznik++; } while (fabs(xn)>eps); cout<<licznik<<endl; return xn; } void main(void) { cout<<muller(3,5,7,1e-8); while(1); } //---------------------------------------------------------------------------
wywala mi błąd: "pow: DOMAIN error". Co jest nie tak?? I co zrobić, żeby ten program zadziałał??
The pow functions compute x raised to the power y. A domain error occurs if x is finite and negative and y is finite and not an integer value. A domain error may occur if x is zero and y is less than or equal to zero. A range error may occur. ? :)
Po polsku bym prosił. I jak naprawić ten program...
x - musi być wartością integer, nie może być równy zero
y - musi być większy lub równy 0
Nie wiem o co chodzi z tym "x is finite and negative" :P
x jest skonczone i ujemne i y jest skonczone ale nie calkowite? :)
zanotowane.pl doc.pisz.pl pdf.pisz.pl zsf.htw.pl
//--------------------------------------------------------------------------- #include <vcl.h> #include <iostream.h> #include <cmath.h> #pragma hdrstop //--------------------------------------------------------------------------- #pragma argsused double f (double x) { return 4*pow(x,4.0)-pow(x,2.0)+5*x-6; } double muller(double xpp, double xp, double xo, double eps)//xi-2, xi-1, xi { double q,xn,A,B,C,dzielnik,pierwiastek; int licznik=0; do { q=(xo-xp)/(xp-xpp); A=q*f(xo)-q*(1+q)*f(xp)+pow(q,2)*f(xpp); B=(2*q+1)*f(xo)- pow((1+q),2.0)*f(xp)+pow(q,2.0)*f(xpp); C=(1+q)*f(xo); //znak podzielnika dobierany jest tak, by jego wartosc bezwzgledna byla janwieksza pierwiastek=pow(pow(B,2.0) - 4*A*C,1.0/2); dzielnik=fabs(B+pierwiastek) > fabs(B-pierwiastek) ? fabs(B+pierwiastek): fabs(B-pierwiastek); //xn=x nastepny (xi+1) xn=xo-(xo-xp)*(2*C/dzielnik); //nastepny krok xpp=xp; xp=xo; xo=xn; licznik++; } while (fabs(xn)>eps); cout<<licznik<<endl; return xn; } void main(void) { cout<<muller(3,5,7,1e-8); while(1); } //---------------------------------------------------------------------------
wywala mi błąd: "pow: DOMAIN error". Co jest nie tak?? I co zrobić, żeby ten program zadziałał??
The pow functions compute x raised to the power y. A domain error occurs if x is finite and negative and y is finite and not an integer value. A domain error may occur if x is zero and y is less than or equal to zero. A range error may occur. ? :)
Po polsku bym prosił. I jak naprawić ten program...
x - musi być wartością integer, nie może być równy zero
y - musi być większy lub równy 0
Nie wiem o co chodzi z tym "x is finite and negative" :P
x jest skonczone i ujemne i y jest skonczone ale nie calkowite? :)