Question

In: Computer Science

Write a program in ecmascript, of Maclurin series of a sine function that declares two variables:...

Write a program in ecmascript, of Maclurin series of a sine function that declares two variables:

x is the value of the argument, h is the accuracy that you want test the program with

x= 1; h= .00001

print out the approximation using as many terms of the Maclaurin series that you need, but no more than that, to get within the required accuracy. While you are at it you might as well also print out Sine(x) BUT do not use the value of Sin(X) to determine the accuracy of the approximation.

Solutions

Expert Solution

Let f(x) = sin(x). To find the Maclaurin series coefficients, we must evaluate

for k = 0, 1, 2, 3, 4, ...

Calculating the first few coefficients, a pattern emerges:

The coefficients alternate between 0, 1, and -1. You should be able to, for the nth derivative, determine whether the nth coefficient is 0, 1, or -1.

Substitute Coefficients into Expansion

Thus, the Maclaurin series for sin(x) is

Step 3: Write the Expansion in Sigma Notation

From the first few terms that we have calculated, we can see a pattern that allows us to derive an expansion for the nth term in the series, which is

Substituting this into the formula for the Taylor series expansion, we obtain

Radius of Convergence

The ratio test gives us:

Because this limit is zero for all real values of x, the radius of convergence of the expansion is the set of all real numbers.

step 1

Maclaurin series coefficients, ak can be calculated using the formula (that comes from the definition of a Taylor series)

where f is the given function, and in this case is sin(x). In step 1, we are only using this formula to calculate the first few coefficients. We can calculate as many as we need, and in this case were able to stop calculating coefficients when we found a pattern to write a general formula for the expansion.

Step 2

Step 2 was a simple substitution of our coefficients into the expression of the Taylor series.

Step 3

A helpful step to find a compact expression for the nth term in the series, is to write out more explicitly the terms in the series that we have found:

We have discovered the sequence 1, 3, 5, ... in the exponents and in the denominator of each term. We may then find a way to convert this sequence that we have discovered, into the sequence k=0, 1, 2, ... that appears in the final summation. The simple transform 2k+1 performs this transformation for us.

Step 4

This step was nothing more than substitution of our formula into the formula for the ratio test. Because we found that the series converges for all x, we did not need to test the endpoints of our interval. If however we did find that the series only converged on an interval with a finite width, then we may need to take extra steps to determine the convergence at the boundary points of the interval.


Related Solutions

C++ Write a program that declares two variables:a string firstName and int age.Write a function, called...
C++ Write a program that declares two variables:a string firstName and int age.Write a function, called getName, that when called, prompts the user for their first name. The function should return the first name and store it in the firstName variable. Write a function, called getAge, that when called, prompts the user for their age. The function should return the age and store it in the age variable. Write a function, that uses the firstName and age as arguments.In the...
Write an entire program (with a main function and necessary header files included) that declares an...
Write an entire program (with a main function and necessary header files included) that declares an 80 byte character buffer, prompts a user to enter a single word (no spaces) from the default input device (e.g. the keyboard), which is stored in the buffer, and then reverses the string while overwriting the buffer. Print the sting before and after the reversal. The program transcript should resemble the following output: $ ./program.exe enter string: nvidia before: nvidia after: aidivn in C
Write Program in C: Write a program that: program starts; declares and initializes to 7.25% constant...
Write Program in C: Write a program that: program starts; declares and initializes to 7.25% constant float variable NJSALES_TAX; declares and initializes to 1000 an integer variable total; declares and initializes to zero a float variable grand_total; prompt and input on new line total; calculate grand_total to equal total plus (total*NJSALES_TAX); if grand_total <= 1000 print on new line “Grand total is less than or equal to 1000 it is $” and the grand_total to two decimal places; else if...
Write a program the declares and uses two parallel arrays. One array for storing the names...
Write a program the declares and uses two parallel arrays. One array for storing the names of countries and a second array for storing the populations of those countries. As you can see per the following the Country name and it's corresponding Population are stored at the same element index in each array. China 1367960000 India 1262670000 United States 319111000 Indonesia 252164800 Brazil 203462000 Pakistan 188172000 Nigeria 178517000 Bangladesh 157339000 Russia 146149200 Japan 127090000 In the main method write a...
Write a program the declares and uses two parallel arrays. One array for storing the names...
Write a program the declares and uses two parallel arrays. One array for storing the names of countries and a second array for storing the populations of those countries. As you can see per the following the Country name and it's corresponding Population are stored at the same element index in each array. China 1367960000 India 1262670000 United States 319111000 Indonesia 252164800 Brazil 203462000 Pakistan 188172000 Nigeria 178517000 Bangladesh 157339000 Russia 146149200 Japan 127090000 In the main method write a...
Identify the Fourier series for the half-wave rectified sine function with period 2π. This is the...
Identify the Fourier series for the half-wave rectified sine function with period 2π. This is the function that is sin(x) when sin(x) is positive, and zero when sin(x) is negative
Write a AL program that will interchange the contents of the two variables.
Assume we have two string variables:  Shakespeare byte 'Brevity is the soul of wit' and Poet byte 'The problem is not in the stars but within ourselves'  Write a AL program that will interchange the contents of the two variables.
Write a complete program (possible to compile) that: 1) declares two local integers x and y...
Write a complete program (possible to compile) that: 1) declares two local integers x and y 2) defines a global structure containing two pointers (xptr,yptr) and an integer (z) 3) Declares a variable (mst) by the type of previous structure 4) requests the values of x and y from the user using only one scanf statement 5) sets the first pointer in the struct to point to x 6) sets the second pointer in the struct to point to y...
1.write a small program using a loop to add a series of numbers 2.write a function...
1.write a small program using a loop to add a series of numbers 2.write a function called "main" that performs several given steps. Be sure to call the main() function so that its code executes In python and doesn't have to be long. just long enough to do what it says. Thank you.
The function Sine is defined as: where x is an angle in radians Write a Matlab...
The function Sine is defined as: where x is an angle in radians Write a Matlab script program to compute the sinus value of any angle as the following: - The program should run always until the user enters - 1 to exit from the program. - A sk user to enter: Number of elements (N) that should be included in the sum - C heck that N is a positive integer . [ Hint: use ( round (N) -...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT