Present Value and Future Value: Valuing Money Across Time

30 minbeginner

3. Present Value and Future Value: Valuing Money Across Time

Present value and future value are the fundamental tools for comparing money at different points in time. They allow us to answer questions like: "Is 110inoneyear?"or"HowmuchdoIneedtoinvesttodaytohave110 in one year?" or "How much do I need to invest today to haveFV=$5,000×(1.06)10=$8,954.24FV = \text{\$}5{,}000 \times (1.06)^{10} = \text{\$}8{,}954.24

Your $5,000 grows to nearly $9,000 over 10 years.

Let's visualize how future value compounds over time:

Python exercise

#| label: future-value-formula-compounding
#| fig-cap: "Future Value Formula: FV = PV × (1 + r)^n - Compounding Visualization"
#| fig-width: 16
#| fig-height: 10
#| echo: false
#| warning: false

# Sandbox metadata (auto-generated from lesson.ts)
# libraries: numpy, matplotlib, pandas

import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display

# Initial investment
PV = 5000  # $5,000
interest_rate = 0.06  # 6%
years = np.arange(0, 21, 1)

# Calculate future value
FV_values = PV * ((1 + interest_rate) ** years)

# Multiple interest rates for comparison
rates = [0.04, 0.06, 0.08, 0.10, 0.12]
FV_by_rate = {r: PV * ((1 + r) ** years) for r in rates}

# Create figure
fig, axes = plt.subplots(2, 2, figsize=(16, 12))
fig.suptitle('Future Value Formula: FV = PV × (1 + r)^n - Compounding Over Time', 
            fontsize=16, fontweight='bold')

# Plot 1: FV vs. Time (Fixed Rate)
ax1 = axes[0, 0]
ax1.plot(years, FV_values, 'b-', linewidth=3, marker='o', markersize=6, 
        label=f'FV at {interest_rate*100:.0f}% interest', alpha=0.8)
ax1.axhline(y=PV, color='green', linestyle='--', linewidth=2, alpha=0.7, 
           label=f'Present Value: ${PV:,}')
ax1.axhline(y=FV_values[10], color='red', linestyle='--', linewidth=2, alpha=0.7, 
           label=f'FV at 10 years: ${FV_values[10]:,.0f}')
ax1.fill_between(years, PV, FV_values, alpha=0.2, color='green', label='Compound Growth')
ax1.set_xlabel('Years (n)', fontsize=12, fontweight='bold')
ax1.set_ylabel('Future Value ($)', fontsize=12, fontweight='bold')
ax1.set_title('Future Value Growth Over Time (6% Interest Rate)', fontsize=13, fontweight='bold')
ax1.grid(True, alpha=0.3, linestyle='--')
ax1.legend(loc='best', fontsize=9)

# Add formula annotation
ax1.text(0.02, 0.98, f'FV = PV × (1 + r)^n\n\nAt n=10 years:\nFV = ${PV:,} × (1.06)^10\nFV = ${FV_values[10]:,.2f}',
       transform=ax1.transAxes, fontsize=10, fontweight='bold',
       bbox=dict(boxstyle='round', facecolor='yellow', alpha=0.9),
       verticalalignment='top', family='monospace')

# Plot 2: FV vs. Interest Rate (Fixed Time)
ax2 = axes[0, 1]
interest_rates_plot = np.linspace(0.01, 0.15, 100)
time_horizon = 10  # 10 years
FV_by_rate_plot = PV * ((1 + interest_rates_plot) ** time_horizon)

ax2.plot(interest_rates_plot * 100, FV_by_rate_plot, 'purple', linewidth=3, alpha=0.8)
ax2.axvline(x=interest_rate*100, color='red', linestyle='--', linewidth=2, alpha=0.7, 
           label=f'{interest_rate*100:.0f}% rate')
ax2.axhline(y=FV_values[time_horizon], color='red', linestyle='--', linewidth=2, alpha=0.7)
ax2.set_xlabel('Interest Rate (%)', fontsize=12, fontweight='bold')
ax2.set_ylabel('Future Value ($)', fontsize=12, fontweight='bold')
ax2.set_title(f'Future Value Sensitivity to Interest Rate (n = {time_horizon} years)', 
             fontsize=13, fontweight='bold')
ax2.grid(True, alpha=0.3, linestyle='--')
ax2.legend(loc='best', fontsize=9)

# Mark specific points
for r in [4, 6, 8, 10, 12]:
    fv = PV * ((1 + r/100) ** time_horizon)
    ax2.plot(r, fv, 'ro', markersize=8, zorder=5)
    ax2.annotate(f'{r}%\n${fv:,.0f}', xy=(r, fv), xytext=(r + 1, fv + 500),
                fontsize=9, fontweight='bold',
                bbox=dict(boxstyle='round', facecolor='lightblue', alpha=0.8),
                arrowprops=dict(arrowstyle='->', color='blue', lw=1.5))

# Plot 3: Compound Growth Visualization
ax3 = axes[1, 0]
growth_factors = (1 + interest_rate) ** years
ax3.plot(years, growth_factors, 'g-', linewidth=3, marker='s', markersize=6, 
        label='Growth Factor: (1+r)^n', alpha=0.8)
ax3.axhline(y=1, color='gray', linestyle='--', linewidth=1.5, alpha=0.5)
ax3.fill_between(years, 1, growth_factors, alpha=0.3, color='green', 
              label='Compound Growth Area')
ax3.set_xlabel('Years (n)', fontsize=12, fontweight='bold')
ax3.set_ylabel('Growth Factor', fontsize=12, fontweight='bold')
ax3.set_title('Compound Growth Factor: How Much Money Multiplies', 
             fontsize=13, fontweight='bold')
ax3.grid(True, alpha=0.3, linestyle='--')
ax3.legend(loc='best', fontsize=9)

# Add value labels at key points
for n in [5, 10, 15, 20]:
    gf = growth_factors[n]
    ax3.annotate(f'n={n}\n{gf:.2f}x', xy=(n, gf), xytext=(n + 2, gf + 0.3),
                fontsize=9, fontweight='bold',
                bbox=dict(boxstyle='round', facecolor='yellow', alpha=0.8),
                arrowprops=dict(arrowstyle='->', color='green', lw=1.5))

# Plot 4: Multiple Interest Rates Comparison
ax4 = axes[1, 1]
for rate in rates:
    fv_series = FV_by_rate[rate]
    ax4.plot(years, fv_series, linewidth=2.5, marker='o', markersize=4, 
            label=f'{rate*100:.0f}%', alpha=0.8)

ax4.axhline(y=PV, color='black', linestyle='--', linewidth=1.5, alpha=0.5, 
           label=f'Present Value: ${PV:,}')
ax4.set_xlabel('Years (n)', fontsize=12, fontweight='bold')
ax4.set_ylabel('Future Value ($)', fontsize=12, fontweight='bold')
ax4.set_title('Future Value at Different Interest Rates', fontsize=13, fontweight='bold')
ax4.grid(True, alpha=0.3, linestyle='--')
ax4.legend(loc='best', fontsize=9)

plt.tight_layout()
display(fig)
plt.close(fig)

print(f"\n📊 **Future Value Formula Analysis**")
print(f"{'='*70}")
print(f"Formula: FV = PV × (1 + r)^n")
print(f"  where FV = Future Value")
print(f"        PV = Present Value")
print(f"        r = Interest rate per period")
print(f"        n = Number of periods")
print(f"{'='*70}")
print(f"Example: PV = ${PV:,}, r = {interest_rate*100:.0f}%, n = 10 years")
print(f"  FV = ${PV:,} × (1.06)^10")
print(f"  FV = ${PV:,} × {((1+interest_rate)**10):.4f}")
print(f"  FV = ${FV_values[10]:,.2f}")
print(f"{'='*70}")
print(f"Key Insights:")
print(f"  • Higher interest rate → Higher future value")
print(f"  • Longer time horizon → Higher future value")
print(f"  • Growth is exponential (compound interest)")
print(f"{'='*70}")
print(f"✅ Compound interest is powerful - small rate differences matter over time")
print(f"✅ Time is the most important factor in wealth accumulation")

Future Value of Multiple Cash Flows: If you have multiple cash flows at different times, you calculate the future value of each and sum them. For example, if you invest 1,000today,$2,000inoneyear,and$3,000intwoyears,allat51,000 today, \text{\$}2,000 in one year, and \text{\$}3,000 in two years, all at 5% interest, you calculate the future value of each separately:$1,000×(1.05)3=$1,157.63\text{\$}1{,}000 \times (1.05)^{3} = \text{\$}1{,}157.63−$2,000investedfor2years:- \text{\$}2,000 invested for 2 years:$2,000×(1.05)2=$2,205.00\text{\$}2{,}000 \times (1.05)^{2} = \text{\$}2{,}205.00−$3,000investedfor1year:- \text{\$}3,000 invested for 1 year:$3,000×(1.05)1=$3,150.00\text{\$}3{,}000 \times (1.05)^{1} = \text{\$}3{,}150.00−TotalFutureValue- Total Future ValueCFtCF_t is the cash flow at time $t$, $r$ is the discount rate, and $n$ is the number of periods.

Let's visualize multiple cash flows with a timeline:

Python exercise

#| label: multiple-cash-flows-timeline
#| fig-cap: "Multiple Cash Flows: Timeline Visualization Showing PV = Σ CF_t/(1+r)^t with Individual PVs"
#| fig-width: 16
#| fig-height: 10
#| echo: false
#| warning: false

# Sandbox metadata (auto-generated from lesson.ts)
# libraries: numpy, matplotlib, pandas

import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display

# Example cash flows
cash_flows = [1000, 2000, 3000, 2500, 2000]  # Cash flows at t=0,1,2,3,4
discount_rate = 0.06  # 6% discount rate
time_periods = np.arange(0, len(cash_flows), 1)

# Calculate present value of each cash flow
pv_individual = cash_flows / ((1 + discount_rate) ** time_periods)
total_pv = np.sum(pv_individual)

# Calculate future value of each cash flow (at end of period 4)
final_period = len(cash_flows) - 1
fv_individual = cash_flows * ((1 + discount_rate) ** (final_period - time_periods))
total_fv = np.sum(fv_individual)

# Create figure
fig, axes = plt.subplots(2, 2, figsize=(16, 12))
fig.suptitle('Multiple Cash Flows: Timeline Visualization with Present and Future Values', 
            fontsize=16, fontweight='bold')

# Plot 1: Cash Flow Timeline
ax1 = axes[0, 0]
colors_cf = plt.cm.viridis(np.linspace(0, 1, len(cash_flows)))
for i, (cf, t, pv, color) in enumerate(zip(cash_flows, time_periods, pv_individual, colors_cf)):
    # Draw cash flow arrow
    if cf > 0:
        ax1.barh(i, cf, left=t, height=0.3, color=color, alpha=0.7, edgecolor='black', linewidth=1.5)
        ax1.text(t + cf/2, i, f'${cf:,}\n(PV=${pv:.0f})', ha='center', va='center',
                fontsize=9, fontweight='bold', color='white')
    else:
        ax1.barh(i, abs(cf), left=t, height=0.3, color='red', alpha=0.7, edgecolor='black', linewidth=1.5)
        ax1.text(t + abs(cf)/2, i, f'${cf:,}\n(PV=${pv:.0f})', ha='center', va='center',
                fontsize=9, fontweight='bold', color='white')

ax1.set_xlabel('Time Period (t)', fontsize=12, fontweight='bold')
ax1.set_ylabel('Cash Flow', fontsize=12, fontweight='bold')
ax1.set_title('Cash Flow Timeline with Present Values', fontsize=13, fontweight='bold')
ax1.set_yticks(range(len(cash_flows)))
ax1.set_yticklabels([f'CF_{i}' for i in time_periods])
ax1.grid(True, alpha=0.3, linestyle='--', axis='x')
ax1.axvline(x=0, color='black', linestyle='-', linewidth=1, alpha=0.5)

# Add total PV annotation
ax1.text(0.98, 0.02, f'Total PV = ${total_pv:,.2f}\n\nPV = Σ CF_t/(1+r)^t\n  = Σ {pv_individual}\n  = ${total_pv:,.2f}',
        transform=ax1.transAxes, fontsize=10, fontweight='bold',
        bbox=dict(boxstyle='round', facecolor='yellow', alpha=0.9),
        verticalalignment='bottom', horizontalalignment='right', family='monospace')

# Plot 2: Present Value of Each Cash Flow
ax2 = axes[0, 1]
bars = ax2.bar(range(len(cash_flows)), pv_individual, 
               color=colors_cf, alpha=0.7, edgecolor='black', linewidth=1.5)
ax2.axhline(y=total_pv, color='red', linestyle='--', linewidth=2, alpha=0.7, 
           label=f'Total PV: ${total_pv:,.2f}')
ax2.set_xlabel('Time Period (t)', fontsize=12, fontweight='bold')
ax2.set_ylabel('Present Value ($)', fontsize=12, fontweight='bold')
ax2.set_title('Present Value of Each Cash Flow', fontsize=13, fontweight='bold')
ax2.set_xticks(range(len(cash_flows)))
ax2.set_xticklabels([f't={i}' for i in time_periods])
ax2.grid(True, alpha=0.3, linestyle='--', axis='y')
ax2.legend(loc='best', fontsize=9)

# Add value labels
for i, (bar, cf, pv) in enumerate(zip(bars, cash_flows, pv_individual)):
    height = bar.get_height()
    ax2.text(bar.get_x() + bar.get_width()/2., height + 50,
            f'${pv:.0f}\n(CF=${cf:,})', ha='center', va='bottom',
            fontsize=8, fontweight='bold',
            bbox=dict(boxstyle='round', facecolor='white', alpha=0.8))

# Plot 3: Discount Factor Over Time
ax3 = axes[1, 0]
discount_factors = 1 / ((1 + discount_rate) ** time_periods)
ax3.plot(time_periods, discount_factors, 'b-o', linewidth=3, markersize=8, alpha=0.8)
ax3.fill_between(time_periods, 0, discount_factors, alpha=0.3, color='blue')
ax3.set_xlabel('Time Period (t)', fontsize=12, fontweight='bold')
ax3.set_ylabel('Discount Factor', fontsize=12, fontweight='bold')
ax3.set_title(f'Discount Factor: 1/(1+r)^t (r = {discount_rate*100:.0f}%)', fontsize=13, fontweight='bold')
ax3.grid(True, alpha=0.3, linestyle='--')

# Add value labels
for t, df in zip(time_periods, discount_factors):
    ax3.annotate(f't={t}\n{df:.3f}', xy=(t, df), xytext=(t, df + 0.05),
                fontsize=9, fontweight='bold',
                bbox=dict(boxstyle='round', facecolor='yellow', alpha=0.8),
                arrowprops=dict(arrowstyle='->', color='blue', lw=1.5),
                ha='center')

# Plot 4: Cumulative Present Value
ax4 = axes[1, 1]
cumulative_pv = np.cumsum(pv_individual)
ax4.plot(time_periods, cumulative_pv, 'g-o', linewidth=3, markersize=8, alpha=0.8, 
        label='Cumulative PV')
ax4.bar(time_periods, pv_individual, alpha=0.5, color='green', edgecolor='black', linewidth=1.5,
       label='Individual PV')
ax4.axhline(y=total_pv, color='red', linestyle='--', linewidth=2, alpha=0.7, 
           label=f'Total PV: ${total_pv:,.2f}')
ax4.set_xlabel('Time Period (t)', fontsize=12, fontweight='bold')
ax4.set_ylabel('Cumulative Present Value ($)', fontsize=12, fontweight='bold')
ax4.set_title('Cumulative Present Value Over Time', fontsize=13, fontweight='bold')
ax4.grid(True, alpha=0.3, linestyle='--')
ax4.legend(loc='best', fontsize=9)

# Add value labels
for t, cum_pv in zip(time_periods, cumulative_pv):
    ax4.text(t, cum_pv + 100, f'${cum_pv:,.0f}', ha='center', va='bottom',
            fontsize=9, fontweight='bold',
            bbox=dict(boxstyle='round', facecolor='lightgreen', alpha=0.8))

plt.tight_layout()
display(fig)
plt.close(fig)

print(f"\n📊 **Multiple Cash Flows Analysis**")
print(f"{'='*70}")
print(f"Formula: PV = Σ CF_t / (1 + r)^t")
print(f"  where CF_t = cash flow at time t")
print(f"        r = discount rate ({discount_rate*100:.0f}%)")
print(f"        t = time period")
print(f"{'='*70}")
print(f"Cash Flows and Present Values:")
print(f"{'Period':<10} {'Cash Flow':<15} {'Discount Factor':<18} {'Present Value':<15}")
print(f"{'-'*70}")
for i, (cf, t, df, pv) in enumerate(zip(cash_flows, time_periods, discount_factors, pv_individual)):
    print(f"t={t:<8} ${cf:>10,}       {df:>6.4f}             ${pv:>10,.2f}")
print(f"{'='*70}")
print(f"Total Present Value: ${total_pv:,.2f}")
print(f"{'='*70}")
print(f"✅ Earlier cash flows have higher present values")
print(f"✅ Discount factor decreases exponentially with time")
print(f"✅ Total PV is sum of all individual PVs")

Python exercise

#| label: future-value-visualization
#| fig-cap: "Future Value: How Money Grows Over Time"
#| fig-width: 14
#| fig-height: 8
#| echo: false
#| warning: false

# Sandbox metadata (auto-generated from lesson.ts)
# libraries: numpy, matplotlib, pandas

import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display

# Example: $5,000 at 6% for 10 years
pv_single = 5000
rate_single = 0.06
years_single = 10
fv_single = pv_single * (1 + rate_single) ** years_single

# Time series
years_series = np.linspace(0, years_single, 1000)
fv_series = pv_single * (1 + rate_single) ** years_series

# Multiple cash flows example
cash_flows = [1000, 2000, 3000]
cash_flow_times = [0, 1, 2]
final_time = 3
rate_multi = 0.05
fv_multi = []
for cf, t in zip(cash_flows, cash_flow_times):
    fv_multi.append(cf * (1 + rate_multi) ** (final_time - t))
total_fv_multi = sum(fv_multi)

# Growth comparison: different rates
rates_comparison = [0.03, 0.06, 0.09, 0.12]
years_comparison = np.linspace(0, 20, 1000)
pv_comparison = 5000

# Sensitivity to rate and time
rates_range = np.linspace(0.02, 0.15, 100)
years_range = np.linspace(1, 30, 100)
FV_rate_sensitivity = pv_single * (1 + rates_range) ** years_single
FV_time_sensitivity = pv_single * (1 + rate_single) ** years_range

fig, axes = plt.subplots(2, 2, figsize=(16, 12))
fig.suptitle('Future Value: How Money Grows Over Time', fontsize=16, fontweight='bold')

# Plot 1: Single Investment Growth
ax1 = axes[0, 0]
ax1.plot(years_series, fv_series, 'b-', linewidth=3, alpha=0.8, label='Future Value')
ax1.axhline(y=pv_single, color='green', linestyle='--', linewidth=2, alpha=0.5, label=f'Initial: ${pv_single:,.0f}')
ax1.axhline(y=fv_single, color='red', linestyle='--', linewidth=2, alpha=0.5, label=f'Final: ${fv_single:,.2f}')
ax1.plot(years_single, fv_single, 'ro', markersize=12, markeredgewidth=2, markeredgecolor='white', zorder=5)
ax1.fill_between(years_series, pv_single, fv_series, alpha=0.3, color='blue', label='Growth')
ax1.set_xlabel('Years', fontsize=12, fontweight='bold')
ax1.set_ylabel('Future Value ($)', fontsize=12, fontweight='bold')
ax1.set_title(f'Single Investment: ${pv_single:,.0f} at {rate_single*100:.0f}% for {years_single} years', fontsize=13, fontweight='bold')
ax1.grid(True, alpha=0.3, linestyle='--')
ax1.legend(loc='upper left', fontsize=10)
ax1.text(0.05, 0.95, f'FV = PV × (1 + r)ⁿ\n= ${pv_single:,.0f} × (1.06)¹⁰\n= ${fv_single:,.2f}',
         transform=ax1.transAxes, ha='left', va='top', fontsize=10, fontweight='bold',
         bbox=dict(boxstyle='round,pad=0.5', facecolor='yellow', edgecolor='black', linewidth=1.5))

# Plot 2: Multiple Cash Flows
ax2 = axes[0, 1]
# Timeline visualization
y_pos = [0.3, 0.5, 0.7]
colors_cf = ['green', 'blue', 'orange']
for i, (cf, t, fv, color) in enumerate(zip(cash_flows, cash_flow_times, fv_multi, colors_cf)):
    # Original cash flow
    ax2.barh(y_pos[i], cf, left=t, height=0.15, color=color, alpha=0.5, edgecolor='black', 
            label=f'CF at t={t}: ${cf:,.0f}')
    # Future value
    ax2.barh(y_pos[i], fv, left=final_time, height=0.15, color=color, alpha=0.8, edgecolor='black')
    ax2.plot([t + cf, final_time], [y_pos[i], y_pos[i]], '--', color=color, linewidth=2, alpha=0.5)
    ax2.text(final_time + 0.5, y_pos[i], f'FV: ${fv:,.2f}', va='center', fontsize=9, fontweight='bold')
ax2.axvline(x=final_time, color='red', linestyle='-', linewidth=2, alpha=0.7, label=f'Future Date (t={final_time})')
ax2.set_xlabel('Time (Years)', fontsize=12, fontweight='bold')
ax2.set_ylabel('Cash Flow', fontsize=12, fontweight='bold')
ax2.set_title('Multiple Cash Flows: Future Value Calculation', fontsize=13, fontweight='bold')
ax2.set_yticks([])
ax2.set_xlim(-0.5, 8)
ax2.grid(True, alpha=0.3, linestyle='--', axis='x')
ax2.legend(loc='upper right', fontsize=9)
ax2.text(0.5, 0.95, f'Total FV: ${total_fv_multi:,.2f}\n= Sum of individual FVs',
         transform=ax2.transAxes, ha='center', va='top', fontsize=10, fontweight='bold',
         bbox=dict(boxstyle='round,pad=0.5', facecolor='lightblue', edgecolor='blue', linewidth=1.5))

# Plot 3: Growth at Different Rates
ax3 = axes[1, 0]
for rate in rates_comparison:
    fv_comp = pv_comparison * (1 + rate) ** years_comparison
    ax3.plot(years_comparison, fv_comp, linewidth=2, alpha=0.8, 
            label=f'{rate*100:.0f}%')
ax3.axhline(y=pv_comparison, color='black', linestyle='--', linewidth=1, alpha=0.5)
ax3.set_xlabel('Years', fontsize=12, fontweight='bold')
ax3.set_ylabel('Future Value ($)', fontsize=12, fontweight='bold')
ax3.set_title(f'Growth Comparison: Different Interest Rates (PV = ${pv_comparison:,.0f})', fontsize=13, fontweight='bold')
ax3.grid(True, alpha=0.3, linestyle='--')
ax3.legend(loc='upper left', fontsize=10)
ax3.set_yscale('log')  # Log scale to show differences better
ax3.text(0.05, 0.95, 'Higher rate → Faster growth\nExponential growth over time',
         transform=ax3.transAxes, ha='left', va='top', fontsize=10, fontweight='bold',
         bbox=dict(boxstyle='round,pad=0.5', facecolor='lightgreen', edgecolor='green', linewidth=1.5))

# Plot 4: Sensitivity Analysis
ax4 = axes[1, 1]
ax4_twin = ax4.twinx()
line1 = ax4.plot(rates_range * 100, FV_rate_sensitivity, 'b-', linewidth=3, alpha=0.8, 
                label=f'FV vs Rate (n={years_single}yr)')
line2 = ax4_twin.plot(years_range, FV_time_sensitivity, 'r--', linewidth=3, alpha=0.8, 
                     label=f'FV vs Time (r={rate_single*100:.0f}%)')
ax4.axvline(x=rate_single * 100, color='blue', linestyle=':', linewidth=2, alpha=0.5)
ax4_twin.axvline(x=years_single, color='red', linestyle=':', linewidth=2, alpha=0.5)
ax4.set_xlabel('Interest Rate (%)', fontsize=12, fontweight='bold', color='blue')
ax4_twin.set_xlabel('Time (Years)', fontsize=12, fontweight='bold', color='red')
ax4.set_ylabel('Future Value ($)', fontsize=12, fontweight='bold', color='blue')
ax4_twin.set_ylabel('Future Value ($)', fontsize=12, fontweight='bold', color='red')
ax4.set_title('Future Value Sensitivity: Rate and Time Impact', fontsize=13, fontweight='bold')
ax4.grid(True, alpha=0.3, linestyle='--')
ax4.tick_params(axis='y', labelcolor='blue')
ax4_twin.tick_params(axis='y', labelcolor='red')
ax4.set_xticks(np.arange(2, 16, 2))
ax4_twin.set_xticks(np.arange(0, 31, 5))
lines = line1 + line2
labels = [l.get_label() for l in lines]
ax4.legend(lines, labels, loc='upper left', fontsize=9)
ax4.text(0.05, 0.95, 'Both rate and time\nhave exponential impact',
         transform=ax4.transAxes, ha='left', va='top', fontsize=10, fontweight='bold',
         bbox=dict(boxstyle='round,pad=0.5', facecolor='yellow', edgecolor='black', linewidth=1.5))

plt.tight_layout()
display(fig)
plt.close(fig)

Present Value: Discounting Future Money

Present value tells us how much future money is worth today. It's the inverse of future value - instead of compounding forward, we discount backward. The formula is:

PV=FV(1+r)nPV = \frac{FV}{(1 + r)^n}

Where:

  • PV = Present Value
  • FV = Future Value
  • r = Discount rate (interest rate)
  • n = Number of periods

Example: If you're promised $10,000 in 5 years and the discount rate is 4%:

  • PV = $10,000 / (1.04)^5 = $8,219.27

$10,000 in 5 years is worth about $8,219 today at a 4% discount rate.

Let's visualize how present value works with discounting over time:

Python exercise

#| label: present-value-formula-interactive
#| fig-cap: "Present Value Formula: PV = FV / (1 + r)^n - Discounting Over Time"
#| fig-width: 16
#| fig-height: 10
#| echo: false
#| warning: false

# Sandbox metadata (auto-generated from lesson.ts)
# libraries: numpy, matplotlib, pandas

import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display

# Future value to discount
FV = 10000  # $10,000
discount_rate = 0.04  # 4%
years = np.arange(0, 21, 1)

# Calculate present value for different time horizons
PV_values = FV / ((1 + discount_rate) ** years)

# Also show different discount rates
rates = [0.02, 0.04, 0.06, 0.08, 0.10]
PV_by_rate = {r: FV / ((1 + r) ** years) for r in rates}

# Create figure
fig, axes = plt.subplots(2, 2, figsize=(16, 12))
fig.suptitle('Present Value Formula: PV = FV / (1 + r)^n - Discounting Over Time', 
            fontsize=16, fontweight='bold')

# Plot 1: PV vs. Time (Fixed Rate)
ax1 = axes[0, 0]
ax1.plot(years, PV_values, 'b-', linewidth=3, marker='o', markersize=6, 
        label=f'PV at {discount_rate*100:.0f}% discount rate', alpha=0.8)
ax1.axhline(y=FV, color='green', linestyle='--', linewidth=2, alpha=0.7, 
           label=f'Future Value: ${FV:,}')
ax1.axhline(y=PV_values[5], color='red', linestyle='--', linewidth=2, alpha=0.7, 
           label=f'PV at 5 years: ${PV_values[5]:,.0f}')
ax1.fill_between(years, PV_values, FV, alpha=0.2, color='red', label='Discount Amount')
ax1.set_xlabel('Years Until Payment (n)', fontsize=12, fontweight='bold')
ax1.set_ylabel('Present Value ($)', fontsize=12, fontweight='bold')
ax1.set_title('Present Value Declines Over Time (4% Discount Rate)', fontsize=13, fontweight='bold')
ax1.grid(True, alpha=0.3, linestyle='--')
ax1.legend(loc='best', fontsize=9)

# Add formula annotation
ax1.text(0.02, 0.98, f'PV = FV / (1 + r)^n\n\nAt n=5 years:\nPV = ${FV:,} / (1.04)^5\nPV = ${PV_values[5]:,.2f}',
       transform=ax1.transAxes, fontsize=10, fontweight='bold',
       bbox=dict(boxstyle='round', facecolor='yellow', alpha=0.9),
       verticalalignment='top', family='monospace')

# Plot 2: PV vs. Discount Rate (Fixed Time)
ax2 = axes[0, 1]
discount_rates_plot = np.linspace(0.01, 0.15, 100)
time_horizon = 5  # 5 years
PV_by_rate_plot = FV / ((1 + discount_rates_plot) ** time_horizon)

ax2.plot(discount_rates_plot * 100, PV_by_rate_plot, 'purple', linewidth=3, alpha=0.8)
ax2.axvline(x=discount_rate*100, color='red', linestyle='--', linewidth=2, alpha=0.7, 
           label=f'{discount_rate*100:.0f}% rate')
ax2.axhline(y=PV_values[time_horizon], color='red', linestyle='--', linewidth=2, alpha=0.7)
ax2.set_xlabel('Discount Rate (%)', fontsize=12, fontweight='bold')
ax2.set_ylabel('Present Value ($)', fontsize=12, fontweight='bold')
ax2.set_title(f'Present Value Sensitivity to Discount Rate (n = {time_horizon} years)', 
             fontsize=13, fontweight='bold')
ax2.grid(True, alpha=0.3, linestyle='--')
ax2.legend(loc='best', fontsize=9)

