Also, the forward rate for borrowing at time for delivery at time is calculated as

The forward rate can also be calculated directly from yields as

// file term_alg.cc // author: Bernt A Oedegaard #include "math.h" double term_structure_yield_from_discount_factor(double dfact, double t) { return (-log(dfact)/t); } double term_structure_discount_factor_from_yield(double r, double t) { return exp(-r*t); }; double term_structure_forward_rate_from_disc_facts(double d_t, double d_T, double time) { return (log (d_t/d_T))/time; }; double term_structure_forward_rate_from_yields(double r_t1, double r_T, double t1, double T) { return (r_T*(T/(T-t1))-r_t1*(t1/T)); };