Calculation of Weighted Average Cost

Weighted Average Cost Calculator & Guide – WACC Explained body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; line-height: 1.6; color: #333; background-color: #f8f9fa; margin: 0; padding: 0; } .container { max-width: 960px; margin: 20px auto; padding: 20px; background-color: #fff; border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05); } header { background-color: #004a99; color: #fff; padding: 20px; text-align: center; border-radius: 8px 8px 0 0; margin: -20px -20px 20px -20px; } header h1 { margin: 0; font-size: 2.2em; font-weight: 600; } h2, h3 { color: #004a99; border-bottom: 2px solid #e0e0e0; padding-bottom: 5px; margin-top: 30px; } .calc-section { background-color: #f0f2f5; padding: 25px; border-radius: 8px; margin-bottom: 30px; box-shadow: inset 0 1px 3px rgba(0,0,0,0.1); } .calc-section h2 { text-align: center; margin-top: 0; border-bottom: none; margin-bottom: 20px; color: #333; } .loan-calc-container { display: flex; flex-direction: column; gap: 15px; } .input-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 15px; } .input-group label { font-weight: bold; color: #004a99; font-size: 0.95em; } .input-group input[type="number"], .input-group select { padding: 10px; border: 1px solid #ccc; border-radius: 5px; font-size: 1em; transition: border-color 0.3s ease; } .input-group input[type="number"]:focus, .input-group select:focus { outline: none; border-color: #007bff; box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25); } .input-group .helper-text { font-size: 0.85em; color: #6c757d; margin-top: 5px; } .error-message { color: #dc3545; font-size: 0.85em; margin-top: 5px; min-height: 1.2em; /* Reserve space to prevent layout shift */ } .button-group { display: flex; justify-content: space-between; margin-top: 20px; gap: 10px; } .button-group button { padding: 12px 20px; border: none; border-radius: 5px; cursor: pointer; font-size: 1em; font-weight: 500; transition: background-color 0.3s ease, transform 0.2s ease; } .btn-calculate { background-color: #28a745; color: white; } .btn-calculate:hover { background-color: #218838; transform: translateY(-1px); } .btn-reset { background-color: #6c757d; color: white; } .btn-reset:hover { background-color: #5a6268; transform: translateY(-1px); } .btn-copy { background-color: #007bff; color: white; } .btn-copy:hover { background-color: #0056b3; transform: translateY(-1px); } #results { margin-top: 30px; padding: 20px; background-color: #e9ecef; border-radius: 8px; border: 1px solid #dee2e6; } #results h3 { margin-top: 0; border-bottom: none; text-align: center; color: #333; } .primary-result { font-size: 2.5em; font-weight: bold; color: #28a745; text-align: center; margin-bottom: 20px; padding: 15px; background-color: #d4edda; border: 1px solid #c3e6cb; border-radius: 5px; } .intermediate-results div, .formula-explanation { margin-bottom: 15px; font-size: 1.1em; } .intermediate-results span { font-weight: bold; color: #004a99; } .formula-explanation { font-style: italic; color: #555; background-color: #fff; padding: 10px; border-left: 3px solid #004a99; border-radius: 4px; } table { width: 100%; border-collapse: collapse; margin-top: 20px; box-shadow: 0 1px 5px rgba(0,0,0,0.05); } caption { font-size: 1.1em; font-weight: bold; color: #004a99; margin-bottom: 10px; text-align: left; } th, td { padding: 12px 15px; text-align: left; border-bottom: 1px solid #ddd; } thead th { background-color: #004a99; color: white; font-weight: bold; } tbody tr:nth-child(even) { background-color: #f2f2f2; } #chartContainer { text-align: center; margin-top: 30px; background-color: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 1px 5px rgba(0,0,0,0.05); } #chartContainer canvas { max-width: 100%; height: auto; } .chart-legend { margin-top: 15px; font-size: 0.9em; color: #555; } .chart-legend span { display: inline-block; margin: 0 10px; } .chart-legend span::before { content: "; display: inline-block; width: 12px; height: 12px; margin-right: 5px; border-radius: 3px; vertical-align: middle; } .legend-equity::before { background-color: #007bff; } .legend-debt::before { background-color: #dc3545; } .legend-wacc::before { background-color: #28a745; } .article-content { margin-top: 40px; background-color: #fff; padding: 30px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05); } .article-content h2 { font-size: 1.8em; color: #004a99; margin-top: 30px; border-bottom: 2px solid #e0e0e0; padding-bottom: 5px; } .article-content h3 { font-size: 1.4em; color: #004a99; margin-top: 25px; border-bottom: 1px solid #eee; padding-bottom: 3px; } .article-content p, .article-content ul, .article-content ol { margin-bottom: 20px; font-size: 1.05em; } .article-content ul, .article-content ol { padding-left: 25px; } .article-content li { margin-bottom: 10px; } .article-content strong, .article-content b { color: #004a99; } .article-content code { background-color: #e9ecef; padding: 2px 5px; border-radius: 3px; font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; } .faq-item { background-color: #f8f9fa; padding: 15px; border-radius: 5px; margin-bottom: 15px; border: 1px solid #e0e0e0; } .faq-item h4 { margin: 0 0 5px 0; color: #004a99; font-size: 1.1em; } .faq-item p { margin: 0; font-size: 1em; color: #555; } .internal-links ul { list-style: none; padding: 0; } .internal-links li { margin-bottom: 15px; background-color: #e9ecef; padding: 15px; border-radius: 5px; border-left: 4px solid #004a99; } .internal-links a { text-decoration: none; color: #004a99; font-weight: bold; font-size: 1.1em; } .internal-links p { margin: 5px 0 0 0; font-size: 0.95em; color: #555; } footer { text-align: center; margin-top: 40px; padding: 20px; font-size: 0.9em; color: #6c757d; }

