Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <math.h>
- #include <iostream>
- using namespace std;
- int main()
- {
- int a, factorial = 1, n;
- double e, res, euler = 2.71828182845904523536, ep,expon;
- cout<<"Serie de Taylor"<<endl;
- cout<<"Ingresa el valor de n: "<<endl;
- cin>>n;
- e = pow(euler,-n);
- cout<<"Valor e^x: "<<e<<endl;
- cout<<"------------------------------"<<endl;
- //Valor de aproximacion
- double aproxi = 0.9;
- for (a =1; a <=n; factorial += a){
- expon = (1+(pow(1,a)/factorial));
- res = 1/(expon) ;
- ep = ((e - res)/e)*100;
- if(res >= aproxi){
- break;
- }
- else{
- cout<<"|"<<factorial<<" "<<res<<" "<<ep<<" "<<endl;
- cout<<"-------------------------------"<<endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement