# xarray.ufuncs.logaddexp

### xarray.ufuncs.logaddexp *= <xarray.ufuncs._binary_ufunc object>*

xarray specific variant of `numpy.logaddexp()`. Handles xarray objects by dispatching to the appropriate function for the underlying array type.

Documentation from numpy:

Logarithm of the sum of exponentiations of the inputs.

Calculates `log(exp(x1) + exp(x2))`. This function is useful in
statistics where the calculated probabilities of events may be so small
as to exceed the range of normal floating point numbers.  In such cases
the logarithm of the calculated probability is stored. This function
allows adding probabilities stored in such a fashion.

* **Parameters:**
  * **x1, x2** ([array_like](https://numpy.org/doc/stable/glossary.html#term-array_like)) – Input values.
    If `x1.shape != x2.shape`, they must be broadcastable to a common
    shape (which becomes the shape of the output).
  * **out** ([`ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray), [`None`](https://docs.python.org/3/builtins/constants.html#None), or [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple) of [`ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray) and [`None`](https://docs.python.org/3/builtins/constants.html#None), *optional*) – A location into which the result is stored. If provided, it must have
    a shape that the inputs broadcast to. If not provided or None,
    a freshly-allocated array is returned. A tuple (possible only as a
    keyword argument) must have length equal to the number of outputs.
  * **where** ([array_like](https://numpy.org/doc/stable/glossary.html#term-array_like), *optional*) – This condition is broadcast over the input. At locations where the
    condition is True, the out array will be set to the ufunc result.
    Elsewhere, the out array will retain its original value.
    Note that if an uninitialized out array is created via the default
    `out=None`, locations within it where the condition is False will
    remain uninitialized.
  * **\*\*kwargs** – For other keyword-only arguments, see the
    [ufunc docs](https://numpy.org/doc/stable/reference/ufuncs.html#ufuncs-kwargs).
* **Returns:**
  **result** ([`ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray)) – Logarithm of `exp(x1) + exp(x2)`.
  This is a scalar if both x1 and x2 are scalars.

#### SEE ALSO
[`logaddexp2`](xarray.ufuncs.logaddexp2.html.md#xarray.ufuncs.logaddexp2)
: Logarithm of the sum of exponentiations of inputs in base 2.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('d69125c0-20a3-42bd-9b0f-c13666c92d3b','f397cf5b-dcb1-4c63-b9ba-f9ac699ee17f','fc22e32f-9bb0-44d3-a492-cd1e6a6f80f0','../lite/tree/../notebooks/index.html?path=a6127a79_34a7_4760_9790_b344186bb130.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> import numpy as np
>>> prob1 = np.log(1e-50)
>>> prob2 = np.log(2.5e-50)
>>> prob12 = np.logaddexp(prob1, prob2)
>>> prob12
-113.87649168120691
>>> np.exp(prob12)
3.5000000000000057e-50
```

<div id="fc22e32f-9bb0-44d3-a492-cd1e6a6f80f0" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('d69125c0-20a3-42bd-9b0f-c13666c92d3b','fc22e32f-9bb0-44d3-a492-cd1e6a6f80f0')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('d69125c0-20a3-42bd-9b0f-c13666c92d3b','fc22e32f-9bb0-44d3-a492-cd1e6a6f80f0')">Open In Tab</button></div><div id="f397cf5b-dcb1-4c63-b9ba-f9ac699ee17f" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
