我无法让该程序通过公式评估一系列值。
范围 = (-3.0,4.0) 公式 = (9(x^3)-27(x^2)-4x+12) / (sqrt(3(x^2)+1) + abs(5-(x^ 4)))
程序打印出y as -1.IND
任何有助于阐明为什么所有 y 都会出现的任何帮助都值得-1.IND
赞赏。
谢谢,戴夫
#include <iostream>
#include <cmath>
using namespace std;
int main() {
cout << "This program outputs formula results\n";
long double x = -3.0;
long double y = 1.0;
long double a = (9*(pow(x,3))-27*(pow(x,2))-4*x+12);
long double b = (sqrt(3*(pow(x,2))+1) + abs(5-(pow(x,4))));
y = a/b;
for(;x <4.5; x=x+.5){
cout << "X = " << x << ", " << "Y = " << y;
if(y==0)
cout << "Y IS ZERO" << endl;
else if(y<0)
cout << "Y IS NEGATIVE" << endl;
else if(y>0)
cout << "Y IS POSITIVE\n" << endl;
}
return 0;
}