Course Test · University: upper level

Financial mathematics: RatMath answers

The same twenty exercises, answered with RatMath Core and the Shelf libraries only. The code below was run when this page was built; its output is shown as printed, and compared with the independent answer.

Agrees 20

Libraries used here: core, finance. In this code each library is in scope under its own name (linalg.det, stats.tTest), and Core's names (R, Rational, …) are in scope directly.

  1. 1.Effective rateAgrees
    What effective annual rate corresponds to 6% compounded monthly?
    Independent answer
    (1+0.06/12)12−1=1.00512−1≈6.16778%(1 + 0.06/12)^{12} - 1 = 1.005^{12} - 1 \approx 6.16778\%.
    RatMath code
    finance.effectiveRate("6%", 12)
    Output
    0.061677811864499568789707…
  2. 2.Compound interestAgrees
    What does \$1000 grow to in 10 years at 5% compounded annually?
    Independent answer
    1000⋅1.0510≈$1628.891000 \cdot 1.05^{10} \approx \$1628.89.
    RatMath code
    finance.compound(1000, "5%", 10)
    Output
    16679880978201/10240000000
  3. 3.Continuous compoundingAgrees
    What does \$1000 grow to in 10 years at 5% compounded continuously?
    Independent answer
    1000e0.5≈$1648.721000e^{0.5} \approx \$1648.72.
    RatMath code
    R`1000`.multiply(finance.exp(R`5/100 * 10`))
    Output
    1648.7212707001281468486[5:6]
  4. 4.Annuity-immediateAgrees
    Find the present value of \$100 paid at the end of each year for 10 years at 5%.
    Independent answer
    100 a10‾∣=100⋅1−1.05−100.05≈$772.17100\,a_{\overline{10}|} = 100\cdot\frac{1 - 1.05^{-10}}{0.05} \approx \$772.17.
    RatMath code
    finance.annuity({ payment: 100, rate: "5%", periods: 10 }).presentValue
    Output
    12879761956402000/16679880978201
  5. 5.Annuity-dueAgrees
    The same payments are made at the start of each year instead. Find the present value.
    Independent answer
    100 a¨10‾∣=1.05×772.173493≈$810.78100\,\ddot a_{\overline{10}|} = 1.05 \times 772.173493 \approx \$810.78.
    RatMath code
    finance.annuity({ payment: 100, rate: "5%", periods: 10, due: true }).presentValue
    Output
    643988097820100/794280046581
  6. 6.Growing perpetuityAgrees
    A perpetuity pays \$100 next year, growing by 2% a year after that. At 6%, what is it worth?
    Independent answer
    1000.06−0.02=$2500\frac{100}{0.06 - 0.02} = \$2500.
    RatMath code
    finance.perpetuity({ payment: 100, rate: "6%", growth: "2%" })
    Output
    2500
  7. 7.Loan paymentAgrees
    Find the monthly payment on a \$250{,}000, 30-year loan at 6% a year compounded monthly.
    Independent answer
    250000⋅0.0051−1.005−360≈$1498.88250000 \cdot \frac{0.005}{1 - 1.005^{-360}} \approx \$1498.88.
    RatMath code
    finance.loan({ principal: 250000, rate: "6%", periods: 360 }).payment
    Output
    37472/25
  8. 8.Paying extraAgrees
    With \$200 a month extra on the same loan, how many payments does it take?
    Independent answer
    Running the balance forward, B↦1.005B−1698.88B \mapsto 1.005B - 1698.88, it reaches zero at the 267th payment.
    RatMath code
    finance.loan({ principal: 250000, rate: "6%", periods: 360, extra: 200 }).periods
    Output
    267
  9. 9.Net present valueAgrees
    A project costs \$1000 now and returns \$300, \$400 and \$500 at the ends of the next three years. Find its NPV at 10%.
    Independent answer
    −1000+3001.1+4001.12+5001.13≈−$21.04-1000 + \frac{300}{1.1} + \frac{400}{1.1^2} + \frac{500}{1.1^3} \approx -\$21.04: not worth it at 10%.
    RatMath code
    finance.npv("10%", [-1000, 300, 400, 500])
    Output
    -28000/1331
  10. 10.Internal rate of returnAgrees
    Find the internal rate of return of the same project.
    Independent answer
    The root of −1000+300v+400v2+500v3=0-1000 + 300v + 400v^2 + 500v^3 = 0 with v=1/(1+i)v = 1/(1 + i): i≈8.8963%i \approx 8.8963\%.
    RatMath code
    finance.irr([-1000, 300, 400, 500]).rate
    Output
    0.0889633946933499353[1:2]
  11. 11.Bond priceAgrees
    A 10-year bond with face 100 pays a 5% coupon semi-annually. Price it at a yield of 6% (compounded semi-annually).
    Independent answer
    2.5 a20‾∣3%+100⋅1.03−20≈92.56132.5\,a_{\overline{20}|3\%} + 100 \cdot 1.03^{-20} \approx 92.5613.
    RatMath code
    finance.bond({ face: 100, coupon: "5%", frequency: 2, periods: 20 }).price("6%").clean
    Output
    92.561262569772246586820875…
  12. 12.Yield at parAgrees
    At what yield does the same bond sell at par?
    Independent answer
    At par the yield equals the coupon rate: 5%.
    RatMath code
    finance.bond({ face: 100, coupon: "5%", frequency: 2, periods: 20 }).yield(100)
    Output
    1/20
  13. 13.DurationAgrees
    Find the Macaulay and modified durations of the bond at a 6% yield.
    Independent answer
    Macaulay =∑t vtct/P≈7.8950= \sum t\,v^t c_t / P \approx 7.8950 years; modified =7.8950/1.03≈7.6650= 7.8950/1.03 \approx 7.6650.
    RatMath code
    const d = finance.bond({ face: 100, coupon: "5%", frequency: 2, periods: 20 }).duration("6%");
    [d.macaulay, d.modified]
    Output
    [7.894997340182342470511566…, 7.665045961342080068457831…]
  14. 14.Forward ratesAgrees
    The one-year spot rate is 4% and the two-year spot rate is 5%. Find the one-year forward rate a year from now.
    Independent answer
    (1.05)2/1.04−1=25416≈6.0096%(1.05)^2/1.04 - 1 = \tfrac{25}{416} \approx 6.0096\%.
    RatMath code
    finance.yieldCurve({ spots: ["4%", "5%"] }).forward(1, 2)
    Output
    25/416
  15. 15.Black–ScholesAgrees
    Price a one-year European call with S=K=100S = K = 100, r=5%r = 5\%, σ=20%\sigma = 20\%.
    Independent answer
    d1=0.35d_1 = 0.35, d2=0.15d_2 = 0.15; C=100N(0.35)−100e−0.05N(0.15)≈10.4506C = 100N(0.35) - 100e^{-0.05}N(0.15) \approx 10.4506.
    RatMath code
    finance.blackScholes({ spot: 100, strike: 100, rate: "5%", volatility: "20%", time: 1 }).call
    Output
    10.4505835721855667816[5:6]
  16. 16.Put–call parityAgrees
    Use put–call parity to price the matching put.
    Independent answer
    P=C−S+Ke−rT=10.450584−100+95.122942≈5.5735P = C - S + Ke^{-rT} = 10.450584 - 100 + 95.122942 \approx 5.5735.
    RatMath code
    const C = finance.blackScholes({ spot: 100, strike: 100, rate: "5%", volatility: "20%", time: 1 }).call;
    finance.parity({ call: C, spot: 100, strike: 100, rate: "5%", time: 1 }).put
    Output
    5.57352602225696769079:5.5735260222569676908
    parity used to refuse the enclosed call that blackScholes returns; it now takes enclosures and returns the put enclosed.
    Fix: ratmath/finance#6, parity takes enclosed prices
  17. 17.American put on a treeAgrees
    A stock at 50 moves up by 1.2 or down by 0.8 each step; one step grows money by 1.05. Price a two-step American put struck at 52.
    Independent answer
    p=(1.05−0.8)/0.4=0.625p = (1.05 - 0.8)/0.4 = 0.625. Final puts 0, 4, 20. At 60: hold 1.5/1.05=1.42861.5/1.05 = 1.4286. At 40: hold 9.52 but exercise 12. Root: hold (0.625⋅1.4286+0.375⋅12)/1.05=755147≈5.1361(0.625 \cdot 1.4286 + 0.375 \cdot 12)/1.05 = \tfrac{755}{147} \approx 5.1361, better than exercising (2).
    RatMath code
    finance.binomialTree({ spot: 50, strike: 52, steps: 2, up: "6/5", down: "4/5", growth: "21/20", type: "put", style: "american" }).price
    Output
    755/147
  18. 18.Option strategiesAgrees
    A straddle buys a call (premium 5) and a put (premium 4), both struck at 100. Where does it break even?
    Independent answer
    It costs 9, so it breaks even when the stock is 99 away from 100: at 91 and 109.
    RatMath code
    finance.strategy([{ type: "call", strike: 100, premium: 5 }, { type: "put", strike: 100, premium: 4 }]).breakEvens
    Output
    [91, 109]
  19. 19.DepreciationAgrees
    A machine costs \$10{,}000, lasts 5 years and is sold for \$1000. Find the yearly straight-line depreciation and the first year's double-declining-balance depreciation.
    Independent answer
    Straight line: 9000/5=$18009000/5 = \$1800. Double declining: 2/52/5 of \$10{,}000 =$4000= \$4000.
    RatMath code
    const s = finance.depreciation({ cost: 10000, salvage: 1000, life: 5 });
    const d = finance.depreciation({ cost: 10000, salvage: 1000, life: 5, method: "declining-balance" });
    [s[0].depreciation, d[0].depreciation]
    Output
    [1800, 4000]
  20. 20.Life expectancyAgrees
    Under de Moivre's law with limiting age 100, what is the complete life expectancy at age 40?
    Independent answer
    The future lifetime is uniform on (0,60)(0, 60), so e˚40=30\mathring e_{40} = 30.
    RatMath code
    finance.deMoivre(100).completeExpectation(40)
    Output
    30