Math 489/889 

Stochastic Processes and 

Advanced Mathematical Finance 

Homework 6 

Steve Dunbar 

Due Monday, October 13, 2010 

 

Problem 1 

`assign`(Duration, `+`(`/`(`*`(T0), `*`(`+`(q, `-`(p)))), `-`(`/`(`*`(a, `*`(`+`(1, `-`(`^`(`/`(`*`(q), `*`(p)), T0))))), `*`(`+`(q, `-`(p)), `*`(`+`(1, `-`(`^`(`/`(`*`(q), `*`(p)), a))))))))) 

`+`(`/`(`*`(T0), `*`(`+`(q, `-`(p)))), `-`(`/`(`*`(a, `*`(`+`(1, `-`(`^`(`/`(`*`(q), `*`(p)), T0))))), `*`(`+`(q, `-`(p)), `*`(`+`(1, `-`(`^`(`/`(`*`(q), `*`(p)), a)))))))) (1.1)
 

 

Part a 

For $ T_0 = 10 $  and $ a = 20 $ , draw a graph of theduration as a function of the probability $ q $ .  

 

plot(subs({T0 = 10, a = 20, p = `+`(1, `-`(q))}, Duration), q = 0 .. 1) 

Plot_2d
 

 

 

Part b 

For $ a = 20 $  and $ q = 0.55 $  draw a graph of the expected duration as a function of $ T_0 $ .  

 

plot(subs({a = 20, p = .45, q = .55}, Duration), T0 = 0 .. 20) 

Plot_2d
 

 

 

Part c 

For $ a = 20 $  and $ q = 0.45 $  draw a graph of the expected duration as a function of $ T_0 $ .  

 

plot(subs({a = 20, p = .55, q = .45}, Duration), T0 = 0 .. 20) 

Plot_2d
 

 

 

Problem 2 

The boundary condition at state 26 says that the duration of the "game" from 26 down to 18 is the sum of hte duration of the subsequent games from 26 down to 25, and then from 25 to 18.  We can compute the duration of the first sub-game using Corollary 1.  Then the set of 9 first-step equations in 9 unknowns is: 

