Data.Histogram.Bin.BinF:$cfromIndex from histogram-fill-0.8.4.1

Percentage Accurate: 100.0% → 100.0%
Time: 2.5s
Alternatives: 7
Speedup: 1.9×

Specification

?
\[\left(\frac{x}{2} + y \cdot x\right) + z \]
(FPCore (x y z)
  :precision binary64
  (+ (+ (/ x 2.0) (* y x)) z))
double code(double x, double y, double z) {
	return ((x / 2.0) + (y * x)) + 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 / 2.0d0) + (y * x)) + z
end function
public static double code(double x, double y, double z) {
	return ((x / 2.0) + (y * x)) + z;
}
def code(x, y, z):
	return ((x / 2.0) + (y * x)) + z
function code(x, y, z)
	return Float64(Float64(Float64(x / 2.0) + Float64(y * x)) + z)
end
function tmp = code(x, y, z)
	tmp = ((x / 2.0) + (y * x)) + z;
end
code[x_, y_, z_] := N[(N[(N[(x / 2.0), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]
\left(\frac{x}{2} + y \cdot x\right) + 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 7 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: 100.0% accurate, 1.0× speedup?

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

Alternative 1: 100.0% accurate, 1.4× speedup?

\[\left(z + y \cdot x\right) - -0.5 \cdot x \]
(FPCore (x y z)
  :precision binary64
  (- (+ z (* y x)) (* -0.5 x)))
double code(double x, double y, double z) {
	return (z + (y * x)) - (-0.5 * x);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (z + (y * x)) - ((-0.5d0) * x)
end function
public static double code(double x, double y, double z) {
	return (z + (y * x)) - (-0.5 * x);
}
def code(x, y, z):
	return (z + (y * x)) - (-0.5 * x)
function code(x, y, z)
	return Float64(Float64(z + Float64(y * x)) - Float64(-0.5 * x))
end
function tmp = code(x, y, z)
	tmp = (z + (y * x)) - (-0.5 * x);
end
code[x_, y_, z_] := N[(N[(z + N[(y * x), $MachinePrecision]), $MachinePrecision] - N[(-0.5 * x), $MachinePrecision]), $MachinePrecision]
\left(z + y \cdot x\right) - -0.5 \cdot x
Derivation
  1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto \left(y \cdot x + z\right) + \color{blue}{\frac{x}{2}} \]
    8. mult-flipN/A

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

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

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

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

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

      \[\leadsto \left(z + y \cdot x\right) - \color{blue}{\frac{\mathsf{neg}\left(x\right)}{2}} \]
    14. distribute-neg-fracN/A

      \[\leadsto \left(z + y \cdot x\right) - \color{blue}{\left(\mathsf{neg}\left(\frac{x}{2}\right)\right)} \]
    15. distribute-neg-frac2N/A

      \[\leadsto \left(z + y \cdot x\right) - \color{blue}{\frac{x}{\mathsf{neg}\left(2\right)}} \]
    16. mult-flipN/A

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

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

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

      \[\leadsto \left(z + y \cdot x\right) - \frac{1}{\color{blue}{-2}} \cdot x \]
    20. metadata-eval100.0%

      \[\leadsto \left(z + y \cdot x\right) - \color{blue}{-0.5} \cdot x \]
  3. Applied rewrites100.0%

    \[\leadsto \color{blue}{\left(z + y \cdot x\right) - -0.5 \cdot x} \]
  4. Add Preprocessing

Alternative 2: 100.0% accurate, 1.9× speedup?

\[z - \left(-0.5 - y\right) \cdot x \]
(FPCore (x y z)
  :precision binary64
  (- z (* (- -0.5 y) x)))
double code(double x, double y, double z) {
	return z - ((-0.5 - y) * x);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = z - (((-0.5d0) - y) * x)
end function
public static double code(double x, double y, double z) {
	return z - ((-0.5 - y) * x);
}
def code(x, y, z):
	return z - ((-0.5 - y) * x)
function code(x, y, z)
	return Float64(z - Float64(Float64(-0.5 - y) * x))
end
function tmp = code(x, y, z)
	tmp = z - ((-0.5 - y) * x);
end
code[x_, y_, z_] := N[(z - N[(N[(-0.5 - y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
z - \left(-0.5 - y\right) \cdot x
Derivation
  1. Initial program 100.0%

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

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

      \[\leadsto \color{blue}{z + \left(\frac{x}{2} + y \cdot x\right)} \]
    3. add-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto z - \left(\frac{1}{\color{blue}{-2}} - y\right) \cdot x \]
    19. metadata-eval100.0%

      \[\leadsto z - \left(\color{blue}{-0.5} - y\right) \cdot x \]
  3. Applied rewrites100.0%

    \[\leadsto \color{blue}{z - \left(-0.5 - y\right) \cdot x} \]
  4. Add Preprocessing

Alternative 3: 84.8% accurate, 1.1× speedup?

\[\begin{array}{l} t_0 := x \cdot \left(0.5 + y\right)\\ \mathbf{if}\;y \leq -1750:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 0.0085:\\ \;\;\;\;z + 0.5 \cdot x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (x y z)
  :precision binary64
  (let* ((t_0 (* x (+ 0.5 y))))
  (if (<= y -1750.0) t_0 (if (<= y 0.0085) (+ z (* 0.5 x)) t_0))))
double code(double x, double y, double z) {
	double t_0 = x * (0.5 + y);
	double tmp;
	if (y <= -1750.0) {
		tmp = t_0;
	} else if (y <= 0.0085) {
		tmp = z + (0.5 * x);
	} else {
		tmp = t_0;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

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

\mathbf{elif}\;y \leq 0.0085:\\
\;\;\;\;z + 0.5 \cdot x\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1750 or 0.0085000000000000006 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

        \[\leadsto \left(y \cdot x + z\right) + \color{blue}{\frac{x}{2}} \]
      8. mult-flipN/A

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

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

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

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

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

        \[\leadsto \left(z + y \cdot x\right) - \color{blue}{\frac{\mathsf{neg}\left(x\right)}{2}} \]
      14. distribute-neg-fracN/A

        \[\leadsto \left(z + y \cdot x\right) - \color{blue}{\left(\mathsf{neg}\left(\frac{x}{2}\right)\right)} \]
      15. distribute-neg-frac2N/A

        \[\leadsto \left(z + y \cdot x\right) - \color{blue}{\frac{x}{\mathsf{neg}\left(2\right)}} \]
      16. mult-flipN/A

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

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

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

        \[\leadsto \left(z + y \cdot x\right) - \frac{1}{\color{blue}{-2}} \cdot x \]
      20. metadata-eval100.0%

        \[\leadsto \left(z + y \cdot x\right) - \color{blue}{-0.5} \cdot x \]
    3. Applied rewrites100.0%

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

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

        \[\leadsto x \cdot \color{blue}{\left(\frac{1}{2} + y\right)} \]
      2. lower-+.f6461.6%

        \[\leadsto x \cdot \left(0.5 + \color{blue}{y}\right) \]
    6. Applied rewrites61.6%

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

    if -1750 < y < 0.0085000000000000006

    1. Initial program 100.0%

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

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

        \[\leadsto z + \color{blue}{\frac{1}{2} \cdot x} \]
      2. lower-*.f6465.0%

        \[\leadsto z + 0.5 \cdot \color{blue}{x} \]
    4. Applied rewrites65.0%

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

Alternative 4: 84.7% accurate, 1.1× speedup?

\[\begin{array}{l} \mathbf{if}\;y \leq -1750:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 3.7 \cdot 10^{+23}:\\ \;\;\;\;z + 0.5 \cdot x\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
(FPCore (x y z)
  :precision binary64
  (if (<= y -1750.0)
  (* x y)
  (if (<= y 3.7e+23) (+ z (* 0.5 x)) (* x y))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -1750.0) {
		tmp = x * y;
	} else if (y <= 3.7e+23) {
		tmp = z + (0.5 * x);
	} else {
		tmp = x * y;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, 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 <= (-1750.0d0)) then
        tmp = x * y
    else if (y <= 3.7d+23) then
        tmp = z + (0.5d0 * x)
    else
        tmp = x * y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -1750.0) {
		tmp = x * y;
	} else if (y <= 3.7e+23) {
		tmp = z + (0.5 * x);
	} else {
		tmp = x * y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -1750.0:
		tmp = x * y
	elif y <= 3.7e+23:
		tmp = z + (0.5 * x)
	else:
		tmp = x * y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -1750.0)
		tmp = Float64(x * y);
	elseif (y <= 3.7e+23)
		tmp = Float64(z + Float64(0.5 * x));
	else
		tmp = Float64(x * y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -1750.0)
		tmp = x * y;
	elseif (y <= 3.7e+23)
		tmp = z + (0.5 * x);
	else
		tmp = x * y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -1750.0], N[(x * y), $MachinePrecision], If[LessEqual[y, 3.7e+23], N[(z + N[(0.5 * x), $MachinePrecision]), $MachinePrecision], N[(x * y), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;y \leq -1750:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;y \leq 3.7 \cdot 10^{+23}:\\
\;\;\;\;z + 0.5 \cdot x\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1750 or 3.7000000000000001e23 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

        \[\leadsto \left(y \cdot x + z\right) + \color{blue}{\frac{x}{2}} \]
      8. mult-flipN/A

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

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

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

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

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

        \[\leadsto \left(z + y \cdot x\right) - \color{blue}{\frac{\mathsf{neg}\left(x\right)}{2}} \]
      14. distribute-neg-fracN/A

        \[\leadsto \left(z + y \cdot x\right) - \color{blue}{\left(\mathsf{neg}\left(\frac{x}{2}\right)\right)} \]
      15. distribute-neg-frac2N/A

        \[\leadsto \left(z + y \cdot x\right) - \color{blue}{\frac{x}{\mathsf{neg}\left(2\right)}} \]
      16. mult-flipN/A

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

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

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

        \[\leadsto \left(z + y \cdot x\right) - \frac{1}{\color{blue}{-2}} \cdot x \]
      20. metadata-eval100.0%

        \[\leadsto \left(z + y \cdot x\right) - \color{blue}{-0.5} \cdot x \]
    3. Applied rewrites100.0%

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

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

        \[\leadsto x \cdot \color{blue}{\left(\frac{1}{2} + y\right)} \]
      2. lower-+.f6461.6%

        \[\leadsto x \cdot \left(0.5 + \color{blue}{y}\right) \]
    6. Applied rewrites61.6%

      \[\leadsto \color{blue}{x \cdot \left(0.5 + y\right)} \]
    7. Taylor expanded in y around 0

      \[\leadsto x \cdot \frac{1}{2} \]
    8. Step-by-step derivation
      1. Applied rewrites27.2%

        \[\leadsto x \cdot 0.5 \]
      2. Taylor expanded in y around inf

        \[\leadsto x \cdot y \]
      3. Step-by-step derivation
        1. Applied rewrites36.6%

          \[\leadsto x \cdot y \]

        if -1750 < y < 3.7000000000000001e23

        1. Initial program 100.0%

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

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

            \[\leadsto z + \color{blue}{\frac{1}{2} \cdot x} \]
          2. lower-*.f6465.0%

            \[\leadsto z + 0.5 \cdot \color{blue}{x} \]
        4. Applied rewrites65.0%

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

      Alternative 5: 60.2% accurate, 0.6× speedup?

      \[\begin{array}{l} \mathbf{if}\;y \leq -4.1 \cdot 10^{-5}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq -1.5 \cdot 10^{-235}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 5.1 \cdot 10^{-166}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq 1.28 \cdot 10^{-21}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 3.7 \cdot 10^{+23}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
      (FPCore (x y z)
        :precision binary64
        (if (<= y -4.1e-5)
        (* x y)
        (if (<= y -1.5e-235)
          (* x 0.5)
          (if (<= y 5.1e-166)
            z
            (if (<= y 1.28e-21) (* x 0.5) (if (<= y 3.7e+23) z (* x y)))))))
      double code(double x, double y, double z) {
      	double tmp;
      	if (y <= -4.1e-5) {
      		tmp = x * y;
      	} else if (y <= -1.5e-235) {
      		tmp = x * 0.5;
      	} else if (y <= 5.1e-166) {
      		tmp = z;
      	} else if (y <= 1.28e-21) {
      		tmp = x * 0.5;
      	} else if (y <= 3.7e+23) {
      		tmp = z;
      	} else {
      		tmp = x * y;
      	}
      	return tmp;
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(x, y, 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 <= (-4.1d-5)) then
              tmp = x * y
          else if (y <= (-1.5d-235)) then
              tmp = x * 0.5d0
          else if (y <= 5.1d-166) then
              tmp = z
          else if (y <= 1.28d-21) then
              tmp = x * 0.5d0
          else if (y <= 3.7d+23) then
              tmp = z
          else
              tmp = x * y
          end if
          code = tmp
      end function
      
      public static double code(double x, double y, double z) {
      	double tmp;
      	if (y <= -4.1e-5) {
      		tmp = x * y;
      	} else if (y <= -1.5e-235) {
      		tmp = x * 0.5;
      	} else if (y <= 5.1e-166) {
      		tmp = z;
      	} else if (y <= 1.28e-21) {
      		tmp = x * 0.5;
      	} else if (y <= 3.7e+23) {
      		tmp = z;
      	} else {
      		tmp = x * y;
      	}
      	return tmp;
      }
      
      def code(x, y, z):
      	tmp = 0
      	if y <= -4.1e-5:
      		tmp = x * y
      	elif y <= -1.5e-235:
      		tmp = x * 0.5
      	elif y <= 5.1e-166:
      		tmp = z
      	elif y <= 1.28e-21:
      		tmp = x * 0.5
      	elif y <= 3.7e+23:
      		tmp = z
      	else:
      		tmp = x * y
      	return tmp
      
      function code(x, y, z)
      	tmp = 0.0
      	if (y <= -4.1e-5)
      		tmp = Float64(x * y);
      	elseif (y <= -1.5e-235)
      		tmp = Float64(x * 0.5);
      	elseif (y <= 5.1e-166)
      		tmp = z;
      	elseif (y <= 1.28e-21)
      		tmp = Float64(x * 0.5);
      	elseif (y <= 3.7e+23)
      		tmp = z;
      	else
      		tmp = Float64(x * y);
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y, z)
      	tmp = 0.0;
      	if (y <= -4.1e-5)
      		tmp = x * y;
      	elseif (y <= -1.5e-235)
      		tmp = x * 0.5;
      	elseif (y <= 5.1e-166)
      		tmp = z;
      	elseif (y <= 1.28e-21)
      		tmp = x * 0.5;
      	elseif (y <= 3.7e+23)
      		tmp = z;
      	else
      		tmp = x * y;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_] := If[LessEqual[y, -4.1e-5], N[(x * y), $MachinePrecision], If[LessEqual[y, -1.5e-235], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 5.1e-166], z, If[LessEqual[y, 1.28e-21], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 3.7e+23], z, N[(x * y), $MachinePrecision]]]]]]
      
      \begin{array}{l}
      \mathbf{if}\;y \leq -4.1 \cdot 10^{-5}:\\
      \;\;\;\;x \cdot y\\
      
      \mathbf{elif}\;y \leq -1.5 \cdot 10^{-235}:\\
      \;\;\;\;x \cdot 0.5\\
      
      \mathbf{elif}\;y \leq 5.1 \cdot 10^{-166}:\\
      \;\;\;\;z\\
      
      \mathbf{elif}\;y \leq 1.28 \cdot 10^{-21}:\\
      \;\;\;\;x \cdot 0.5\\
      
      \mathbf{elif}\;y \leq 3.7 \cdot 10^{+23}:\\
      \;\;\;\;z\\
      
      \mathbf{else}:\\
      \;\;\;\;x \cdot y\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if y < -4.1e-5 or 3.7000000000000001e23 < y

        1. Initial program 100.0%

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

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

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

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

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

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

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

            \[\leadsto \left(y \cdot x + z\right) + \color{blue}{\frac{x}{2}} \]
          8. mult-flipN/A

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

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

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

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

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

            \[\leadsto \left(z + y \cdot x\right) - \color{blue}{\frac{\mathsf{neg}\left(x\right)}{2}} \]
          14. distribute-neg-fracN/A

            \[\leadsto \left(z + y \cdot x\right) - \color{blue}{\left(\mathsf{neg}\left(\frac{x}{2}\right)\right)} \]
          15. distribute-neg-frac2N/A

            \[\leadsto \left(z + y \cdot x\right) - \color{blue}{\frac{x}{\mathsf{neg}\left(2\right)}} \]
          16. mult-flipN/A

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

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

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

            \[\leadsto \left(z + y \cdot x\right) - \frac{1}{\color{blue}{-2}} \cdot x \]
          20. metadata-eval100.0%

            \[\leadsto \left(z + y \cdot x\right) - \color{blue}{-0.5} \cdot x \]
        3. Applied rewrites100.0%

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

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

            \[\leadsto x \cdot \color{blue}{\left(\frac{1}{2} + y\right)} \]
          2. lower-+.f6461.6%

            \[\leadsto x \cdot \left(0.5 + \color{blue}{y}\right) \]
        6. Applied rewrites61.6%

          \[\leadsto \color{blue}{x \cdot \left(0.5 + y\right)} \]
        7. Taylor expanded in y around 0

          \[\leadsto x \cdot \frac{1}{2} \]
        8. Step-by-step derivation
          1. Applied rewrites27.2%

            \[\leadsto x \cdot 0.5 \]
          2. Taylor expanded in y around inf

            \[\leadsto x \cdot y \]
          3. Step-by-step derivation
            1. Applied rewrites36.6%

              \[\leadsto x \cdot y \]

            if -4.1e-5 < y < -1.4999999999999999e-235 or 5.1000000000000002e-166 < y < 1.2799999999999999e-21

            1. Initial program 100.0%

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

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

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

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

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

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

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

                \[\leadsto \left(y \cdot x + z\right) + \color{blue}{\frac{x}{2}} \]
              8. mult-flipN/A

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

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

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

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

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

                \[\leadsto \left(z + y \cdot x\right) - \color{blue}{\frac{\mathsf{neg}\left(x\right)}{2}} \]
              14. distribute-neg-fracN/A

                \[\leadsto \left(z + y \cdot x\right) - \color{blue}{\left(\mathsf{neg}\left(\frac{x}{2}\right)\right)} \]
              15. distribute-neg-frac2N/A

                \[\leadsto \left(z + y \cdot x\right) - \color{blue}{\frac{x}{\mathsf{neg}\left(2\right)}} \]
              16. mult-flipN/A

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

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

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

                \[\leadsto \left(z + y \cdot x\right) - \frac{1}{\color{blue}{-2}} \cdot x \]
              20. metadata-eval100.0%

                \[\leadsto \left(z + y \cdot x\right) - \color{blue}{-0.5} \cdot x \]
            3. Applied rewrites100.0%

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

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

                \[\leadsto x \cdot \color{blue}{\left(\frac{1}{2} + y\right)} \]
              2. lower-+.f6461.6%

                \[\leadsto x \cdot \left(0.5 + \color{blue}{y}\right) \]
            6. Applied rewrites61.6%

              \[\leadsto \color{blue}{x \cdot \left(0.5 + y\right)} \]
            7. Taylor expanded in y around 0

              \[\leadsto x \cdot \frac{1}{2} \]
            8. Step-by-step derivation
              1. Applied rewrites27.2%

                \[\leadsto x \cdot 0.5 \]

              if -1.4999999999999999e-235 < y < 5.1000000000000002e-166 or 1.2799999999999999e-21 < y < 3.7000000000000001e23

              1. Initial program 100.0%

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

                \[\leadsto \color{blue}{z} \]
              3. Step-by-step derivation
                1. Applied rewrites39.7%

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

              Alternative 6: 50.6% accurate, 1.3× speedup?

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

                1. Initial program 100.0%

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

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

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

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

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

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

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

                    \[\leadsto \left(y \cdot x + z\right) + \color{blue}{\frac{x}{2}} \]
                  8. mult-flipN/A

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

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

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

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

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

                    \[\leadsto \left(z + y \cdot x\right) - \color{blue}{\frac{\mathsf{neg}\left(x\right)}{2}} \]
                  14. distribute-neg-fracN/A

                    \[\leadsto \left(z + y \cdot x\right) - \color{blue}{\left(\mathsf{neg}\left(\frac{x}{2}\right)\right)} \]
                  15. distribute-neg-frac2N/A

                    \[\leadsto \left(z + y \cdot x\right) - \color{blue}{\frac{x}{\mathsf{neg}\left(2\right)}} \]
                  16. mult-flipN/A

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

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

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

                    \[\leadsto \left(z + y \cdot x\right) - \frac{1}{\color{blue}{-2}} \cdot x \]
                  20. metadata-eval100.0%

                    \[\leadsto \left(z + y \cdot x\right) - \color{blue}{-0.5} \cdot x \]
                3. Applied rewrites100.0%

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

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

                    \[\leadsto x \cdot \color{blue}{\left(\frac{1}{2} + y\right)} \]
                  2. lower-+.f6461.6%

                    \[\leadsto x \cdot \left(0.5 + \color{blue}{y}\right) \]
                6. Applied rewrites61.6%

                  \[\leadsto \color{blue}{x \cdot \left(0.5 + y\right)} \]
                7. Taylor expanded in y around 0

                  \[\leadsto x \cdot \frac{1}{2} \]
                8. Step-by-step derivation
                  1. Applied rewrites27.2%

                    \[\leadsto x \cdot 0.5 \]

                  if -8.2000000000000003e40 < x < 1.82e50

                  1. Initial program 100.0%

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

                    \[\leadsto \color{blue}{z} \]
                  3. Step-by-step derivation
                    1. Applied rewrites39.7%

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

                  Alternative 7: 39.7% accurate, 23.0× speedup?

                  \[z \]
                  (FPCore (x y z)
                    :precision binary64
                    z)
                  double code(double x, double y, double z) {
                  	return 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 = z
                  end function
                  
                  public static double code(double x, double y, double z) {
                  	return z;
                  }
                  
                  def code(x, y, z):
                  	return z
                  
                  function code(x, y, z)
                  	return z
                  end
                  
                  function tmp = code(x, y, z)
                  	tmp = z;
                  end
                  
                  code[x_, y_, z_] := z
                  
                  z
                  
                  Derivation
                  1. Initial program 100.0%

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

                    \[\leadsto \color{blue}{z} \]
                  3. Step-by-step derivation
                    1. Applied rewrites39.7%

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

                    Reproduce

                    ?
                    herbie shell --seed 2025258 
                    (FPCore (x y z)
                      :name "Data.Histogram.Bin.BinF:$cfromIndex from histogram-fill-0.8.4.1"
                      :precision binary64
                      (+ (+ (/ x 2.0) (* y x)) z))