# Mark specific points
for r in [2, 4, 6, 8, 10]:
    pv = FV / ((1 + r/100) ** time_horizon)
    ax2.plot(r, pv, 'ro', markersize=8, zorder=5)
    ax2.annotate(f'{r}%\n${pv:,.0f}', xy=(r, pv), xytext=(r + 1, pv + 200),
                fontsize=9, fontweight='bold',
                bbox=dict(boxstyle='round', facecolor='lightblue', alpha=0.8),
                arrowprops=dict(arrowstyle='->', color='blue', lw=1.5))

# Plot 3: Discount Factor Visualization
ax3 = axes[1, 0]
discount_factors = 1 / ((1 + discount_rate) ** years)
ax3.plot(years, discount_factors, 'g-', linewidth=3, marker='s', markersize=6, 
        label='Discount Factor: 1/(1+r)^n', alpha=0.8)
ax3.axhline(y=1, color='gray', linestyle='--', linewidth=1.5, alpha=0.5)
ax3.fill_between(years, 0, discount_factors, alpha=0.3, color='green', 
              label='Discount Factor Area')
ax3.set_xlabel('Years (n)', fontsize=12, fontweight='bold')
ax3.set_ylabel('Discount Factor', fontsize=12, fontweight='bold')
ax3.set_title('Discount Factor: How Much Future Value is Worth Today', 
             fontsize=13, fontweight='bold')
ax3.grid(True, alpha=0.3, linestyle='--')
ax3.legend(loc='best', fontsize=9)

# Add value labels at key points
for n in [5, 10, 15, 20]:
    df = discount_factors[n]
    ax3.annotate(f'n={n}\n{df:.3f}', xy=(n, df), xytext=(n + 2, df + 0.05),
                fontsize=9, fontweight='bold',
                bbox=dict(boxstyle='round', facecolor='yellow', alpha=0.8),
                arrowprops=dict(arrowstyle='->', color='green', lw=1.5))

# Plot 4: Multiple Discount Rates Comparison
ax4 = axes[1, 1]
for rate in rates:
    pv_series = PV_by_rate[rate]
    ax4.plot(years, pv_series, linewidth=2.5, marker='o', markersize=4, 
            label=f'{rate*100:.0f}%', alpha=0.8)

ax4.axhline(y=FV, color='black', linestyle='--', linewidth=1.5, alpha=0.5, 
           label=f'Future Value: ${FV:,}')
ax4.set_xlabel('Years Until Payment (n)', fontsize=12, fontweight='bold')
ax4.set_ylabel('Present Value ($)', fontsize=12, fontweight='bold')
ax4.set_title('Present Value at Different Discount Rates', fontsize=13, fontweight='bold')
ax4.grid(True, alpha=0.3, linestyle='--')
ax4.legend(loc='best', fontsize=9)

plt.tight_layout()
display(fig)
plt.close(fig)

print(f"\n📊 **Present Value Formula Analysis**")
print(f"{'='*70}")
print(f"Formula: PV = FV / (1 + r)^n")
print(f"  where PV = Present Value")
print(f"        FV = Future Value")
print(f"        r = Discount rate (interest rate)")
print(f"        n = Number of periods")
print(f"{'='*70}")
print(f"Example: FV = ${FV:,}, r = {discount_rate*100:.0f}%, n = 5 years")
print(f"  PV = ${FV:,} / (1.04)^5")
print(f"  PV = ${FV:,} / {((1+discount_rate)**5):.4f}")
print(f"  PV = ${PV_values[5]:,.2f}")
print(f"{'='*70}")
print(f"Key Insights:")
print(f"  • Higher discount rate → Lower present value")
print(f"  • Longer time horizon → Lower present value")
print(f"  • Discount factor decreases exponentially with time")
print(f"{'='*70}")
print(f"✅ Present value represents the 'time cost' of waiting")
print(f"✅ Higher discount rates reflect higher opportunity cost or risk")

Practice Problem 3.1: Lottery Lump Sum vs. Annuity

You win a lottery that offers two payment options:

  • Option A: $500,000 lump sum today
  • Option B: $50,000 per year for 15 years (total of $750,000)

If you can invest at 6% annual return, which option has the higher present value?

Solution:

Option A: $500,000 today

  • PV = $500,000 (already in present value)

Option B: $50,000 per year for 15 years
This is an annuity. We need to calculate the present value of all 15 payments:

  • PMT = $50,000
  • r = 6% = 0.06
  • n = 15 years

Using the annuity present value formula:

  • PV = $50,000 × [1 - (1.06)^(-15)] / 0.06
  • PV = $50,000 × [1 - 0.4173] / 0.06
  • PV = $50,000 × 9.7122 = $485,610

Analysis: Option A ($500,000) has a higher present value than Option B ($485,610) by $14,390. Even though Option B pays more total dollars ($750,000 vs $500,000), the time value of money makes Option A more valuable. However, Option B provides income over time, which may be valuable for budgeting and spending control.

Python exercise

#| label: practice-3-1
#| fig-cap: "Practice Problem 3.1: Lottery Lump Sum vs Annuity"
#| fig-width: 14
#| fig-height: 6
#| echo: false
#| warning: false

# Sandbox metadata (auto-generated from lesson.ts)
# libraries: numpy, matplotlib, pandas

import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display

# Parameters
lump_sum = 500000
annual_payment = 50000
years = 15
rate = 0.06

# Calculate PV of annuity
pv_annuity = annual_payment * ((1 - (1 + rate)**(-years)) / rate)
pv_lump = lump_sum  # Already in present value

# Cash flows over time for annuity
time_points = np.arange(0, years + 1, 1)
cumulative_received = np.cumsum([0] + [annual_payment] * years)

fig, axes = plt.subplots(1, 2, figsize=(16, 6))
fig.suptitle('Practice Problem 3.1: Lottery Lump Sum vs Annuity', fontsize=14, fontweight='bold')

# Plot 1: Cash Flow Timeline
ax1 = axes[0]
ax1.barh([0], [lump_sum], left=0, height=0.3, color='blue', alpha=0.7, label='Option A: Lump Sum', edgecolor='black')
for i in range(years):
    ax1.barh([1], [annual_payment], left=i, height=0.3, color='green' if i == 0 else None, 
             alpha=0.7 if i == 0 else 0.5, edgecolor='black')
ax1.set_xlabel('Time (Years)', fontsize=11, fontweight='bold')
ax1.set_ylabel('Option', fontsize=11, fontweight='bold')
ax1.set_yticks([0, 1])
ax1.set_yticklabels(['Option A\n(Lump Sum)', 'Option B\n(Annuity)'])
ax1.set_title('Cash Flow Timeline', fontsize=12, fontweight='bold')
ax1.grid(True, alpha=0.3, linestyle='--', axis='x')
ax1.legend(loc='upper right', fontsize=9)
ax1.set_xlim(-0.5, years + 0.5)

# Plot 2: Present Value Comparison
ax2 = axes[1]
options = ['Option A\n(Lump Sum)', 'Option B\n(Annuity)']
pv_values = [pv_lump, pv_annuity]
colors = ['blue', 'green']
bars = ax2.bar(options, pv_values, color=colors, alpha=0.7, edgecolor='black', linewidth=1.5)
ax2.axhline(y=pv_lump, color='blue', linestyle='--', linewidth=2, alpha=0.5, label=f'Option A: ${pv_lump:,.0f}')
ax2.set_ylabel('Present Value ($)', fontsize=11, fontweight='bold')
ax2.set_title('Present Value Comparison (6% discount rate)', fontsize=12, fontweight='bold')
ax2.grid(True, alpha=0.3, linestyle='--', axis='y')
for bar, val in zip(bars, pv_values):
    height = bar.get_height()
    ax2.text(bar.get_x() + bar.get_width()/2., height + 5000,
             f'${val:,.0f}', ha='center', va='bottom', fontsize=10, fontweight='bold')
diff = pv_lump - pv_annuity
ax2.text(0.5, 0.7, f'Difference: ${diff:,.0f}\nOption A is better',
         transform=ax2.transAxes, ha='center', fontsize=10, fontweight='bold',
         bbox=dict(boxstyle='round,pad=0.5', facecolor='yellow', edgecolor='black', linewidth=1.5))
ax2.legend(loc='upper right', fontsize=9)

plt.tight_layout()
display(fig)
plt.close(fig)

Real-World Context: This is exactly the choice lottery winners face. The "lump sum" option is typically about 60% of the total annuity value, but when you calculate present value, the difference is often smaller than it appears. Many financial advisors recommend the lump sum if you have investment discipline, as you can potentially earn higher returns than the implicit discount rate.

Practice Problem 3.2: Investment Project Evaluation

A company is evaluating a new factory project. The project requires an initial investment of $2,000,000 and is expected to generate the following cash flows:

  • Year 1: $400,000
  • Year 2: $500,000
  • Year 3: $600,000
  • Year 4: $700,000
  • Year 5: $800,000

The company's cost of capital (discount rate) is 8%. Should the company proceed with this project?

Solution:

Calculate the Net Present Value (NPV):

Step 1: Calculate present value of each cash flow:

  • Year 1: $400,000 / (1.08)^1 = $370,370.37
  • Year 2: $500,000 / (1.08)^2 = $428,669.41
  • Year 3: $600,000 / (1.08)^3 = $476,299.39
  • Year 4: $700,000 / (1.08)^4 = $514,520.87
  • Year 5: $800,000 / (1.08)^5 = $544,466.49

Step 2: Sum the present values:

  • Total PV of cash flows = $370,370.37 + $428,669.41 + $476,299.39 + $514,520.87 + $544,466.49
  • Total PV = $2,334,326.53

Step 3: Calculate NPV:

  • NPV = Total PV of cash flows - Initial investment
  • NPV = $2,334,326.53 - $2,000,000 = $334,326.53

Analysis: NPV is positive ($334,326.53), which means the project is profitable. The present value of future cash flows exceeds the initial investment cost. The company should proceed with this project.

Python exercise

#| label: practice-3-2
#| fig-cap: "Practice Problem 3.2: Investment Project NPV Analysis"
#| fig-width: 14
#| fig-height: 6
#| echo: false
#| warning: false

# Sandbox metadata (auto-generated from lesson.ts)
# libraries: numpy, matplotlib, pandas

import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display

# Project parameters
initial_investment = 2000000
cash_flows = [400000, 500000, 600000, 700000, 800000]
years = [1, 2, 3, 4, 5]
rate = 0.08

# Calculate PVs
pvs = [cf / ((1 + rate) ** t) for t, cf in zip(years, cash_flows)]
total_pv = sum(pvs)
npv = total_pv - initial_investment
cumulative_npv = np.cumsum([-initial_investment] + pvs)

fig, axes = plt.subplots(1, 2, figsize=(16, 6))
fig.suptitle('Practice Problem 3.2: Investment Project Evaluation', fontsize=14, fontweight='bold')

# Plot 1: Cash Flows and Present Values
ax1 = axes[0]
x = np.arange(len(years))
width = 0.35
bars1 = ax1.bar(x - width/2, cash_flows, width, label='Original Cash Flows', color='blue', alpha=0.7, edgecolor='black')
bars2 = ax1.bar(x + width/2, pvs, width, label='Present Values (8% discount)', color='green', alpha=0.7, edgecolor='black')
ax1.set_xlabel('Year', fontsize=11, fontweight='bold')
ax1.set_ylabel('Cash Flow ($)', fontsize=11, fontweight='bold')
ax1.set_title('Cash Flows: Original vs Discounted', fontsize=12, fontweight='bold')
ax1.set_xticks(x)
ax1.set_xticklabels(years)
ax1.legend(loc='upper left', fontsize=9)
ax1.grid(True, alpha=0.3, linestyle='--', axis='y')
for bars in [bars1, bars2]:
    for bar in bars:
        height = bar.get_height()
        ax1.text(bar.get_x() + bar.get_width()/2., height + height*0.01,
                 f'${height/1000:.0f}K', ha='center', va='bottom', fontsize=8, fontweight='bold')

# Plot 2: Cumulative NPV
ax2 = axes[1]
time_points = [0] + years
ax2.plot(time_points, cumulative_npv, 'g-', linewidth=3, marker='o', markersize=8, alpha=0.8)
ax2.axhline(y=0, color='red', linestyle='--', linewidth=2, alpha=0.7, label='Break-even')
ax2.fill_between(time_points, 0, cumulative_npv, where=(cumulative_npv >= 0), alpha=0.3, color='green', label='Positive NPV')
ax2.fill_between(time_points, 0, cumulative_npv, where=(cumulative_npv < 0), alpha=0.3, color='red', label='Negative NPV')
ax2.plot(0, -initial_investment, 'ro', markersize=12, markeredgewidth=2, markeredgecolor='white', zorder=5)
ax2.plot(5, npv, 'go', markersize=12, markeredgewidth=2, markeredgecolor='white', zorder=5)
ax2.set_xlabel('Year', fontsize=11, fontweight='bold')
ax2.set_ylabel('Cumulative NPV ($)', fontsize=11, fontweight='bold')
ax2.set_title(f'Cumulative NPV Over Project Life\nFinal NPV: ${npv:,.2f}', fontsize=12, fontweight='bold')
ax2.grid(True, alpha=0.3, linestyle='--')
ax2.legend(loc='upper left', fontsize=9)
ax2.set_xticks(time_points)
ax2.annotate(f'NPV = ${npv:,.0f}\n✓ Profitable', xy=(5, npv), xytext=(4, npv + 200000),
             arrowprops=dict(arrowstyle='->', color='green', lw=2), fontsize=10, fontweight='bold',
             bbox=dict(boxstyle='round,pad=0.5', facecolor='lightgreen', edgecolor='green', linewidth=2))

plt.tight_layout()
display(fig)
plt.close(fig)

Real-World Context: This is the standard method companies use to evaluate capital investment projects. NPV analysis helps companies allocate capital efficiently by comparing the present value of expected returns to the required investment. Projects with positive NPV create value for shareholders, while projects with negative NPV destroy value.

Practice Problem 3.3: Real Estate Investment Analysis

You're considering buying a rental property for $300,000. You expect to receive $2,000 per month in rent (paid at the end of each month) and sell the property for $350,000 after 10 years. Your required return is 6% per year (0.5% per month). What is the present value of this investment?

Solution:

This involves multiple cash flows:

  1. Monthly rental income (annuity)
  2. Sale proceeds (lump sum)

Step 1: Calculate present value of rental income (annuity):

  • Monthly rent = $2,000

  • Monthly rate = 0.06 / 12 = 0.005 = 0.5%

  • Number of months = 10 years × 12 = 120 months

  • PV of rent = $2,000 × [1 - (1.005)^(-120)] / 0.005

  • PV of rent = $2,000 × [1 - 0.5496] / 0.005

  • PV of rent = $2,000 × 90.08 = $180,160

Step 2: Calculate present value of sale proceeds:

  • Sale price = $350,000

  • Number of years = 10

  • Annual rate = 6% = 0.06

  • PV of sale = $350,000 / (1.06)^10

  • PV of sale = $350,000 / 1.7908 = $195,339

