Skip to content

Commit 1a5b6c5

Browse files
Merge pull request #133 from QuantEcon/wip-lecture-geometric
add Symbolics to Project.toml
2 parents 98793b1 + cef96f2 commit 1a5b6c5

File tree

3 files changed

+9
-35
lines changed

3 files changed

+9
-35
lines changed

lectures/Manifest.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,9 +1014,9 @@ version = "5.1.0+5"
10141014

10151015
[[MKL_jll]]
10161016
deps = ["Artifacts", "IntelOpenMP_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "Pkg"]
1017-
git-tree-sha1 = "c253236b0ed414624b083e6b72bfe891fbd2c7af"
1017+
git-tree-sha1 = "5455aef09b40e5020e1520f551fa3135040d4ed0"
10181018
uuid = "856f044c-d86e-5d09-b602-aeab76dc8ba7"
1019-
version = "2021.1.1+1"
1019+
version = "2021.1.1+2"
10201020

10211021
[[MPFR_jll]]
10221022
deps = ["Artifacts", "GMP_jll", "Libdl"]

lectures/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
5050
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
5151
StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd"
5252
StochasticDiffEq = "789caeaf-c7a9-5a7d-9973-96adeb23e2a0"
53+
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
5354
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
5455
VegaLite = "112f6efa-9a02-5b7d-90c0-432ed331239a"
5556
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

lectures/tools_and_techniques/geom_series.md

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -767,36 +767,6 @@ This graph gives a big hint for why the condition $r > g$ is
767767
necessary if a lease of length $T = +\infty$ is to have finite
768768
value.
769769

770-
For fans of 3-d graphs the same point comes through in the following
771-
graph.
772-
773-
If you aren't enamored of 3-d graphs, feel free to skip the next
774-
visualization!
775-
776-
```{code-cell} julia
777-
# Second view
778-
plt = plot(xlim = (-0.04, 1.1),ylim = (-0.04, 1.1), zlim = (0,15), title= "Three Period Lease PV with Varying g and r", xlabel = "r", ylabel = "g", zlabel = "Present Value, p0")
779-
780-
T = 3
781-
r = 0.01:0.005:0.985
782-
g = 0.011:0.005:0.986
783-
784-
# Construct meshgrid, similar to Numpy.meshgrid in Python
785-
function meshgrid(r, g)
786-
rr = [i for i in r, j in 1:length(g)]
787-
gg = [j for i in 1:length(r), j in g]
788-
return rr, gg
789-
end
790-
791-
rr, gg = meshgrid(r, g)
792-
z = finite_lease_pv_true(T, gg, rr, x_0)
793-
794-
# Removes points where undefined
795-
z[rr .== gg] .= NaN
796-
797-
plot!(r, g, z, st = :surface, colour = :balance, camera=(20,50))
798-
```
799-
800770
We can use a little calculus to study how the present value $p_0$
801771
of a lease varies with $r$ and $g$.
802772

@@ -816,21 +786,24 @@ After that, we'll use `Symbolics.jl` to compute derivatives
816786
G = (1 + g)
817787
R = (1 + r)
818788
p0 = x0 / (1 - G * R ^ (-1))
819-
print("Our formula is: $p0")
789+
print("Our formula is")
790+
p0
820791
```
821792

822793
```{code-cell} julia
823794
# Partial derivative with respect to g
824795
dg = Differential(g)
825796
dp_dg = expand_derivatives(dg(p0))
826-
print("dp0 / dg is: ", dp_dg)
797+
print("dp0 / dg is")
798+
dp_dg
827799
```
828800

829801
```{code-cell} julia
830802
# Partial derivative with respect to r
831803
dr = Differential(r)
832804
dp_dr = expand_derivatives(dr(p0))
833-
print("dp0 / dr is: ", dp_dr)
805+
print("dp0 / dr is")
806+
dp_dr
834807
```
835808

836809
We can see that for $\frac{\partial p_0}{\partial r}<0$ as long as

0 commit comments

Comments
 (0)