[PYTHON] Introduction to Financial Engineering [Investment science] Chapter 2 Exercises Self-answer

Introduction

This article is a self-answer to the exercises at the end of each chapter of "Introduction to Financial Engineering," a Japanese translation of David G. Luenberger's "Investment science (Second edition)."

It's my own answer, so I hope you can use it as a reference. Also, if the answer given is incorrect or if there is a better method, please let me know.

Derivation etc. will be described as much as possible, and if numerical calculation etc. is necessary, it will be implemented using Python or R as appropriate.

Also, due to copyright issues, the problem statement will not be described, so please check the problem statement yourself. </ b> </ font>

Answer range

This article is the answer to the exercises in Chapter 2 "Basic Interest Rate Theory" </ b>.

answer

2.1 The end period of the investment is 2020 at the time of writing.

The desired price $ P $ was calculated as $ P = x \ left (1 + r \ right) ^ {n} \ tag {1} $. Here, $ x $: initial investment amount, $ r $: interest rate, $ n : investment period. (a) $r=0.033\\n=2020-1776=244$$ Is known.

This time $ \ left (i \ right) x = $ 1,000 $

From $ (1) $ $ P = 1000 (1 + 0.033) ^ {244} \ approx $ 2.76 million $

Similarly below $ \ left (ii \ right) x = $ 10,000 $ $ P = 100000 (1 + 0.033) ^ {244} \ approx $ 27.6 million $

$ \ left (iii \ right) x = $ 100,000 $ $ P = 1000000 (1 + 0.033) ^ {244} \ approx $ 276 million $

$ \ left (iv \ right) x = $ 1,000,000 $ $ P = 10000 (1 + 0.033) ^ {244} \ approx $ 2.76 billion $

(b) As $ r = 0.066 $, it can be solved by using $ (1) $ exactly as in (a), so if you check only $ \ left (i \ right) x = $ 1,000 $

$ P = 1000 (1 + 0.066) ^ {244} \ approx $ 5.9 billion $

(The power of compound interest is scary ...)

2.2

\begin{align}
\left(1+r\right)^{n}&=2\\
\Leftrightarrow n\ln\left(1+r\right)&=\ln2\tag{2}
\end{align}

here $\ln2=0.69\\\ \ln(1+r)\approx r$ By using $ (2) $ $n=\frac{0.69}{r}$ If you set $ r = i / 100 $ for percentage display $n=\frac{69}{i}$ Therefore, the subject is satisfied.

The other $n=\frac{72}{i}$ I don't know how to convince those who are close to, so please let me know if anyone knows.

2.3 The execution interest rate you want to find is $ r_0 $ to $ 1 + r_0 = \ left (1 + \ frac {r} {m} \ right) ^ {m} \ quad (m: compound interest implementation interval) $ And.

(a)

1+r_0=\left(1+\frac{0.03}{12}\right)^{12}\\
r_0=0.0304

(b)

1+r_0=\left(1+\frac{0.18}{12}\right)^{12}\\
r_0=0.1956

(c)

1+r_0=\left(1+\frac{0.18}{4}\right)^{4}\\
r_0=0.1925

2.4 In the text, only the definition of Newton's method is written, but I have derived it for the time being, so I will describe it.

\begin{align}
f(\lambda)&=-a_0+a_1\lambda+\cdots+a_n\lambda^n\\
f'(\lambda)&=a_1+2a_2\lambda+\cdots+na_n\lambda^{n-1}
\end{align}

At this time, determine an appropriate solution $ \ lambda_0 $ under the condition of $ \ lambda> 0 $, and a straight line with a slope of $ f'(\ lambda_0) $ passing through $ (\ lambda_0, f (\ lambda_0)) $. Update the intersection of and the $ x $ axis as $ \ lambda_1 $. If this straight line is $ g (\ lambda) $, then $ g (\ lambda) $ is

g(\lambda)=f'(\lambda_0)(\lambda-\lambda_0)+f(\lambda_0)

And the intersection $ \ lambda_1 $ is