Step 3: Calculate total present value:

  • Total PV = PV of rent + PV of sale
  • Total PV = $180,160 + $195,339 = $375,499

Step 4: Calculate net present value:

  • NPV = Total PV - Purchase price
  • NPV = $375,499 - $300,000 = $75,499

Analysis: The investment has a positive NPV of $75,499, meaning it's profitable at your required 6% return. The present value of rental income and sale proceeds exceeds the purchase price. However, this analysis doesn't include expenses (maintenance, property taxes, insurance), which would reduce the NPV.

Python exercise

#| label: practice-3-3
#| fig-cap: "Practice Problem 3.3: Real Estate Investment Analysis"
#| fig-width: 14
#| fig-height: 6
#| echo: false
#| warning: false

# Sandbox metadata (auto-generated from lesson.ts)
# libraries: numpy, matplotlib, pandas

import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display

# Parameters
purchase_price = 300000
monthly_rent = 2000
years = 10
months = years * 12
monthly_rate = 0.06 / 12
annual_rate = 0.06
sale_price = 350000

# Calculate PVs
pv_rent = monthly_rent * ((1 - (1 + monthly_rate)**(-months)) / monthly_rate)
pv_sale = sale_price / ((1 + annual_rate) ** years)
total_pv = pv_rent + pv_sale
npv = total_pv - purchase_price

# Monthly cash flows
month_numbers = np.arange(1, months + 1, 1)
monthly_cash_flows = [monthly_rent] * months

fig, axes = plt.subplots(1, 2, figsize=(16, 6))
fig.suptitle('Practice Problem 3.3: Real Estate Investment Analysis', fontsize=14, fontweight='bold')

# Plot 1: Cash Flow Timeline
ax1 = axes[0]
ax1.barh([0], [purchase_price], left=0, height=0.2, color='red', alpha=0.7, label='Purchase Price', edgecolor='black')
# Show monthly rent (sample every 12 months for visibility)
for i in range(0, months, 12):
    ax1.barh([1], [monthly_rent * 12], left=i, height=0.2, color='green', alpha=0.7 if i == 0 else 0.5, edgecolor='black')
ax1.barh([1], [sale_price], left=months, height=0.2, color='blue', alpha=0.7, label='Sale Proceeds', edgecolor='black')
ax1.set_xlabel('Time (Months)', fontsize=11, fontweight='bold')
ax1.set_ylabel('Cash Flow Type', fontsize=11, fontweight='bold')
ax1.set_yticks([0, 1])
ax1.set_yticklabels(['Purchase\n(Outflow)', 'Rent & Sale\n(Inflows)'])
ax1.set_title('Investment Cash Flow Timeline', fontsize=12, fontweight='bold')
ax1.grid(True, alpha=0.3, linestyle='--', axis='x')
ax1.legend(loc='upper right', fontsize=9)
ax1.set_xlim(-10, months + 20)

# Plot 2: Present Value Breakdown
ax2 = axes[1]
components = ['Purchase\nPrice', 'PV of\nRent', 'PV of\nSale', 'Total PV', 'NPV']
values = [-purchase_price, pv_rent, pv_sale, total_pv, npv]
colors = ['red', 'green', 'blue', 'purple', 'orange']
bars = ax2.bar(components, values, color=colors, alpha=0.7, edgecolor='black', linewidth=1.5)
ax2.axhline(y=0, color='black', linestyle='-', linewidth=1)
ax2.set_ylabel('Value ($)', fontsize=11, fontweight='bold')
ax2.set_title('Present Value Analysis', fontsize=12, fontweight='bold')
ax2.grid(True, alpha=0.3, linestyle='--', axis='y')
for bar, val in zip(bars, values):
    height = bar.get_height()
    y_pos = height + (abs(height) * 0.02 if height >= 0 else -abs(height) * 0.02)
    ax2.text(bar.get_x() + bar.get_width()/2., y_pos,
             f'${val:,.0f}', ha='center', va='bottom' if height >= 0 else 'top', 
             fontsize=9, fontweight='bold')
ax2.text(0.5, 0.95, f'✓ Profitable Investment\nNPV = ${npv:,.0f}',
         transform=ax2.transAxes, ha='center', va='top', fontsize=10, fontweight='bold',
         bbox=dict(boxstyle='round,pad=0.5', facecolor='lightgreen', edgecolor='green', linewidth=2))

plt.tight_layout()
display(fig)
plt.close(fig)

Real-World Context: Real estate investors use this type of analysis to evaluate rental properties. The key is comparing the present value of expected cash flows (rent and eventual sale) to the purchase price. This helps investors identify properties that will generate returns above their required rate, creating value over time.

Present Value of Multiple Cash Flows: If you have multiple future cash flows, you calculate the present value of each and sum them. For example, if you'll receive $1,000 in one year, $2,000 in two years, and $3,000 in three years, all discounted at 6%:

  • $1,000 in 1 year: $1,000 / (1.06)^1 = $943.40
  • $2,000 in 2 years: $2,000 / (1.06)^2 = $1,779.99
  • $3,000 in 3 years: $3,000 / (1.06)^3 = $2,518.86
  • Total Present Value: $5,242.25

This is how bonds are priced - the bond price is the present value of all future coupon payments and principal repayment.

Net Present Value (NPV)

Net Present Value is a crucial concept for investment decisions. It's the present value of all cash flows (both inflows and outflows) from an investment. The formula is:

NPV=∑t=0nCFt(1+r)tNPV = \sum_{t=0}^{n} \frac{CF_t}{(1 + r)^t}

Where:

  • CF_t = Cash flow at time t
  • r = Discount rate
  • n = Number of periods

Investment Decision Rule: If NPV > 0, the investment is profitable and should be accepted. If NPV < 0, the investment loses money and should be rejected. If NPV = 0, the investment breaks even.

Example: An investment costs $10,000 today and generates cash flows of $3,000 per year for 5 years. If the discount rate is 8%:

  • Initial investment (t=0): -$10,000
  • Year 1: $3,000 / (1.08)^1 = $2,777.78
  • Year 2: $3,000 / (1.08)^2 = $2,572.02
  • Year 3: $3,000 / (1.08)^3 = $2,381.50
  • Year 4: $3,000 / (1.08)^4 = $2,205.09
  • Year 5: $3,000 / (1.08)^5 = $2,041.75
  • NPV = -$10,000 + $11,978.14 = $1,978.14

Since NPV > 0, the investment is profitable.

Let's visualize NPV with sensitivity analysis:

Python exercise

#| label: npv-visualization-enhanced
#| fig-cap: "NPV Visualization: Enhanced NPV Chart with Sensitivity Analysis, IRR Calculation Visualization"
#| fig-width: 16
#| fig-height: 10
#| echo: false
#| warning: false

# Sandbox metadata (auto-generated from lesson.ts)
# libraries: numpy, matplotlib, pandas

import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display

# Investment parameters
initial_investment = -10000
annual_cashflow = 3000
years = 5
base_discount_rate = 0.08

# Calculate NPV components
cash_flows = [initial_investment] + [annual_cashflow] * years
time_periods = np.arange(0, years + 1, 1)
pv_individual = cash_flows / ((1 + base_discount_rate) ** time_periods)
total_npv = np.sum(pv_individual)

# NPV sensitivity to discount rate
discount_rates = np.linspace(0.01, 0.20, 100)
npv_by_rate = []
for r in discount_rates:
    pv_at_r = cash_flows / ((1 + r) ** time_periods)
    npv_by_rate.append(np.sum(pv_at_r))

npv_by_rate = np.array(npv_by_rate)

# Find IRR (where NPV = 0)
irr = None
for r in discount_rates:
    pv_at_r = cash_flows / ((1 + r) ** time_periods)
    npv_at_r = np.sum(pv_at_r)
    if npv_at_r <= 0:
        irr = r
        break

# Create figure
fig, axes = plt.subplots(2, 2, figsize=(16, 12))
fig.suptitle('NPV Visualization: Enhanced Analysis with Sensitivity and IRR', 
            fontsize=16, fontweight='bold')

# Plot 1: NPV Components
ax1 = axes[0, 0]
bars = ax1.bar(range(len(time_periods)), pv_individual, 
               color=plt.cm.RdYlGn(np.linspace(0.3, 0.9, len(time_periods))), 
               alpha=0.7, edgecolor='black', linewidth=1.5)
ax1.axhline(y=0, color='black', linestyle='-', linewidth=1.5)
ax1.axhline(y=total_npv, color='red', linestyle='--', linewidth=2, alpha=0.7, 
           label=f'Total NPV: ${total_npv:,.2f}')
ax1.set_xlabel('Time Period (t)', fontsize=12, fontweight='bold')
ax1.set_ylabel('Present Value ($)', fontsize=12, fontweight='bold')
ax1.set_title(f'NPV Components: Individual Cash Flow PVs (r = {base_discount_rate*100:.0f}%)', 
             fontsize=13, fontweight='bold')
ax1.set_xticks(range(len(time_periods)))
ax1.set_xticklabels([f't={i}' for i in time_periods])
ax1.grid(True, alpha=0.3, linestyle='--', axis='y')
ax1.legend(loc='best', fontsize=9)

# Add value labels
for i, (bar, cf, pv) in enumerate(zip(bars, cash_flows, pv_individual)):
    height = bar.get_height()
    ax1.text(bar.get_x() + bar.get_width()/2., height + (100 if height > 0 else -300),
            f'${pv:.0f}\n(CF=${cf:,})', ha='center', va='bottom' if height > 0 else 'top',
            fontsize=8, fontweight='bold',
            bbox=dict(boxstyle='round', facecolor='white', alpha=0.8))

# Plot 2: NPV vs Discount Rate (IRR calculation)
ax2 = axes[0, 1]
ax2.plot(discount_rates * 100, npv_by_rate, 'b-', linewidth=3, alpha=0.8)
ax2.axhline(y=0, color='black', linestyle='-', linewidth=1.5)
ax2.axvline(x=base_discount_rate * 100, color='green', linestyle='--', linewidth=2, alpha=0.7, 
           label=f'Base Rate: {base_discount_rate*100:.0f}%')
if irr:
    ax2.axvline(x=irr * 100, color='red', linestyle='--', linewidth=2, alpha=0.7, 
               label=f'IRR: {irr*100:.2f}%')
    ax2.plot(irr * 100, 0, 'ro', markersize=12, markeredgewidth=2, 
            markeredgecolor='white', zorder=5)
ax2.plot(base_discount_rate * 100, total_npv, 'go', markersize=12, markeredgewidth=2, 
        markeredgecolor='white', zorder=5)
ax2.fill_between(discount_rates * 100, 0, npv_by_rate, where=(npv_by_rate > 0),
                alpha=0.3, color='green', label='Profitable Zone (NPV > 0)')
ax2.fill_between(discount_rates * 100, 0, npv_by_rate, where=(npv_by_rate < 0),
                alpha=0.3, color='red', label='Unprofitable Zone (NPV < 0)')
ax2.set_xlabel('Discount Rate (%)', fontsize=12, fontweight='bold')
ax2.set_ylabel('Net Present Value ($)', fontsize=12, fontweight='bold')
ax2.set_title('NPV vs Discount Rate: Finding IRR (where NPV = 0)', fontsize=13, fontweight='bold')
ax2.grid(True, alpha=0.3, linestyle='--')
ax2.legend(loc='best', fontsize=9)

# Plot 3: Sensitivity Analysis
ax3 = axes[1, 0]
# Vary cash flow amount
cashflow_range = np.linspace(2000, 4000, 100)
npv_by_cf = []
for cf in cashflow_range:
    cf_series = [initial_investment] + [cf] * years
    pv_cf = cf_series / ((1 + base_discount_rate) ** time_periods)
    npv_by_cf.append(np.sum(pv_cf))

npv_by_cf = np.array(npv_by_cf)

ax3.plot(cashflow_range, npv_by_cf, 'purple', linewidth=3, alpha=0.8)
ax3.axhline(y=0, color='black', linestyle='-', linewidth=1.5)
ax3.axvline(x=annual_cashflow, color='green', linestyle='--', linewidth=2, alpha=0.7, 
           label=f'Base CF: ${annual_cashflow:,}')
ax3.plot(annual_cashflow, total_npv, 'go', markersize=12, markeredgewidth=2, 
        markeredgecolor='white', zorder=5)
ax3.fill_between(cashflow_range, 0, npv_by_cf, where=(npv_by_cf > 0),
                alpha=0.3, color='green', label='Profitable Zone')
ax3.set_xlabel('Annual Cash Flow ($)', fontsize=12, fontweight='bold')
ax3.set_ylabel('Net Present Value ($)', fontsize=12, fontweight='bold')
ax3.set_title('NPV Sensitivity to Cash Flow Amount', fontsize=13, fontweight='bold')
ax3.grid(True, alpha=0.3, linestyle='--')
ax3.legend(loc='best', fontsize=9)

# Plot 4: Cumulative NPV
ax4 = axes[1, 1]
cumulative_npv = np.cumsum(pv_individual)
ax4.plot(time_periods, cumulative_npv, 'b-o', linewidth=3, markersize=8, alpha=0.8)
ax4.bar(time_periods, pv_individual, alpha=0.5, color='blue', edgecolor='black', linewidth=1.5,
       label='Period PV')
ax4.axhline(y=0, color='black', linestyle='-', linewidth=1.5)
ax4.axhline(y=total_npv, color='red', linestyle='--', linewidth=2, alpha=0.7, 
           label=f'Final NPV: ${total_npv:,.2f}')
ax4.fill_between(time_periods, 0, cumulative_npv, where=(cumulative_npv > 0),
                alpha=0.3, color='green', label='Positive NPV Zone')
ax4.set_xlabel('Time Period (t)', fontsize=12, fontweight='bold')
ax4.set_ylabel('Cumulative NPV ($)', fontsize=12, fontweight='bold')
ax4.set_title('Cumulative NPV Over Time', fontsize=13, fontweight='bold')
ax4.grid(True, alpha=0.3, linestyle='--')
ax4.legend(loc='best', fontsize=9)

# Add value labels
for t, cum_npv in zip(time_periods, cumulative_npv):
    ax4.text(t, cum_npv + (200 if cum_npv > 0 else -400), f'${cum_npv:,.0f}', 
            ha='center', va='bottom' if cum_npv > 0 else 'top',
            fontsize=9, fontweight='bold',
            bbox=dict(boxstyle='round', facecolor='lightblue', alpha=0.8))

plt.tight_layout()
display(fig)
plt.close(fig)

print(f"\n📊 **NPV Analysis**")
print(f"{'='*70}")
print(f"Formula: NPV = Σ CF_t / (1 + r)^t")
print(f"  where CF_t = cash flow at time t")
print(f"        r = discount rate")
print(f"{'='*70}")
print(f"Investment: Initial cost = ${abs(initial_investment):,}, Annual CF = ${annual_cashflow:,} for {years} years")
print(f"Discount Rate: {base_discount_rate*100:.0f}%")
print(f"{'='*70}")
print(f"NPV Components:")
for i, (t, cf, pv) in enumerate(zip(time_periods, cash_flows, pv_individual)):
    print(f"  t={t}: CF=${cf:>7,} → PV=${pv:>10,.2f}")
print(f"{'='*70}")
print(f"Total NPV: ${total_npv:,.2f}")
if total_npv > 0:
    print(f"Decision: ACCEPT (NPV > 0, profitable)")
else:
    print(f"Decision: REJECT (NPV < 0, unprofitable)")
if irr:
    print(f"IRR: {irr*100:.2f}% (discount rate where NPV = 0)")
print(f"{'='*70}")
print(f"✅ NPV > 0 means investment earns more than discount rate")
print(f"✅ IRR is the break-even discount rate")
print(f"✅ Sensitivity analysis shows how NPV changes with assumptions")

Interactive NPV Visualization

Let's visualize how NPV works with an interactive example. The plot below shows how the present value of each cash flow decreases over time due to discounting, and how the total NPV is the sum of all discounted cash flows.

Python exercise

#| label: npv-visualization
#| fig-cap: "NPV Visualization: Present Value of Cash Flows Over Time"
#| fig-width: 14
#| fig-height: 8
#| echo: false
#| warning: false

# Sandbox metadata (auto-generated from lesson.ts)
# libraries: numpy, matplotlib, pandas

import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display
import matplotlib.patches as mpatches

# Investment parameters
initial_investment = -10000
annual_cashflow = 3000
years = 5
discount_rate = 0.08

# Calculate cash flows
cash_flows = [initial_investment] + [annual_cashflow] * years
time_periods = list(range(years + 1))

# Calculate present value of each cash flow
present_values = []
for t, cf in enumerate(cash_flows):
    if t == 0:
        pv = cf  # Initial investment is at t=0, no discounting
    else:
        pv = cf / ((1 + discount_rate) ** t)
    present_values.append(pv)

# Calculate cumulative NPV
cumulative_npv = np.cumsum(present_values)

# Calculate NPV
npv = sum(present_values)

# Create figure with subplots - larger size for expanded content area
fig, axes = plt.subplots(2, 2, figsize=(16, 12))
fig.suptitle('Net Present Value (NPV) Analysis', fontsize=16, fontweight='bold')

# Plot 1: Cash Flows Over Time
ax1 = axes[0, 0]
ax1.bar(time_periods, cash_flows, color=['red' if x < 0 else 'green' for x in cash_flows], 
        alpha=0.7, edgecolor='black', linewidth=1.5)
ax1.axhline(y=0, color='black', linestyle='-', linewidth=0.5)
ax1.set_xlabel('Time Period (Years)', fontsize=11, fontweight='bold')
ax1.set_ylabel('Cash Flow ($)', fontsize=11, fontweight='bold')
ax1.set_title('1. Original Cash Flows', fontsize=12, fontweight='bold')
ax1.grid(True, alpha=0.3, linestyle='--')
ax1.set_xticks(time_periods)
for i, (t, cf) in enumerate(zip(time_periods, cash_flows)):
    ax1.text(t, cf + 300 if cf > 0 else cf - 800, f'${cf:,.0f}', 
             ha='center', va='bottom' if cf > 0 else 'top', fontsize=9, fontweight='bold')

# Plot 2: Present Value of Each Cash Flow
ax2 = axes[0, 1]
colors_pv = ['red' if x < 0 else 'blue' for x in present_values]
bars = ax2.bar(time_periods, present_values, color=colors_pv, alpha=0.7, 
               edgecolor='black', linewidth=1.5)
ax2.axhline(y=0, color='black', linestyle='-', linewidth=0.5)
ax2.set_xlabel('Time Period (Years)', fontsize=11, fontweight='bold')
ax2.set_ylabel('Present Value ($)', fontsize=11, fontweight='bold')
ax2.set_title(f'2. Present Values (r = {discount_rate*100:.1f}%)', fontsize=12, fontweight='bold')
ax2.grid(True, alpha=0.3, linestyle='--')
ax2.set_xticks(time_periods)
for i, (t, pv) in enumerate(zip(time_periods, present_values)):
    ax2.text(t, pv + 200 if pv > 0 else pv - 600, f'${pv:,.2f}', 
             ha='center', va='bottom' if pv > 0 else 'top', fontsize=9, fontweight='bold')

# Plot 3: Cumulative NPV
ax3 = axes[1, 0]
line = ax3.plot(time_periods, cumulative_npv, marker='o', linewidth=2.5, 
                markersize=8, color='#2563eb', markerfacecolor='white', 
                markeredgewidth=2, markeredgecolor='#2563eb')
ax3.axhline(y=0, color='black', linestyle='-', linewidth=0.5)
ax3.fill_between(time_periods, 0, cumulative_npv, 
                 where=(cumulative_npv >= 0), alpha=0.3, color='green', label='Positive NPV')
ax3.fill_between(time_periods, 0, cumulative_npv, 
                 where=(cumulative_npv < 0), alpha=0.3, color='red', label='Negative NPV')
ax3.set_xlabel('Time Period (Years)', fontsize=11, fontweight='bold')
ax3.set_ylabel('Cumulative NPV ($)', fontsize=11, fontweight='bold')
ax3.set_title('3. Cumulative NPV Over Time', fontsize=12, fontweight='bold')
ax3.grid(True, alpha=0.3, linestyle='--')
ax3.set_xticks(time_periods)
ax3.legend(loc='best', fontsize=9)
# Add final NPV annotation
ax3.annotate(f'Final NPV = ${npv:,.2f}', 
             xy=(years, npv), xytext=(years-1.5, npv + 1000),
             arrowprops=dict(arrowstyle='->', color='#2563eb', lw=2),
             fontsize=11, fontweight='bold', color='#2563eb',
             bbox=dict(boxstyle='round,pad=0.5', facecolor='white', edgecolor='#2563eb', linewidth=2))

# Plot 4: NPV Sensitivity to Discount Rate
ax4 = axes[1, 1]
discount_rates = np.linspace(0.02, 0.20, 100)
npv_sensitivity = []
for r in discount_rates:
    pv_sum = initial_investment
    for t in range(1, years + 1):
        pv_sum += annual_cashflow / ((1 + r) ** t)
    npv_sensitivity.append(pv_sum)

ax4.plot(discount_rates * 100, npv_sensitivity, linewidth=2.5, color='#7c3aed')
ax4.axhline(y=0, color='black', linestyle='-', linewidth=0.5)
ax4.axvline(x=discount_rate * 100, color='red', linestyle='--', linewidth=1.5, 
            label=f'Current Rate ({discount_rate*100:.1f}%)')
ax4.fill_between(discount_rates * 100, 0, npv_sensitivity, 
                 where=(np.array(npv_sensitivity) >= 0), alpha=0.3, color='green', label='Profitable')
ax4.fill_between(discount_rates * 100, 0, npv_sensitivity, 
                 where=(np.array(npv_sensitivity) < 0), alpha=0.3, color='red', label='Unprofitable')
ax4.set_xlabel('Discount Rate (%)', fontsize=11, fontweight='bold')
ax4.set_ylabel('NPV ($)', fontsize=11, fontweight='bold')
ax4.set_title('4. NPV Sensitivity to Discount Rate', fontsize=12, fontweight='bold')
ax4.grid(True, alpha=0.3, linestyle='--')
ax4.legend(loc='best', fontsize=9)
# Mark the current NPV
current_npv_idx = np.argmin(np.abs(np.array(discount_rates) - discount_rate))
ax4.plot(discount_rate * 100, npv_sensitivity[current_npv_idx], 'ro', markersize=10, 
         markerfacecolor='white', markeredgewidth=2, markeredgecolor='red')
ax4.annotate(f'NPV = ${npv:,.2f}', 
             xy=(discount_rate * 100, npv), xytext=(discount_rate * 100 + 3, npv + 500),
             arrowprops=dict(arrowstyle='->', color='red', lw=1.5),
             fontsize=10, fontweight='bold', color='red',
             bbox=dict(boxstyle='round,pad=0.4', facecolor='white', edgecolor='red', linewidth=1.5))

plt.tight_layout()
display(fig)
plt.close(fig)

# Print summary statistics
print(f"\n📊 **NPV Analysis Summary**")
print(f"{'='*50}")
print(f"Initial Investment:     ${initial_investment:,.2f}")
print(f"Annual Cash Flow:       ${annual_cashflow:,.2f}")
print(f"Number of Years:        {years}")
print(f"Discount Rate:          {discount_rate*100:.2f}%")
print(f"{'='*50}")
print(f"**Net Present Value:    ${npv:,.2f}**")
print(f"{'='*50}")
if npv > 0:
    print(f"✅ **Investment Decision: ACCEPT** (NPV > 0)")
    print(f"   The investment is profitable and adds ${npv:,.2f} in value.")
else:
    print(f"❌ **Investment Decision: REJECT** (NPV < 0)")
    print(f"   The investment destroys ${abs(npv):,.2f} in value.")

This visualization demonstrates four key aspects of NPV:

  1. Original Cash Flows: Shows the actual cash flows over time (red for outflows, green for inflows)
  2. Present Values: Shows how each cash flow is discounted to present value (notice how future cash flows are worth less)
  3. Cumulative NPV: Shows how NPV builds up over time, starting negative and becoming positive
  4. NPV Sensitivity: Shows how NPV changes with different discount rates - critical for understanding risk

Internal Rate of Return (IRR)

The Internal Rate of Return is the discount rate that makes NPV equal to zero. It's the rate of return that an investment actually earns. If IRR > required rate of return, the investment is acceptable.

IRR is calculated by solving for r in the NPV equation when NPV = 0:

0=∑t=0nCFt(1+IRR)t0 = \sum_{t=0}^{n} \frac{CF_t}{(1 + IRR)^t}

IRR must typically be calculated using trial and error or financial calculators/software, as there's no simple algebraic solution.

