Question: I'm having trouble with this MATLAB problem. 21) a) The factorial function nl can be coded as y t prod (1:n) i.e, n!1.2 3Find the

 I'm having trouble with this MATLAB problem. 21) a) The factorial

I'm having trouble with this MATLAB problem.

21) a) The factorial function nl can be coded as y t prod (1:n) i.e, n!1.2 3Find the largest value of n for which the result is not Inf by using a while loop. Check that the largest value of n you have caleulated is the same as when calling factorial directly b) Calculate 1! directly as (1) (1) (1)- (n ) (1) 5.11) using one statement, and find the largest value of n for which the product is positive, again using a for loop. (It is larger than in the previouis part.) Note (this part only): Do the divisions inside the parentheses before doing the multiplications between the parentheses. d) As determined above, the factorial function can easily return oo. The floating-point overflow can be avoided by calculating n! in scientific notation, and returning the result as fx10" where f [1 10) and m is an integer. This can be done by not calculating n! but, instead logio n! ? logo i + logio 2 +- .. + log 1011, and logon! logo f+m (i) Write a seript named logfact. m to do this calculation. The input is n, and the outputs are f and m. Verify that your code is correct (ii) Print the output forn:-104 and then for 106 d) What is the approximate value of n for which logio n! is realmax? This is a question you must answer analytically, not numerically

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!