Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1

Percentage Accurate: 88.4% → 99.9%
Time: 4.7s
Alternatives: 13
Speedup: 0.8×

Specification

?
\[\begin{array}{l} \\ \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \end{array} \]
(FPCore (x y) :precision binary64 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))
double code(double x, double y) {
	return (x * ((x / y) + 1.0)) / (x + 1.0);
}
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)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
end function
public static double code(double x, double y) {
	return (x * ((x / y) + 1.0)) / (x + 1.0);
}
def code(x, y):
	return (x * ((x / y) + 1.0)) / (x + 1.0)
function code(x, y)
	return Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0))
end
function tmp = code(x, y)
	tmp = (x * ((x / y) + 1.0)) / (x + 1.0);
end
code[x_, y_] := N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}
\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 13 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: 88.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \end{array} \]
(FPCore (x y) :precision binary64 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))
double code(double x, double y) {
	return (x * ((x / y) + 1.0)) / (x + 1.0);
}
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)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
end function
public static double code(double x, double y) {
	return (x * ((x / y) + 1.0)) / (x + 1.0);
}
def code(x, y):
	return (x * ((x / y) + 1.0)) / (x + 1.0)
function code(x, y)
	return Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0))
end
function tmp = code(x, y)
	tmp = (x * ((x / y) + 1.0)) / (x + 1.0);
end
code[x_, y_] := N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}
\end{array}

Alternative 1: 99.9% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -7500000000000:\\ \;\;\;\;\frac{x - 1}{y} - -1\\ \mathbf{elif}\;x \leq 3 \cdot 10^{+16}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x - -1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} - -1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -7500000000000.0)
   (- (/ (- x 1.0) y) -1.0)
   (if (<= x 3e+16) (/ (fma (/ x y) x x) (- x -1.0)) (- (/ x y) -1.0))))
double code(double x, double y) {
	double tmp;
	if (x <= -7500000000000.0) {
		tmp = ((x - 1.0) / y) - -1.0;
	} else if (x <= 3e+16) {
		tmp = fma((x / y), x, x) / (x - -1.0);
	} else {
		tmp = (x / y) - -1.0;
	}
	return tmp;
}
function code(x, y)
	tmp = 0.0
	if (x <= -7500000000000.0)
		tmp = Float64(Float64(Float64(x - 1.0) / y) - -1.0);
	elseif (x <= 3e+16)
		tmp = Float64(fma(Float64(x / y), x, x) / Float64(x - -1.0));
	else
		tmp = Float64(Float64(x / y) - -1.0);
	end
	return tmp
