Question

In: Computer Science

If S = 1-x/1! + x^2/2! - x^3/3! + .....   where n! means factorial(n) and x...

If S = 1-x/1! + x^2/2! - x^3/3! + .....  
where n! means factorial(n) and x is a variable that will be assigned.
Use matlab to compute S for x = 7 and n (number of terms) = 5.   Write the value below as the one displayed when you issue "format short" in matlab. Explain the process and result of the question.

Solutions

Expert Solution

Matlab code

=====================================================================================

clc
x=7;
n=0;
S=0;

while n<5
temp = ((-x)^n)/factorial(n);
S=S+temp;
n=n+1;
end
format short
S

=====================================================================================
Output


Related Solutions

Given a sequence x(n) for 0 ≤ n ≤ 3, where x(0)=4, x(1)=3, x(2)=2, and x(3)=1,...
Given a sequence x(n) for 0 ≤ n ≤ 3, where x(0)=4, x(1)=3, x(2)=2, and x(3)=1, evaluate your DFT X(k)
Write a factorial C++ program where n=10,000,000
Write a factorial C++ program where n=10,000,000
Write a factorial C++ program where n=10,000,000
Write a factorial C++ program where n=10,000,000
A 5th filter is described by the difference equation: 2y(n)=2 x(n)+7 x(n-1)+3 x(n-2)-8 x(n-3)+ x(n-4)-8 x(n-5)+7...
A 5th filter is described by the difference equation: 2y(n)=2 x(n)+7 x(n-1)+3 x(n-2)-8 x(n-3)+ x(n-4)-8 x(n-5)+7 y(n-1)-3 y(n-2)+5y(n-3)- y(n-4) Determine the frequency response. Plot the magnitude and the phase response of this filter. Consider the plot -π≤w≤π for 501 points. Describe the magnitude response (Low pass filter, High Pass filter, etc.) Determine the system stability. Determine the impulse response h(n). You may set the period to -100≤n≤100 Determine the unit step response for -100≤n≤100 . (Matlab)
(1) Write a simple Lisp function factorial1 to computee factorial number of n recursivaly (where n...
(1) Write a simple Lisp function factorial1 to computee factorial number of n recursivaly (where n is an int >= 0). (2) Write a Lisp function factorial2 to computee factorial number of n (where n is an int >=0) recursivaly with a global variable (e.g., a list, an array, or a hash tble) to save the result to be used later (memorization) to compute next factorial number. Run the program with test case. For your test run, the following cases:...
The factorial of a non-negative integer is defined as follows: n! = 1 × 2 ×...
The factorial of a non-negative integer is defined as follows: n! = 1 × 2 × ... × (n − 1) × n A. Write a function that takes an input value n and returns its factorial result n!. Ensure that your function returns an error statement if the input n is either a negative or a non-integer value. You cannot use the prod() or factorial() functions. The Euler number e is calculated as the sum of the infinite series...
Show that, for each natural number n, (x − 1)(x − 2)(x − 3). . .(x...
Show that, for each natural number n, (x − 1)(x − 2)(x − 3). . .(x − n) − 1 is irreducible over Q, the rationals.
Let f(x) = {(C/x^n if 1≤ x <∞; 0 elsewhere)} where n is an integer >1....
Let f(x) = {(C/x^n if 1≤ x <∞; 0 elsewhere)} where n is an integer >1. a. Find the value of the constant C (in terms of n) that makes this a probability density function. b. For what values of n does the expected value E(X) exist? Why? c. For what values of n does the variance var(X) exist? Why?
Explain the different types of factorial designs (chapter 8). 1. Mixed factorial designs: 2. P X...
Explain the different types of factorial designs (chapter 8). 1. Mixed factorial designs: 2. P X E designs: 3. Mixed P X E designs:
Considerapopulationwhoseprobabilitiesaregivenby p(1)=p(2)=p(3)= 1 3 (a) DetermineE[X]. (b) DetermineSD(X). σ2σ n =√n SD(X)= In the preceding formula,...
Considerapopulationwhoseprobabilitiesaregivenby p(1)=p(2)=p(3)= 1 3 (a) DetermineE[X]. (b) DetermineSD(X). σ2σ n =√n SD(X)= In the preceding formula, σ is the population standard deviation, and n is the (c) Let X denote the sample mean of a sample of size 2 from this population. Determine the possible values of X along with their probabilities. (d) Usetheresultofpart(c)tocomputeE[X]andSD(X). (e) Areyouranswersconsistent?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT