-
Present Values 3
-
Lecture1.1
-
Lecture1.2
-
Lecture1.3
-
-
NPV vs. IRR 4
-
Lecture2.1
-
Lecture2.2
-
Lecture2.3
-
Lecture2.4
-
-
Other Profit Measures 4
-
Lecture3.1
-
Lecture3.2
-
Lecture3.3
-
Lecture3.4
-
-
Depreciation 4
-
Lecture4.1
-
Lecture4.2
-
Lecture4.3
-
Lecture4.4
-
-
Cash Flow Challenges 9
-
Lecture5.1
-
Lecture5.2
-
Lecture5.3
-
Lecture5.4
-
Lecture5.5
-
Lecture5.6
-
Lecture5.7
-
Lecture5.8
-
Lecture5.9
-
-
Capital Asset Pricing Model 3
-
Lecture6.1
-
Lecture6.2
-
Lecture6.3
-
-
Risky Debt 3
-
Lecture7.1
-
Lecture7.2
-
Lecture7.3
-
-
Unlevering Equity 3
-
Lecture8.1
-
Lecture8.2
-
Lecture8.3
-
-
Weighted Average Cost of Capital 4
-
Lecture9.1
-
Lecture9.2
-
Lecture9.3
-
Lecture9.4
-
-
Debt Effect Analysis 2
-
Lecture10.1
-
Lecture10.2
-
-
WACC Challenge 2
-
Lecture11.1
-
Lecture11.2
-
-
Relative Valuation 4
-
Lecture12.1
-
Lecture12.2
-
Lecture12.3
-
Lecture12.4
-
-
Forward Contract Valuation 3
-
Lecture13.1
-
Lecture13.2
-
Lecture13.3
-
Solving Systems of Equations
We can solve these systems of equations with numpy’s linear algebra library.
Year 1 Cash Flow = 100x
1
+ 10x
2
+ 5x
3
Year 2 Cash Flow = 100x
2
+ 5x
3
Year 3 Cash Flow = 100x
3
If the cash flows were 200, 300 and 400 in the years, what would the value of the cash flows be?
Let’s first define the the system of equations as a matrix A
100 | 10 | 5 |
0 | 100 | 5 |
0 | 0 | 100 |
Let’s also define the project cash flows as a matrix B
200 |
300 |
400 |
And now we are going to use the numpy.linalg.solve. You can read about it here: https://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.solve.html. The way it works is we feed the function our A matrix and B matrix, and then it spits back the X matrix that solves the system of equations Ax = B
Now let’s create our matrices in python. To do this we will make a nested array, the inside arrays are each row.
import numpy as np
A = np.array( [ [100,10,5],[0,100,5],[0,0,100] ] )
B = np.array([200,300,400])
Now that we have our arrays set up, we can solve with numpy’s linear algebra function.
x = np.linalg.solve(A, B)
print(x)
What this array says is that we need 1.52 of bond 1, 2.8 of bond 2, 4 of bond 3.
Now to find the price of our cash flows, we would multiply these numbers by the price of each bond. Let’s say prices are 90, 100, and 110 respectively.
print(x*[90,100,110])
print(sum(x*[90,100,110]))
We value our cash flows at 856.8! Something to note is that we might have a negative in our x matrix, this means that we are going to sell this bond and that means the price will end up being subtracted insteaded of added (the program will take care of this on its own though).