f'(\lambda_0)(\lambda_1-\lambda_0)+f(\lambda_0)=0\\
\therefore \lambda_1=\lambda_0-\frac{f(\lambda_0)}{f'(\lambda_0)}

By doing this work many times, you get the general expression $ \ lambda_ {k + 1} = \ lambda_k- \ frac {f (\ lambda_k)} {f'(\ lambda_k)} \ tag {3} $ ..

Well, the main subject,

f(\lambda)=-1+\lambda+\lambda^2\\
f'(\lambda)=1+2\lambda\\
\lambda_0=1

Find $ \ lambda_1, \ lambda_2, \ lambda_3 $ as. Since it is only assigned to $ (3) $, the calculation is omitted.

\begin{align}
\lambda_1&=\frac{2}{3} \\
\lambda_2&=\frac{13}{21} \\
\lambda_3&=0.62
\end{align}

Let's run it easily in Python.

import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

def f(x):
    y=-1+x+x**2
    return y
def df(x):
    y=1+2*x
    return y

lam=1
num=10
plt.figure(figsize=(4,3))
y = [lam,]

for i in range(num):
    lam = lam - (f(lam)/df(lam))
    print(lam)
    y.append(lam)
    
plt.plot(np.arange(num+1),y)

Execution result newton.jpg

Value for each update of $ \ lambda $

0.6666666666666667 0.6190476190476191 0.6180344478216818 0.618033988749989 0.6180339887498948 0.6180339887498948 0.6180339887498948 0.6180339887498948 0.6180339887498948 0.6180339887498948

After updating the value of $ \ lambda $ four or five times, the error can be regarded as 0. (For some reason, the X-axis label sticks out ...)

2.5 This question is taken up in the exercises in Chapter 2 and lists two methods, one is to evaluate by present value and the other is to evaluate by internal rate of return. Similarly, I will try to solve this problem by two methods, but it seems that this problem is intended to be evaluated by present value. (I don't think the internal rate of return can be calculated.)

1. Evaluated by present value

The present value of $ PV_n $ after waiting $ n $ years is $PV_n=-1+\frac{n+1}{(1+0.1)^n}$ Will be. This time

\begin{align}
PV_{n+1}-PV_{n}&=\left(-1+\frac{n+2}{1.1^{n+1}}\right)-\left(-1+\frac{n+1}{1.1^{n}}\right) \\
&=\frac{1}{1.1^n}\left(\frac{n+2}{1.1}-(n+1)\right)
\end{align}

This time I'm interested in the code, so I only have to think about it in the parentheses of the last expression. $\frac{n+2}{1.1}-(n+1)=\frac{-0.1n+0.9}{1.1}$ This

PV_{n+1}-PV_{n}Is\begin{cases}n<9\rightarrow +\\ n=9\rightarrow 0\\ n >9\rightarrow -\end{cases}

Therefore, the present value increases monotonically up to $ PV_9 $, but it becomes equal at $ PV_9 $ and $ PV_ {10} $ and continues to decrease monotonically thereafter, so $ n = 9,10 $ is considered to be the best. Be done.

2. Evaluated by internal rate of return

If this project is not a one-time project but is repeated many times, it is desirable to consider the internal rate of return. The internal rate of return $ r_n $ of the project that waited $ n $ years at this time is

-1+c^n(n+1)=0\quad\left(c=\frac{1}{1+r_n}\right) 

Meet.

c^n=\frac{1}{n+1} \\\ c=\left(\frac{1}{n+1}\right)^{\frac{1}{n}}

When $ r $ is large, $ c $ takes a small value, so you can find $ c $ which takes the minimum value. I feel that it looks like $ \ log $ somehow, but after confirming it, I implemented Python. I feel that this calculation can be solved if I do my best, but I can't remember how to do it, so please let me know if you can understand it.

import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

y = []
num = 1100
def IRR(n):
    y=(1/(n+1))**(1/n)
    return y

for i in range(num):
    i+=1
    y.append(IRR(i))

x = np.arange(num)
x+=1

plt.figure(figsize=(4,3))
plt.plot(x,y)
plt.xlabel("num")
plt.ylabel("c")
plt.savefig('IRR.png')

IRR.png

Also, I'm sorry that the X-axis label is cut off, but it is a graph showing the relationship between $ n $ and $ c $. Looking at this, it came out with a feeling like $ \ log $. Therefore, as you can see from the graph, the point with the best internal rate of return seems to be $ n = 1 $.

2.6

Since this is a simple calculation problem, only the formula is described.

(a) \left(1+\frac{0.1}{12}\right)^{12}=1.104713\cdots \\
(b) e^{0.1}=1.105170\cdots

Therefore, the interest rate $ r $ is $(a)r=10.471\%\\\ (b)r=10.517\%$

Is.

Maybe ...

(a) \left(1+\frac{r}{12}\right)^{12}=1.10 \\
(b) e^{r}=1.10

It may be a problem in the sense of finding $ r $ that satisfies. I couldn't judge either by just reading the text.

By the way, this answer is $(a)r=9.5670\% \\\ (b)r=9.5310\%$ It will be.

2.7 This problem is simply $PV=\sum ^{19}_{k=0}\frac {50}{\left( 1.1\right) ^{k}}$ However, I will also post the derivation of the solution method using an infinite series.

\begin{align}
\sum^{n}_{0}\frac{a}{(1+r)^k}&=\sum^{\infty}_{0}\frac{a}{(1+r)^k}-\sum^{\infty}_{n+1}\frac{a}{(1+r)^k} \\
&=\frac{a(1+r)}{r}-\frac{1}{(1+r)^{n+1}}\frac{a(1+r)}{r} \\
&=\left(1-\frac{1}{(1+r)^{n+1}}\right)\frac{a(1+r)}{r}
\end{align}

Therefore, Substituting $ r = 0.1 \\\ n = 19 \\\ a = 50 $ to obtain $$ PV = $ 46.824 million.

Recommended Posts