Chapter 1
First Look: Ten Questions.
1. Put options with strikes 30 and 20 on the same un-
derlying asset and with the same maturity are trad-
ing for $6 and $4, respectively. Can you find an
arbitrage?
2. The number 229 has 9 digits, all different. Without
computing 229 , find the missing digit.
3. Let Wt be a Wiener process, and let
Z t
Xt = Wτ dτ.
0
What is the distribution of Xt ? Is Xt a martingale?
4. Alice and Bob stand at opposite ends of a straight
line segment. Bob sends 50 ants towards Alice, one
after another. Alice sends 20 ants towards Bob. All
ants travel along the straight line segment. When-
ever two ants collide, they simply bounce back and
start traveling in the opposite direction. How many
1
2 CHAPTER 1. FIRST LOOK: TEN QUESTIONS
ants reach Bob and how many ants reach Alice?
How many ant collisions take place?
5. Find all the values of ρ such that
1 0.6 −0.3
0.6 1 ρ
−0.3 ρ 1
is a correlation matrix.
6. How many independent random variables uniformly
distributed on [0, 1] should you generate to ensure
that there is at least one between 0.70 and 0.72 with
probability 95%?
7. Show that the probability density function of the
standard normal integrates to 1.
8. Assume the Earth is perfectly spherical and you are
standing somewhere on its surface. You travel ex-
actly 1 mile south, then 1 mile east, then 1 mile
north. Surprisingly, you find yourself back at the
starting point. If you are not at the North Pole,
where can you possibly be?!
9. Solve the Ornstein-Uhlenbeck SDE
drt = λ(θ − rt )dt + σdWt ,
which is used, e.g., in the Vasicek model for interest
rates.
10. Write a C++ function that computes the n-th Fi-
bonacci number.
3
Solutions
Question 1. Put options with strikes 30 and 20 on the
same underlying asset and with the same maturity are
trading for $6 and $4, respectively. Can you find an arbi-
trage?
Answer: Since the value of a put option with strike 0 is
$0, we in fact know the prices of put options with three
different strikes, i.e.,
P (30) = 6; P (20) = 4; P (0) = 0,
where P (K) denotes the value of a put option with strike
K.
In the plane (K, P (K)), these option values correspond
to the points (30, 6), (20, 4), and (0, 0), which are on the
line P (K) = 23 K.
This contradicts the fact that put options are strictly
convex functions of strike price, and creates an arbitrage
opportunity.
The arbitrage comes from the fact that the put with
strike 20 is overpriced. Using a ”buy low, sell high” strat-
egy, we could buy (i.e., go long) 23 put options with strike
30, and sell (i.e., go short) 1 put option with strike 20. To
avoid fractions, we set up the following portfolio:
• long 2 puts with strike 30;
• short 3 puts with strike 20.
This portfolio is set up at no initial cost, since the cash
flow generated by selling 3 puts with strike 20 and buying
2 puts with strike 30 is $0:
3 · $4 − 2 · $6 = $0.
At the maturity T of the options, the value of the port-
folio is
V (T ) = 2 max(30 − S(T ), 0) − 3 max(20 − S(T ), 0).
4 CHAPTER 1. FIRST LOOK: TEN QUESTIONS
Note that V (T ) is nonnegative for any value S(T ) of
the underlying asset:
If S(T ) ≥ 30, then both put options expire worthless,
and V (T ) = 0.
If 20 ≤ S(T ) < 30, then
V (T ) = 2(30 − S(T )) > 0.
If 0 < S(T ) < 20, then
V (T ) = 2(30 − S(T )) − 3(20 − S(T ))
= S(T )
> 0.
In other words, we took advantage of the existing ar-
bitrage opportunity by setting up, at no initial cost, a
portfolio with nonnegative payoff at T regardless of the
price S(T ) of the underlying asset, and with a strictly
positive payoff if 0 < S(T ) < 30.
Question 2. The number 229 has 9 digits, all different.
Without computing 229 , find the missing digit.
Answer: For any positive integer n, denote by D(n) the
sum of the digits of n. Recall that the difference between
a number and the sum of its digits is divisible by 9, i.e.,
9 | n − D(n);
see the footnote below1 for details.
1
If the digits of n are ak , ak−1 , . . . a1 , a0 (from left to right),
then
n = ak · 10k + ak−1 · 10k−1 + . . . a1 · 10 + a0 ;
D(n) = ak + ak−1 + . . . + a1 + a0 .
Hence,
k
X i
n − D(n) = ai · (10 − 1).
i=0
Since 10i − 1 is an i-digit number with all digits equal to 9, it
follows that 9 | 10i − 1, for all i = 1 : k, and therefore 9 | n − D(n).
5
Thus, for n = 229 , it follows that
9 | 229 − D 229 . (1.1)
29
We are given that 2 has 9 digits, and that all 9 digits
are different. Denote by x the missing digit. Then,
9
!
29
X
D 2 = j − x = 45 − x. (1.2)
j=0
From (1.1) and (1.2), it follows that
9 | 229 − (45 − x). (1.3)
Note that
229 = 25 · (26 )4 = 25 · 644
= 25 · (63 + 1)4
= 25 · (63 · k + 1)
= 25 · 63 · k + 25 , (1.4)
2
where k is a positive integer.
From (1.4), we find that
229 − 25 = 63 · 25 · k,
and therefore
9 | 229 − 25 . (1.5)
From (1.3) and (1.5), it follows that
9 | (229 − 25 ) − (229 − (45 − x))
= (45 − x) − 25
= 13 − x.
2
It is easy to see that
4 4 3 2
(63 + 1) = 63 + 4 · 63 + 6 · 63 + 4 · 63 + 1
3 2
= 63 · (63 + 4 · 63 + 6 · 63 + 4) + 1
= 63 · k + 1,
where k = 633 + 4 · 632 + 6 · 63 + 4.
6 CHAPTER 1. FIRST LOOK: TEN QUESTIONS
Since 9 | 13−x and x is a digit, we conclude that x = 4.
In other words, we identified that x, the missing digit from
229 , must be 4.
Indeed, 229 = 536 870 912, i.e., 229 has 9 digits, all
different, and 4 is not a digit of 229 .
Question 3. Let Wt be a Wiener process, and let
Z t
Xt = Wτ dτ. (1.6)
0
What is the distribution of Xt? Is Xt a martingale?
Answer: Note that we can rewrite (1.6) in differential
form as
dXt = Wt dt = Wt dt + 0 dWt .
Then, Xt is a diffusion process with only drift part Wt ,
and therefore Xt is not a martingale.
We use integration by parts to find the distribution of
Xt ; a different solution can be found in Section 3.6.
By applying integration by parts, we obtain that
Z t
Xt = Wτ dτ
0
Z t
= tWt − τ dWτ
0
Z t Z t
= t dWτ − τ dWτ
0 0
Z t
= (t − τ )dWτ .
0
Recall that, if f (t) is a deterministic
R t square integrable
function, then the stochastic integral 0 f (τ )dWτ is a nor-
Rt
mal random variable of mean 0 and variance 0 |f (τ )|2dτ ,
i.e., Z Z
t t
f (τ )dWτ ∼ N 0, |f (τ )|2dτ .
0 0
7
Thus,
Z t
Xt = (t − τ )dWτ
0
Z t
∼ N 0, (t − τ )2 dτ
0
3
t
= N 0, .
3
We conclude that Xt is a normal random variable of mean
3
0 and variance t3 .
Question 4. Alice and Bob stand at opposite ends of a
straight line segment. Bob sends 50 ants towards Alice,
one after another. Alice sends 20 ants towards Bob. All
ants travel along the straight line segment. Whenever two
ants collide, they simply bounce back and start traveling
in the opposite direction. How many ants reach Bob and
how many ants reach Alice? How many ant collisions take
place?
Answer: Imagine that when two ants meet, they switch
identities. Hence, even after a collision, two ants are trav-
eling in two opposite directions. It follows that 20 ants
reach Bob, while 50 ants reach Alice.
To calculate the number of ant collisions, imagine that
each ant carries a message. In other words, Bob sends
50 messages to Alice, one message per ant. Similarly,
Alice sends 20 messages to Bob, one message per ant.
Furthermore, imagine that the two ants swap messages
when they collide. Then a message always makes forward
progress. Each of Alice’s messages goes through 50 ant
collisions. Each of Bob’s messages goes through 20 ant
collisions. The total number of collisions is 50 times 20,
which is 1000 collisions.
8 CHAPTER 1. FIRST LOOK: TEN QUESTIONS
Question 5. Find all the values of ρ such that
1 0.6 −0.3
0.6 1 ρ
−0.3 ρ 1
is a correlation matrix.
Answer: A symmetric matrix with diagonal entries equal
to 1 is a correlation matrix if and only if the matrix is
symmetric positive semidefinite. Thus, we need to find all
the values of ρ such that the matrix
1 0.6 −0.3
Ω = 0.6 1 ρ (1.7)
−0.3 ρ 1
is symmetric positive semidefinite.
We give a short solution using Sylvester’s criterion.
Two more solutions, one using the Cholesky decomposi-
tion, and another one based on the definition of symmetric
positive semidefinite matrices will be given in Section 3.2.
Recall from Sylvester’s criterion that a matrix is sym-
metric positive semidefinite if and only if all its principal
minors are greater than or equal to 0. Also, recall that
the principal minors of a matrix are the determinants of
all the square matrices obtained by eliminating the same
rows and columns from the matrix. In particular, the
matrix Ω from (1.7) has the following principal minors:
det(1) = 1; det(1) = 1; det(1) = 1;
1 0.6
det = 0.64;
0.6 1
1 −0.3
det = 0.91;
−0.3 1
1 ρ
det = 1 − ρ2 ;
ρ 1
9
det(Ω) = 1 − 0.36ρ − 0.09 − 0.36 − ρ2
= 0.55 − 0.36ρ − ρ2 .
Thus, it follows from Sylvester’s criterion that Ω is a
symmetric positive semidefinite matrix if and only if
1 − ρ2 ≥ 0;
2
0.55 − 0.36ρ − ρ ≥ 0,
which is equivalent to −1 ≤ ρ ≤ 1 and
ρ2 + 0.36ρ − 0.55 ≤ 0. (1.8)
Since the roots of the quadratic equation corresponding
to (1.8) are −0.9432 and 0.5832, we conclude that the
matrix Ω is symmetric positive semidefinite, and therefore
a correlation matrix, if and only if
−0.9432 ≤ ρ ≤ 0.5832. (1.9)
Question 6. How many independent random variables
uniformly distributed on [0, 1] should you generate to en-
sure that there is at least one between 0.70 and 0.72 with
probability 95%?
Answer: Denote by N the smallest number of random
variables you should generate such that
P (at least one r.v. in [0.70, 0.72]) ≥ 0.95. (1.10)
The probability that a random variable uniformly dis-
tributed on [0, 1] is not in the interval [0.70, 0.72] is 0.98.
Thus, the probability that none of the N independent
variables are in [0.70, 0.72] is 0.98N , i.e.,
P (no r.v. in [0.70, 0.72]) = 0.98N .
10 CHAPTER 1. FIRST LOOK: TEN QUESTIONS
Note that
P (at least one r.v. in [0.70, 0.72])
= 1 − P (no r.v. in [0.70, 0.72])
= 1 − (0.98)N . (1.11)
From (1.10) and (1.11), we find that N is the smallest
integer such that
1 − (0.98)N ≥ 0.95,
which is equivalent to
(0.98)N ≤ 0.05
⇐⇒ N ln(0.98) ≤ ln(0.05)
ln(0.05)
⇐⇒ N≥ ≈ 148.28
ln(0.98)
⇐⇒ N = 149.
We conclude that at least 149 uniform random vari-
ables on [0, 1] must be generated in order to have 95%
confidence that at least one of the random variables is
between 0.70 and 0.72.
Question 7. Show that the probability density function
of the standard normal integrates to 1.
Answer: The probability density function of the standard
t2
normal variable is √1
2π
e− 2 . We want to show that
Z ∞
1 t2
√ e− 2 dt = 1,
2π −∞
√
which, using the substitution t = 2x, can be written as
Z ∞
2 √
I = e−x dx = π. (1.12)
−∞
11
We prove (1.12) by using polar coordinates. Since x is
just an integrating variable, we can also write the integral
I in terms of another integrating variable, denoted by y,
R∞ 2
as I = −∞ e−y dy.
Then,3
Z ∞ Z ∞
2 2
I2 = e−x dx · e−y dy
−∞ −∞
Z ∞ Z ∞
−x2 −y 2
= e e dxdy (1.13)
−∞ −∞
Z ∞ Z ∞
2 2
= e−(x +y ) dxdy.
−∞ −∞
We use the polar coordinates transformation x = r cos θ
and y = r sin θ, with r ∈ [0, ∞) and θ ∈ [0, 2π), to
evaluate the last integral. Since dxdy = rdθdr, we obtain
that
Z ∞ Z ∞
2 2
I2 = e−(x +y ) dxdy
−∞ −∞
Z ∞ Z 2π 2 cos2 θ+r 2 sin2 θ
= r e−(r ) dθdr
0 0
Z ∞ Z 2π 2
= r e−r dθdr (1.14)
Z0 ∞ 0
2
= 2π r e−r dr
0
Z t
2
= 2π lim r e−r dr
t→∞ 0
t
1 2
= 2π lim − e−r
t→∞ 2 0
= π;
note that (1.14) follows from the equality cos2 θ + sin2 θ =
1 for any real number θ.
3
Note that Fubini’s theorem is needed for a rigorous derivation
of the equality (1.13); this technical step is rarely required by the
interviewer.
12 CHAPTER 1. FIRST LOOK: TEN QUESTIONS
√
Since I > 0, I = π, which is what we wanted to
prove; see (1.12).
Question 8. Assume the Earth is perfectly spherical and
you are standing somewhere on its surface. You travel
exactly 1 mile south, then 1 mile east, then 1 mile north.
Surprisingly, you find yourself back at the starting point.
If you are not at the North Pole, where can you possibly
be?!
Answer: There are infinitely many locations, aside from
the North Pole, that have this property.
Somewhere near the South Pole, there is a latitude
that has a circumference of one mile. In other words, if
you are at this latitude and start walking east (or west),
in one mile you will be back exactly where you started
from. If you instead start at some point one mile north
of this latitude, your journey will take you one mile south
to this special latitude, then one mile east “around the
globe” and finally one mile north right back to wherever
you started from. Moreover, there are infinitely many
points on the Earth that are one mile north of this special
latitude, where you could start your journey and eventu-
ally end up exactly where you started.
We are still not finished! There are infinitely many spe-
cial latitudes as well; namely, you could start at any point
one mile north of the latitude that has a circumference of
1/k miles, where k is a positive integer. Your journey will
take you one mile south to this special latitude, then one
mile east looping “around the globe” k times, and finally
one mile north right back to where you started from.
Question 9. Solve the Ornstein-Uhlenbeck SDE
drt = λ(θ − rt )dt + σdWt , (1.15)
which is used, e.g., in the Vasicek model for interest rates.
13
Answer: We can rewrite (1.15) as
drt + λrt dt = λθdt + σdWt . (1.16)
By multiplying (1.16) on both sides by the integrating
factor eλt , we obtain that
eλt drt + λeλt rt dt = λθeλt dt + σeλt dWt ,
which is equivalent to
d eλt rt = λθeλt dt + σeλt dWt . (1.17)
By integrating (1.17) from 0 to t, it follows that
Z t Z t
eλt rt − r0 = λθ eλsds + σ eλsdWs
0 0
Z t
= θ eλt − 1 + σ eλs dWs .
0
By solving for rt , we find that the solution to the Ornstein-
Uhlenbeck SDE is
Z t
rt = e−λt r0 + e−λt θ eλt − 1 + σe−λt eλsdWs
0
Z t
−λt −λt
= e r0 + θ 1 − e +σ e−λ(t−s) dWs .
0
Note that the process rt is mean reverting to θ, regard-
less of the starting point r0 . To see this,R recall that the
t
expected value of the stochastic integral 0 f (s)dWs of a
non-random function f (s) is 0. Then,
Z t
E e−λ(t−s) dWs = 0,
0
and therefore
E[rt ] = e−λt r0 + θ 1 − e−λt .
14 CHAPTER 1. FIRST LOOK: TEN QUESTIONS
Thus,
lim E[rt ] = θ.
t→∞
Question 10. Write a C++ function that computes the
n-th Fibonacci number.
Answer: The Fibonacci numbers (Fn )n≥0 are given by the
following recurrence:
Fn+2 = Fn+1 + Fn, ∀ n ≥ 0,
with F0 = 0 and F1 = 1.
//recursive implementation
int fib(int n) {
if (n == 0 || n == 1) return n;
else {
return fib(n-1) + fib(n-2);
}
}
//iterative implementation
int fib(int n ){
if (n == 0 || n == 1) return n;
int prev = 0, last = 1, temp;
for (int i = 2; i <= n; ++i) {
temp = last;
last = prev + last;
prev = temp;
}
return last;
}
//tail recursive implementation
int fib(int n, int last = 1, int prev = 0)
{
if (n == 0) return prev;
15
if (n == 1) return last;
return fib(n-1, last+prev, last);
}