Weighted Average Cost Calculator & Guide

Calculate Weighted Average Cost of Capital (WACC)

Enter the total market value of your company's equity (e.g., stock price * shares outstanding).
Enter the total market value of your company's debt (e.g., book value of bonds and loans).
Enter the required rate of return for equity investors (as a percentage).
Enter the current interest rate on your company's debt (as a percentage).
Enter your company's effective corporate tax rate (as a percentage).

Your WACC Results

Weight of Equity (We):
Weight of Debt (Wd):
After-Tax Cost of Debt:
Formula: WACC = (We * Re) + (Wd * Rd * (1 – Tc))

Where:
We = Weight of Equity (E / (E + D))
Wd = Weight of Debt (D / (E + D))
Re = Cost of Equity
Rd = Cost of Debt
Tc = Corporate Tax Rate

WACC Component Breakdown

Equity Cost Component Debt Cost Component Total WACC
WACC Calculation Breakdown
Component Value Percentage of Capital Cost (After-Tax for Debt) Weighted Cost
Equity
Debt
Total WACC

What is Weighted Average Cost of Capital (WACC)?

The Weighted Average Cost of Capital, commonly abbreviated as WACC, is a crucial financial metric representing a company's blended cost of capital across all sources, including common stock, preferred stock, bonds, and other forms of debt. Essentially, it signifies the average rate of return a company expects to pay to its investors (both debt holders and equity holders) to finance its assets. A lower WACC generally indicates a more efficient use of capital and a lower risk profile for the company, making it more attractive to investors and lenders.

Who Should Use WACC?

WACC is primarily used by:

  • Corporate Finance Managers and CFOs: To evaluate the profitability of potential projects and investments, set hurdle rates for new ventures, and understand the overall cost of financing the business.
  • Investors: To assess a company's investment attractiveness and risk profile. A company with a high WACC may be considered riskier.
  • Analysts: To value companies using discounted cash flow (DCF) models, where WACC serves as the discount rate.
  • Mergers & Acquisitions Professionals: To determine the viability and value of potential acquisitions.

Common Misconceptions about WACC

Several common misunderstandings surround WACC:

  • WACC is a fixed number: In reality, WACC fluctuates with market conditions, interest rates, and the company's capital structure.
  • WACC is the cost of debt: WACC incorporates both debt and equity costs, weighted by their respective proportions in the capital structure.
  • A high WACC is always bad: While a high WACC signifies a higher cost of capital, it can sometimes be justified by higher-risk, higher-return opportunities. The key is comparing it against potential returns.
  • WACC applies universally: A single WACC may not be appropriate for all divisions or projects within a diversified company if they have significantly different risk profiles.

WACC Formula and Mathematical Explanation

The calculation of the Weighted Average Cost of Capital hinges on understanding the proportion and cost of each component of a company's capital structure. The formula is derived by taking the cost of each capital component (equity and debt), multiplying it by its respective weight in the total capital, and summing these weighted costs. Crucially, the cost of debt is adjusted for the tax deductibility of interest payments.

The WACC Formula

The standard formula for WACC is:

WACC = (We * Re) + (Wd * Rd * (1 – Tc))

Variable Explanations

Let's break down each component of the WACC formula:

  • E (Market Value of Equity): This represents the total market value of a company's outstanding shares. It's calculated by multiplying the current stock price by the number of shares outstanding.
  • D (Market Value of Debt): This is the total market value of a company's interest-bearing debt. This typically includes bonds, bank loans, and other forms of borrowing. Often, the book value of debt is used as a proxy if market values are not readily available.
  • V (Total Firm Value): The sum of the market value of equity and the market value of debt (V = E + D). This represents the total market value of the company's financing.
  • We (Weight of Equity): The proportion of the company's total capital that is financed by equity. It's calculated as E / V.
  • Wd (Weight of Debt): The proportion of the company's total capital that is financed by debt. It's calculated as D / V.
  • Re (Cost of Equity): The rate of return required by equity investors. This is often estimated using models like the Capital Asset Pricing Model (CAPM), which considers the risk-free rate, the stock's beta, and the market risk premium.
  • Rd (Cost of Debt): The current market interest rate that a company pays on its debt. This is the yield-to-maturity on outstanding bonds or the interest rate on loans.
  • Tc (Corporate Tax Rate): The company's effective corporate income tax rate. Interest payments on debt are typically tax-deductible, which reduces the effective cost of debt.

Variables Table

WACC Variables and Their Characteristics
Variable Meaning Unit Typical Range
E Market Value of Equity Currency (e.g., USD, EUR) Varies widely by company size
D Market Value of Debt Currency (e.g., USD, EUR) Varies widely by company size
V Total Firm Value (E + D) Currency (e.g., USD, EUR) Sum of E and D
We Weight of Equity (E / V) Proportion (0 to 1) Typically 0.5 to 0.9
Wd Weight of Debt (D / V) Proportion (0 to 1) Typically 0.1 to 0.5
Re Cost of Equity Percentage (%) Commonly 8% to 20% or higher, depending on risk
Rd Cost of Debt Percentage (%) Typically 3% to 10%, depending on creditworthiness and market rates
Tc Corporate Tax Rate Percentage (%) Varies by jurisdiction, often 15% to 35%

Practical Examples of WACC Calculation

Understanding WACC is best illustrated through practical application. Here are a couple of examples:

Example 1: Technology Startup

Consider a rapidly growing tech startup, "Innovatech Solutions":

  • Market Value of Equity (E): $80 million
  • Market Value of Debt (D): $20 million
  • Total Firm Value (V): $80M + $20M = $100 million
  • Cost of Equity (Re): 18% (Higher due to startup risk)
  • Cost of Debt (Rd): 7%
  • Corporate Tax Rate (Tc): 21%

Calculation:

  • Weight of Equity (We) = $80M / $100M = 0.80 (or 80%)
  • Weight of Debt (Wd) = $20M / $100M = 0.20 (or 20%)
  • After-Tax Cost of Debt = 7% * (1 – 0.21) = 7% * 0.79 = 5.53%
  • WACC = (0.80 * 18%) + (0.20 * 5.53%)
  • WACC = 14.40% + 1.11% = 15.51%

Interpretation: Innovatech Solutions has a WACC of 15.51%. This means the company must generate returns exceeding this rate on its investments to create value for its shareholders. The high WACC reflects the significant risk associated with a startup, driven by its high cost of equity.

Example 2: Established Utility Company

Now, let's look at a stable, established utility company, "Reliable Power Corp.":

  • Market Value of Equity (E): $300 million
  • Market Value of Debt (D): $700 million (Higher leverage typical for utilities)
  • Total Firm Value (V): $300M + $700M = $1 billion
  • Cost of Equity (Re): 10% (Lower due to stability)
  • Cost of Debt (Rd): 5%
  • Corporate Tax Rate (Tc): 28%

