function result = My_Cos(x)
err = 10^(-18);
total = 1;
sign = -1;
i = 2;
while true
val = (sign * x^i /
factorial(i));
if abs(val) <
err
break;
end
total = total +
val;
i = i + 2;
sign = sign * -1;
end
result = total;
end

The cosine function can be evaluated by the following infinite series as (where the angle x...
Please show exactly how it is in MATLAB The cosine function can be evaluated by the following infinite series: cos ? = 1 − ?^2/ 2! + ?^4/ 4! − ?^6 /6! + ⋯ Create an M-file to compute cos(1.2345 rad) for up to and including eight terms, which is up to the term x^14/14!. a) Your program should compute and display the values of cos ? as each term in the series is added, e.g. cos ? = 1...
7. (a) Use the well known Maclaurin series expansion for the cosine function: f (x ) = cos x = 1 x? 2! + 4! х 6! + (-1)" (2n)! . * 8! 0 and a substitution to obtain the Maclaurin series expansion for g(x) = cos (x²). Express your formula using sigma notation. (b) Use the Term-by-Term Integration Theorem to obtain an infinite series which converges to: cos(x) dx . y = cos(x²) (c) Use the remainder theorem associated...
3. Cosine Approximation Write a function m-file to calculate the approximated cosine function which can be evaluated by the following infinite series - equation (2): 1. x² x4 26 (-1)(n+1). 22(n-1) cos x = 1 - 3 + - 6! + + (2(n − 1))! Here are requirements for the function m-file. - Parameter lists (inputs): 2 value (in radian), and desired error percentagel. - Return value (outputs): approximated value, real error percentage, and number of iterations - Function name:...
Write a regular function (i.e. in a function .m file) to calculate the series expansion of cosine(x). The number of terms calculated in the series should be specified in the input list of the function. Write a separate function that determines when the series expansion begins to deviate by at least 10% from the true value of cosine(x) based on the number of terms calculated in the series expansion, n. For n = 1, 2, … 10, determine the values...
below. Then find the corresponding Fourier cosine series t. Wite and ikcrch the even externsion ) for the function b f(x). 2 for 1s x<2 B. If fu) is approximated by the finse three terms of the Fourier cosine espansion series, determine the error percent in C. Determine the frequency, magnitude and phase angle of the 3d harmonic of the expansion.
below. Then find the corresponding Fourier cosine series t. Wite and ikcrch the even externsion ) for the function...
Convince yourself that the Maclaurin Series for cos(x) is:
A. Write a function script called cos_series
that takes that takes as its inputs, x and N and has output given
by the sum in the N-term Maclaurin Series approximation for Cos(x).
Hint: try a “for loop” and set “format long” in
your code. You may use the MATLAB built-in function factorial()
B. Check your code by finding the 2-terms,
3-terms, 4-terms, 5-terms and 6-terms Maclaurin Series
approximations every 30 degrees...
Question 4. Calculate the Fourier sine series and the Fourier cosine series of the function f(x) = sin(x) on the interval [0, 1]. Hint: For the cosine series, it is easiest to use the complex exponential version of Fourier series. Question 5. Solve the following boundary value problem: Ut – 3Uzx = 0, u(0,t) = u(2,t) = 0, u(x,0) = –2? + 22 Question 6. Solve the following boundary value problem: Ut – Uxx = 0, Uz(-7,t) = uz (77,t)...
Programming Assignment 3 CSCI 251, Fall 2015 Infinite Series Trigonometric and math functions are usually calculated on computers using truncated Taylor series (an infinite series). An infinite series is an infinite set of terms whose sum is a particular function or expression. For example, the infinite series used to evaluate the natural log of a number is (x - 1)2 (x-1)3 (x-1)* (x-1)5 2 4 where x E (0, 2], or 0
In MATLAB
The value of cos(x) can be approximated using a Maclaurin series + +... cos(x)=1-1 2! 4! 6! Which can be expressed compactly as cos(x) = {(-1)+7 (2(k-1))! 00 2(k-1) k-1 Write Matlab code using a while loop that calculates cos(2) with 5 terms of Maclaurin series. Compare the value with the one calculated with a built-in function cos (2) in Matlab. The following is an expected output from your code: Using the Maclaurin series cos( 2.0) with 5...
Write in Python 3
Write a program that takes the value of an angle x in degrees, such that 0 s x <90, and calculates approximate value of sine of the given angel using the following series sin(x)-x-for all x The series given above has infinite number of terms. However, you can only include a finite number of terms in the series. The absolute value of each subsequent term is smaller than that of the term calculated before it. The...