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

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.
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:
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?
2. Consider an n-cube, where n = 3. Is it possible to draw this on a...
2. Consider an n-cube, where n = 3. Is it possible to draw this on a two dimensional plane where the lines do not cross? If it is possible, draw it. If not, prove that it isn't possible.
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?
(a) Show that the sample variance s 2 = [Pn i=1(xi − x¯) 2 ]/(n −...
(a) Show that the sample variance s 2 = [Pn i=1(xi − x¯) 2 ]/(n − 1) can also be expressed as s 2 = [Pn i=1 x 2 i − ( Pn i=1 xi) 2 n ]/(n − 1). At a medical center, a sample of 36 days showed the following number of cardiograms done each day. 25 31 20 32 20 24 43 22 57 23 35 22 43 26 56 21 19 29 36 32 33 32...
Let S be the cone z = 4 − ( x^2 + y^2)^(1/2) where z ≥...
Let S be the cone z = 4 − ( x^2 + y^2)^(1/2) where z ≥ 0, oriented with downward pointing unit normal vectors. The image below contains S. The grey plane is the xy-plane. Let F~ (x, y, z) = <− z , x − y , x + y >. Use Stokes’ Theorem to evaluate Z Z S ∇ × F~ · dS~.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT