Taylor series expands function into a finite sequence of a variable x or a finite series plus a
remainder. A complex electromagnetic signal transmitted from a radio transmitter can be
decomposed into its components by using Taylor approximation, which is equivalent to estimating
the parameters of complex exponential functions. Let x(t) be a signal transmitted. Develop a C-
script that calculates the following Taylor series approximation of function f(x) for N number of
terms. Where N is the largest whole number which is a factor of both 42 and 98. You can select any
positive real value of x.
f (x) = β
π
π
π!
π΅
π=π
= 1 +
π
π!
+
π
π
π!
+
π
π
π!
........
Note : Don't use arrays, do with loops
#include <iostream>
using namespace std;
int getGCD(int x, int y)
{
if (x == 0)
return y;
if (y == 0)
return x;
if (x == y)
return x;
if (x > y)
return getGCD(x-y, y);
return getGCD(x, y-x);
}
int main()
{
int n1= 42, n2 = 98;
cout<<"GCD of "<<n1<<" and "<<n2<<" is "<<getGCD(n1, n2);
return 0;
}
Comments
Leave a comment