`assign`(eqn26, D26 = `+`(`/`(1, `*`(`+`(`/`(2, 3), -`/`(1, 3)))), D25)); 1; `assign`(eqn25, D25 = `+`(`*`(`/`(1, 3), `*`(D26)), `*`(`/`(2, 3), `*`(D24)), 1)); 1; `assign`(eqn24, D24 = `+`(`*`(`/`(1, ...
`assign`(eqn26, D26 = `+`(`/`(1, `*`(`+`(`/`(2, 3), -`/`(1, 3)))), D25)); 1; `assign`(eqn25, D25 = `+`(`*`(`/`(1, 3), `*`(D26)), `*`(`/`(2, 3), `*`(D24)), 1)); 1; `assign`(eqn24, D24 = `+`(`*`(`/`(1, ...
`assign`(eqn26, D26 = `+`(`/`(1, `*`(`+`(`/`(2, 3), -`/`(1, 3)))), D25)); 1; `assign`(eqn25, D25 = `+`(`*`(`/`(1, 3), `*`(D26)), `*`(`/`(2, 3), `*`(D24)), 1)); 1; `assign`(eqn24, D24 = `+`(`*`(`/`(1, ...
`assign`(eqn26, D26 = `+`(`/`(1, `*`(`+`(`/`(2, 3), -`/`(1, 3)))), D25)); 1; `assign`(eqn25, D25 = `+`(`*`(`/`(1, 3), `*`(D26)), `*`(`/`(2, 3), `*`(D24)), 1)); 1; `assign`(eqn24, D24 = `+`(`*`(`/`(1, ...
`assign`(eqn26, D26 = `+`(`/`(1, `*`(`+`(`/`(2, 3), -`/`(1, 3)))), D25)); 1; `assign`(eqn25, D25 = `+`(`*`(`/`(1, 3), `*`(D26)), `*`(`/`(2, 3), `*`(D24)), 1)); 1; `assign`(eqn24, D24 = `+`(`*`(`/`(1, ...
`assign`(eqn26, D26 = `+`(`/`(1, `*`(`+`(`/`(2, 3), -`/`(1, 3)))), D25)); 1; `assign`(eqn25, D25 = `+`(`*`(`/`(1, 3), `*`(D26)), `*`(`/`(2, 3), `*`(D24)), 1)); 1; `assign`(eqn24, D24 = `+`(`*`(`/`(1, ...
`assign`(eqn26, D26 = `+`(`/`(1, `*`(`+`(`/`(2, 3), -`/`(1, 3)))), D25)); 1; `assign`(eqn25, D25 = `+`(`*`(`/`(1, 3), `*`(D26)), `*`(`/`(2, 3), `*`(D24)), 1)); 1; `assign`(eqn24, D24 = `+`(`*`(`/`(1, ...
`assign`(eqn26, D26 = `+`(`/`(1, `*`(`+`(`/`(2, 3), -`/`(1, 3)))), D25)); 1; `assign`(eqn25, D25 = `+`(`*`(`/`(1, 3), `*`(D26)), `*`(`/`(2, 3), `*`(D24)), 1)); 1; `assign`(eqn24, D24 = `+`(`*`(`/`(1, ...
`assign`(eqn26, D26 = `+`(`/`(1, `*`(`+`(`/`(2, 3), -`/`(1, 3)))), D25)); 1; `assign`(eqn25, D25 = `+`(`*`(`/`(1, 3), `*`(D26)), `*`(`/`(2, 3), `*`(D24)), 1)); 1; `assign`(eqn24, D24 = `+`(`*`(`/`(1, ...
`assign`(eqn26, D26 = `+`(`/`(1, `*`(`+`(`/`(2, 3), -`/`(1, 3)))), D25)); 1; `assign`(eqn25, D25 = `+`(`*`(`/`(1, 3), `*`(D26)), `*`(`/`(2, 3), `*`(D24)), 1)); 1; `assign`(eqn24, D24 = `+`(`*`(`/`(1, ...
 

 

 

 

 

 

 

 

 

D26 = `+`(3, D25)
D25 = `+`(`*`(`/`(1, 3), `*`(D26)), `*`(`/`(2, 3), `*`(D24)), 1)
D24 = `+`(`*`(`/`(1, 3), `*`(D25)), `*`(`/`(2, 3), `*`(D23)), 1)
D23 = `+`(`*`(`/`(1, 3), `*`(D24)), `*`(`/`(2, 3), `*`(D22)), 1)
D22 = `+`(`*`(`/`(1, 3), `*`(D23)), `*`(`/`(2, 3), `*`(D21)), 1)
D21 = `+`(`*`(`/`(9, 10), `*`(D22)), `*`(`/`(1, 10), `*`(D20)), 1)
D20 = `+`(`*`(`/`(3, 4), `*`(D21)), `*`(`/`(1, 4), `*`(D19)), 1)
D19 = `+`(`*`(`/`(3, 4), `*`(D20)), `*`(`/`(1, 4), `*`(D18)), 1)
D18 = 0 (2.1)
 

`assign`(durations, solve({eqn18, eqn19, eqn20, eqn21, eqn22, eqn23, eqn24, eqn25, eqn26}, {D18, D19, D20, D21, D22, D23, D24, D25, D26})); 1
`assign`(durations, solve({eqn18, eqn19, eqn20, eqn21, eqn22, eqn23, eqn24, eqn25, eqn26}, {D18, D19, D20, D21, D22, D23, D24, D25, D26})); 1
 

{D18 = 0, D19 = 349, D20 = 464, D21 = 501, D22 = 504, D23 = 507, D24 = 510, D25 = 513, D26 = 516}
{D18 = 0, D19 = 349, D20 = 464, D21 = 501, D22 = 504, D23 = 507, D24 = 510, D25 = 513, D26 = 516}
(2.2)
 

subs(%, D25); 1 

513 (2.3)
 

 

Problem 3 

 

Insert the trial solution 

 

`^`(W[sk], p) = piecewise(`<=`(s, k), 0, `>=`(s, k), `+`(`-`(`*`(2, `+`(s, `-`(k)))))) 

into the difference equation.   For  s < kthe substitution yields 0 = `+`(`+`(0, `*`(`/`(1, 2), 0)), `*`(0, `/`(1, 2)))so the equation is satisfied by the trial particular solution. 

For `>`(s, k) the difference equation becomes `*`(2, `+`(`-`(s), k)) = `+`(`+`(0, `*`(`*`(`/`(1, 2), 2), `*`(`+`(k, `+`(`-`(s), 1))))), `*`(`*`(`/`(1, 2), 2), `*`(`+`(k, `+`(`-`(s), `-`(1)))))) and again the equation is satisfied identically. 

For s = k, the difference equation becomes    Therefore, the particular solution is  

`^`(W[sk], p) = piecewise(`<=`(s, k), 0, `>=`(s, k), `+`(`-`(`*`(2, `+`(s, `-`(k))))))= `+`(`-`(`*`(2, `*`(max(0, `+`(s, `-`(k))))))). 

 

Problem 4 

`assign`(ExpectedVisits, `*`(2, [`+`(`/`(`*`(s, `*`(sum(`*`(k, `*`(`+`(S, `-`(k)))), k = 1 .. `+`(S, `-`(1))))), `*`(S)), `-`(sum(`*`(k, `*`(`+`(s, `-`(k)))), k = 1 .. `+`(s, `-`(1)))))])) 

[`+`(`/`(`*`(2, `*`(s, `*`(`+`(`*`(`/`(1, 6), `*`(`^`(S, 3))), `-`(`*`(`/`(1, 6), `*`(S))))))), `*`(S)), `-`(`*`(`/`(1, 3), `*`(`^`(s, 3)))), `*`(`/`(1, 3), `*`(s)))] (4.1)
 

 

[`+`(`*`(`/`(1, 3), `*`(s, `*`(`+`(`*`(`^`(S, 2)), `-`(`*`(`^`(s, 2))))))))] (4.2)
 

 

`assign`(SumIntegers, sum(k, k = 1 .. N)) 

`+`(`*`(`/`(1, 2), `*`(`^`(`+`(N, 1), 2))), `-`(`*`(`/`(1, 2), `*`(N))), `-`(`/`(1, 2))) (4.3)
 

 

`+`(`*`(`/`(1, 2), `*`(`^`(N, 2))), `*`(`/`(1, 2), `*`(N))) (4.4)
 

 

`assign`(SumSquares, sum(`*`(`^`(k, 2)), k = 1 .. N)) 

`+`(`*`(`/`(1, 3), `*`(`^`(`+`(N, 1), 3))), `-`(`*`(`/`(1, 2), `*`(`^`(`+`(N, 1), 2)))), `*`(`/`(1, 6), `*`(N)), `/`(1, 6)) (4.5)
 

 

`+`(`*`(`/`(1, 3), `*`(`^`(N, 3))), `*`(`/`(1, 2), `*`(`^`(N, 2))), `*`(`/`(1, 6), `*`(N))) (4.6)
 

 

 

`assign`(SumQuadratic, sum(`*`(k, `*`(`+`(M, `-`(k)))), k = 1 .. N)) 

`+`(`*`(`/`(1, 2), `*`(M, `*`(`^`(`+`(N, 1), 2)))), `-`(`*`(`/`(1, 2), `*`(M, `*`(`+`(N, 1))))), `-`(`*`(`/`(1, 3), `*`(`^`(`+`(N, 1), 3)))), `*`(`/`(1, 2), `*`(`^`(`+`(N, 1), 2))), `-`(`*`(`/`(1, 6),... (4.7)
 

 

`+`(`*`(`/`(1, 2), `*`(M, `*`(`^`(N, 2)))), `*`(`/`(1, 2), `*`(M, `*`(N))), `-`(`*`(`/`(1, 3), `*`(`^`(N, 3)))), `-`(`*`(`/`(1, 2), `*`(`^`(N, 2)))), `-`(`*`(`/`(1, 6), `*`(N)))) (4.8)
 

 

`assign`(ComninationPowers, `+`(`*`(M, `*`(SumIntegers)), `-`(SumSquares))) 

`+`(`*`(M, `*`(`+`(`*`(`/`(1, 2), `*`(`^`(`+`(N, 1), 2))), `-`(`*`(`/`(1, 2), `*`(N))), `-`(`/`(1, 2))))), `-`(`*`(`/`(1, 3), `*`(`^`(`+`(N, 1), 3)))), `*`(`/`(1, 2), `*`(`^`(`+`(N, 1), 2))), `-`(`*`(... (4.9)
 

 

`+`(`*`(`/`(1, 2), `*`(M, `*`(`^`(N, 2)))), `*`(`/`(1, 2), `*`(M, `*`(N))), `-`(`*`(`/`(1, 3), `*`(`^`(N, 3)))), `-`(`*`(`/`(1, 2), `*`(`^`(N, 2)))), `-`(`*`(`/`(1, 6), `*`(N)))) (4.10)
 

 

Problem 5 

`assign`(C, `/`(`*`(`+`(K, `*`(`/`(1, 3), `*`(r, `*`(`^`(S, 3), `*`(x, `*`(`+`(1, `-`(`*`(`^`(x, 2))))))))))), `*`(`^`(S, 2), `*`(x, `*`(`+`(1, `-`(x))))))) 

`/`(`*`(`+`(K, `*`(`/`(1, 3), `*`(r, `*`(`^`(S, 3), `*`(x, `*`(`+`(1, `-`(`*`(`^`(x, 2))))))))))), `*`(`^`(S, 2), `*`(x, `*`(`+`(1, `-`(x)))))) (5.1)
 

 

Part a 

`assign`(dCdx, diff(C, x)); 1 

`+`(`/`(`*`(`+`(`*`(`/`(1, 3), `*`(r, `*`(`^`(S, 3), `*`(`+`(1, `-`(`*`(`^`(x, 2)))))))), `-`(`*`(`/`(2, 3), `*`(r, `*`(`^`(S, 3), `*`(`^`(x, 2)))))))), `*`(`^`(S, 2), `*`(x, `*`(`+`(1, `-`(x)))))), `... (5.1.1)
 

 

 

Part b 

`assign`(dCdS, diff(C, S)); 1 

`+`(`/`(`*`(r, `*`(`+`(1, `-`(`*`(`^`(x, 2)))))), `*`(`+`(1, `-`(x)))), `-`(`/`(`*`(2, `*`(`+`(K, `*`(`/`(1, 3), `*`(r, `*`(`^`(S, 3), `*`(x, `*`(`+`(1, `-`(`*`(`^`(x, 2)))))))))))), `*`(`^`(S, 3), `*... (5.2.1)
 

 

Part c 

`assign`(optima, solve({dCdS = 0, dCdx = 0}, {S, x})); 1 

{S = `+`(`*`(3, `*`(RootOf(`+`(`*`(4, `*`(`^`(_Z, 3), `*`(r))), `-`(`*`(3, `*`(K)))))))), x = `/`(1, 3)} (5.3.1)
 

allvalues(optima); 1 

{S = `+`(`*`(`/`(3, 4), `*`(`^`(3, `/`(1, 3)), `*`(`^`(4, `/`(2, 3)), `*`(`^`(`/`(`*`(K), `*`(r)), `/`(1, 3))))))), x = `/`(1, 3)}, {S = `+`(`*`(`/`(3, 4), `*`(`^`(3, `/`(1, 3)), `*`(`^`(4, `/`(2, 3))...
{S = `+`(`*`(`/`(3, 4), `*`(`^`(3, `/`(1, 3)), `*`(`^`(4, `/`(2, 3)), `*`(`^`(`/`(`*`(K), `*`(r)), `/`(1, 3))))))), x = `/`(1, 3)}, {S = `+`(`*`(`/`(3, 4), `*`(`^`(3, `/`(1, 3)), `*`(`^`(4, `/`(2, 3))...
(5.3.2)
 

Inspect carefully, one solution set with is real, the other terms have complex factors `*`(`^`(-1, `/`(2, 3))) and `*`(`^`(-1, `/`(1, 3))). 

 

We can also solve the partial derivative eqations "by hand". 

Set the derivative dCdS equal to 0, then clear denominators. 

`*`(r, `*`(`^`(S, 3), `*`(x, `*`(`+`(1, `-`(`*`(`^`(x, 2)))))))) = `*`(2, `+`(K, `*`(`/`(1, 3), `*`(r, `*`(`^`(S, 3), `*`(x, `*`(`+`(1, `-`(`*`(`^`(x, 2))))))))))) 

`*`(r, `*`(`^`(S, 3), `*`(x, `*`(`+`(1, `-`(`*`(`^`(x, 2)))))))) = `+`(`*`(2, `*`(K)), `*`(`/`(2, 3), `*`(r, `*`(`^`(S, 3), `*`(x, `*`(`+`(1, `-`(`*`(`^`(x, 2)))))))))) (5.3.3)
 

 

K = `+`(`*`(`/`(1, 6), `*`(r, `*`(`^`(S, 3), `*`(x, `*`(`+`(1, `-`(`*`(`^`(x, 2)))))))))) (5.3.4)
 

 

 

Substitute this into the derivative with respect to x. 

subs(K = `+`(`*`(`/`(1, 6), `*`(r, `*`(`^`(S, 3), `*`(x, `*`(`+`(1, `-`(`*`(`^`(x, 2)))))))))), dCdx); 1 

`+`(`/`(`*`(`+`(`*`(`/`(1, 3), `*`(r, `*`(`^`(S, 3), `*`(`+`(1, `-`(`*`(`^`(x, 2)))))))), `-`(`*`(`/`(2, 3), `*`(r, `*`(`^`(S, 3), `*`(`^`(x, 2)))))))), `*`(`^`(S, 2), `*`(x, `*`(`+`(1, `-`(x)))))), `... (5.3.5)
 

 

`+`(`-`(`/`(`*`(`/`(1, 6), `*`(`+`(`*`(3, `*`(x)), `-`(1)), `*`(r, `*`(S)))), `*`(x, `*`(`+`(`-`(1), x)))))) (5.3.6)
 

 

Now this derivative is 0 when x = `/`(1, 3).  Note that x = 0 and x = 1 are not realistic values of x, that is, the values x = 0 and x = 1 are not in the domain so the denominator is never 0 in the domain.  Likewise, r and S are not 0.  Then substitute x = `/`(1, 3)back into the expression for K 

subs(x = `/`(1, 3), K = `+`(`*`(`/`(1, 6), `*`(r, `*`(`^`(S, 3), `*`(x, `*`(`+`(1, `-`(`*`(`^`(x, 2))))))))))) 

K = `+`(`*`(`/`(4, 81), `*`(r, `*`(`^`(S, 3))))) (5.3.7)
 

 

S = RootOf(`+`(`*`(4, `*`(`^`(_Z, 3), `*`(r))), `-`(`*`(81, `*`(K))))) (5.3.8)
 

 

allvalues(%); 1 

S = `+`(`*`(`/`(1, 4), `*`(`^`(81, `/`(1, 3)), `*`(`^`(4, `/`(2, 3)), `*`(`^`(`/`(`*`(K), `*`(r)), `/`(1, 3))))))), S = `+`(`*`(`/`(1, 4), `*`(`^`(81, `/`(1, 3)), `*`(`^`(4, `/`(2, 3)), `*`(`^`(`/`(`*...
S = `+`(`*`(`/`(1, 4), `*`(`^`(81, `/`(1, 3)), `*`(`^`(4, `/`(2, 3)), `*`(`^`(`/`(`*`(K), `*`(r)), `/`(1, 3))))))), S = `+`(`*`(`/`(1, 4), `*`(`^`(81, `/`(1, 3)), `*`(`^`(4, `/`(2, 3)), `*`(`^`(`/`(`*...
(5.3.9)