I'm not 100% sure but I think it would look something like def maturity_formula(C, P, r): return sum([C / (1 + r) ^ t + F / (1 + r) ^ n for t in range(1, n+1)])
On Fri, Apr 3, 2009 at 8:54 PM, Brian <medo...@gmail.com> wrote: > > I was hoping to get help with using SAGE to plot this equation: > http://www.streetauthority.com/images/education/ytm.gif > > This is the yield to maturity formula, expressing that a bond's price > is the sum of the present values of its future cash flows. > > P = price of the bond > n = number of periods > C = coupon payment > r = required rate of return on this investment > F = maturity value > t = time period when payment is to be received > > All variables are fixed except P and r, so my plot will be the > function P(r). > > Once this is working, my next goal is to unfix n and have it vary on > the z axis. > > A more basic question that could get me started is, how do I express > that summation? > > Thanks, Brian > > (Source: http://www.streetauthority.com/terms/y/yield-to-maturity.asp) > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---