end
code[x_, y_] := If[LessEqual[x, -7500000000000.0], N[(N[(N[(x - 1.0), $MachinePrecision] / y), $MachinePrecision] - -1.0), $MachinePrecision], If[LessEqual[x, 3e+16], N[(N[(N[(x / y), $MachinePrecision] * x + x), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] - -1.0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -7500000000000:\\
\;\;\;\;\frac{x - 1}{y} - -1\\

\mathbf{elif}\;x \leq 3 \cdot 10^{+16}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x - -1}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{y} - -1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -7.5e12

    1. Initial program 76.4%

      \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
    2. Taylor expanded in x around inf

      \[\leadsto \color{blue}{x \cdot \left(\left(\frac{1}{x} + \frac{1}{y}\right) - \frac{1}{x \cdot y}\right)} \]
    3. Step-by-step derivation
      1. associate--l+N/A

        \[\leadsto x \cdot \left(\frac{1}{x} + \color{blue}{\left(\frac{1}{y} - \frac{1}{x \cdot y}\right)}\right) \]
      2. +-commutativeN/A

        \[\leadsto x \cdot \left(\left(\frac{1}{y} - \frac{1}{x \cdot y}\right) + \color{blue}{\frac{1}{x}}\right) \]
      3. distribute-rgt-inN/A

        \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + \color{blue}{\frac{1}{x} \cdot x} \]
      4. lft-mult-inverseN/A

        \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + 1 \]
      5. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{1}{x \cdot y}, \color{blue}{x}, 1\right) \]
      6. associate-/r*N/A

        \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{\frac{1}{x}}{y}, x, 1\right) \]
      7. sub-divN/A

        \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
      8. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
      9. lower--.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
      10. lower-/.f6499.7

        \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
    4. Applied rewrites99.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right)} \]
    5. Taylor expanded in x around 0

      \[\leadsto \left(1 + \frac{x}{y}\right) - \color{blue}{\frac{1}{y}} \]
    6. Step-by-step derivation
      1. associate--l+N/A

        \[\leadsto 1 + \left(\frac{x}{y} - \color{blue}{\frac{1}{y}}\right) \]
      2. +-commutativeN/A

        \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) + 1 \]
      3. metadata-evalN/A

        \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) + -1 \cdot -1 \]
      4. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - \left(\mathsf{neg}\left(-1\right)\right) \cdot \color{blue}{-1} \]
      5. metadata-evalN/A

        \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - 1 \cdot -1 \]
      6. metadata-evalN/A

        \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - -1 \]
      7. lower--.f64N/A

        \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - -1 \]
      8. sub-divN/A

        \[\leadsto \frac{x - 1}{y} - -1 \]
      9. lower-/.f64N/A

        \[\leadsto \frac{x - 1}{y} - -1 \]
      10. lower--.f64100.0

        \[\leadsto \frac{x - 1}{y} - -1 \]
    7. Applied rewrites100.0%

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

    if -7.5e12 < x < 3e16

    1. Initial program 99.8%

      \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{x \cdot \left(\frac{x}{y} + 1\right)}}{x + 1} \]
      2. lift-+.f64N/A

        \[\leadsto \frac{x \cdot \color{blue}{\left(\frac{x}{y} + 1\right)}}{x + 1} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{x \cdot \left(\color{blue}{\frac{x}{y}} + 1\right)}{x + 1} \]
      4. distribute-rgt-inN/A

        \[\leadsto \frac{\color{blue}{\frac{x}{y} \cdot x + 1 \cdot x}}{x + 1} \]
      5. *-lft-identityN/A

        \[\leadsto \frac{\frac{x}{y} \cdot x + \color{blue}{x}}{x + 1} \]
      6. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}}{x + 1} \]
      7. lift-/.f6499.8

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{x}{y}}, x, x\right)}{x + 1} \]
      8. lift-+.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{\color{blue}{x + 1}} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{\color{blue}{1 + x}} \]
      10. rgt-mult-inverseN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{\color{blue}{x \cdot \frac{1}{x}} + x} \]
      11. *-rgt-identityN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x \cdot \frac{1}{x} + \color{blue}{x \cdot 1}} \]
      12. distribute-lft-inN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{\color{blue}{x \cdot \left(\frac{1}{x} + 1\right)}} \]
      13. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x \cdot \color{blue}{\left(1 + \frac{1}{x}\right)}} \]
      14. distribute-rgt-inN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{\color{blue}{1 \cdot x + \frac{1}{x} \cdot x}} \]
      15. *-lft-identityN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{\color{blue}{x} + \frac{1}{x} \cdot x} \]
      16. lft-mult-inverseN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x + \color{blue}{1}} \]
      17. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x + \color{blue}{1 \cdot 1}} \]
      18. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{\color{blue}{x - \left(\mathsf{neg}\left(1\right)\right) \cdot 1}} \]
      19. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x - \color{blue}{-1} \cdot 1} \]
      20. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x - \color{blue}{-1}} \]
      21. lower--.f6499.8

        \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{\color{blue}{x - -1}} \]
    3. Applied rewrites99.8%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x - -1}} \]

    if 3e16 < x

    1. Initial program 76.0%

      \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
    2. Taylor expanded in x around inf

      \[\leadsto \color{blue}{x \cdot \left(\left(\frac{1}{x} + \frac{1}{y}\right) - \frac{1}{x \cdot y}\right)} \]
    3. Step-by-step derivation
      1. associate--l+N/A

        \[\leadsto x \cdot \left(\frac{1}{x} + \color{blue}{\left(\frac{1}{y} - \frac{1}{x \cdot y}\right)}\right) \]
      2. +-commutativeN/A

        \[\leadsto x \cdot \left(\left(\frac{1}{y} - \frac{1}{x \cdot y}\right) + \color{blue}{\frac{1}{x}}\right) \]
      3. distribute-rgt-inN/A

        \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + \color{blue}{\frac{1}{x} \cdot x} \]
      4. lft-mult-inverseN/A

        \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + 1 \]
      5. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{1}{x \cdot y}, \color{blue}{x}, 1\right) \]
      6. associate-/r*N/A

        \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{\frac{1}{x}}{y}, x, 1\right) \]
      7. sub-divN/A

        \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
      8. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
      9. lower--.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
      10. lower-/.f6499.8

        \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
    4. Applied rewrites99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right)} \]
    5. Taylor expanded in x around 0

      \[\leadsto \left(1 + \frac{x}{y}\right) - \color{blue}{\frac{1}{y}} \]
    6. Step-by-step derivation
      1. associate--l+N/A

        \[\leadsto 1 + \left(\frac{x}{y} - \color{blue}{\frac{1}{y}}\right) \]
      2. +-commutativeN/A

        \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) + 1 \]
      3. metadata-evalN/A

        \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) + -1 \cdot -1 \]
      4. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - \left(\mathsf{neg}\left(-1\right)\right) \cdot \color{blue}{-1} \]
      5. metadata-evalN/A

        \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - 1 \cdot -1 \]
      6. metadata-evalN/A

        \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - -1 \]
      7. lower--.f64N/A

        \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - -1 \]
      8. sub-divN/A

        \[\leadsto \frac{x - 1}{y} - -1 \]
      9. lower-/.f64N/A

        \[\leadsto \frac{x - 1}{y} - -1 \]
      10. lower--.f64100.0

        \[\leadsto \frac{x - 1}{y} - -1 \]
    7. Applied rewrites100.0%

      \[\leadsto \frac{x - 1}{y} - \color{blue}{-1} \]
    8. Taylor expanded in x around inf

      \[\leadsto \frac{x}{y} - -1 \]
    9. Step-by-step derivation
      1. Applied rewrites100.0%

        \[\leadsto \frac{x}{y} - -1 \]
    10. Recombined 3 regimes into one program.
    11. Add Preprocessing

    Alternative 2: 99.9% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -3400000000000:\\ \;\;\;\;\frac{x - 1}{y} - -1\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{+14}:\\ \;\;\;\;x \cdot \frac{y + x}{\mathsf{fma}\left(y, x, y\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} - -1\\ \end{array} \end{array} \]
    (FPCore (x y)
     :precision binary64
     (if (<= x -3400000000000.0)
       (- (/ (- x 1.0) y) -1.0)
       (if (<= x 6.5e+14) (* x (/ (+ y x) (fma y x y))) (- (/ x y) -1.0))))
    double code(double x, double y) {
    	double tmp;
    	if (x <= -3400000000000.0) {
    		tmp = ((x - 1.0) / y) - -1.0;
    	} else if (x <= 6.5e+14) {
    		tmp = x * ((y + x) / fma(y, x, y));
    	} else {
    		tmp = (x / y) - -1.0;
    	}
    	return tmp;
    }
    
    function code(x, y)
    	tmp = 0.0
    	if (x <= -3400000000000.0)
    		tmp = Float64(Float64(Float64(x - 1.0) / y) - -1.0);
    	elseif (x <= 6.5e+14)
    		tmp = Float64(x * Float64(Float64(y + x) / fma(y, x, y)));
    	else
    		tmp = Float64(Float64(x / y) - -1.0);
    	end
    	return tmp
    end
    
    code[x_, y_] := If[LessEqual[x, -3400000000000.0], N[(N[(N[(x - 1.0), $MachinePrecision] / y), $MachinePrecision] - -1.0), $MachinePrecision], If[LessEqual[x, 6.5e+14], N[(x * N[(N[(y + x), $MachinePrecision] / N[(y * x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] - -1.0), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;x \leq -3400000000000:\\
    \;\;\;\;\frac{x - 1}{y} - -1\\
    
    \mathbf{elif}\;x \leq 6.5 \cdot 10^{+14}:\\
    \;\;\;\;x \cdot \frac{y + x}{\mathsf{fma}\left(y, x, y\right)}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{x}{y} - -1\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if x < -3.4e12

      1. Initial program 76.4%

        \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
      2. Taylor expanded in x around inf

        \[\leadsto \color{blue}{x \cdot \left(\left(\frac{1}{x} + \frac{1}{y}\right) - \frac{1}{x \cdot y}\right)} \]
      3. Step-by-step derivation
        1. associate--l+N/A

          \[\leadsto x \cdot \left(\frac{1}{x} + \color{blue}{\left(\frac{1}{y} - \frac{1}{x \cdot y}\right)}\right) \]
        2. +-commutativeN/A

          \[\leadsto x \cdot \left(\left(\frac{1}{y} - \frac{1}{x \cdot y}\right) + \color{blue}{\frac{1}{x}}\right) \]
        3. distribute-rgt-inN/A

          \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + \color{blue}{\frac{1}{x} \cdot x} \]
        4. lft-mult-inverseN/A

          \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + 1 \]
        5. lower-fma.f64N/A

          \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{1}{x \cdot y}, \color{blue}{x}, 1\right) \]
        6. associate-/r*N/A

          \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{\frac{1}{x}}{y}, x, 1\right) \]
        7. sub-divN/A

          \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
        8. lower-/.f64N/A

          \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
        9. lower--.f64N/A

          \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
        10. lower-/.f6499.7

          \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
      4. Applied rewrites99.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right)} \]
      5. Taylor expanded in x around 0

        \[\leadsto \left(1 + \frac{x}{y}\right) - \color{blue}{\frac{1}{y}} \]
      6. Step-by-step derivation
        1. associate--l+N/A

          \[\leadsto 1 + \left(\frac{x}{y} - \color{blue}{\frac{1}{y}}\right) \]
        2. +-commutativeN/A

          \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) + 1 \]
        3. metadata-evalN/A

          \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) + -1 \cdot -1 \]
        4. fp-cancel-sign-sub-invN/A

          \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - \left(\mathsf{neg}\left(-1\right)\right) \cdot \color{blue}{-1} \]
        5. metadata-evalN/A

          \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - 1 \cdot -1 \]
        6. metadata-evalN/A

          \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - -1 \]
        7. lower--.f64N/A

          \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - -1 \]
        8. sub-divN/A

          \[\leadsto \frac{x - 1}{y} - -1 \]
        9. lower-/.f64N/A

          \[\leadsto \frac{x - 1}{y} - -1 \]
        10. lower--.f64100.0

          \[\leadsto \frac{x - 1}{y} - -1 \]
      7. Applied rewrites100.0%

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

      if -3.4e12 < x < 6.5e14

      1. Initial program 99.8%

        \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
      2. Applied rewrites99.8%

        \[\leadsto \color{blue}{x \cdot \frac{y + x}{\mathsf{fma}\left(y, x, y\right)}} \]

      if 6.5e14 < x

      1. Initial program 76.2%

        \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
      2. Taylor expanded in x around inf

        \[\leadsto \color{blue}{x \cdot \left(\left(\frac{1}{x} + \frac{1}{y}\right) - \frac{1}{x \cdot y}\right)} \]
      3. Step-by-step derivation
        1. associate--l+N/A

          \[\leadsto x \cdot \left(\frac{1}{x} + \color{blue}{\left(\frac{1}{y} - \frac{1}{x \cdot y}\right)}\right) \]
        2. +-commutativeN/A

          \[\leadsto x \cdot \left(\left(\frac{1}{y} - \frac{1}{x \cdot y}\right) + \color{blue}{\frac{1}{x}}\right) \]
        3. distribute-rgt-inN/A

          \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + \color{blue}{\frac{1}{x} \cdot x} \]
        4. lft-mult-inverseN/A

          \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + 1 \]
        5. lower-fma.f64N/A

          \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{1}{x \cdot y}, \color{blue}{x}, 1\right) \]
        6. associate-/r*N/A

          \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{\frac{1}{x}}{y}, x, 1\right) \]
        7. sub-divN/A

          \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
        8. lower-/.f64N/A

          \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
        9. lower--.f64N/A

          \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
        10. lower-/.f6499.8

          \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
      4. Applied rewrites99.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right)} \]
      5. Taylor expanded in x around 0

        \[\leadsto \left(1 + \frac{x}{y}\right) - \color{blue}{\frac{1}{y}} \]
      6. Step-by-step derivation
        1. associate--l+N/A

          \[\leadsto 1 + \left(\frac{x}{y} - \color{blue}{\frac{1}{y}}\right) \]
        2. +-commutativeN/A

          \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) + 1 \]
        3. metadata-evalN/A

          \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) + -1 \cdot -1 \]
        4. fp-cancel-sign-sub-invN/A

          \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - \left(\mathsf{neg}\left(-1\right)\right) \cdot \color{blue}{-1} \]
        5. metadata-evalN/A

          \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - 1 \cdot -1 \]
        6. metadata-evalN/A

          \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - -1 \]
        7. lower--.f64N/A

          \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - -1 \]
        8. sub-divN/A

          \[\leadsto \frac{x - 1}{y} - -1 \]
        9. lower-/.f64N/A

          \[\leadsto \frac{x - 1}{y} - -1 \]
        10. lower--.f64100.0

          \[\leadsto \frac{x - 1}{y} - -1 \]
      7. Applied rewrites100.0%

        \[\leadsto \frac{x - 1}{y} - \color{blue}{-1} \]
      8. Taylor expanded in x around inf

        \[\leadsto \frac{x}{y} - -1 \]
      9. Step-by-step derivation
        1. Applied rewrites100.0%

          \[\leadsto \frac{x}{y} - -1 \]
      10. Recombined 3 regimes into one program.
      11. Add Preprocessing

      Alternative 3: 98.2% accurate, 0.8× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x - 1}{y} - -1\\ \mathbf{if}\;x \leq -1:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1.3:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{1}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
      (FPCore (x y)
       :precision binary64
       (let* ((t_0 (- (/ (- x 1.0) y) -1.0)))
         (if (<= x -1.0) t_0 (if (<= x 1.3) (/ (fma (/ x y) x x) 1.0) t_0))))
      double code(double x, double y) {
      	double t_0 = ((x - 1.0) / y) - -1.0;
      	double tmp;
      	if (x <= -1.0) {
      		tmp = t_0;
      	} else if (x <= 1.3) {
      		tmp = fma((x / y), x, x) / 1.0;
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      function code(x, y)
      	t_0 = Float64(Float64(Float64(x - 1.0) / y) - -1.0)
      	tmp = 0.0
      	if (x <= -1.0)
      		tmp = t_0;
      	elseif (x <= 1.3)
      		tmp = Float64(fma(Float64(x / y), x, x) / 1.0);
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      code[x_, y_] := Block[{t$95$0 = N[(N[(N[(x - 1.0), $MachinePrecision] / y), $MachinePrecision] - -1.0), $MachinePrecision]}, If[LessEqual[x, -1.0], t$95$0, If[LessEqual[x, 1.3], N[(N[(N[(x / y), $MachinePrecision] * x + x), $MachinePrecision] / 1.0), $MachinePrecision], t$95$0]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \frac{x - 1}{y} - -1\\
      \mathbf{if}\;x \leq -1:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;x \leq 1.3:\\
      \;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{1}\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < -1 or 1.30000000000000004 < x

        1. Initial program 77.3%

          \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
        2. Taylor expanded in x around inf

          \[\leadsto \color{blue}{x \cdot \left(\left(\frac{1}{x} + \frac{1}{y}\right) - \frac{1}{x \cdot y}\right)} \]
        3. Step-by-step derivation
          1. associate--l+N/A

            \[\leadsto x \cdot \left(\frac{1}{x} + \color{blue}{\left(\frac{1}{y} - \frac{1}{x \cdot y}\right)}\right) \]
          2. +-commutativeN/A

            \[\leadsto x \cdot \left(\left(\frac{1}{y} - \frac{1}{x \cdot y}\right) + \color{blue}{\frac{1}{x}}\right) \]
          3. distribute-rgt-inN/A

            \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + \color{blue}{\frac{1}{x} \cdot x} \]
          4. lft-mult-inverseN/A

            \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + 1 \]
          5. lower-fma.f64N/A

            \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{1}{x \cdot y}, \color{blue}{x}, 1\right) \]
          6. associate-/r*N/A

            \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{\frac{1}{x}}{y}, x, 1\right) \]
          7. sub-divN/A

            \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
          8. lower-/.f64N/A

            \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
          9. lower--.f64N/A

            \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
          10. lower-/.f6498.3

            \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
        4. Applied rewrites98.3%

          \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right)} \]
        5. Taylor expanded in x around 0

          \[\leadsto \left(1 + \frac{x}{y}\right) - \color{blue}{\frac{1}{y}} \]
        6. Step-by-step derivation
          1. associate--l+N/A

            \[\leadsto 1 + \left(\frac{x}{y} - \color{blue}{\frac{1}{y}}\right) \]
          2. +-commutativeN/A

            \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) + 1 \]
          3. metadata-evalN/A

            \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) + -1 \cdot -1 \]
          4. fp-cancel-sign-sub-invN/A

            \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - \left(\mathsf{neg}\left(-1\right)\right) \cdot \color{blue}{-1} \]
          5. metadata-evalN/A

            \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - 1 \cdot -1 \]
          6. metadata-evalN/A

            \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - -1 \]
          7. lower--.f64N/A

            \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - -1 \]
          8. sub-divN/A

            \[\leadsto \frac{x - 1}{y} - -1 \]
          9. lower-/.f64N/A

            \[\leadsto \frac{x - 1}{y} - -1 \]
          10. lower--.f6498.5

            \[\leadsto \frac{x - 1}{y} - -1 \]
        7. Applied rewrites98.5%

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

        if -1 < x < 1.30000000000000004

        1. Initial program 99.9%

          \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
        2. Step-by-step derivation
          1. lift-*.f64N/A

            \[\leadsto \frac{\color{blue}{x \cdot \left(\frac{x}{y} + 1\right)}}{x + 1} \]
          2. lift-+.f64N/A

            \[\leadsto \frac{x \cdot \color{blue}{\left(\frac{x}{y} + 1\right)}}{x + 1} \]
          3. lift-/.f64N/A

            \[\leadsto \frac{x \cdot \left(\color{blue}{\frac{x}{y}} + 1\right)}{x + 1} \]
          4. distribute-rgt-inN/A

            \[\leadsto \frac{\color{blue}{\frac{x}{y} \cdot x + 1 \cdot x}}{x + 1} \]
          5. *-lft-identityN/A

            \[\leadsto \frac{\frac{x}{y} \cdot x + \color{blue}{x}}{x + 1} \]
          6. lower-fma.f64N/A

            \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}}{x + 1} \]
          7. lift-/.f6499.9

            \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{x}{y}}, x, x\right)}{x + 1} \]
          8. lift-+.f64N/A

            \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{\color{blue}{x + 1}} \]
          9. +-commutativeN/A

            \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{\color{blue}{1 + x}} \]
          10. rgt-mult-inverseN/A

            \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{\color{blue}{x \cdot \frac{1}{x}} + x} \]
          11. *-rgt-identityN/A

            \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x \cdot \frac{1}{x} + \color{blue}{x \cdot 1}} \]
          12. distribute-lft-inN/A

            \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{\color{blue}{x \cdot \left(\frac{1}{x} + 1\right)}} \]
          13. +-commutativeN/A

            \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x \cdot \color{blue}{\left(1 + \frac{1}{x}\right)}} \]
          14. distribute-rgt-inN/A

            \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{\color{blue}{1 \cdot x + \frac{1}{x} \cdot x}} \]
          15. *-lft-identityN/A

            \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{\color{blue}{x} + \frac{1}{x} \cdot x} \]
          16. lft-mult-inverseN/A

            \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x + \color{blue}{1}} \]
          17. metadata-evalN/A

            \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x + \color{blue}{1 \cdot 1}} \]
          18. fp-cancel-sign-sub-invN/A

            \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{\color{blue}{x - \left(\mathsf{neg}\left(1\right)\right) \cdot 1}} \]
          19. metadata-evalN/A

            \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x - \color{blue}{-1} \cdot 1} \]
          20. metadata-evalN/A

            \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x - \color{blue}{-1}} \]
          21. lower--.f6499.9

            \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{\color{blue}{x - -1}} \]
        3. Applied rewrites99.9%

          \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x - -1}} \]
        4. Taylor expanded in x around 0

          \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{\color{blue}{1}} \]
        5. Step-by-step derivation
          1. Applied rewrites97.9%

            \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{\color{blue}{1}} \]
        6. Recombined 2 regimes into one program.
        7. Add Preprocessing

        Alternative 4: 88.6% accurate, 0.2× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \frac{x}{\mathsf{fma}\left(y, x, y\right)}\\ t_1 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\ \mathbf{if}\;t\_1 \leq -1 \cdot 10^{+213}:\\ \;\;\;\;\frac{x - 1}{y}\\ \mathbf{elif}\;t\_1 \leq -5 \cdot 10^{-64}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_1 \leq 2:\\ \;\;\;\;\frac{x}{x - -1}\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+206}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array} \]
        (FPCore (x y)
         :precision binary64
         (let* ((t_0 (* x (/ x (fma y x y))))
                (t_1 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
           (if (<= t_1 -1e+213)
             (/ (- x 1.0) y)
             (if (<= t_1 -5e-64)
               t_0
               (if (<= t_1 2.0) (/ x (- x -1.0)) (if (<= t_1 5e+206) t_0 (/ x y)))))))
        double code(double x, double y) {
        	double t_0 = x * (x / fma(y, x, y));
        	double t_1 = (x * ((x / y) + 1.0)) / (x + 1.0);
        	double tmp;
        	if (t_1 <= -1e+213) {
        		tmp = (x - 1.0) / y;
        	} else if (t_1 <= -5e-64) {
        		tmp = t_0;
        	} else if (t_1 <= 2.0) {
        		tmp = x / (x - -1.0);
        	} else if (t_1 <= 5e+206) {
        		tmp = t_0;
        	} else {
        		tmp = x / y;
        	}
        	return tmp;
        }
        
        function code(x, y)
        	t_0 = Float64(x * Float64(x / fma(y, x, y)))
        	t_1 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0))
        	tmp = 0.0
        	if (t_1 <= -1e+213)
        		tmp = Float64(Float64(x - 1.0) / y);
        	elseif (t_1 <= -5e-64)
        		tmp = t_0;
        	elseif (t_1 <= 2.0)
        		tmp = Float64(x / Float64(x - -1.0));
        	elseif (t_1 <= 5e+206)
        		tmp = t_0;
        	else
        		tmp = Float64(x / y);
        	end
        	return tmp
        end
        
        code[x_, y_] := Block[{t$95$0 = N[(x * N[(x / N[(y * x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+213], N[(N[(x - 1.0), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[t$95$1, -5e-64], t$95$0, If[LessEqual[t$95$1, 2.0], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+206], t$95$0, N[(x / y), $MachinePrecision]]]]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := x \cdot \frac{x}{\mathsf{fma}\left(y, x, y\right)}\\
        t_1 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
        \mathbf{if}\;t\_1 \leq -1 \cdot 10^{+213}:\\
        \;\;\;\;\frac{x - 1}{y}\\
        
        \mathbf{elif}\;t\_1 \leq -5 \cdot 10^{-64}:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;t\_1 \leq 2:\\
        \;\;\;\;\frac{x}{x - -1}\\
        
        \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+206}:\\
        \;\;\;\;t\_0\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{x}{y}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 4 regimes
        2. if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -9.99999999999999984e212

          1. Initial program 55.5%

            \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
          2. Taylor expanded in x around inf

            \[\leadsto \color{blue}{x \cdot \left(\left(\frac{1}{x} + \frac{1}{y}\right) - \frac{1}{x \cdot y}\right)} \]
          3. Step-by-step derivation
            1. associate--l+N/A

              \[\leadsto x \cdot \left(\frac{1}{x} + \color{blue}{\left(\frac{1}{y} - \frac{1}{x \cdot y}\right)}\right) \]
            2. +-commutativeN/A

              \[\leadsto x \cdot \left(\left(\frac{1}{y} - \frac{1}{x \cdot y}\right) + \color{blue}{\frac{1}{x}}\right) \]
            3. distribute-rgt-inN/A

              \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + \color{blue}{\frac{1}{x} \cdot x} \]
            4. lft-mult-inverseN/A

              \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + 1 \]
            5. lower-fma.f64N/A

              \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{1}{x \cdot y}, \color{blue}{x}, 1\right) \]
            6. associate-/r*N/A

              \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{\frac{1}{x}}{y}, x, 1\right) \]
            7. sub-divN/A

              \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
            8. lower-/.f64N/A

              \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
            9. lower--.f64N/A

              \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
            10. lower-/.f6497.5

              \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
          4. Applied rewrites97.5%

            \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right)} \]
          5. Taylor expanded in x around 0

            \[\leadsto \left(1 + \frac{x}{y}\right) - \color{blue}{\frac{1}{y}} \]
          6. Step-by-step derivation
            1. associate--l+N/A

              \[\leadsto 1 + \left(\frac{x}{y} - \color{blue}{\frac{1}{y}}\right) \]
            2. +-commutativeN/A

              \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) + 1 \]
            3. metadata-evalN/A

              \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) + -1 \cdot -1 \]
            4. fp-cancel-sign-sub-invN/A

              \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - \left(\mathsf{neg}\left(-1\right)\right) \cdot \color{blue}{-1} \]
            5. metadata-evalN/A

              \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - 1 \cdot -1 \]
            6. metadata-evalN/A

              \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - -1 \]
            7. lower--.f64N/A

              \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - -1 \]
            8. sub-divN/A

              \[\leadsto \frac{x - 1}{y} - -1 \]
            9. lower-/.f64N/A

              \[\leadsto \frac{x - 1}{y} - -1 \]
            10. lower--.f6497.7

              \[\leadsto \frac{x - 1}{y} - -1 \]
          7. Applied rewrites97.7%

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

            \[\leadsto \frac{x - 1}{y} \]
          9. Step-by-step derivation
            1. lift-/.f64N/A

              \[\leadsto \frac{x - 1}{y} \]
            2. lift--.f6497.7

              \[\leadsto \frac{x - 1}{y} \]
          10. Applied rewrites97.7%

            \[\leadsto \frac{x - 1}{y} \]

          if -9.99999999999999984e212 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -5.00000000000000033e-64 or 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 5.0000000000000002e206

          1. Initial program 99.8%

            \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
          2. Taylor expanded in y around 0

            \[\leadsto \color{blue}{\frac{{x}^{2}}{y \cdot \left(1 + x\right)}} \]
          3. Step-by-step derivation
            1. unpow2N/A

              \[\leadsto \frac{x \cdot x}{\color{blue}{y} \cdot \left(1 + x\right)} \]
            2. associate-/l*N/A

              \[\leadsto x \cdot \color{blue}{\frac{x}{y \cdot \left(1 + x\right)}} \]
            3. lower-*.f64N/A

              \[\leadsto x \cdot \color{blue}{\frac{x}{y \cdot \left(1 + x\right)}} \]
            4. lower-/.f64N/A

              \[\leadsto x \cdot \frac{x}{\color{blue}{y \cdot \left(1 + x\right)}} \]
            5. +-commutativeN/A

              \[\leadsto x \cdot \frac{x}{y \cdot \left(x + \color{blue}{1}\right)} \]
            6. distribute-lft-inN/A

              \[\leadsto x \cdot \frac{x}{y \cdot x + \color{blue}{y \cdot 1}} \]
            7. *-rgt-identityN/A

              \[\leadsto x \cdot \frac{x}{y \cdot x + y} \]
            8. lower-fma.f6475.8

              \[\leadsto x \cdot \frac{x}{\mathsf{fma}\left(y, \color{blue}{x}, y\right)} \]
          4. Applied rewrites75.8%

            \[\leadsto \color{blue}{x \cdot \frac{x}{\mathsf{fma}\left(y, x, y\right)}} \]

          if -5.00000000000000033e-64 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2

          1. Initial program 99.9%

            \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
          2. Taylor expanded in y around inf

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

              \[\leadsto \frac{x}{\color{blue}{1 + x}} \]
            2. rgt-mult-inverseN/A

              \[\leadsto \frac{x}{x \cdot \frac{1}{x} + x} \]
            3. *-rgt-identityN/A

              \[\leadsto \frac{x}{x \cdot \frac{1}{x} + x \cdot \color{blue}{1}} \]
            4. distribute-lft-inN/A

              \[\leadsto \frac{x}{x \cdot \color{blue}{\left(\frac{1}{x} + 1\right)}} \]
            5. +-commutativeN/A

              \[\leadsto \frac{x}{x \cdot \left(1 + \color{blue}{\frac{1}{x}}\right)} \]
            6. distribute-rgt-inN/A

              \[\leadsto \frac{x}{1 \cdot x + \color{blue}{\frac{1}{x} \cdot x}} \]
            7. *-lft-identityN/A

              \[\leadsto \frac{x}{x + \color{blue}{\frac{1}{x}} \cdot x} \]
            8. lft-mult-inverseN/A

              \[\leadsto \frac{x}{x + 1} \]
            9. metadata-evalN/A

              \[\leadsto \frac{x}{x + 1 \cdot \color{blue}{1}} \]
            10. fp-cancel-sign-sub-invN/A

              \[\leadsto \frac{x}{x - \color{blue}{\left(\mathsf{neg}\left(1\right)\right) \cdot 1}} \]
            11. metadata-evalN/A

              \[\leadsto \frac{x}{x - -1 \cdot 1} \]
            12. metadata-evalN/A

              \[\leadsto \frac{x}{x - -1} \]
            13. lower--.f6489.6

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

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

          if 5.0000000000000002e206 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64)))

          1. Initial program 99.8%

            \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
          2. Taylor expanded in x around inf

            \[\leadsto \color{blue}{\frac{x}{y}} \]
          3. Step-by-step derivation
            1. lift-/.f6452.1

              \[\leadsto \frac{x}{\color{blue}{y}} \]
          4. Applied rewrites52.1%

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

        Alternative 5: 86.9% accurate, 0.8× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x - 1}{y} - -1\\ \mathbf{if}\;x \leq -1:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -2.9 \cdot 10^{-63}:\\ \;\;\;\;\frac{x \cdot x}{y}\\ \mathbf{elif}\;x \leq 220:\\ \;\;\;\;\frac{x}{x - -1}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
        (FPCore (x y)
         :precision binary64
         (let* ((t_0 (- (/ (- x 1.0) y) -1.0)))
           (if (<= x -1.0)
             t_0
             (if (<= x -2.9e-63)
               (/ (* x x) y)
               (if (<= x 220.0) (/ x (- x -1.0)) t_0)))))
        double code(double x, double y) {
        	double t_0 = ((x - 1.0) / y) - -1.0;
        	double tmp;
        	if (x <= -1.0) {
        		tmp = t_0;
        	} else if (x <= -2.9e-63) {
        		tmp = (x * x) / y;
        	} else if (x <= 220.0) {
        		tmp = x / (x - -1.0);
        	} 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)
        use fmin_fmax_functions
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            real(8) :: t_0
            real(8) :: tmp
            t_0 = ((x - 1.0d0) / y) - (-1.0d0)
            if (x <= (-1.0d0)) then
                tmp = t_0
            else if (x <= (-2.9d-63)) then
                tmp = (x * x) / y
            else if (x <= 220.0d0) then
                tmp = x / (x - (-1.0d0))
            else
                tmp = t_0
            end if
            code = tmp
        end function
        
        public static double code(double x, double y) {
        	double t_0 = ((x - 1.0) / y) - -1.0;
        	double tmp;
        	if (x <= -1.0) {
        		tmp = t_0;
        	} else if (x <= -2.9e-63) {
        		tmp = (x * x) / y;
        	} else if (x <= 220.0) {
        		tmp = x / (x - -1.0);
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        def code(x, y):
        	t_0 = ((x - 1.0) / y) - -1.0
        	tmp = 0
        	if x <= -1.0:
        		tmp = t_0
        	elif x <= -2.9e-63:
        		tmp = (x * x) / y
        	elif x <= 220.0:
        		tmp = x / (x - -1.0)
        	else:
        		tmp = t_0
        	return tmp
        
        function code(x, y)
        	t_0 = Float64(Float64(Float64(x - 1.0) / y) - -1.0)
        	tmp = 0.0
        	if (x <= -1.0)
        		tmp = t_0;
        	elseif (x <= -2.9e-63)
        		tmp = Float64(Float64(x * x) / y);
        	elseif (x <= 220.0)
        		tmp = Float64(x / Float64(x - -1.0));
        	else
        		tmp = t_0;
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y)
        	t_0 = ((x - 1.0) / y) - -1.0;
        	tmp = 0.0;
        	if (x <= -1.0)
        		tmp = t_0;
        	elseif (x <= -2.9e-63)
        		tmp = (x * x) / y;
        	elseif (x <= 220.0)
        		tmp = x / (x - -1.0);
        	else
        		tmp = t_0;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_] := Block[{t$95$0 = N[(N[(N[(x - 1.0), $MachinePrecision] / y), $MachinePrecision] - -1.0), $MachinePrecision]}, If[LessEqual[x, -1.0], t$95$0, If[LessEqual[x, -2.9e-63], N[(N[(x * x), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[x, 220.0], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \frac{x - 1}{y} - -1\\
        \mathbf{if}\;x \leq -1:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;x \leq -2.9 \cdot 10^{-63}:\\
        \;\;\;\;\frac{x \cdot x}{y}\\
        
        \mathbf{elif}\;x \leq 220:\\
        \;\;\;\;\frac{x}{x - -1}\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_0\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if x < -1 or 220 < x

          1. Initial program 77.2%

            \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
          2. Taylor expanded in x around inf

            \[\leadsto \color{blue}{x \cdot \left(\left(\frac{1}{x} + \frac{1}{y}\right) - \frac{1}{x \cdot y}\right)} \]
          3. Step-by-step derivation
            1. associate--l+N/A

              \[\leadsto x \cdot \left(\frac{1}{x} + \color{blue}{\left(\frac{1}{y} - \frac{1}{x \cdot y}\right)}\right) \]
            2. +-commutativeN/A

              \[\leadsto x \cdot \left(\left(\frac{1}{y} - \frac{1}{x \cdot y}\right) + \color{blue}{\frac{1}{x}}\right) \]
            3. distribute-rgt-inN/A

              \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + \color{blue}{\frac{1}{x} \cdot x} \]
            4. lft-mult-inverseN/A

              \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + 1 \]
            5. lower-fma.f64N/A

              \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{1}{x \cdot y}, \color{blue}{x}, 1\right) \]
            6. associate-/r*N/A

              \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{\frac{1}{x}}{y}, x, 1\right) \]
            7. sub-divN/A

              \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
            8. lower-/.f64N/A

              \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
            9. lower--.f64N/A

              \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
            10. lower-/.f6498.6

              \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
          4. Applied rewrites98.6%

            \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right)} \]
          5. Taylor expanded in x around 0

            \[\leadsto \left(1 + \frac{x}{y}\right) - \color{blue}{\frac{1}{y}} \]
          6. Step-by-step derivation
            1. associate--l+N/A

              \[\leadsto 1 + \left(\frac{x}{y} - \color{blue}{\frac{1}{y}}\right) \]
            2. +-commutativeN/A

              \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) + 1 \]
            3. metadata-evalN/A

              \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) + -1 \cdot -1 \]
            4. fp-cancel-sign-sub-invN/A

              \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - \left(\mathsf{neg}\left(-1\right)\right) \cdot \color{blue}{-1} \]
            5. metadata-evalN/A

              \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - 1 \cdot -1 \]
            6. metadata-evalN/A

              \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - -1 \]
            7. lower--.f64N/A

              \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - -1 \]
            8. sub-divN/A

              \[\leadsto \frac{x - 1}{y} - -1 \]
            9. lower-/.f64N/A

              \[\leadsto \frac{x - 1}{y} - -1 \]
            10. lower--.f6498.8

              \[\leadsto \frac{x - 1}{y} - -1 \]
          7. Applied rewrites98.8%

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

          if -1 < x < -2.89999999999999975e-63

          1. Initial program 99.8%

            \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
          2. Taylor expanded in y around 0

            \[\leadsto \color{blue}{\frac{{x}^{2}}{y \cdot \left(1 + x\right)}} \]
          3. Step-by-step derivation
            1. unpow2N/A

              \[\leadsto \frac{x \cdot x}{\color{blue}{y} \cdot \left(1 + x\right)} \]
            2. associate-/l*N/A

              \[\leadsto x \cdot \color{blue}{\frac{x}{y \cdot \left(1 + x\right)}} \]
            3. lower-*.f64N/A

              \[\leadsto x \cdot \color{blue}{\frac{x}{y \cdot \left(1 + x\right)}} \]
            4. lower-/.f64N/A

              \[\leadsto x \cdot \frac{x}{\color{blue}{y \cdot \left(1 + x\right)}} \]
            5. +-commutativeN/A

              \[\leadsto x \cdot \frac{x}{y \cdot \left(x + \color{blue}{1}\right)} \]
            6. distribute-lft-inN/A

              \[\leadsto x \cdot \frac{x}{y \cdot x + \color{blue}{y \cdot 1}} \]
            7. *-rgt-identityN/A

              \[\leadsto x \cdot \frac{x}{y \cdot x + y} \]
            8. lower-fma.f6446.0

              \[\leadsto x \cdot \frac{x}{\mathsf{fma}\left(y, \color{blue}{x}, y\right)} \]
          4. Applied rewrites46.0%

            \[\leadsto \color{blue}{x \cdot \frac{x}{\mathsf{fma}\left(y, x, y\right)}} \]
          5. Taylor expanded in x around 0

            \[\leadsto x \cdot \frac{x}{y} \]
          6. Step-by-step derivation
            1. Applied rewrites41.4%

              \[\leadsto x \cdot \frac{x}{y} \]
            2. Step-by-step derivation
              1. lift-*.f64N/A

                \[\leadsto x \cdot \color{blue}{\frac{x}{y}} \]
              2. lift-/.f64N/A

                \[\leadsto x \cdot \frac{x}{\color{blue}{y}} \]
              3. associate-*r/N/A

                \[\leadsto \frac{x \cdot x}{\color{blue}{y}} \]
              4. pow2N/A

                \[\leadsto \frac{{x}^{2}}{y} \]
              5. lower-/.f64N/A

                \[\leadsto \frac{{x}^{2}}{\color{blue}{y}} \]
              6. pow2N/A

                \[\leadsto \frac{x \cdot x}{y} \]
              7. lift-*.f6441.4

                \[\leadsto \frac{x \cdot x}{y} \]
            3. Applied rewrites41.4%

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

            if -2.89999999999999975e-63 < x < 220

            1. Initial program 99.9%

              \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
            2. Taylor expanded in y around inf

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

                \[\leadsto \frac{x}{\color{blue}{1 + x}} \]
              2. rgt-mult-inverseN/A

                \[\leadsto \frac{x}{x \cdot \frac{1}{x} + x} \]
              3. *-rgt-identityN/A

                \[\leadsto \frac{x}{x \cdot \frac{1}{x} + x \cdot \color{blue}{1}} \]
              4. distribute-lft-inN/A

                \[\leadsto \frac{x}{x \cdot \color{blue}{\left(\frac{1}{x} + 1\right)}} \]
              5. +-commutativeN/A

                \[\leadsto \frac{x}{x \cdot \left(1 + \color{blue}{\frac{1}{x}}\right)} \]
              6. distribute-rgt-inN/A

                \[\leadsto \frac{x}{1 \cdot x + \color{blue}{\frac{1}{x} \cdot x}} \]
              7. *-lft-identityN/A

                \[\leadsto \frac{x}{x + \color{blue}{\frac{1}{x}} \cdot x} \]
              8. lft-mult-inverseN/A

                \[\leadsto \frac{x}{x + 1} \]
              9. metadata-evalN/A

                \[\leadsto \frac{x}{x + 1 \cdot \color{blue}{1}} \]
              10. fp-cancel-sign-sub-invN/A

                \[\leadsto \frac{x}{x - \color{blue}{\left(\mathsf{neg}\left(1\right)\right) \cdot 1}} \]
              11. metadata-evalN/A

                \[\leadsto \frac{x}{x - -1 \cdot 1} \]
              12. metadata-evalN/A

                \[\leadsto \frac{x}{x - -1} \]
              13. lower--.f6477.6

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

              \[\leadsto \color{blue}{\frac{x}{x - -1}} \]
          7. Recombined 3 regimes into one program.
          8. Add Preprocessing

          Alternative 6: 86.4% accurate, 0.9× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{y} - -1\\ \mathbf{if}\;x \leq -1:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -2.9 \cdot 10^{-63}:\\ \;\;\;\;\frac{x \cdot x}{y}\\ \mathbf{elif}\;x \leq 12500000:\\ \;\;\;\;\frac{x}{x - -1}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
          (FPCore (x y)
           :precision binary64
           (let* ((t_0 (- (/ x y) -1.0)))
             (if (<= x -1.0)
               t_0
               (if (<= x -2.9e-63)
                 (/ (* x x) y)
                 (if (<= x 12500000.0) (/ x (- x -1.0)) t_0)))))
          double code(double x, double y) {
          	double t_0 = (x / y) - -1.0;
          	double tmp;
          	if (x <= -1.0) {
          		tmp = t_0;
          	} else if (x <= -2.9e-63) {
          		tmp = (x * x) / y;
          	} else if (x <= 12500000.0) {
          		tmp = x / (x - -1.0);
          	} 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)
          use fmin_fmax_functions
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              real(8) :: t_0
              real(8) :: tmp
              t_0 = (x / y) - (-1.0d0)
              if (x <= (-1.0d0)) then
                  tmp = t_0
              else if (x <= (-2.9d-63)) then
                  tmp = (x * x) / y
              else if (x <= 12500000.0d0) then
                  tmp = x / (x - (-1.0d0))
              else
                  tmp = t_0
              end if
              code = tmp
          end function
          
          public static double code(double x, double y) {
          	double t_0 = (x / y) - -1.0;
          	double tmp;
          	if (x <= -1.0) {
          		tmp = t_0;
          	} else if (x <= -2.9e-63) {
          		tmp = (x * x) / y;
          	} else if (x <= 12500000.0) {
          		tmp = x / (x - -1.0);
          	} else {
          		tmp = t_0;
          	}
          	return tmp;
          }
          
          def code(x, y):
          	t_0 = (x / y) - -1.0
          	tmp = 0
          	if x <= -1.0:
          		tmp = t_0
          	elif x <= -2.9e-63:
          		tmp = (x * x) / y
          	elif x <= 12500000.0:
          		tmp = x / (x - -1.0)
          	else:
          		tmp = t_0
          	return tmp
          
          function code(x, y)
          	t_0 = Float64(Float64(x / y) - -1.0)
          	tmp = 0.0
          	if (x <= -1.0)
          		tmp = t_0;
          	elseif (x <= -2.9e-63)
          		tmp = Float64(Float64(x * x) / y);
          	elseif (x <= 12500000.0)
          		tmp = Float64(x / Float64(x - -1.0));
          	else
          		tmp = t_0;
          	end
          	return tmp
          end
          
          function tmp_2 = code(x, y)
          	t_0 = (x / y) - -1.0;
          	tmp = 0.0;
          	if (x <= -1.0)
          		tmp = t_0;
          	elseif (x <= -2.9e-63)
          		tmp = (x * x) / y;
          	elseif (x <= 12500000.0)
          		tmp = x / (x - -1.0);
          	else
          		tmp = t_0;
          	end
          	tmp_2 = tmp;
          end
          
          code[x_, y_] := Block[{t$95$0 = N[(N[(x / y), $MachinePrecision] - -1.0), $MachinePrecision]}, If[LessEqual[x, -1.0], t$95$0, If[LessEqual[x, -2.9e-63], N[(N[(x * x), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[x, 12500000.0], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \frac{x}{y} - -1\\
          \mathbf{if}\;x \leq -1:\\
          \;\;\;\;t\_0\\
          
          \mathbf{elif}\;x \leq -2.9 \cdot 10^{-63}:\\
          \;\;\;\;\frac{x \cdot x}{y}\\
          
          \mathbf{elif}\;x \leq 12500000:\\
          \;\;\;\;\frac{x}{x - -1}\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_0\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if x < -1 or 1.25e7 < x

            1. Initial program 77.0%

              \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
            2. Taylor expanded in x around inf

              \[\leadsto \color{blue}{x \cdot \left(\left(\frac{1}{x} + \frac{1}{y}\right) - \frac{1}{x \cdot y}\right)} \]
            3. Step-by-step derivation
              1. associate--l+N/A

                \[\leadsto x \cdot \left(\frac{1}{x} + \color{blue}{\left(\frac{1}{y} - \frac{1}{x \cdot y}\right)}\right) \]
              2. +-commutativeN/A

                \[\leadsto x \cdot \left(\left(\frac{1}{y} - \frac{1}{x \cdot y}\right) + \color{blue}{\frac{1}{x}}\right) \]
              3. distribute-rgt-inN/A

                \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + \color{blue}{\frac{1}{x} \cdot x} \]
              4. lft-mult-inverseN/A

                \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + 1 \]
              5. lower-fma.f64N/A

                \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{1}{x \cdot y}, \color{blue}{x}, 1\right) \]
              6. associate-/r*N/A

                \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{\frac{1}{x}}{y}, x, 1\right) \]
              7. sub-divN/A

                \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
              8. lower-/.f64N/A

                \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
              9. lower--.f64N/A

                \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
              10. lower-/.f6498.8

                \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
            4. Applied rewrites98.8%

              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right)} \]
            5. Taylor expanded in x around 0

              \[\leadsto \left(1 + \frac{x}{y}\right) - \color{blue}{\frac{1}{y}} \]
            6. Step-by-step derivation
              1. associate--l+N/A

                \[\leadsto 1 + \left(\frac{x}{y} - \color{blue}{\frac{1}{y}}\right) \]
              2. +-commutativeN/A

                \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) + 1 \]
              3. metadata-evalN/A

                \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) + -1 \cdot -1 \]
              4. fp-cancel-sign-sub-invN/A

                \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - \left(\mathsf{neg}\left(-1\right)\right) \cdot \color{blue}{-1} \]
              5. metadata-evalN/A

                \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - 1 \cdot -1 \]
              6. metadata-evalN/A

                \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - -1 \]
              7. lower--.f64N/A

                \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - -1 \]
              8. sub-divN/A

                \[\leadsto \frac{x - 1}{y} - -1 \]
              9. lower-/.f64N/A

                \[\leadsto \frac{x - 1}{y} - -1 \]
              10. lower--.f6499.1

                \[\leadsto \frac{x - 1}{y} - -1 \]
            7. Applied rewrites99.1%

              \[\leadsto \frac{x - 1}{y} - \color{blue}{-1} \]
            8. Taylor expanded in x around inf

              \[\leadsto \frac{x}{y} - -1 \]
            9. Step-by-step derivation
              1. Applied rewrites98.6%

                \[\leadsto \frac{x}{y} - -1 \]

              if -1 < x < -2.89999999999999975e-63

              1. Initial program 99.8%

                \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
              2. Taylor expanded in y around 0

                \[\leadsto \color{blue}{\frac{{x}^{2}}{y \cdot \left(1 + x\right)}} \]
              3. Step-by-step derivation
                1. unpow2N/A

                  \[\leadsto \frac{x \cdot x}{\color{blue}{y} \cdot \left(1 + x\right)} \]
                2. associate-/l*N/A

                  \[\leadsto x \cdot \color{blue}{\frac{x}{y \cdot \left(1 + x\right)}} \]
                3. lower-*.f64N/A

                  \[\leadsto x \cdot \color{blue}{\frac{x}{y \cdot \left(1 + x\right)}} \]
                4. lower-/.f64N/A

                  \[\leadsto x \cdot \frac{x}{\color{blue}{y \cdot \left(1 + x\right)}} \]
                5. +-commutativeN/A

                  \[\leadsto x \cdot \frac{x}{y \cdot \left(x + \color{blue}{1}\right)} \]
                6. distribute-lft-inN/A

                  \[\leadsto x \cdot \frac{x}{y \cdot x + \color{blue}{y \cdot 1}} \]
                7. *-rgt-identityN/A

                  \[\leadsto x \cdot \frac{x}{y \cdot x + y} \]
                8. lower-fma.f6446.0

                  \[\leadsto x \cdot \frac{x}{\mathsf{fma}\left(y, \color{blue}{x}, y\right)} \]
              4. Applied rewrites46.0%

                \[\leadsto \color{blue}{x \cdot \frac{x}{\mathsf{fma}\left(y, x, y\right)}} \]
              5. Taylor expanded in x around 0

                \[\leadsto x \cdot \frac{x}{y} \]
              6. Step-by-step derivation
                1. Applied rewrites41.4%

                  \[\leadsto x \cdot \frac{x}{y} \]
                2. Step-by-step derivation
                  1. lift-*.f64N/A

                    \[\leadsto x \cdot \color{blue}{\frac{x}{y}} \]
                  2. lift-/.f64N/A

                    \[\leadsto x \cdot \frac{x}{\color{blue}{y}} \]
                  3. associate-*r/N/A

                    \[\leadsto \frac{x \cdot x}{\color{blue}{y}} \]
                  4. pow2N/A

                    \[\leadsto \frac{{x}^{2}}{y} \]
                  5. lower-/.f64N/A

                    \[\leadsto \frac{{x}^{2}}{\color{blue}{y}} \]
                  6. pow2N/A

                    \[\leadsto \frac{x \cdot x}{y} \]
                  7. lift-*.f6441.4

                    \[\leadsto \frac{x \cdot x}{y} \]
                3. Applied rewrites41.4%

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

                if -2.89999999999999975e-63 < x < 1.25e7

                1. Initial program 99.9%

                  \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
                2. Taylor expanded in y around inf

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

                    \[\leadsto \frac{x}{\color{blue}{1 + x}} \]
                  2. rgt-mult-inverseN/A

                    \[\leadsto \frac{x}{x \cdot \frac{1}{x} + x} \]
                  3. *-rgt-identityN/A

                    \[\leadsto \frac{x}{x \cdot \frac{1}{x} + x \cdot \color{blue}{1}} \]
                  4. distribute-lft-inN/A

                    \[\leadsto \frac{x}{x \cdot \color{blue}{\left(\frac{1}{x} + 1\right)}} \]
                  5. +-commutativeN/A

                    \[\leadsto \frac{x}{x \cdot \left(1 + \color{blue}{\frac{1}{x}}\right)} \]
                  6. distribute-rgt-inN/A

                    \[\leadsto \frac{x}{1 \cdot x + \color{blue}{\frac{1}{x} \cdot x}} \]
                  7. *-lft-identityN/A

                    \[\leadsto \frac{x}{x + \color{blue}{\frac{1}{x}} \cdot x} \]
                  8. lft-mult-inverseN/A

                    \[\leadsto \frac{x}{x + 1} \]
                  9. metadata-evalN/A

                    \[\leadsto \frac{x}{x + 1 \cdot \color{blue}{1}} \]
                  10. fp-cancel-sign-sub-invN/A

                    \[\leadsto \frac{x}{x - \color{blue}{\left(\mathsf{neg}\left(1\right)\right) \cdot 1}} \]
                  11. metadata-evalN/A

                    \[\leadsto \frac{x}{x - -1 \cdot 1} \]
                  12. metadata-evalN/A

                    \[\leadsto \frac{x}{x - -1} \]
                  13. lower--.f6477.3

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

                  \[\leadsto \color{blue}{\frac{x}{x - -1}} \]
              7. Recombined 3 regimes into one program.
              8. Add Preprocessing

              Alternative 7: 86.3% accurate, 0.9× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{y} - -1\\ \mathbf{if}\;x \leq -1:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -2.9 \cdot 10^{-63}:\\ \;\;\;\;x \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq 12500000:\\ \;\;\;\;\frac{x}{x - -1}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
              (FPCore (x y)
               :precision binary64
               (let* ((t_0 (- (/ x y) -1.0)))
                 (if (<= x -1.0)
                   t_0
                   (if (<= x -2.9e-63)
                     (* x (/ x y))
                     (if (<= x 12500000.0) (/ x (- x -1.0)) t_0)))))
              double code(double x, double y) {
              	double t_0 = (x / y) - -1.0;
              	double tmp;
              	if (x <= -1.0) {
              		tmp = t_0;
              	} else if (x <= -2.9e-63) {
              		tmp = x * (x / y);
              	} else if (x <= 12500000.0) {
              		tmp = x / (x - -1.0);
              	} 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)
              use fmin_fmax_functions
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  real(8) :: t_0
                  real(8) :: tmp
                  t_0 = (x / y) - (-1.0d0)
                  if (x <= (-1.0d0)) then
                      tmp = t_0
                  else if (x <= (-2.9d-63)) then
                      tmp = x * (x / y)
                  else if (x <= 12500000.0d0) then
                      tmp = x / (x - (-1.0d0))
                  else
                      tmp = t_0
                  end if
                  code = tmp
              end function
              
              public static double code(double x, double y) {
              	double t_0 = (x / y) - -1.0;
              	double tmp;
              	if (x <= -1.0) {
              		tmp = t_0;
              	} else if (x <= -2.9e-63) {
              		tmp = x * (x / y);
              	} else if (x <= 12500000.0) {
              		tmp = x / (x - -1.0);
              	} else {
              		tmp = t_0;
              	}
              	return tmp;
              }
              
              def code(x, y):
              	t_0 = (x / y) - -1.0
              	tmp = 0
              	if x <= -1.0:
              		tmp = t_0
              	elif x <= -2.9e-63:
              		tmp = x * (x / y)
              	elif x <= 12500000.0:
              		tmp = x / (x - -1.0)
              	else:
              		tmp = t_0
              	return tmp
              
              function code(x, y)
              	t_0 = Float64(Float64(x / y) - -1.0)
              	tmp = 0.0
              	if (x <= -1.0)
              		tmp = t_0;
              	elseif (x <= -2.9e-63)
              		tmp = Float64(x * Float64(x / y));
              	elseif (x <= 12500000.0)
              		tmp = Float64(x / Float64(x - -1.0));
              	else
              		tmp = t_0;
              	end
              	return tmp
              end
              
              function tmp_2 = code(x, y)
              	t_0 = (x / y) - -1.0;
              	tmp = 0.0;
              	if (x <= -1.0)
              		tmp = t_0;
              	elseif (x <= -2.9e-63)
              		tmp = x * (x / y);
              	elseif (x <= 12500000.0)
              		tmp = x / (x - -1.0);
              	else
              		tmp = t_0;
              	end
              	tmp_2 = tmp;
              end
              
              code[x_, y_] := Block[{t$95$0 = N[(N[(x / y), $MachinePrecision] - -1.0), $MachinePrecision]}, If[LessEqual[x, -1.0], t$95$0, If[LessEqual[x, -2.9e-63], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 12500000.0], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              t_0 := \frac{x}{y} - -1\\
              \mathbf{if}\;x \leq -1:\\
              \;\;\;\;t\_0\\
              
              \mathbf{elif}\;x \leq -2.9 \cdot 10^{-63}:\\
              \;\;\;\;x \cdot \frac{x}{y}\\
              
              \mathbf{elif}\;x \leq 12500000:\\
              \;\;\;\;\frac{x}{x - -1}\\
              
              \mathbf{else}:\\
              \;\;\;\;t\_0\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 3 regimes
              2. if x < -1 or 1.25e7 < x

                1. Initial program 77.0%

                  \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
                2. Taylor expanded in x around inf

                  \[\leadsto \color{blue}{x \cdot \left(\left(\frac{1}{x} + \frac{1}{y}\right) - \frac{1}{x \cdot y}\right)} \]
                3. Step-by-step derivation
                  1. associate--l+N/A

                    \[\leadsto x \cdot \left(\frac{1}{x} + \color{blue}{\left(\frac{1}{y} - \frac{1}{x \cdot y}\right)}\right) \]
                  2. +-commutativeN/A

                    \[\leadsto x \cdot \left(\left(\frac{1}{y} - \frac{1}{x \cdot y}\right) + \color{blue}{\frac{1}{x}}\right) \]
                  3. distribute-rgt-inN/A

                    \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + \color{blue}{\frac{1}{x} \cdot x} \]
                  4. lft-mult-inverseN/A

                    \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + 1 \]
                  5. lower-fma.f64N/A

                    \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{1}{x \cdot y}, \color{blue}{x}, 1\right) \]
                  6. associate-/r*N/A

                    \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{\frac{1}{x}}{y}, x, 1\right) \]
                  7. sub-divN/A

                    \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                  8. lower-/.f64N/A

                    \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                  9. lower--.f64N/A

                    \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                  10. lower-/.f6498.8

                    \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                4. Applied rewrites98.8%

                  \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right)} \]
                5. Taylor expanded in x around 0

                  \[\leadsto \left(1 + \frac{x}{y}\right) - \color{blue}{\frac{1}{y}} \]
                6. Step-by-step derivation
                  1. associate--l+N/A

                    \[\leadsto 1 + \left(\frac{x}{y} - \color{blue}{\frac{1}{y}}\right) \]
                  2. +-commutativeN/A

                    \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) + 1 \]
                  3. metadata-evalN/A

                    \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) + -1 \cdot -1 \]
                  4. fp-cancel-sign-sub-invN/A

                    \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - \left(\mathsf{neg}\left(-1\right)\right) \cdot \color{blue}{-1} \]
                  5. metadata-evalN/A

                    \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - 1 \cdot -1 \]
                  6. metadata-evalN/A

                    \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - -1 \]
                  7. lower--.f64N/A

                    \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - -1 \]
                  8. sub-divN/A

                    \[\leadsto \frac{x - 1}{y} - -1 \]
                  9. lower-/.f64N/A

                    \[\leadsto \frac{x - 1}{y} - -1 \]
                  10. lower--.f6499.1

                    \[\leadsto \frac{x - 1}{y} - -1 \]
                7. Applied rewrites99.1%

                  \[\leadsto \frac{x - 1}{y} - \color{blue}{-1} \]
                8. Taylor expanded in x around inf

                  \[\leadsto \frac{x}{y} - -1 \]
                9. Step-by-step derivation
                  1. Applied rewrites98.6%

                    \[\leadsto \frac{x}{y} - -1 \]

                  if -1 < x < -2.89999999999999975e-63

                  1. Initial program 99.8%

                    \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
                  2. Taylor expanded in y around 0

                    \[\leadsto \color{blue}{\frac{{x}^{2}}{y \cdot \left(1 + x\right)}} \]
                  3. Step-by-step derivation
                    1. unpow2N/A

                      \[\leadsto \frac{x \cdot x}{\color{blue}{y} \cdot \left(1 + x\right)} \]
                    2. associate-/l*N/A

                      \[\leadsto x \cdot \color{blue}{\frac{x}{y \cdot \left(1 + x\right)}} \]
                    3. lower-*.f64N/A

                      \[\leadsto x \cdot \color{blue}{\frac{x}{y \cdot \left(1 + x\right)}} \]
                    4. lower-/.f64N/A

                      \[\leadsto x \cdot \frac{x}{\color{blue}{y \cdot \left(1 + x\right)}} \]
                    5. +-commutativeN/A

                      \[\leadsto x \cdot \frac{x}{y \cdot \left(x + \color{blue}{1}\right)} \]
                    6. distribute-lft-inN/A

                      \[\leadsto x \cdot \frac{x}{y \cdot x + \color{blue}{y \cdot 1}} \]
                    7. *-rgt-identityN/A

                      \[\leadsto x \cdot \frac{x}{y \cdot x + y} \]
                    8. lower-fma.f6446.0

                      \[\leadsto x \cdot \frac{x}{\mathsf{fma}\left(y, \color{blue}{x}, y\right)} \]
                  4. Applied rewrites46.0%

                    \[\leadsto \color{blue}{x \cdot \frac{x}{\mathsf{fma}\left(y, x, y\right)}} \]
                  5. Taylor expanded in x around 0

                    \[\leadsto x \cdot \frac{x}{y} \]
                  6. Step-by-step derivation
                    1. Applied rewrites41.4%

                      \[\leadsto x \cdot \frac{x}{y} \]

                    if -2.89999999999999975e-63 < x < 1.25e7

                    1. Initial program 99.9%

                      \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
                    2. Taylor expanded in y around inf

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

                        \[\leadsto \frac{x}{\color{blue}{1 + x}} \]
                      2. rgt-mult-inverseN/A

                        \[\leadsto \frac{x}{x \cdot \frac{1}{x} + x} \]
                      3. *-rgt-identityN/A

                        \[\leadsto \frac{x}{x \cdot \frac{1}{x} + x \cdot \color{blue}{1}} \]
                      4. distribute-lft-inN/A

                        \[\leadsto \frac{x}{x \cdot \color{blue}{\left(\frac{1}{x} + 1\right)}} \]
                      5. +-commutativeN/A

                        \[\leadsto \frac{x}{x \cdot \left(1 + \color{blue}{\frac{1}{x}}\right)} \]
                      6. distribute-rgt-inN/A

                        \[\leadsto \frac{x}{1 \cdot x + \color{blue}{\frac{1}{x} \cdot x}} \]
                      7. *-lft-identityN/A

                        \[\leadsto \frac{x}{x + \color{blue}{\frac{1}{x}} \cdot x} \]
                      8. lft-mult-inverseN/A

                        \[\leadsto \frac{x}{x + 1} \]
                      9. metadata-evalN/A

                        \[\leadsto \frac{x}{x + 1 \cdot \color{blue}{1}} \]
                      10. fp-cancel-sign-sub-invN/A

                        \[\leadsto \frac{x}{x - \color{blue}{\left(\mathsf{neg}\left(1\right)\right) \cdot 1}} \]
                      11. metadata-evalN/A

                        \[\leadsto \frac{x}{x - -1 \cdot 1} \]
                      12. metadata-evalN/A

                        \[\leadsto \frac{x}{x - -1} \]
                      13. lower--.f6477.3

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

                      \[\leadsto \color{blue}{\frac{x}{x - -1}} \]
                  7. Recombined 3 regimes into one program.
                  8. Add Preprocessing

                  Alternative 8: 86.1% accurate, 1.1× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{y} - -1\\ \mathbf{if}\;x \leq -3950:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 12500000:\\ \;\;\;\;\frac{x}{x - -1}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                  (FPCore (x y)
                   :precision binary64
                   (let* ((t_0 (- (/ x y) -1.0)))
                     (if (<= x -3950.0) t_0 (if (<= x 12500000.0) (/ x (- x -1.0)) t_0))))
                  double code(double x, double y) {
                  	double t_0 = (x / y) - -1.0;
                  	double tmp;
                  	if (x <= -3950.0) {
                  		tmp = t_0;
                  	} else if (x <= 12500000.0) {
                  		tmp = x / (x - -1.0);
                  	} 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)
                  use fmin_fmax_functions
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      real(8) :: t_0
                      real(8) :: tmp
                      t_0 = (x / y) - (-1.0d0)
                      if (x <= (-3950.0d0)) then
                          tmp = t_0
                      else if (x <= 12500000.0d0) then
                          tmp = x / (x - (-1.0d0))
                      else
                          tmp = t_0
                      end if
                      code = tmp
                  end function
                  
                  public static double code(double x, double y) {
                  	double t_0 = (x / y) - -1.0;
                  	double tmp;
                  	if (x <= -3950.0) {
                  		tmp = t_0;
                  	} else if (x <= 12500000.0) {
                  		tmp = x / (x - -1.0);
                  	} else {
                  		tmp = t_0;
                  	}
                  	return tmp;
                  }
                  
                  def code(x, y):
                  	t_0 = (x / y) - -1.0
                  	tmp = 0
                  	if x <= -3950.0:
                  		tmp = t_0
                  	elif x <= 12500000.0:
                  		tmp = x / (x - -1.0)
                  	else:
                  		tmp = t_0
                  	return tmp
                  
                  function code(x, y)
                  	t_0 = Float64(Float64(x / y) - -1.0)
                  	tmp = 0.0
                  	if (x <= -3950.0)
                  		tmp = t_0;
                  	elseif (x <= 12500000.0)
                  		tmp = Float64(x / Float64(x - -1.0));
                  	else
                  		tmp = t_0;
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(x, y)
                  	t_0 = (x / y) - -1.0;
                  	tmp = 0.0;
                  	if (x <= -3950.0)
                  		tmp = t_0;
                  	elseif (x <= 12500000.0)
                  		tmp = x / (x - -1.0);
                  	else
                  		tmp = t_0;
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[x_, y_] := Block[{t$95$0 = N[(N[(x / y), $MachinePrecision] - -1.0), $MachinePrecision]}, If[LessEqual[x, -3950.0], t$95$0, If[LessEqual[x, 12500000.0], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  t_0 := \frac{x}{y} - -1\\
                  \mathbf{if}\;x \leq -3950:\\
                  \;\;\;\;t\_0\\
                  
                  \mathbf{elif}\;x \leq 12500000:\\
                  \;\;\;\;\frac{x}{x - -1}\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;t\_0\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if x < -3950 or 1.25e7 < x

                    1. Initial program 76.9%

                      \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
                    2. Taylor expanded in x around inf

                      \[\leadsto \color{blue}{x \cdot \left(\left(\frac{1}{x} + \frac{1}{y}\right) - \frac{1}{x \cdot y}\right)} \]
                    3. Step-by-step derivation
                      1. associate--l+N/A

                        \[\leadsto x \cdot \left(\frac{1}{x} + \color{blue}{\left(\frac{1}{y} - \frac{1}{x \cdot y}\right)}\right) \]
                      2. +-commutativeN/A

                        \[\leadsto x \cdot \left(\left(\frac{1}{y} - \frac{1}{x \cdot y}\right) + \color{blue}{\frac{1}{x}}\right) \]
                      3. distribute-rgt-inN/A

                        \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + \color{blue}{\frac{1}{x} \cdot x} \]
                      4. lft-mult-inverseN/A

                        \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + 1 \]
                      5. lower-fma.f64N/A

                        \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{1}{x \cdot y}, \color{blue}{x}, 1\right) \]
                      6. associate-/r*N/A

                        \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{\frac{1}{x}}{y}, x, 1\right) \]
                      7. sub-divN/A

                        \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                      8. lower-/.f64N/A

                        \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                      9. lower--.f64N/A

                        \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                      10. lower-/.f6499.2

                        \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                    4. Applied rewrites99.2%

                      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right)} \]
                    5. Taylor expanded in x around 0

                      \[\leadsto \left(1 + \frac{x}{y}\right) - \color{blue}{\frac{1}{y}} \]
                    6. Step-by-step derivation
                      1. associate--l+N/A

                        \[\leadsto 1 + \left(\frac{x}{y} - \color{blue}{\frac{1}{y}}\right) \]
                      2. +-commutativeN/A

                        \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) + 1 \]
                      3. metadata-evalN/A

                        \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) + -1 \cdot -1 \]
                      4. fp-cancel-sign-sub-invN/A

                        \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - \left(\mathsf{neg}\left(-1\right)\right) \cdot \color{blue}{-1} \]
                      5. metadata-evalN/A

                        \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - 1 \cdot -1 \]
                      6. metadata-evalN/A

                        \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - -1 \]
                      7. lower--.f64N/A

                        \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - -1 \]
                      8. sub-divN/A

                        \[\leadsto \frac{x - 1}{y} - -1 \]
                      9. lower-/.f64N/A

                        \[\leadsto \frac{x - 1}{y} - -1 \]
                      10. lower--.f6499.5

                        \[\leadsto \frac{x - 1}{y} - -1 \]
                    7. Applied rewrites99.5%

                      \[\leadsto \frac{x - 1}{y} - \color{blue}{-1} \]
                    8. Taylor expanded in x around inf

                      \[\leadsto \frac{x}{y} - -1 \]
                    9. Step-by-step derivation
                      1. Applied rewrites99.0%

                        \[\leadsto \frac{x}{y} - -1 \]

                      if -3950 < x < 1.25e7

                      1. Initial program 99.9%

                        \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
                      2. Taylor expanded in y around inf

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

                          \[\leadsto \frac{x}{\color{blue}{1 + x}} \]
                        2. rgt-mult-inverseN/A

                          \[\leadsto \frac{x}{x \cdot \frac{1}{x} + x} \]
                        3. *-rgt-identityN/A

                          \[\leadsto \frac{x}{x \cdot \frac{1}{x} + x \cdot \color{blue}{1}} \]
                        4. distribute-lft-inN/A

                          \[\leadsto \frac{x}{x \cdot \color{blue}{\left(\frac{1}{x} + 1\right)}} \]
                        5. +-commutativeN/A

                          \[\leadsto \frac{x}{x \cdot \left(1 + \color{blue}{\frac{1}{x}}\right)} \]
                        6. distribute-rgt-inN/A

                          \[\leadsto \frac{x}{1 \cdot x + \color{blue}{\frac{1}{x} \cdot x}} \]
                        7. *-lft-identityN/A

                          \[\leadsto \frac{x}{x + \color{blue}{\frac{1}{x}} \cdot x} \]
                        8. lft-mult-inverseN/A

                          \[\leadsto \frac{x}{x + 1} \]
                        9. metadata-evalN/A

                          \[\leadsto \frac{x}{x + 1 \cdot \color{blue}{1}} \]
                        10. fp-cancel-sign-sub-invN/A

                          \[\leadsto \frac{x}{x - \color{blue}{\left(\mathsf{neg}\left(1\right)\right) \cdot 1}} \]
                        11. metadata-evalN/A

                          \[\leadsto \frac{x}{x - -1 \cdot 1} \]
                        12. metadata-evalN/A

                          \[\leadsto \frac{x}{x - -1} \]
                        13. lower--.f6474.9

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

                        \[\leadsto \color{blue}{\frac{x}{x - -1}} \]
                    10. Recombined 2 regimes into one program.
                    11. Add Preprocessing

                    Alternative 9: 86.1% accurate, 0.4× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\ t_1 := \frac{x}{y} - -1\\ \mathbf{if}\;t\_0 \leq -400:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 0.1:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
                    (FPCore (x y)
                     :precision binary64
                     (let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))) (t_1 (- (/ x y) -1.0)))
                       (if (<= t_0 -400.0) t_1 (if (<= t_0 0.1) x t_1))))
                    double code(double x, double y) {
                    	double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
                    	double t_1 = (x / y) - -1.0;
                    	double tmp;
                    	if (t_0 <= -400.0) {
                    		tmp = t_1;
                    	} else if (t_0 <= 0.1) {
                    		tmp = x;
                    	} else {
                    		tmp = t_1;
                    	}
                    	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)
                    use fmin_fmax_functions
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        real(8) :: t_0
                        real(8) :: t_1
                        real(8) :: tmp
                        t_0 = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
                        t_1 = (x / y) - (-1.0d0)
                        if (t_0 <= (-400.0d0)) then
                            tmp = t_1
                        else if (t_0 <= 0.1d0) then
                            tmp = x
                        else
                            tmp = t_1
                        end if
                        code = tmp
                    end function
                    
                    public static double code(double x, double y) {
                    	double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
                    	double t_1 = (x / y) - -1.0;
                    	double tmp;
                    	if (t_0 <= -400.0) {
                    		tmp = t_1;
                    	} else if (t_0 <= 0.1) {
                    		tmp = x;
                    	} else {
                    		tmp = t_1;
                    	}
                    	return tmp;
                    }
                    
                    def code(x, y):
                    	t_0 = (x * ((x / y) + 1.0)) / (x + 1.0)
                    	t_1 = (x / y) - -1.0
                    	tmp = 0
                    	if t_0 <= -400.0:
                    		tmp = t_1
                    	elif t_0 <= 0.1:
                    		tmp = x
                    	else:
                    		tmp = t_1
                    	return tmp
                    
                    function code(x, y)
                    	t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0))
                    	t_1 = Float64(Float64(x / y) - -1.0)
                    	tmp = 0.0
                    	if (t_0 <= -400.0)
                    		tmp = t_1;
                    	elseif (t_0 <= 0.1)
                    		tmp = x;
                    	else
                    		tmp = t_1;
                    	end
                    	return tmp
                    end
                    
                    function tmp_2 = code(x, y)
                    	t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
                    	t_1 = (x / y) - -1.0;
                    	tmp = 0.0;
                    	if (t_0 <= -400.0)
                    		tmp = t_1;
                    	elseif (t_0 <= 0.1)
                    		tmp = x;
                    	else
                    		tmp = t_1;
                    	end
                    	tmp_2 = tmp;
                    end
                    
                    code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x / y), $MachinePrecision] - -1.0), $MachinePrecision]}, If[LessEqual[t$95$0, -400.0], t$95$1, If[LessEqual[t$95$0, 0.1], x, t$95$1]]]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
                    t_1 := \frac{x}{y} - -1\\
                    \mathbf{if}\;t\_0 \leq -400:\\
                    \;\;\;\;t\_1\\
                    
                    \mathbf{elif}\;t\_0 \leq 0.1:\\
                    \;\;\;\;x\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;t\_1\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -400 or 0.10000000000000001 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64)))

                      1. Initial program 79.8%

                        \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
                      2. Taylor expanded in x around inf

                        \[\leadsto \color{blue}{x \cdot \left(\left(\frac{1}{x} + \frac{1}{y}\right) - \frac{1}{x \cdot y}\right)} \]
                      3. Step-by-step derivation
                        1. associate--l+N/A

                          \[\leadsto x \cdot \left(\frac{1}{x} + \color{blue}{\left(\frac{1}{y} - \frac{1}{x \cdot y}\right)}\right) \]
                        2. +-commutativeN/A

                          \[\leadsto x \cdot \left(\left(\frac{1}{y} - \frac{1}{x \cdot y}\right) + \color{blue}{\frac{1}{x}}\right) \]
                        3. distribute-rgt-inN/A

                          \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + \color{blue}{\frac{1}{x} \cdot x} \]
                        4. lft-mult-inverseN/A

                          \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + 1 \]
                        5. lower-fma.f64N/A

                          \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{1}{x \cdot y}, \color{blue}{x}, 1\right) \]
                        6. associate-/r*N/A

                          \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{\frac{1}{x}}{y}, x, 1\right) \]
                        7. sub-divN/A

                          \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                        8. lower-/.f64N/A

                          \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                        9. lower--.f64N/A

                          \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                        10. lower-/.f6487.2

                          \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                      4. Applied rewrites87.2%

                        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right)} \]
                      5. Taylor expanded in x around 0

                        \[\leadsto \left(1 + \frac{x}{y}\right) - \color{blue}{\frac{1}{y}} \]
                      6. Step-by-step derivation
                        1. associate--l+N/A

                          \[\leadsto 1 + \left(\frac{x}{y} - \color{blue}{\frac{1}{y}}\right) \]
                        2. +-commutativeN/A

                          \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) + 1 \]
                        3. metadata-evalN/A

                          \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) + -1 \cdot -1 \]
                        4. fp-cancel-sign-sub-invN/A

                          \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - \left(\mathsf{neg}\left(-1\right)\right) \cdot \color{blue}{-1} \]
                        5. metadata-evalN/A

                          \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - 1 \cdot -1 \]
                        6. metadata-evalN/A

                          \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - -1 \]
                        7. lower--.f64N/A

                          \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - -1 \]
                        8. sub-divN/A

                          \[\leadsto \frac{x - 1}{y} - -1 \]
                        9. lower-/.f64N/A

                          \[\leadsto \frac{x - 1}{y} - -1 \]
                        10. lower--.f6487.4

                          \[\leadsto \frac{x - 1}{y} - -1 \]
                      7. Applied rewrites87.4%

                        \[\leadsto \frac{x - 1}{y} - \color{blue}{-1} \]
                      8. Taylor expanded in x around inf

                        \[\leadsto \frac{x}{y} - -1 \]
                      9. Step-by-step derivation
                        1. Applied rewrites87.3%

                          \[\leadsto \frac{x}{y} - -1 \]

                        if -400 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 0.10000000000000001

                        1. Initial program 99.9%

                          \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
                        2. Taylor expanded in x around 0

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

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

                        Alternative 10: 85.3% accurate, 0.3× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\ \mathbf{if}\;t\_0 \leq -400:\\ \;\;\;\;\frac{x - 1}{y}\\ \mathbf{elif}\;t\_0 \leq 0.1:\\ \;\;\;\;x\\ \mathbf{elif}\;t\_0 \leq 200:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array} \]
                        (FPCore (x y)
                         :precision binary64
                         (let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
                           (if (<= t_0 -400.0)
                             (/ (- x 1.0) y)
                             (if (<= t_0 0.1) x (if (<= t_0 200.0) 1.0 (/ x y))))))
                        double code(double x, double y) {
                        	double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
                        	double tmp;
                        	if (t_0 <= -400.0) {
                        		tmp = (x - 1.0) / y;
                        	} else if (t_0 <= 0.1) {
                        		tmp = x;
                        	} else if (t_0 <= 200.0) {
                        		tmp = 1.0;
                        	} else {
                        		tmp = x / y;
                        	}
                        	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)
                        use fmin_fmax_functions
                            real(8), intent (in) :: x
                            real(8), intent (in) :: y
                            real(8) :: t_0
                            real(8) :: tmp
                            t_0 = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
                            if (t_0 <= (-400.0d0)) then
                                tmp = (x - 1.0d0) / y
                            else if (t_0 <= 0.1d0) then
                                tmp = x
                            else if (t_0 <= 200.0d0) then
                                tmp = 1.0d0
                            else
                                tmp = x / y
                            end if
                            code = tmp
                        end function
                        
                        public static double code(double x, double y) {
                        	double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
                        	double tmp;
                        	if (t_0 <= -400.0) {
                        		tmp = (x - 1.0) / y;
                        	} else if (t_0 <= 0.1) {
                        		tmp = x;
                        	} else if (t_0 <= 200.0) {
                        		tmp = 1.0;
                        	} else {
                        		tmp = x / y;
                        	}
                        	return tmp;
                        }
                        
                        def code(x, y):
                        	t_0 = (x * ((x / y) + 1.0)) / (x + 1.0)
                        	tmp = 0
                        	if t_0 <= -400.0:
                        		tmp = (x - 1.0) / y
                        	elif t_0 <= 0.1:
                        		tmp = x
                        	elif t_0 <= 200.0:
                        		tmp = 1.0
                        	else:
                        		tmp = x / y
                        	return tmp
                        
                        function code(x, y)
                        	t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0))
                        	tmp = 0.0
                        	if (t_0 <= -400.0)
                        		tmp = Float64(Float64(x - 1.0) / y);
                        	elseif (t_0 <= 0.1)
                        		tmp = x;
                        	elseif (t_0 <= 200.0)
                        		tmp = 1.0;
                        	else
                        		tmp = Float64(x / y);
                        	end
                        	return tmp
                        end
                        
                        function tmp_2 = code(x, y)
                        	t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
                        	tmp = 0.0;
                        	if (t_0 <= -400.0)
                        		tmp = (x - 1.0) / y;
                        	elseif (t_0 <= 0.1)
                        		tmp = x;
                        	elseif (t_0 <= 200.0)
                        		tmp = 1.0;
                        	else
                        		tmp = x / y;
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -400.0], N[(N[(x - 1.0), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[t$95$0, 0.1], x, If[LessEqual[t$95$0, 200.0], 1.0, N[(x / y), $MachinePrecision]]]]]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
                        \mathbf{if}\;t\_0 \leq -400:\\
                        \;\;\;\;\frac{x - 1}{y}\\
                        
                        \mathbf{elif}\;t\_0 \leq 0.1:\\
                        \;\;\;\;x\\
                        
                        \mathbf{elif}\;t\_0 \leq 200:\\
                        \;\;\;\;1\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;\frac{x}{y}\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 4 regimes
                        2. if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -400

                          1. Initial program 73.6%

                            \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
                          2. Taylor expanded in x around inf

                            \[\leadsto \color{blue}{x \cdot \left(\left(\frac{1}{x} + \frac{1}{y}\right) - \frac{1}{x \cdot y}\right)} \]
                          3. Step-by-step derivation
                            1. associate--l+N/A

                              \[\leadsto x \cdot \left(\frac{1}{x} + \color{blue}{\left(\frac{1}{y} - \frac{1}{x \cdot y}\right)}\right) \]
                            2. +-commutativeN/A

                              \[\leadsto x \cdot \left(\left(\frac{1}{y} - \frac{1}{x \cdot y}\right) + \color{blue}{\frac{1}{x}}\right) \]
                            3. distribute-rgt-inN/A

                              \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + \color{blue}{\frac{1}{x} \cdot x} \]
                            4. lft-mult-inverseN/A

                              \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + 1 \]
                            5. lower-fma.f64N/A

                              \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{1}{x \cdot y}, \color{blue}{x}, 1\right) \]
                            6. associate-/r*N/A

                              \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{\frac{1}{x}}{y}, x, 1\right) \]
                            7. sub-divN/A

                              \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                            8. lower-/.f64N/A

                              \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                            9. lower--.f64N/A

                              \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                            10. lower-/.f6484.6

                              \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                          4. Applied rewrites84.6%

                            \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right)} \]
                          5. Taylor expanded in x around 0

                            \[\leadsto \left(1 + \frac{x}{y}\right) - \color{blue}{\frac{1}{y}} \]
                          6. Step-by-step derivation
                            1. associate--l+N/A

                              \[\leadsto 1 + \left(\frac{x}{y} - \color{blue}{\frac{1}{y}}\right) \]
                            2. +-commutativeN/A

                              \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) + 1 \]
                            3. metadata-evalN/A

                              \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) + -1 \cdot -1 \]
                            4. fp-cancel-sign-sub-invN/A

                              \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - \left(\mathsf{neg}\left(-1\right)\right) \cdot \color{blue}{-1} \]
                            5. metadata-evalN/A

                              \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - 1 \cdot -1 \]
                            6. metadata-evalN/A

                              \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - -1 \]
                            7. lower--.f64N/A

                              \[\leadsto \left(\frac{x}{y} - \frac{1}{y}\right) - -1 \]
                            8. sub-divN/A

                              \[\leadsto \frac{x - 1}{y} - -1 \]
                            9. lower-/.f64N/A

                              \[\leadsto \frac{x - 1}{y} - -1 \]
                            10. lower--.f6484.8

                              \[\leadsto \frac{x - 1}{y} - -1 \]
                          7. Applied rewrites84.8%

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

                            \[\leadsto \frac{x - 1}{y} \]
                          9. Step-by-step derivation
                            1. lift-/.f64N/A

                              \[\leadsto \frac{x - 1}{y} \]
                            2. lift--.f6484.0

                              \[\leadsto \frac{x - 1}{y} \]
                          10. Applied rewrites84.0%

                            \[\leadsto \frac{x - 1}{y} \]

                          if -400 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 0.10000000000000001

                          1. Initial program 99.9%

                            \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
                          2. Taylor expanded in x around 0

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

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

                            if 0.10000000000000001 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 200

                            1. Initial program 100.0%

                              \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
                            2. Taylor expanded in x around inf

                              \[\leadsto \color{blue}{x \cdot \left(\left(\frac{1}{x} + \frac{1}{y}\right) - \frac{1}{x \cdot y}\right)} \]
                            3. Step-by-step derivation
                              1. associate--l+N/A

                                \[\leadsto x \cdot \left(\frac{1}{x} + \color{blue}{\left(\frac{1}{y} - \frac{1}{x \cdot y}\right)}\right) \]
                              2. +-commutativeN/A

                                \[\leadsto x \cdot \left(\left(\frac{1}{y} - \frac{1}{x \cdot y}\right) + \color{blue}{\frac{1}{x}}\right) \]
                              3. distribute-rgt-inN/A

                                \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + \color{blue}{\frac{1}{x} \cdot x} \]
                              4. lft-mult-inverseN/A

                                \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + 1 \]
                              5. lower-fma.f64N/A

                                \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{1}{x \cdot y}, \color{blue}{x}, 1\right) \]
                              6. associate-/r*N/A

                                \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{\frac{1}{x}}{y}, x, 1\right) \]
                              7. sub-divN/A

                                \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                              8. lower-/.f64N/A

                                \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                              9. lower--.f64N/A

                                \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                              10. lower-/.f6495.6

                                \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                            4. Applied rewrites95.6%

                              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right)} \]
                            5. Taylor expanded in y around inf

                              \[\leadsto 1 \]
                            6. Step-by-step derivation
                              1. Applied rewrites90.5%

                                \[\leadsto 1 \]

                              if 200 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64)))

                              1. Initial program 73.3%

                                \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
                              2. Taylor expanded in x around inf

                                \[\leadsto \color{blue}{\frac{x}{y}} \]
                              3. Step-by-step derivation
                                1. lift-/.f6483.9

                                  \[\leadsto \frac{x}{\color{blue}{y}} \]
                              4. Applied rewrites83.9%

                                \[\leadsto \color{blue}{\frac{x}{y}} \]
                            7. Recombined 4 regimes into one program.
                            8. Add Preprocessing

                            Alternative 11: 85.2% accurate, 0.3× speedup?

                            \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\ \mathbf{if}\;t\_0 \leq -400:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;t\_0 \leq 0.1:\\ \;\;\;\;x\\ \mathbf{elif}\;t\_0 \leq 200:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array} \]
                            (FPCore (x y)
                             :precision binary64
                             (let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0))))
                               (if (<= t_0 -400.0)
                                 (/ x y)
                                 (if (<= t_0 0.1) x (if (<= t_0 200.0) 1.0 (/ x y))))))
                            double code(double x, double y) {
                            	double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
                            	double tmp;
                            	if (t_0 <= -400.0) {
                            		tmp = x / y;
                            	} else if (t_0 <= 0.1) {
                            		tmp = x;
                            	} else if (t_0 <= 200.0) {
                            		tmp = 1.0;
                            	} else {
                            		tmp = x / y;
                            	}
                            	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)
                            use fmin_fmax_functions
                                real(8), intent (in) :: x
                                real(8), intent (in) :: y
                                real(8) :: t_0
                                real(8) :: tmp
                                t_0 = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
                                if (t_0 <= (-400.0d0)) then
                                    tmp = x / y
                                else if (t_0 <= 0.1d0) then
                                    tmp = x
                                else if (t_0 <= 200.0d0) then
                                    tmp = 1.0d0
                                else
                                    tmp = x / y
                                end if
                                code = tmp
                            end function
                            
                            public static double code(double x, double y) {
                            	double t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
                            	double tmp;
                            	if (t_0 <= -400.0) {
                            		tmp = x / y;
                            	} else if (t_0 <= 0.1) {
                            		tmp = x;
                            	} else if (t_0 <= 200.0) {
                            		tmp = 1.0;
                            	} else {
                            		tmp = x / y;
                            	}
                            	return tmp;
                            }
                            
                            def code(x, y):
                            	t_0 = (x * ((x / y) + 1.0)) / (x + 1.0)
                            	tmp = 0
                            	if t_0 <= -400.0:
                            		tmp = x / y
                            	elif t_0 <= 0.1:
                            		tmp = x
                            	elif t_0 <= 200.0:
                            		tmp = 1.0
                            	else:
                            		tmp = x / y
                            	return tmp
                            
                            function code(x, y)
                            	t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0))
                            	tmp = 0.0
                            	if (t_0 <= -400.0)
                            		tmp = Float64(x / y);
                            	elseif (t_0 <= 0.1)
                            		tmp = x;
                            	elseif (t_0 <= 200.0)
                            		tmp = 1.0;
                            	else
                            		tmp = Float64(x / y);
                            	end
                            	return tmp
                            end
                            
                            function tmp_2 = code(x, y)
                            	t_0 = (x * ((x / y) + 1.0)) / (x + 1.0);
                            	tmp = 0.0;
                            	if (t_0 <= -400.0)
                            		tmp = x / y;
                            	elseif (t_0 <= 0.1)
                            		tmp = x;
                            	elseif (t_0 <= 200.0)
                            		tmp = 1.0;
                            	else
                            		tmp = x / y;
                            	end
                            	tmp_2 = tmp;
                            end
                            
                            code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -400.0], N[(x / y), $MachinePrecision], If[LessEqual[t$95$0, 0.1], x, If[LessEqual[t$95$0, 200.0], 1.0, N[(x / y), $MachinePrecision]]]]]
                            
                            \begin{array}{l}
                            
                            \\
                            \begin{array}{l}
                            t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
                            \mathbf{if}\;t\_0 \leq -400:\\
                            \;\;\;\;\frac{x}{y}\\
                            
                            \mathbf{elif}\;t\_0 \leq 0.1:\\
                            \;\;\;\;x\\
                            
                            \mathbf{elif}\;t\_0 \leq 200:\\
                            \;\;\;\;1\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;\frac{x}{y}\\
                            
                            
                            \end{array}
                            \end{array}
                            
                            Derivation
                            1. Split input into 3 regimes
                            2. if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -400 or 200 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64)))

                              1. Initial program 73.5%

                                \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
                              2. Taylor expanded in x around inf

                                \[\leadsto \color{blue}{\frac{x}{y}} \]
                              3. Step-by-step derivation
                                1. lift-/.f6483.9

                                  \[\leadsto \frac{x}{\color{blue}{y}} \]
                              4. Applied rewrites83.9%

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

                              if -400 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 0.10000000000000001

                              1. Initial program 99.9%

                                \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
                              2. Taylor expanded in x around 0

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

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

                                if 0.10000000000000001 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 200

                                1. Initial program 100.0%

                                  \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
                                2. Taylor expanded in x around inf

                                  \[\leadsto \color{blue}{x \cdot \left(\left(\frac{1}{x} + \frac{1}{y}\right) - \frac{1}{x \cdot y}\right)} \]
                                3. Step-by-step derivation
                                  1. associate--l+N/A

                                    \[\leadsto x \cdot \left(\frac{1}{x} + \color{blue}{\left(\frac{1}{y} - \frac{1}{x \cdot y}\right)}\right) \]
                                  2. +-commutativeN/A

                                    \[\leadsto x \cdot \left(\left(\frac{1}{y} - \frac{1}{x \cdot y}\right) + \color{blue}{\frac{1}{x}}\right) \]
                                  3. distribute-rgt-inN/A

                                    \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + \color{blue}{\frac{1}{x} \cdot x} \]
                                  4. lft-mult-inverseN/A

                                    \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + 1 \]
                                  5. lower-fma.f64N/A

                                    \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{1}{x \cdot y}, \color{blue}{x}, 1\right) \]
                                  6. associate-/r*N/A

                                    \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{\frac{1}{x}}{y}, x, 1\right) \]
                                  7. sub-divN/A

                                    \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                                  8. lower-/.f64N/A

                                    \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                                  9. lower--.f64N/A

                                    \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                                  10. lower-/.f6495.6

                                    \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                                4. Applied rewrites95.6%

                                  \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right)} \]
                                5. Taylor expanded in y around inf

                                  \[\leadsto 1 \]
                                6. Step-by-step derivation
                                  1. Applied rewrites90.5%

                                    \[\leadsto 1 \]
                                7. Recombined 3 regimes into one program.
                                8. Add Preprocessing

                                Alternative 12: 50.6% accurate, 0.8× speedup?

                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \leq 0.1:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
                                (FPCore (x y)
                                 :precision binary64
                                 (if (<= (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)) 0.1) x 1.0))
                                double code(double x, double y) {
                                	double tmp;
                                	if (((x * ((x / y) + 1.0)) / (x + 1.0)) <= 0.1) {
                                		tmp = x;
                                	} else {
                                		tmp = 1.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)
                                use fmin_fmax_functions
                                    real(8), intent (in) :: x
                                    real(8), intent (in) :: y
                                    real(8) :: tmp
                                    if (((x * ((x / y) + 1.0d0)) / (x + 1.0d0)) <= 0.1d0) then
                                        tmp = x
                                    else
                                        tmp = 1.0d0
                                    end if
                                    code = tmp
                                end function
                                
                                public static double code(double x, double y) {
                                	double tmp;
                                	if (((x * ((x / y) + 1.0)) / (x + 1.0)) <= 0.1) {
                                		tmp = x;
                                	} else {
                                		tmp = 1.0;
                                	}
                                	return tmp;
                                }
                                
                                def code(x, y):
                                	tmp = 0
                                	if ((x * ((x / y) + 1.0)) / (x + 1.0)) <= 0.1:
                                		tmp = x
                                	else:
                                		tmp = 1.0
                                	return tmp
                                
                                function code(x, y)
                                	tmp = 0.0
                                	if (Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) <= 0.1)
                                		tmp = x;
                                	else
                                		tmp = 1.0;
                                	end
                                	return tmp
                                end
                                
                                function tmp_2 = code(x, y)
                                	tmp = 0.0;
                                	if (((x * ((x / y) + 1.0)) / (x + 1.0)) <= 0.1)
                                		tmp = x;
                                	else
                                		tmp = 1.0;
                                	end
                                	tmp_2 = tmp;
                                end
                                
                                code[x_, y_] := If[LessEqual[N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], 0.1], x, 1.0]
                                
                                \begin{array}{l}
                                
                                \\
                                \begin{array}{l}
                                \mathbf{if}\;\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \leq 0.1:\\
                                \;\;\;\;x\\
                                
                                \mathbf{else}:\\
                                \;\;\;\;1\\
                                
                                
                                \end{array}
                                \end{array}
                                
                                Derivation
                                1. Split input into 2 regimes
                                2. if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 0.10000000000000001

                                  1. Initial program 90.9%

                                    \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
                                  2. Taylor expanded in x around 0

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

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

                                    if 0.10000000000000001 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64)))

                                    1. Initial program 83.7%

                                      \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
                                    2. Taylor expanded in x around inf

                                      \[\leadsto \color{blue}{x \cdot \left(\left(\frac{1}{x} + \frac{1}{y}\right) - \frac{1}{x \cdot y}\right)} \]
                                    3. Step-by-step derivation
                                      1. associate--l+N/A

                                        \[\leadsto x \cdot \left(\frac{1}{x} + \color{blue}{\left(\frac{1}{y} - \frac{1}{x \cdot y}\right)}\right) \]
                                      2. +-commutativeN/A

                                        \[\leadsto x \cdot \left(\left(\frac{1}{y} - \frac{1}{x \cdot y}\right) + \color{blue}{\frac{1}{x}}\right) \]
                                      3. distribute-rgt-inN/A

                                        \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + \color{blue}{\frac{1}{x} \cdot x} \]
                                      4. lft-mult-inverseN/A

                                        \[\leadsto \left(\frac{1}{y} - \frac{1}{x \cdot y}\right) \cdot x + 1 \]
                                      5. lower-fma.f64N/A

                                        \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{1}{x \cdot y}, \color{blue}{x}, 1\right) \]
                                      6. associate-/r*N/A

                                        \[\leadsto \mathsf{fma}\left(\frac{1}{y} - \frac{\frac{1}{x}}{y}, x, 1\right) \]
                                      7. sub-divN/A

                                        \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                                      8. lower-/.f64N/A

                                        \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                                      9. lower--.f64N/A

                                        \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                                      10. lower-/.f6488.9

                                        \[\leadsto \mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right) \]
                                    4. Applied rewrites88.9%

                                      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1 - \frac{1}{x}}{y}, x, 1\right)} \]
                                    5. Taylor expanded in y around inf

                                      \[\leadsto 1 \]
                                    6. Step-by-step derivation
                                      1. Applied rewrites38.3%

                                        \[\leadsto 1 \]
                                    7. Recombined 2 regimes into one program.
                                    8. Add Preprocessing

                                    Alternative 13: 38.6% accurate, 16.1× speedup?

                                    \[\begin{array}{l} \\ x \end{array} \]
                                    (FPCore (x y) :precision binary64 x)
                                    double code(double x, double y) {
                                    	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)
                                    use fmin_fmax_functions
                                        real(8), intent (in) :: x
                                        real(8), intent (in) :: y
                                        code = x
                                    end function
                                    
                                    public static double code(double x, double y) {
                                    	return x;
                                    }
                                    
                                    def code(x, y):
                                    	return x
                                    
                                    function code(x, y)
                                    	return x
                                    end
                                    
                                    function tmp = code(x, y)
                                    	tmp = x;
                                    end
                                    
                                    code[x_, y_] := x
                                    
                                    \begin{array}{l}
                                    
                                    \\
                                    x
                                    \end{array}
                                    
                                    Derivation
                                    1. Initial program 88.4%

                                      \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
                                    2. Taylor expanded in x around 0

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

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

                                      Reproduce

                                      ?
                                      herbie shell --seed 2025130 
                                      (FPCore (x y)
                                        :name "Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1"
                                        :precision binary64
                                        (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))