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.Effective rateAgreesWhat effective annual rate corresponds to 6% compounded monthly?Independent answer.RatMath code
finance.effectiveRate("6%", 12)Output0.061677811864499568789707…
- 2.Compound interestAgreesWhat does \$1000 grow to in 10 years at 5% compounded annually?Independent answer.RatMath code
finance.compound(1000, "5%", 10)Output16679880978201/10240000000
- 3.Continuous compoundingAgreesWhat does \$1000 grow to in 10 years at 5% compounded continuously?Independent answer.RatMath code
R`1000`.multiply(finance.exp(R`5/100 * 10`))Output1648.7212707001281468486[5:6]
- 4.Annuity-immediateAgreesFind the present value of \$100 paid at the end of each year for 10 years at 5%.Independent answer.RatMath code
finance.annuity({ payment: 100, rate: "5%", periods: 10 }).presentValueOutput12879761956402000/16679880978201
- 5.Annuity-dueAgreesThe same payments are made at the start of each year instead. Find the present value.Independent answer.RatMath code
finance.annuity({ payment: 100, rate: "5%", periods: 10, due: true }).presentValueOutput643988097820100/794280046581
- 6.Growing perpetuityAgreesA perpetuity pays \$100 next year, growing by 2% a year after that. At 6%, what is it worth?Independent answer.RatMath code
finance.perpetuity({ payment: 100, rate: "6%", growth: "2%" })Output2500
- 7.Loan paymentAgreesFind the monthly payment on a \$250{,}000, 30-year loan at 6% a year compounded monthly.Independent answer.RatMath code
finance.loan({ principal: 250000, rate: "6%", periods: 360 }).paymentOutput37472/25
- 8.Paying extraAgreesWith \$200 a month extra on the same loan, how many payments does it take?Independent answerRunning the balance forward, , it reaches zero at the 267th payment.RatMath code
finance.loan({ principal: 250000, rate: "6%", periods: 360, extra: 200 }).periodsOutput267
- 9.Net present valueAgreesA 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: not worth it at 10%.RatMath code
finance.npv("10%", [-1000, 300, 400, 500])Output-28000/1331
- 10.Internal rate of returnAgreesFind the internal rate of return of the same project.Independent answerThe root of with : .RatMath code
finance.irr([-1000, 300, 400, 500]).rateOutput0.0889633946933499353[1:2]
- 11.Bond priceAgreesA 10-year bond with face 100 pays a 5% coupon semi-annually. Price it at a yield of 6% (compounded semi-annually).Independent answer.RatMath code
finance.bond({ face: 100, coupon: "5%", frequency: 2, periods: 20 }).price("6%").cleanOutput92.561262569772246586820875…
- 12.Yield at parAgreesAt what yield does the same bond sell at par?Independent answerAt par the yield equals the coupon rate: 5%.RatMath code
finance.bond({ face: 100, coupon: "5%", frequency: 2, periods: 20 }).yield(100)Output1/20
- 13.DurationAgreesFind the Macaulay and modified durations of the bond at a 6% yield.Independent answerMacaulay years; modified .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.Forward ratesAgreesThe 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.RatMath code
finance.yieldCurve({ spots: ["4%", "5%"] }).forward(1, 2)Output25/416
- 15.Black–ScholesAgreesPrice a one-year European call with , , .Independent answer, ; .RatMath code
finance.blackScholes({ spot: 100, strike: 100, rate: "5%", volatility: "20%", time: 1 }).callOutput10.4505835721855667816[5:6]
- 16.Put–call parityAgreesUse put–call parity to price the matching put.Independent answer.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 }).putOutput5.57352602225696769079:5.5735260222569676908
parityused to refuse the enclosed call thatblackScholesreturns; it now takes enclosures and returns the put enclosed.Fix: ratmath/finance#6,paritytakes enclosed prices - 17.American put on a treeAgreesA 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. Final puts 0, 4, 20. At 60: hold . At 40: hold 9.52 but exercise 12. Root: hold , 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" }).priceOutput755/147
- 18.Option strategiesAgreesA straddle buys a call (premium 5) and a put (premium 4), both struck at 100. Where does it break even?Independent answerIt costs 9, so it breaks even when the stock is away from 100: at 91 and 109.RatMath code
finance.strategy([{ type: "call", strike: 100, premium: 5 }, { type: "put", strike: 100, premium: 4 }]).breakEvensOutput[91, 109]
- 19.DepreciationAgreesA 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 answerStraight line: . Double declining: of \$10{,}000 .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.Life expectancyAgreesUnder de Moivre's law with limiting age 100, what is the complete life expectancy at age 40?Independent answerThe future lifetime is uniform on , so .RatMath code
finance.deMoivre(100).completeExpectation(40)Output30