1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
//graphing calculator. plot points derive antiderive and asymptotes.
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
double coeff[11]={0};
double point[11]={0}; // i changed them to 11, so when n=10, it would fill up the 11th spot! is that right?
double degree, points, con;
cout << "Welcome to my graphing utility!\n";
cout << "Insert your equation and the points you want to input and I will do the rest.\n";
cout << "What is the highest degree of your equation: (up to 10) \n";
cin >> degree;
for ( int n = 0 ; n<degree ; n++)
{cout << "what is the coefficient of x^" << n+1 << endl;
cin >>coeff[n+1];}
cout << "What is your constant: \n";
cin >> con;
cout << "How many points do you want to plot: (up to 10) \n";
cin>> points;
for ( int p=0; p<points ; p++)
{cout << "What is point number " << p+1 << ": \n";
cin >> point[p+1];}
cout << "Your equation is: " << coeff[10] << "x^10 + " << coeff[9] << "x^9 + " << coeff[8] << "x^8 + " << coeff[7] << "x^7 + " << coeff[6] << "x^6 + " << coeff[5] << "x^5 + " << coeff[4] << "x^4 + " << coeff[3] << "x^3 + " << coeff[2] << "x^2 + " << coeff[1] << "x^1 + " << con << endl;
cout << coeff[10]*pow(point[1],10) + coeff[9]*pow(point[1],9) + coeff[8]*pow(point[1],8) + coeff[7]*pow(point[1],7) + coeff[6]*pow(point[1],6) + coeff[5]*pow(point[1],5) + coeff[4]*pow(point[1],4) + coeff[3]*pow(point[1],3) + coeff[2]*pow(point[1],2) + coeff[1]*pow(point[1],1) + con;
cout << endl;
cout << coeff[10]*pow(point[2],10) + coeff[9]*pow(point[2],9) + coeff[8]*pow(point[2],8) + coeff[7]*pow(point[2],7) + coeff[6]*pow(point[2],6) + coeff[5]*pow(point[2],5) + coeff[4]*pow(point[2],4) + coeff[3]*pow(point[2],3) + coeff[2]*pow(point[2],2) + coeff[1]*pow(point[2],1) + con;
cout << endl;
cout << coeff[10]*pow(point[3],10) + coeff[9]*pow(point[3],9) + coeff[8]*pow(point[3],8) + coeff[7]*pow(point[3],7) + coeff[6]*pow(point[3],6) + coeff[5]*pow(point[3],5) + coeff[4]*pow(point[3],4) + coeff[3]*pow(point[3],3) + coeff[2]*pow(point[3],2) + coeff[1]*pow(point[3],1) + con;
cout << endl;
cout << coeff[10]*pow(point[4],10) + coeff[9]*pow(point[4],9) + coeff[8]*pow(point[4],8) + coeff[7]*pow(point[4],7) + coeff[6]*pow(point[4],6) + coeff[5]*pow(point[4],5) + coeff[4]*pow(point[4],4) + coeff[3]*pow(point[4],3) + coeff[2]*pow(point[4],2) + coeff[1]*pow(point[4],1) + con;
cout << endl;
cout << coeff[10]*pow(point[5],10) + coeff[9]*pow(point[5],9) + coeff[8]*pow(point[5],8) + coeff[7]*pow(point[5],7) + coeff[6]*pow(point[5],6) + coeff[5]*pow(point[5],5) + coeff[4]*pow(point[5],4) + coeff[3]*pow(point[5],3) + coeff[2]*pow(point[5],2) + coeff[1]*pow(point[5],1) + con;
cout << endl;
cout << coeff[10]*pow(point[6],10) + coeff[9]*pow(point[6],9) + coeff[8]*pow(point[6],8) + coeff[7]*pow(point[6],7) + coeff[6]*pow(point[6],6) + coeff[5]*pow(point[6],5) + coeff[4]*pow(point[6],4) + coeff[3]*pow(point[6],3) + coeff[2]*pow(point[6],2) + coeff[1]*pow(point[6],1) + con;
cout << endl;
cout << coeff[10]*pow(point[7],10) + coeff[9]*pow(point[7],9) + coeff[8]*pow(point[7],8) + coeff[7]*pow(point[7],7) + coeff[6]*pow(point[7],6) + coeff[5]*pow(point[7],5) + coeff[4]*pow(point[7],4) + coeff[3]*pow(point[7],3) + coeff[2]*pow(point[7],2) + coeff[1]*pow(point[7],1) + con;
cout << endl;
cout << coeff[10]*pow(point[8],10) + coeff[9]*pow(point[8],9) + coeff[8]*pow(point[8],8) + coeff[7]*pow(point[8],7) + coeff[6]*pow(point[8],6) + coeff[5]*pow(point[8],5) + coeff[4]*pow(point[8],4) + coeff[3]*pow(point[8],3) + coeff[2]*pow(point[8],2) + coeff[1]*pow(point[8],1) + con;
cout << endl;
cout << coeff[10]*pow(point[9],10) + coeff[9]*pow(point[9],9) + coeff[8]*pow(point[9],8) + coeff[7]*pow(point[9],7) + coeff[6]*pow(point[9],6) + coeff[5]*pow(point[9],5) + coeff[4]*pow(point[9],4) + coeff[3]*pow(point[9],3) + coeff[2]*pow(point[9],2) + coeff[1]*pow(point[9],1) + con;
cout << endl;
cout << coeff[10]*pow(point[10],10) + coeff[9]*pow(point[10],9) + coeff[8]*pow(point[10],8) + coeff[7]*pow(point[10],7) + coeff[6]*pow(point[10],6) + coeff[5]*pow(point[10],5) + coeff[4]*pow(point[10],4) + coeff[3]*pow(point[10],3) + coeff[2]*pow(point[10],2) + coeff[1]*pow(point[10],1) + con;
cout << endl;
system("pause");
}
|