Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A

Percentage Accurate: 88.6% → 99.8%
Time: 46.1s
Alternatives: 9
Speedup: 0.3×

Specification

?
\[\frac{x + y}{1 - \frac{y}{z}} \]
(FPCore (x y z)
  :precision binary64
  (/ (+ x y) (- 1 (/ y z))))
double code(double x, double y, double z) {
	return (x + y) / (1.0 - (y / z));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x + y) / (1.0d0 - (y / z))
end function
public static double code(double x, double y, double z) {
	return (x + y) / (1.0 - (y / z));
}
def code(x, y, z):
	return (x + y) / (1.0 - (y / z))
function code(x, y, z)
	return Float64(Float64(x + y) / Float64(1.0 - Float64(y / z)))
end
function tmp = code(x, y, z)
	tmp = (x + y) / (1.0 - (y / z));
end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] / N[(1 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x + y}{1 - \frac{y}{z}}

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 9 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.6% accurate, 1.0× speedup?

\[\frac{x + y}{1 - \frac{y}{z}} \]
(FPCore (x y z)
  :precision binary64
  (/ (+ x y) (- 1 (/ y z))))
double code(double x, double y, double z) {
	return (x + y) / (1.0 - (y / z));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x + y) / (1.0d0 - (y / z))
end function
public static double code(double x, double y, double z) {
	return (x + y) / (1.0 - (y / z));
}
def code(x, y, z):
	return (x + y) / (1.0 - (y / z))
function code(x, y, z)
	return Float64(Float64(x + y) / Float64(1.0 - Float64(y / z)))
end
function tmp = code(x, y, z)
	tmp = (x + y) / (1.0 - (y / z));
end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] / N[(1 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x + y}{1 - \frac{y}{z}}

Alternative 1: 99.8% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := \frac{x + y}{1 - \frac{y}{z}}\\ t_1 := \frac{z}{z - y} \cdot \left(y + x\right)\\ \mathbf{if}\;t\_0 \leq \frac{-6237000967295999}{311850048364799970571308236412006025948039259443040240859773006630814358104525635278899682108224328295209757319405077381870693435686499009490495593482004909425000886398607136955865268975681716747289586991334988123957939133612635998263883635695006899610487641699336881506618514879741251551232}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 0:\\ \;\;\;\;\frac{x}{z - y} \cdot z - \frac{y}{y - z} \cdot z\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
(FPCore (x y z)
  :precision binary64
  (let* ((t_0 (/ (+ x y) (- 1 (/ y z))))
       (t_1 (* (/ z (- z y)) (+ y x))))
  (if (<=
       t_0
       -6237000967295999/311850048364799970571308236412006025948039259443040240859773006630814358104525635278899682108224328295209757319405077381870693435686499009490495593482004909425000886398607136955865268975681716747289586991334988123957939133612635998263883635695006899610487641699336881506618514879741251551232)
    t_1
    (if (<= t_0 0) (- (* (/ x (- z y)) z) (* (/ y (- y z)) z)) t_1))))
double code(double x, double y, double z) {
	double t_0 = (x + y) / (1.0 - (y / z));
	double t_1 = (z / (z - y)) * (y + x);
	double tmp;
	if (t_0 <= -2e-275) {
		tmp = t_1;
	} else if (t_0 <= 0.0) {
		tmp = ((x / (z - y)) * z) - ((y / (y - z)) * z);
	} else {
		tmp = t_1;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (x + y) / (1.0d0 - (y / z))
    t_1 = (z / (z - y)) * (y + x)
    if (t_0 <= (-2d-275)) then
        tmp = t_1
    else if (t_0 <= 0.0d0) then
        tmp = ((x / (z - y)) * z) - ((y / (y - z)) * z)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = (x + y) / (1.0 - (y / z));
	double t_1 = (z / (z - y)) * (y + x);
	double tmp;
	if (t_0 <= -2e-275) {
		tmp = t_1;
	} else if (t_0 <= 0.0) {
		tmp = ((x / (z - y)) * z) - ((y / (y - z)) * z);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (x + y) / (1.0 - (y / z))
	t_1 = (z / (z - y)) * (y + x)
	tmp = 0
	if t_0 <= -2e-275:
		tmp = t_1
	elif t_0 <= 0.0:
		tmp = ((x / (z - y)) * z) - ((y / (y - z)) * z)
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(x + y) / Float64(1.0 - Float64(y / z)))
	t_1 = Float64(Float64(z / Float64(z - y)) * Float64(y + x))
	tmp = 0.0
	if (t_0 <= -2e-275)
		tmp = t_1;
	elseif (t_0 <= 0.0)
		tmp = Float64(Float64(Float64(x / Float64(z - y)) * z) - Float64(Float64(y / Float64(y - z)) * z));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (x + y) / (1.0 - (y / z));
	t_1 = (z / (z - y)) * (y + x);
	tmp = 0.0;
	if (t_0 <= -2e-275)
		tmp = t_1;
	elseif (t_0 <= 0.0)
		tmp = ((x / (z - y)) * z) - ((y / (y - z)) * z);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] / N[(1 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(z / N[(z - y), $MachinePrecision]), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -6237000967295999/311850048364799970571308236412006025948039259443040240859773006630814358104525635278899682108224328295209757319405077381870693435686499009490495593482004909425000886398607136955865268975681716747289586991334988123957939133612635998263883635695006899610487641699336881506618514879741251551232], t$95$1, If[LessEqual[t$95$0, 0], N[(N[(N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision] - N[(N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
t_1 := \frac{z}{z - y} \cdot \left(y + x\right)\\
\mathbf{if}\;t\_0 \leq \frac{-6237000967295999}{311850048364799970571308236412006025948039259443040240859773006630814358104525635278899682108224328295209757319405077381870693435686499009490495593482004909425000886398607136955865268975681716747289586991334988123957939133612635998263883635695006899610487641699336881506618514879741251551232}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\frac{x}{z - y} \cdot z - \frac{y}{y - z} \cdot z\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -1.9999999999999999e-275 or 0.0 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z)))

    1. Initial program 88.6%

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

        \[\leadsto \color{blue}{\frac{x + y}{1 - \frac{y}{z}}} \]
      2. mult-flipN/A

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

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

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

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

        \[\leadsto \frac{1}{1 - \color{blue}{\frac{y}{z}}} \cdot \left(x + y\right) \]
      7. sub-to-fractionN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{1 \cdot z - y}{z}}} \cdot \left(x + y\right) \]
      8. div-flip-revN/A

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

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

        \[\leadsto \frac{z}{\color{blue}{z} - y} \cdot \left(x + y\right) \]
      11. lower--.f6489.2%

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

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

        \[\leadsto \frac{z}{z - y} \cdot \color{blue}{\left(y + x\right)} \]
      14. lower-+.f6489.2%

        \[\leadsto \frac{z}{z - y} \cdot \color{blue}{\left(y + x\right)} \]
    3. Applied rewrites89.2%

      \[\leadsto \color{blue}{\frac{z}{z - y} \cdot \left(y + x\right)} \]

    if -1.9999999999999999e-275 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < 0.0

    1. Initial program 88.6%

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

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

        \[\leadsto \frac{\color{blue}{x + y}}{1 - \frac{y}{z}} \]
      3. add-flipN/A

        \[\leadsto \frac{\color{blue}{x - \left(\mathsf{neg}\left(y\right)\right)}}{1 - \frac{y}{z}} \]
      4. div-subN/A

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

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

        \[\leadsto \frac{x}{\color{blue}{1 - \frac{y}{z}}} - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      7. lift-/.f64N/A

        \[\leadsto \frac{x}{1 - \color{blue}{\frac{y}{z}}} - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      8. sub-to-fractionN/A

        \[\leadsto \frac{x}{\color{blue}{\frac{1 \cdot z - y}{z}}} - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      9. associate-/r/N/A

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

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

        \[\leadsto \color{blue}{\frac{x}{1 \cdot z - y}} \cdot z - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      12. *-lft-identityN/A

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

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

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

        \[\leadsto \frac{x}{z - y} \cdot z - \frac{\mathsf{neg}\left(y\right)}{1 - \color{blue}{\frac{y}{z}}} \]
      16. sub-to-fractionN/A

        \[\leadsto \frac{x}{z - y} \cdot z - \frac{\mathsf{neg}\left(y\right)}{\color{blue}{\frac{1 \cdot z - y}{z}}} \]
      17. associate-/r/N/A

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

        \[\leadsto \frac{x}{z - y} \cdot z - \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)}{\mathsf{neg}\left(\left(1 \cdot z - y\right)\right)}} \cdot z \]
      19. remove-double-negN/A

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

        \[\leadsto \frac{x}{z - y} \cdot z - \color{blue}{\frac{y}{\mathsf{neg}\left(\left(1 \cdot z - y\right)\right)} \cdot z} \]
    3. Applied rewrites92.5%

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

Alternative 2: 99.8% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := \frac{x + y}{1 - \frac{y}{z}}\\ t_1 := \frac{z}{z - y} \cdot \left(y + x\right)\\ \mathbf{if}\;t\_0 \leq \frac{-6237000967295999}{311850048364799970571308236412006025948039259443040240859773006630814358104525635278899682108224328295209757319405077381870693435686499009490495593482004909425000886398607136955865268975681716747289586991334988123957939133612635998263883635695006899610487641699336881506618514879741251551232}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 0:\\ \;\;\;\;\frac{y + x}{z - y} \cdot z\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
(FPCore (x y z)
  :precision binary64
  (let* ((t_0 (/ (+ x y) (- 1 (/ y z))))
       (t_1 (* (/ z (- z y)) (+ y x))))
  (if (<=
       t_0
       -6237000967295999/311850048364799970571308236412006025948039259443040240859773006630814358104525635278899682108224328295209757319405077381870693435686499009490495593482004909425000886398607136955865268975681716747289586991334988123957939133612635998263883635695006899610487641699336881506618514879741251551232)
    t_1
    (if (<= t_0 0) (* (/ (+ y x) (- z y)) z) t_1))))
double code(double x, double y, double z) {
	double t_0 = (x + y) / (1.0 - (y / z));
	double t_1 = (z / (z - y)) * (y + x);
	double tmp;
	if (t_0 <= -2e-275) {
		tmp = t_1;
	} else if (t_0 <= 0.0) {
		tmp = ((y + x) / (z - y)) * z;
	} else {
		tmp = t_1;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (x + y) / (1.0d0 - (y / z))
    t_1 = (z / (z - y)) * (y + x)
    if (t_0 <= (-2d-275)) then
        tmp = t_1
    else if (t_0 <= 0.0d0) then
        tmp = ((y + x) / (z - y)) * z
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = (x + y) / (1.0 - (y / z));
	double t_1 = (z / (z - y)) * (y + x);
	double tmp;
	if (t_0 <= -2e-275) {
		tmp = t_1;
	} else if (t_0 <= 0.0) {
		tmp = ((y + x) / (z - y)) * z;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (x + y) / (1.0 - (y / z))
	t_1 = (z / (z - y)) * (y + x)
	tmp = 0
	if t_0 <= -2e-275:
		tmp = t_1
	elif t_0 <= 0.0:
		tmp = ((y + x) / (z - y)) * z
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(x + y) / Float64(1.0 - Float64(y / z)))
	t_1 = Float64(Float64(z / Float64(z - y)) * Float64(y + x))
	tmp = 0.0
	if (t_0 <= -2e-275)
		tmp = t_1;
	elseif (t_0 <= 0.0)
		tmp = Float64(Float64(Float64(y + x) / Float64(z - y)) * z);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (x + y) / (1.0 - (y / z));
	t_1 = (z / (z - y)) * (y + x);
	tmp = 0.0;
	if (t_0 <= -2e-275)
		tmp = t_1;
	elseif (t_0 <= 0.0)
		tmp = ((y + x) / (z - y)) * z;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] / N[(1 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(z / N[(z - y), $MachinePrecision]), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -6237000967295999/311850048364799970571308236412006025948039259443040240859773006630814358104525635278899682108224328295209757319405077381870693435686499009490495593482004909425000886398607136955865268975681716747289586991334988123957939133612635998263883635695006899610487641699336881506618514879741251551232], t$95$1, If[LessEqual[t$95$0, 0], N[(N[(N[(y + x), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
t_1 := \frac{z}{z - y} \cdot \left(y + x\right)\\
\mathbf{if}\;t\_0 \leq \frac{-6237000967295999}{311850048364799970571308236412006025948039259443040240859773006630814358104525635278899682108224328295209757319405077381870693435686499009490495593482004909425000886398607136955865268975681716747289586991334988123957939133612635998263883635695006899610487641699336881506618514879741251551232}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\frac{y + x}{z - y} \cdot z\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -1.9999999999999999e-275 or 0.0 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z)))

    1. Initial program 88.6%

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

        \[\leadsto \color{blue}{\frac{x + y}{1 - \frac{y}{z}}} \]
      2. mult-flipN/A

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

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

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

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

        \[\leadsto \frac{1}{1 - \color{blue}{\frac{y}{z}}} \cdot \left(x + y\right) \]
      7. sub-to-fractionN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{1 \cdot z - y}{z}}} \cdot \left(x + y\right) \]
      8. div-flip-revN/A

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

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

        \[\leadsto \frac{z}{\color{blue}{z} - y} \cdot \left(x + y\right) \]
      11. lower--.f6489.2%

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

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

        \[\leadsto \frac{z}{z - y} \cdot \color{blue}{\left(y + x\right)} \]
      14. lower-+.f6489.2%

        \[\leadsto \frac{z}{z - y} \cdot \color{blue}{\left(y + x\right)} \]
    3. Applied rewrites89.2%

      \[\leadsto \color{blue}{\frac{z}{z - y} \cdot \left(y + x\right)} \]

    if -1.9999999999999999e-275 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < 0.0

    1. Initial program 88.6%

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

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

        \[\leadsto \frac{x + y}{\color{blue}{1 - \frac{y}{z}}} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{x + y}{1 - \color{blue}{\frac{y}{z}}} \]
      4. sub-to-fractionN/A

        \[\leadsto \frac{x + y}{\color{blue}{\frac{1 \cdot z - y}{z}}} \]
      5. associate-/r/N/A

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

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

        \[\leadsto \color{blue}{\frac{x + y}{1 \cdot z - y}} \cdot z \]
      8. lift-+.f64N/A

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

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

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

        \[\leadsto \frac{y + x}{\color{blue}{z} - y} \cdot z \]
      12. lower--.f6492.5%

        \[\leadsto \frac{y + x}{\color{blue}{z - y}} \cdot z \]
    3. Applied rewrites92.5%

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

Alternative 3: 97.8% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := \frac{x + y}{1 - \frac{y}{z}}\\ t_1 := \frac{z}{z - y} \cdot \left(y + x\right)\\ \mathbf{if}\;t\_0 \leq \frac{-3511119404027961}{351111940402796075728379920075981393284761128699669252487168127261196632432619068618571244770327218791250222421623815151677323767215657465806342637967722899175327916845440400930277772658683777577056802640791026892262013051450122815378736544025053197584668966180832613749896964723593195907881555331297312768}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 0:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
(FPCore (x y z)
  :precision binary64
  (let* ((t_0 (/ (+ x y) (- 1 (/ y z))))
       (t_1 (* (/ z (- z y)) (+ y x))))
  (if (<=
       t_0
       -3511119404027961/351111940402796075728379920075981393284761128699669252487168127261196632432619068618571244770327218791250222421623815151677323767215657465806342637967722899175327916845440400930277772658683777577056802640791026892262013051450122815378736544025053197584668966180832613749896964723593195907881555331297312768)
    t_1
    (if (<= t_0 0) (- z) t_1))))
double code(double x, double y, double z) {
	double t_0 = (x + y) / (1.0 - (y / z));
	double t_1 = (z / (z - y)) * (y + x);
	double tmp;
	if (t_0 <= -1e-290) {
		tmp = t_1;
	} else if (t_0 <= 0.0) {
		tmp = -z;
	} else {
		tmp = t_1;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (x + y) / (1.0d0 - (y / z))
    t_1 = (z / (z - y)) * (y + x)
    if (t_0 <= (-1d-290)) then
        tmp = t_1
    else if (t_0 <= 0.0d0) then
        tmp = -z
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = (x + y) / (1.0 - (y / z));
	double t_1 = (z / (z - y)) * (y + x);
	double tmp;
	if (t_0 <= -1e-290) {
		tmp = t_1;
	} else if (t_0 <= 0.0) {
		tmp = -z;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (x + y) / (1.0 - (y / z))
	t_1 = (z / (z - y)) * (y + x)
	tmp = 0
	if t_0 <= -1e-290:
		tmp = t_1
	elif t_0 <= 0.0:
		tmp = -z
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(x + y) / Float64(1.0 - Float64(y / z)))
	t_1 = Float64(Float64(z / Float64(z - y)) * Float64(y + x))
	tmp = 0.0
	if (t_0 <= -1e-290)
		tmp = t_1;
	elseif (t_0 <= 0.0)
		tmp = Float64(-z);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (x + y) / (1.0 - (y / z));
	t_1 = (z / (z - y)) * (y + x);
	tmp = 0.0;
	if (t_0 <= -1e-290)
		tmp = t_1;
	elseif (t_0 <= 0.0)
		tmp = -z;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] / N[(1 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(z / N[(z - y), $MachinePrecision]), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -3511119404027961/351111940402796075728379920075981393284761128699669252487168127261196632432619068618571244770327218791250222421623815151677323767215657465806342637967722899175327916845440400930277772658683777577056802640791026892262013051450122815378736544025053197584668966180832613749896964723593195907881555331297312768], t$95$1, If[LessEqual[t$95$0, 0], (-z), t$95$1]]]]
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
t_1 := \frac{z}{z - y} \cdot \left(y + x\right)\\
\mathbf{if}\;t\_0 \leq \frac{-3511119404027961}{351111940402796075728379920075981393284761128699669252487168127261196632432619068618571244770327218791250222421623815151677323767215657465806342637967722899175327916845440400930277772658683777577056802640791026892262013051450122815378736544025053197584668966180832613749896964723593195907881555331297312768}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;-z\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -1.0000000000000001e-290 or 0.0 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z)))

    1. Initial program 88.6%

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

        \[\leadsto \color{blue}{\frac{x + y}{1 - \frac{y}{z}}} \]
      2. mult-flipN/A

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

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

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

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

        \[\leadsto \frac{1}{1 - \color{blue}{\frac{y}{z}}} \cdot \left(x + y\right) \]
      7. sub-to-fractionN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{1 \cdot z - y}{z}}} \cdot \left(x + y\right) \]
      8. div-flip-revN/A

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

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

        \[\leadsto \frac{z}{\color{blue}{z} - y} \cdot \left(x + y\right) \]
      11. lower--.f6489.2%

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

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

        \[\leadsto \frac{z}{z - y} \cdot \color{blue}{\left(y + x\right)} \]
      14. lower-+.f6489.2%

        \[\leadsto \frac{z}{z - y} \cdot \color{blue}{\left(y + x\right)} \]
    3. Applied rewrites89.2%

      \[\leadsto \color{blue}{\frac{z}{z - y} \cdot \left(y + x\right)} \]

    if -1.0000000000000001e-290 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < 0.0

    1. Initial program 88.6%

      \[\frac{x + y}{1 - \frac{y}{z}} \]
    2. Taylor expanded in y around inf

      \[\leadsto \color{blue}{-1 \cdot z} \]
    3. Step-by-step derivation
      1. lower-*.f6434.7%

        \[\leadsto -1 \cdot \color{blue}{z} \]
    4. Applied rewrites34.7%

      \[\leadsto \color{blue}{-1 \cdot z} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{z} \]
      2. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(z\right) \]
      3. lower-neg.f6434.7%

        \[\leadsto -z \]
    6. Applied rewrites34.7%

      \[\leadsto -z \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 75.1% accurate, 0.8× speedup?

\[\begin{array}{l} t_0 := \frac{y}{z - y} \cdot z\\ \mathbf{if}\;y \leq -194999999999999983724270038920213885242203718025216:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq \frac{-2018324372703715}{2124551971267068394758352826209874509318372470908127692797776552801614239443408970956650009060917142675557317944986004061386317350610828957638079915066349407775325083341572876126912512}:\\ \;\;\;\;\frac{z}{z - y} \cdot x\\ \mathbf{elif}\;y \leq \frac{35681192317649}{2854495385411919762116571938898990272765493248}:\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (x y z)
  :precision binary64
  (let* ((t_0 (* (/ y (- z y)) z)))
  (if (<= y -194999999999999983724270038920213885242203718025216)
    t_0
    (if (<=
         y
         -2018324372703715/2124551971267068394758352826209874509318372470908127692797776552801614239443408970956650009060917142675557317944986004061386317350610828957638079915066349407775325083341572876126912512)
      (* (/ z (- z y)) x)
      (if (<=
           y
           35681192317649/2854495385411919762116571938898990272765493248)
        (+ x y)
        t_0)))))
double code(double x, double y, double z) {
	double t_0 = (y / (z - y)) * z;
	double tmp;
	if (y <= -1.95e+50) {
		tmp = t_0;
	} else if (y <= -9.5e-169) {
		tmp = (z / (z - y)) * x;
	} else if (y <= 1.25e-32) {
		tmp = x + y;
	} else {
		tmp = t_0;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (y / (z - y)) * z
    if (y <= (-1.95d+50)) then
        tmp = t_0
    else if (y <= (-9.5d-169)) then
        tmp = (z / (z - y)) * x
    else if (y <= 1.25d-32) then
        tmp = x + y
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = (y / (z - y)) * z;
	double tmp;
	if (y <= -1.95e+50) {
		tmp = t_0;
	} else if (y <= -9.5e-169) {
		tmp = (z / (z - y)) * x;
	} else if (y <= 1.25e-32) {
		tmp = x + y;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (y / (z - y)) * z
	tmp = 0
	if y <= -1.95e+50:
		tmp = t_0
	elif y <= -9.5e-169:
		tmp = (z / (z - y)) * x
	elif y <= 1.25e-32:
		tmp = x + y
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(y / Float64(z - y)) * z)
	tmp = 0.0
	if (y <= -1.95e+50)
		tmp = t_0;
	elseif (y <= -9.5e-169)
		tmp = Float64(Float64(z / Float64(z - y)) * x);
	elseif (y <= 1.25e-32)
		tmp = Float64(x + y);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (y / (z - y)) * z;
	tmp = 0.0;
	if (y <= -1.95e+50)
		tmp = t_0;
	elseif (y <= -9.5e-169)
		tmp = (z / (z - y)) * x;
	elseif (y <= 1.25e-32)
		tmp = x + y;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y / N[(z - y), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[y, -194999999999999983724270038920213885242203718025216], t$95$0, If[LessEqual[y, -2018324372703715/2124551971267068394758352826209874509318372470908127692797776552801614239443408970956650009060917142675557317944986004061386317350610828957638079915066349407775325083341572876126912512], N[(N[(z / N[(z - y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[y, 35681192317649/2854495385411919762116571938898990272765493248], N[(x + y), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
t_0 := \frac{y}{z - y} \cdot z\\
\mathbf{if}\;y \leq -194999999999999983724270038920213885242203718025216:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq \frac{-2018324372703715}{2124551971267068394758352826209874509318372470908127692797776552801614239443408970956650009060917142675557317944986004061386317350610828957638079915066349407775325083341572876126912512}:\\
\;\;\;\;\frac{z}{z - y} \cdot x\\

\mathbf{elif}\;y \leq \frac{35681192317649}{2854495385411919762116571938898990272765493248}:\\
\;\;\;\;x + y\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.9499999999999998e50 or 1.2500000000000001e-32 < y

    1. Initial program 88.6%

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

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

        \[\leadsto \frac{x + y}{\color{blue}{1 - \frac{y}{z}}} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{x + y}{1 - \color{blue}{\frac{y}{z}}} \]
      4. sub-to-fractionN/A

        \[\leadsto \frac{x + y}{\color{blue}{\frac{1 \cdot z - y}{z}}} \]
      5. associate-/r/N/A

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

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

        \[\leadsto \color{blue}{\frac{x + y}{1 \cdot z - y}} \cdot z \]
      8. lift-+.f64N/A

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

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

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

        \[\leadsto \frac{y + x}{\color{blue}{z} - y} \cdot z \]
      12. lower--.f6492.5%

        \[\leadsto \frac{y + x}{\color{blue}{z - y}} \cdot z \]
    3. Applied rewrites92.5%

      \[\leadsto \color{blue}{\frac{y + x}{z - y} \cdot z} \]
    4. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{y}{z - y}} \cdot z \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{y}{\color{blue}{z - y}} \cdot z \]
      2. lower--.f6449.1%

        \[\leadsto \frac{y}{z - \color{blue}{y}} \cdot z \]
    6. Applied rewrites49.1%

      \[\leadsto \color{blue}{\frac{y}{z - y}} \cdot z \]

    if -1.9499999999999998e50 < y < -9.5000000000000001e-169

    1. Initial program 88.6%

      \[\frac{x + y}{1 - \frac{y}{z}} \]
    2. Taylor expanded in y around inf

      \[\leadsto \color{blue}{-1 \cdot z} \]
    3. Step-by-step derivation
      1. lower-*.f6434.7%

        \[\leadsto -1 \cdot \color{blue}{z} \]
    4. Applied rewrites34.7%

      \[\leadsto \color{blue}{-1 \cdot z} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{z} \]
      2. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(z\right) \]
      3. lower-neg.f6434.7%

        \[\leadsto -z \]
    6. Applied rewrites34.7%

      \[\leadsto -z \]
    7. Taylor expanded in x around inf

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

        \[\leadsto \frac{x}{\color{blue}{1 - \frac{y}{z}}} \]
      2. lower--.f64N/A

        \[\leadsto \frac{x}{1 - \color{blue}{\frac{y}{z}}} \]
      3. lower-/.f6449.5%

        \[\leadsto \frac{x}{1 - \frac{y}{\color{blue}{z}}} \]
    9. Applied rewrites49.5%

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

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

        \[\leadsto \frac{x}{1 - \color{blue}{\frac{y}{z}}} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{x}{1 - \frac{y}{\color{blue}{z}}} \]
      4. sub-to-fractionN/A

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

        \[\leadsto \frac{x}{\frac{z - y}{z}} \]
      6. associate-/r/N/A

        \[\leadsto \frac{x}{z - y} \cdot \color{blue}{z} \]
      7. associate-*l/N/A

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

        \[\leadsto x \cdot \color{blue}{\frac{z}{z - y}} \]
      9. *-commutativeN/A

        \[\leadsto \frac{z}{z - y} \cdot \color{blue}{x} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{z}{z - y} \cdot \color{blue}{x} \]
      11. lower-/.f64N/A

        \[\leadsto \frac{z}{z - y} \cdot x \]
      12. lift--.f6449.6%

        \[\leadsto \frac{z}{z - y} \cdot x \]
    11. Applied rewrites49.6%

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

    if -9.5000000000000001e-169 < y < 1.2500000000000001e-32

    1. Initial program 88.6%

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

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

        \[\leadsto \frac{\color{blue}{x + y}}{1 - \frac{y}{z}} \]
      3. add-flipN/A

        \[\leadsto \frac{\color{blue}{x - \left(\mathsf{neg}\left(y\right)\right)}}{1 - \frac{y}{z}} \]
      4. div-subN/A

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

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

        \[\leadsto \frac{x}{\color{blue}{1 - \frac{y}{z}}} - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      7. lift-/.f64N/A

        \[\leadsto \frac{x}{1 - \color{blue}{\frac{y}{z}}} - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      8. sub-to-fractionN/A

        \[\leadsto \frac{x}{\color{blue}{\frac{1 \cdot z - y}{z}}} - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      9. associate-/r/N/A

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

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

        \[\leadsto \color{blue}{\frac{x}{1 \cdot z - y}} \cdot z - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      12. *-lft-identityN/A

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

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

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

        \[\leadsto \frac{x}{z - y} \cdot z - \frac{\mathsf{neg}\left(y\right)}{1 - \color{blue}{\frac{y}{z}}} \]
      16. sub-to-fractionN/A

        \[\leadsto \frac{x}{z - y} \cdot z - \frac{\mathsf{neg}\left(y\right)}{\color{blue}{\frac{1 \cdot z - y}{z}}} \]
      17. associate-/r/N/A

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

        \[\leadsto \frac{x}{z - y} \cdot z - \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)}{\mathsf{neg}\left(\left(1 \cdot z - y\right)\right)}} \cdot z \]
      19. remove-double-negN/A

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

        \[\leadsto \frac{x}{z - y} \cdot z - \color{blue}{\frac{y}{\mathsf{neg}\left(\left(1 \cdot z - y\right)\right)} \cdot z} \]
    3. Applied rewrites92.5%

      \[\leadsto \color{blue}{\frac{x}{z - y} \cdot z - \frac{y}{y - z} \cdot z} \]
    4. Taylor expanded in z around inf

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

        \[\leadsto x - \color{blue}{-1 \cdot y} \]
      2. lower-*.f6451.9%

        \[\leadsto x - -1 \cdot \color{blue}{y} \]
    6. Applied rewrites51.9%

      \[\leadsto \color{blue}{x - -1 \cdot y} \]
    7. Step-by-step derivation
      1. distribute-rgt-out--51.9%

        \[\leadsto \color{blue}{x} - -1 \cdot y \]
      2. sub-flip51.9%

        \[\leadsto x - -1 \cdot y \]
      3. +-commutative51.9%

        \[\leadsto x - -1 \cdot y \]
      4. distribute-neg-frac251.9%

        \[\leadsto x - -1 \cdot y \]
      5. sub-negate-rev51.9%

        \[\leadsto x - -1 \cdot y \]
      6. lift--.f64N/A

        \[\leadsto x - -1 \cdot y \]
      7. lift--.f64N/A

        \[\leadsto x - -1 \cdot y \]
      8. div-addN/A

        \[\leadsto x - -1 \cdot y \]
      9. lift-+.f64N/A

        \[\leadsto x - -1 \cdot y \]
      10. associate-/l*N/A

        \[\leadsto \color{blue}{x} - -1 \cdot y \]
      11. associate-*l/N/A

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

        \[\leadsto x - -1 \cdot y \]
      13. lift-+.f6451.9%

        \[\leadsto x - -1 \cdot y \]
      14. lift--.f64N/A

        \[\leadsto x - \color{blue}{-1 \cdot y} \]
      15. lift-*.f64N/A

        \[\leadsto x - -1 \cdot \color{blue}{y} \]
      16. mul-1-negN/A

        \[\leadsto x - \left(\mathsf{neg}\left(y\right)\right) \]
      17. add-flipN/A

        \[\leadsto x + \color{blue}{y} \]
      18. lower-+.f6451.9%

        \[\leadsto x + \color{blue}{y} \]
    8. Applied rewrites51.9%

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

Alternative 5: 69.8% accurate, 0.7× speedup?

\[\begin{array}{l} \mathbf{if}\;y \leq -194999999999999983724270038920213885242203718025216:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq \frac{-2018324372703715}{2124551971267068394758352826209874509318372470908127692797776552801614239443408970956650009060917142675557317944986004061386317350610828957638079915066349407775325083341572876126912512}:\\ \;\;\;\;\frac{z}{z - y} \cdot x\\ \mathbf{elif}\;y \leq \frac{319703483166135}{11417981541647679048466287755595961091061972992}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;y \leq 550000000000000034620484012274092293161598264847377161196670750875660543518704867470375044471607874880979271586561345253287966082623990237146785940556165572473160640990296858979914666830930817442259472152448714805578030907392:\\ \;\;\;\;\frac{y \cdot z}{z - y}\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]
(FPCore (x y z)
  :precision binary64
  (if (<= y -194999999999999983724270038920213885242203718025216)
  (- z)
  (if (<=
       y
       -2018324372703715/2124551971267068394758352826209874509318372470908127692797776552801614239443408970956650009060917142675557317944986004061386317350610828957638079915066349407775325083341572876126912512)
    (* (/ z (- z y)) x)
    (if (<=
         y
         319703483166135/11417981541647679048466287755595961091061972992)
      (+ x y)
      (if (<=
           y
           550000000000000034620484012274092293161598264847377161196670750875660543518704867470375044471607874880979271586561345253287966082623990237146785940556165572473160640990296858979914666830930817442259472152448714805578030907392)
        (/ (* y z) (- z y))
        (- z))))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.95e+50) {
		tmp = -z;
	} else if (y <= -9.5e-169) {
		tmp = (z / (z - y)) * x;
	} else if (y <= 2.8e-32) {
		tmp = x + y;
	} else if (y <= 5.5e+224) {
		tmp = (y * z) / (z - y);
	} else {
		tmp = -z;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-1.95d+50)) then
        tmp = -z
    else if (y <= (-9.5d-169)) then
        tmp = (z / (z - y)) * x
    else if (y <= 2.8d-32) then
        tmp = x + y
    else if (y <= 5.5d+224) then
        tmp = (y * z) / (z - y)
    else
        tmp = -z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.95e+50) {
		tmp = -z;
	} else if (y <= -9.5e-169) {
		tmp = (z / (z - y)) * x;
	} else if (y <= 2.8e-32) {
		tmp = x + y;
	} else if (y <= 5.5e+224) {
		tmp = (y * z) / (z - y);
	} else {
		tmp = -z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -1.95e+50:
		tmp = -z
	elif y <= -9.5e-169:
		tmp = (z / (z - y)) * x
	elif y <= 2.8e-32:
		tmp = x + y
	elif y <= 5.5e+224:
		tmp = (y * z) / (z - y)
	else:
		tmp = -z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -1.95e+50)
		tmp = Float64(-z);
	elseif (y <= -9.5e-169)
		tmp = Float64(Float64(z / Float64(z - y)) * x);
	elseif (y <= 2.8e-32)
		tmp = Float64(x + y);
	elseif (y <= 5.5e+224)
		tmp = Float64(Float64(y * z) / Float64(z - y));
	else
		tmp = Float64(-z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -1.95e+50)
		tmp = -z;
	elseif (y <= -9.5e-169)
		tmp = (z / (z - y)) * x;
	elseif (y <= 2.8e-32)
		tmp = x + y;
	elseif (y <= 5.5e+224)
		tmp = (y * z) / (z - y);
	else
		tmp = -z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -194999999999999983724270038920213885242203718025216], (-z), If[LessEqual[y, -2018324372703715/2124551971267068394758352826209874509318372470908127692797776552801614239443408970956650009060917142675557317944986004061386317350610828957638079915066349407775325083341572876126912512], N[(N[(z / N[(z - y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[y, 319703483166135/11417981541647679048466287755595961091061972992], N[(x + y), $MachinePrecision], If[LessEqual[y, 550000000000000034620484012274092293161598264847377161196670750875660543518704867470375044471607874880979271586561345253287966082623990237146785940556165572473160640990296858979914666830930817442259472152448714805578030907392], N[(N[(y * z), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision], (-z)]]]]
\begin{array}{l}
\mathbf{if}\;y \leq -194999999999999983724270038920213885242203718025216:\\
\;\;\;\;-z\\

\mathbf{elif}\;y \leq \frac{-2018324372703715}{2124551971267068394758352826209874509318372470908127692797776552801614239443408970956650009060917142675557317944986004061386317350610828957638079915066349407775325083341572876126912512}:\\
\;\;\;\;\frac{z}{z - y} \cdot x\\

\mathbf{elif}\;y \leq \frac{319703483166135}{11417981541647679048466287755595961091061972992}:\\
\;\;\;\;x + y\\

\mathbf{elif}\;y \leq 550000000000000034620484012274092293161598264847377161196670750875660543518704867470375044471607874880979271586561345253287966082623990237146785940556165572473160640990296858979914666830930817442259472152448714805578030907392:\\
\;\;\;\;\frac{y \cdot z}{z - y}\\

\mathbf{else}:\\
\;\;\;\;-z\\


\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -1.9499999999999998e50 or 5.5000000000000003e224 < y

    1. Initial program 88.6%

      \[\frac{x + y}{1 - \frac{y}{z}} \]
    2. Taylor expanded in y around inf

      \[\leadsto \color{blue}{-1 \cdot z} \]
    3. Step-by-step derivation
      1. lower-*.f6434.7%

        \[\leadsto -1 \cdot \color{blue}{z} \]
    4. Applied rewrites34.7%

      \[\leadsto \color{blue}{-1 \cdot z} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{z} \]
      2. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(z\right) \]
      3. lower-neg.f6434.7%

        \[\leadsto -z \]
    6. Applied rewrites34.7%

      \[\leadsto -z \]

    if -1.9499999999999998e50 < y < -9.5000000000000001e-169

    1. Initial program 88.6%

      \[\frac{x + y}{1 - \frac{y}{z}} \]
    2. Taylor expanded in y around inf

      \[\leadsto \color{blue}{-1 \cdot z} \]
    3. Step-by-step derivation
      1. lower-*.f6434.7%

        \[\leadsto -1 \cdot \color{blue}{z} \]
    4. Applied rewrites34.7%

      \[\leadsto \color{blue}{-1 \cdot z} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{z} \]
      2. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(z\right) \]
      3. lower-neg.f6434.7%

        \[\leadsto -z \]
    6. Applied rewrites34.7%

      \[\leadsto -z \]
    7. Taylor expanded in x around inf

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

        \[\leadsto \frac{x}{\color{blue}{1 - \frac{y}{z}}} \]
      2. lower--.f64N/A

        \[\leadsto \frac{x}{1 - \color{blue}{\frac{y}{z}}} \]
      3. lower-/.f6449.5%

        \[\leadsto \frac{x}{1 - \frac{y}{\color{blue}{z}}} \]
    9. Applied rewrites49.5%

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

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

        \[\leadsto \frac{x}{1 - \color{blue}{\frac{y}{z}}} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{x}{1 - \frac{y}{\color{blue}{z}}} \]
      4. sub-to-fractionN/A

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

        \[\leadsto \frac{x}{\frac{z - y}{z}} \]
      6. associate-/r/N/A

        \[\leadsto \frac{x}{z - y} \cdot \color{blue}{z} \]
      7. associate-*l/N/A

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

        \[\leadsto x \cdot \color{blue}{\frac{z}{z - y}} \]
      9. *-commutativeN/A

        \[\leadsto \frac{z}{z - y} \cdot \color{blue}{x} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{z}{z - y} \cdot \color{blue}{x} \]
      11. lower-/.f64N/A

        \[\leadsto \frac{z}{z - y} \cdot x \]
      12. lift--.f6449.6%

        \[\leadsto \frac{z}{z - y} \cdot x \]
    11. Applied rewrites49.6%

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

    if -9.5000000000000001e-169 < y < 2.7999999999999999e-32

    1. Initial program 88.6%

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

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

        \[\leadsto \frac{\color{blue}{x + y}}{1 - \frac{y}{z}} \]
      3. add-flipN/A

        \[\leadsto \frac{\color{blue}{x - \left(\mathsf{neg}\left(y\right)\right)}}{1 - \frac{y}{z}} \]
      4. div-subN/A

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

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

        \[\leadsto \frac{x}{\color{blue}{1 - \frac{y}{z}}} - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      7. lift-/.f64N/A

        \[\leadsto \frac{x}{1 - \color{blue}{\frac{y}{z}}} - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      8. sub-to-fractionN/A

        \[\leadsto \frac{x}{\color{blue}{\frac{1 \cdot z - y}{z}}} - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      9. associate-/r/N/A

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

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

        \[\leadsto \color{blue}{\frac{x}{1 \cdot z - y}} \cdot z - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      12. *-lft-identityN/A

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

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

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

        \[\leadsto \frac{x}{z - y} \cdot z - \frac{\mathsf{neg}\left(y\right)}{1 - \color{blue}{\frac{y}{z}}} \]
      16. sub-to-fractionN/A

        \[\leadsto \frac{x}{z - y} \cdot z - \frac{\mathsf{neg}\left(y\right)}{\color{blue}{\frac{1 \cdot z - y}{z}}} \]
      17. associate-/r/N/A

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

        \[\leadsto \frac{x}{z - y} \cdot z - \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)}{\mathsf{neg}\left(\left(1 \cdot z - y\right)\right)}} \cdot z \]
      19. remove-double-negN/A

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

        \[\leadsto \frac{x}{z - y} \cdot z - \color{blue}{\frac{y}{\mathsf{neg}\left(\left(1 \cdot z - y\right)\right)} \cdot z} \]
    3. Applied rewrites92.5%

      \[\leadsto \color{blue}{\frac{x}{z - y} \cdot z - \frac{y}{y - z} \cdot z} \]
    4. Taylor expanded in z around inf

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

        \[\leadsto x - \color{blue}{-1 \cdot y} \]
      2. lower-*.f6451.9%

        \[\leadsto x - -1 \cdot \color{blue}{y} \]
    6. Applied rewrites51.9%

      \[\leadsto \color{blue}{x - -1 \cdot y} \]
    7. Step-by-step derivation
      1. distribute-rgt-out--51.9%

        \[\leadsto \color{blue}{x} - -1 \cdot y \]
      2. sub-flip51.9%

        \[\leadsto x - -1 \cdot y \]
      3. +-commutative51.9%

        \[\leadsto x - -1 \cdot y \]
      4. distribute-neg-frac251.9%

        \[\leadsto x - -1 \cdot y \]
      5. sub-negate-rev51.9%

        \[\leadsto x - -1 \cdot y \]
      6. lift--.f64N/A

        \[\leadsto x - -1 \cdot y \]
      7. lift--.f64N/A

        \[\leadsto x - -1 \cdot y \]
      8. div-addN/A

        \[\leadsto x - -1 \cdot y \]
      9. lift-+.f64N/A

        \[\leadsto x - -1 \cdot y \]
      10. associate-/l*N/A

        \[\leadsto \color{blue}{x} - -1 \cdot y \]
      11. associate-*l/N/A

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

        \[\leadsto x - -1 \cdot y \]
      13. lift-+.f6451.9%

        \[\leadsto x - -1 \cdot y \]
      14. lift--.f64N/A

        \[\leadsto x - \color{blue}{-1 \cdot y} \]
      15. lift-*.f64N/A

        \[\leadsto x - -1 \cdot \color{blue}{y} \]
      16. mul-1-negN/A

        \[\leadsto x - \left(\mathsf{neg}\left(y\right)\right) \]
      17. add-flipN/A

        \[\leadsto x + \color{blue}{y} \]
      18. lower-+.f6451.9%

        \[\leadsto x + \color{blue}{y} \]
    8. Applied rewrites51.9%

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

    if 2.7999999999999999e-32 < y < 5.5000000000000003e224

    1. Initial program 88.6%

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

        \[\leadsto \color{blue}{\frac{x + y}{1 - \frac{y}{z}}} \]
      2. mult-flipN/A

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

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

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

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

        \[\leadsto \frac{1}{1 - \color{blue}{\frac{y}{z}}} \cdot \left(x + y\right) \]
      7. sub-to-fractionN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{1 \cdot z - y}{z}}} \cdot \left(x + y\right) \]
      8. div-flip-revN/A

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

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

        \[\leadsto \frac{z}{\color{blue}{z} - y} \cdot \left(x + y\right) \]
      11. lower--.f6489.2%

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

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

        \[\leadsto \frac{z}{z - y} \cdot \color{blue}{\left(y + x\right)} \]
      14. lower-+.f6489.2%

        \[\leadsto \frac{z}{z - y} \cdot \color{blue}{\left(y + x\right)} \]
    3. Applied rewrites89.2%

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

      \[\leadsto \color{blue}{\frac{y \cdot z}{z - y}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

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

        \[\leadsto \frac{y \cdot z}{\color{blue}{z} - y} \]
      3. lower--.f6439.4%

        \[\leadsto \frac{y \cdot z}{z - \color{blue}{y}} \]
    6. Applied rewrites39.4%

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

Alternative 6: 69.2% accurate, 0.8× speedup?

\[\begin{array}{l} \mathbf{if}\;y \leq -8199999999999999888373114960669082384948087332005840710986759143424:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq \frac{319703483166135}{11417981541647679048466287755595961091061972992}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;y \leq 550000000000000034620484012274092293161598264847377161196670750875660543518704867470375044471607874880979271586561345253287966082623990237146785940556165572473160640990296858979914666830930817442259472152448714805578030907392:\\ \;\;\;\;\frac{y \cdot z}{z - y}\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]
(FPCore (x y z)
  :precision binary64
  (if (<=
     y
     -8199999999999999888373114960669082384948087332005840710986759143424)
  (- z)
  (if (<=
       y
       319703483166135/11417981541647679048466287755595961091061972992)
    (+ x y)
    (if (<=
         y
         550000000000000034620484012274092293161598264847377161196670750875660543518704867470375044471607874880979271586561345253287966082623990237146785940556165572473160640990296858979914666830930817442259472152448714805578030907392)
      (/ (* y z) (- z y))
      (- z)))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -8.2e+66) {
		tmp = -z;
	} else if (y <= 2.8e-32) {
		tmp = x + y;
	} else if (y <= 5.5e+224) {
		tmp = (y * z) / (z - y);
	} else {
		tmp = -z;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-8.2d+66)) then
        tmp = -z
    else if (y <= 2.8d-32) then
        tmp = x + y
    else if (y <= 5.5d+224) then
        tmp = (y * z) / (z - y)
    else
        tmp = -z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -8.2e+66) {
		tmp = -z;
	} else if (y <= 2.8e-32) {
		tmp = x + y;
	} else if (y <= 5.5e+224) {
		tmp = (y * z) / (z - y);
	} else {
		tmp = -z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -8.2e+66:
		tmp = -z
	elif y <= 2.8e-32:
		tmp = x + y
	elif y <= 5.5e+224:
		tmp = (y * z) / (z - y)
	else:
		tmp = -z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -8.2e+66)
		tmp = Float64(-z);
	elseif (y <= 2.8e-32)
		tmp = Float64(x + y);
	elseif (y <= 5.5e+224)
		tmp = Float64(Float64(y * z) / Float64(z - y));
	else
		tmp = Float64(-z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -8.2e+66)
		tmp = -z;
	elseif (y <= 2.8e-32)
		tmp = x + y;
	elseif (y <= 5.5e+224)
		tmp = (y * z) / (z - y);
	else
		tmp = -z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -8199999999999999888373114960669082384948087332005840710986759143424], (-z), If[LessEqual[y, 319703483166135/11417981541647679048466287755595961091061972992], N[(x + y), $MachinePrecision], If[LessEqual[y, 550000000000000034620484012274092293161598264847377161196670750875660543518704867470375044471607874880979271586561345253287966082623990237146785940556165572473160640990296858979914666830930817442259472152448714805578030907392], N[(N[(y * z), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision], (-z)]]]
\begin{array}{l}
\mathbf{if}\;y \leq -8199999999999999888373114960669082384948087332005840710986759143424:\\
\;\;\;\;-z\\

\mathbf{elif}\;y \leq \frac{319703483166135}{11417981541647679048466287755595961091061972992}:\\
\;\;\;\;x + y\\

\mathbf{elif}\;y \leq 550000000000000034620484012274092293161598264847377161196670750875660543518704867470375044471607874880979271586561345253287966082623990237146785940556165572473160640990296858979914666830930817442259472152448714805578030907392:\\
\;\;\;\;\frac{y \cdot z}{z - y}\\

\mathbf{else}:\\
\;\;\;\;-z\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -8.1999999999999999e66 or 5.5000000000000003e224 < y

    1. Initial program 88.6%

      \[\frac{x + y}{1 - \frac{y}{z}} \]
    2. Taylor expanded in y around inf

      \[\leadsto \color{blue}{-1 \cdot z} \]
    3. Step-by-step derivation
      1. lower-*.f6434.7%

        \[\leadsto -1 \cdot \color{blue}{z} \]
    4. Applied rewrites34.7%

      \[\leadsto \color{blue}{-1 \cdot z} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{z} \]
      2. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(z\right) \]
      3. lower-neg.f6434.7%

        \[\leadsto -z \]
    6. Applied rewrites34.7%

      \[\leadsto -z \]

    if -8.1999999999999999e66 < y < 2.7999999999999999e-32

    1. Initial program 88.6%

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

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

        \[\leadsto \frac{\color{blue}{x + y}}{1 - \frac{y}{z}} \]
      3. add-flipN/A

        \[\leadsto \frac{\color{blue}{x - \left(\mathsf{neg}\left(y\right)\right)}}{1 - \frac{y}{z}} \]
      4. div-subN/A

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

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

        \[\leadsto \frac{x}{\color{blue}{1 - \frac{y}{z}}} - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      7. lift-/.f64N/A

        \[\leadsto \frac{x}{1 - \color{blue}{\frac{y}{z}}} - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      8. sub-to-fractionN/A

        \[\leadsto \frac{x}{\color{blue}{\frac{1 \cdot z - y}{z}}} - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      9. associate-/r/N/A

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

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

        \[\leadsto \color{blue}{\frac{x}{1 \cdot z - y}} \cdot z - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      12. *-lft-identityN/A

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

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

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

        \[\leadsto \frac{x}{z - y} \cdot z - \frac{\mathsf{neg}\left(y\right)}{1 - \color{blue}{\frac{y}{z}}} \]
      16. sub-to-fractionN/A

        \[\leadsto \frac{x}{z - y} \cdot z - \frac{\mathsf{neg}\left(y\right)}{\color{blue}{\frac{1 \cdot z - y}{z}}} \]
      17. associate-/r/N/A

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

        \[\leadsto \frac{x}{z - y} \cdot z - \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)}{\mathsf{neg}\left(\left(1 \cdot z - y\right)\right)}} \cdot z \]
      19. remove-double-negN/A

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

        \[\leadsto \frac{x}{z - y} \cdot z - \color{blue}{\frac{y}{\mathsf{neg}\left(\left(1 \cdot z - y\right)\right)} \cdot z} \]
    3. Applied rewrites92.5%

      \[\leadsto \color{blue}{\frac{x}{z - y} \cdot z - \frac{y}{y - z} \cdot z} \]
    4. Taylor expanded in z around inf

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

        \[\leadsto x - \color{blue}{-1 \cdot y} \]
      2. lower-*.f6451.9%

        \[\leadsto x - -1 \cdot \color{blue}{y} \]
    6. Applied rewrites51.9%

      \[\leadsto \color{blue}{x - -1 \cdot y} \]
    7. Step-by-step derivation
      1. distribute-rgt-out--51.9%

        \[\leadsto \color{blue}{x} - -1 \cdot y \]
      2. sub-flip51.9%

        \[\leadsto x - -1 \cdot y \]
      3. +-commutative51.9%

        \[\leadsto x - -1 \cdot y \]
      4. distribute-neg-frac251.9%

        \[\leadsto x - -1 \cdot y \]
      5. sub-negate-rev51.9%

        \[\leadsto x - -1 \cdot y \]
      6. lift--.f64N/A

        \[\leadsto x - -1 \cdot y \]
      7. lift--.f64N/A

        \[\leadsto x - -1 \cdot y \]
      8. div-addN/A

        \[\leadsto x - -1 \cdot y \]
      9. lift-+.f64N/A

        \[\leadsto x - -1 \cdot y \]
      10. associate-/l*N/A

        \[\leadsto \color{blue}{x} - -1 \cdot y \]
      11. associate-*l/N/A

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

        \[\leadsto x - -1 \cdot y \]
      13. lift-+.f6451.9%

        \[\leadsto x - -1 \cdot y \]
      14. lift--.f64N/A

        \[\leadsto x - \color{blue}{-1 \cdot y} \]
      15. lift-*.f64N/A

        \[\leadsto x - -1 \cdot \color{blue}{y} \]
      16. mul-1-negN/A

        \[\leadsto x - \left(\mathsf{neg}\left(y\right)\right) \]
      17. add-flipN/A

        \[\leadsto x + \color{blue}{y} \]
      18. lower-+.f6451.9%

        \[\leadsto x + \color{blue}{y} \]
    8. Applied rewrites51.9%

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

    if 2.7999999999999999e-32 < y < 5.5000000000000003e224

    1. Initial program 88.6%

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

        \[\leadsto \color{blue}{\frac{x + y}{1 - \frac{y}{z}}} \]
      2. mult-flipN/A

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

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

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

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

        \[\leadsto \frac{1}{1 - \color{blue}{\frac{y}{z}}} \cdot \left(x + y\right) \]
      7. sub-to-fractionN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{1 \cdot z - y}{z}}} \cdot \left(x + y\right) \]
      8. div-flip-revN/A

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

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

        \[\leadsto \frac{z}{\color{blue}{z} - y} \cdot \left(x + y\right) \]
      11. lower--.f6489.2%

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

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

        \[\leadsto \frac{z}{z - y} \cdot \color{blue}{\left(y + x\right)} \]
      14. lower-+.f6489.2%

        \[\leadsto \frac{z}{z - y} \cdot \color{blue}{\left(y + x\right)} \]
    3. Applied rewrites89.2%

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

      \[\leadsto \color{blue}{\frac{y \cdot z}{z - y}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

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

        \[\leadsto \frac{y \cdot z}{\color{blue}{z} - y} \]
      3. lower--.f6439.4%

        \[\leadsto \frac{y \cdot z}{z - \color{blue}{y}} \]
    6. Applied rewrites39.4%

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

Alternative 7: 69.0% accurate, 1.8× speedup?

\[\begin{array}{l} \mathbf{if}\;y \leq -8199999999999999888373114960669082384948087332005840710986759143424:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq 72000000000000000693102649494470656:\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]
(FPCore (x y z)
  :precision binary64
  (if (<=
     y
     -8199999999999999888373114960669082384948087332005840710986759143424)
  (- z)
  (if (<= y 72000000000000000693102649494470656) (+ x y) (- z))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -8.2e+66) {
		tmp = -z;
	} else if (y <= 7.2e+34) {
		tmp = x + y;
	} else {
		tmp = -z;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-8.2d+66)) then
        tmp = -z
    else if (y <= 7.2d+34) then
        tmp = x + y
    else
        tmp = -z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -8.2e+66) {
		tmp = -z;
	} else if (y <= 7.2e+34) {
		tmp = x + y;
	} else {
		tmp = -z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -8.2e+66:
		tmp = -z
	elif y <= 7.2e+34:
		tmp = x + y
	else:
		tmp = -z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -8.2e+66)
		tmp = Float64(-z);
	elseif (y <= 7.2e+34)
		tmp = Float64(x + y);
	else
		tmp = Float64(-z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -8.2e+66)
		tmp = -z;
	elseif (y <= 7.2e+34)
		tmp = x + y;
	else
		tmp = -z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -8199999999999999888373114960669082384948087332005840710986759143424], (-z), If[LessEqual[y, 72000000000000000693102649494470656], N[(x + y), $MachinePrecision], (-z)]]
\begin{array}{l}
\mathbf{if}\;y \leq -8199999999999999888373114960669082384948087332005840710986759143424:\\
\;\;\;\;-z\\

\mathbf{elif}\;y \leq 72000000000000000693102649494470656:\\
\;\;\;\;x + y\\

\mathbf{else}:\\
\;\;\;\;-z\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -8.1999999999999999e66 or 7.2000000000000001e34 < y

    1. Initial program 88.6%

      \[\frac{x + y}{1 - \frac{y}{z}} \]
    2. Taylor expanded in y around inf

      \[\leadsto \color{blue}{-1 \cdot z} \]
    3. Step-by-step derivation
      1. lower-*.f6434.7%

        \[\leadsto -1 \cdot \color{blue}{z} \]
    4. Applied rewrites34.7%

      \[\leadsto \color{blue}{-1 \cdot z} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto -1 \cdot \color{blue}{z} \]
      2. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(z\right) \]
      3. lower-neg.f6434.7%

        \[\leadsto -z \]
    6. Applied rewrites34.7%

      \[\leadsto -z \]

    if -8.1999999999999999e66 < y < 7.2000000000000001e34

    1. Initial program 88.6%

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

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

        \[\leadsto \frac{\color{blue}{x + y}}{1 - \frac{y}{z}} \]
      3. add-flipN/A

        \[\leadsto \frac{\color{blue}{x - \left(\mathsf{neg}\left(y\right)\right)}}{1 - \frac{y}{z}} \]
      4. div-subN/A

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

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

        \[\leadsto \frac{x}{\color{blue}{1 - \frac{y}{z}}} - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      7. lift-/.f64N/A

        \[\leadsto \frac{x}{1 - \color{blue}{\frac{y}{z}}} - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      8. sub-to-fractionN/A

        \[\leadsto \frac{x}{\color{blue}{\frac{1 \cdot z - y}{z}}} - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      9. associate-/r/N/A

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

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

        \[\leadsto \color{blue}{\frac{x}{1 \cdot z - y}} \cdot z - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      12. *-lft-identityN/A

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

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

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

        \[\leadsto \frac{x}{z - y} \cdot z - \frac{\mathsf{neg}\left(y\right)}{1 - \color{blue}{\frac{y}{z}}} \]
      16. sub-to-fractionN/A

        \[\leadsto \frac{x}{z - y} \cdot z - \frac{\mathsf{neg}\left(y\right)}{\color{blue}{\frac{1 \cdot z - y}{z}}} \]
      17. associate-/r/N/A

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

        \[\leadsto \frac{x}{z - y} \cdot z - \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)}{\mathsf{neg}\left(\left(1 \cdot z - y\right)\right)}} \cdot z \]
      19. remove-double-negN/A

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

        \[\leadsto \frac{x}{z - y} \cdot z - \color{blue}{\frac{y}{\mathsf{neg}\left(\left(1 \cdot z - y\right)\right)} \cdot z} \]
    3. Applied rewrites92.5%

      \[\leadsto \color{blue}{\frac{x}{z - y} \cdot z - \frac{y}{y - z} \cdot z} \]
    4. Taylor expanded in z around inf

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

        \[\leadsto x - \color{blue}{-1 \cdot y} \]
      2. lower-*.f6451.9%

        \[\leadsto x - -1 \cdot \color{blue}{y} \]
    6. Applied rewrites51.9%

      \[\leadsto \color{blue}{x - -1 \cdot y} \]
    7. Step-by-step derivation
      1. distribute-rgt-out--51.9%

        \[\leadsto \color{blue}{x} - -1 \cdot y \]
      2. sub-flip51.9%

        \[\leadsto x - -1 \cdot y \]
      3. +-commutative51.9%

        \[\leadsto x - -1 \cdot y \]
      4. distribute-neg-frac251.9%

        \[\leadsto x - -1 \cdot y \]
      5. sub-negate-rev51.9%

        \[\leadsto x - -1 \cdot y \]
      6. lift--.f64N/A

        \[\leadsto x - -1 \cdot y \]
      7. lift--.f64N/A

        \[\leadsto x - -1 \cdot y \]
      8. div-addN/A

        \[\leadsto x - -1 \cdot y \]
      9. lift-+.f64N/A

        \[\leadsto x - -1 \cdot y \]
      10. associate-/l*N/A

        \[\leadsto \color{blue}{x} - -1 \cdot y \]
      11. associate-*l/N/A

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

        \[\leadsto x - -1 \cdot y \]
      13. lift-+.f6451.9%

        \[\leadsto x - -1 \cdot y \]
      14. lift--.f64N/A

        \[\leadsto x - \color{blue}{-1 \cdot y} \]
      15. lift-*.f64N/A

        \[\leadsto x - -1 \cdot \color{blue}{y} \]
      16. mul-1-negN/A

        \[\leadsto x - \left(\mathsf{neg}\left(y\right)\right) \]
      17. add-flipN/A

        \[\leadsto x + \color{blue}{y} \]
      18. lower-+.f6451.9%

        \[\leadsto x + \color{blue}{y} \]
    8. Applied rewrites51.9%

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

Alternative 8: 40.8% accurate, 1.9× speedup?

\[\begin{array}{l} \mathbf{if}\;z \leq -179999999999999991809867743164304086087427869300453890886284773824455759423616381689070858720502746283775855272893250654006708753453914860067394837843033146261504:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq 1050000000000000039771512955146801415361985593779020615116046538467559188987904:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
(FPCore (x y z)
  :precision binary64
  (if (<=
     z
     -179999999999999991809867743164304086087427869300453890886284773824455759423616381689070858720502746283775855272893250654006708753453914860067394837843033146261504)
  y
  (if (<=
       z
       1050000000000000039771512955146801415361985593779020615116046538467559188987904)
    (- z)
    y)))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -1.8e+161) {
		tmp = y;
	} else if (z <= 1.05e+78) {
		tmp = -z;
	} else {
		tmp = y;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= (-1.8d+161)) then
        tmp = y
    else if (z <= 1.05d+78) then
        tmp = -z
    else
        tmp = y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -1.8e+161) {
		tmp = y;
	} else if (z <= 1.05e+78) {
		tmp = -z;
	} else {
		tmp = y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -1.8e+161:
		tmp = y
	elif z <= 1.05e+78:
		tmp = -z
	else:
		tmp = y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -1.8e+161)
		tmp = y;
	elseif (z <= 1.05e+78)
		tmp = Float64(-z);
	else
		tmp = y;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -1.8e+161)
		tmp = y;
	elseif (z <= 1.05e+78)
		tmp = -z;
	else
		tmp = y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -179999999999999991809867743164304086087427869300453890886284773824455759423616381689070858720502746283775855272893250654006708753453914860067394837843033146261504], y, If[LessEqual[z, 1050000000000000039771512955146801415361985593779020615116046538467559188987904], (-z), y]]
\begin{array}{l}
\mathbf{if}\;z \leq -179999999999999991809867743164304086087427869300453890886284773824455759423616381689070858720502746283775855272893250654006708753453914860067394837843033146261504:\\
\;\;\;\;y\\

\mathbf{elif}\;z \leq 1050000000000000039771512955146801415361985593779020615116046538467559188987904:\\
\;\;\;\;-z\\

\mathbf{else}:\\
\;\;\;\;y\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.7999999999999999e161 or 1.05e78 < z

    1. Initial program 88.6%

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

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

        \[\leadsto \frac{\color{blue}{x + y}}{1 - \frac{y}{z}} \]
      3. add-flipN/A

        \[\leadsto \frac{\color{blue}{x - \left(\mathsf{neg}\left(y\right)\right)}}{1 - \frac{y}{z}} \]
      4. div-subN/A

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

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

        \[\leadsto \frac{x}{\color{blue}{1 - \frac{y}{z}}} - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      7. lift-/.f64N/A

        \[\leadsto \frac{x}{1 - \color{blue}{\frac{y}{z}}} - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      8. sub-to-fractionN/A

        \[\leadsto \frac{x}{\color{blue}{\frac{1 \cdot z - y}{z}}} - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      9. associate-/r/N/A

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

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

        \[\leadsto \color{blue}{\frac{x}{1 \cdot z - y}} \cdot z - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      12. *-lft-identityN/A

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

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

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

        \[\leadsto \frac{x}{z - y} \cdot z - \frac{\mathsf{neg}\left(y\right)}{1 - \color{blue}{\frac{y}{z}}} \]
      16. sub-to-fractionN/A

        \[\leadsto \frac{x}{z - y} \cdot z - \frac{\mathsf{neg}\left(y\right)}{\color{blue}{\frac{1 \cdot z - y}{z}}} \]
      17. associate-/r/N/A

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

        \[\leadsto \frac{x}{z - y} \cdot z - \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)}{\mathsf{neg}\left(\left(1 \cdot z - y\right)\right)}} \cdot z \]
      19. remove-double-negN/A

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

        \[\leadsto \frac{x}{z - y} \cdot z - \color{blue}{\frac{y}{\mathsf{neg}\left(\left(1 \cdot z - y\right)\right)} \cdot z} \]
    3. Applied rewrites92.5%

      \[\leadsto \color{blue}{\frac{x}{z - y} \cdot z - \frac{y}{y - z} \cdot z} \]
    4. Taylor expanded in z around inf

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

        \[\leadsto x - \color{blue}{-1 \cdot y} \]
      2. lower-*.f6451.9%

        \[\leadsto x - -1 \cdot \color{blue}{y} \]
    6. Applied rewrites51.9%

      \[\leadsto \color{blue}{x - -1 \cdot y} \]
    7. Step-by-step derivation
      1. distribute-rgt-out--51.9%

        \[\leadsto \color{blue}{x} - -1 \cdot y \]
      2. sub-flip51.9%

        \[\leadsto x - -1 \cdot y \]
      3. +-commutative51.9%

        \[\leadsto x - -1 \cdot y \]
      4. distribute-neg-frac251.9%

        \[\leadsto x - -1 \cdot y \]
      5. sub-negate-rev51.9%

        \[\leadsto x - -1 \cdot y \]
      6. lift--.f64N/A

        \[\leadsto x - -1 \cdot y \]
      7. lift--.f64N/A

        \[\leadsto x - -1 \cdot y \]
      8. div-addN/A

        \[\leadsto x - -1 \cdot y \]
      9. lift-+.f64N/A

        \[\leadsto x - -1 \cdot y \]
      10. associate-/l*N/A

        \[\leadsto \color{blue}{x} - -1 \cdot y \]
      11. associate-*l/N/A

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

        \[\leadsto x - -1 \cdot y \]
      13. lift-+.f6451.9%

        \[\leadsto x - -1 \cdot y \]
      14. lift--.f64N/A

        \[\leadsto x - \color{blue}{-1 \cdot y} \]
      15. lift-*.f64N/A

        \[\leadsto x - -1 \cdot \color{blue}{y} \]
      16. mul-1-negN/A

        \[\leadsto x - \left(\mathsf{neg}\left(y\right)\right) \]
      17. add-flipN/A

        \[\leadsto x + \color{blue}{y} \]
      18. lower-+.f6451.9%

        \[\leadsto x + \color{blue}{y} \]
    8. Applied rewrites51.9%

      \[\leadsto \color{blue}{x + y} \]
    9. Taylor expanded in x around 0

      \[\leadsto y \]
    10. Step-by-step derivation
      1. Applied rewrites18.6%

        \[\leadsto y \]

      if -1.7999999999999999e161 < z < 1.05e78

      1. Initial program 88.6%

        \[\frac{x + y}{1 - \frac{y}{z}} \]
      2. Taylor expanded in y around inf

        \[\leadsto \color{blue}{-1 \cdot z} \]
      3. Step-by-step derivation
        1. lower-*.f6434.7%

          \[\leadsto -1 \cdot \color{blue}{z} \]
      4. Applied rewrites34.7%

        \[\leadsto \color{blue}{-1 \cdot z} \]
      5. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto -1 \cdot \color{blue}{z} \]
        2. mul-1-negN/A

          \[\leadsto \mathsf{neg}\left(z\right) \]
        3. lower-neg.f6434.7%

          \[\leadsto -z \]
      6. Applied rewrites34.7%

        \[\leadsto -z \]
    11. Recombined 2 regimes into one program.
    12. Add Preprocessing

    Alternative 9: 18.6% accurate, 29.0× speedup?

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

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

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

        \[\leadsto \frac{\color{blue}{x + y}}{1 - \frac{y}{z}} \]
      3. add-flipN/A

        \[\leadsto \frac{\color{blue}{x - \left(\mathsf{neg}\left(y\right)\right)}}{1 - \frac{y}{z}} \]
      4. div-subN/A

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

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

        \[\leadsto \frac{x}{\color{blue}{1 - \frac{y}{z}}} - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      7. lift-/.f64N/A

        \[\leadsto \frac{x}{1 - \color{blue}{\frac{y}{z}}} - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      8. sub-to-fractionN/A

        \[\leadsto \frac{x}{\color{blue}{\frac{1 \cdot z - y}{z}}} - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      9. associate-/r/N/A

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

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

        \[\leadsto \color{blue}{\frac{x}{1 \cdot z - y}} \cdot z - \frac{\mathsf{neg}\left(y\right)}{1 - \frac{y}{z}} \]
      12. *-lft-identityN/A

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

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

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

        \[\leadsto \frac{x}{z - y} \cdot z - \frac{\mathsf{neg}\left(y\right)}{1 - \color{blue}{\frac{y}{z}}} \]
      16. sub-to-fractionN/A

        \[\leadsto \frac{x}{z - y} \cdot z - \frac{\mathsf{neg}\left(y\right)}{\color{blue}{\frac{1 \cdot z - y}{z}}} \]
      17. associate-/r/N/A

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

        \[\leadsto \frac{x}{z - y} \cdot z - \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)}{\mathsf{neg}\left(\left(1 \cdot z - y\right)\right)}} \cdot z \]
      19. remove-double-negN/A

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

        \[\leadsto \frac{x}{z - y} \cdot z - \color{blue}{\frac{y}{\mathsf{neg}\left(\left(1 \cdot z - y\right)\right)} \cdot z} \]
    3. Applied rewrites92.5%

      \[\leadsto \color{blue}{\frac{x}{z - y} \cdot z - \frac{y}{y - z} \cdot z} \]
    4. Taylor expanded in z around inf

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

        \[\leadsto x - \color{blue}{-1 \cdot y} \]
      2. lower-*.f6451.9%

        \[\leadsto x - -1 \cdot \color{blue}{y} \]
    6. Applied rewrites51.9%

      \[\leadsto \color{blue}{x - -1 \cdot y} \]
    7. Step-by-step derivation
      1. distribute-rgt-out--51.9%

        \[\leadsto \color{blue}{x} - -1 \cdot y \]
      2. sub-flip51.9%

        \[\leadsto x - -1 \cdot y \]
      3. +-commutative51.9%

        \[\leadsto x - -1 \cdot y \]
      4. distribute-neg-frac251.9%

        \[\leadsto x - -1 \cdot y \]
      5. sub-negate-rev51.9%

        \[\leadsto x - -1 \cdot y \]
      6. lift--.f64N/A

        \[\leadsto x - -1 \cdot y \]
      7. lift--.f64N/A

        \[\leadsto x - -1 \cdot y \]
      8. div-addN/A

        \[\leadsto x - -1 \cdot y \]
      9. lift-+.f64N/A

        \[\leadsto x - -1 \cdot y \]
      10. associate-/l*N/A

        \[\leadsto \color{blue}{x} - -1 \cdot y \]
      11. associate-*l/N/A

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

        \[\leadsto x - -1 \cdot y \]
      13. lift-+.f6451.9%

        \[\leadsto x - -1 \cdot y \]
      14. lift--.f64N/A

        \[\leadsto x - \color{blue}{-1 \cdot y} \]
      15. lift-*.f64N/A

        \[\leadsto x - -1 \cdot \color{blue}{y} \]
      16. mul-1-negN/A

        \[\leadsto x - \left(\mathsf{neg}\left(y\right)\right) \]
      17. add-flipN/A

        \[\leadsto x + \color{blue}{y} \]
      18. lower-+.f6451.9%

        \[\leadsto x + \color{blue}{y} \]
    8. Applied rewrites51.9%

      \[\leadsto \color{blue}{x + y} \]
    9. Taylor expanded in x around 0

      \[\leadsto y \]
    10. Step-by-step derivation
      1. Applied rewrites18.6%

        \[\leadsto y \]
      2. Add Preprocessing

      Reproduce

      ?
      herbie shell --seed 2025271 -o generate:evaluate
      (FPCore (x y z)
        :name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A"
        :precision binary64
        (/ (+ x y) (- 1 (/ y z))))