newton.utils.smooth_max#

newton.utils.smooth_max(a, b, eps)[source]#

Compute a smooth approximation of the maximum of two values.

This function returns a value close to max(a, b), but is differentiable everywhere. The eps parameter controls the smoothness: larger values make the transition smoother.

Parameters:
  • a (float) – The first value.

  • b (float) – The second value.

  • eps (float) – Smoothing parameter (should be small and positive).

Returns:

A smooth approximation of max(a, b).

Return type:

float