Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1

Percentage Accurate: 88.5% → 99.9%
Time: 4.2s
Alternatives: 11
Speedup: 1.0×

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}

Sampling outcomes in binary64 precision:

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 11 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.5% 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, 1.0× speedup?

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

\\
\left(\frac{x}{y} - -1\right) \cdot \frac{x}{x - -1}
\end{array}
Derivation
  1. Initial program 89.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\frac{x}{y} - \color{blue}{-1}\right) \cdot \frac{x}{x + 1} \]
    14. lower-/.f6499.9

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

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

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

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

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

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

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

      \[\leadsto \left(\frac{x}{y} - -1\right) \cdot \frac{x}{\color{blue}{x - \left(\mathsf{neg}\left(1\right)\right)}} \]
    22. metadata-eval99.9

      \[\leadsto \left(\frac{x}{y} - -1\right) \cdot \frac{x}{x - \color{blue}{-1}} \]
  4. Applied rewrites99.9%

    \[\leadsto \color{blue}{\left(\frac{x}{y} - -1\right) \cdot \frac{x}{x - -1}} \]
  5. Add Preprocessing

Alternative 2: 92.5% 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 -40:\\ \;\;\;\;\frac{x}{\mathsf{fma}\left(y, x, y\right)} \cdot x\\ \mathbf{elif}\;t\_0 \leq 0.02:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{y} - x, x, x\right)\\ \mathbf{elif}\;t\_0 \leq 2:\\ \;\;\;\;\frac{x}{x - -1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y} \cdot x\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ (* x (- (/ x y) -1.0)) (- x -1.0))))
   (if (<= t_0 -40.0)
     (* (/ x (fma y x y)) x)
     (if (<= t_0 0.02)
       (fma (- (/ x y) x) x x)
       (if (<= t_0 2.0) (/ x (- x -1.0)) (* (/ 1.0 y) x))))))