Calculation:

  • Weight of Equity (We) = $300M / $1B = 0.30 (or 30%)
  • Weight of Debt (Wd) = $700M / $1B = 0.70 (or 70%)
  • After-Tax Cost of Debt = 5% * (1 – 0.28) = 5% * 0.72 = 3.60%
  • WACC = (0.30 * 10%) + (0.70 * 3.60%)
  • WACC = 3.00% + 2.52% = 5.52%

Interpretation: Reliable Power Corp.'s WACC is 5.52%. This significantly lower rate compared to the startup is due to its lower risk profile, stable cash flows, and substantial use of debt, which is cheaper and tax-advantaged. This low WACC allows the company to undertake projects with modest returns that still create value.

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. Input Market Values: Enter the total market value of your company's equity (E) and the market value of its debt (D). If market values aren't precisely known, book values can serve as reasonable approximations, especially for debt.
  2. Input Costs: Provide the cost of equity (Re) – the return investors expect. This often requires using a model like CAPM. Then, enter the current cost of debt (Rd), which is the interest rate your company pays on its borrowings.
  3. Input Tax Rate: Enter your company's effective corporate tax rate (Tc). This is crucial because interest expense reduces taxable income.
  4. Calculate: Click the "Calculate WACC" button.

Reading the Results

  • Primary Result (WACC %): This is your company's overall weighted average cost of capital, displayed prominently. It's the minimum return your company must earn on its investments to satisfy its investors.
  • Intermediate Values: You'll see the calculated weights of equity (We) and debt (Wd), along with the after-tax cost of debt. These provide insight into your capital structure and cost components.
  • Table Breakdown: The table offers a detailed view of each component's contribution to the total WACC.
  • Chart: The dynamic chart visually represents the proportion of WACC contributed by equity and debt, making it easier to grasp the impact of each.

Decision-Making Guidance

Use your calculated WACC as a benchmark:

  • Investment Appraisal: Any new project or investment should have an expected rate of return *higher* than the WACC to be considered value-creating.
  • Valuation: WACC is the discount rate used in DCF models to determine the present value of future cash flows, thus estimating the company's intrinsic value.
  • Capital Structure: Analyze how changes in your capital mix (e.g., taking on more debt or issuing more equity) might affect your WACC.

Remember to use the "Copy Results" button to easily transfer your findings for reporting or further analysis. The "Reset" button is available to start fresh with new inputs.

Key Factors That Affect WACC Results

Several dynamic factors influence a company's Weighted Average Cost of Capital. Understanding these is key to managing and potentially lowering it:

  1. Capital Structure (We & Wd): The mix of debt and equity financing is the most direct influence. Debt is typically cheaper than equity, and its interest payments are tax-deductible. A company that finances more through debt (higher Wd) will generally have a lower WACC, assuming the cost of debt doesn't rise excessively due to increased risk. However, too much debt increases financial risk (e.g., bankruptcy risk), which can raise the cost of both debt and equity.
  2. Cost of Equity (Re): This is influenced by the company's systematic risk (beta), market conditions, and investor expectations. Higher perceived risk, lower liquidity, or unfavorable market sentiment will increase the cost of equity, thereby raising WACC. Techniques like the Capital Asset Pricing Model (CAPM) are used to estimate this, considering factors like the risk-free rate and market risk premium.
  3. Cost of Debt (Rd): This is heavily tied to prevailing market interest rates and the company's credit rating. A company with a strong credit rating will pay lower interest rates on its debt. Changes in monetary policy or the company's financial health directly impact Rd and, consequently, WACC.
  4. Corporate Tax Rate (Tc): The effective tax rate impacts the "after-tax cost of debt." A higher tax rate makes the tax shield from debt more valuable, reducing the *effective* cost of debt and lowering the overall WACC. Conversely, lower tax rates reduce this benefit.
  5. Market Risk Premium: The additional return investors expect for investing in the stock market over a risk-free asset. A higher market risk premium generally increases the cost of equity (Re) and thus WACC. This premium fluctuates based on economic conditions and investor sentiment.
  6. Company-Specific Risk Factors: Beyond market risk, factors like industry volatility, operational efficiency, management quality, regulatory environment, and competitive landscape contribute to the perceived risk. Higher company-specific risks often translate into a higher cost of equity and potentially a higher cost of debt, increasing WACC.
  7. Inflation Expectations: Inflation can influence both interest rates (affecting Rd) and the required return on equity (Re). Higher expected inflation often leads to higher nominal interest rates and higher required equity returns, pushing WACC upwards.
  8. Financial Distress Costs: While debt financing can lower WACC due to tax advantages, excessive debt increases the probability of financial distress or bankruptcy. The potential costs associated with distress (e.g., loss of customers, supplier constraints, legal fees) can indirectly increase both Re and Rd, raising WACC.

