Time Value of Money: The Foundation of Finance
1. Time Value of Money: The Foundation of Finance
Python exercise
# Interactive Expected Value and Risk Visualization
# Shows probability distributions, variance calculation, risk-return scatter, and efficient frontier
interactive_html = """
<div id="expected-value-risk" style="margin: 2em 0; padding: 1.5em; background: #ffffff; border: 1px solid #e5e7eb; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
<h3 style="margin-top: 0; color: #1f2937; font-size: 1.25em; font-weight: 600;">Expected Value and Risk: Understanding Return Distributions</h3>
<p style="color: #6b7280; margin-bottom: 1.5em;">Adjust outcomes and probabilities to see how they affect expected value and risk:</p>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1em; margin-bottom: 2em;">
<div style="padding: 1em; background: #f9fafb; border-radius: 6px;">
<label style="display: block; margin-bottom: 0.5em; font-weight: 500; color: #374151;">Outcome 1 (%):</label>
<input type="range" id="outcome1" min="-20" max="30" value="10" step="1" style="width: 100%; height: 8px; border-radius: 4px; background: #e5e7eb; outline: none;">
<div style="text-align: center; margin-top: 0.5em;">
<span id="outcome1_value" style="display: inline-block; padding: 0.5em 1em; background: #059669; color: white; font-weight: 600; font-size: 0.9em; border-radius: 6px; min-width: 50px;">10%</span>
</div>
</div>
<div style="padding: 1em; background: #f9fafb; border-radius: 6px;">
<label style="display: block; margin-bottom: 0.5em; font-weight: 500; color: #374151;">Probability 1:</label>
<input type="range" id="prob1" min="0" max="100" value="30" step="1" style="width: 100%; height: 8px; border-radius: 4px; background: #e5e7eb; outline: none;">
<div style="text-align: center; margin-top: 0.5em;">
<span id="prob1_value" style="display: inline-block; padding: 0.5em 1em; background: #2563eb; color: white; font-weight: 600; font-size: 0.9em; border-radius: 6px; min-width: 50px;">30%</span>
</div>
</div>
<div style="padding: 1em; background: #f9fafb; border-radius: 6px;">
<label style="display: block; margin-bottom: 0.5em; font-weight: 500; color: #374151;">Outcome 2 (%):</label>
<input type="range" id="outcome2" min="-20" max="30" value="5" step="1" style="width: 100%; height: 8px; border-radius: 4px; background: #e5e7eb; outline: none;">
<div style="text-align: center; margin-top: 0.5em;">
<span id="outcome2_value" style="display: inline-block; padding: 0.5em 1em; background: #059669; color: white; font-weight: 600; font-size: 0.9em; border-radius: 6px; min-width: 50px;">5%</span>
</div>
</div>
<div style="padding: 1em; background: #f9fafb; border-radius: 6px;">
<label style="display: block; margin-bottom: 0.5em; font-weight: 500; color: #374151;">Probability 2:</label>
<input type="range" id="prob2" min="0" max="100" value="50" step="1" style="width: 100%; height: 8px; border-radius: 4px; background: #e5e7eb; outline: none;">
<div style="text-align: center; margin-top: 0.5em;">
<span id="prob2_value" style="display: inline-block; padding: 0.5em 1em; background: #2563eb; color: white; font-weight: 600; font-size: 0.9em; border-radius: 6px; min-width: 50px;">50%</span>
</div>
</div>
<div style="padding: 1em; background: #f9fafb; border-radius: 6px;">
<label style="display: block; margin-bottom: 0.5em; font-weight: 500; color: #374151;">Outcome 3 (%):</label>
<input type="range" id="outcome3" min="-20" max="30" value="-5" step="1" style="width: 100%; height: 8px; border-radius: 4px; background: #e5e7eb; outline: none;">
<div style="text-align: center; margin-top: 0.5em;">
<span id="outcome3_value" style="display: inline-block; padding: 0.5em 1em; background: #dc2626; color: white; font-weight: 600; font-size: 0.9em; border-radius: 6px; min-width: 50px;">-5%</span>
</div>
</div>
<div style="padding: 1em; background: #f9fafb; border-radius: 6px;">
<label style="display: block; margin-bottom: 0.5em; font-weight: 500; color: #374151;">Probability 3:</label>
<input type="range" id="prob3" min="0" max="100" value="20" step="1" style="width: 100%; height: 8px; border-radius: 4px; background: #e5e7eb; outline: none;">
<div style="text-align: center; margin-top: 0.5em;">
<span id="prob3_value" style="display: inline-block; padding: 0.5em 1em; background: #2563eb; color: white; font-weight: 600; font-size: 0.9em; border-radius: 6px; min-width: 50px;">20%</span>
</div>
</div>
</div>
<div style="background: white; padding: 1.5em; border-radius: 6px; border: 1px solid #e5e7eb;">
<canvas id="riskCanvas" width="700" height="700" style="width: 100%; max-width: 700px; height: 700px; border: 1px solid #e5e7eb; border-radius: 4px; display: block;"></canvas>
</div>
<div id="risk-analysis" style="margin-top: 1.5em; padding: 1.5em; background: #eff6ff; border-radius: 6px; border-left: 4px solid #2563eb;">
<h4 style="margin: 0 0 0.5em 0; color: #1e40af; font-size: 1em; font-weight: 600;">Risk Metrics:</h4>
<div id="analysis_text" style="color: #1e40af; font-size: 0.9em; line-height: 1.6;">
Calculating expected value and risk...
</div>
</div>
</div>
<script>
(function() {
function initCanvas() {
const canvas = document.getElementById('riskCanvas');
if (!canvas) return;
const ctx = canvas.getContext('2d');
if (!ctx) return;
const dpr = window.devicePixelRatio || 1;
const baseWidth = 700;
const baseHeight = 700;
canvas.width = baseWidth * dpr;
canvas.height = baseHeight * dpr;
ctx.scale(dpr, dpr);
canvas.style.width = baseWidth + 'px';
canvas.style.height = baseHeight + 'px';
}
function drawRiskVisualization(ctx, width, height, outcomes, probabilities) {
ctx.clearRect(0, 0, width, height);
// Normalize probabilities
const totalProb = probabilities.reduce((a, b) => a + b, 0);
const normalizedProbs = probabilities.map(p => p / totalProb);
// Calculate expected value and variance
const expectedReturn = outcomes.reduce((sum, outcome, i) => sum + outcome * normalizedProbs[i], 0);
const variance = outcomes.reduce((sum, outcome, i) => {
const deviation = outcome - expectedReturn;
return sum + normalizedProbs[i] * deviation * deviation;
}, 0);
const stdDev = Math.sqrt(variance);
// Draw probability distribution (bar chart)
const padding = 80;
const plotWidth = width - padding * 2;
const plotHeight = height - padding * 2;
const barWidth = plotWidth / outcomes.length * 0.6;
const maxProb = Math.max(...normalizedProbs);
// Draw bars
const colors = ['#059669', '#2563eb', '#dc2626'];
outcomes.forEach((outcome, i) => {
const barHeight = (normalizedProbs[i] / maxProb) * plotHeight * 0.4;
const x = padding + (i * plotWidth / outcomes.length) + (plotWidth / outcomes.length - barWidth) / 2;
const y = height - padding - barHeight;
ctx.fillStyle = colors[i];
ctx.fillRect(x, y, barWidth, barHeight);
ctx.strokeStyle = '#374151';
ctx.lineWidth = 2;
ctx.strokeRect(x, y, barWidth, barHeight);
// Labels
ctx.fillStyle = '#374151';
ctx.font = '11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
ctx.textAlign = 'center';
ctx.fillText(`${(normalizedProbs[i] * 100).toFixed(0)}%`, x + barWidth / 2, y - 5);
ctx.fillText(`${outcome}%`, x + barWidth / 2, height - padding + 20);
});
// Draw expected value line
const expectedX = padding + plotWidth / 2;
ctx.strokeStyle = '#dc2626';
ctx.lineWidth = 3;
ctx.setLineDash([10, 5]);
ctx.beginPath();
ctx.moveTo(expectedX, padding);
ctx.lineTo(expectedX, height - padding);
ctx.stroke();
ctx.setLineDash([]);
// Labels
ctx.fillStyle = '#374151';
ctx.font = '12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
ctx.textAlign = 'center';
ctx.fillText('Return (%)', width / 2, height - 10);
ctx.textAlign = 'right';
ctx.fillText('Probability', padding - 10, height / 2);
// Title
ctx.font = 'bold 16px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
ctx.textAlign = 'center';
ctx.fillText('Probability Distribution of Returns', width / 2, 30);
// Expected value label
ctx.fillStyle = '#dc2626';
ctx.font = 'bold 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
ctx.fillText(`Expected: ${expectedReturn.toFixed(1)}%`, expectedX, padding - 10);
// Update analysis
updateAnalysis(expectedReturn, variance, stdDev);
}
function updateAnalysis(expectedReturn, variance, stdDev) {
const analysisEl = document.getElementById('analysis_text');
if (!analysisEl) return;
let html = `Expected Return: <strong>${expectedReturn.toFixed(2)}%</strong><br>`;
html += `Variance: <strong>${variance.toFixed(2)}</strong><br>`;
html += `Standard Deviation: <strong>${stdDev.toFixed(2)}%</strong> = √${variance.toFixed(2)}<br><br>`;
html += `✅ Higher variance = Higher risk. Standard deviation measures the spread of possible returns around the expected value.`;
analysisEl.innerHTML = html;
}
window.updateRisk = function() {
const outcome1El = document.getElementById('outcome1');
const prob1El = document.getElementById('prob1');
const outcome2El = document.getElementById('outcome2');
const prob2El = document.getElementById('prob2');
const outcome3El = document.getElementById('outcome3');
const prob3El = document.getElementById('prob3');
if (!outcome1El || !prob1El || !outcome2El || !prob2El || !outcome3El || !prob3El) return;
const outcomes = [
parseFloat(outcome1El.value),
parseFloat(outcome2El.value),
parseFloat(outcome3El.value)
];
const probabilities = [
parseFloat(prob1El.value),
parseFloat(prob2El.value),
parseFloat(prob3El.value)
];
document.getElementById('outcome1_value').textContent = outcomes[0] + '%';
document.getElementById('prob1_value').textContent = probabilities[0] + '%';
document.getElementById('outcome2_value').textContent = outcomes[1] + '%';
document.getElementById('prob2_value').textContent = probabilities[1] + '%';
document.getElementById('outcome3_value').textContent = outcomes[2] + '%';
document.getElementById('prob3_value').textContent = probabilities[2] + '%';
const canvas = document.getElementById('riskCanvas');
if (!canvas) return;
const ctx = canvas.getContext('2d');
if (!ctx) return;
const dpr = window.devicePixelRatio || 1;
const width = canvas.width / dpr;
const height = canvas.height / dpr;
drawRiskVisualization(ctx, width, height, outcomes, probabilities);
};
function tryInit() {
const canvas = document.getElementById('riskCanvas');
const outcome1El = document.getElementById('outcome1');
if (canvas && outcome1El) {
initCanvas();
window.updateRisk();
['outcome1', 'prob1', 'outcome2', 'prob2', 'outcome3', 'prob3'].forEach(id => {
document.getElementById(id).addEventListener('input', window.updateRisk);
});
return true;
}
return false;
}
if (!tryInit()) {
setTimeout(() => {
if (!tryInit()) {
setTimeout(tryInit, 200);
}
}, 50);
}
})();
</script>
"""
import sys
sys.stdout.write(f"[HTML_CONTENT]{interactive_html}[/HTML_CONTENT]\n")
sys.stdout.flush()
The time value of money is perhaps the most fundamental concept in finance. It recognizes a simple but profound truth: a dollar today is worth more than a dollar tomorrow. This principle underlies virtually every financial decision - from personal savings to corporate investment to government policy. Understanding the time value of money is essential for understanding how financial markets work, how investments are valued, and how to make sound financial decisions.
Why Money Has Time Value
The time value of money exists for several fundamental reasons:
Opportunity Cost is the most basic reason. If you have a dollar today, you can invest it and earn a return. If you receive a dollar in the future, you've lost the opportunity to earn that return. The opportunity cost of waiting is the return you could have earned.
Inflation erodes purchasing power over time. A dollar today can buy more than a dollar in the future if prices are rising. To maintain purchasing power, money must grow over time at least at the rate of inflation.
Risk means that future payments are uncertain. A dollar today is certain, but a dollar promised in the future might not materialize. Investors require compensation for this uncertainty, which is reflected in higher required returns for riskier investments.
Liquidity Preference reflects the fact that people prefer to have money now rather than later. Having money now provides flexibility and options that having money later doesn't provide.
Consumption Preference recognizes that people generally prefer to consume now rather than later. To defer consumption, people require compensation in the form of interest or returns.
These factors combine to create the time value of money. The magnitude of the time value depends on the interest rate, the time period, and the risk involved. Understanding these relationships is crucial for all financial decisions.
The Basic Time Value Relationship
The fundamental relationship in time value of money is:
Future Value:
This simple formula shows how money grows over time. If you invest today at 5% interest for one year, you'll have in one year and the interest rate is 5%.
The present value is
Analysis: Option B gives slightly more ($76,123 vs $74,872), but Option A requires only half the initial investment. However, the real lesson is that starting early is powerful - Option A's $5,000 grows to almost as much as Option B's $10,000 because of the extra 10 years of compounding.
Python exercise
#| label: practice-1-1
#| fig-cap: "Practice Problem 1.1: Retirement Savings Comparison"
#| 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
pv_a = 5000
pv_b = 10000
rate = 0.07
years_a = 40
years_b = 30
fv_a = pv_a * ((1 + rate) ** years_a)
fv_b = pv_b * ((1 + rate) ** years_b)
# Growth over time
years = np.arange(0, 41, 1)
growth_a = pv_a * ((1 + rate) ** years)
growth_b = np.zeros_like(years)
growth_b[years >= 10] = pv_b * ((1 + rate) ** (years[years >= 10] - 10))
fig, axes = plt.subplots(1, 2, figsize=(16, 6))
fig.suptitle('Practice Problem 1.1: Retirement Savings Decision', fontsize=14, fontweight='bold')
# Plot 1: Growth Comparison
ax1 = axes[0]
ax1.plot(years, growth_a, 'b-', linewidth=3, marker='o', markersize=4, label='Option A: $5K at 25', alpha=0.8)
ax1.plot(years, growth_b, 'r--', linewidth=3, marker='s', markersize=4, label='Option B: $10K at 35', alpha=0.8)
ax1.axvline(x=10, color='gray', linestyle=':', linewidth=1.5, alpha=0.5)
ax1.plot(40, fv_a, 'go', markersize=12, markeredgewidth=2, markeredgecolor='darkgreen', zorder=5)
ax1.plot(40, fv_b, 'ro', markersize=12, markeredgewidth=2, markeredgecolor='darkred', zorder=5)
ax1.set_xlabel('Years', fontsize=11, fontweight='bold')
ax1.set_ylabel('Future Value ($)', fontsize=11, fontweight='bold')
ax1.set_title('Growth Over Time', fontsize=12, fontweight='bold')
ax1.grid(True, alpha=0.3, linestyle='--')
ax1.legend(loc='upper left', fontsize=9)
ax1.annotate(f'Option A: ${fv_a:,.0f}', xy=(40, fv_a), xytext=(42, fv_a + 5000),
arrowprops=dict(arrowstyle='->', color='blue', lw=1.5), fontsize=9, fontweight='bold')
ax1.annotate(f'Option B: ${fv_b:,.0f}', xy=(40, fv_b), xytext=(42, fv_b - 5000),
arrowprops=dict(arrowstyle='->', color='red', lw=1.5), fontsize=9, fontweight='bold')
# Plot 2: Comparison Bar Chart
ax2 = axes[1]
categories = ['Initial\nInvestment', 'Final Value\n(at 65)']
option_a_values = [pv_a, fv_a]
option_b_values = [pv_b, fv_b]
x = np.arange(len(categories))
width = 0.35
bars1 = ax2.bar(x - width/2, option_a_values, width, label='Option A', color='blue', alpha=0.7, edgecolor='black')
bars2 = ax2.bar(x + width/2, option_b_values, width, label='Option B', color='red', alpha=0.7, edgecolor='black')
ax2.set_ylabel('Amount ($)', fontsize=11, fontweight='bold')
ax2.set_title('Comparison: Investment vs Final Value', fontsize=12, fontweight='bold')
ax2.set_xticks(x)
ax2.set_xticklabels(categories)
ax2.legend(loc='upper left', fontsize=9)
ax2.grid(True, alpha=0.3, linestyle='--', axis='y')
for bars in [bars1, bars2]:
for bar in bars:
height = bar.get_height()
ax2.text(bar.get_x() + bar.get_width()/2., height + height*0.01,
f'${height:,.0f}', ha='center', va='bottom', fontsize=9, fontweight='bold')
plt.tight_layout()
display(fig)
plt.close(fig)Real-World Context: This demonstrates why financial advisors emphasize starting retirement savings early. The time value of money means that even smaller amounts invested early can grow to significant sums due to compounding over long periods.
Practice Problem 1.2: Comparing Investment Offers
A technology startup offers you two compensation packages:
- Package A: $100,000 salary today
- Package B: $50,000 salary today plus a $60,000 bonus in 3 years
If you can invest at 5% annual return, which package is worth more in present value terms?
Solution:
Package A: $100,000 today
- PV = $100,000 (already in present value)
Package B: $50,000 today + $60,000 in 3 years
- PV of $50,000 today = $50,000
- PV of $60,000 in 3 years:
Analysis: Package B is worth more in present value ($101,833 vs $100,000), making it the better financial choice if you can wait for the bonus. However, Package A provides more immediate liquidity, which may be valuable if you have immediate needs.