Numeric.SpecFunctions:invErfc from math-functions-0.1.5.2, A

Percentage Accurate: 95.8% → 98.8%
Time: 2.3s
Alternatives: 5
Speedup: 1.3×

Specification

?
\[\begin{array}{l} \\ x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (+ x (/ y (- (* 1.1283791670955126 (exp z)) (* x y)))))
double code(double x, double y, double z) {
	return x + (y / ((1.1283791670955126 * exp(z)) - (x * y)));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x + (y / ((1.1283791670955126d0 * exp(z)) - (x * y)))
end function
public static double code(double x, double y, double z) {
	return x + (y / ((1.1283791670955126 * Math.exp(z)) - (x * y)));
}
def code(x, y, z):
	return x + (y / ((1.1283791670955126 * math.exp(z)) - (x * y)))
function code(x, y, z)
	return Float64(x + Float64(y / Float64(Float64(1.1283791670955126 * exp(z)) - Float64(x * y))))
end
function tmp = code(x, y, z)
	tmp = x + (y / ((1.1283791670955126 * exp(z)) - (x * y)));
end
code[x_, y_, z_] := N[(x + N[(y / N[(N[(1.1283791670955126 * N[Exp[z], $MachinePrecision]), $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}
\end{array}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 5 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 95.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (+ x (/ y (- (* 1.1283791670955126 (exp z)) (* x y)))))
double code(double x, double y, double z) {
	return x + (y / ((1.1283791670955126 * exp(z)) - (x * y)));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x + (y / ((1.1283791670955126d0 * exp(z)) - (x * y)))
end function
public static double code(double x, double y, double z) {
	return x + (y / ((1.1283791670955126 * Math.exp(z)) - (x * y)));
}
def code(x, y, z):
	return x + (y / ((1.1283791670955126 * math.exp(z)) - (x * y)))
function code(x, y, z)
	return Float64(x + Float64(y / Float64(Float64(1.1283791670955126 * exp(z)) - Float64(x * y))))
end
function tmp = code(x, y, z)
	tmp = x + (y / ((1.1283791670955126 * exp(z)) - (x * y)));
end
code[x_, y_, z_] := N[(x + N[(y / N[(N[(1.1283791670955126 * N[Exp[z], $MachinePrecision]), $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}
\end{array}

Alternative 1: 98.8% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -125:\\ \;\;\;\;x - \frac{1}{x}\\ \mathbf{elif}\;z \leq 1.22 \cdot 10^{-29}:\\ \;\;\;\;x + \frac{y}{1.1283791670955126 - x \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -125.0)
   (- x (/ 1.0 x))
   (if (<= z 1.22e-29) (+ x (/ y (- 1.1283791670955126 (* x y)))) x)))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -125.0) {
		tmp = x - (1.0 / x);
	} else if (z <= 1.22e-29) {
		tmp = x + (y / (1.1283791670955126 - (x * y)));
	} else {
		tmp = x;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= (-125.0d0)) then
        tmp = x - (1.0d0 / x)
    else if (z <= 1.22d-29) then
        tmp = x + (y / (1.1283791670955126d0 - (x * y)))
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -125.0) {
		tmp = x - (1.0 / x);
	} else if (z <= 1.22e-29) {
		tmp = x + (y / (1.1283791670955126 - (x * y)));
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -125.0:
		tmp = x - (1.0 / x)
	elif z <= 1.22e-29:
		tmp = x + (y / (1.1283791670955126 - (x * y)))
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -125.0)
		tmp = Float64(x - Float64(1.0 / x));
	elseif (z <= 1.22e-29)
		tmp = Float64(x + Float64(y / Float64(1.1283791670955126 - Float64(x * y))));
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -125.0)
		tmp = x - (1.0 / x);
	elseif (z <= 1.22e-29)
		tmp = x + (y / (1.1283791670955126 - (x * y)));
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -125.0], N[(x - N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.22e-29], N[(x + N[(y / N[(1.1283791670955126 - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -125:\\
\;\;\;\;x - \frac{1}{x}\\

\mathbf{elif}\;z \leq 1.22 \cdot 10^{-29}:\\
\;\;\;\;x + \frac{y}{1.1283791670955126 - x \cdot y}\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -125

    1. Initial program 89.2%

      \[x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \]
    2. Taylor expanded in y around inf

      \[\leadsto \color{blue}{x - \frac{1}{x}} \]
    3. Step-by-step derivation
      1. lower--.f64N/A

        \[\leadsto x - \color{blue}{\frac{1}{x}} \]
      2. lower-/.f6499.9

        \[\leadsto x - \frac{1}{\color{blue}{x}} \]
    4. Applied rewrites99.9%

      \[\leadsto \color{blue}{x - \frac{1}{x}} \]

    if -125 < z < 1.21999999999999996e-29

    1. Initial program 99.8%

      \[x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \]
    2. Taylor expanded in z around 0

      \[\leadsto x + \frac{y}{\color{blue}{\frac{5641895835477563}{5000000000000000}} - x \cdot y} \]
    3. Step-by-step derivation
      1. Applied rewrites99.4%

        \[\leadsto x + \frac{y}{\color{blue}{1.1283791670955126} - x \cdot y} \]

      if 1.21999999999999996e-29 < z

      1. Initial program 94.7%

        \[x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \]
      2. Taylor expanded in x around inf

        \[\leadsto \color{blue}{x} \]
      3. Step-by-step derivation
        1. Applied rewrites96.6%

          \[\leadsto \color{blue}{x} \]
      4. Recombined 3 regimes into one program.
      5. Add Preprocessing

      Alternative 2: 86.8% accurate, 0.4× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := x - \frac{1}{x}\\ t_1 := x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}\\ \mathbf{if}\;t\_1 \leq -50000000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_1 \leq 20:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (let* ((t_0 (- x (/ 1.0 x)))
              (t_1 (+ x (/ y (- (* 1.1283791670955126 (exp z)) (* x y))))))
         (if (<= t_1 -50000000.0) t_0 (if (<= t_1 20.0) x t_0))))
      double code(double x, double y, double z) {
      	double t_0 = x - (1.0 / x);
      	double t_1 = x + (y / ((1.1283791670955126 * exp(z)) - (x * y)));
      	double tmp;
      	if (t_1 <= -50000000.0) {
      		tmp = t_0;
      	} else if (t_1 <= 20.0) {
      		tmp = x;
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(x, y, z)
      use fmin_fmax_functions
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          real(8), intent (in) :: z
          real(8) :: t_0
          real(8) :: t_1
          real(8) :: tmp
          t_0 = x - (1.0d0 / x)
          t_1 = x + (y / ((1.1283791670955126d0 * exp(z)) - (x * y)))
          if (t_1 <= (-50000000.0d0)) then
              tmp = t_0
          else if (t_1 <= 20.0d0) then
              tmp = x
          else
              tmp = t_0
          end if
          code = tmp
      end function
      
      public static double code(double x, double y, double z) {
      	double t_0 = x - (1.0 / x);
      	double t_1 = x + (y / ((1.1283791670955126 * Math.exp(z)) - (x * y)));
      	double tmp;
      	if (t_1 <= -50000000.0) {
      		tmp = t_0;
      	} else if (t_1 <= 20.0) {
      		tmp = x;
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      def code(x, y, z):
      	t_0 = x - (1.0 / x)
      	t_1 = x + (y / ((1.1283791670955126 * math.exp(z)) - (x * y)))
      	tmp = 0
      	if t_1 <= -50000000.0:
      		tmp = t_0
      	elif t_1 <= 20.0:
      		tmp = x
      	else:
      		tmp = t_0
      	return tmp
      
      function code(x, y, z)
      	t_0 = Float64(x - Float64(1.0 / x))
      	t_1 = Float64(x + Float64(y / Float64(Float64(1.1283791670955126 * exp(z)) - Float64(x * y))))
      	tmp = 0.0
      	if (t_1 <= -50000000.0)
      		tmp = t_0;
      	elseif (t_1 <= 20.0)
      		tmp = x;
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y, z)
      	t_0 = x - (1.0 / x);
      	t_1 = x + (y / ((1.1283791670955126 * exp(z)) - (x * y)));
      	tmp = 0.0;
      	if (t_1 <= -50000000.0)
      		tmp = t_0;
      	elseif (t_1 <= 20.0)
      		tmp = x;
      	else
      		tmp = t_0;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_] := Block[{t$95$0 = N[(x - N[(1.0 / x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x + N[(y / N[(N[(1.1283791670955126 * N[Exp[z], $MachinePrecision]), $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -50000000.0], t$95$0, If[LessEqual[t$95$1, 20.0], x, t$95$0]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := x - \frac{1}{x}\\
      t_1 := x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}\\
      \mathbf{if}\;t\_1 \leq -50000000:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;t\_1 \leq 20:\\
      \;\;\;\;x\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (+.f64 x (/.f64 y (-.f64 (*.f64 #s(literal 5641895835477563/5000000000000000 binary64) (exp.f64 z)) (*.f64 x y)))) < -5e7 or 20 < (+.f64 x (/.f64 y (-.f64 (*.f64 #s(literal 5641895835477563/5000000000000000 binary64) (exp.f64 z)) (*.f64 x y))))

        1. Initial program 94.5%

          \[x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \]
        2. Taylor expanded in y around inf

          \[\leadsto \color{blue}{x - \frac{1}{x}} \]
        3. Step-by-step derivation
          1. lower--.f64N/A

            \[\leadsto x - \color{blue}{\frac{1}{x}} \]
          2. lower-/.f6491.1

            \[\leadsto x - \frac{1}{\color{blue}{x}} \]
        4. Applied rewrites91.1%

          \[\leadsto \color{blue}{x - \frac{1}{x}} \]

        if -5e7 < (+.f64 x (/.f64 y (-.f64 (*.f64 #s(literal 5641895835477563/5000000000000000 binary64) (exp.f64 z)) (*.f64 x y)))) < 20

        1. Initial program 99.9%

          \[x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \]
        2. Taylor expanded in x around inf

          \[\leadsto \color{blue}{x} \]
        3. Step-by-step derivation
          1. Applied rewrites74.3%

            \[\leadsto \color{blue}{x} \]
        4. Recombined 2 regimes into one program.
        5. Add Preprocessing

        Alternative 3: 71.5% accurate, 1.3× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.9 \cdot 10^{-138}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.15 \cdot 10^{-231}:\\ \;\;\;\;\frac{-1}{x}\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{-238}:\\ \;\;\;\;y \cdot 0.8862269254527579\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-127}:\\ \;\;\;\;\frac{-1}{x}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
        (FPCore (x y z)
         :precision binary64
         (if (<= x -2.9e-138)
           x
           (if (<= x -2.15e-231)
             (/ -1.0 x)
             (if (<= x 3.4e-238)
               (* y 0.8862269254527579)
               (if (<= x 2.1e-127) (/ -1.0 x) x)))))
        double code(double x, double y, double z) {
        	double tmp;
        	if (x <= -2.9e-138) {
        		tmp = x;
        	} else if (x <= -2.15e-231) {
        		tmp = -1.0 / x;
        	} else if (x <= 3.4e-238) {
        		tmp = y * 0.8862269254527579;
        	} else if (x <= 2.1e-127) {
        		tmp = -1.0 / x;
        	} else {
        		tmp = x;
        	}
        	return tmp;
        }
        
        module fmin_fmax_functions
            implicit none
            private
            public fmax
            public fmin
        
            interface fmax
                module procedure fmax88
                module procedure fmax44
                module procedure fmax84
                module procedure fmax48
            end interface
            interface fmin
                module procedure fmin88
                module procedure fmin44
                module procedure fmin84
                module procedure fmin48
            end interface
        contains
            real(8) function fmax88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(4) function fmax44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(8) function fmax84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmax48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
            end function
            real(8) function fmin88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(4) function fmin44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(8) function fmin84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmin48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
            end function
        end module
        
        real(8) function code(x, y, z)
        use fmin_fmax_functions
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            real(8), intent (in) :: z
            real(8) :: tmp
            if (x <= (-2.9d-138)) then
                tmp = x
            else if (x <= (-2.15d-231)) then
                tmp = (-1.0d0) / x
            else if (x <= 3.4d-238) then
                tmp = y * 0.8862269254527579d0
            else if (x <= 2.1d-127) then
                tmp = (-1.0d0) / x
            else
                tmp = x
            end if
            code = tmp
        end function
        
        public static double code(double x, double y, double z) {
        	double tmp;
        	if (x <= -2.9e-138) {
        		tmp = x;
        	} else if (x <= -2.15e-231) {
        		tmp = -1.0 / x;
        	} else if (x <= 3.4e-238) {
        		tmp = y * 0.8862269254527579;
        	} else if (x <= 2.1e-127) {
        		tmp = -1.0 / x;
        	} else {
        		tmp = x;
        	}
        	return tmp;
        }
        
        def code(x, y, z):
        	tmp = 0
        	if x <= -2.9e-138:
        		tmp = x
        	elif x <= -2.15e-231:
        		tmp = -1.0 / x
        	elif x <= 3.4e-238:
        		tmp = y * 0.8862269254527579
        	elif x <= 2.1e-127:
        		tmp = -1.0 / x
        	else:
        		tmp = x
        	return tmp
        
        function code(x, y, z)
        	tmp = 0.0
        	if (x <= -2.9e-138)
        		tmp = x;
        	elseif (x <= -2.15e-231)
        		tmp = Float64(-1.0 / x);
        	elseif (x <= 3.4e-238)
        		tmp = Float64(y * 0.8862269254527579);
        	elseif (x <= 2.1e-127)
        		tmp = Float64(-1.0 / x);
        	else
        		tmp = x;
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y, z)
        	tmp = 0.0;
        	if (x <= -2.9e-138)
        		tmp = x;
        	elseif (x <= -2.15e-231)
        		tmp = -1.0 / x;
        	elseif (x <= 3.4e-238)
        		tmp = y * 0.8862269254527579;
        	elseif (x <= 2.1e-127)
        		tmp = -1.0 / x;
        	else
        		tmp = x;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_] := If[LessEqual[x, -2.9e-138], x, If[LessEqual[x, -2.15e-231], N[(-1.0 / x), $MachinePrecision], If[LessEqual[x, 3.4e-238], N[(y * 0.8862269254527579), $MachinePrecision], If[LessEqual[x, 2.1e-127], N[(-1.0 / x), $MachinePrecision], x]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;x \leq -2.9 \cdot 10^{-138}:\\
        \;\;\;\;x\\
        
        \mathbf{elif}\;x \leq -2.15 \cdot 10^{-231}:\\
        \;\;\;\;\frac{-1}{x}\\
        
        \mathbf{elif}\;x \leq 3.4 \cdot 10^{-238}:\\
        \;\;\;\;y \cdot 0.8862269254527579\\
        
        \mathbf{elif}\;x \leq 2.1 \cdot 10^{-127}:\\
        \;\;\;\;\frac{-1}{x}\\
        
        \mathbf{else}:\\
        \;\;\;\;x\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if x < -2.89999999999999973e-138 or 2.1000000000000001e-127 < x

          1. Initial program 97.3%

            \[x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \]
          2. Taylor expanded in x around inf

            \[\leadsto \color{blue}{x} \]
          3. Step-by-step derivation
            1. Applied rewrites84.0%

              \[\leadsto \color{blue}{x} \]

            if -2.89999999999999973e-138 < x < -2.14999999999999999e-231 or 3.39999999999999983e-238 < x < 2.1000000000000001e-127

            1. Initial program 93.0%

              \[x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \]
            2. Taylor expanded in y around inf

              \[\leadsto \color{blue}{x - \frac{1}{x}} \]
            3. Step-by-step derivation
              1. lower--.f64N/A

                \[\leadsto x - \color{blue}{\frac{1}{x}} \]
              2. lower-/.f6436.2

                \[\leadsto x - \frac{1}{\color{blue}{x}} \]
            4. Applied rewrites36.2%

              \[\leadsto \color{blue}{x - \frac{1}{x}} \]
            5. Taylor expanded in x around 0

              \[\leadsto \frac{-1}{\color{blue}{x}} \]
            6. Step-by-step derivation
              1. lower-/.f6436.2

                \[\leadsto \frac{-1}{x} \]
            7. Applied rewrites36.2%

              \[\leadsto \frac{-1}{\color{blue}{x}} \]

            if -2.14999999999999999e-231 < x < 3.39999999999999983e-238

            1. Initial program 90.7%

              \[x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \]
            2. Taylor expanded in x around 0

              \[\leadsto \color{blue}{\frac{5000000000000000}{5641895835477563} \cdot \frac{y}{e^{z}}} \]
            3. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \frac{y}{e^{z}} \cdot \color{blue}{\frac{5000000000000000}{5641895835477563}} \]
              2. lower-*.f64N/A

                \[\leadsto \frac{y}{e^{z}} \cdot \color{blue}{\frac{5000000000000000}{5641895835477563}} \]
              3. lower-/.f64N/A

                \[\leadsto \frac{y}{e^{z}} \cdot \frac{5000000000000000}{5641895835477563} \]
              4. lift-exp.f6447.6

                \[\leadsto \frac{y}{e^{z}} \cdot 0.8862269254527579 \]
            4. Applied rewrites47.6%

              \[\leadsto \color{blue}{\frac{y}{e^{z}} \cdot 0.8862269254527579} \]
            5. Taylor expanded in z around 0

              \[\leadsto y \cdot \frac{5000000000000000}{5641895835477563} \]
            6. Step-by-step derivation
              1. Applied rewrites44.7%

                \[\leadsto y \cdot 0.8862269254527579 \]
            7. Recombined 3 regimes into one program.
            8. Add Preprocessing

            Alternative 4: 71.3% accurate, 2.2× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.15 \cdot 10^{-197}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.78 \cdot 10^{-245}:\\ \;\;\;\;y \cdot 0.8862269254527579\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
            (FPCore (x y z)
             :precision binary64
             (if (<= x -1.15e-197) x (if (<= x 1.78e-245) (* y 0.8862269254527579) x)))
            double code(double x, double y, double z) {
            	double tmp;
            	if (x <= -1.15e-197) {
            		tmp = x;
            	} else if (x <= 1.78e-245) {
            		tmp = y * 0.8862269254527579;
            	} else {
            		tmp = x;
            	}
            	return tmp;
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            real(8) function code(x, y, z)
            use fmin_fmax_functions
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                real(8), intent (in) :: z
                real(8) :: tmp
                if (x <= (-1.15d-197)) then
                    tmp = x
                else if (x <= 1.78d-245) then
                    tmp = y * 0.8862269254527579d0
                else
                    tmp = x
                end if
                code = tmp
            end function
            
            public static double code(double x, double y, double z) {
            	double tmp;
            	if (x <= -1.15e-197) {
            		tmp = x;
            	} else if (x <= 1.78e-245) {
            		tmp = y * 0.8862269254527579;
            	} else {
            		tmp = x;
            	}
            	return tmp;
            }
            
            def code(x, y, z):
            	tmp = 0
            	if x <= -1.15e-197:
            		tmp = x
            	elif x <= 1.78e-245:
            		tmp = y * 0.8862269254527579
            	else:
            		tmp = x
            	return tmp
            
            function code(x, y, z)
            	tmp = 0.0
            	if (x <= -1.15e-197)
            		tmp = x;
            	elseif (x <= 1.78e-245)
            		tmp = Float64(y * 0.8862269254527579);
            	else
            		tmp = x;
            	end
            	return tmp
            end
            
            function tmp_2 = code(x, y, z)
            	tmp = 0.0;
            	if (x <= -1.15e-197)
            		tmp = x;
            	elseif (x <= 1.78e-245)
            		tmp = y * 0.8862269254527579;
            	else
            		tmp = x;
            	end
            	tmp_2 = tmp;
            end
            
            code[x_, y_, z_] := If[LessEqual[x, -1.15e-197], x, If[LessEqual[x, 1.78e-245], N[(y * 0.8862269254527579), $MachinePrecision], x]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;x \leq -1.15 \cdot 10^{-197}:\\
            \;\;\;\;x\\
            
            \mathbf{elif}\;x \leq 1.78 \cdot 10^{-245}:\\
            \;\;\;\;y \cdot 0.8862269254527579\\
            
            \mathbf{else}:\\
            \;\;\;\;x\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if x < -1.15e-197 or 1.78e-245 < x

              1. Initial program 96.7%

                \[x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \]
              2. Taylor expanded in x around inf

                \[\leadsto \color{blue}{x} \]
              3. Step-by-step derivation
                1. Applied rewrites76.2%

                  \[\leadsto \color{blue}{x} \]

                if -1.15e-197 < x < 1.78e-245

                1. Initial program 90.7%

                  \[x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \]
                2. Taylor expanded in x around 0

                  \[\leadsto \color{blue}{\frac{5000000000000000}{5641895835477563} \cdot \frac{y}{e^{z}}} \]
                3. Step-by-step derivation
                  1. *-commutativeN/A

                    \[\leadsto \frac{y}{e^{z}} \cdot \color{blue}{\frac{5000000000000000}{5641895835477563}} \]
                  2. lower-*.f64N/A

                    \[\leadsto \frac{y}{e^{z}} \cdot \color{blue}{\frac{5000000000000000}{5641895835477563}} \]
                  3. lower-/.f64N/A

                    \[\leadsto \frac{y}{e^{z}} \cdot \frac{5000000000000000}{5641895835477563} \]
                  4. lift-exp.f6445.6

                    \[\leadsto \frac{y}{e^{z}} \cdot 0.8862269254527579 \]
                4. Applied rewrites45.6%

                  \[\leadsto \color{blue}{\frac{y}{e^{z}} \cdot 0.8862269254527579} \]
                5. Taylor expanded in z around 0

                  \[\leadsto y \cdot \frac{5000000000000000}{5641895835477563} \]
                6. Step-by-step derivation
                  1. Applied rewrites43.0%

                    \[\leadsto y \cdot 0.8862269254527579 \]
                7. Recombined 2 regimes into one program.
                8. Add Preprocessing

                Alternative 5: 69.6% accurate, 25.8× speedup?

                \[\begin{array}{l} \\ x \end{array} \]
                (FPCore (x y z) :precision binary64 x)
                double code(double x, double y, double z) {
                	return x;
                }
                
                module fmin_fmax_functions
                    implicit none
                    private
                    public fmax
                    public fmin
                
                    interface fmax
                        module procedure fmax88
                        module procedure fmax44
                        module procedure fmax84
                        module procedure fmax48
                    end interface
                    interface fmin
                        module procedure fmin88
                        module procedure fmin44
                        module procedure fmin84
                        module procedure fmin48
                    end interface
                contains
                    real(8) function fmax88(x, y) result (res)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                    end function
                    real(4) function fmax44(x, y) result (res)
                        real(4), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                    end function
                    real(8) function fmax84(x, y) result(res)
                        real(8), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                    end function
                    real(8) function fmax48(x, y) result(res)
                        real(4), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                    end function
                    real(8) function fmin88(x, y) result (res)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                    end function
                    real(4) function fmin44(x, y) result (res)
                        real(4), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                    end function
                    real(8) function fmin84(x, y) result(res)
                        real(8), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                    end function
                    real(8) function fmin48(x, y) result(res)
                        real(4), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                    end function
                end module
                
                real(8) function code(x, y, z)
                use fmin_fmax_functions
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    real(8), intent (in) :: z
                    code = x
                end function
                
                public static double code(double x, double y, double z) {
                	return x;
                }
                
                def code(x, y, z):
                	return x
                
                function code(x, y, z)
                	return x
                end
                
                function tmp = code(x, y, z)
                	tmp = x;
                end
                
                code[x_, y_, z_] := x
                
                \begin{array}{l}
                
                \\
                x
                \end{array}
                
                Derivation
                1. Initial program 95.8%

                  \[x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \]
                2. Taylor expanded in x around inf

                  \[\leadsto \color{blue}{x} \]
                3. Step-by-step derivation
                  1. Applied rewrites69.6%

                    \[\leadsto \color{blue}{x} \]
                  2. Add Preprocessing

                  Reproduce

                  ?
                  herbie shell --seed 2025115 
                  (FPCore (x y z)
                    :name "Numeric.SpecFunctions:invErfc from math-functions-0.1.5.2, A"
                    :precision binary64
                    (+ x (/ y (- (* 1.1283791670955126 (exp z)) (* x y)))))