logaddexp

Contents

logaddexp#

class saiunit.math.logaddexp(x, y, unit_to_scale=None, **kwargs)#

Logarithm of the sum of exponentiations of the inputs.

Computes log(exp(x) + exp(y)) in a numerically stable way.

Parameters:
  • x (Array | ndarray | bool | number | bool | int | float | complex | saiunit.Quantity) – First input.

  • y (Array | ndarray | bool | number | bool | int | float | complex | saiunit.Quantity) – Second input. Must be broadcastable with x.

  • unit_to_scale (saiunit.Unit | None) – Unit used to convert both inputs to dimensionless numbers.

Returns:

out – Element-wise log(exp(x) + exp(y)).

Return type:

Array

Examples

>>> import saiunit as u
>>> import jax.numpy as jnp
>>> u.math.logaddexp(jnp.array([1.0]), jnp.array([2.0]))
Array([2.3132617], dtype=float32)