Numerical Analysis Questions & Answers | |
|
|
On gcc on x86 Linux, the smallest number for a signed 1-byte integer will be -128 and the largest number will be +127 (this can be easily tested). As I mentioned in class, this is due to the negative zero being used for an extra negative number. I couldn't find a reference thus on whether this is a strict standard for C. I also couldn't find a reference on how gcc does the arithmetic, hence why I mentioned in class there are several ways the compiler could achieve this. As you mention, one way this could be done is with “two's complement” [l]. Then the bits will look this way:
|
|
|
|
This was explained in class.
|
|
|
|
|
|
But $e=0$ indicates a special case, not an exponent. Thus, the minimum exponent $p_{\rm min}$ is not calculated using $e=0$ but using $e=1$.
|
|
|
|
I'm not sure why you're getting negative bits.. You have more or less the right logic thus (although not perfectly). Keep working more on it.
|
|
|
|
I will answer your question if the numbers are properly typeset. Answer it again below and use LATEX to write the math and numbers properly.
|
|
|
|
The number has to be constructed with the same rules as the float and double types shown in class. So yes, the exponents must be split equally between positive and negative values, and yes, the exponent must include the usual exceptions. Thus, denormal numbers will of course be present.
|
|
|
|
Yes, the relative error can be less than $\epsilon_{\rm mach}$. In class, $\epsilon_{\rm mach}$ was defined as the maximum relative error on a non-denormal float. For most non-denormal floats, the error will of course be less. 1 point bonus boost.
|
|
|
|
Yes, of course, the number of iterations will depend on the initial interval chosen. This is why the initial interval is specified in the question. There are no rules that can be used to guess a proper initial interval that would apply in the general case because each function has a different behaviour. But if you do know the function, then it may be possible to specify an initial interval that is quite close to the root through a good guess for the root. 1 point bonus boost.
|
|
|
|
Here's a hint. Simply obtaining the 4th digit is not enough. You need to make sure the 4th significant digit is actually valid.. The best way to solve this problem is to specify what is the maximum allowable value of the relative error $\epsilon$ needed here and to determine analytically how many iterations is needed to reach this level. In the exam, I may ask you a similar question but instead of 4 significant digits, I may ask you for 100 significant digits. Solving the problem by hand one iteration at a time will take too long. Thus, you should aim to find here an analytical expression giving you number of iterations for a certain $\epsilon$ sought. 1 point bonus.
|
|
|
|
Just define $\pi$ in the preamble of your code with #define pi 3.141592920 |
|
|
|
Yes $p$ varies as the iteration count varies. You should explain why this is. There is one reason for the discrepancy in the first few iterations and another reason when approaching machine accuracy. Explain both.
|
|
|
|
Proportional to does not exclude equal to..
|
|
||
$\pi$ |