Advertisement
dimkaxrsa

asdasd

Mar 23rd, 2016
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. #include <math.h>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5. int main()
  6. {
  7.     int a, factorial = 1, n;
  8.     double e, res, euler = 2.71828182845904523536, ep,expon;
  9.  
  10.    
  11.     cout<<"Serie de Taylor"<<endl;
  12.     cout<<"Ingresa el valor de n: "<<endl;
  13.     cin>>n;
  14.     e = pow(euler,-n);
  15.     cout<<"Valor e^x: "<<e<<endl;
  16.     cout<<"------------------------------"<<endl;
  17.      
  18.      //Valor de aproximacion
  19.     double aproxi = 0.9;
  20.    
  21.     for (a =1; a <=n; factorial += a){
  22.    
  23.         expon = (1+(pow(1,a)/factorial));
  24.         res = 1/(expon) ;
  25.  
  26.         ep = ((e - res)/e)*100;
  27.  
  28.         if(res >= aproxi){
  29.         break;
  30.     }
  31.  
  32.     else{
  33.    
  34.         cout<<"|"<<factorial<<"    "<<res<<"      "<<ep<<" "<<endl;
  35.         cout<<"-------------------------------"<<endl;
  36.     }
  37.        
  38.     }  
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement