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)
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)
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
Prove by induction that: 1) x^n - 1 is divisible by x-1 2)2n < 3^n for...
Prove by induction that: 1) x^n - 1 is divisible by x-1 2)2n < 3^n for all natural numbers n
(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.
The factorial of a nonnegative integer n is written n! (Pronounced “n factorial”) and is defined...
The factorial of a nonnegative integer n is written n! (Pronounced “n factorial”) and is defined as follows: n! = n.(n-1). (n-2).……...1 (for values of n greater than 1) n!=1 (for n = 0 or 1) For instance, 5! = 5.4.3.2.1 which is 120. Write a Python program that reads a nonnegative integer n and calculates and prints its factorial. Your program should display a suitable error message if n entered as a negative integer.    Figure   6.   Exercise   6  ...
In mathematics, the notation n! represents the factorial of the nonnegative integer n. The factorial of...
In mathematics, the notation n! represents the factorial of the nonnegative integer n. The factorial of n is the product of non-negative numbers from 1 to n. Design a program that asks the user to enter a nonnegative integer and then displays the factorial of that number. Module main. Asks the user to enter a non-negative integer. A loop is used to require user input until a nonnegative number is entered. Once a nonnegative number is entered, the integer is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT