How to Calculate Weighted Average Cost of Capital (WACC)
:root {
–primary-color: #004a99;
–success-color: #28a745;
–background-color: #f8f9fa;
–text-color: #333;
–secondary-text-color: #6c757d;
–border-color: #dee2e6;
–card-background: #ffffff;
–shadow: 0 4px 8px rgba(0,0,0,0.05);
–border-radius: 8px;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
line-height: 1.6;
color: var(–text-color);
background-color: var(–background-color);
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
}
.container {
width: 100%;
max-width: 1000px;
margin: 20px auto;
padding: 20px;
background-color: var(–card-background);
border-radius: var(–border-radius);
box-shadow: var(–shadow);
}
header {
background-color: var(–primary-color);
color: white;
padding: 20px 0;
text-align: center;
width: 100%;
margin-bottom: 20px;
}
header h1 {
margin: 0;
font-size: 2.5em;
font-weight: 600;
}
main {
width: 100%;
}
h2, h3 {
color: var(–primary-color);
margin-top: 1.5em;
margin-bottom: 0.8em;
}
h2 {
font-size: 2em;
border-bottom: 2px solid var(–border-color);
padding-bottom: 0.3em;
}
h3 {
font-size: 1.5em;
}
p {
margin-bottom: 1em;
}
a {
color: var(–primary-color);
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.loan-calc-container {
background-color: var(–card-background);
padding: 30px;
border-radius: var(–border-radius);
box-shadow: var(–shadow);
margin-bottom: 30px;
}
.calc-header {
text-align: center;
margin-bottom: 25px;
color: var(–primary-color);
}
.calc-header h3 {
margin-bottom: 10px;
font-size: 1.8em;
}
.calc-header p {
color: var(–secondary-text-color);
font-size: 0.95em;
}
.input-group {
margin-bottom: 20px;
padding: 15px;
border: 1px solid var(–border-color);
border-radius: var(–border-radius);
background-color: #fdfdfd;
}
.input-group label {
display: block;
margin-bottom: 8px;
font-weight: 600;
color: var(–primary-color);
}
.input-group input[type="number"],
.input-group select {
width: calc(100% – 24px);
padding: 12px 15px;
margin-bottom: 5px;
border: 1px solid var(–border-color);
border-radius: var(–border-radius);
font-size: 1em;
box-sizing: border-box;
}
.input-group .helper-text {
font-size: 0.85em;
color: var(–secondary-text-color);
display: block;
margin-top: 5px;
}
.error-message {
color: red;
font-size: 0.85em;
margin-top: 5px;
display: none; /* Hidden by default */
}
.error-message.visible {
display: block;
}
.button-group {
display: flex;
justify-content: space-between;
margin-top: 25px;
gap: 10px;
}
button {
padding: 12px 25px;
border: none;
border-radius: var(–border-radius);
cursor: pointer;
font-size: 1em;
font-weight: 600;
transition: background-color 0.3s ease;
}
.btn-calculate {
background-color: var(–primary-color);
color: white;
flex-grow: 1;
}
.btn-calculate:hover {
background-color: #003366;
}
.btn-reset {
background-color: var(–secondary-text-color);
color: white;
}
.btn-reset:hover {
background-color: #5a6268;
}
.btn-copy {
background-color: var(–success-color);
color: white;
}
.btn-copy:hover {
background-color: #218838;
}
.results-container {
margin-top: 30px;
padding: 25px;
border: 1px solid var(–border-color);
border-radius: var(–border-radius);
background-color: var(–card-background);
box-shadow: var(–shadow);
}
.results-container h3 {
text-align: center;
margin-bottom: 20px;
color: var(–primary-color);
}
.primary-result {
background-color: var(–success-color);
color: white;
padding: 20px;
text-align: center;
border-radius: var(–border-radius);
margin-bottom: 20px;
}
.primary-result .label {
font-size: 1.2em;
font-weight: bold;
display: block;
margin-bottom: 10px;
}
.primary-result .value {
font-size: 2.5em;
font-weight: bold;
}
.intermediate-results,
.formula-explanation {
margin-top: 20px;
font-size: 0.95em;
color: var(–secondary-text-color);
}
.intermediate-results ul {
list-style: none;
padding: 0;
}
.intermediate-results li {
display: flex;
justify-content: space-between;
padding: 8px 0;
border-bottom: 1px dotted var(–border-color);
}
.intermediate-results li:last-child {
border-bottom: none;
}
.intermediate-results .label {
font-weight: 600;
color: var(–text-color);
}
.intermediate-results .value {
color: var(–primary-color);
font-weight: bold;
}
.formula-explanation {
text-align: center;
margin-top: 20px;
padding: 15px;
background-color: #e9ecef;
border-radius: var(–border-radius);
}
.formula-explanation p {
margin-bottom: 0;
}
table {
width: 100%;
margin-top: 20px;
border-collapse: collapse;
box-shadow: var(–shadow);
border-radius: var(–border-radius);
overflow: hidden; /* Needed for rounded corners with border-collapse */
}
th, td {
padding: 12px 15px;
text-align: left;
border: 1px solid var(–border-color);
}
thead th {
background-color: var(–primary-color);
color: white;
font-weight: 600;
}
tbody tr:nth-child(even) {
background-color: #f2f2f2;
}
tbody td {
color: var(–text-color);
}
caption {
font-size: 1.1em;
font-weight: bold;
color: var(–primary-color);
margin-bottom: 15px;
text-align: left;
}
canvas {
margin-top: 20px;
background-color: white;
border-radius: var(–border-radius);
box-shadow: var(–shadow);
}
.section {
margin-bottom: 40px;
}
.section-title {
font-size: 2.2em;
color: var(–primary-color);
border-bottom: 3px solid var(–primary-color);
padding-bottom: 0.5em;
margin-bottom: 1em;
text-align: center;
}
.faq-list {
list-style: none;
padding: 0;
}
.faq-item {
margin-bottom: 20px;
padding: 15px;
border: 1px solid var(–border-color);
border-radius: var(–border-radius);
background-color: var(–card-background);
box-shadow: var(–shadow);
}
.faq-item .question {
font-weight: bold;
color: var(–primary-color);
margin-bottom: 10px;
cursor: pointer;
display: flex;
justify-content: space-between;
align-items: center;
}
.faq-item .question::after {
content: '+';
font-size: 1.5em;
transition: transform 0.3s ease;
}
.faq-item.open .question::after {
content: '-';
transform: rotate(0deg);
}
.faq-item .answer {
max-height: 0;
overflow: hidden;
transition: max-height 0.3s ease-out;
padding-left: 10px;
border-left: 2px solid var(–primary-color);
margin-top: 10px;
color: var(–secondary-text-color);
}
.faq-item.open .answer {
max-height: 200px; /* Adjust as needed */
}
.related-tools {
margin-top: 30px;
padding: 25px;
background-color: var(–card-background);
border-radius: var(–border-radius);
box-shadow: var(–shadow);
}
.related-tools h3 {
margin-bottom: 20px;
color: var(–primary-color);
text-align: center;
}
.related-tools ul {
list-style: none;
padding: 0;
}
.related-tools li {
margin-bottom: 15px;
padding-bottom: 15px;
border-bottom: 1px solid var(–border-color);
}
.related-tools li:last-child {
border-bottom: none;
padding-bottom: 0;
}
.related-tools a {
font-weight: bold;
font-size: 1.1em;
display: block;
margin-bottom: 5px;
}
.related-tools p {
font-size: 0.9em;
color: var(–secondary-text-color);
margin-bottom: 0;
}
How to Calculate Weighted Average Cost of Capital (WACC)
Weighted Average Cost of Capital (WACC)
–.–%
WACC Components Contribution
What is the Weighted Average Cost of Capital (WACC)?
The Weighted Average Cost of Capital (WACC) is a critical metric in corporate finance that represents a company's blended cost of capital across all sources, including common stock, preferred stock, bonds, and other forms of debt. It is calculated by taking the weighted average of the cost of each capital component. The WACC signifies the minimum rate of return a company must earn on its existing asset base to satisfy its creditors, owners, and other capital providers. Essentially, it's the company's overall hurdle rate; any project or investment yielding a return lower than the WACC is likely to destroy shareholder value.
Who Should Use WACC:
- Corporate Financial Analysts: To evaluate potential investments, mergers, acquisitions, and capital budgeting decisions. A positive net present value (NPV) using WACC as the discount rate indicates a value-creating project.
- Investors: To assess the risk profile of a company and understand its operational efficiency and cost structure. A lower WACC generally suggests a less risky company with a more efficient capital structure.
- Management Teams: To set performance targets and strategic financial goals. WACC helps align investment strategies with the cost of financing.
Common Misconceptions:
- WACC is static: WACC is not a fixed number; it fluctuates with market interest rates, company-specific risk, and changes in capital structure.
- WACC is the lowest cost of capital: While it's an average, specific components like debt can be cheaper than equity. WACC reflects the combined cost.
- WACC is only for large corporations: Businesses of all sizes that use external financing can benefit from understanding their WACC to make informed financial decisions.
Weighted Average Cost of Capital (WACC) Formula and Mathematical Explanation
The formula for calculating the Weighted Average Cost of Capital (WACC) is as follows:
WACC = (E/V * Ke) + (D/V * Kd * (1 – T))
Let's break down each component:
- E: Market Value of Equity (market capitalization).
- D: Market Value of Debt.
- V: Total Market Value of the Company's Financing (E + D).
- Ke: Cost of Equity. This is the return shareholders require for their investment. It's often calculated using models like the Capital Asset Pricing Model (CAPM).
- Kd: Cost of Debt. This is the effective interest rate a company pays on its debt. It's typically represented by the yield to maturity on outstanding long-term debt.
- T: Corporate Tax Rate. The company's statutory or effective tax rate. This is crucial because interest payments on debt are usually tax-deductible, creating a "tax shield" that lowers the effective cost of debt.
- E/V: Weight of Equity. The proportion of the company's total financing that comes from equity.
- D/V: Weight of Debt. The proportion of the company's total financing that comes from debt.
The formula essentially sums the cost of each financing component, weighted by its proportion in the company's capital structure, and adjusts the cost of debt for its tax deductibility. This calculation provides a single, unified measure of the cost of capital for the entire firm.
Variables Table:
| Variable |
Meaning |
Unit |
Typical Range |
| E | Market Value of Equity | $ | Millions to Billions |
| D | Market Value of Debt | $ | Thousands to Billions |
| V | Total Market Value (E+D) | $ | Millions to Billions |
| Ke | Cost of Equity | % | 8% – 20% |
| Kd | Cost of Debt | % | 3% – 10% |
| T | Corporate Tax Rate | % | 15% – 35% |
| E/V | Weight of Equity | Proportion | 0 – 1 (or 0% – 100%) |
| D/V | Weight of Debt | Proportion | 0 – 1 (or 0% – 100%) |
| WACC | Weighted Average Cost of Capital | % | 5% – 15% |
Practical Examples (Real-World Use Cases)
Example 1: Technology Startup's Expansion
A growing tech company, 'Innovate Solutions', is considering a major expansion requiring significant capital. They need to determine if the expected returns justify the investment.
- Market Value of Equity (E): $150,000,000
- Market Value of Debt (D): $50,000,000
- Total Value (V): $200,000,000
- Cost of Equity (Ke): 15%
- Cost of Debt (Kd): 6%
- Corporate Tax Rate (T): 28%
Calculation:
- Weight of Equity (E/V): $150M / $200M = 0.75 or 75%
- Weight of Debt (D/V): $50M / $200M = 0.25 or 25%
- After-Tax Cost of Debt: 6% * (1 – 0.28) = 4.32%
- WACC = (0.75 * 15%) + (0.25 * 4.32%) = 11.25% + 1.08% = 12.33%
Interpretation: Innovate Solutions needs to achieve an annual return of at least 12.33% on its expansion project to create value for its shareholders. If the project is expected to yield less, they should reconsider.
Example 2: Manufacturing Company's Refinancing
A stable manufacturing firm, 'Durable Goods Inc.', is refinancing its debt and wants to understand its overall cost of capital.
- Market Value of Equity (E): $500,000,000
- Market Value of Debt (D): $250,000,000
- Total Value (V): $750,000,000
- Cost of Equity (Ke): 10%
- Cost of Debt (Kd): 4.5% (new rate after refinancing)
- Corporate Tax Rate (T): 21%
Calculation:
- Weight of Equity (E/V): $500M / $750M = 0.667 or 66.7%
- Weight of Debt (D/V): $250M / $750M = 0.333 or 33.3%
- After-Tax Cost of Debt: 4.5% * (1 – 0.21) = 3.555%
- WACC = (0.667 * 10%) + (0.333 * 3.555%) = 6.67% + 1.18% = 7.85%
Interpretation: Durable Goods Inc.'s WACC is 7.85%. This means their average cost of financing is 7.85%. They should only pursue projects with expected returns exceeding this rate. The refinancing at a lower interest rate has successfully reduced their overall WACC.
How to Use This WACC Calculator
Our WACC calculator simplifies the process of determining your company's cost of capital. Follow these steps:
- Input Cost of Equity: Enter the percentage return required by your equity investors. If you're unsure, you can estimate it using the CAPM formula: Ke = Rf + Beta * (Rm – Rf), where Rf is the risk-free rate, Beta is the stock's volatility relative to the market, and (Rm – Rf) is the market risk premium.
- Input Cost of Debt: Enter the current average interest rate your company pays on its borrowings, expressed as a percentage.
- Input Corporate Tax Rate: Provide your company's effective or statutory tax rate as a percentage. This is used to calculate the tax shield benefit of debt.
- Input Market Value of Equity: Enter the total current market value of your company's outstanding shares (Market Cap = Share Price * Number of Shares Outstanding).
- Input Market Value of Debt: Enter the total market value of all your company's debt. For publicly traded bonds, this is their current market price. For non-traded debt, book value is often used as a proxy if market value is unavailable.
- Click 'Calculate WACC': The calculator will instantly display your company's WACC, along with the calculated weights of equity and debt, and the after-tax cost of debt.
- Interpret Results: The primary WACC figure tells you the minimum return your investments need to generate. The intermediate values show the composition of your capital structure and the effective cost of debt.
- Use Decision Guidance: Compare the calculated WACC to the expected returns of potential projects. If expected return > WACC, the project is likely to add value. If expected return < WACC, it may destroy value.
- Reset or Copy: Use the 'Reset' button to clear fields and start over, or 'Copy Results' to save the calculated figures.
Key Factors That Affect WACC Results
Several dynamic factors influence a company's Weighted Average Cost of Capital:
- Market Interest Rates: Increases in general market interest rates (e.g., central bank policy changes) tend to raise the cost of debt (Kd) and often the cost of equity (Ke) as well, thus increasing WACC.
- Company-Specific Risk (Beta): A higher Beta (indicating greater stock volatility relative to the market) increases the cost of equity (Ke), leading to a higher WACC. Conversely, lower operational or financial risk reduces Ke and WACC.
- Capital Structure Mix: The proportion of debt versus equity significantly impacts WACC. While debt is typically cheaper than equity and offers a tax advantage, excessive debt increases financial risk (higher Kd and potentially higher Ke due to increased equity risk), which can eventually raise WACC. Understanding the optimal capital structure is key.
- Corporate Tax Rate: A higher tax rate enhances the tax shield benefit of debt (Kd * (1 – T)), making debt relatively cheaper and potentially lowering WACC, assuming other factors remain constant. Changes in tax policy directly affect WACC.
- Inflation Expectations: Higher expected inflation generally leads central banks to raise interest rates, increasing Kd. It also increases the required return for equity investors (Ke) to compensate for the erosion of purchasing power, thus raising WACC.
- Investor Sentiment and Market Conditions: During periods of high market uncertainty or risk aversion, investors demand higher returns for both debt and equity, increasing Kd and Ke and consequently, WACC. Economic growth prospects also influence Ke.
- Company Performance and Profitability: Strong, consistent financial performance can reduce perceived risk, potentially lowering both Kd and Ke. A company with a solid track record might access cheaper debt and require less return from equity investors.
Frequently Asked Questions (FAQ)
-
What is the difference between the cost of debt and the interest rate?
The interest rate is the stated cost of borrowing. The cost of debt (Kd) used in WACC is the *effective* interest rate, often represented by the yield to maturity on outstanding bonds. It reflects the market's required return on the company's debt, considering its risk profile.
-
How is the Cost of Equity (Ke) typically calculated?
The most common method is the Capital Asset Pricing Model (CAPM): Ke = Rf + Beta * (Rm – Rf). Other methods include the Dividend Discount Model (DDM). Ke represents the return shareholders expect given the risk of investing in the company.
-
Should I use book value or market value for debt and equity?
The WACC formula requires *market values* for both debt and equity. Market value reflects the current economic value and investor expectations. Book values can be outdated and may not accurately represent the current cost of capital. If market value for debt is unavailable, book value is often used as a practical approximation.
-
What does a WACC of 10% mean for a company?
A WACC of 10% means the company must earn an average annual return of at least 10% on its investments to satisfy all its capital providers (debt holders and equity holders). Projects expected to yield more than 10% are considered value-adding.
-
Can WACC be negative?
Typically, no. Costs of equity and debt are generally positive. While a negative tax rate is theoretically possible (e.g., government subsidies), it's highly uncommon. Therefore, WACC is almost always a positive figure.
-
How often should WACC be recalculated?
WACC should be recalculated whenever there are significant changes in the company's capital structure, market interest rates, risk profile (Beta), or corporate tax rates. Annually is a common practice for stable companies, but more frequently if major events occur.
-
What is the role of preferred stock in WACC?
If a company has preferred stock, the WACC formula is expanded to include it: WACC = (E/V * Ke) + (D/V * Kd * (1 – T)) + (P/V * Kp), where P is the market value of preferred stock and Kp is its cost.
-
Is WACC the best metric for all investment decisions?
WACC is a powerful tool for evaluating projects that have a similar risk profile to the company's existing operations. For projects with significantly different risk levels, using a risk-adjusted discount rate derived from comparable companies is more appropriate than using the firm's overall WACC.
var costOfEquityInput = document.getElementById('costOfEquity');
var costOfDebtInput = document.getElementById('costOfDebt');
var taxRateInput = document.getElementById('taxRate');
var marketValueEquityInput = document.getElementById('marketValueEquity');
var marketValueDebtInput = document.getElementById('marketValueDebt');
var costOfEquityError = document.getElementById('costOfEquityError');
var costOfDebtError = document.getElementById('costOfDebtError');
var taxRateError = document.getElementById('taxRateError');
var marketValueEquityError = document.getElementById('marketValueEquityError');
var marketValueDebtError = document.getElementById('marketValueDebtError');
var waccResult = document.getElementById('waccResult');
var weightOfEquityResult = document.getElementById('weightOfEquityResult');
var weightOfDebtResult = document.getElementById('weightOfDebtResult');
var afterTaxCostOfDebtResult = document.getElementById('afterTaxCostOfDebtResult');
var tableCostOfEquity = document.getElementById('tableCostOfEquity');
var tableCostOfDebt = document.getElementById('tableCostOfDebt');
var tableTaxRate = document.getElementById('tableTaxRate');
var tableMarketValueEquity = document.getElementById('tableMarketValueEquity');
var tableMarketValueDebt = document.getElementById('tableMarketValueDebt');
var ctx = document.getElementById('waccChart').getContext('2d');
var waccChart; // Declare chart variable globally
// Initialize chart with placeholder data
function initializeChart() {
waccChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ['Equity Cost Contribution', 'Debt Cost Contribution'],
datasets: [{
label: 'Contribution to WACC (%)',
data: [0, 0],
backgroundColor: [
'rgba(0, 74, 153, 0.7)', // Primary Color for Equity
'rgba(40, 167, 69, 0.7)' // Success Color for Debt
],
borderColor: [
'rgba(0, 74, 153, 1)',
'rgba(40, 167, 69, 1)'
],
borderWidth: 1
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true,
ticks: {
callback: function(value) {
return value.toFixed(2) + '%';
}
}
}
},
plugins: {
tooltip: {
callbacks: {
label: function(context) {
var label = context.dataset.label || ";
if (label) {
label += ': ';
}
if (context.parsed.y !== null) {
label += context.parsed.y.toFixed(2) + '%';
}
return label;
}
}
}
}
}
});
}
// Function to update the chart
function updateChart(equityContribution, debtContribution) {
if (!waccChart) {
initializeChart();
}
waccChart.data.datasets[0].data = [equityContribution, debtContribution];
waccChart.update();
}
function formatCurrency(value) {
return value.toLocaleString('en-US', { style: 'currency', currency: 'USD', minimumFractionDigits: 0, maximumFractionDigits: 0 });
}
function formatPercent(value, decimals = 2) {
return value.toFixed(decimals) + '%';
}
function validateInput(input, errorElement, min = null, max = null) {
var value = parseFloat(input.value);
var isValid = true;
var errorMessage = ";
if (isNaN(value)) {
errorMessage = 'Please enter a valid number.';
isValid = false;
} else if (input.id !== 'marketValueEquity' && input.id !== 'marketValueDebt' && value < 0) {
errorMessage = 'Value cannot be negative.';
isValid = false;
} else if (input.id === 'marketValueEquity' || input.id === 'marketValueDebt') {
if (value <= 0) {
errorMessage = 'Market value must be positive.';
isValid = false;
}
} else if (min !== null && value max) {
errorMessage = 'Value cannot exceed ' + max + '%';
isValid = false;
}
if (isValid) {
errorElement.classList.remove('visible');
input.style.borderColor = 'var(–border-color)';
} else {
errorElement.innerText = errorMessage;
errorElement.classList.add('visible');
input.style.borderColor = 'red';
}
return isValid;
}
function calculateWACC() {
var isValid = true;
isValid &= validateInput(costOfEquityInput, costOfEquityError, 0, 100);
isValid &= validateInput(costOfDebtInput, costOfDebtError, 0, 100);
isValid &= validateInput(taxRateInput, taxRateError, 0, 100);
isValid &= validateInput(marketValueEquityInput, marketValueEquityError, 1); // Must be positive
isValid &= validateInput(marketValueDebtInput, marketValueDebtError, 1); // Must be positive
if (!isValid) {
waccResult.innerText = '–.–%';
weightOfEquityResult.innerText = '–.–%';
weightOfDebtResult.innerText = '–.–%';
afterTaxCostOfDebtResult.innerText = '–.–%';
updateChart(0, 0); // Reset chart
return;
}
var costOfEquity = parseFloat(costOfEquityInput.value) / 100;
var costOfDebt = parseFloat(costOfDebtInput.value) / 100;
var taxRate = parseFloat(taxRateInput.value) / 100;
var marketValueEquity = parseFloat(marketValueEquityInput.value);
var marketValueDebt = parseFloat(marketValueDebtInput.value);
var totalValue = marketValueEquity + marketValueDebt;
var weightOfEquity = marketValueEquity / totalValue;
var weightOfDebt = marketValueDebt / totalValue;
var afterTaxCostOfDebt = costOfDebt * (1 – taxRate);
var wacc = (weightOfEquity * costOfEquity) + (weightOfDebt * afterTaxCostOfDebt);
// Update results display
waccResult.innerText = formatPercent(wacc * 100);
weightOfEquityResult.innerText = formatPercent(weightOfEquity * 100);
weightOfDebtResult.innerText = formatPercent(weightOfDebt * 100);
afterTaxCostOfDebtResult.innerText = formatPercent(afterTaxCostOfDebt * 100);
// Update table
tableCostOfEquity.innerText = formatPercent(costOfEquity * 100, 2);
tableCostOfDebt.innerText = formatPercent(costOfDebt * 100, 2);
tableTaxRate.innerText = formatPercent(taxRate * 100, 2);
tableMarketValueEquity.innerText = formatCurrency(marketValueEquity);
tableMarketValueDebt.innerText = formatCurrency(marketValueDebt);
// Update chart
var equityContribution = weightOfEquity * costOfEquity * 100;
var debtContribution = weightOfDebt * afterTaxCostOfDebt * 100;
updateChart(equityContribution, debtContribution);
}
function resetCalculator() {
costOfEquityInput.value = '12.0';
costOfDebtInput.value = '5.0';
taxRateInput.value = '25.0';
marketValueEquityInput.value = '100000000';
marketValueDebtInput.value = '50000000';
// Clear error messages and styles
costOfEquityError.classList.remove('visible');
costOfDebtError.classList.remove('visible');
taxRateError.classList.remove('visible');
marketValueEquityError.classList.remove('visible');
marketValueDebtError.classList.remove('visible');
costOfEquityInput.style.borderColor = 'var(–border-color)';
costOfDebtInput.style.borderColor = 'var(–border-color)';
taxRateInput.style.borderColor = 'var(–border-color)';
marketValueEquityInput.style.borderColor = 'var(–border-color)';
marketValueDebtInput.style.borderColor = 'var(–border-color)';
calculateWACC(); // Recalculate with reset values
}
function copyResults() {
var resultsText = "WACC Calculation Results:\n\n";
resultsText += "Weighted Average Cost of Capital (WACC): " + waccResult.innerText + "\n";
resultsText += "Weight of Equity (We): " + weightOfEquityResult.innerText + "\n";
resultsText += "Weight of Debt (Wd): " + weightOfDebtResult.innerText + "\n";
resultsText += "After-Tax Cost of Debt: " + afterTaxCostOfDebtResult.innerText + "\n\n";
resultsText += "Key Assumptions:\n";
resultsText += "Cost of Equity: " + formatPercent(parseFloat(costOfEquityInput.value)) + "\n";
resultsText += "Cost of Debt: " + formatPercent(parseFloat(costOfDebtInput.value)) + "\n";
resultsText += "Tax Rate: " + formatPercent(parseFloat(taxRateInput.value)) + "\n";
resultsText += "Market Value of Equity: " + formatCurrency(parseFloat(marketValueEquityInput.value)) + "\n";
resultsText += "Market Value of Debt: " + formatCurrency(parseFloat(marketValueDebtInput.value)) + "\n";
// Use a temporary textarea for copying
var textArea = document.createElement("textarea");
textArea.value = resultsText;
textArea.style.position = "fixed";
textArea.style.left = "-9999px";
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
document.execCommand('copy');
alert('Results copied to clipboard!');
} catch (err) {
console.error('Failed to copy: ', err);
alert('Failed to copy results. Please copy manually.');
}
document.body.removeChild(textArea);
}
// Add event listeners for real-time updates
costOfEquityInput.addEventListener('input', calculateWACC);
costOfDebtInput.addEventListener('input', calculateWACC);
taxRateInput.addEventListener('input', calculateWACC);
marketValueEquityInput.addEventListener('input', calculateWACC);
marketValueDebtInput.addEventListener('input', calculateWACC);
// Initial calculation on page load
calculateWACC();
initializeChart(); // Initialize chart on load
// FAQ Accordion Functionality
var faqItems = document.querySelectorAll('.faq-item .question');
faqItems.forEach(function(item) {
item.addEventListener('click', function() {
var faqItem = this.parentNode;
faqItem.classList.toggle('open');
});
});