Professional Documents
Culture Documents
Number systems
– 1.1: Find the zeros of functions f (s) and g(s) using the command roots().
Ans:
– 1.2: Show the roots of f (s) as red circles and of g(s) as blue plus signs.
The x-axis should display the real part of each root, and the y-axis should display the imaginary part. Use hold
on and grid on when plotting the roots.
Ans:
1
2 CHAPTER 1. NUMBER SYSTEMS
– 1.3 Give your figure the title “Complex Roots of f(s) and g(s).” Label the x- and y-axes
“Real Part” and “Imaginary Part.” Hint: Use xlabel, ylabel, ylim([-10 10]), and
xlim([-10 10]) to expand the axes.
– 2.1: Use subplot to show the real and imaginary parts of h(t).
Make two graphs in one figure. Label the x-axes “Time (s)” and the y-axes “Real Part” and “Imaginary Part.”
Ans:
– 2.2: Use subplot to plot the magnitude and phase parts of h(t).
Use the command angle or unwrap(angle()) to plot the phase. Label the x-axes “Time (s)” and the y-axes
’‘Magnitude” and “Phase (radians).”
Ans:
– 3.1: Use the Matlab/Octave function factor to find the prime factors of 123, 248,
1767, and 999,999.
– 3.3: Use the Matlab/Octave function primes to generate prime numbers between
1 and 106 . Save them in a vector x. Plot this result using the command hist(x).
– 3.5: Set the number of bins to 100 by using an extra input argument to the function
hist. Show the resulting figure, give it a title, and label the axes. Hint: help hist
and doc hist.
1.1. PROBLEMS NS-1 3
– 4.3: Try log(1) in the command window. What do you expect for log10(1) and
log2(1)?
Ans:
– 4.4: Try log(-1) in the command window. What do you expect for log10(-1) and
log2(-1)?
Ans:
– 4.5: Explain how Matlab/Octave arrives at the answer in problem 4.4. Hint: −1 = eiπ .
Ans:
4 CHAPTER 1. NUMBER SYSTEMS
√
– 4.6: Try log(exp(j*sqrt(pi))) (i.e., log e π
) in the command window. What do
you expect?
Ans:
– 4.7: What does inverse mean in this context? What is the inverse of ln f (x)?
Ans:
Problem # 5: Very large primes on Intel computers. Find the largest prime number
that can be stored on an Intel 64-bit computer, which we call πmax . Hint: As explained
in the Matlab/Octave command help flintmax, the largest positive integer is 253 ;
however, the largest unsigned integer that can be factored is at least 254 . Explain the
logic of your answer. Hint: help isprime().
Problem # 6: We are interested in primes that are greater than πmax . How can you
find them on an Intel computer (i.e., one using IEEE floating point)? Hint: Consider a
sieve that contains only odd numbers, starting from 3 (not 2). Since every prime number
greater than 2 is odd, there is no reason to check the even numbers. nodd ∈ N/2 contain
all the primes other than 2.
1.1. PROBLEMS NS-1 5
1 = 12
1 + 3 = 22
1 + 3 + 5 = 32
1 + 3 + 5 + 7 = 42
1 + 3 + 5 + 7 + 9 = 52
..
.
N
X −1
2n + 1 = N 2 .
n=0