Frequently Asked Questions (FAQ) about WACC

Q1: What is the ideal WACC?

There isn't a single "ideal" WACC. The goal is to have a WACC that is lower than the expected returns on profitable projects. Generally, a lower WACC is preferred as it signifies a lower cost of capital and potentially lower risk. However, what's considered "good" depends heavily on the industry, company size, and market conditions.

Q2: How is the Cost of Equity (Re) typically calculated?

The most common method is the Capital Asset Pricing Model (CAPM): Re = Rf + Beta * (Rm – Rf), where Rf is the risk-free rate, Beta measures the stock's volatility relative to the market, and (Rm – Rf) is the equity market risk premium.

Q3: Can WACC be negative?

In theory, a negative WACC is highly unlikely for a functioning business. It would imply that the company is being paid to raise capital, which is not sustainable. It might occur in highly unusual circumstances or due to calculation errors.

Q4: Why is the cost of debt adjusted for taxes in the WACC formula?

Interest paid on debt is usually a tax-deductible expense for corporations. This means that interest payments reduce the company's taxable income, providing a "tax shield." The WACC formula accounts for this tax benefit by multiplying the cost of debt (Rd) by (1 – Tc), reflecting its lower *after-tax* cost.

Q5: Should I use book value or market value for equity and debt?

Market values are theoretically preferred because they reflect current investor perceptions and the true economic cost of capital. However, market values can be volatile. For debt, book value is often used as a proxy if market prices aren't readily available, especially for bank loans. For equity, the market capitalization (stock price * shares outstanding) is standard.

Q6: How does a company's credit rating affect WACC?

A higher credit rating (e.g., AAA) indicates lower risk of default, leading to a lower cost of debt (Rd). A lower credit rating (e.g., B, CCC) signals higher risk, resulting in a higher Rd. This directly impacts the WACC calculation, with a better rating generally leading to a lower WACC.

Q7: Can WACC be used for private companies?

Yes, but it's more challenging. Estimating the cost of equity for a private company is difficult as its stock isn't publicly traded. Analysts often use comparable public companies (using their Betas) or build-up methods to estimate Re. The market value of debt might also be approximated by book value.

Q8: What is the relationship between WACC and the hurdle rate?

WACC often serves as the minimum acceptable rate of return, or "hurdle rate," for new projects or investments. A project is generally considered financially viable only if its expected return exceeds the company's WACC. This ensures that the project is expected to generate enough profit to cover the cost of the capital used to fund it.

© 2023 Your Financial Tools. All rights reserved.

