#include<iostream>
#include<math.h>
using namespace std;
double pot(int a, int b)
{
double p=1;
for(int k=1;k<=b;k++)
{
p=p*a;
}
return (p);
}
int fac (int a)
{
int s=1;
for(int k=1;k<=a;k++)
{
s=s*k;
}
return (s);
}
double seno (double n, double x)
{
double a,f;
double b=0;
for(int i=1;i<=n;i++)
{
for(double k=1;k<=2*n-1 ;k=k+2)
{
for(double v=0; v<n ;v++)
{
f=pot((-1),v);
}
a=pot(x,k)/fac(k);
b=b+(a*f);
}
return(b);
}
}
int main()
{
cout<<" SERIE DE TAYLOR"<<endl;
cout<<" -----------------"<<endl<<endl;
cout<<seno(2,1)<<endl;
}
#include<math.h>
using namespace std;
double pot(int a, int b)
{
double p=1;
for(int k=1;k<=b;k++)
{
p=p*a;
}
return (p);
}
int fac (int a)
{
int s=1;
for(int k=1;k<=a;k++)
{
s=s*k;
}
return (s);
}
double seno (double n, double x)
{
double a,f;
double b=0;
for(int i=1;i<=n;i++)
{
for(double k=1;k<=2*n-1 ;k=k+2)
{
for(double v=0; v<n ;v++)
{
f=pot((-1),v);
}
a=pot(x,k)/fac(k);
b=b+(a*f);
}
return(b);
}
}
int main()
{
cout<<" SERIE DE TAYLOR"<<endl;
cout<<" -----------------"<<endl<<endl;
cout<<seno(2,1)<<endl;
}