Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, B

Percentage Accurate: 99.8% → 100.0%
Time: 1.5s
Alternatives: 7
Speedup: 1.3×

Specification

?
\[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
(FPCore (x y z)
  :precision binary64
  :pre TRUE
  (/ (* 4.0 (- (- x y) (* z 0.5))) z))
double code(double x, double y, double z) {
	return (4.0 * ((x - y) - (z * 0.5))) / z;
}
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 = (4.0d0 * ((x - y) - (z * 0.5d0))) / z
end function
public static double code(double x, double y, double z) {
	return (4.0 * ((x - y) - (z * 0.5))) / z;
}
def code(x, y, z):
	return (4.0 * ((x - y) - (z * 0.5))) / z
function code(x, y, z)
	return Float64(Float64(4.0 * Float64(Float64(x - y) - Float64(z * 0.5))) / z)
end
function tmp = code(x, y, z)
	tmp = (4.0 * ((x - y) - (z * 0.5))) / z;
end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - y), $MachinePrecision] - N[(z * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
f(x, y, z):
	x in [-inf, +inf],
	y in [-inf, +inf],
	z in [-inf, +inf]
code: THEORY
BEGIN
f(x, y, z: real): real =
	((4) * ((x - y) - (z * (5e-1)))) / z
END code
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\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: 99.8% accurate, 1.0× speedup?

\[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
(FPCore (x y z)
  :precision binary64
  :pre TRUE
  (/ (* 4.0 (- (- x y) (* z 0.5))) z))
double code(double x, double y, double z) {
	return (4.0 * ((x - y) - (z * 0.5))) / z;
}
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 = (4.0d0 * ((x - y) - (z * 0.5d0))) / z
end function
public static double code(double x, double y, double z) {
	return (4.0 * ((x - y) - (z * 0.5))) / z;
}
def code(x, y, z):
	return (4.0 * ((x - y) - (z * 0.5))) / z
function code(x, y, z)
	return Float64(Float64(4.0 * Float64(Float64(x - y) - Float64(z * 0.5))) / z)
end
function tmp = code(x, y, z)
	tmp = (4.0 * ((x - y) - (z * 0.5))) / z;
end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - y), $MachinePrecision] - N[(z * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
f(x, y, z):
	x in [-inf, +inf],
	y in [-inf, +inf],
	z in [-inf, +inf]
code: THEORY
BEGIN
f(x, y, z: real): real =
	((4) * ((x - y) - (z * (5e-1)))) / z
END code
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}

Alternative 1: 100.0% accurate, 1.3× speedup?

\[\mathsf{fma}\left(4, \frac{x - y}{z}, -2\right) \]
(FPCore (x y z)
  :precision binary64
  :pre TRUE
  (fma 4.0 (/ (- x y) z) -2.0))
double code(double x, double y, double z) {
	return fma(4.0, ((x - y) / z), -2.0);
}
function code(x, y, z)
	return fma(4.0, Float64(Float64(x - y) / z), -2.0)
end
code[x_, y_, z_] := N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision] + -2.0), $MachinePrecision]
f(x, y, z):
	x in [-inf, +inf],
	y in [-inf, +inf],
	z in [-inf, +inf]
code: THEORY
BEGIN
f(x, y, z: real): real =
	((4) * ((x - y) / z)) + (-2)
