XAD documentation

Smoothed mathematics

The functions in this section are smoothed equivalents of the original math functions and can be used to allow computing derivatives around discontinuities.

smooth_abs

T smooth_abs(T x, T c = 0.001) is a smoothed version of abs, defined as:

smooth_abs(x,c)={|x|if x<c or x>cx2(2c−1c2x)if 0≤x≤cx2(2c+1c2x)if −c≤x<0
  • x is the input value
  • c is the cut-off point for the spline-approximated area (default: 0.001)
  • returns: The smoothed absolute value, defined as above.

smooth_max

T smooth_max(T x, T y, T c = 0.001) is a smoothed version of max, defined as:

smooth_max(x,y,c)=0.5(x+y+smooth_abs(x−y,c))
  • x First argument to max
  • y Second argument to max
  • c Cut-off point for the spline-approximated area (default: 0.001)
  • returns: The smoothed max function, defined as above

smooth_min

T smooth_min(T x, T y, T c = 0.001) is a smoothed version of min, defined as:

smooth_min(x,y,c)=0.5(x+y−smooth_abs(x−y,c))
  • x First argument to min
  • y Second argument to min
  • c Cut-off point for the spline-approximated area (default: 0.001)
  • returns: The smoothed min function, defined as above

Questions or issues: GitHub Discussions · issues. Would you rather we AAD-enabled your code? Get a free speed-up estimate.