Calculations for Weighted Average Cost of Capital

Weighted Average Cost of Capital (WACC) Calculator & Guide :root { –primary-color: #004a99; –success-color: #28a745; –background-color: #f8f9fa; –text-color: #333; –border-color: #ddd; –shadow-color: rgba(0, 0, 0, 0.1); –card-background: #fff; } body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: var(–background-color); color: var(–text-color); line-height: 1.6; margin: 0; padding: 0; } .container { max-width: 960px; margin: 20px auto; padding: 20px; background-color: var(–card-background); border-radius: 8px; box-shadow: 0 4px 12px var(–shadow-color); display: flex; flex-direction: column; align-items: center; } h1, h2, h3 { color: var(–primary-color); text-align: center; } .loan-calc-container { width: 100%; max-width: 600px; margin-top: 20px; padding: 25px; border: 1px solid var(–border-color); border-radius: 8px; background-color: var(–card-background); box-shadow: 0 2px 8px var(–shadow-color); } .input-group { margin-bottom: 20px; width: 100%; } .input-group label { display: block; margin-bottom: 8px; font-weight: bold; color: var(–primary-color); } .input-group input[type="number"], .input-group select { width: calc(100% – 22px); padding: 10px; border: 1px solid var(–border-color); border-radius: 4px; font-size: 1rem; margin-top: 4px; box-sizing: border-box; } .input-group .helper-text { font-size: 0.85em; color: #666; margin-top: 8px; display: block; } .input-group .error-message { color: #dc3545; font-size: 0.8em; margin-top: 5px; display: block; min-height: 1.2em; /* Prevent layout shift */ } button { background-color: var(–primary-color); color: white; border: none; padding: 12px 25px; border-radius: 5px; cursor: pointer; font-size: 1rem; margin-right: 10px; transition: background-color 0.3s ease; margin-top: 10px; } button:hover { background-color: #003366; } button.reset-button { background-color: #6c757d; } button.reset-button:hover { background-color: #5a6268; } button.copy-button { background-color: var(–success-color); } button.copy-button:hover { background-color: #218838; } #results { margin-top: 30px; padding: 25px; border: 1px solid var(–border-color); border-radius: 8px; background-color: var(–card-background); box-shadow: 0 2px 8px var(–shadow-color); width: 100%; box-sizing: border-box; text-align: center; } #results h3 { margin-top: 0; } #waccResult { font-size: 2.5em; font-weight: bold; color: var(–success-color); margin: 15px 0; padding: 15px; background-color: #e9ecef; border-radius: 5px; display: inline-block; } .result-item { margin-bottom: 15px; padding: 10px; border-bottom: 1px dashed var(–border-color); } .result-item:last-child { border-bottom: none; } .result-label { font-weight: bold; color: var(–primary-color); } .result-value { font-weight: bold; color: var(–text-color); } .formula-explanation { font-size: 0.9em; color: #555; margin-top: 20px; text-align: left; background-color: #e9ecef; padding: 15px; border-radius: 5px; border-left: 5px solid var(–primary-color); } table { width: 100%; border-collapse: collapse; margin-top: 25px; box-shadow: 0 2px 8px var(–shadow-color); } th, td { padding: 12px 15px; text-align: left; border-bottom: 1px solid var(–border-color); } thead { background-color: var(–primary-color); color: white; } th { font-weight: bold; } tbody tr:nth-child(even) { background-color: #f2f2f2; } caption { font-size: 1.1em; font-weight: bold; color: var(–primary-color); margin-bottom: 10px; text-align: left; } canvas { margin-top: 25px; border: 1px solid var(–border-color); border-radius: 4px; background-color: var(–card-background); box-shadow: 0 2px 8px var(–shadow-color); } .chart-container { width: 100%; display: flex; flex-direction: column; align-items: center; } .chart-legend { margin-top: 15px; font-size: 0.9em; color: #555; } .chart-legend span { margin: 0 10px; display: inline-block; } .chart-legend span::before { content: "; display: inline-block; width: 10px; height: 10px; margin-right: 5px; border-radius: 2px; } .chart-legend .equity-legend::before { background-color: #4CAF50; /* Green for Equity */ } .chart-legend .debt-legend::before { background-color: #f44336; /* Red for Debt */ } .chart-legend .preferred-legend::before { background-color: #ff9800; /* Orange for Preferred */ } .article-section { margin-top: 40px; padding: 20px; border-top: 1px solid var(–border-color); } .article-section h2, .article-section h3 { text-align: left; margin-bottom: 15px; } .article-section p { margin-bottom: 15px; } .article-section ul, .article-section ol { margin-left: 20px; margin-bottom: 15px; } .article-section li { margin-bottom: 8px; } .article-section table { margin-top: 15px; box-shadow: none; /* Reset shadow for article tables */ } .article-section table th, .article-section table td { padding: 8px 10px; border: 1px solid var(–border-color); } .article-section table thead { background-color: #e9ecef; color: var(–text-color); } .article-section table th { font-weight: bold; color: var(–text-color); } .internal-links ul { list-style: none; padding: 0; } .internal-links li { margin-bottom: 15px; } .internal-links a { color: var(–primary-color); text-decoration: none; font-weight: bold; } .internal-links a:hover { text-decoration: underline; } .internal-links p { font-size: 0.9em; color: #555; margin-top: 5px; } .highlight-result { background-color: var(–success-color); color: white; padding: 10px 15px; border-radius: 5px; display: inline-block; font-size: 1.2em; font-weight: bold; margin-top: 10px; } .no-results { color: #6c757d; font-style: italic; } .results-summary { margin-top: 15px; font-size: 0.95em; color: #555; text-align: left; }

Weighted Average Cost of Capital (WACC) Calculator

Easily calculate your company's Weighted Average Cost of Capital (WACC) with our intuitive calculator. Understand the cost of funding your business and make informed financial decisions.

Calculate Your WACC

The required rate of return for equity investors. Typically derived from CAPM.
The proportion of equity in your company's capital structure.
The after-tax cost of borrowing. (Pre-tax cost * (1 – Tax Rate)).
The proportion of debt in your company's capital structure.
The required rate of return for preferred stock investors.
The proportion of preferred stock in your company's capital structure. (Enter 0 if not applicable).

Your WACC Calculation

–.–%
Cost of Equity: –.–%
Weighted Cost of Equity: –.–%
Cost of Debt (Post-Tax): –.–%
Weighted Cost of Debt: –.–%
Cost of Preferred Stock: –.–%
Weighted Cost of Preferred Stock: –.–%
Total Capital Weights: –.–%
WACC Formula:
WACC = (E/V * Re) + (D/V * Rd * (1 – Tc)) + (P/V * Rp)

Where:
E = Market Value of Equity
D = Market Value of Debt
P = Market Value of Preferred Stock
V = Total Market Value of the Company (E + D + P)
Re = Cost of Equity
Rd = Cost of Debt (Pre-Tax)
Rp = Cost of Preferred Stock
Tc = Corporate Tax Rate (Note: Our calculator uses post-tax cost of debt directly)

This calculator simplifies by using weights directly:
WACC = (Weight of Equity * Cost of Equity) + (Weight of Debt * Cost of Debt Post-Tax) + (Weight of Preferred Stock * Cost of Preferred Stock)
Equity Debt Preferred Stock
Key Assumptions and Inputs
Component Input Value (%) Weight (%) Weighted Component Cost (%)
Equity –.– –.– –.–
Debt –.– –.– –.–
Preferred Stock –.– –.– –.–
Total –.– –.– –.–

What is Weighted Average Cost of Capital (WACC)?

The Weighted Average Cost of Capital (WACC) is a crucial financial metric that represents a company's blended cost of capital across all sources, including common stock, preferred stock, and debt. It signifies the average rate of return a company expects to compensate its investors (both debt holders and equity holders) for the risk of investing in the company. In essence, WACC is the minimum return a company must earn on its existing asset base to satisfy its creditors, owners, and other capital providers.

Who Should Use WACC? WACC is primarily used by financial analysts, corporate finance professionals, investors, and management. It is fundamental for:

  • Capital Budgeting Decisions: WACC serves as the discount rate for evaluating the net present value (NPV) of potential projects or investments. A project's expected return should exceed the WACC to be considered value-creating.
  • Valuation: It's used in discounted cash flow (DCF) analysis to determine the present value of a company's future cash flows, thus estimating its intrinsic value.
  • Performance Measurement: Companies can compare their actual returns on investment against their WACC to gauge performance.
  • Capital Structure Optimization: Understanding the cost of different capital components helps companies find an optimal mix that minimizes their overall WACC.

Common Misconceptions:
WACC is static: WACC is not a fixed number; it fluctuates with market conditions, interest rates, company-specific risk, and changes in the capital structure.
WACC is the cost of new financing: While related, WACC represents the overall cost of the company's *entire* existing capital structure, not just the cost of raising new funds, although it is used to evaluate new investments.
WACC is always higher than the cost of debt: This is generally true because equity is riskier than debt. However, the tax deductibility of interest expense lowers the effective cost of debt.

WACC Formula and Mathematical Explanation

The standard formula for calculating the Weighted Average Cost of Capital (WACC) is:

WACC = (E/V * Re) + (D/V * Rd * (1 – Tc)) + (P/V * Rp)

Let's break down each component of this weighted average cost of capital formula:

Variable Explanations

Variable Meaning Unit Typical Range/Considerations
E Market Value of the Company's Equity Currency (e.g., USD) Number of shares outstanding * Current share price. Market capitalization.
D Market Value of the Company's Debt Currency (e.g., USD) Sum of the market values of all outstanding debt instruments (bonds, loans).
P Market Value of the Company's Preferred Stock Currency (e.g., USD) Number of preferred shares outstanding * Current preferred share price.
V Total Market Value of the Company's Financing Currency (e.g., USD) V = E + D + P. The total capital pool.
E/V Proportion (Weight) of Equity in the Capital Structure Percentage (%) Calculated as E divided by V. Must sum to 100% with D/V and P/V.
D/V Proportion (Weight) of Debt in the Capital Structure Percentage (%) Calculated as D divided by V. Must sum to 100% with E/V and P/V.
P/V Proportion (Weight) of Preferred Stock in the Capital Structure Percentage (%) Calculated as P divided by V. Must sum to 100% with E/V and D/V.
Re Cost of Equity Percentage (%) Typically estimated using the Capital Asset Pricing Model (CAPM): Rf + Beta * (Rm – Rf). Usually 8-15% for stable companies, higher for riskier ones.
Rd Cost of Debt (Pre-Tax) Percentage (%) The effective interest rate the company pays on its debt before taxes. Often based on current market yields for similar debt. Typically 4-10%.
Tc Corporate Tax Rate Percentage (%) The company's effective marginal tax rate. Crucial for the tax shield benefit of debt. Typically 21-35%.
Rp Cost of Preferred Stock Percentage (%) Annual preferred dividend / Current market price of preferred stock. Usually 5-10%.

Note on Calculator Simplification: Our calculator uses the direct weights (E/V, D/V, P/V) and the post-tax cost of debt (Rd * (1 – Tc)) for simplicity and ease of use. You can input the post-tax cost of debt directly. If you only have the pre-tax cost of debt, you would calculate the post-tax cost first before entering it into the calculator. The calculation becomes:

WACC = (Weight of Equity * Cost of Equity) + (Weight of Debt * Cost of Debt Post-Tax) + (Weight of Preferred Stock * Cost of Preferred Stock)

Practical Examples of WACC in Action

Understanding WACC is best illustrated with real-world scenarios. Here are two examples:

Example 1: Tech Startup Expansion

A rapidly growing tech startup, "Innovate Solutions," is considering a major expansion into a new market. They need to determine if the projected returns from this expansion justify the cost of capital.

Assumptions:

  • Innovate Solutions has a capital structure entirely of equity and debt.
  • Market Value of Equity (E): $50 million
  • Market Value of Debt (D): $20 million
  • Total Value (V): $70 million
  • Weight of Equity (E/V): $50M / $70M = 71.43%
  • Weight of Debt (D/V): $20M / $70M = 28.57%
  • Cost of Equity (Re): 15% (Higher due to startup risk)
  • Cost of Debt (Post-Tax) (Rd*(1-Tc)): 6%

Calculation: Using the calculator's logic (or the formula): WACC = (0.7143 * 15%) + (0.2857 * 6%) WACC = 10.71% + 1.71% WACC = 12.42%

Financial Interpretation: Innovate Solutions must achieve an expected rate of return of at least 12.42% on its expansion project to create value for its shareholders. If the projected ROI for the new market entry is 18%, the project is likely attractive. If it's only 10%, it should be rejected. This analysis demonstrates how WACC guides strategic investment decisions for growing firms.

Example 2: Mature Manufacturing Company Investment

"Reliable Manufacturing," a stable, established company, is evaluating the purchase of new, efficient machinery. They need to know their cost of capital to assess the project's viability.

Assumptions:

  • Capital Structure: Equity, Debt, and Preferred Stock
  • Market Value of Equity (E): $100 million
  • Market Value of Debt (D): $50 million
  • Market Value of Preferred Stock (P): $10 million
  • Total Value (V): $160 million
  • Weight of Equity (E/V): $100M / $160M = 62.5%
  • Weight of Debt (D/V): $50M / $160M = 31.25%
  • Weight of Preferred Stock (P/V): $10M / $160M = 6.25%
  • Cost of Equity (Re): 10%
  • Cost of Debt (Post-Tax) (Rd*(1-Tc)): 4%
  • Cost of Preferred Stock (Rp): 7%

Calculation: Using the calculator inputs: WACC = (0.625 * 10%) + (0.3125 * 4%) + (0.0625 * 7%) WACC = 6.25% + 1.25% + 0.44% WACC = 7.94%

Financial Interpretation: Reliable Manufacturing's overall cost of capital is 7.94%. The new machinery investment must generate returns significantly higher than this threshold. The inclusion of preferred stock, even at a small weight, slightly increases the WACC compared to a company with only debt and equity. This example highlights how WACC captures the costs of all financing sources for established firms.

How to Use This WACC Calculator

Our Weighted Average Cost of Capital calculator is designed for simplicity and accuracy. Follow these steps to get your WACC:

  1. Gather Your Financial Data: You'll need the following key figures for your company:
    • Cost of Equity (%)
    • Weight of Equity (%)
    • Cost of Debt (Post-Tax) (%)
    • Weight of Debt (%)
    • Cost of Preferred Stock (%) (If applicable)
    • Weight of Preferred Stock (%) (If applicable)
    Ensure that the weights of your capital components (Equity, Debt, Preferred Stock) add up to 100%. If you don't have preferred stock, simply enter 0 for its cost and weight.
  2. Input the Values: Enter each percentage value into the corresponding field in the calculator. Pay close attention to whether the Cost of Debt is pre-tax or post-tax. Our calculator requires the post-tax cost. If you only have the pre-tax cost, you'll need to calculate it first: Post-Tax Cost of Debt = Pre-Tax Cost of Debt * (1 – Tax Rate).
  3. View the Results: Click the "Calculate WACC" button. The calculator will immediately display:
    • The main WACC result: Highlighted in green, this is your company's overall weighted average cost of capital.
    • Intermediate Values: The weighted costs of equity, debt, and preferred stock.
    • Total Capital Weights: Confirmation that your input weights sum to 100%.
    • A dynamic chart visually representing the contribution of each capital component to the WACC.
    • A detailed table summarizing your inputs and calculated weighted components.
  4. Interpret Your WACC: Your calculated WACC represents the minimum acceptable rate of return for new investments or projects. Any project expected to yield less than your WACC is likely to destroy shareholder value. Use it as a benchmark for investment decisions and financial planning.
  5. Utilize Additional Features:
    • Reset: Use the "Reset" button to clear all fields and return to default values for a fresh calculation.
    • Copy Results: Click "Copy Results" to copy the main WACC, intermediate values, and key assumptions to your clipboard for easy pasting into reports or spreadsheets.

Key Factors Affecting WACC Results

Several factors can significantly influence a company's Weighted Average Cost of Capital. Understanding these drivers is crucial for accurate calculation and strategic financial management.

  • Cost of Equity (Re): This is often the largest component of WACC. Factors influencing it include market risk premium, the company's beta (systematic risk), the risk-free rate, and investor expectations. Higher perceived risk leads to a higher cost of equity.
  • Cost of Debt (Rd): Influenced by prevailing market interest rates, the company's credit rating, and the specific terms of its debt. A higher credit rating generally results in a lower cost of debt.
  • Corporate Tax Rate (Tc): The higher the corporate tax rate, the greater the tax shield benefit from debt (interest expense is tax-deductible), thus lowering the effective post-tax cost of debt and, consequently, the WACC.
  • Capital Structure Weights (E/V, D/V, P/V): The proportion of each financing source matters. A company heavily reliant on expensive equity will have a higher WACC than one financed primarily by cheaper debt (considering the tax shield). The optimal capital structure aims to minimize WACC.
  • Market Conditions and Economic Factors: Broad economic factors like inflation, interest rate policies by central banks, and overall market sentiment impact both the cost of debt and the required return on equity. A rising interest rate environment will typically increase WACC.
  • Company-Specific Risk and Growth Prospects: Companies perceived as riskier or having uncertain future cash flows will demand higher returns from investors, increasing their cost of equity and potentially their cost of debt, leading to a higher WACC. Conversely, stable, predictable cash flows usually result in a lower WACC.
  • Financial Distress Costs: While debt is cheaper due to its tax deductibility, having too much debt increases the risk of financial distress or bankruptcy. The potential costs associated with this risk (e.g., loss of customers, legal fees) can offset the benefits of debt financing and influence the WACC calculation indirectly through higher perceived risk.

Frequently Asked Questions (FAQ)

Q1: What is the difference between WACC and the discount rate used in NPV calculations?
A: WACC is *the* discount rate commonly used for NPV calculations for projects that have a similar risk profile to the company's overall business. If a project is significantly riskier or less risky than the company average, a risk-adjusted discount rate (often higher or lower than WACC) should be used.

Q2: Should I use the book value or market value for capital structure weights?
A: Market values are preferred for WACC calculations because they reflect the current economic reality of the company's financing costs and investor expectations. Book values are historical accounting figures and may not represent current market perceptions or costs.

Q3: How often should WACC be recalculated?
A: WACC should be recalculated periodically, at least annually, or whenever there are significant changes in the company's capital structure, market interest rates, the cost of equity (e.g., due to changes in beta or risk premiums), or the corporate tax rate.

Q4: What does a WACC of 0% mean?
A: A WACC of 0% is practically impossible for a real business. It would imply that capital is free, which is not the case. If the calculator shows 0%, it's likely due to input errors (e.g., all components having 0 cost or weight).

Q5: Can WACC be negative?
A: Theoretically, if a company could borrow money at a negative interest rate and had significant tax benefits, and investors paid the company to hold its equity, WACC could approach zero or be slightly negative. However, in practice, WACC is almost always positive.

Q6: How does inflation affect WACC?
A: Inflation typically increases nominal interest rates (cost of debt) and the required return on equity, thus increasing WACC. Financial models often use nominal cash flows and a nominal WACC for consistency.

Q7: What if my company only has equity and debt (no preferred stock)?
A: Simply leave the "Cost of Preferred Stock" and "Weight of Preferred Stock" fields at their default value of 0. The calculator will automatically exclude preferred stock from the WACC calculation.

Q8: How is the Cost of Equity typically calculated?
A: The most common method is the Capital Asset Pricing Model (CAPM): Cost of Equity = Risk-Free Rate + Beta * (Market Risk Premium). Beta measures the stock's volatility relative to the market.

Related Tools and Internal Resources

© 2023 Financial Calculators Inc. All rights reserved.

var canvas = document.getElementById('waccChart'); var ctx = canvas.getContext('2d'); var myChart; function validateInput(id, min, max, errorId) { var input = document.getElementById(id); var value = parseFloat(input.value); var errorSpan = document.getElementById(errorId); var isValid = true; errorSpan.textContent = "; if (isNaN(value)) { errorSpan.textContent = 'Please enter a valid number.'; isValid = false; } else if (value max) { errorSpan.textContent = 'Value cannot be greater than ' + max + '%.'; isValid = false; } return isValid; } function updateChart() { if (myChart) { myChart.destroy(); } var costOfEquity = parseFloat(document.getElementById('costOfEquity').value); var equityWeight = parseFloat(document.getElementById('equityWeight').value); var costOfDebt = parseFloat(document.getElementById('costOfDebt').value); var debtWeight = parseFloat(document.getElementById('debtWeight').value); var costOfPreferred = parseFloat(document.getElementById('costOfPreferred').value); var preferredWeight = parseFloat(document.getElementById('preferredWeight').value); var totalWeight = equityWeight + debtWeight + preferredWeight; var weightedEquity = equityWeight > 0 ? (equityWeight / 100) * costOfEquity : 0; var weightedDebt = debtWeight > 0 ? (debtWeight / 100) * costOfDebt : 0; var weightedPreferred = preferredWeight > 0 ? (preferredWeight / 100) * costOfPreferred : 0; var data = { labels: ['Equity', 'Debt', 'Preferred Stock'], datasets: [{ label: 'Contribution to WACC (%)', data: [ equityWeight > 0 ? weightedEquity : 0, debtWeight > 0 ? weightedDebt : 0, preferredWeight > 0 ? weightedPreferred : 0 ], backgroundColor: [ 'rgba(75, 192, 192, 0.7)', // Green for Equity 'rgba(255, 99, 132, 0.7)', // Red for Debt 'rgba(255, 159, 64, 0.7)' // Orange for Preferred Stock ], borderColor: [ 'rgba(75, 192, 192, 1)', 'rgba(255, 99, 132, 1)', 'rgba(255, 159, 64, 1)' ], borderWidth: 1 }] }; var options = { responsive: true, maintainAspectRatio: false, plugins: { legend: { display: false // Legend is handled by custom div }, title: { display: true, text: 'WACC Component Breakdown', color: 'var(–primary-color)', font: { size: 16 } } }, scales: { y: { beginAtZero: true, title: { display: true, text: 'Percentage (%)' } } } }; myChart = new Chart(ctx, { type: 'bar', // Changed to bar chart for better component visualization data: data, options: options }); } function calculateWACC() { var isValid = true; isValid &= validateInput('costOfEquity', 0, 100, 'costOfEquityError'); isValid &= validateInput('equityWeight', 0, 100, 'equityWeightError'); isValid &= validateInput('costOfDebt', 0, 100, 'costOfDebtError'); isValid &= validateInput('debtWeight', 0, 100, 'debtWeightError'); isValid &= validateInput('costOfPreferred', 0, 100, 'costOfPreferredError'); isValid &= validateInput('preferredWeight', 0, 100, 'preferredWeightError'); if (!isValid) { document.getElementById('waccResult').textContent = 'Error'; document.getElementById('waccResult').className = 'no-results'; clearResultsDisplay(); return; } var costOfEquity = parseFloat(document.getElementById('costOfEquity').value); var equityWeight = parseFloat(document.getElementById('equityWeight').value); var costOfDebt = parseFloat(document.getElementById('costOfDebt').value); var debtWeight = parseFloat(document.getElementById('debtWeight').value); var costOfPreferred = parseFloat(document.getElementById('costOfPreferred').value); var preferredWeight = parseFloat(document.getElementById('preferredWeight').value); var totalWeight = equityWeight + debtWeight + preferredWeight; var waccResultElement = document.getElementById('waccResult'); var displayCostOfEquityElement = document.getElementById('displayCostOfEquity'); var weightedCostOfEquityElement = document.getElementById('weightedCostOfEquity'); var displayCostOfDebtElement = document.getElementById('displayCostOfDebt'); var weightedCostOfDebtElement = document.getElementById('weightedCostOfDebt'); var displayCostOfPreferredElement = document.getElementById('displayCostOfPreferred'); var weightedCostOfPreferredElement = document.getElementById('weightedCostOfPreferred'); var totalWeightElement = document.getElementById('totalWeight'); var weightedEquity = (equityWeight / 100) * costOfEquity; var weightedDebt = (debtWeight / 100) * costOfDebt; var weightedPreferred = (preferredWeight / 100) * costOfPreferred; var wacc = weightedEquity + weightedDebt + weightedPreferred; displayCostOfEquityElement.textContent = costOfEquity.toFixed(2) + '%'; weightedCostOfEquityElement.textContent = weightedEquity.toFixed(2) + '%'; displayCostOfDebtElement.textContent = costOfDebt.toFixed(2) + '%'; weightedCostOfDebtElement.textContent = weightedDebt.toFixed(2) + '%'; totalWeightElement.textContent = totalWeight.toFixed(2) + '%'; var preferredStockResults = document.getElementById('preferredStockResults'); var weightedPreferredStockResults = document.getElementById('weightedPreferredStockResults'); var preferredStockTableTr = document.getElementById('preferredStockTableTr'); if (preferredWeight > 0) { displayCostOfPreferredElement.textContent = costOfPreferred.toFixed(2) + '%'; weightedCostOfPreferredElement.textContent = weightedPreferred.toFixed(2) + '%'; preferredStockResults.style.display = 'block'; weightedPreferredStockResults.style.display = 'block'; preferredStockTableTr.style.display = 'table-row'; } else { displayCostOfPreferredElement.textContent = '–.–%'; weightedCostOfPreferredElement.textContent = '–.–%'; preferredStockResults.style.display = 'none'; weightedPreferredStockResults.style.display = 'none'; preferredStockTableTr.style.display = 'none'; } if (totalWeight 100.1) { // Allow for minor float precision issues waccResultElement.textContent = 'Check Weights'; waccResultElement.className = 'no-results'; } else { waccResultElement.textContent = wacc.toFixed(2) + '%'; waccResultElement.className = 'highlight-result'; } updateTable(costOfEquity, equityWeight, weightedEquity, costOfDebt, debtWeight, weightedDebt, costOfPreferred, preferredWeight, weightedPreferred, totalWeight, wacc); updateChart(); } function updateTable(costEquity, weightEquity, weightedEquity, costDebt, weightDebt, weightedDebt, costPreferred, weightPreferred, weightedPreferred, totalWeight, finalWACC) { document.getElementById('tableCostOfEquity').textContent = costEquity.toFixed(2); document.getElementById('tableEquityWeight').textContent = weightEquity.toFixed(2); document.getElementById('tableWeightedEquity').textContent = weightedEquity.toFixed(2); document.getElementById('tableCostOfDebt').textContent = costDebt.toFixed(2); document.getElementById('tableDebtWeight').textContent = weightDebt.toFixed(2); document.getElementById('tableWeightedDebt').textContent = weightedDebt.toFixed(2); document.getElementById('tableCostOfPreferred').textContent = costPreferred.toFixed(2); document.getElementById('tablePreferredWeight').textContent = weightPreferred.toFixed(2); document.getElementById('tableWeightedPreferred').textContent = weightedPreferred.toFixed(2); document.getElementById('tableTotalWeight').textContent = totalWeight.toFixed(2); document.getElementById('tableTotalWeighted').textContent = finalWACC.toFixed(2); } function clearResultsDisplay() { document.getElementById('displayCostOfEquity').textContent = '–.–%'; document.getElementById('weightedCostOfEquity').textContent = '–.–%'; document.getElementById('displayCostOfDebt').textContent = '–.–%'; document.getElementById('weightedCostOfDebt').textContent = '–.–%'; document.getElementById('totalWeight').textContent = '–.–%'; document.getElementById('displayCostOfPreferred').textContent = '–.–%'; document.getElementById('weightedCostOfPreferred').textContent = '–.–%'; var tableElements = document.querySelectorAll('#assumptionTableBody td:not(:first-child)'); for (var i = 0; i < tableElements.length; i++) { if (tableElements[i].id !== 'tableTotalWeight' && tableElements[i].id !== 'tableTotalWeighted') { tableElements[i].textContent = '–.–'; } } } function resetForm() { document.getElementById('costOfEquity').value = 12; document.getElementById('equityWeight').value = 60; document.getElementById('costOfDebt').value = 5; document.getElementById('debtWeight').value = 40; document.getElementById('costOfPreferred').value = 8; document.getElementById('preferredWeight').value = 0; document.getElementById('waccResult').textContent = '–.–%'; document.getElementById('waccResult').className = 'no-results'; clearResultsDisplay(); // Clear errors var errorSpans = document.querySelectorAll('.error-message'); for (var i = 0; i < errorSpans.length; i++) { errorSpans[i].textContent = ''; } if (myChart) { myChart.destroy(); } } function copyResults() { var waccResult = document.getElementById('waccResult').textContent; if (waccResult === '–.–%' || waccResult === 'Error' || waccResult === 'Check Weights') { alert("Please calculate WACC first to copy results."); return; } var resultText = "WACC Calculation Results:\n\n"; resultText += "Weighted Average Cost of Capital (WACC): " + waccResult + "\n"; resultText += "—————————————-\n"; resultText += "Key Components:\n"; resultText += " Cost of Equity: " + document.getElementById('displayCostOfEquity').textContent + "\n"; resultText += " Weighted Cost of Equity: " + document.getElementById('weightedCostOfEquity').textContent + "\n"; resultText += " Cost of Debt (Post-Tax): " + document.getElementById('displayCostOfDebt').textContent + "\n"; resultText += " Weighted Cost of Debt: " + document.getElementById('weightedCostOfDebt').textContent + "\n"; if (document.getElementById('preferredStockResults').style.display !== 'none') { resultText += " Cost of Preferred Stock: " + document.getElementById('displayCostOfPreferred').textContent + "\n"; resultText += " Weighted Cost of Preferred Stock: " + document.getElementById('weightedCostOfPreferred').textContent + "\n"; } resultText += " Total Capital Weights: " + document.getElementById('totalWeight').textContent + "\n"; resultText += "\nKey Assumptions/Inputs:\n"; resultText += " Equity Weight: " + document.getElementById('tableEquityWeight').textContent + "%\n"; resultText += " Debt Weight: " + document.getElementById('tableDebtWeight').textContent + "%\n"; if (document.getElementById('preferredStockTableTr').style.display !== 'none') { resultText += " Preferred Stock Weight: " + document.getElementById('tablePreferredWeight').textContent + "%\n"; } resultText += " Cost of Equity: " + document.getElementById('tableCostOfEquity').textContent + "%\n"; resultText += " Cost of Debt (Post-Tax): " + document.getElementById('tableCostOfDebt').textContent + "%\n"; if (document.getElementById('preferredStockTableTr').style.display !== 'none') { resultText += " Cost of Preferred Stock: " + document.getElementById('tableCostOfPreferred').textContent + "%\n"; } try { navigator.clipboard.writeText(resultText).then(function() { alert("Results copied to clipboard!"); }, function(err) { alert("Failed to copy results. Please copy manually."); console.error("Clipboard copy failed: ", err); }); } catch (e) { alert("Clipboard API not available. Please copy manually."); console.error("Clipboard API error: ", e); } } // Initial calculation on load document.addEventListener('DOMContentLoaded', function() { // Add Chart.js library dynamically var script = document.createElement('script'); script.src = 'https://cdn.jsdelivr.net/npm/chart.js@3.0.0/dist/chart.min.js'; script.onload = function() { console.log('Chart.js loaded'); calculateWACC(); // Perform initial calculation after Chart.js is loaded }; script.onerror = function() { console.error('Failed to load Chart.js'); alert('Error loading charting library. Chart functionality may be unavailable.'); }; document.head.appendChild(script); // Add event listeners for real-time updates var inputs = document.querySelectorAll('.loan-calc-container input[type="number"], .loan-calc-container select'); for (var i = 0; i < inputs.length; i++) { inputs[i].addEventListener('input', calculateWACC); } });

Leave a Comment