END code
\mathsf{fma}\left(4, \frac{x - y}{z}, -2\right)
Derivation
  1. Initial program 99.8%

    \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
  2. Step-by-step derivation
    1. Applied rewrites100.0%

      \[\leadsto \mathsf{fma}\left(4, \frac{x - y}{z}, -2\right) \]
    2. Add Preprocessing

    Alternative 2: 97.9% accurate, 0.3× speedup?

    \[\begin{array}{l} t_0 := \frac{4 \cdot \left(x - y\right)}{z}\\ t_1 := \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}\\ \mathbf{if}\;t\_1 \leq -4 \cdot 10^{+18}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_1 \leq 5000:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, -4, -2\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
    (FPCore (x y z)
      :precision binary64
      :pre TRUE
      (let* ((t_0 (/ (* 4.0 (- x y)) z))
           (t_1 (/ (* 4.0 (- (- x y) (* z 0.5))) z)))
      (if (<= t_1 -4e+18)
        t_0
        (if (<= t_1 5000.0) (fma (/ y z) -4.0 -2.0) t_0))))
    double code(double x, double y, double z) {
    	double t_0 = (4.0 * (x - y)) / z;
    	double t_1 = (4.0 * ((x - y) - (z * 0.5))) / z;
    	double tmp;
    	if (t_1 <= -4e+18) {
    		tmp = t_0;
    	} else if (t_1 <= 5000.0) {
    		tmp = fma((y / z), -4.0, -2.0);
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    function code(x, y, z)
    	t_0 = Float64(Float64(4.0 * Float64(x - y)) / z)
    	t_1 = Float64(Float64(4.0 * Float64(Float64(x - y) - Float64(z * 0.5))) / z)
    	tmp = 0.0
    	if (t_1 <= -4e+18)
    		tmp = t_0;
    	elseif (t_1 <= 5000.0)
    		tmp = fma(Float64(y / z), -4.0, -2.0);
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    code[x_, y_, z_] := Block[{t$95$0 = N[(N[(4.0 * N[(x - y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, Block[{t$95$1 = N[(N[(4.0 * N[(N[(x - y), $MachinePrecision] - N[(z * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+18], t$95$0, If[LessEqual[t$95$1, 5000.0], N[(N[(y / z), $MachinePrecision] * -4.0 + -2.0), $MachinePrecision], t$95$0]]]]
    
    f(x, y, z):
    	x in [-inf, +inf],
    	y in [-inf, +inf],
    	z in [-inf, +inf]
    code: THEORY
    BEGIN
    f(x, y, z: real): real =
    	LET t_0 = (((4) * (x - y)) / z) IN
    		LET t_1 = (((4) * ((x - y) - (z * (5e-1)))) / z) IN
    			LET tmp_1 = IF (t_1 <= (5000)) THEN (((y / z) * (-4)) + (-2)) ELSE t_0 ENDIF IN
    			LET tmp = IF (t_1 <= (-4e18)) THEN t_0 ELSE tmp_1 ENDIF IN
    	tmp
    END code
    \begin{array}{l}
    t_0 := \frac{4 \cdot \left(x - y\right)}{z}\\
    t_1 := \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}\\
    \mathbf{if}\;t\_1 \leq -4 \cdot 10^{+18}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;t\_1 \leq 5000:\\
    \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, -4, -2\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (/.f64 (*.f64 #s(literal 4 binary64) (-.f64 (-.f64 x y) (*.f64 z #s(literal 1/2 binary64)))) z) < -4e18 or 5e3 < (/.f64 (*.f64 #s(literal 4 binary64) (-.f64 (-.f64 x y) (*.f64 z #s(literal 1/2 binary64)))) z)

      1. Initial program 99.8%

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

        \[\leadsto \frac{4 \cdot \left(x - y\right)}{z} \]
      3. Step-by-step derivation
        1. Applied rewrites66.3%

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

        if -4e18 < (/.f64 (*.f64 #s(literal 4 binary64) (-.f64 (-.f64 x y) (*.f64 z #s(literal 1/2 binary64)))) z) < 5e3

        1. Initial program 99.8%

          \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
        2. Step-by-step derivation
          1. Applied rewrites100.0%

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

            \[\leadsto -4 \cdot \frac{y}{z} - 2 \]
          3. Step-by-step derivation
            1. Applied rewrites67.7%

              \[\leadsto -4 \cdot \frac{y}{z} - 2 \]
            2. Step-by-step derivation
              1. Applied rewrites67.7%

                \[\leadsto \mathsf{fma}\left(\frac{y}{z}, -4, -2\right) \]
            3. Recombined 2 regimes into one program.
            4. Add Preprocessing

            Alternative 3: 86.8% accurate, 0.9× speedup?

            \[\begin{array}{l} t_0 := \mathsf{fma}\left(4, \frac{x}{z}, -2\right)\\ \mathbf{if}\;x \leq -0.003879612161427806:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 474010.7854988907:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, -4, -2\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
            (FPCore (x y z)
              :precision binary64
              :pre TRUE
              (let* ((t_0 (fma 4.0 (/ x z) -2.0)))
              (if (<= x -0.003879612161427806)
                t_0
                (if (<= x 474010.7854988907) (fma (/ y z) -4.0 -2.0) t_0))))
            double code(double x, double y, double z) {
            	double t_0 = fma(4.0, (x / z), -2.0);
            	double tmp;
            	if (x <= -0.003879612161427806) {
            		tmp = t_0;
            	} else if (x <= 474010.7854988907) {
            		tmp = fma((y / z), -4.0, -2.0);
            	} else {
            		tmp = t_0;
            	}
            	return tmp;
            }
            
            function code(x, y, z)
            	t_0 = fma(4.0, Float64(x / z), -2.0)
            	tmp = 0.0
            	if (x <= -0.003879612161427806)
            		tmp = t_0;
            	elseif (x <= 474010.7854988907)
            		tmp = fma(Float64(y / z), -4.0, -2.0);
            	else
            		tmp = t_0;
            	end
            	return tmp
            end
            
            code[x_, y_, z_] := Block[{t$95$0 = N[(4.0 * N[(x / z), $MachinePrecision] + -2.0), $MachinePrecision]}, If[LessEqual[x, -0.003879612161427806], t$95$0, If[LessEqual[x, 474010.7854988907], N[(N[(y / z), $MachinePrecision] * -4.0 + -2.0), $MachinePrecision], t$95$0]]]
            
            f(x, y, z):
            	x in [-inf, +inf],
            	y in [-inf, +inf],
            	z in [-inf, +inf]
            code: THEORY
            BEGIN
            f(x, y, z: real): real =
            	LET t_0 = (((4) * (x / z)) + (-2)) IN
            		LET tmp_1 = IF (x <= (474010785498890676535665988922119140625e-33)) THEN (((y / z) * (-4)) + (-2)) ELSE t_0 ENDIF IN
            		LET tmp = IF (x <= (-387961216142780618287844163205591030418872833251953125e-56)) THEN t_0 ELSE tmp_1 ENDIF IN
            	tmp
            END code
            \begin{array}{l}
            t_0 := \mathsf{fma}\left(4, \frac{x}{z}, -2\right)\\
            \mathbf{if}\;x \leq -0.003879612161427806:\\
            \;\;\;\;t\_0\\
            
            \mathbf{elif}\;x \leq 474010.7854988907:\\
            \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, -4, -2\right)\\
            
            \mathbf{else}:\\
            \;\;\;\;t\_0\\
            
            
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if x < -0.0038796121614278062 or 474010.78549889068 < x

              1. Initial program 99.8%

                \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
              2. Step-by-step derivation
                1. Applied rewrites100.0%

                  \[\leadsto \mathsf{fma}\left(4, \frac{x - y}{z}, -2\right) \]
                2. Taylor expanded in x around inf

                  \[\leadsto \mathsf{fma}\left(4, \frac{x}{z}, -2\right) \]
                3. Step-by-step derivation
                  1. Applied rewrites68.3%

                    \[\leadsto \mathsf{fma}\left(4, \frac{x}{z}, -2\right) \]

                  if -0.0038796121614278062 < x < 474010.78549889068

                  1. Initial program 99.8%

                    \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
                  2. Step-by-step derivation
                    1. Applied rewrites100.0%

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

                      \[\leadsto -4 \cdot \frac{y}{z} - 2 \]
                    3. Step-by-step derivation
                      1. Applied rewrites67.7%

                        \[\leadsto -4 \cdot \frac{y}{z} - 2 \]
                      2. Step-by-step derivation
                        1. Applied rewrites67.7%

                          \[\leadsto \mathsf{fma}\left(\frac{y}{z}, -4, -2\right) \]
                      3. Recombined 2 regimes into one program.
                      4. Add Preprocessing

                      Alternative 4: 80.3% accurate, 0.9× speedup?

                      \[\begin{array}{l} t_0 := \frac{4 \cdot x}{z}\\ \mathbf{if}\;x \leq -1.5154749511009043 \cdot 10^{+102}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1.3064649686083533 \cdot 10^{+147}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, -4, -2\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
                      (FPCore (x y z)
                        :precision binary64
                        :pre TRUE
                        (let* ((t_0 (/ (* 4.0 x) z)))
                        (if (<= x -1.5154749511009043e+102)
                          t_0
                          (if (<= x 1.3064649686083533e+147) (fma (/ y z) -4.0 -2.0) t_0))))
                      double code(double x, double y, double z) {
                      	double t_0 = (4.0 * x) / z;
                      	double tmp;
                      	if (x <= -1.5154749511009043e+102) {
                      		tmp = t_0;
                      	} else if (x <= 1.3064649686083533e+147) {
                      		tmp = fma((y / z), -4.0, -2.0);
                      	} else {
                      		tmp = t_0;
                      	}
                      	return tmp;
                      }
                      
                      function code(x, y, z)
                      	t_0 = Float64(Float64(4.0 * x) / z)
                      	tmp = 0.0
                      	if (x <= -1.5154749511009043e+102)
                      		tmp = t_0;
                      	elseif (x <= 1.3064649686083533e+147)
                      		tmp = fma(Float64(y / z), -4.0, -2.0);
                      	else
                      		tmp = t_0;
                      	end
                      	return tmp
                      end
                      
                      code[x_, y_, z_] := Block[{t$95$0 = N[(N[(4.0 * x), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[x, -1.5154749511009043e+102], t$95$0, If[LessEqual[x, 1.3064649686083533e+147], N[(N[(y / z), $MachinePrecision] * -4.0 + -2.0), $MachinePrecision], t$95$0]]]
                      
                      f(x, y, z):
                      	x in [-inf, +inf],
                      	y in [-inf, +inf],
                      	z in [-inf, +inf]
                      code: THEORY
                      BEGIN
                      f(x, y, z: real): real =
                      	LET t_0 = (((4) * x) / z) IN
                      		LET tmp_1 = IF (x <= (1306464968608353291917552759654382600582940896221174479734158802198310852262413427002729117057911732841890700755877960701217930113429315076552130560)) THEN (((y / z) * (-4)) + (-2)) ELSE t_0 ENDIF IN
                      		LET tmp = IF (x <= (-1515474951100904265797726916768202718528404263409534502959203922947084940691542789719649840481777483776)) THEN t_0 ELSE tmp_1 ENDIF IN
                      	tmp
                      END code
                      \begin{array}{l}
                      t_0 := \frac{4 \cdot x}{z}\\
                      \mathbf{if}\;x \leq -1.5154749511009043 \cdot 10^{+102}:\\
                      \;\;\;\;t\_0\\
                      
                      \mathbf{elif}\;x \leq 1.3064649686083533 \cdot 10^{+147}:\\
                      \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, -4, -2\right)\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;t\_0\\
                      
                      
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if x < -1.5154749511009043e102 or 1.3064649686083533e147 < x

                        1. Initial program 99.8%

                          \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
                        2. Taylor expanded in x around inf

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

                            \[\leadsto \frac{4 \cdot x}{z} \]

                          if -1.5154749511009043e102 < x < 1.3064649686083533e147

                          1. Initial program 99.8%

                            \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
                          2. Step-by-step derivation
                            1. Applied rewrites100.0%

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

                              \[\leadsto -4 \cdot \frac{y}{z} - 2 \]
                            3. Step-by-step derivation
                              1. Applied rewrites67.7%

                                \[\leadsto -4 \cdot \frac{y}{z} - 2 \]
                              2. Step-by-step derivation
                                1. Applied rewrites67.7%

                                  \[\leadsto \mathsf{fma}\left(\frac{y}{z}, -4, -2\right) \]
                              3. Recombined 2 regimes into one program.
                              4. Add Preprocessing

                              Alternative 5: 66.2% accurate, 0.2× speedup?

                              \[\begin{array}{l} t_0 := \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}\\ t_1 := \frac{-4 \cdot y}{z}\\ \mathbf{if}\;t\_0 \leq -2 \cdot 10^{+173}:\\ \;\;\;\;\frac{4 \cdot x}{z}\\ \mathbf{elif}\;t\_0 \leq -5 \cdot 10^{+15}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq -1:\\ \;\;\;\;-2\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
                              (FPCore (x y z)
                                :precision binary64
                                :pre TRUE
                                (let* ((t_0 (/ (* 4.0 (- (- x y) (* z 0.5))) z))
                                     (t_1 (/ (* -4.0 y) z)))
                                (if (<= t_0 -2e+173)
                                  (/ (* 4.0 x) z)
                                  (if (<= t_0 -5e+15) t_1 (if (<= t_0 -1.0) -2.0 t_1)))))
                              double code(double x, double y, double z) {
                              	double t_0 = (4.0 * ((x - y) - (z * 0.5))) / z;
                              	double t_1 = (-4.0 * y) / z;
                              	double tmp;
                              	if (t_0 <= -2e+173) {
                              		tmp = (4.0 * x) / z;
                              	} else if (t_0 <= -5e+15) {
                              		tmp = t_1;
                              	} else if (t_0 <= -1.0) {
                              		tmp = -2.0;
                              	} else {
                              		tmp = t_1;
                              	}
                              	return tmp;
                              }
                              
                              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 = (4.0d0 * ((x - y) - (z * 0.5d0))) / z
                                  t_1 = ((-4.0d0) * y) / z
                                  if (t_0 <= (-2d+173)) then
                                      tmp = (4.0d0 * x) / z
                                  else if (t_0 <= (-5d+15)) then
                                      tmp = t_1
                                  else if (t_0 <= (-1.0d0)) then
                                      tmp = -2.0d0
                                  else
                                      tmp = t_1
                                  end if
                                  code = tmp
                              end function
                              
                              public static double code(double x, double y, double z) {
                              	double t_0 = (4.0 * ((x - y) - (z * 0.5))) / z;
                              	double t_1 = (-4.0 * y) / z;
                              	double tmp;
                              	if (t_0 <= -2e+173) {
                              		tmp = (4.0 * x) / z;
                              	} else if (t_0 <= -5e+15) {
                              		tmp = t_1;
                              	} else if (t_0 <= -1.0) {
                              		tmp = -2.0;
                              	} else {
                              		tmp = t_1;
                              	}
                              	return tmp;
                              }
                              
                              def code(x, y, z):
                              	t_0 = (4.0 * ((x - y) - (z * 0.5))) / z
                              	t_1 = (-4.0 * y) / z
                              	tmp = 0
                              	if t_0 <= -2e+173:
                              		tmp = (4.0 * x) / z
                              	elif t_0 <= -5e+15:
                              		tmp = t_1
                              	elif t_0 <= -1.0:
                              		tmp = -2.0
                              	else:
                              		tmp = t_1
                              	return tmp
                              
                              function code(x, y, z)
                              	t_0 = Float64(Float64(4.0 * Float64(Float64(x - y) - Float64(z * 0.5))) / z)
                              	t_1 = Float64(Float64(-4.0 * y) / z)
                              	tmp = 0.0
                              	if (t_0 <= -2e+173)
                              		tmp = Float64(Float64(4.0 * x) / z);
                              	elseif (t_0 <= -5e+15)
                              		tmp = t_1;
                              	elseif (t_0 <= -1.0)
                              		tmp = -2.0;
                              	else
                              		tmp = t_1;
                              	end
                              	return tmp
                              end
                              
                              function tmp_2 = code(x, y, z)
                              	t_0 = (4.0 * ((x - y) - (z * 0.5))) / z;
                              	t_1 = (-4.0 * y) / z;
                              	tmp = 0.0;
                              	if (t_0 <= -2e+173)
                              		tmp = (4.0 * x) / z;
                              	elseif (t_0 <= -5e+15)
                              		tmp = t_1;
                              	elseif (t_0 <= -1.0)
                              		tmp = -2.0;
                              	else
                              		tmp = t_1;
                              	end
                              	tmp_2 = tmp;
                              end
                              
                              code[x_, y_, z_] := Block[{t$95$0 = N[(N[(4.0 * N[(N[(x - y), $MachinePrecision] - N[(z * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, Block[{t$95$1 = N[(N[(-4.0 * y), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+173], N[(N[(4.0 * x), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[t$95$0, -5e+15], t$95$1, If[LessEqual[t$95$0, -1.0], -2.0, t$95$1]]]]]
                              
                              f(x, y, z):
                              	x in [-inf, +inf],
                              	y in [-inf, +inf],
                              	z in [-inf, +inf]
                              code: THEORY
                              BEGIN
                              f(x, y, z: real): real =
                              	LET t_0 = (((4) * ((x - y) - (z * (5e-1)))) / z) IN
                              		LET t_1 = (((-4) * y) / z) IN
                              			LET tmp_2 = IF (t_0 <= (-1)) THEN (-2) ELSE t_1 ENDIF IN
                              			LET tmp_1 = IF (t_0 <= (-5e15)) THEN t_1 ELSE tmp_2 ENDIF IN
                              			LET tmp = IF (t_0 <= (-200000000000000002807837251159941043564923941140258272187660085890042609097300216216368266487131373689224571527556203812385978553726279379745535544168843379433521211366178816)) THEN (((4) * x) / z) ELSE tmp_1 ENDIF IN
                              	tmp
                              END code
                              \begin{array}{l}
                              t_0 := \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}\\
                              t_1 := \frac{-4 \cdot y}{z}\\
                              \mathbf{if}\;t\_0 \leq -2 \cdot 10^{+173}:\\
                              \;\;\;\;\frac{4 \cdot x}{z}\\
                              
                              \mathbf{elif}\;t\_0 \leq -5 \cdot 10^{+15}:\\
                              \;\;\;\;t\_1\\
                              
                              \mathbf{elif}\;t\_0 \leq -1:\\
                              \;\;\;\;-2\\
                              
                              \mathbf{else}:\\
                              \;\;\;\;t\_1\\
                              
                              
                              \end{array}
                              
                              Derivation
                              1. Split input into 3 regimes
                              2. if (/.f64 (*.f64 #s(literal 4 binary64) (-.f64 (-.f64 x y) (*.f64 z #s(literal 1/2 binary64)))) z) < -2e173

                                1. Initial program 99.8%

                                  \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
                                2. Taylor expanded in x around inf

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

                                    \[\leadsto \frac{4 \cdot x}{z} \]

                                  if -2e173 < (/.f64 (*.f64 #s(literal 4 binary64) (-.f64 (-.f64 x y) (*.f64 z #s(literal 1/2 binary64)))) z) < -5e15 or -1 < (/.f64 (*.f64 #s(literal 4 binary64) (-.f64 (-.f64 x y) (*.f64 z #s(literal 1/2 binary64)))) z)

                                  1. Initial program 99.8%

                                    \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
                                  2. Taylor expanded in y around inf

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

                                      \[\leadsto \frac{-4 \cdot y}{z} \]

                                    if -5e15 < (/.f64 (*.f64 #s(literal 4 binary64) (-.f64 (-.f64 x y) (*.f64 z #s(literal 1/2 binary64)))) z) < -1

                                    1. Initial program 99.8%

                                      \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
                                    2. Taylor expanded in z around inf

                                      \[\leadsto -2 \]
                                    3. Step-by-step derivation
                                      1. Applied rewrites34.5%

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

                                    Alternative 6: 66.2% accurate, 0.4× speedup?

                                    \[\begin{array}{l} t_0 := \frac{-4 \cdot y}{z}\\ t_1 := \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}\\ \mathbf{if}\;t\_1 \leq -5 \cdot 10^{+15}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_1 \leq -1:\\ \;\;\;\;-2\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
                                    (FPCore (x y z)
                                      :precision binary64
                                      :pre TRUE
                                      (let* ((t_0 (/ (* -4.0 y) z))
                                           (t_1 (/ (* 4.0 (- (- x y) (* z 0.5))) z)))
                                      (if (<= t_1 -5e+15) t_0 (if (<= t_1 -1.0) -2.0 t_0))))
                                    double code(double x, double y, double z) {
                                    	double t_0 = (-4.0 * y) / z;
                                    	double t_1 = (4.0 * ((x - y) - (z * 0.5))) / z;
                                    	double tmp;
                                    	if (t_1 <= -5e+15) {
                                    		tmp = t_0;
                                    	} else if (t_1 <= -1.0) {
                                    		tmp = -2.0;
                                    	} else {
                                    		tmp = t_0;
                                    	}
                                    	return tmp;
                                    }
                                    
                                    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 = ((-4.0d0) * y) / z
                                        t_1 = (4.0d0 * ((x - y) - (z * 0.5d0))) / z
                                        if (t_1 <= (-5d+15)) then
                                            tmp = t_0
                                        else if (t_1 <= (-1.0d0)) then
                                            tmp = -2.0d0
                                        else
                                            tmp = t_0
                                        end if
                                        code = tmp
                                    end function
                                    
                                    public static double code(double x, double y, double z) {
                                    	double t_0 = (-4.0 * y) / z;
                                    	double t_1 = (4.0 * ((x - y) - (z * 0.5))) / z;
                                    	double tmp;
                                    	if (t_1 <= -5e+15) {
                                    		tmp = t_0;
                                    	} else if (t_1 <= -1.0) {
                                    		tmp = -2.0;
                                    	} else {
                                    		tmp = t_0;
                                    	}
                                    	return tmp;
                                    }
                                    
                                    def code(x, y, z):
                                    	t_0 = (-4.0 * y) / z
                                    	t_1 = (4.0 * ((x - y) - (z * 0.5))) / z
                                    	tmp = 0
                                    	if t_1 <= -5e+15:
                                    		tmp = t_0
                                    	elif t_1 <= -1.0:
                                    		tmp = -2.0
                                    	else:
                                    		tmp = t_0
                                    	return tmp
                                    
                                    function code(x, y, z)
                                    	t_0 = Float64(Float64(-4.0 * y) / z)
                                    	t_1 = Float64(Float64(4.0 * Float64(Float64(x - y) - Float64(z * 0.5))) / z)
                                    	tmp = 0.0
                                    	if (t_1 <= -5e+15)
                                    		tmp = t_0;
                                    	elseif (t_1 <= -1.0)
                                    		tmp = -2.0;
                                    	else
                                    		tmp = t_0;
                                    	end
                                    	return tmp
                                    end
                                    
                                    function tmp_2 = code(x, y, z)
                                    	t_0 = (-4.0 * y) / z;
                                    	t_1 = (4.0 * ((x - y) - (z * 0.5))) / z;
                                    	tmp = 0.0;
                                    	if (t_1 <= -5e+15)
                                    		tmp = t_0;
                                    	elseif (t_1 <= -1.0)
                                    		tmp = -2.0;
                                    	else
                                    		tmp = t_0;
                                    	end
                                    	tmp_2 = tmp;
                                    end
                                    
                                    code[x_, y_, z_] := Block[{t$95$0 = N[(N[(-4.0 * y), $MachinePrecision] / z), $MachinePrecision]}, Block[{t$95$1 = N[(N[(4.0 * N[(N[(x - y), $MachinePrecision] - N[(z * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+15], t$95$0, If[LessEqual[t$95$1, -1.0], -2.0, t$95$0]]]]
                                    
                                    f(x, y, z):
                                    	x in [-inf, +inf],
                                    	y in [-inf, +inf],
                                    	z in [-inf, +inf]
                                    code: THEORY
                                    BEGIN
                                    f(x, y, z: real): real =
                                    	LET t_0 = (((-4) * y) / z) IN
                                    		LET t_1 = (((4) * ((x - y) - (z * (5e-1)))) / z) IN
                                    			LET tmp_1 = IF (t_1 <= (-1)) THEN (-2) ELSE t_0 ENDIF IN
                                    			LET tmp = IF (t_1 <= (-5e15)) THEN t_0 ELSE tmp_1 ENDIF IN
                                    	tmp
                                    END code
                                    \begin{array}{l}
                                    t_0 := \frac{-4 \cdot y}{z}\\
                                    t_1 := \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}\\
                                    \mathbf{if}\;t\_1 \leq -5 \cdot 10^{+15}:\\
                                    \;\;\;\;t\_0\\
                                    
                                    \mathbf{elif}\;t\_1 \leq -1:\\
                                    \;\;\;\;-2\\
                                    
                                    \mathbf{else}:\\
                                    \;\;\;\;t\_0\\
                                    
                                    
                                    \end{array}
                                    
                                    Derivation
                                    1. Split input into 2 regimes
                                    2. if (/.f64 (*.f64 #s(literal 4 binary64) (-.f64 (-.f64 x y) (*.f64 z #s(literal 1/2 binary64)))) z) < -5e15 or -1 < (/.f64 (*.f64 #s(literal 4 binary64) (-.f64 (-.f64 x y) (*.f64 z #s(literal 1/2 binary64)))) z)

                                      1. Initial program 99.8%

                                        \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
                                      2. Taylor expanded in y around inf

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

                                          \[\leadsto \frac{-4 \cdot y}{z} \]

                                        if -5e15 < (/.f64 (*.f64 #s(literal 4 binary64) (-.f64 (-.f64 x y) (*.f64 z #s(literal 1/2 binary64)))) z) < -1

                                        1. Initial program 99.8%

                                          \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
                                        2. Taylor expanded in z around inf

                                          \[\leadsto -2 \]
                                        3. Step-by-step derivation
                                          1. Applied rewrites34.5%

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

                                        Alternative 7: 34.5% accurate, 16.0× speedup?

                                        \[-2 \]
                                        (FPCore (x y z)
                                          :precision binary64
                                          :pre TRUE
                                          -2.0)
                                        double code(double x, double y, double z) {
                                        	return -2.0;
                                        }
                                        
                                        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 = -2.0d0
                                        end function
                                        
                                        public static double code(double x, double y, double z) {
                                        	return -2.0;
                                        }
                                        
                                        def code(x, y, z):
                                        	return -2.0
                                        
                                        function code(x, y, z)
                                        	return -2.0
                                        end
                                        
                                        function tmp = code(x, y, z)
                                        	tmp = -2.0;
                                        end
                                        
                                        code[x_, y_, z_] := -2.0
                                        
                                        f(x, y, z):
                                        	x in [-inf, +inf],
                                        	y in [-inf, +inf],
                                        	z in [-inf, +inf]
                                        code: THEORY
                                        BEGIN
                                        f(x, y, z: real): real =
                                        	-2
                                        END code
                                        -2
                                        
                                        Derivation
                                        1. Initial program 99.8%

                                          \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
                                        2. Taylor expanded in z around inf

                                          \[\leadsto -2 \]
                                        3. Step-by-step derivation
                                          1. Applied rewrites34.5%

                                            \[\leadsto -2 \]
                                          2. Add Preprocessing

                                          Reproduce

                                          ?
                                          herbie shell --seed 2026092 
                                          (FPCore (x y z)
                                            :name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, B"
                                            :precision binary64
                                            (/ (* 4.0 (- (- x y) (* z 0.5))) z))