Serie de Taylor c++

#include #include #define PI 3.14159265 #define nn -1 using namespace std; class taylor { public: int expo, sig; //expon

Views 134 Downloads 5 File size 12KB

Report DMCA / Copyright

DOWNLOAD FILE

Recommend stories

Citation preview

#include #include #define PI 3.14159265 #define nn -1 using namespace std; class taylor { public: int expo, sig; //exponente y signo a evaluar; ge=grado a evaluar // double int facto; //calculo del factorial float serie, xi, xi1, st, xis; //sc=suma cosenos; ss=suma senos; serie=suma total double ss1, sc1; //xi=termino xi; xi1=xi+ 1, termino dado. // double int factorial(double int fact); float sc(int exp1, int sig1, double fact1);//sc2, serie cosenos funcion; par ametros que recibira float ss(int exp2, int sig2, double fact2);//ss2, serie cosenos; float conversion(float conver1, float conver2); //funcion grado que conviert e a radianes. taylor(){ } }; float taylor::conversion(float conver1, float conver2) //revisar, esta mal. { xi=((conver1*PI))/180; xi1=((conver2*PI))/180; xis=xi1-xi; } float taylor::sc(int exp1, int sig1, double fact1) { int exp1c; int sig1c; double fact1c; float t1,t2,t3,t4,t5; exp1c=exp1; sig1c=sig1; fact1c=fact1; if(exp1c==1) { expo=1; sc1=((cos(xi))); return sc1; //expo++; } else t1=(cos(xi)); t2=pow(xis,exp1c); t3=t1*t2;

t4=t3/fact1c; t5=t4*sig1c; sc1=t5; return sc1; //sc1=(sig1)((cos(xi))(pow((xis),exp1)))/(fact1); } float taylor::ss(int exp2, int sig2, double fact2) { int exp1c; int sig1c; double fact1c; float t1,t2,t3,t4,t5; exp1c=exp2; sig1c=sig2; fact1c=fact2; t1=(sin(xi)); t2=pow(xis,exp1c); t3=t1*t2; t4=t3/fact1c; t5=t4*sig1c; ss1=t5; return ss1; } int Fact(double x) { if (x==0 || x==1) return 1; return (x * Fact(x-1)); } int main (void) { int exp=0, n=0, termc=0, terms=0, sign=0,t; float xi, xi1, senos, cosenos, radianes,error1, error2, valor; taylor obj; taylor *apu; double f; //f=factorial

cout