{
  "category": "Compatibility",
  "display_name": "GAMMAINV",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.GAMMAINV",
  "implementation_state": {
    "answer_bank": null,
    "detail": "Everything else matches (5 workbook cells). Last-bit means a finite number within 16 ULP of Excel's.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "close",
    "state_label": "Close: last-bit deviations remain",
    "summary": "Close: 2 of 5 recorded answers differ in the last bits, worst 2 ULP",
    "workbook_corpus": {
      "cells": 5,
      "last_bit": 2,
      "matched": 3,
      "worst_ulp": 2
    }
  },
  "implementations": [
    {
      "commit": "9e1884369a678158dd82d3d74188daf986995e87",
      "flavour": "excel-compatibility-candidate",
      "language": "Rust",
      "name": "CalcFunc",
      "own_code": [
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/distributions.rs#L235-L238"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "catalogue/distributions::nums",
        "ported/beta_gamma_stats_family::validate_gamma_shape",
        "ported/beta_gamma_stats_family::gamma_inv_kernel",
        "ported/excel_numeric::binary_with",
        "ported/excel_numeric::excel_expm1_internal",
        "ported/excel_numeric::expm1_internal_graph",
        "ported/excel_numeric::excel_x87_sub",
        "ported/excel_numeric::excel_x87_mul",
        "ported/excel_numeric::excel_x87_temme_finish",
        "ported/excel_numeric::excel_x87_div",
        "ported/excel_numeric/x87::mul",
        "ported/excel_numeric/x87::sub",
        "ported/excel_numeric/x87::div",
        "ported/excel_numeric/x87_chains::pow2_positive",
        "ported/excel_numeric/x87_chains::pow2",
        "ported/excel_numeric/x87_chains::exp_ext",
        "ported/excel_numeric/x87_chains::exp_with",
        "ported/excel_numeric/x87_chains::excel_exp",
        "ported/excel_numeric/x87_chains::log_with",
        "ported/excel_numeric/x87_chains::excel_log",
        "ported/special_math_common::gratio_norm_gamma",
        "ported/special_math_common::gratio_rexp",
        "ported/special_math_common::gratio_rlog",
        "ported/special_math_common::gratio_gam1",
        "ported/special_math_common::gratio",
        "ported/special_math_common::series_prefactor",
        "ported/special_math_common::gratio_after40",
        "ported/special_math_common::gratio_cf",
        "ported/special_math_common::gratio_temme_270",
        "ported/special_math_common::gratio_temme_340",
        "ported/special_math_common::gratio_temme_330",
        "ported/special_math_common::gratio_temme_finish",
        "ported/special_math_common::regularized_gamma_p",
        "ported/special_math_common::bisect_inverse"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/distributions.rs#L235-L238",
      "state": "close",
      "suite": null,
      "summary": "Close: 2 of 5 recorded answers differ in the last bits, worst 2 ULP"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.GAMMAINV.json",
  "name": "GAMMAINV",
  "notes": [],
  "schema": "efh.function-reference/v1",
  "section_order": [
    "what-it-does",
    "try-it",
    "quirks",
    "how-to-implement",
    "version-differences",
    "alternatives"
  ],
  "sections": {
    "alternatives": "\n[GAMMA.INV](FUNC.GAMMA.INV.md) is the current spelling; [EXPON.DIST](FUNC.EXPON.DIST.md) handles the shape-one waiting time; [CHISQ.DIST](FUNC.CHISQ.DIST.md) is a shape/scale specialization.\n\n\n",
    "how-to-implement": "\nThe current helper searches the positive binary64 lattice rather than stopping at a decimal tolerance:\n\n1. Validate shape, scale and probability. Return zero at `p=0`; reject `p>=1` or `p<0`.\n2. Start the upper bound at `hi=beta*max(alpha+10*sqrt(alpha)+10,1)`. The code allows up to 200 doublings while the generic forward value `P(alpha,hi/beta)` is below `p`.\n3. With lower bound zero, encode the nonnegative bounds as unsigned binary64 bit integers. Their ordering agrees with numeric ordering.\n4. While the two encodings differ by more than one, bisect their integer encodings and decode the middle value `x`. If `P(alpha,x/beta)>=p`, move the upper encoding to it; otherwise move the lower encoding.\n5. Return the upper value once the encodings are adjacent. This chooses the first representable candidate meeting the current forward test under the maintained bracket.\n\nFor shape one, scale two and probability one half, the mathematical equation is `1-exp(-x/2)=0.5`; its solution is `-2*ln(0.5)`, about `1.38629436111989`. That explains the scale and the example, not every last bit of the generic forward search.\n\nThe inverse callback calls `regularized_gamma_p` directly. It does not use every special-case wrapper of public GAMMADIST. Its forward approximation, bracket failures and return policy remain separate compatibility obligations; the current problem report still lists distribution mismatches. This is the current implementable candidate, not a recovered Excel search program.\n\n\n",
    "quirks": "\nAlpha and beta must be positive; nonpositive shape or scale gives `#NUM!`, while text arguments are documented as `#VALUE!`. The opened legacy page rejects probabilities outside `[0,1]`. The current shared helper returns zero at `p=0` and rejects `p=1` with `#NUM!`, since no finite upper support endpoint is available.\n\nMicrosoft describes this legacy inverse as an iterative search over GAMMADIST with a 100-iteration limit and `#N/A` on failure. Its current GAMMA.INV page describes 64 iterations and also `#N/A`. This is a difference in published descriptions of the two spellings; it does not establish a measured change between Excel builds or identify either internal search.\n\n\n",
    "sources": "\n- [Microsoft: GAMMAINV function](https://support.microsoft.com/en-us/excel/functions/gammainv-function), opened 6 November 2026; syntax, documented argument rules and errors.\n- [DnaCalc implementation](https://github.com/DnaCalc/DnaCalc/blob/da3ecc4fb19a3a5529708c311d0e8f05688ac165/crates/calc-func/src/ported/beta_gamma_stats_family.rs); implementation steps and the limits identified in the text.\n- [Binary64-lattice bisection](https://github.com/DnaCalc/DnaCalc/blob/da3ecc4fb19a3a5529708c311d0e8f05688ac165/crates/calc-func/src/ported/special_math_common.rs), `bisect_inverse`.\n- [Microsoft: GAMMA.INV](https://support.microsoft.com/en-us/excel/functions/gamma-inv-function), opened 6 November 2026; the modern page’s documented 64-iteration limit and error.\n\n",
    "try-it": "\n`=GAMMAINV(0.5,1,2)` is about `1.38629436111989`: the median of the shape-one distribution with scale two is `-2*ln(0.5)`.\n\n\n",
    "version-differences": "The recorded environments below distinguish a reading from a same-input comparison. Counts describe captured inputs in each environment; overlapping captures and comparisons are not totals of unique worksheet calls.\n\n| Excel 16.0 build | Platform and CPU | Captured inputs |\n|---|---|---:|\n| 19929 | Windows, bitness not recorded, CPU not recorded | 82 |\n\nThe record contains no same-input comparison between these environments. Reading different inputs on different builds does not establish either a version change or cross-build agreement.\n\n[Recorded environments and comparison details](https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.GAMMAINV.json).",
    "what-it-does": "\n`GAMMAINV(probability, alpha, beta)` inverts the gamma cumulative distribution. Alpha is a positive shape and beta a positive **scale**. This is the compatibility name.\n\n\n"
  },
  "signature": {
    "display": "GAMMAINV(probability, alpha, beta)",
    "parameters": [
      {
        "description": null,
        "name": "probability",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "alpha",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "beta",
        "optional": false,
        "repeats": false
      }
    ],
    "trailing_repeats": false
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "implemented",
        "reason": null
      },
      "arity": {
        "max": 3,
        "min": 3
      },
      "category": "Compatibility",
      "classification": {
        "arg_preparation_profile": "ValuesOnlyPreAdapter",
        "coercion_lift_profile": "Custom",
        "determinism_class": "Deterministic",
        "error_collapse_profile": "None",
        "fec_dependency_profile": "None",
        "host_interaction_class": "None",
        "kernel_signature_class": "Custom",
        "rich_value_usage": "RichBlind",
        "surface_fec_dependency_profile": "None",
        "thread_safety_class": "SafePure",
        "volatility_class": "NonVolatile"
      },
      "descriptions": {
        "long": null,
        "short": "Inverse of the cumulative gamma distribution (older form)",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns the inverse of the gamma cumulative distribution",
        "microsoft_url": "https://support.microsoft.com/en-us/office/gammainv-function-06393558-37ab-47d0-aa63-432f99e7916d"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "GAMMAINV"
        },
        {
          "locale": "bg-BG",
          "name": "GAMMAINV"
        },
        {
          "locale": "cs-CZ",
          "name": "GAMMAINV"
        },
        {
          "locale": "da-DK",
          "name": "GAMMAINV"
        },
        {
          "locale": "de-DE",
          "name": "GAMMAINV"
        },
        {
          "locale": "el-GR",
          "name": "GAMMAINV"
        },
        {
          "locale": "en-AU",
          "name": "GAMMAINV"
        },
        {
          "locale": "en-GB",
          "name": "GAMMAINV"
        },
        {
          "locale": "en-US",
          "name": "GAMMAINV"
        },
        {
          "locale": "es-ES",
          "name": "DISTR.GAMMA.INV"
        },
        {
          "locale": "et-EE",
          "name": "GAMMAINV"
        },
        {
          "locale": "fi-FI",
          "name": "GAMMAJAKAUMA.KÄÄNT"
        },
        {
          "locale": "fr-FR",
          "name": "LOI.GAMMA.INVERSE*"
        },
        {
          "locale": "he-IL",
          "name": "GAMMAINV"
        },
        {
          "locale": "hr-HR",
          "name": "GAMMAINV"
        },
        {
          "locale": "hu-HU",
          "name": "INVERZ.GAMMA"
        },
        {
          "locale": "id-ID",
          "name": "GAMMAINV"
        },
        {
          "locale": "it-IT",
          "name": "GAMMAINV"
        },
        {
          "locale": "ja-JP",
          "name": "GAMMAINV"
        },
        {
          "locale": "ko-KR",
          "name": "GAMMAINV"
        },
        {
          "locale": "lt-LT",
          "name": "GAMMAINV"
        },
        {
          "locale": "lv-LV",
          "name": "GAMMAINV"
        },
        {
          "locale": "nb-NO",
          "name": "GAMMAINV"
        },
        {
          "locale": "nl-NL",
          "name": "GAMMA.INV"
        },
        {
          "locale": "pl-PL",
          "name": "ROZKŁAD.GAMMA.ODW"
        },
        {
          "locale": "pt-BR",
          "name": "GAMMAINV"
        },
        {
          "locale": "pt-PT",
          "name": "INVGAMA"
        },
        {
          "locale": "ro-RO",
          "name": "GAMMAINV"
        },
        {
          "locale": "ru-RU",
          "name": "ГАММАОБР"
        },
        {
          "locale": "sk-SK",
          "name": "GAMMAINV"
        },
        {
          "locale": "sl-SI",
          "name": "GAMAINV"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "GAMMAINV"
        },
        {
          "locale": "sv-SE",
          "name": "GAMMAINV"
        },
        {
          "locale": "th-TH",
          "name": "GAMMAINV"
        },
        {
          "locale": "tr-TR",
          "name": "GAMATERS işlevi"
        },
        {
          "locale": "uk-UA",
          "name": "GAMMAINV"
        },
        {
          "locale": "vi-VN",
          "name": "GAMMAINV"
        },
        {
          "locale": "zh-CN",
          "name": "GAMMAINV"
        },
        {
          "locale": "zh-HK",
          "name": "GAMMAINV"
        },
        {
          "locale": "zh-TW",
          "name": "GAMMAINV"
        }
      ],
      "signature": {
        "display": "GAMMAINV(probability, alpha, beta)",
        "parameters": [
          {
            "description": null,
            "name": "probability",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "alpha",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "beta",
            "optional": false,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "GAMMAINV",
      "version_marker": null,
      "xlcall": {
        "code": "287",
        "symbol": "xlfGammainv"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/gammainv-function-06393558-37ab-47d0-aa63-432f99e7916d"
  },
  "try_it": {
    "formula": "=GAMMAINV(0.5,1,2)"
  },
  "url": "https://handbook.dnacalc.com/functions/GAMMAINV.html",
  "variants": [],
  "versions": [
    {
      "behaviour": "82 captured inputs are indexed for this environment. Capture dates are not recorded. This is a reading count, not a comparison with another build.",
      "excel_build": "16.0 build 19929",
      "platform": "Windows, bitness not recorded, CPU not recorded",
      "sources": [
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.GAMMAINV.json"
      ]
    }
  ]
}