Example: Using the previous example, we need to find the rate where:

  • 10,000=$3,000×[PVIFAfor5periodsatr10,000 = \text{\$}3,000 × [PVIFA for 5 periods at r%]1−(1+r)−nr\frac{1 - (1 + r)^{-n}}{r} is called the Present Value Interest Factor of an Annuity (PVIFA). It's a factor that can be looked up in tables or calculated.

Let's visualize how annuities work:

Python exercise

#| label: annuity-visualization
#| fig-cap: "Annuity Cash Flows: Present and Future Value Analysis"
#| fig-width: 14
#| fig-height: 8
#| echo: false
#| warning: false

# Sandbox metadata (auto-generated from lesson.ts)
# libraries: numpy, matplotlib, pandas

import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display

# Annuity parameters
payment = 1000  # Annual payment
n_periods = 10  # Number of years
rate = 0.06  # 6% annual rate

# Calculate PV of annuity
pv_annuity = payment * ((1 - (1 + rate)**(-n_periods)) / rate)

# Calculate FV of annuity
fv_annuity = payment * (((1 + rate)**n_periods - 1) / rate)

# Calculate individual PVs for each payment
periods = np.arange(1, n_periods + 1, 1)
pv_per_payment = payment / ((1 + rate) ** periods)
cumulative_pv = np.cumsum(pv_per_payment)

# Calculate individual FVs for each payment (at end of period n)
fv_per_payment = payment * ((1 + rate) ** (n_periods - periods + 1))
cumulative_fv = np.cumsum(fv_per_payment)

# Create figure
fig, axes = plt.subplots(2, 2, figsize=(16, 12))
fig.suptitle('Annuity Analysis: Present Value and Future Value', fontsize=16, fontweight='bold')

# Plot 1: Cash Flows Timeline
ax1 = axes[0, 0]
ax1.bar(periods, [payment] * n_periods, color='blue', alpha=0.7, 
        edgecolor='black', linewidth=1.5, label='Annual Payment')
ax1.set_xlabel('Period (Year)', fontsize=12, fontweight='bold')
ax1.set_ylabel('Cash Flow ($)', fontsize=12, fontweight='bold')
ax1.set_title(f'Annuity: ${payment:,.0f} per year for {n_periods} years', fontsize=13, fontweight='bold')
ax1.grid(True, alpha=0.3, linestyle='--', axis='y')
ax1.set_xticks(periods)
for i, p in enumerate(periods):
    ax1.text(p, payment + 50, f'${payment:,.0f}', ha='center', va='bottom', 
             fontsize=9, fontweight='bold')

# Plot 2: Present Value of Each Payment
ax2 = axes[0, 1]
bars2 = ax2.bar(periods, pv_per_payment, color='green', alpha=0.7, 
                edgecolor='black', linewidth=1.5, label='PV of Each Payment')
ax2.plot(periods, cumulative_pv, 'r-', linewidth=3, marker='o', markersize=6, 
         label='Cumulative PV', alpha=0.8)
ax2.axhline(y=pv_annuity, color='red', linestyle='--', linewidth=2, alpha=0.7, 
            label=f'Total PV: ${pv_annuity:,.2f}')
ax2.set_xlabel('Period (Year)', fontsize=12, fontweight='bold')
ax2.set_ylabel('Present Value ($)', fontsize=12, fontweight='bold')
ax2.set_title(f'Present Value of Annuity (Discounted at {rate*100:.0f}%)', fontsize=13, fontweight='bold')
ax2.grid(True, alpha=0.3, linestyle='--', axis='y')
ax2.set_xticks(periods)
ax2.legend(loc='upper right', fontsize=9)
for i, (p, pv) in enumerate(zip(periods, pv_per_payment)):
    ax2.text(p, pv + 30, f'${pv:,.0f}', ha='center', va='bottom', 
             fontsize=8, fontweight='bold')

# Plot 3: Future Value of Each Payment
ax3 = axes[1, 0]
bars3 = ax3.bar(periods, fv_per_payment, color='orange', alpha=0.7, 
                edgecolor='black', linewidth=1.5, label='FV of Each Payment')
ax3.plot(periods, cumulative_fv, 'purple', linewidth=3, marker='s', markersize=6, 
         label='Cumulative FV', alpha=0.8)
ax3.axhline(y=fv_annuity, color='purple', linestyle='--', linewidth=2, alpha=0.7, 
            label=f'Total FV: ${fv_annuity:,.2f}')
ax3.set_xlabel('Period (Year)', fontsize=12, fontweight='bold')
ax3.set_ylabel('Future Value at Year 10 ($)', fontsize=12, fontweight='bold')
ax3.set_title(f'Future Value of Annuity (Compounded at {rate*100:.0f}%)', fontsize=13, fontweight='bold')
ax3.grid(True, alpha=0.3, linestyle='--', axis='y')
ax3.set_xticks(periods)
ax3.legend(loc='upper left', fontsize=9)
for i, (p, fv) in enumerate(zip(periods, fv_per_payment)):
    ax3.text(p, fv + 200, f'${fv:,.0f}', ha='center', va='bottom', 
             fontsize=8, fontweight='bold', rotation=90)

# Plot 4: PV and FV Relationship
ax4 = axes[1, 1]
# Show that FV = PV * (1+r)^n
verification_fv = pv_annuity * ((1 + rate) ** n_periods)
x = np.arange(len(['PV', 'FV']))
y = [pv_annuity, fv_annuity]
bars4 = ax4.bar(x, y, color=['green', 'purple'], alpha=0.7, 
                edgecolor='black', linewidth=1.5)
ax4.set_ylabel('Value ($)', fontsize=12, fontweight='bold')
ax4.set_title('PV and FV Relationship', fontsize=13, fontweight='bold')
ax4.set_xticks(x)
ax4.set_xticklabels(['Present Value\n(at t=0)', 'Future Value\n(at t=10)'])
ax4.grid(True, alpha=0.3, linestyle='--', axis='y')
for i, (bar, val) in enumerate(zip(bars4, y)):
    ax4.text(bar.get_x() + bar.get_width()/2., val + val*0.02,
             f'${val:,.2f}',
             ha='center', va='bottom', fontsize=11, fontweight='bold')
# Add verification text
ax4.text(0.5, 0.95, f'Verification: FV = PV × (1+r)ⁿ\n     = ${pv_annuity:,.2f} × 1.06¹⁰\n     = ${verification_fv:,.2f}',
         transform=ax4.transAxes, ha='center', va='top', fontsize=10,
         bbox=dict(boxstyle='round,pad=0.5', facecolor='yellow', edgecolor='black', linewidth=1.5))

plt.tight_layout()
display(fig)
plt.close(fig)

print(f"\n📊 **Annuity Analysis**")
print(f"{'='*60}")
print(f"Annuity Parameters:")
print(f"  Annual Payment: ${payment:,.2f}")
print(f"  Number of Periods: {n_periods} years")
print(f"  Interest Rate: {rate*100:.1f}%")
print(f"{'='*60}")
print(f"Present Value of Annuity: ${pv_annuity:,.2f}")
print(f"  Formula: PMT × [1 - (1+r)⁻ⁿ] / r")
print(f"  = ${payment:,.0f} × [1 - (1.06)⁻¹⁰] / 0.06")
print(f"  = ${payment:,.0f} × {pv_annuity/payment:.4f}")
print(f"{'='*60}")
print(f"Future Value of Annuity: ${fv_annuity:,.2f}")
print(f"  Formula: PMT × [(1+r)ⁿ - 1] / r")
print(f"  = ${payment:,.0f} × [(1.06)¹⁰ - 1] / 0.06")
print(f"  = ${payment:,.0f} × {fv_annuity/payment:.4f}")
print(f"{'='*60}")
print(f"Verification: FV = PV × (1+r)ⁿ")
print(f"  ${fv_annuity:,.2f} = ${pv_annuity:,.2f} × 1.06¹⁰")
print(f"  ${fv_annuity:,.2f} = ${verification_fv:,.2f} ✓")
print(f"{'='*60}")
print(f"✅ Key Insight: Early payments are worth more in PV terms")
print(f"✅ Later payments have more time to compound in FV terms")

Example: What is the present value of receiving $1,000 per year for 5 years at 6% interest?

  • PV = $1,000 × [1 - (1.06)^(-5)] / 0.06
  • PV = $1,000 × [1 - 0.7473] / 0.06
  • PV = $1,000 × 4.2124 = $4,212.40

This means that receiving $1,000 per year for 5 years is equivalent to receiving $4,212.40 today at a 6% discount rate.

Let's visualize the PVIFA factor and annuity due comparison:

Python exercise

#| label: annuity-pvifa-enhanced
#| fig-cap: "Annuity PV Formula: Enhanced Visualization of PV = PMT × [1-(1+r)^-n]/r with PVIFA Table"
#| fig-width: 16
#| fig-height: 10
#| echo: false
#| warning: false

# Sandbox metadata (auto-generated from lesson.ts)
# libraries: numpy, matplotlib, pandas

import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display

# Parameters
PMT = 1000
r = 0.06
n_values = np.arange(1, 21, 1)

# Calculate PVIFA for different n values
pvifa_values = (1 - (1 + r) ** (-n_values)) / r
pv_annuity_by_n = PMT * pvifa_values

# Annuity due vs ordinary annuity
n_example = 10
pv_ordinary = PMT * ((1 - (1 + r)**(-n_example)) / r)
pv_due = pv_ordinary * (1 + r)

# Create figure
fig, axes = plt.subplots(2, 2, figsize=(16, 12))
fig.suptitle('Annuity PV Formula: PV = PMT × [1-(1+r)^-n]/r with PVIFA Analysis', 
            fontsize=16, fontweight='bold')

# Plot 1: PVIFA vs Number of Periods
ax1 = axes[0, 0]
ax1.plot(n_values, pvifa_values, 'b-o', linewidth=3, markersize=6, alpha=0.8)
ax1.fill_between(n_values, 0, pvifa_values, alpha=0.3, color='blue')
ax1.set_xlabel('Number of Periods (n)', fontsize=12, fontweight='bold')
ax1.set_ylabel('PVIFA Factor', fontsize=12, fontweight='bold')
ax1.set_title(f'Present Value Interest Factor of Annuity (PVIFA) at {r*100:.0f}%', 
             fontsize=13, fontweight='bold')
ax1.grid(True, alpha=0.3, linestyle='--')

# Add asymptotic line (approaches 1/r as n → ∞)
asymptote = 1 / r
ax1.axhline(y=asymptote, color='red', linestyle='--', linewidth=2, alpha=0.7, 
           label=f'Asymptote: 1/r = {asymptote:.2f} (Perpetuity)')
ax1.legend(loc='best', fontsize=9)

# Add value labels at key points
for n in [5, 10, 15, 20]:
    idx = n - 1
    ax1.annotate(f'n={n}\nPVIFA={pvifa_values[idx]:.3f}', 
                xy=(n, pvifa_values[idx]), xytext=(n + 2, pvifa_values[idx] + 0.5),
                fontsize=9, fontweight='bold',
                bbox=dict(boxstyle='round', facecolor='yellow', alpha=0.8),
                arrowprops=dict(arrowstyle='->', color='blue', lw=1.5))

# Plot 2: PV of Annuity vs Number of Periods
ax2 = axes[0, 1]
ax2.plot(n_values, pv_annuity_by_n, 'g-o', linewidth=3, markersize=6, alpha=0.8)
ax2.fill_between(n_values, 0, pv_annuity_by_n, alpha=0.3, color='green')
ax2.set_xlabel('Number of Periods (n)', fontsize=12, fontweight='bold')
ax2.set_ylabel('Present Value ($)', fontsize=12, fontweight='bold')
ax2.set_title(f'PV of Annuity: ${PMT:,} per period at {r*100:.0f}%', 
             fontsize=13, fontweight='bold')
ax2.grid(True, alpha=0.3, linestyle='--')

# Mark key points
for n in [5, 10, 15, 20]:
    idx = n - 1
    ax2.plot(n, pv_annuity_by_n[idx], 'ro', markersize=8, zorder=5)
    ax2.annotate(f'n={n}\n${pv_annuity_by_n[idx]:,.0f}', 
                xy=(n, pv_annuity_by_n[idx]), xytext=(n + 2, pv_annuity_by_n[idx] + 1000),
                fontsize=9, fontweight='bold',
                bbox=dict(boxstyle='round', facecolor='lightgreen', alpha=0.8),
                arrowprops=dict(arrowstyle='->', color='green', lw=1.5))

# Plot 3: Ordinary Annuity vs Annuity Due
ax3 = axes[1, 0]
periods_comp = np.arange(0, n_example + 1, 1)
pv_ordinary_series = np.zeros(n_example + 1)
pv_due_series = np.zeros(n_example + 1)

for i in range(n_example + 1):
    if i == 0:
        pv_ordinary_series[i] = 0
        pv_due_series[i] = PMT
    else:
        pv_ordinary_series[i] = PMT * ((1 - (1 + r)**(-i)) / r)
        pv_due_series[i] = PMT * ((1 - (1 + r)**(-i)) / r) * (1 + r)

ax3.plot(periods_comp, pv_ordinary_series, 'b-o', linewidth=2.5, markersize=6, 
        label=f'Ordinary Annuity (PV=${pv_ordinary:,.2f})', alpha=0.8)
ax3.plot(periods_comp, pv_due_series, 'r-s', linewidth=2.5, markersize=6, 
        label=f'Annuity Due (PV=${pv_due:,.2f})', alpha=0.8)
ax3.fill_between(periods_comp, pv_ordinary_series, pv_due_series, 
                alpha=0.2, color='orange', label='Difference')
ax3.set_xlabel('Number of Payments Received', fontsize=12, fontweight='bold')
ax3.set_ylabel('Present Value ($)', fontsize=12, fontweight='bold')
ax3.set_title(f'Ordinary Annuity vs Annuity Due (n={n_example}, r={r*100:.0f}%)', 
             fontsize=13, fontweight='bold')
ax3.grid(True, alpha=0.3, linestyle='--')
ax3.legend(loc='best', fontsize=9)

# Add annotation
ax3.text(0.02, 0.98, f'Difference:\n${pv_due - pv_ordinary:,.2f}\n({((pv_due/pv_ordinary - 1)*100):.2f}% more)',
        transform=ax3.transAxes, fontsize=10, fontweight='bold',
        bbox=dict(boxstyle='round', facecolor='yellow', alpha=0.9),
        verticalalignment='top', family='monospace')

# Plot 4: PVIFA Table (Heatmap)
ax4 = axes[1, 1]
rates_table = np.array([0.02, 0.04, 0.06, 0.08, 0.10, 0.12])
periods_table = np.array([5, 10, 15, 20])
pvifa_table = np.zeros((len(rates_table), len(periods_table)))

for i, rate in enumerate(rates_table):
    for j, n in enumerate(periods_table):
        pvifa_table[i, j] = (1 - (1 + rate)**(-n)) / rate

im = ax4.imshow(pvifa_table, cmap='YlGnBu', aspect='auto', vmin=pvifa_table.min(), vmax=pvifa_table.max())
ax4.set_xlabel('Number of Periods (n)', fontsize=12, fontweight='bold')
ax4.set_ylabel('Interest Rate (%)', fontsize=12, fontweight='bold')
ax4.set_title('PVIFA Table: [1-(1+r)^-n]/r', fontsize=13, fontweight='bold')
ax4.set_xticks(range(len(periods_table)))
ax4.set_xticklabels(periods_table)
ax4.set_yticks(range(len(rates_table)))
ax4.set_yticklabels([f'{r*100:.0f}%' for r in rates_table])
cbar = plt.colorbar(im, ax=ax4)
cbar.set_label('PVIFA Factor', fontsize=11, fontweight='bold')

# Add text annotations
for i in range(len(rates_table)):
    for j in range(len(periods_table)):
        text = ax4.text(j, i, f'{pvifa_table[i, j]:.2f}',
                       ha="center", va="center", color="black", fontsize=9, fontweight='bold')

plt.tight_layout()
display(fig)
plt.close(fig)

print(f"\n📊 **Annuity PVIFA Analysis**")
print(f"{'='*70}")
print(f"Formula: PV = PMT × [1 - (1+r)^-n] / r")
print(f"  where PVIFA = [1 - (1+r)^-n] / r")
print(f"        PMT = payment per period")
print(f"        r = interest rate per period")
print(f"        n = number of periods")
print(f"{'='*70}")
print(f"PVIFA Table (Sample):")
print(f"{'Rate':<8} {'n=5':<10} {'n=10':<10} {'n=15':<10} {'n=20':<10}")
print(f"{'-'*70}")
for i, rate in enumerate(rates_table):
    print(f"{rate*100:>5.0f}%   {pvifa_table[i,0]:>8.3f}   {pvifa_table[i,1]:>8.3f}   {pvifa_table[i,2]:>8.3f}   {pvifa_table[i,3]:>8.3f}")
print(f"{'='*70}")
print(f"Ordinary Annuity vs Annuity Due (n={n_example}, r={r*100:.0f}%):")
print(f"  Ordinary Annuity: PV = ${pv_ordinary:,.2f}")
print(f"  Annuity Due:      PV = ${pv_due:,.2f}")
print(f"  Difference:       ${pv_due - pv_ordinary:,.2f} ({(pv_due/pv_ordinary - 1)*100:.2f}% more)")
print(f"{'='*70}")
print(f"✅ PVIFA increases with number of periods (approaches 1/r)")
print(f"✅ Annuity due worth more (payments received earlier)")
print(f"✅ PVIFA table useful for quick calculations")

For an Annuity Due: Multiply the ordinary annuity PV by (1 + r):

PVdue=PMT×1−(1+r)−nr×(1+r)PV_{due} = PMT \times \frac{1 - (1 + r)^{-n}}{r} \times (1 + r)

Example: If the 4,212.40×1.06=4,212.40 × 1.06 =(1+r)n−1r\frac{(1 + r)^n - 1}{r} is called the Future Value Interest Factor of an Annuity (FVIFA).

Example: If you save $2,000 per year for 20 years at 7% interest, how much will you have?

  • FV = $2,000 × [(1.07)^20 - 1] / 0.07
  • FV = $2,000 × [3.8697 - 1] / 0.07
  • FV = $2,000 × 41.0270 = $82,054.00

Your $40,000 in contributions ($2,000 × 20) grows to over $82,000 due to compound interest.

Practice Problem 4.1: Mortgage Payment Calculation

You're buying a house for $400,000. You make a 20% down payment ($80,000) and take out a 30-year fixed-rate mortgage for $320,000 at 5% annual interest. What is your monthly mortgage payment?

Solution:

A mortgage is an annuity where the loan amount equals the present value of all future payments.

Given:

  • Loan amount (PV) = $320,000
  • Annual rate = 5% = 0.05
  • Monthly rate = 0.05 / 12 = 0.004167
  • Number of months = 30 years × 12 = 360 months

Using the annuity present value formula, solve for PMT:

  • PV = PMT × [1 - (1 + r)^(-n)] / r
  • $320,000 = PMT × [1 - (1.004167)^(-360)] / 0.004167
  • $320,000 = PMT × [1 - 0.2238] / 0.004167
  • $320,000 = PMT × 186.2816
  • PMT = $320,000 / 186.2816 = $1,717.83

Analysis: Your monthly payment is $1,717.83. Over 30 years, you'll make 360 payments totaling $618,418.80, but the loan was only $320,000. The difference ($298,418.80) is interest paid to the bank. This demonstrates the cost of borrowing over long periods.

Real-World Context: This is how mortgage payments are calculated. The bank uses the annuity formula to determine the payment that, when discounted at the interest rate, equals the loan amount. Understanding this helps you see how much of each payment goes to principal vs. interest, and how interest rates affect affordability.

Let's visualize how loan amortization works:

Python exercise

#| label: loan-amortization
#| fig-cap: "Loan Amortization: Principal and Interest Over Time"
#| fig-width: 14
#| fig-height: 8
#| echo: false
#| warning: false

# Sandbox metadata (auto-generated from lesson.ts)
# libraries: numpy, matplotlib, pandas

import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display

# Loan parameters
loan_amount = 320000  # $320,000 mortgage
annual_rate = 0.05  # 5% annual
n_years = 30
n_periods = n_years * 12  # Monthly payments
monthly_rate = annual_rate / 12

# Calculate monthly payment
monthly_payment = loan_amount * (monthly_rate * (1 + monthly_rate)**n_periods) / ((1 + monthly_rate)**n_periods - 1)

# Calculate amortization schedule
balance = loan_amount
principal_paid = []
interest_paid = []
balance_remaining = [loan_amount]
total_paid = []

for month in range(1, n_periods + 1):
    interest = balance * monthly_rate
    principal = monthly_payment - interest
    balance = balance - principal
    
    principal_paid.append(principal)
    interest_paid.append(interest)
    balance_remaining.append(balance)
    total_paid.append(monthly_payment)

months = np.arange(1, n_periods + 1, 1)
cumulative_principal = np.cumsum(principal_paid)
cumulative_interest = np.cumsum(interest_paid)

# Create figure
fig, axes = plt.subplots(2, 2, figsize=(16, 12))
fig.suptitle('Loan Amortization: Principal and Interest Over Time', fontsize=16, fontweight='bold')

# Plot 1: Payment Breakdown (first 5 years)
ax1 = axes[0, 0]
first_5_years = 60  # 60 months
months_5 = months[:first_5_years]
width = 0.6
ax1.bar(months_5, [principal_paid[i] for i in range(first_5_years)], width, 
        label='Principal', color='green', alpha=0.7, edgecolor='black', linewidth=0.5)
ax1.bar(months_5, [interest_paid[i] for i in range(first_5_years)], width,
        bottom=[principal_paid[i] for i in range(first_5_years)],
        label='Interest', color='red', alpha=0.7, edgecolor='black', linewidth=0.5)
ax1.set_xlabel('Month', fontsize=12, fontweight='bold')
ax1.set_ylabel('Payment Amount ($)', fontsize=12, fontweight='bold')
ax1.set_title(f'Monthly Payment Breakdown (First 5 Years)\nTotal Payment: ${monthly_payment:,.2f}/month', fontsize=13, fontweight='bold')
ax1.grid(True, alpha=0.3, linestyle='--', axis='y')
ax1.legend(loc='upper right', fontsize=10)
ax1.set_xticks(range(0, first_5_years + 1, 12))
ax1.set_xticklabels(range(0, 6))

# Plot 2: Principal vs Interest Over Full Loan
ax2 = axes[0, 1]
# Sample every 12 months for clarity
sample_months = months[::12]
sample_principal = [principal_paid[i-1] for i in sample_months]
sample_interest = [interest_paid[i-1] for i in sample_months]
years = sample_months / 12

ax2.plot(years, sample_principal, 'g-', linewidth=3, marker='o', markersize=5, label='Principal Payment', alpha=0.8)
ax2.plot(years, sample_interest, 'r-', linewidth=3, marker='s', markersize=5, label='Interest Payment', alpha=0.8)
ax2.axhline(y=monthly_payment, color='blue', linestyle='--', linewidth=2, alpha=0.5, label=f'Total Payment: ${monthly_payment:,.2f}')
ax2.set_xlabel('Year', fontsize=12, fontweight='bold')
ax2.set_ylabel('Payment Amount ($)', fontsize=12, fontweight='bold')
ax2.set_title('Principal vs Interest Over Loan Life', fontsize=13, fontweight='bold')
ax2.grid(True, alpha=0.3, linestyle='--')
ax2.legend(loc='best', fontsize=10)
ax2.set_xticks(range(0, n_years + 1, 5))

# Plot 3: Balance Remaining Over Time
ax3 = axes[1, 0]
balance_yearly = balance_remaining[::12]
years_balance = np.arange(0, n_years + 1, 1)
ax3.plot(years_balance, balance_yearly, 'purple', linewidth=3, marker='o', markersize=5, alpha=0.8)
ax3.fill_between(years_balance, 0, balance_yearly, alpha=0.3, color='purple')
ax3.set_xlabel('Year', fontsize=12, fontweight='bold')
ax3.set_ylabel('Loan Balance ($)', fontsize=12, fontweight='bold')
ax3.set_title('Remaining Loan Balance Over Time', fontsize=13, fontweight='bold')
ax3.grid(True, alpha=0.3, linestyle='--')
ax3.set_xticks(range(0, n_years + 1, 5))
# Mark half-paid point
half_paid_idx = np.argmin(np.abs(np.array(balance_yearly) - loan_amount/2))
ax3.plot(years_balance[half_paid_idx], balance_yearly[half_paid_idx], 'ro', markersize=12, 
         markeredgewidth=2, markeredgecolor='white', zorder=5)
ax3.annotate(f'Half Paid: Year {years_balance[half_paid_idx]:.0f}',
             xy=(years_balance[half_paid_idx], balance_yearly[half_paid_idx]),
             xytext=(years_balance[half_paid_idx] + 3, balance_yearly[half_paid_idx] + 40000),
             arrowprops=dict(arrowstyle='->', color='red', lw=2),
             fontsize=10, fontweight='bold', color='red',
             bbox=dict(boxstyle='round,pad=0.5', facecolor='yellow', edgecolor='red', linewidth=2))

# Plot 4: Cumulative Principal and Interest
ax4 = axes[1, 1]
cumulative_principal_yearly = cumulative_principal[11::12]  # End of each year
cumulative_interest_yearly = cumulative_interest[11::12]
years_cum = np.arange(1, n_years + 1, 1)

ax4.plot(years_cum, cumulative_principal_yearly, 'g-', linewidth=3, marker='o', markersize=5, 
         label='Cumulative Principal Paid', alpha=0.8)
ax4.plot(years_cum, cumulative_interest_yearly, 'r-', linewidth=3, marker='s', markersize=5, 
         label='Cumulative Interest Paid', alpha=0.8)
ax4.axhline(y=loan_amount, color='blue', linestyle=':', linewidth=2, alpha=0.5, 
            label=f'Loan Amount: ${loan_amount:,.0f}')
ax4.set_xlabel('Year', fontsize=12, fontweight='bold')
ax4.set_ylabel('Cumulative Amount ($)', fontsize=12, fontweight='bold')
ax4.set_title('Cumulative Principal and Interest Paid', fontsize=13, fontweight='bold')
ax4.grid(True, alpha=0.3, linestyle='--')
ax4.legend(loc='upper left', fontsize=10)
ax4.set_xticks(range(0, n_years + 1, 5))

plt.tight_layout()
display(fig)
plt.close(fig)

print(f"\n📊 **Loan Amortization Analysis**")
print(f"{'='*60}")
print(f"Loan Parameters:")
print(f"  Loan Amount: ${loan_amount:,.2f}")
print(f"  Annual Interest Rate: {annual_rate*100:.2f}%")
print(f"  Loan Term: {n_years} years ({n_periods} months)")
print(f"{'='*60}")
print(f"Monthly Payment: ${monthly_payment:,.2f}")
print(f"{'='*60}")
print(f"Total Payments Over Loan Life:")
print(f"  Total Paid:        ${sum(total_paid):,.2f}")
print(f"  Principal Paid:    ${cumulative_principal[-1]:,.2f}")
print(f"  Interest Paid:     ${cumulative_interest[-1]:,.2f}")
print(f"  Interest as % of Total: {cumulative_interest[-1]/sum(total_paid)*100:.1f}%")
print(f"{'='*60}")
print(f"Key Insights:")
print(f"  • Early payments are mostly interest")
print(f"  • Later payments are mostly principal")
print(f"  • Total interest: ${cumulative_interest[-1]:,.2f} (almost as much as loan!)")
print(f"  • Half of loan paid off around year {years_balance[half_paid_idx]:.0f}")
print(f"{'='*60}")
print(f"✅ Understanding amortization helps you see the true cost of borrowing")
print(f"✅ Making extra principal payments early saves significant interest")

Practice Problem 4.2: Retirement Annuity Withdrawal

You've saved $1,000,000 for retirement and want to withdraw a fixed amount each year for 25 years. If your retirement account earns 5% annual interest, how much can you withdraw each year?

Solution:

This is the reverse of a savings annuity - you have a present value and want to determine the annual payment.

Given:

  • PV = $1,000,000 (retirement savings)
  • r = 5% = 0.05
  • n = 25 years

Using the annuity present value formula, solve for PMT:

  • PV = PMT × [1 - (1 + r)^(-n)] / r
  • $1,000,000 = PMT × [1 - (1.05)^(-25)] / 0.05
  • $1,000,000 = PMT × [1 - 0.2953] / 0.05
  • $1,000,000 = PMT × 14.0939
  • PMT = $1,000,000 / 14.0939 = $70,952.00

Analysis: You can withdraw approximately $70,952 per year for 25 years. This totals $1,773,800 over 25 years, but you only started with $1,000,000. The difference comes from the 5% annual return on your remaining balance. Notice that if you withdraw more than this amount, you'll run out of money before 25 years.

Python exercise

#| label: practice-4-2
#| fig-cap: "Practice Problem 4.2: Retirement Annuity Withdrawal"
#| fig-width: 14
#| fig-height: 6
#| echo: false
#| warning: false

# Sandbox metadata (auto-generated from lesson.ts)
# libraries: numpy, matplotlib, pandas

import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display

# Parameters
initial_savings = 1000000
annual_withdrawal = 70952
years = 25
rate = 0.05

# Calculate balance over time
balance = initial_savings
balances = [balance]
withdrawals = []

for year in range(years):
    balance = balance * (1 + rate) - annual_withdrawal
    balances.append(balance)
    withdrawals.append(annual_withdrawal)

total_withdrawn = sum(withdrawals)

fig, axes = plt.subplots(1, 2, figsize=(16, 6))
fig.suptitle('Practice Problem 4.2: Retirement Annuity Withdrawal', fontsize=14, fontweight='bold')

# Plot 1: Balance Over Time
ax1 = axes[0]
year_numbers = np.arange(0, years + 1, 1)
ax1.plot(year_numbers, balances, 'b-', linewidth=3, marker='o', markersize=4, alpha=0.8)
ax1.axhline(y=0, color='red', linestyle='--', linewidth=2, alpha=0.7, label='Zero Balance')
ax1.fill_between(year_numbers, 0, balances, alpha=0.3, color='blue')
ax1.set_xlabel('Year', fontsize=11, fontweight='bold')
ax1.set_ylabel('Account Balance ($)', fontsize=11, fontweight='bold')
ax1.set_title(f'Account Balance Over {years} Years\n(${annual_withdrawal:,.0f}/year withdrawal)', fontsize=12, fontweight='bold')
ax1.grid(True, alpha=0.3, linestyle='--')
ax1.legend(loc='upper right', fontsize=9)
ax1.plot(0, initial_savings, 'go', markersize=12, zorder=5)
ax1.plot(years, balances[-1], 'ro', markersize=12, zorder=5)

# Plot 2: Withdrawal vs Investment Returns
ax2 = axes[1]
year_indices = np.arange(1, years + 1, 1)
annual_returns = [b * rate for b in balances[:-1]]
annual_withdrawals_list = [annual_withdrawal] * years
x = np.arange(len(year_indices))
width = 0.35
bars1 = ax2.bar(x - width/2, annual_returns, width, label='Investment Returns', color='green', alpha=0.7, edgecolor='black')
bars2 = ax2.bar(x + width/2, annual_withdrawals_list, width, label='Annual Withdrawals', color='blue', alpha=0.7, edgecolor='black')
ax2.set_xlabel('Year', fontsize=11, fontweight='bold')
ax2.set_ylabel('Amount ($)', fontsize=11, fontweight='bold')
ax2.set_title('Annual Returns vs Withdrawals', fontsize=12, fontweight='bold')
ax2.set_xticks(x[::5])
ax2.set_xticklabels(year_indices[::5])
ax2.legend(loc='upper right', fontsize=9)
ax2.grid(True, alpha=0.3, linestyle='--', axis='y')
ax2.text(0.5, 0.95, f'Total Withdrawn: ${total_withdrawn:,.0f}\n(Started with ${initial_savings:,.0f})',
         transform=ax2.transAxes, ha='center', va='top', fontsize=10, fontweight='bold',
         bbox=dict(boxstyle='round,pad=0.5', facecolor='yellow', edgecolor='black', linewidth=1.5))

plt.tight_layout()
display(fig)
plt.close(fig)

Real-World Context: This is the basis for retirement withdrawal strategies like the "4% rule" (though simplified). Financial planners use this calculation to help retirees determine sustainable withdrawal rates. The key insight is that with investment returns, you can withdraw more than just the principal - the returns supplement your withdrawals.

Practice Problem 4.3: Perpetuity Valuation - Dividend Stock

A company pays annual dividends of 3.00(annualdividend)−r=6∗∗Usingtheperpetuityformula∗∗:−PV=PMT/r−PV=3.00 (annual dividend) - r = 6% = 0.06 (required return) **Using the perpetuity formula**: - PV = PMT / r - PV =PV=PMTrPV = \frac{PMT}{r}Where:−PV=PresentValue−PMT=Paymentperperiod−r=Discountrateperperiod∗∗GrowingPerpetuityFormula∗∗:IfpaymentsgrowataconstantrateWhere: - PV = Present Value - PMT = Payment per period - r = Discount rate per period **Growing Perpetuity Formula**: If payments grow at a constant rateg$:g\text{\$}:g$ is the growth rate per period (must be less than $r$).

Let's visualize perpetuities and growing perpetuities:

Python exercise

#| label: perpetuity-formula
#| fig-cap: "Perpetuity Formula: Visualization showing PV = PMT/r with growing perpetuity PV = PMT/(r-g)"
#| fig-width: 16
#| fig-height: 10
#| echo: false
#| warning: false

# Sandbox metadata (auto-generated from lesson.ts)
# libraries: numpy, matplotlib, pandas

import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display

# Perpetuity parameters
PMT = 1000  # Annual payment
r = 0.06  # 6% discount rate
g = 0.03  # 3% growth rate for growing perpetuity

# Calculate perpetuity PV
pv_perpetuity = PMT / r

# Calculate growing perpetuity PV
pv_growing_perpetuity = PMT / (r - g)

# Compare with finite annuities
n_values = np.arange(1, 101, 1)
pv_annuities = PMT * ((1 - (1 + r)**(-n_values)) / r)

# PV vs discount rate
rates = np.linspace(0.02, 0.15, 100)
pv_by_rate = PMT / rates
pv_growing_by_rate = PMT / (rates - g)
pv_growing_by_rate = np.where(rates > g, pv_growing_by_rate, np.nan)  # Only valid when r > g

# Create figure
fig, axes = plt.subplots(2, 2, figsize=(16, 12))
fig.suptitle('Perpetuity Formula: PV = PMT/r and Growing Perpetuity PV = PMT/(r-g)', 
            fontsize=16, fontweight='bold')

# Plot 1: Annuity vs Perpetuity (convergence)
ax1 = axes[0, 0]
ax1.plot(n_values, pv_annuities, 'b-', linewidth=3, alpha=0.8, label='Finite Annuity PV')
ax1.axhline(y=pv_perpetuity, color='red', linestyle='--', linewidth=2.5, alpha=0.8, 
           label=f'Perpetuity PV = ${pv_perpetuity:,.2f}')
ax1.axhline(y=pv_growing_perpetuity, color='green', linestyle='--', linewidth=2.5, alpha=0.8, 
           label=f'Growing Perpetuity PV = ${pv_growing_perpetuity:,.2f}')
ax1.set_xlabel('Number of Periods (n)', fontsize=12, fontweight='bold')
ax1.set_ylabel('Present Value ($)', fontsize=12, fontweight='bold')
ax1.set_title(f'Annuity Approaches Perpetuity as n → ∞ (r = {r*100:.0f}%)', fontsize=13, fontweight='bold')
ax1.grid(True, alpha=0.3, linestyle='--')
ax1.legend(loc='best', fontsize=9)
ax1.set_xlim(0, 100)

# Mark convergence point
ax1.annotate(f'As n → ∞:\nPV → ${pv_perpetuity:,.2f}\n(Perpetuity)', 
            xy=(80, pv_perpetuity), xytext=(60, pv_perpetuity + 2000),
            arrowprops=dict(arrowstyle='->', color='red', lw=2),
            fontsize=10, fontweight='bold',
            bbox=dict(boxstyle='round', facecolor='yellow', alpha=0.9))

# Plot 2: PV vs Discount Rate
ax2 = axes[0, 1]
ax2.plot(rates * 100, pv_by_rate, 'b-', linewidth=3, alpha=0.8, label='Perpetuity: PV = PMT/r')
ax2.plot(rates * 100, pv_growing_by_rate, 'g-', linewidth=3, alpha=0.8, 
        label=f'Growing Perpetuity: PV = PMT/(r-g)\n(g = {g*100:.0f}%)')
ax2.axvline(x=r * 100, color='red', linestyle='--', linewidth=2, alpha=0.7, 
           label=f'Base Rate: {r*100:.0f}%')
ax2.plot(r * 100, pv_perpetuity, 'bo', markersize=12, markeredgewidth=2, 
        markeredgecolor='white', zorder=5)
ax2.plot(r * 100, pv_growing_perpetuity, 'go', markersize=12, markeredgewidth=2, 
        markeredgecolor='white', zorder=5)
ax2.set_xlabel('Discount Rate (%)', fontsize=12, fontweight='bold')
ax2.set_ylabel('Present Value ($)', fontsize=12, fontweight='bold')
ax2.set_title('Perpetuity PV Sensitivity to Discount Rate', fontsize=13, fontweight='bold')
ax2.grid(True, alpha=0.3, linestyle='--')
ax2.legend(loc='best', fontsize=9)
ax2.set_xlim(2, 15)

# Add formula annotations
ax2.text(0.02, 0.98, f'Perpetuity:\nPV = PMT/r\n= ${PMT:,} / {r:.2f}\n= ${pv_perpetuity:,.2f}',
        transform=ax2.transAxes, fontsize=10, fontweight='bold',
        bbox=dict(boxstyle='round', facecolor='lightblue', alpha=0.9),
        verticalalignment='top', family='monospace')
ax2.text(0.02, 0.70, f'Growing:\nPV = PMT/(r-g)\n= ${PMT:,} / ({r:.2f}-{g:.2f})\n= ${pv_growing_perpetuity:,.2f}',
        transform=ax2.transAxes, fontsize=10, fontweight='bold',
        bbox=dict(boxstyle='round', facecolor='lightgreen', alpha=0.9),
        verticalalignment='top', family='monospace')

# Plot 3: Growth Rate Impact
ax3 = axes[1, 0]
growth_rates = np.linspace(0, r - 0.01, 50)  # g must be < r
pv_growing_by_g = PMT / (r - growth_rates)

ax3.plot(growth_rates * 100, pv_growing_by_g, 'purple', linewidth=3, alpha=0.8)
ax3.axvline(x=g * 100, color='green', linestyle='--', linewidth=2, alpha=0.7, 
           label=f'Base Growth: {g*100:.0f}%')
ax3.plot(g * 100, pv_growing_perpetuity, 'go', markersize=12, markeredgewidth=2, 
        markeredgecolor='white', zorder=5)
ax3.axhline(y=pv_perpetuity, color='red', linestyle='--', linewidth=2, alpha=0.7, 
           label=f'Perpetuity (no growth): ${pv_perpetuity:,.2f}')
ax3.set_xlabel('Growth Rate (%)', fontsize=12, fontweight='bold')
ax3.set_ylabel('Present Value ($)', fontsize=12, fontweight='bold')
ax3.set_title('Growing Perpetuity: Impact of Growth Rate (r = 6%)', fontsize=13, fontweight='bold')
ax3.grid(True, alpha=0.3, linestyle='--')
ax3.legend(loc='best', fontsize=9)

# Add warning annotation
ax3.text(0.98, 0.02, 'Warning: g must be < r\nor PV → ∞',
        transform=ax3.transAxes, fontsize=10, fontweight='bold',
        bbox=dict(boxstyle='round', facecolor='red', alpha=0.9),
        verticalalignment='bottom', horizontalalignment='right')

# Plot 4: Comparison Table
ax4 = axes[1, 1]
scenarios = ['Perpetuity\n(no growth)', 'Growing\nPerpetuity\n(g=3%)', 'Annuity\n(n=10)', 'Annuity\n(n=20)', 'Annuity\n(n=50)']
pv_values = [
    pv_perpetuity,
    pv_growing_perpetuity,
    PMT * ((1 - (1 + r)**(-10)) / r),
    PMT * ((1 - (1 + r)**(-20)) / r),
    PMT * ((1 - (1 + r)**(-50)) / r)
]

bars = ax4.bar(range(len(scenarios)), pv_values, 
               color=plt.cm.RdYlGn(np.linspace(0.3, 0.9, len(scenarios))), 
               alpha=0.7, edgecolor='black', linewidth=1.5)
ax4.axhline(y=pv_perpetuity, color='red', linestyle='--', linewidth=2, alpha=0.7, 
           label=f'Perpetuity Baseline')
ax4.set_xlabel('Scenario', fontsize=12, fontweight='bold')
ax4.set_ylabel('Present Value ($)', fontsize=12, fontweight='bold')
ax4.set_title('Comparison: Perpetuity vs Annuities', fontsize=13, fontweight='bold')
ax4.set_xticks(range(len(scenarios)))
ax4.set_xticklabels(scenarios, rotation=45, ha='right')
ax4.grid(True, alpha=0.3, linestyle='--', axis='y')
ax4.legend(loc='best', fontsize=9)

# Add value labels
for bar, val in zip(bars, pv_values):
    height = bar.get_height()
    ax4.text(bar.get_x() + bar.get_width()/2., height + 500,
            f'${val:,.0f}', ha='center', va='bottom',
            fontsize=9, fontweight='bold')

plt.tight_layout()
display(fig)
plt.close(fig)

print(f"\n📊 **Perpetuity Analysis**")
print(f"{'='*70}")
print(f"Perpetuity Formula: PV = PMT / r")
print(f"  where PMT = payment per period")
print(f"        r = discount rate per period")
print(f"{'='*70}")
print(f"Growing Perpetuity Formula: PV = PMT / (r - g)")
print(f"  where g = growth rate per period (must be < r)")
print(f"{'='*70}")
print(f"Example: PMT = ${PMT:,}, r = {r*100:.0f}%, g = {g*100:.0f}%")
print(f"  Perpetuity PV:        ${pv_perpetuity:,.2f} = ${PMT:,} / {r:.2f}")
print(f"  Growing Perpetuity PV: ${pv_growing_perpetuity:,.2f} = ${PMT:,} / ({r:.2f} - {g:.2f})")
print(f"{'='*70}")
print(f"Comparison with Finite Annuities:")
print(f"  Annuity (n=10):  ${pv_values[2]:,.2f}")
print(f"  Annuity (n=20):  ${pv_values[3]:,.2f}")
print(f"  Annuity (n=50):  ${pv_values[4]:,.2f}")
print(f"  Perpetuity:      ${pv_perpetuity:,.2f} (as n → ∞)")
print(f"{'='*70}")
print(f"✅ Perpetuity is limit of annuity as n → ∞")
print(f"✅ Growing perpetuity worth more (payments increase)")
print(f"✅ Growth rate must be < discount rate (or PV → ∞)")

Python exercise

#| label: practice-4-3
#| fig-cap: "Practice Problem 4.3: Perpetuity Valuation - Dividend Stock"
#| fig-width: 14
#| fig-height: 6
#| echo: false
#| warning: false

# Sandbox metadata (auto-generated from lesson.ts)
# libraries: numpy, matplotlib, pandas

import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display

# Parameters
dividend = 3.00
required_return = 0.06
fair_value = dividend / required_return

# Dividend yield at different prices
prices = np.linspace(30, 70, 100)
dividend_yields = dividend / prices

# PV of infinite dividend stream at different discount rates
discount_rates = np.linspace(0.03, 0.10, 100)
stock_values = dividend / discount_rates

fig, axes = plt.subplots(1, 2, figsize=(16, 6))
fig.suptitle('Practice Problem 4.3: Perpetuity Valuation - Dividend Stock', fontsize=14, fontweight='bold')

# Plot 1: Dividend Yield vs Stock Price
ax1 = axes[0]
ax1.plot(prices, dividend_yields * 100, 'b-', linewidth=3, alpha=0.8)
ax1.axvline(x=fair_value, color='green', linestyle='--', linewidth=2, alpha=0.7, label=f'Fair Value: ${fair_value:.2f}')
ax1.axhline(y=required_return * 100, color='red', linestyle='--', linewidth=2, alpha=0.7, label=f'Required Return: {required_return*100:.0f}%')
ax1.plot(fair_value, required_return * 100, 'go', markersize=12, markeredgewidth=2, markeredgecolor='white', zorder=5)
ax1.fill_between(prices, 0, dividend_yields * 100, where=(prices <= fair_value), alpha=0.3, color='green', label='Undervalued')
ax1.fill_between(prices, 0, dividend_yields * 100, where=(prices > fair_value), alpha=0.3, color='red', label='Overvalued')
ax1.set_xlabel('Stock Price ($)', fontsize=11, fontweight='bold')
ax1.set_ylabel('Dividend Yield (%)', fontsize=11, fontweight='bold')
ax1.set_title('Dividend Yield vs Stock Price', fontsize=12, fontweight='bold')
ax1.grid(True, alpha=0.3, linestyle='--')
ax1.legend(loc='upper right', fontsize=9)

# Plot 2: Stock Value vs Required Return
ax2 = axes[1]
ax2.plot(discount_rates * 100, stock_values, 'purple', linewidth=3, alpha=0.8)
ax2.axvline(x=required_return * 100, color='red', linestyle='--', linewidth=2, alpha=0.7, label=f'Required Return: {required_return*100:.0f}%')
ax2.axhline(y=fair_value, color='green', linestyle='--', linewidth=2, alpha=0.7, label=f'Fair Value: ${fair_value:.2f}')
ax2.plot(required_return * 100, fair_value, 'go', markersize=12, markeredgewidth=2, markeredgecolor='white', zorder=5)
ax2.set_xlabel('Required Return / Discount Rate (%)', fontsize=11, fontweight='bold')
ax2.set_ylabel('Stock Value ($)', fontsize=11, fontweight='bold')
ax2.set_title('Stock Value Sensitivity to Required Return', fontsize=12, fontweight='bold')
ax2.grid(True, alpha=0.3, linestyle='--')
ax2.legend(loc='upper right', fontsize=9)

plt.tight_layout()
display(fig)
plt.close(fig)

Real-World Context: This is the basis for the dividend discount model (DDM) used in stock valuation. While real companies often grow dividends over time (requiring the growing perpetuity model), the basic perpetuity model is useful for stable, mature companies with consistent dividend policies. Utility companies and real estate investment trusts (REITs) are often valued this way.

For an Annuity Due: Multiply the ordinary annuity FV by (1 + r):

FVdue=PMT×(1+r)n−1r×(1+r)FV_{due} = PMT \times \frac{(1 + r)^n - 1}{r} \times (1 + r)

Perpetuities: Infinite Series of Regular Payments

A perpetuity is an annuity that continues forever. While true perpetuities are rare, they're useful for understanding certain financial instruments and as approximations for long-term annuities.

Present Value of a Perpetuity: Since payments continue forever, we use a simplified formula:

PV=PMTrPV = \frac{PMT}{r}

Where:

  • PV = Present Value
  • PMT = Payment per period
  • r = Interest rate per period

Example: What is the present value of receiving $100 per year forever at 5% interest?

  • PV = $100 / 0.05 = $2,000

Receiving $100 per year forever is worth $2,000 today at a 5% discount rate.

Growing Perpetuity: If payments grow at a constant rate g, the formula is:

PV=PMTr−gPV = \frac{PMT}{r - g}

Where g < r (the growth rate must be less than the discount rate).

Example: What is the present value of receiving $100 in the first year, growing at 3% per year forever, at a 5% discount rate?

  • PV = $100 / (0.05 - 0.03) = $100 / 0.02 = $5,000

The growing perpetuity is worth much more because payments increase over time.

Applications of Annuities and Perpetuities

Mortgages: Mortgage payments are annuities. The loan amount is the present value of all future payments. Understanding annuities helps you understand how mortgages work and how to calculate payments.

Bonds: Bond coupon payments are annuities. The bond price is the present value of coupon payments (annuity) plus the present value of principal repayment. Understanding annuities is essential for understanding bonds.

Retirement Planning: Retirement planning involves calculating how much to save (future value of annuity) or how much you can withdraw (present value of annuity). Understanding annuities is crucial for retirement planning.

Dividend Valuation: Some stock valuation models treat dividends as perpetuities or growing perpetuities. The dividend discount model uses perpetuity concepts.

Pension Obligations: Pension obligations are valued using annuity concepts. Companies must calculate the present value of future pension payments.

Leases: Lease payments are annuities. Understanding annuities helps evaluate lease vs. buy decisions.

Loan Amortization: Loan amortization schedules show how payments are split between principal and interest. Understanding annuities helps understand these schedules.

Annuities and perpetuities are fundamental to many financial instruments and decisions. Understanding them is essential for understanding financial markets.


In Module 4: Mathematics for Finance

  1. Introduction
  2. Time Value of Money: The Foundation of Finance
  3. Compound Interest: The Power of Exponential Growth
  4. Present Value and Future Value: Valuing Money Across Time
  5. Annuities and Perpetuities
  6. Basic Statistics and Probability: Understanding Uncertainty
  7. Financial Ratios and Percentages: Tools for Analysis
  8. Advanced Financial Mathematics
  9. Mathematical Modeling in Finance
  10. End-of-Module Assessment