Exact arithmetic, MATLAB Programming

Run the MATLAB script
sum = single(0); term = single(1);
n=1;
while sum + term > sum
sum = sum+term;
n=n+1;
term = 1/n;
end
n

Explain what you think it is trying to do. What would this code do in exact arithmetic?Describe why the code produces a nite result and (harder) describe the output. What would happen (don't try it!) if you replaced the fi rst line with sum=0; term=1;?

Posted Date: 3/22/2013 7:03:16 AM | Location : United States







Related Discussions:- Exact arithmetic, Assignment Help, Ask Question on Exact arithmetic, Get Answer, Expert's Help, Exact arithmetic Discussions

Write discussion on Exact arithmetic
Your posts are moderated
Related Questions
Write a function rid_multiple_blanks that will receive a string as an input argument. The string contains a sentence that may have multiple blank spaces in between some of the word

How do you write a programme that asks the user for a number between 1 and 1000 and calculates the sum of its digits?

use the loop for to produce [-1 -1 -1 -1; 0 -1 -1 -1; 0 0 -1 -1; 0 0 0 -1]

Appending data to a data File: A text file once exists; the data can be appended to it. The format is similar as formerly, with the addition of the qualifier -append. For illu

Write a script to determine the volume of a pyramid, which is 1/3 * base * height, where the base is length * width. On time the user to enter values for the length, width, and th

how to write the national log (ln(x)) in matlap ?

Hold and legend function: hold: is a toggle which freezes the present graph in the figure window, so that the new plots will be superimposed on the present one. Just hold

to find given number is odd or even in an array with explanation and flow chart

Variable numbers of arguments: In the functions there have been a fixed number of input and output arguments. For illustration, in the function below, there is one input argum

Write a MATLAB program to find the undamped natural frequencies and modes of an electric car treating it as a four degree of freedom system. Determine the undamped natural frequenc