var chartInstance = null; // Global variable to hold chart instance function calculateWACC() { // Input validation var equityValue = parseFloat(document.getElementById("equityValue").value); var debtValue = parseFloat(document.getElementById("debtValue").value); var costOfEquity = parseFloat(document.getElementById("costOfEquity").value); var costOfDebt = parseFloat(document.getElementById("costOfDebt").value); var taxRate = parseFloat(document.getElementById("taxRate").value); var errors = 0; if (isNaN(equityValue) || equityValue <= 0) { document.getElementById("equityValueError").textContent = "Please enter a valid positive number for Equity Value."; errors++; } else { document.getElementById("equityValueError").textContent = ""; } if (isNaN(debtValue) || debtValue <= 0) { document.getElementById("debtValueError").textContent = "Please enter a valid positive number for Debt Value."; errors++; } else { document.getElementById("debtValueError").textContent = ""; } if (isNaN(costOfEquity) || costOfEquity 100) { document.getElementById("costOfEquityError").textContent = "Please enter a valid percentage (0-100) for Cost of Equity."; errors++; } else { document.getElementById("costOfEquityError").textContent = ""; } if (isNaN(costOfDebt) || costOfDebt 100) { document.getElementById("costOfDebtError").textContent = "Please enter a valid percentage (0-100) for Cost of Debt."; errors++; } else { document.getElementById("costOfDebtError").textContent = ""; } if (isNaN(taxRate) || taxRate 100) { document.getElementById("taxRateError").textContent = "Please enter a valid percentage (0-100) for Tax Rate."; errors++; } else { document.getElementById("taxRateError").textContent = ""; } if (errors > 0) { document.getElementById("results").style.display = "none"; return; } var totalValue = equityValue + debtValue; var weightEquity = equityValue / totalValue; var weightDebt = debtValue / totalValue; var afterTaxCostOfDebt = costOfDebt * (1 – (taxRate / 100)); var wacc = (weightEquity * costOfEquity) + (weightDebt * afterTaxCostOfDebt); // Convert costs to percentages for display var costOfEquityPercent = costOfEquity; var costOfDebtPercent = costOfDebt; var afterTaxCostOfDebtPercent = afterTaxCostOfDebt; var waccPercent = wacc; // Update intermediate results display document.getElementById("weightEquity").getElementsByTagName("span")[0].textContent = (weightEquity * 100).toFixed(2) + "%"; document.getElementById("weightDebt").getElementsByTagName("span")[0].textContent = (weightDebt * 100).toFixed(2) + "%"; document.getElementById("afterTaxCostOfDebt").getElementsByTagName("span")[0].textContent = afterTaxCostOfDebtPercent.toFixed(2) + "%"; // Update primary result display document.getElementById("primaryResult").textContent = waccPercent.toFixed(2) + "%"; // Update table document.getElementById("tableEquityValue").textContent = "$" + equityValue.toLocaleString(); document.getElementById("tableDebtValue").textContent = "$" + debtValue.toLocaleString(); document.getElementById("tableEquityWeight").textContent = (weightEquity * 100).toFixed(2) + "%"; document.getElementById("tableDebtWeight").textContent = (weightDebt * 100).toFixed(2) + "%"; document.getElementById("tableEquityCost").textContent = costOfEquityPercent.toFixed(2) + "%"; document.getElementById("tableDebtAfterTaxCost").textContent = afterTaxCostOfDebtPercent.toFixed(2) + "%"; document.getElementById("tableEquityWeightedCost").textContent = (weightEquity * costOfEquityPercent).toFixed(2) + "%"; document.getElementById("tableDebtWeightedCost").textContent = (weightDebt * afterTaxCostOfDebtPercent).toFixed(2) + "%"; document.getElementById("tableTotalWACC").textContent = waccPercent.toFixed(2) + "%"; updateChart(weightEquity, weightDebt, costOfEquityPercent, afterTaxCostOfDebtPercent, waccPercent); document.getElementById("results").style.display = "block"; } function resetCalculator() { document.getElementById("equityValue").value = "50000000"; document.getElementById("debtValue").value = "20000000"; document.getElementById("costOfEquity").value = "12"; document.getElementById("costOfDebt").value = "6"; document.getElementById("taxRate").value = "25"; document.getElementById("results").style.display = "none"; // Clear errors document.getElementById("equityValueError").textContent = ""; document.getElementById("debtValueError").textContent = ""; document.getElementById("costOfEquityError").textContent = ""; document.getElementById("costOfDebtError").textContent = ""; document.getElementById("taxRateError").textContent = ""; // Reset chart data if needed (or just call calculateWACC to refresh display) calculateWACC(); // Recalculate with default values } function copyResults() { var resultText = "WACC Calculation Results:\n\n"; resultText += "Weighted Average Cost of Capital (WACC): " + document.getElementById("primaryResult").textContent + "\n"; resultText += "Weight of Equity (We): " + document.getElementById("weightEquity").getElementsByTagName("span")[0].textContent + "\n"; resultText += "Weight of Debt (Wd): " + document.getElementById("weightDebt").getElementsByTagName("span")[0].textContent + "\n"; resultText += "After-Tax Cost of Debt: " + document.getElementById("afterTaxCostOfDebt").getElementsByTagName("span")[0].textContent + "\n\n"; resultText += "Detailed Breakdown:\n"; resultText += "Equity Value: " + document.getElementById("tableEquityValue").textContent + "\n"; resultText += "Debt Value: " + document.getElementById("tableDebtValue").textContent + "\n"; resultText += "Equity Weight: " + document.getElementById("tableEquityWeight").textContent + "\n"; resultText += "Debt Weight: " + document.getElementById("tableDebtWeight").textContent + "\n"; resultText += "Cost of Equity: " + document.getElementById("tableEquityCost").textContent + "\n"; resultText += "After-Tax Cost of Debt: " + document.getElementById("tableDebtAfterTaxCost").textContent + "\n"; resultText += "Weighted Equity Cost: " + document.getElementById("tableEquityWeightedCost").textContent + "\n"; resultText += "Weighted Debt Cost (After-Tax): " + document.getElementById("tableDebtWeightedCost").textContent + "\n"; resultText += "Total WACC: " + document.getElementById("tableTotalWACC").textContent + "\n\n"; resultText += "Assumptions:\n"; resultText += " – Market Value of Equity: " + document.getElementById("equityValue").value + "\n"; resultText += " – Market Value of Debt: " + document.getElementById("debtValue").value + "\n"; resultText += " – Cost of Equity: " + document.getElementById("costOfEquity").value + "%\n"; resultText += " – Cost of Debt: " + document.getElementById("costOfDebt").value + "%\n"; resultText += " – Tax Rate: " + document.getElementById("taxRate").value + "%\n"; var textArea = document.createElement("textarea"); textArea.value = resultText; document.body.appendChild(textArea); textArea.select(); document.execCommand("copy"); document.body.removeChild(textArea); alert("Results copied to clipboard!"); } function updateChart(weightEquity, weightDebt, costOfEquity, afterTaxCostOfDebt, wacc) { var ctx = document.getElementById("waccChart").getContext("2d"); // Calculate weighted components for chart series var equityComponent = weightEquity * costOfEquity; var debtComponent = weightDebt * afterTaxCostOfDebt; // Ensure data is not NaN before chart update if (isNaN(equityComponent) || isNaN(debtComponent) || isNaN(wacc)) { console.error("Chart data is NaN. Cannot update chart."); return; } var chartData = { labels: ["Equity Cost", "Debt Cost"], datasets: [{ label: 'Component Contribution', data: [equityComponent, debtComponent], backgroundColor: ['#007bff', '#dc3545'], // Blue for Equity, Red for Debt borderWidth: 1 }, { label: 'WACC Target', data: [wacc, wacc], // Plotting WACC as a reference line across both components type: 'line', // Render as a line borderColor: '#28a745', // Green for WACC borderWidth: 3, fill: false, pointRadius: 0, // Hide points for line spanGaps: false // Do not connect segments if data is missing }] }; var chartOptions = { responsive: true, maintainAspectRatio: false, plugins: { legend: { display: false // Legend handled by custom div }, title: { display: true, text: 'WACC Components vs. Total WACC', font: { size: 16 } } }, scales: { y: { beginAtZero: true, ticks: { callback: function(value) { return value.toFixed(2) + '%'; } }, title: { display: true, text: 'Percentage Cost' } }, x: { title: { display: true, text: 'Capital Component' } } } }; // Destroy previous chart instance if it exists if (chartInstance) { chartInstance.destroy(); } // Create new chart chartInstance = new Chart(ctx, { type: 'bar', // Base type is bar chart data: chartData, options: chartOptions }); } // Initial calculation on load with default values window.onload = function() { // Check if canvas element exists before trying to initialize chart var canvas = document.getElementById("waccChart"); if (canvas) { // Mock initial chart update with default values to set up the canvas // The actual calculation will happen when calculateWACC is called updateChart(0.71, 0.29, 12, 4.46, 8.98); // Mock values based on defaults } calculateWACC(); };

Leave a Comment