double code(double x, double y) {
	double t_0 = (x * ((x / y) - -1.0)) / (x - -1.0);
	double tmp;
	if (t_0 <= -40.0) {
		tmp = (x / fma(y, x, y)) * x;
	} else if (t_0 <= 0.02) {
		tmp = fma(((x / y) - x), x, x);
	} else if (t_0 <= 2.0) {
		tmp = x / (x - -1.0);
	} else {
		tmp = (1.0 / y) * x;
	}
	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 <= -40.0)
		tmp = Float64(Float64(x / fma(y, x, y)) * x);
	elseif (t_0 <= 0.02)
		tmp = fma(Float64(Float64(x / y) - x), x, x);
	elseif (t_0 <= 2.0)
		tmp = Float64(x / Float64(x - -1.0));
	else
		tmp = Float64(Float64(1.0 / y) * x);
	end
	return 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, -40.0], N[(N[(x / N[(y * x + y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[t$95$0, 0.02], N[(N[(N[(x / y), $MachinePrecision] - x), $MachinePrecision] * x + x), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] * x), $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 -40:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(y, x, y\right)} \cdot x\\

\mathbf{elif}\;t\_0 \leq 0.02:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y} - x, x, x\right)\\

\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;\frac{x}{x - -1}\\

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


\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))) < -40

    1. Initial program 71.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x}{y \cdot x + \color{blue}{y}} \cdot x \]
      9. lower-fma.f6492.1

        \[\leadsto \frac{x}{\color{blue}{\mathsf{fma}\left(y, x, y\right)}} \cdot x \]
    5. Applied rewrites92.1%

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

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

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{x \cdot \left(1 + x \cdot \left(\frac{1}{y} - 1\right)\right)} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

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

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

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

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

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

      \[\leadsto {x}^{2} \cdot \color{blue}{\left(\left(\frac{1}{x} + \frac{1}{y}\right) - 1\right)} \]
    7. Step-by-step derivation
      1. Applied rewrites99.0%

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

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

      1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{x}{x - \color{blue}{-1}} \]
        13. lower--.f6497.4

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

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

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

      1. Initial program 71.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(\frac{x}{y} - \color{blue}{-1}\right) \cdot \frac{x}{x + 1} \]
        14. lower-/.f64100.0

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

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

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

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

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

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

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

          \[\leadsto \left(\frac{x}{y} - -1\right) \cdot \frac{x}{\color{blue}{x - \left(\mathsf{neg}\left(1\right)\right)}} \]
        22. metadata-eval100.0

          \[\leadsto \left(\frac{x}{y} - -1\right) \cdot \frac{x}{x - \color{blue}{-1}} \]
      4. Applied rewrites100.0%

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

        \[\leadsto \color{blue}{\frac{\frac{x \cdot y}{1 + x} + \frac{{x}^{2}}{1 + x}}{y}} \]
      6. Step-by-step derivation
        1. div-add-revN/A

          \[\leadsto \frac{\color{blue}{\frac{x \cdot y + {x}^{2}}{1 + x}}}{y} \]
        2. associate-/l/N/A

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{x \cdot \left(y + x\right)}{y \cdot x + \color{blue}{y}} \]
        14. lower-fma.f6470.5

          \[\leadsto \frac{x \cdot \left(y + x\right)}{\color{blue}{\mathsf{fma}\left(y, x, y\right)}} \]
      7. Applied rewrites70.5%

        \[\leadsto \color{blue}{\frac{x \cdot \left(y + x\right)}{\mathsf{fma}\left(y, x, y\right)}} \]
      8. Step-by-step derivation
        1. Applied rewrites89.8%

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

          \[\leadsto \frac{1}{y} \cdot x \]
        3. Step-by-step derivation
          1. Applied rewrites90.5%

            \[\leadsto \frac{1}{y} \cdot x \]
        4. Recombined 4 regimes into one program.
        5. Final simplification96.0%

          \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(\frac{x}{y} - -1\right)}{x - -1} \leq -40:\\ \;\;\;\;\frac{x}{\mathsf{fma}\left(y, x, y\right)} \cdot x\\ \mathbf{elif}\;\frac{x \cdot \left(\frac{x}{y} - -1\right)}{x - -1} \leq 0.02:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{y} - x, x, x\right)\\ \mathbf{elif}\;\frac{x \cdot \left(\frac{x}{y} - -1\right)}{x - -1} \leq 2:\\ \;\;\;\;\frac{x}{x - -1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y} \cdot x\\ \end{array} \]
        6. Add Preprocessing

        Alternative 3: 92.3% accurate, 0.3× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x \cdot \left(\frac{x}{y} - -1\right)}{x - -1}\\ t_1 := \frac{1}{y} \cdot x\\ \mathbf{if}\;t\_0 \leq -40:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 0.02:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{y} - x, x, x\right)\\ \mathbf{elif}\;t\_0 \leq 2:\\ \;\;\;\;\frac{x}{x - -1}\\ \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 (* (/ 1.0 y) x)))
           (if (<= t_0 -40.0)
             t_1
             (if (<= t_0 0.02)
               (fma (- (/ x y) x) x x)
               (if (<= t_0 2.0) (/ x (- x -1.0)) t_1)))))
        double code(double x, double y) {
        	double t_0 = (x * ((x / y) - -1.0)) / (x - -1.0);
        	double t_1 = (1.0 / y) * x;
        	double tmp;
        	if (t_0 <= -40.0) {
        		tmp = t_1;
        	} else if (t_0 <= 0.02) {
        		tmp = fma(((x / y) - x), x, x);
        	} else if (t_0 <= 2.0) {
        		tmp = x / (x - -1.0);
        	} 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(1.0 / y) * x)
        	tmp = 0.0
        	if (t_0 <= -40.0)
        		tmp = t_1;
        	elseif (t_0 <= 0.02)
        		tmp = fma(Float64(Float64(x / y) - x), x, x);
        	elseif (t_0 <= 2.0)
        		tmp = Float64(x / Float64(x - -1.0));
        	else
        		tmp = t_1;
        	end
        	return 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[(1.0 / y), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[t$95$0, -40.0], t$95$1, If[LessEqual[t$95$0, 0.02], N[(N[(N[(x / y), $MachinePrecision] - x), $MachinePrecision] * x + x), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], 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{1}{y} \cdot x\\
        \mathbf{if}\;t\_0 \leq -40:\\
        \;\;\;\;t\_1\\
        
        \mathbf{elif}\;t\_0 \leq 0.02:\\
        \;\;\;\;\mathsf{fma}\left(\frac{x}{y} - x, x, x\right)\\
        
        \mathbf{elif}\;t\_0 \leq 2:\\
        \;\;\;\;\frac{x}{x - -1}\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_1\\
        
        
        \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))) < -40 or 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64)))

          1. Initial program 71.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \left(\frac{x}{y} - \color{blue}{-1}\right) \cdot \frac{x}{x + 1} \]
            14. lower-/.f6499.9

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

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

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

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

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

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

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

              \[\leadsto \left(\frac{x}{y} - -1\right) \cdot \frac{x}{\color{blue}{x - \left(\mathsf{neg}\left(1\right)\right)}} \]
            22. metadata-eval99.9

              \[\leadsto \left(\frac{x}{y} - -1\right) \cdot \frac{x}{x - \color{blue}{-1}} \]
          4. Applied rewrites99.9%

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

            \[\leadsto \color{blue}{\frac{\frac{x \cdot y}{1 + x} + \frac{{x}^{2}}{1 + x}}{y}} \]
          6. Step-by-step derivation
            1. div-add-revN/A

              \[\leadsto \frac{\color{blue}{\frac{x \cdot y + {x}^{2}}{1 + x}}}{y} \]
            2. associate-/l/N/A

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \frac{x \cdot \left(y + x\right)}{y \cdot x + \color{blue}{y}} \]
            14. lower-fma.f6472.0

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

            \[\leadsto \color{blue}{\frac{x \cdot \left(y + x\right)}{\mathsf{fma}\left(y, x, y\right)}} \]
          8. Step-by-step derivation
            1. Applied rewrites92.2%

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

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

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

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

              1. Initial program 99.8%

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

                \[\leadsto \color{blue}{x \cdot \left(1 + x \cdot \left(\frac{1}{y} - 1\right)\right)} \]
              4. Step-by-step derivation
                1. *-commutativeN/A

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

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

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

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

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

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

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

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

                \[\leadsto {x}^{2} \cdot \color{blue}{\left(\left(\frac{1}{x} + \frac{1}{y}\right) - 1\right)} \]
              7. Step-by-step derivation
                1. Applied rewrites99.0%

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

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

                1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \frac{x}{x - \color{blue}{-1}} \]
                  13. lower--.f6497.4

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

                  \[\leadsto \color{blue}{\frac{x}{x - -1}} \]
              8. Recombined 3 regimes into one program.
              9. Final simplification95.3%

                \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(\frac{x}{y} - -1\right)}{x - -1} \leq -40:\\ \;\;\;\;\frac{1}{y} \cdot x\\ \mathbf{elif}\;\frac{x \cdot \left(\frac{x}{y} - -1\right)}{x - -1} \leq 0.02:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{y} - x, x, x\right)\\ \mathbf{elif}\;\frac{x \cdot \left(\frac{x}{y} - -1\right)}{x - -1} \leq 2:\\ \;\;\;\;\frac{x}{x - -1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y} \cdot x\\ \end{array} \]
              10. Add Preprocessing

              Alternative 4: 99.5% 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 -\infty \lor \neg \left(t\_0 \leq 2 \cdot 10^{+208}\right):\\ \;\;\;\;\frac{1}{y} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x - -1}\\ \end{array} \end{array} \]
              (FPCore (x y)
               :precision binary64
               (let* ((t_0 (/ (* x (- (/ x y) -1.0)) (- x -1.0))))
                 (if (or (<= t_0 (- INFINITY)) (not (<= t_0 2e+208)))
                   (* (/ 1.0 y) x)
                   (/ (fma (/ x y) x x) (- x -1.0)))))
              double code(double x, double y) {
              	double t_0 = (x * ((x / y) - -1.0)) / (x - -1.0);
              	double tmp;
              	if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 2e+208)) {
              		tmp = (1.0 / y) * x;
              	} else {
              		tmp = fma((x / y), x, x) / (x - -1.0);
              	}
              	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 <= Float64(-Inf)) || !(t_0 <= 2e+208))
              		tmp = Float64(Float64(1.0 / y) * x);
              	else
              		tmp = Float64(fma(Float64(x / y), x, x) / Float64(x - -1.0));
              	end
              	return 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[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 2e+208]], $MachinePrecision]], N[(N[(1.0 / y), $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(x / y), $MachinePrecision] * x + x), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $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 -\infty \lor \neg \left(t\_0 \leq 2 \cdot 10^{+208}\right):\\
              \;\;\;\;\frac{1}{y} \cdot x\\
              
              \mathbf{else}:\\
              \;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x - -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))) < -inf.0 or 2e208 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64)))

                1. Initial program 51.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \left(\frac{x}{y} - \color{blue}{-1}\right) \cdot \frac{x}{x + 1} \]
                  14. lower-/.f64100.0

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

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

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

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

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

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

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

                    \[\leadsto \left(\frac{x}{y} - -1\right) \cdot \frac{x}{\color{blue}{x - \left(\mathsf{neg}\left(1\right)\right)}} \]
                  22. metadata-eval100.0

                    \[\leadsto \left(\frac{x}{y} - -1\right) \cdot \frac{x}{x - \color{blue}{-1}} \]
                4. Applied rewrites100.0%

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

                  \[\leadsto \color{blue}{\frac{\frac{x \cdot y}{1 + x} + \frac{{x}^{2}}{1 + x}}{y}} \]
                6. Step-by-step derivation
                  1. div-add-revN/A

                    \[\leadsto \frac{\color{blue}{\frac{x \cdot y + {x}^{2}}{1 + x}}}{y} \]
                  2. associate-/l/N/A

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \frac{x \cdot \left(y + x\right)}{y \cdot x + \color{blue}{y}} \]
                  14. lower-fma.f6463.4

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

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

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

                    \[\leadsto \frac{1}{y} \cdot x \]
                  3. Step-by-step derivation
                    1. Applied rewrites99.7%

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

                    if -inf.0 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 2e208

                    1. Initial program 99.8%

                      \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
                    2. Add Preprocessing
                    3. 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. distribute-rgt-inN/A

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

                        \[\leadsto \frac{\frac{x}{y} \cdot x + \color{blue}{x}}{x + 1} \]
                      5. lower-fma.f6499.8

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

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

                        \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x + \color{blue}{1 \cdot 1}} \]
                      8. 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}} \]
                      9. metadata-evalN/A

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

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

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

                        \[\leadsto \frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{\color{blue}{x - \left(\mathsf{neg}\left(1\right)\right)}} \]
                      13. metadata-eval99.8

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

                      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x - -1}} \]
                  4. Recombined 2 regimes into one program.
                  5. Final simplification99.8%

                    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(\frac{x}{y} - -1\right)}{x - -1} \leq -\infty \lor \neg \left(\frac{x \cdot \left(\frac{x}{y} - -1\right)}{x - -1} \leq 2 \cdot 10^{+208}\right):\\ \;\;\;\;\frac{1}{y} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x - -1}\\ \end{array} \]
                  6. Add Preprocessing

                  Alternative 5: 85.8% accurate, 0.4× 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 -40 \lor \neg \left(t\_0 \leq 2\right):\\ \;\;\;\;\frac{1}{y} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x - -1}\\ \end{array} \end{array} \]
                  (FPCore (x y)
                   :precision binary64
                   (let* ((t_0 (/ (* x (- (/ x y) -1.0)) (- x -1.0))))
                     (if (or (<= t_0 -40.0) (not (<= t_0 2.0)))
                       (* (/ 1.0 y) x)
                       (/ x (- x -1.0)))))
                  double code(double x, double y) {
                  	double t_0 = (x * ((x / y) - -1.0)) / (x - -1.0);
                  	double tmp;
                  	if ((t_0 <= -40.0) || !(t_0 <= 2.0)) {
                  		tmp = (1.0 / y) * x;
                  	} else {
                  		tmp = x / (x - -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) :: t_0
                      real(8) :: tmp
                      t_0 = (x * ((x / y) - (-1.0d0))) / (x - (-1.0d0))
                      if ((t_0 <= (-40.0d0)) .or. (.not. (t_0 <= 2.0d0))) then
                          tmp = (1.0d0 / y) * x
                      else
                          tmp = x / (x - (-1.0d0))
                      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 <= -40.0) || !(t_0 <= 2.0)) {
                  		tmp = (1.0 / y) * x;
                  	} else {
                  		tmp = x / (x - -1.0);
                  	}
                  	return tmp;
                  }
                  
                  def code(x, y):
                  	t_0 = (x * ((x / y) - -1.0)) / (x - -1.0)
                  	tmp = 0
                  	if (t_0 <= -40.0) or not (t_0 <= 2.0):
                  		tmp = (1.0 / y) * x
                  	else:
                  		tmp = x / (x - -1.0)
                  	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 <= -40.0) || !(t_0 <= 2.0))
                  		tmp = Float64(Float64(1.0 / y) * x);
                  	else
                  		tmp = Float64(x / Float64(x - -1.0));
                  	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 <= -40.0) || ~((t_0 <= 2.0)))
                  		tmp = (1.0 / y) * x;
                  	else
                  		tmp = x / (x - -1.0);
                  	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[Or[LessEqual[t$95$0, -40.0], N[Not[LessEqual[t$95$0, 2.0]], $MachinePrecision]], N[(N[(1.0 / y), $MachinePrecision] * x), $MachinePrecision], N[(x / N[(x - -1.0), $MachinePrecision]), $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 -40 \lor \neg \left(t\_0 \leq 2\right):\\
                  \;\;\;\;\frac{1}{y} \cdot x\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\frac{x}{x - -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))) < -40 or 2 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64)))

                    1. Initial program 71.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \left(\frac{x}{y} - \color{blue}{-1}\right) \cdot \frac{x}{x + 1} \]
                      14. lower-/.f6499.9

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

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

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

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

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

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

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

                        \[\leadsto \left(\frac{x}{y} - -1\right) \cdot \frac{x}{\color{blue}{x - \left(\mathsf{neg}\left(1\right)\right)}} \]
                      22. metadata-eval99.9

                        \[\leadsto \left(\frac{x}{y} - -1\right) \cdot \frac{x}{x - \color{blue}{-1}} \]
                    4. Applied rewrites99.9%

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

                      \[\leadsto \color{blue}{\frac{\frac{x \cdot y}{1 + x} + \frac{{x}^{2}}{1 + x}}{y}} \]
                    6. Step-by-step derivation
                      1. div-add-revN/A

                        \[\leadsto \frac{\color{blue}{\frac{x \cdot y + {x}^{2}}{1 + x}}}{y} \]
                      2. associate-/l/N/A

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \frac{x \cdot \left(y + x\right)}{y \cdot x + \color{blue}{y}} \]
                      14. lower-fma.f6472.0

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

                      \[\leadsto \color{blue}{\frac{x \cdot \left(y + x\right)}{\mathsf{fma}\left(y, x, y\right)}} \]
                    8. Step-by-step derivation
                      1. Applied rewrites92.2%

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

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

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

                        if -40 < (/.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. Add Preprocessing
                        3. Taylor expanded in y around inf

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

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

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

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

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

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

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

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

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

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

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

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

                            \[\leadsto \frac{x}{x - \color{blue}{-1}} \]
                          13. lower--.f6488.3

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

                          \[\leadsto \color{blue}{\frac{x}{x - -1}} \]
                      4. Recombined 2 regimes into one program.
                      5. Final simplification88.7%

                        \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(\frac{x}{y} - -1\right)}{x - -1} \leq -40 \lor \neg \left(\frac{x \cdot \left(\frac{x}{y} - -1\right)}{x - -1} \leq 2\right):\\ \;\;\;\;\frac{1}{y} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x - -1}\\ \end{array} \]
                      6. Add Preprocessing

                      Alternative 6: 92.9% accurate, 0.4× 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 0.9999999:\\ \;\;\;\;\frac{y + x}{\mathsf{fma}\left(y, x, y\right)} \cdot x\\ \mathbf{elif}\;t\_0 \leq 2:\\ \;\;\;\;\frac{x}{x - -1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y} \cdot x\\ \end{array} \end{array} \]
                      (FPCore (x y)
                       :precision binary64
                       (let* ((t_0 (/ (* x (- (/ x y) -1.0)) (- x -1.0))))
                         (if (<= t_0 0.9999999)
                           (* (/ (+ y x) (fma y x y)) x)
                           (if (<= t_0 2.0) (/ x (- x -1.0)) (* (/ 1.0 y) x)))))
                      double code(double x, double y) {
                      	double t_0 = (x * ((x / y) - -1.0)) / (x - -1.0);
                      	double tmp;
                      	if (t_0 <= 0.9999999) {
                      		tmp = ((y + x) / fma(y, x, y)) * x;
                      	} else if (t_0 <= 2.0) {
                      		tmp = x / (x - -1.0);
                      	} else {
                      		tmp = (1.0 / y) * x;
                      	}
                      	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 <= 0.9999999)
                      		tmp = Float64(Float64(Float64(y + x) / fma(y, x, y)) * x);
                      	elseif (t_0 <= 2.0)
                      		tmp = Float64(x / Float64(x - -1.0));
                      	else
                      		tmp = Float64(Float64(1.0 / y) * x);
                      	end
                      	return 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, 0.9999999], N[(N[(N[(y + x), $MachinePrecision] / N[(y * x + y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] * x), $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 0.9999999:\\
                      \;\;\;\;\frac{y + x}{\mathsf{fma}\left(y, x, y\right)} \cdot x\\
                      
                      \mathbf{elif}\;t\_0 \leq 2:\\
                      \;\;\;\;\frac{x}{x - -1}\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\frac{1}{y} \cdot x\\
                      
                      
                      \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))) < 0.999999900000000053

                        1. Initial program 91.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

                            \[\leadsto \left(\frac{x}{y} - \color{blue}{-1}\right) \cdot \frac{x}{x + 1} \]
                          14. lower-/.f6499.9

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

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

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

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

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

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

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

                            \[\leadsto \left(\frac{x}{y} - -1\right) \cdot \frac{x}{\color{blue}{x - \left(\mathsf{neg}\left(1\right)\right)}} \]
                          22. metadata-eval99.9

                            \[\leadsto \left(\frac{x}{y} - -1\right) \cdot \frac{x}{x - \color{blue}{-1}} \]
                        4. Applied rewrites99.9%

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

                          \[\leadsto \color{blue}{\frac{\frac{x \cdot y}{1 + x} + \frac{{x}^{2}}{1 + x}}{y}} \]
                        6. Step-by-step derivation
                          1. div-add-revN/A

                            \[\leadsto \frac{\color{blue}{\frac{x \cdot y + {x}^{2}}{1 + x}}}{y} \]
                          2. associate-/l/N/A

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

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

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

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

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

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

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

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

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

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

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

                            \[\leadsto \frac{x \cdot \left(y + x\right)}{y \cdot x + \color{blue}{y}} \]
                          14. lower-fma.f6477.9

                            \[\leadsto \frac{x \cdot \left(y + x\right)}{\color{blue}{\mathsf{fma}\left(y, x, y\right)}} \]
                        7. Applied rewrites77.9%

                          \[\leadsto \color{blue}{\frac{x \cdot \left(y + x\right)}{\mathsf{fma}\left(y, x, y\right)}} \]
                        8. Step-by-step derivation
                          1. Applied rewrites98.1%

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

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

                          1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

                              \[\leadsto \frac{x}{x - \color{blue}{-1}} \]
                            13. lower--.f6498.5

                              \[\leadsto \frac{x}{\color{blue}{x - -1}} \]
                          5. Applied rewrites98.5%

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

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

                          1. Initial program 71.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

                              \[\leadsto \left(\frac{x}{y} - \color{blue}{-1}\right) \cdot \frac{x}{x + 1} \]
                            14. lower-/.f64100.0

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

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

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

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

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

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

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

                              \[\leadsto \left(\frac{x}{y} - -1\right) \cdot \frac{x}{\color{blue}{x - \left(\mathsf{neg}\left(1\right)\right)}} \]
                            22. metadata-eval100.0

                              \[\leadsto \left(\frac{x}{y} - -1\right) \cdot \frac{x}{x - \color{blue}{-1}} \]
                          4. Applied rewrites100.0%

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

                            \[\leadsto \color{blue}{\frac{\frac{x \cdot y}{1 + x} + \frac{{x}^{2}}{1 + x}}{y}} \]
                          6. Step-by-step derivation
                            1. div-add-revN/A

                              \[\leadsto \frac{\color{blue}{\frac{x \cdot y + {x}^{2}}{1 + x}}}{y} \]
                            2. associate-/l/N/A

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

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

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

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

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

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

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

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

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

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

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

                              \[\leadsto \frac{x \cdot \left(y + x\right)}{y \cdot x + \color{blue}{y}} \]
                            14. lower-fma.f6470.5

                              \[\leadsto \frac{x \cdot \left(y + x\right)}{\color{blue}{\mathsf{fma}\left(y, x, y\right)}} \]
                          7. Applied rewrites70.5%

                            \[\leadsto \color{blue}{\frac{x \cdot \left(y + x\right)}{\mathsf{fma}\left(y, x, y\right)}} \]
                          8. Step-by-step derivation
                            1. Applied rewrites89.8%

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

                              \[\leadsto \frac{1}{y} \cdot x \]
                            3. Step-by-step derivation
                              1. Applied rewrites90.5%

                                \[\leadsto \frac{1}{y} \cdot x \]
                            4. Recombined 3 regimes into one program.
                            5. Final simplification97.0%

                              \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(\frac{x}{y} - -1\right)}{x - -1} \leq 0.9999999:\\ \;\;\;\;\frac{y + x}{\mathsf{fma}\left(y, x, y\right)} \cdot x\\ \mathbf{elif}\;\frac{x \cdot \left(\frac{x}{y} - -1\right)}{x - -1} \leq 2:\\ \;\;\;\;\frac{x}{x - -1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y} \cdot x\\ \end{array} \]
                            6. Add Preprocessing

                            Alternative 7: 56.0% accurate, 0.6× speedup?

                            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(\frac{x}{y} - -1\right)}{x - -1} \leq -40:\\ \;\;\;\;\left(1 - x\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x - -1}\\ \end{array} \end{array} \]
                            (FPCore (x y)
                             :precision binary64
                             (if (<= (/ (* x (- (/ x y) -1.0)) (- x -1.0)) -40.0)
                               (* (- 1.0 x) x)
                               (/ x (- x -1.0))))
                            double code(double x, double y) {
                            	double tmp;
                            	if (((x * ((x / y) - -1.0)) / (x - -1.0)) <= -40.0) {
                            		tmp = (1.0 - x) * x;
                            	} else {
                            		tmp = x / (x - -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))) <= (-40.0d0)) then
                                    tmp = (1.0d0 - x) * x
                                else
                                    tmp = x / (x - (-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)) <= -40.0) {
                            		tmp = (1.0 - x) * x;
                            	} else {
                            		tmp = x / (x - -1.0);
                            	}
                            	return tmp;
                            }
                            
                            def code(x, y):
                            	tmp = 0
                            	if ((x * ((x / y) - -1.0)) / (x - -1.0)) <= -40.0:
                            		tmp = (1.0 - x) * x
                            	else:
                            		tmp = x / (x - -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)) <= -40.0)
                            		tmp = Float64(Float64(1.0 - x) * x);
                            	else
                            		tmp = Float64(x / Float64(x - -1.0));
                            	end
                            	return tmp
                            end
                            
                            function tmp_2 = code(x, y)
                            	tmp = 0.0;
                            	if (((x * ((x / y) - -1.0)) / (x - -1.0)) <= -40.0)
                            		tmp = (1.0 - x) * x;
                            	else
                            		tmp = x / (x - -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], -40.0], N[(N[(1.0 - x), $MachinePrecision] * x), $MachinePrecision], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]]
                            
                            \begin{array}{l}
                            
                            \\
                            \begin{array}{l}
                            \mathbf{if}\;\frac{x \cdot \left(\frac{x}{y} - -1\right)}{x - -1} \leq -40:\\
                            \;\;\;\;\left(1 - x\right) \cdot x\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;\frac{x}{x - -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))) < -40

                              1. Initial program 71.9%

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

                                \[\leadsto \color{blue}{x \cdot \left(1 + x \cdot \left(\frac{1}{y} - 1\right)\right)} \]
                              4. Step-by-step derivation
                                1. *-commutativeN/A

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

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

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

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

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

                                  \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{y} - 1}, x, 1\right) \cdot x \]
                                7. lower-/.f6422.0

                                  \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{y}} - 1, x, 1\right) \cdot x \]
                              5. Applied rewrites22.0%

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

                                \[\leadsto \left(1 + -1 \cdot x\right) \cdot x \]
                              7. Step-by-step derivation
                                1. Applied rewrites27.1%

                                  \[\leadsto \left(1 - x\right) \cdot x \]

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

                                1. Initial program 94.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    \[\leadsto \frac{x}{x - \color{blue}{-1}} \]
                                  13. lower--.f6472.3

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

                                  \[\leadsto \color{blue}{\frac{x}{x - -1}} \]
                              8. Recombined 2 regimes into one program.
                              9. Final simplification62.9%

                                \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(\frac{x}{y} - -1\right)}{x - -1} \leq -40:\\ \;\;\;\;\left(1 - x\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x - -1}\\ \end{array} \]
                              10. Add Preprocessing

                              Alternative 8: 55.5% accurate, 0.6× speedup?

                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(\frac{x}{y} - -1\right)}{x - -1} \leq 0.4:\\ \;\;\;\;\left(1 - x\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{1}{x}\\ \end{array} \end{array} \]
                              (FPCore (x y)
                               :precision binary64
                               (if (<= (/ (* x (- (/ x y) -1.0)) (- x -1.0)) 0.4)
                                 (* (- 1.0 x) x)
                                 (- 1.0 (/ 1.0 x))))
                              double code(double x, double y) {
                              	double tmp;
                              	if (((x * ((x / y) - -1.0)) / (x - -1.0)) <= 0.4) {
                              		tmp = (1.0 - x) * x;
                              	} else {
                              		tmp = 1.0 - (1.0 / x);
                              	}
                              	return tmp;
                              }
                              
                              module fmin_fmax_functions
                                  implicit none
                                  private
                                  public fmax
                                  public fmin
                              
                                  interface fmax
                                      module procedure fmax88
                                      module procedure fmax44
                                      module procedure fmax84
                                      module procedure fmax48
                                  end interface
                                  interface fmin
                                      module procedure fmin88
                                      module procedure fmin44
                                      module procedure fmin84
                                      module procedure fmin48
                                  end interface
                              contains
                                  real(8) function fmax88(x, y) result (res)
                                      real(8), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                  end function
                                  real(4) function fmax44(x, y) result (res)
                                      real(4), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                  end function
                                  real(8) function fmax84(x, y) result(res)
                                      real(8), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                  end function
                                  real(8) function fmax48(x, y) result(res)
                                      real(4), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                  end function
                                  real(8) function fmin88(x, y) result (res)
                                      real(8), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                  end function
                                  real(4) function fmin44(x, y) result (res)
                                      real(4), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                  end function
                                  real(8) function fmin84(x, y) result(res)
                                      real(8), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                  end function
                                  real(8) function fmin48(x, y) result(res)
                                      real(4), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                  end function
                              end module
                              
                              real(8) function code(x, y)
                              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.4d0) then
                                      tmp = (1.0d0 - x) * x
                                  else
                                      tmp = 1.0d0 - (1.0d0 / x)
                                  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.4) {
                              		tmp = (1.0 - x) * x;
                              	} else {
                              		tmp = 1.0 - (1.0 / x);
                              	}
                              	return tmp;
                              }
                              
                              def code(x, y):
                              	tmp = 0
                              	if ((x * ((x / y) - -1.0)) / (x - -1.0)) <= 0.4:
                              		tmp = (1.0 - x) * x
                              	else:
                              		tmp = 1.0 - (1.0 / x)
                              	return tmp
                              
                              function code(x, y)
                              	tmp = 0.0
                              	if (Float64(Float64(x * Float64(Float64(x / y) - -1.0)) / Float64(x - -1.0)) <= 0.4)
                              		tmp = Float64(Float64(1.0 - x) * x);
                              	else
                              		tmp = Float64(1.0 - Float64(1.0 / x));
                              	end
                              	return tmp
                              end
                              
                              function tmp_2 = code(x, y)
                              	tmp = 0.0;
                              	if (((x * ((x / y) - -1.0)) / (x - -1.0)) <= 0.4)
                              		tmp = (1.0 - x) * x;
                              	else
                              		tmp = 1.0 - (1.0 / x);
                              	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.4], N[(N[(1.0 - x), $MachinePrecision] * x), $MachinePrecision], N[(1.0 - N[(1.0 / x), $MachinePrecision]), $MachinePrecision]]
                              
                              \begin{array}{l}
                              
                              \\
                              \begin{array}{l}
                              \mathbf{if}\;\frac{x \cdot \left(\frac{x}{y} - -1\right)}{x - -1} \leq 0.4:\\
                              \;\;\;\;\left(1 - x\right) \cdot x\\
                              
                              \mathbf{else}:\\
                              \;\;\;\;1 - \frac{1}{x}\\
                              
                              
                              \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.40000000000000002

                                1. Initial program 91.6%

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

                                  \[\leadsto \color{blue}{x \cdot \left(1 + x \cdot \left(\frac{1}{y} - 1\right)\right)} \]
                                4. Step-by-step derivation
                                  1. *-commutativeN/A

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

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

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

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

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

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

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

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

                                  \[\leadsto \left(1 + -1 \cdot x\right) \cdot x \]
                                7. Step-by-step derivation
                                  1. Applied rewrites67.3%

                                    \[\leadsto \left(1 - x\right) \cdot x \]

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

                                  1. Initial program 85.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

                                      \[\leadsto \frac{x}{x - \color{blue}{-1}} \]
                                    13. lower--.f6450.4

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

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

                                    \[\leadsto 1 - \color{blue}{\frac{1}{x}} \]
                                  7. Step-by-step derivation
                                    1. Applied rewrites49.2%

                                      \[\leadsto 1 - \color{blue}{\frac{1}{x}} \]
                                  8. Recombined 2 regimes into one program.
                                  9. Final simplification61.8%

                                    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(\frac{x}{y} - -1\right)}{x - -1} \leq 0.4:\\ \;\;\;\;\left(1 - x\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{1}{x}\\ \end{array} \]
                                  10. Add Preprocessing

                                  Alternative 9: 46.2% accurate, 0.6× speedup?

                                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(\frac{x}{y} - -1\right)}{x - -1} \leq -40:\\ \;\;\;\;\left(1 - x\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x - 1, x, 1\right) \cdot x\\ \end{array} \end{array} \]
                                  (FPCore (x y)
                                   :precision binary64
                                   (if (<= (/ (* x (- (/ x y) -1.0)) (- x -1.0)) -40.0)
                                     (* (- 1.0 x) x)
                                     (* (fma (- x 1.0) x 1.0) x)))
                                  double code(double x, double y) {
                                  	double tmp;
                                  	if (((x * ((x / y) - -1.0)) / (x - -1.0)) <= -40.0) {
                                  		tmp = (1.0 - x) * x;
                                  	} else {
                                  		tmp = fma((x - 1.0), x, 1.0) * x;
                                  	}
                                  	return tmp;
                                  }
                                  
                                  function code(x, y)
                                  	tmp = 0.0
                                  	if (Float64(Float64(x * Float64(Float64(x / y) - -1.0)) / Float64(x - -1.0)) <= -40.0)
                                  		tmp = Float64(Float64(1.0 - x) * x);
                                  	else
                                  		tmp = Float64(fma(Float64(x - 1.0), x, 1.0) * x);
                                  	end
                                  	return 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], -40.0], N[(N[(1.0 - x), $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(x - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * x), $MachinePrecision]]
                                  
                                  \begin{array}{l}
                                  
                                  \\
                                  \begin{array}{l}
                                  \mathbf{if}\;\frac{x \cdot \left(\frac{x}{y} - -1\right)}{x - -1} \leq -40:\\
                                  \;\;\;\;\left(1 - x\right) \cdot x\\
                                  
                                  \mathbf{else}:\\
                                  \;\;\;\;\mathsf{fma}\left(x - 1, x, 1\right) \cdot x\\
                                  
                                  
                                  \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))) < -40

                                    1. Initial program 71.9%

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

                                      \[\leadsto \color{blue}{x \cdot \left(1 + x \cdot \left(\frac{1}{y} - 1\right)\right)} \]
                                    4. Step-by-step derivation
                                      1. *-commutativeN/A

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

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

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

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

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

                                        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{y} - 1}, x, 1\right) \cdot x \]
                                      7. lower-/.f6422.0

                                        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{y}} - 1, x, 1\right) \cdot x \]
                                    5. Applied rewrites22.0%

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

                                      \[\leadsto \left(1 + -1 \cdot x\right) \cdot x \]
                                    7. Step-by-step derivation
                                      1. Applied rewrites27.1%

                                        \[\leadsto \left(1 - x\right) \cdot x \]

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

                                      1. Initial program 94.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

                                          \[\leadsto \frac{x}{x - \color{blue}{-1}} \]
                                        13. lower--.f6472.3

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

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

                                        \[\leadsto 1 - \color{blue}{\frac{1}{x}} \]
                                      7. Step-by-step derivation
                                        1. Applied rewrites19.7%

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

                                          \[\leadsto x \cdot \color{blue}{\left(1 + x \cdot \left(x - 1\right)\right)} \]
                                        3. Step-by-step derivation
                                          1. Applied rewrites55.6%

                                            \[\leadsto \mathsf{fma}\left(x - 1, x, 1\right) \cdot \color{blue}{x} \]
                                        4. Recombined 2 regimes into one program.
                                        5. Final simplification49.7%

                                          \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(\frac{x}{y} - -1\right)}{x - -1} \leq -40:\\ \;\;\;\;\left(1 - x\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x - 1, x, 1\right) \cdot x\\ \end{array} \]
                                        6. Add Preprocessing

                                        Alternative 10: 42.7% accurate, 3.8× speedup?

                                        \[\begin{array}{l} \\ \left(1 - x\right) \cdot x \end{array} \]
                                        (FPCore (x y) :precision binary64 (* (- 1.0 x) x))
                                        double code(double x, double y) {
                                        	return (1.0 - x) * 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 = (1.0d0 - x) * x
                                        end function
                                        
                                        public static double code(double x, double y) {
                                        	return (1.0 - x) * x;
                                        }
                                        
                                        def code(x, y):
                                        	return (1.0 - x) * x
                                        
                                        function code(x, y)
                                        	return Float64(Float64(1.0 - x) * x)
                                        end
                                        
                                        function tmp = code(x, y)
                                        	tmp = (1.0 - x) * x;
                                        end
                                        
                                        code[x_, y_] := N[(N[(1.0 - x), $MachinePrecision] * x), $MachinePrecision]
                                        
                                        \begin{array}{l}
                                        
                                        \\
                                        \left(1 - x\right) \cdot x
                                        \end{array}
                                        
                                        Derivation
                                        1. Initial program 89.7%

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

                                          \[\leadsto \color{blue}{x \cdot \left(1 + x \cdot \left(\frac{1}{y} - 1\right)\right)} \]
                                        4. Step-by-step derivation
                                          1. *-commutativeN/A

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

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

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

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

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

                                            \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{y} - 1}, x, 1\right) \cdot x \]
                                          7. lower-/.f6456.1

                                            \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{y}} - 1, x, 1\right) \cdot x \]
                                        5. Applied rewrites56.1%

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

                                          \[\leadsto \left(1 + -1 \cdot x\right) \cdot x \]
                                        7. Step-by-step derivation
                                          1. Applied rewrites47.3%

                                            \[\leadsto \left(1 - x\right) \cdot x \]
                                          2. Add Preprocessing

                                          Alternative 11: 39.0% accurate, 5.7× speedup?

                                          \[\begin{array}{l} \\ 1 \cdot x \end{array} \]
                                          (FPCore (x y) :precision binary64 (* 1.0 x))
                                          double code(double x, double y) {
                                          	return 1.0 * 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 = 1.0d0 * x
                                          end function
                                          
                                          public static double code(double x, double y) {
                                          	return 1.0 * x;
                                          }
                                          
                                          def code(x, y):
                                          	return 1.0 * x
                                          
                                          function code(x, y)
                                          	return Float64(1.0 * x)
                                          end
                                          
                                          function tmp = code(x, y)
                                          	tmp = 1.0 * x;
                                          end
                                          
                                          code[x_, y_] := N[(1.0 * x), $MachinePrecision]
                                          
                                          \begin{array}{l}
                                          
                                          \\
                                          1 \cdot x
                                          \end{array}
                                          
                                          Derivation
                                          1. Initial program 89.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

                                              \[\leadsto \left(\frac{x}{y} - \color{blue}{-1}\right) \cdot \frac{x}{x + 1} \]
                                            14. lower-/.f6499.9

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

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

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

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

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

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

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

                                              \[\leadsto \left(\frac{x}{y} - -1\right) \cdot \frac{x}{\color{blue}{x - \left(\mathsf{neg}\left(1\right)\right)}} \]
                                            22. metadata-eval99.9

                                              \[\leadsto \left(\frac{x}{y} - -1\right) \cdot \frac{x}{x - \color{blue}{-1}} \]
                                          4. Applied rewrites99.9%

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

                                            \[\leadsto \color{blue}{\frac{\frac{x \cdot y}{1 + x} + \frac{{x}^{2}}{1 + x}}{y}} \]
                                          6. Step-by-step derivation
                                            1. div-add-revN/A

                                              \[\leadsto \frac{\color{blue}{\frac{x \cdot y + {x}^{2}}{1 + x}}}{y} \]
                                            2. associate-/l/N/A

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

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

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

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

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

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

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

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

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

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

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

                                              \[\leadsto \frac{x \cdot \left(y + x\right)}{y \cdot x + \color{blue}{y}} \]
                                            14. lower-fma.f6474.4

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

                                            \[\leadsto \color{blue}{\frac{x \cdot \left(y + x\right)}{\mathsf{fma}\left(y, x, y\right)}} \]
                                          8. Step-by-step derivation
                                            1. Applied rewrites91.8%

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

                                              \[\leadsto 1 \cdot x \]
                                            3. Step-by-step derivation
                                              1. Applied rewrites42.8%

                                                \[\leadsto 1 \cdot x \]
                                              2. Final simplification42.8%

                                                \[\leadsto 1 \cdot x \]
                                              3. Add Preprocessing

                                              Developer Target 1: 99.8% accurate, 0.8× speedup?

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

                                              Reproduce

                                              ?
                                              herbie shell --seed 2025017 
                                              (FPCore (x y)
                                                :name "Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1"
                                                :precision binary64
                                              
                                                :alt
                                                (! :herbie-platform default (* (/ x 1) (/ (+ (/ x y) 1) (+ x 1))))
                                              
                                                (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))