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

Percentage Accurate: 99.9% → 100.0%
Time: 6.3s
Alternatives: 11
Speedup: 1.4×

Specification

?
\[\begin{array}{l} \\ 1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))
double code(double x, double y, double z) {
	return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = 1.0d0 + ((4.0d0 * ((x + (y * 0.25d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
	return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
def code(x, y, z):
	return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y)
function code(x, y, z)
	return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.25)) - z)) / y))
end
function tmp = code(x, y, z)
	tmp = 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 11 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ 1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))
double code(double x, double y, double z) {
	return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = 1.0d0 + ((4.0d0 * ((x + (y * 0.25d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
	return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
def code(x, y, z):
	return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y)
function code(x, y, z)
	return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.25)) - z)) / y))
end
function tmp = code(x, y, z)
	tmp = 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}
\end{array}

Alternative 1: 100.0% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \frac{x - z}{y \cdot 0.25} + 2 \end{array} \]
(FPCore (x y z) :precision binary64 (+ (/ (- x z) (* y 0.25)) 2.0))
double code(double x, double y, double z) {
	return ((x - z) / (y * 0.25)) + 2.0;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = ((x - z) / (y * 0.25d0)) + 2.0d0
end function
public static double code(double x, double y, double z) {
	return ((x - z) / (y * 0.25)) + 2.0;
}
def code(x, y, z):
	return ((x - z) / (y * 0.25)) + 2.0
function code(x, y, z)
	return Float64(Float64(Float64(x - z) / Float64(y * 0.25)) + 2.0)
end
function tmp = code(x, y, z)
	tmp = ((x - z) / (y * 0.25)) + 2.0;
end
code[x_, y_, z_] := N[(N[(N[(x - z), $MachinePrecision] / N[(y * 0.25), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]
\begin{array}{l}

\\
\frac{x - z}{y \cdot 0.25} + 2
\end{array}
Derivation
  1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} + 1} \]
    2. associate-*l/99.8%

      \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(\left(x + y \cdot 0.25\right) - z\right)} + 1 \]
    3. +-commutative99.8%

      \[\leadsto \frac{4}{y} \cdot \left(\color{blue}{\left(y \cdot 0.25 + x\right)} - z\right) + 1 \]
    4. associate--l+99.8%

      \[\leadsto \frac{4}{y} \cdot \color{blue}{\left(y \cdot 0.25 + \left(x - z\right)\right)} + 1 \]
    5. +-commutative99.8%

      \[\leadsto \frac{4}{y} \cdot \color{blue}{\left(\left(x - z\right) + y \cdot 0.25\right)} + 1 \]
    6. distribute-lft-in99.8%

      \[\leadsto \color{blue}{\left(\frac{4}{y} \cdot \left(x - z\right) + \frac{4}{y} \cdot \left(y \cdot 0.25\right)\right)} + 1 \]
    7. associate-+l+99.8%

      \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(x - z\right) + \left(\frac{4}{y} \cdot \left(y \cdot 0.25\right) + 1\right)} \]
    8. associate-*l/99.8%

      \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\color{blue}{\frac{4 \cdot \left(y \cdot 0.25\right)}{y}} + 1\right) \]
    9. *-commutative99.8%

      \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{\left(y \cdot 0.25\right) \cdot 4}}{y} + 1\right) \]
    10. associate-*l*99.8%

      \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{y \cdot \left(0.25 \cdot 4\right)}}{y} + 1\right) \]
    11. metadata-eval99.8%

      \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{y \cdot \color{blue}{1}}{y} + 1\right) \]
    12. *-rgt-identity99.8%

      \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{y}}{y} + 1\right) \]
    13. *-inverses99.8%

      \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\color{blue}{1} + 1\right) \]
    14. metadata-eval99.8%

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

    \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(x - z\right) + 2} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. clear-num99.8%

      \[\leadsto \color{blue}{\frac{1}{\frac{y}{4}}} \cdot \left(x - z\right) + 2 \]
    2. div-inv99.8%

      \[\leadsto \frac{1}{\color{blue}{y \cdot \frac{1}{4}}} \cdot \left(x - z\right) + 2 \]
    3. metadata-eval99.8%

      \[\leadsto \frac{1}{y \cdot \color{blue}{0.25}} \cdot \left(x - z\right) + 2 \]
    4. associate-*l/100.0%

      \[\leadsto \color{blue}{\frac{1 \cdot \left(x - z\right)}{y \cdot 0.25}} + 2 \]
    5. *-un-lft-identity100.0%

      \[\leadsto \frac{\color{blue}{x - z}}{y \cdot 0.25} + 2 \]
  6. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\frac{x - z}{y \cdot 0.25}} + 2 \]
  7. Add Preprocessing

Alternative 2: 55.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -4 \cdot \frac{z}{y} + 1\\ t_1 := 1 + \frac{x \cdot 4}{y}\\ \mathbf{if}\;x \leq -7.6 \cdot 10^{+30}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq -1.66 \cdot 10^{-87}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq -2.2 \cdot 10^{-172}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -1.22 \cdot 10^{-201}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq -8.2 \cdot 10^{-297}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 98000000000:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ (* -4.0 (/ z y)) 1.0)) (t_1 (+ 1.0 (/ (* x 4.0) y))))
   (if (<= x -7.6e+30)
     t_1
     (if (<= x -1.66e-87)
       2.0
       (if (<= x -2.2e-172)
         t_0
         (if (<= x -1.22e-201)
           2.0
           (if (<= x -8.2e-297) t_0 (if (<= x 98000000000.0) 2.0 t_1))))))))
double code(double x, double y, double z) {
	double t_0 = (-4.0 * (z / y)) + 1.0;
	double t_1 = 1.0 + ((x * 4.0) / y);
	double tmp;
	if (x <= -7.6e+30) {
		tmp = t_1;
	} else if (x <= -1.66e-87) {
		tmp = 2.0;
	} else if (x <= -2.2e-172) {
		tmp = t_0;
	} else if (x <= -1.22e-201) {
		tmp = 2.0;
	} else if (x <= -8.2e-297) {
		tmp = t_0;
	} else if (x <= 98000000000.0) {
		tmp = 2.0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, y, z)
    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) * (z / y)) + 1.0d0
    t_1 = 1.0d0 + ((x * 4.0d0) / y)
    if (x <= (-7.6d+30)) then
        tmp = t_1
    else if (x <= (-1.66d-87)) then
        tmp = 2.0d0
    else if (x <= (-2.2d-172)) then
        tmp = t_0
    else if (x <= (-1.22d-201)) then
        tmp = 2.0d0
    else if (x <= (-8.2d-297)) then
        tmp = t_0
    else if (x <= 98000000000.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 * (z / y)) + 1.0;
	double t_1 = 1.0 + ((x * 4.0) / y);
	double tmp;
	if (x <= -7.6e+30) {
		tmp = t_1;
	} else if (x <= -1.66e-87) {
		tmp = 2.0;
	} else if (x <= -2.2e-172) {
		tmp = t_0;
	} else if (x <= -1.22e-201) {
		tmp = 2.0;
	} else if (x <= -8.2e-297) {
		tmp = t_0;
	} else if (x <= 98000000000.0) {
		tmp = 2.0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (-4.0 * (z / y)) + 1.0
	t_1 = 1.0 + ((x * 4.0) / y)
	tmp = 0
	if x <= -7.6e+30:
		tmp = t_1
	elif x <= -1.66e-87:
		tmp = 2.0
	elif x <= -2.2e-172:
		tmp = t_0
	elif x <= -1.22e-201:
		tmp = 2.0
	elif x <= -8.2e-297:
		tmp = t_0
	elif x <= 98000000000.0:
		tmp = 2.0
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(-4.0 * Float64(z / y)) + 1.0)
	t_1 = Float64(1.0 + Float64(Float64(x * 4.0) / y))
	tmp = 0.0
	if (x <= -7.6e+30)
		tmp = t_1;
	elseif (x <= -1.66e-87)
		tmp = 2.0;
	elseif (x <= -2.2e-172)
		tmp = t_0;
	elseif (x <= -1.22e-201)
		tmp = 2.0;
	elseif (x <= -8.2e-297)
		tmp = t_0;
	elseif (x <= 98000000000.0)
		tmp = 2.0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (-4.0 * (z / y)) + 1.0;
	t_1 = 1.0 + ((x * 4.0) / y);
	tmp = 0.0;
	if (x <= -7.6e+30)
		tmp = t_1;
	elseif (x <= -1.66e-87)
		tmp = 2.0;
	elseif (x <= -2.2e-172)
		tmp = t_0;
	elseif (x <= -1.22e-201)
		tmp = 2.0;
	elseif (x <= -8.2e-297)
		tmp = t_0;
	elseif (x <= 98000000000.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[(z / y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(N[(x * 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -7.6e+30], t$95$1, If[LessEqual[x, -1.66e-87], 2.0, If[LessEqual[x, -2.2e-172], t$95$0, If[LessEqual[x, -1.22e-201], 2.0, If[LessEqual[x, -8.2e-297], t$95$0, If[LessEqual[x, 98000000000.0], 2.0, t$95$1]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := -4 \cdot \frac{z}{y} + 1\\
t_1 := 1 + \frac{x \cdot 4}{y}\\
\mathbf{if}\;x \leq -7.6 \cdot 10^{+30}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq -1.66 \cdot 10^{-87}:\\
\;\;\;\;2\\

\mathbf{elif}\;x \leq -2.2 \cdot 10^{-172}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq -1.22 \cdot 10^{-201}:\\
\;\;\;\;2\\

\mathbf{elif}\;x \leq -8.2 \cdot 10^{-297}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 98000000000:\\
\;\;\;\;2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -7.6000000000000003e30 or 9.8e10 < x

    1. Initial program 100.0%

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

      \[\leadsto 1 + \color{blue}{4 \cdot \frac{x}{y}} \]
    4. Step-by-step derivation
      1. *-commutative69.1%

        \[\leadsto 1 + \color{blue}{\frac{x}{y} \cdot 4} \]
      2. associate-*l/69.1%

        \[\leadsto 1 + \color{blue}{\frac{x \cdot 4}{y}} \]
    5. Simplified69.1%

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

    if -7.6000000000000003e30 < x < -1.66e-87 or -2.20000000000000009e-172 < x < -1.22000000000000009e-201 or -8.2000000000000004e-297 < x < 9.8e10

    1. Initial program 100.0%

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

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

    if -1.66e-87 < x < -2.20000000000000009e-172 or -1.22000000000000009e-201 < x < -8.2000000000000004e-297

    1. Initial program 100.0%

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

      \[\leadsto 1 + \color{blue}{-4 \cdot \frac{z}{y}} \]
    4. Step-by-step derivation
      1. *-commutative71.1%

        \[\leadsto 1 + \color{blue}{\frac{z}{y} \cdot -4} \]
    5. Simplified71.1%

      \[\leadsto 1 + \color{blue}{\frac{z}{y} \cdot -4} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification67.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7.6 \cdot 10^{+30}:\\ \;\;\;\;1 + \frac{x \cdot 4}{y}\\ \mathbf{elif}\;x \leq -1.66 \cdot 10^{-87}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq -2.2 \cdot 10^{-172}:\\ \;\;\;\;-4 \cdot \frac{z}{y} + 1\\ \mathbf{elif}\;x \leq -1.22 \cdot 10^{-201}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq -8.2 \cdot 10^{-297}:\\ \;\;\;\;-4 \cdot \frac{z}{y} + 1\\ \mathbf{elif}\;x \leq 98000000000:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{x \cdot 4}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 55.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -4 \cdot \frac{z}{y} + 1\\ t_1 := 1 + x \cdot \frac{4}{y}\\ \mathbf{if}\;x \leq -2.4 \cdot 10^{+31}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq -1.9 \cdot 10^{-87}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq -9.5 \cdot 10^{-173}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -1.25 \cdot 10^{-200}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq -3.1 \cdot 10^{-293}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 85000000000:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ (* -4.0 (/ z y)) 1.0)) (t_1 (+ 1.0 (* x (/ 4.0 y)))))
   (if (<= x -2.4e+31)
     t_1
     (if (<= x -1.9e-87)
       2.0
       (if (<= x -9.5e-173)
         t_0
         (if (<= x -1.25e-200)
           2.0
           (if (<= x -3.1e-293) t_0 (if (<= x 85000000000.0) 2.0 t_1))))))))
double code(double x, double y, double z) {
	double t_0 = (-4.0 * (z / y)) + 1.0;
	double t_1 = 1.0 + (x * (4.0 / y));
	double tmp;
	if (x <= -2.4e+31) {
		tmp = t_1;
	} else if (x <= -1.9e-87) {
		tmp = 2.0;
	} else if (x <= -9.5e-173) {
		tmp = t_0;
	} else if (x <= -1.25e-200) {
		tmp = 2.0;
	} else if (x <= -3.1e-293) {
		tmp = t_0;
	} else if (x <= 85000000000.0) {
		tmp = 2.0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, y, z)
    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) * (z / y)) + 1.0d0
    t_1 = 1.0d0 + (x * (4.0d0 / y))
    if (x <= (-2.4d+31)) then
        tmp = t_1
    else if (x <= (-1.9d-87)) then
        tmp = 2.0d0
    else if (x <= (-9.5d-173)) then
        tmp = t_0
    else if (x <= (-1.25d-200)) then
        tmp = 2.0d0
    else if (x <= (-3.1d-293)) then
        tmp = t_0
    else if (x <= 85000000000.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 * (z / y)) + 1.0;
	double t_1 = 1.0 + (x * (4.0 / y));
	double tmp;
	if (x <= -2.4e+31) {
		tmp = t_1;
	} else if (x <= -1.9e-87) {
		tmp = 2.0;
	} else if (x <= -9.5e-173) {
		tmp = t_0;
	} else if (x <= -1.25e-200) {
		tmp = 2.0;
	} else if (x <= -3.1e-293) {
		tmp = t_0;
	} else if (x <= 85000000000.0) {
		tmp = 2.0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (-4.0 * (z / y)) + 1.0
	t_1 = 1.0 + (x * (4.0 / y))
	tmp = 0
	if x <= -2.4e+31:
		tmp = t_1
	elif x <= -1.9e-87:
		tmp = 2.0
	elif x <= -9.5e-173:
		tmp = t_0
	elif x <= -1.25e-200:
		tmp = 2.0
	elif x <= -3.1e-293:
		tmp = t_0
	elif x <= 85000000000.0:
		tmp = 2.0
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(-4.0 * Float64(z / y)) + 1.0)
	t_1 = Float64(1.0 + Float64(x * Float64(4.0 / y)))
	tmp = 0.0
	if (x <= -2.4e+31)
		tmp = t_1;
	elseif (x <= -1.9e-87)
		tmp = 2.0;
	elseif (x <= -9.5e-173)
		tmp = t_0;
	elseif (x <= -1.25e-200)
		tmp = 2.0;
	elseif (x <= -3.1e-293)
		tmp = t_0;
	elseif (x <= 85000000000.0)
		tmp = 2.0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (-4.0 * (z / y)) + 1.0;
	t_1 = 1.0 + (x * (4.0 / y));
	tmp = 0.0;
	if (x <= -2.4e+31)
		tmp = t_1;
	elseif (x <= -1.9e-87)
		tmp = 2.0;
	elseif (x <= -9.5e-173)
		tmp = t_0;
	elseif (x <= -1.25e-200)
		tmp = 2.0;
	elseif (x <= -3.1e-293)
		tmp = t_0;
	elseif (x <= 85000000000.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[(z / y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.4e+31], t$95$1, If[LessEqual[x, -1.9e-87], 2.0, If[LessEqual[x, -9.5e-173], t$95$0, If[LessEqual[x, -1.25e-200], 2.0, If[LessEqual[x, -3.1e-293], t$95$0, If[LessEqual[x, 85000000000.0], 2.0, t$95$1]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := -4 \cdot \frac{z}{y} + 1\\
t_1 := 1 + x \cdot \frac{4}{y}\\
\mathbf{if}\;x \leq -2.4 \cdot 10^{+31}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq -1.9 \cdot 10^{-87}:\\
\;\;\;\;2\\

\mathbf{elif}\;x \leq -9.5 \cdot 10^{-173}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq -1.25 \cdot 10^{-200}:\\
\;\;\;\;2\\

\mathbf{elif}\;x \leq -3.1 \cdot 10^{-293}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 85000000000:\\
\;\;\;\;2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.39999999999999982e31 or 8.5e10 < x

    1. Initial program 100.0%

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

      \[\leadsto 1 + \color{blue}{4 \cdot \frac{x}{y}} \]
    4. Step-by-step derivation
      1. associate-*r/69.1%

        \[\leadsto 1 + \color{blue}{\frac{4 \cdot x}{y}} \]
      2. associate-*l/68.9%

        \[\leadsto 1 + \color{blue}{\frac{4}{y} \cdot x} \]
      3. *-commutative68.9%

        \[\leadsto 1 + \color{blue}{x \cdot \frac{4}{y}} \]
    5. Simplified68.9%

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

    if -2.39999999999999982e31 < x < -1.9e-87 or -9.49999999999999967e-173 < x < -1.24999999999999998e-200 or -3.09999999999999983e-293 < x < 8.5e10

    1. Initial program 100.0%

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

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

    if -1.9e-87 < x < -9.49999999999999967e-173 or -1.24999999999999998e-200 < x < -3.09999999999999983e-293

    1. Initial program 100.0%

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

      \[\leadsto 1 + \color{blue}{-4 \cdot \frac{z}{y}} \]
    4. Step-by-step derivation
      1. *-commutative71.1%

        \[\leadsto 1 + \color{blue}{\frac{z}{y} \cdot -4} \]
    5. Simplified71.1%

      \[\leadsto 1 + \color{blue}{\frac{z}{y} \cdot -4} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification67.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.4 \cdot 10^{+31}:\\ \;\;\;\;1 + x \cdot \frac{4}{y}\\ \mathbf{elif}\;x \leq -1.9 \cdot 10^{-87}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq -9.5 \cdot 10^{-173}:\\ \;\;\;\;-4 \cdot \frac{z}{y} + 1\\ \mathbf{elif}\;x \leq -1.25 \cdot 10^{-200}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq -3.1 \cdot 10^{-293}:\\ \;\;\;\;-4 \cdot \frac{z}{y} + 1\\ \mathbf{elif}\;x \leq 85000000000:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;1 + x \cdot \frac{4}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 55.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + x \cdot \frac{4}{y}\\ \mathbf{if}\;x \leq -6 \cdot 10^{+31}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -1.8 \cdot 10^{-201}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq -4.8 \cdot 10^{-294}:\\ \;\;\;\;-4 \cdot \frac{z}{y}\\ \mathbf{elif}\;x \leq 225000000000:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ 1.0 (* x (/ 4.0 y)))))
   (if (<= x -6e+31)
     t_0
     (if (<= x -1.8e-201)
       2.0
       (if (<= x -4.8e-294)
         (* -4.0 (/ z y))
         (if (<= x 225000000000.0) 2.0 t_0))))))
double code(double x, double y, double z) {
	double t_0 = 1.0 + (x * (4.0 / y));
	double tmp;
	if (x <= -6e+31) {
		tmp = t_0;
	} else if (x <= -1.8e-201) {
		tmp = 2.0;
	} else if (x <= -4.8e-294) {
		tmp = -4.0 * (z / y);
	} else if (x <= 225000000000.0) {
		tmp = 2.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 + (x * (4.0d0 / y))
    if (x <= (-6d+31)) then
        tmp = t_0
    else if (x <= (-1.8d-201)) then
        tmp = 2.0d0
    else if (x <= (-4.8d-294)) then
        tmp = (-4.0d0) * (z / y)
    else if (x <= 225000000000.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 = 1.0 + (x * (4.0 / y));
	double tmp;
	if (x <= -6e+31) {
		tmp = t_0;
	} else if (x <= -1.8e-201) {
		tmp = 2.0;
	} else if (x <= -4.8e-294) {
		tmp = -4.0 * (z / y);
	} else if (x <= 225000000000.0) {
		tmp = 2.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 1.0 + (x * (4.0 / y))
	tmp = 0
	if x <= -6e+31:
		tmp = t_0
	elif x <= -1.8e-201:
		tmp = 2.0
	elif x <= -4.8e-294:
		tmp = -4.0 * (z / y)
	elif x <= 225000000000.0:
		tmp = 2.0
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(1.0 + Float64(x * Float64(4.0 / y)))
	tmp = 0.0
	if (x <= -6e+31)
		tmp = t_0;
	elseif (x <= -1.8e-201)
		tmp = 2.0;
	elseif (x <= -4.8e-294)
		tmp = Float64(-4.0 * Float64(z / y));
	elseif (x <= 225000000000.0)
		tmp = 2.0;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 1.0 + (x * (4.0 / y));
	tmp = 0.0;
	if (x <= -6e+31)
		tmp = t_0;
	elseif (x <= -1.8e-201)
		tmp = 2.0;
	elseif (x <= -4.8e-294)
		tmp = -4.0 * (z / y);
	elseif (x <= 225000000000.0)
		tmp = 2.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -6e+31], t$95$0, If[LessEqual[x, -1.8e-201], 2.0, If[LessEqual[x, -4.8e-294], N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 225000000000.0], 2.0, t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 1 + x \cdot \frac{4}{y}\\
\mathbf{if}\;x \leq -6 \cdot 10^{+31}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq -1.8 \cdot 10^{-201}:\\
\;\;\;\;2\\

\mathbf{elif}\;x \leq -4.8 \cdot 10^{-294}:\\
\;\;\;\;-4 \cdot \frac{z}{y}\\

\mathbf{elif}\;x \leq 225000000000:\\
\;\;\;\;2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -5.99999999999999978e31 or 2.25e11 < x

    1. Initial program 100.0%

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

      \[\leadsto 1 + \color{blue}{4 \cdot \frac{x}{y}} \]
    4. Step-by-step derivation
      1. associate-*r/69.1%

        \[\leadsto 1 + \color{blue}{\frac{4 \cdot x}{y}} \]
      2. associate-*l/68.9%

        \[\leadsto 1 + \color{blue}{\frac{4}{y} \cdot x} \]
      3. *-commutative68.9%

        \[\leadsto 1 + \color{blue}{x \cdot \frac{4}{y}} \]
    5. Simplified68.9%

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

    if -5.99999999999999978e31 < x < -1.80000000000000016e-201 or -4.79999999999999994e-294 < x < 2.25e11

    1. Initial program 100.0%

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

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

    if -1.80000000000000016e-201 < x < -4.79999999999999994e-294

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{\frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} + 1} \]
      2. associate-*l/99.8%

        \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(\left(x + y \cdot 0.25\right) - z\right)} + 1 \]
      3. +-commutative99.8%

        \[\leadsto \frac{4}{y} \cdot \left(\color{blue}{\left(y \cdot 0.25 + x\right)} - z\right) + 1 \]
      4. associate--l+99.8%

        \[\leadsto \frac{4}{y} \cdot \color{blue}{\left(y \cdot 0.25 + \left(x - z\right)\right)} + 1 \]
      5. +-commutative99.8%

        \[\leadsto \frac{4}{y} \cdot \color{blue}{\left(\left(x - z\right) + y \cdot 0.25\right)} + 1 \]
      6. distribute-lft-in99.8%

        \[\leadsto \color{blue}{\left(\frac{4}{y} \cdot \left(x - z\right) + \frac{4}{y} \cdot \left(y \cdot 0.25\right)\right)} + 1 \]
      7. associate-+l+99.8%

        \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(x - z\right) + \left(\frac{4}{y} \cdot \left(y \cdot 0.25\right) + 1\right)} \]
      8. associate-*l/99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\color{blue}{\frac{4 \cdot \left(y \cdot 0.25\right)}{y}} + 1\right) \]
      9. *-commutative99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{\left(y \cdot 0.25\right) \cdot 4}}{y} + 1\right) \]
      10. associate-*l*99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{y \cdot \left(0.25 \cdot 4\right)}}{y} + 1\right) \]
      11. metadata-eval99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{y \cdot \color{blue}{1}}{y} + 1\right) \]
      12. *-rgt-identity99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{y}}{y} + 1\right) \]
      13. *-inverses99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\color{blue}{1} + 1\right) \]
      14. metadata-eval99.8%

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

      \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(x - z\right) + 2} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num99.8%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{4}}} \cdot \left(x - z\right) + 2 \]
      2. div-inv99.8%

        \[\leadsto \frac{1}{\color{blue}{y \cdot \frac{1}{4}}} \cdot \left(x - z\right) + 2 \]
      3. metadata-eval99.8%

        \[\leadsto \frac{1}{y \cdot \color{blue}{0.25}} \cdot \left(x - z\right) + 2 \]
      4. associate-*l/99.9%

        \[\leadsto \color{blue}{\frac{1 \cdot \left(x - z\right)}{y \cdot 0.25}} + 2 \]
      5. *-un-lft-identity99.9%

        \[\leadsto \frac{\color{blue}{x - z}}{y \cdot 0.25} + 2 \]
    6. Applied egg-rr99.9%

      \[\leadsto \color{blue}{\frac{x - z}{y \cdot 0.25}} + 2 \]
    7. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{-4 \cdot \frac{z}{y}} + 2 \]
    8. Taylor expanded in z around inf 70.0%

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

Alternative 5: 53.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 4 \cdot \frac{x}{y}\\ \mathbf{if}\;x \leq -5.5 \cdot 10^{+31}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -1.1 \cdot 10^{-200}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq -1.4 \cdot 10^{-290}:\\ \;\;\;\;-4 \cdot \frac{z}{y}\\ \mathbf{elif}\;x \leq 140000000:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* 4.0 (/ x y))))
   (if (<= x -5.5e+31)
     t_0
     (if (<= x -1.1e-200)
       2.0
       (if (<= x -1.4e-290)
         (* -4.0 (/ z y))
         (if (<= x 140000000.0) 2.0 t_0))))))
double code(double x, double y, double z) {
	double t_0 = 4.0 * (x / y);
	double tmp;
	if (x <= -5.5e+31) {
		tmp = t_0;
	} else if (x <= -1.1e-200) {
		tmp = 2.0;
	} else if (x <= -1.4e-290) {
		tmp = -4.0 * (z / y);
	} else if (x <= 140000000.0) {
		tmp = 2.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 4.0d0 * (x / y)
    if (x <= (-5.5d+31)) then
        tmp = t_0
    else if (x <= (-1.1d-200)) then
        tmp = 2.0d0
    else if (x <= (-1.4d-290)) then
        tmp = (-4.0d0) * (z / y)
    else if (x <= 140000000.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 * (x / y);
	double tmp;
	if (x <= -5.5e+31) {
		tmp = t_0;
	} else if (x <= -1.1e-200) {
		tmp = 2.0;
	} else if (x <= -1.4e-290) {
		tmp = -4.0 * (z / y);
	} else if (x <= 140000000.0) {
		tmp = 2.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 4.0 * (x / y)
	tmp = 0
	if x <= -5.5e+31:
		tmp = t_0
	elif x <= -1.1e-200:
		tmp = 2.0
	elif x <= -1.4e-290:
		tmp = -4.0 * (z / y)
	elif x <= 140000000.0:
		tmp = 2.0
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(4.0 * Float64(x / y))
	tmp = 0.0
	if (x <= -5.5e+31)
		tmp = t_0;
	elseif (x <= -1.1e-200)
		tmp = 2.0;
	elseif (x <= -1.4e-290)
		tmp = Float64(-4.0 * Float64(z / y));
	elseif (x <= 140000000.0)
		tmp = 2.0;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 4.0 * (x / y);
	tmp = 0.0;
	if (x <= -5.5e+31)
		tmp = t_0;
	elseif (x <= -1.1e-200)
		tmp = 2.0;
	elseif (x <= -1.4e-290)
		tmp = -4.0 * (z / y);
	elseif (x <= 140000000.0)
		tmp = 2.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -5.5e+31], t$95$0, If[LessEqual[x, -1.1e-200], 2.0, If[LessEqual[x, -1.4e-290], N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 140000000.0], 2.0, t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{y}\\
\mathbf{if}\;x \leq -5.5 \cdot 10^{+31}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq -1.1 \cdot 10^{-200}:\\
\;\;\;\;2\\

\mathbf{elif}\;x \leq -1.4 \cdot 10^{-290}:\\
\;\;\;\;-4 \cdot \frac{z}{y}\\

\mathbf{elif}\;x \leq 140000000:\\
\;\;\;\;2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -5.50000000000000002e31 or 1.4e8 < x

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{\frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} + 1} \]
      2. associate-*l/99.7%

        \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(\left(x + y \cdot 0.25\right) - z\right)} + 1 \]
      3. +-commutative99.7%

        \[\leadsto \frac{4}{y} \cdot \left(\color{blue}{\left(y \cdot 0.25 + x\right)} - z\right) + 1 \]
      4. associate--l+99.7%

        \[\leadsto \frac{4}{y} \cdot \color{blue}{\left(y \cdot 0.25 + \left(x - z\right)\right)} + 1 \]
      5. +-commutative99.7%

        \[\leadsto \frac{4}{y} \cdot \color{blue}{\left(\left(x - z\right) + y \cdot 0.25\right)} + 1 \]
      6. distribute-lft-in99.7%

        \[\leadsto \color{blue}{\left(\frac{4}{y} \cdot \left(x - z\right) + \frac{4}{y} \cdot \left(y \cdot 0.25\right)\right)} + 1 \]
      7. associate-+l+99.7%

        \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(x - z\right) + \left(\frac{4}{y} \cdot \left(y \cdot 0.25\right) + 1\right)} \]
      8. associate-*l/99.7%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\color{blue}{\frac{4 \cdot \left(y \cdot 0.25\right)}{y}} + 1\right) \]
      9. *-commutative99.7%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{\left(y \cdot 0.25\right) \cdot 4}}{y} + 1\right) \]
      10. associate-*l*99.7%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{y \cdot \left(0.25 \cdot 4\right)}}{y} + 1\right) \]
      11. metadata-eval99.7%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{y \cdot \color{blue}{1}}{y} + 1\right) \]
      12. *-rgt-identity99.7%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{y}}{y} + 1\right) \]
      13. *-inverses99.7%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\color{blue}{1} + 1\right) \]
      14. metadata-eval99.7%

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

      \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(x - z\right) + 2} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num99.7%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{4}}} \cdot \left(x - z\right) + 2 \]
      2. div-inv99.7%

        \[\leadsto \frac{1}{\color{blue}{y \cdot \frac{1}{4}}} \cdot \left(x - z\right) + 2 \]
      3. metadata-eval99.7%

        \[\leadsto \frac{1}{y \cdot \color{blue}{0.25}} \cdot \left(x - z\right) + 2 \]
      4. associate-*l/100.0%

        \[\leadsto \color{blue}{\frac{1 \cdot \left(x - z\right)}{y \cdot 0.25}} + 2 \]
      5. *-un-lft-identity100.0%

        \[\leadsto \frac{\color{blue}{x - z}}{y \cdot 0.25} + 2 \]
    6. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\frac{x - z}{y \cdot 0.25}} + 2 \]
    7. Taylor expanded in x around inf 84.5%

      \[\leadsto \color{blue}{4 \cdot \frac{x}{y}} + 2 \]
    8. Taylor expanded in x around inf 66.7%

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

    if -5.50000000000000002e31 < x < -1.10000000000000007e-200 or -1.39999999999999998e-290 < x < 1.4e8

    1. Initial program 100.0%

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

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

    if -1.10000000000000007e-200 < x < -1.39999999999999998e-290

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{\frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} + 1} \]
      2. associate-*l/99.8%

        \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(\left(x + y \cdot 0.25\right) - z\right)} + 1 \]
      3. +-commutative99.8%

        \[\leadsto \frac{4}{y} \cdot \left(\color{blue}{\left(y \cdot 0.25 + x\right)} - z\right) + 1 \]
      4. associate--l+99.8%

        \[\leadsto \frac{4}{y} \cdot \color{blue}{\left(y \cdot 0.25 + \left(x - z\right)\right)} + 1 \]
      5. +-commutative99.8%

        \[\leadsto \frac{4}{y} \cdot \color{blue}{\left(\left(x - z\right) + y \cdot 0.25\right)} + 1 \]
      6. distribute-lft-in99.8%

        \[\leadsto \color{blue}{\left(\frac{4}{y} \cdot \left(x - z\right) + \frac{4}{y} \cdot \left(y \cdot 0.25\right)\right)} + 1 \]
      7. associate-+l+99.8%

        \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(x - z\right) + \left(\frac{4}{y} \cdot \left(y \cdot 0.25\right) + 1\right)} \]
      8. associate-*l/99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\color{blue}{\frac{4 \cdot \left(y \cdot 0.25\right)}{y}} + 1\right) \]
      9. *-commutative99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{\left(y \cdot 0.25\right) \cdot 4}}{y} + 1\right) \]
      10. associate-*l*99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{y \cdot \left(0.25 \cdot 4\right)}}{y} + 1\right) \]
      11. metadata-eval99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{y \cdot \color{blue}{1}}{y} + 1\right) \]
      12. *-rgt-identity99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{y}}{y} + 1\right) \]
      13. *-inverses99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\color{blue}{1} + 1\right) \]
      14. metadata-eval99.8%

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

      \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(x - z\right) + 2} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num99.8%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{4}}} \cdot \left(x - z\right) + 2 \]
      2. div-inv99.8%

        \[\leadsto \frac{1}{\color{blue}{y \cdot \frac{1}{4}}} \cdot \left(x - z\right) + 2 \]
      3. metadata-eval99.8%

        \[\leadsto \frac{1}{y \cdot \color{blue}{0.25}} \cdot \left(x - z\right) + 2 \]
      4. associate-*l/99.9%

        \[\leadsto \color{blue}{\frac{1 \cdot \left(x - z\right)}{y \cdot 0.25}} + 2 \]
      5. *-un-lft-identity99.9%

        \[\leadsto \frac{\color{blue}{x - z}}{y \cdot 0.25} + 2 \]
    6. Applied egg-rr99.9%

      \[\leadsto \color{blue}{\frac{x - z}{y \cdot 0.25}} + 2 \]
    7. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{-4 \cdot \frac{z}{y}} + 2 \]
    8. Taylor expanded in z around inf 70.0%

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

Alternative 6: 85.5% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{-46} \lor \neg \left(x \leq 9.5\right):\\ \;\;\;\;2 + 4 \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;2 + -4 \cdot \frac{z}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -1.6e-46) (not (<= x 9.5)))
   (+ 2.0 (* 4.0 (/ x y)))
   (+ 2.0 (* -4.0 (/ z y)))))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -1.6e-46) || !(x <= 9.5)) {
		tmp = 2.0 + (4.0 * (x / y));
	} else {
		tmp = 2.0 + (-4.0 * (z / y));
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((x <= (-1.6d-46)) .or. (.not. (x <= 9.5d0))) then
        tmp = 2.0d0 + (4.0d0 * (x / y))
    else
        tmp = 2.0d0 + ((-4.0d0) * (z / y))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((x <= -1.6e-46) || !(x <= 9.5)) {
		tmp = 2.0 + (4.0 * (x / y));
	} else {
		tmp = 2.0 + (-4.0 * (z / y));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x <= -1.6e-46) or not (x <= 9.5):
		tmp = 2.0 + (4.0 * (x / y))
	else:
		tmp = 2.0 + (-4.0 * (z / y))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((x <= -1.6e-46) || !(x <= 9.5))
		tmp = Float64(2.0 + Float64(4.0 * Float64(x / y)));
	else
		tmp = Float64(2.0 + Float64(-4.0 * Float64(z / y)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= -1.6e-46) || ~((x <= 9.5)))
		tmp = 2.0 + (4.0 * (x / y));
	else
		tmp = 2.0 + (-4.0 * (z / y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.6e-46], N[Not[LessEqual[x, 9.5]], $MachinePrecision]], N[(2.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{-46} \lor \neg \left(x \leq 9.5\right):\\
\;\;\;\;2 + 4 \cdot \frac{x}{y}\\

\mathbf{else}:\\
\;\;\;\;2 + -4 \cdot \frac{z}{y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.6e-46 or 9.5 < x

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{\frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} + 1} \]
      2. associate-*l/99.7%

        \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(\left(x + y \cdot 0.25\right) - z\right)} + 1 \]
      3. +-commutative99.7%

        \[\leadsto \frac{4}{y} \cdot \left(\color{blue}{\left(y \cdot 0.25 + x\right)} - z\right) + 1 \]
      4. associate--l+99.7%

        \[\leadsto \frac{4}{y} \cdot \color{blue}{\left(y \cdot 0.25 + \left(x - z\right)\right)} + 1 \]
      5. +-commutative99.7%

        \[\leadsto \frac{4}{y} \cdot \color{blue}{\left(\left(x - z\right) + y \cdot 0.25\right)} + 1 \]
      6. distribute-lft-in99.7%

        \[\leadsto \color{blue}{\left(\frac{4}{y} \cdot \left(x - z\right) + \frac{4}{y} \cdot \left(y \cdot 0.25\right)\right)} + 1 \]
      7. associate-+l+99.8%

        \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(x - z\right) + \left(\frac{4}{y} \cdot \left(y \cdot 0.25\right) + 1\right)} \]
      8. associate-*l/99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\color{blue}{\frac{4 \cdot \left(y \cdot 0.25\right)}{y}} + 1\right) \]
      9. *-commutative99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{\left(y \cdot 0.25\right) \cdot 4}}{y} + 1\right) \]
      10. associate-*l*99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{y \cdot \left(0.25 \cdot 4\right)}}{y} + 1\right) \]
      11. metadata-eval99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{y \cdot \color{blue}{1}}{y} + 1\right) \]
      12. *-rgt-identity99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{y}}{y} + 1\right) \]
      13. *-inverses99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\color{blue}{1} + 1\right) \]
      14. metadata-eval99.8%

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

      \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(x - z\right) + 2} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num99.8%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{4}}} \cdot \left(x - z\right) + 2 \]
      2. div-inv99.8%

        \[\leadsto \frac{1}{\color{blue}{y \cdot \frac{1}{4}}} \cdot \left(x - z\right) + 2 \]
      3. metadata-eval99.8%

        \[\leadsto \frac{1}{y \cdot \color{blue}{0.25}} \cdot \left(x - z\right) + 2 \]
      4. associate-*l/100.0%

        \[\leadsto \color{blue}{\frac{1 \cdot \left(x - z\right)}{y \cdot 0.25}} + 2 \]
      5. *-un-lft-identity100.0%

        \[\leadsto \frac{\color{blue}{x - z}}{y \cdot 0.25} + 2 \]
    6. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\frac{x - z}{y \cdot 0.25}} + 2 \]
    7. Taylor expanded in x around inf 85.4%

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

    if -1.6e-46 < x < 9.5

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{\frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} + 1} \]
      2. associate-*l/99.8%

        \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(\left(x + y \cdot 0.25\right) - z\right)} + 1 \]
      3. +-commutative99.8%

        \[\leadsto \frac{4}{y} \cdot \left(\color{blue}{\left(y \cdot 0.25 + x\right)} - z\right) + 1 \]
      4. associate--l+99.8%

        \[\leadsto \frac{4}{y} \cdot \color{blue}{\left(y \cdot 0.25 + \left(x - z\right)\right)} + 1 \]
      5. +-commutative99.8%

        \[\leadsto \frac{4}{y} \cdot \color{blue}{\left(\left(x - z\right) + y \cdot 0.25\right)} + 1 \]
      6. distribute-lft-in99.8%

        \[\leadsto \color{blue}{\left(\frac{4}{y} \cdot \left(x - z\right) + \frac{4}{y} \cdot \left(y \cdot 0.25\right)\right)} + 1 \]
      7. associate-+l+99.8%

        \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(x - z\right) + \left(\frac{4}{y} \cdot \left(y \cdot 0.25\right) + 1\right)} \]
      8. associate-*l/99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\color{blue}{\frac{4 \cdot \left(y \cdot 0.25\right)}{y}} + 1\right) \]
      9. *-commutative99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{\left(y \cdot 0.25\right) \cdot 4}}{y} + 1\right) \]
      10. associate-*l*99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{y \cdot \left(0.25 \cdot 4\right)}}{y} + 1\right) \]
      11. metadata-eval99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{y \cdot \color{blue}{1}}{y} + 1\right) \]
      12. *-rgt-identity99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{y}}{y} + 1\right) \]
      13. *-inverses99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\color{blue}{1} + 1\right) \]
      14. metadata-eval99.8%

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

      \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(x - z\right) + 2} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num99.9%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{4}}} \cdot \left(x - z\right) + 2 \]
      2. div-inv99.9%

        \[\leadsto \frac{1}{\color{blue}{y \cdot \frac{1}{4}}} \cdot \left(x - z\right) + 2 \]
      3. metadata-eval99.9%

        \[\leadsto \frac{1}{y \cdot \color{blue}{0.25}} \cdot \left(x - z\right) + 2 \]
      4. associate-*l/100.0%

        \[\leadsto \color{blue}{\frac{1 \cdot \left(x - z\right)}{y \cdot 0.25}} + 2 \]
      5. *-un-lft-identity100.0%

        \[\leadsto \frac{\color{blue}{x - z}}{y \cdot 0.25} + 2 \]
    6. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\frac{x - z}{y \cdot 0.25}} + 2 \]
    7. Taylor expanded in x around 0 97.5%

      \[\leadsto \color{blue}{-4 \cdot \frac{z}{y}} + 2 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification91.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{-46} \lor \neg \left(x \leq 9.5\right):\\ \;\;\;\;2 + 4 \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;2 + -4 \cdot \frac{z}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 79.2% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -3.8 \cdot 10^{+32} \lor \neg \left(x \leq 145000000\right):\\ \;\;\;\;1 + \frac{x \cdot 4}{y}\\ \mathbf{else}:\\ \;\;\;\;2 + -4 \cdot \frac{z}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -3.8e+32) (not (<= x 145000000.0)))
   (+ 1.0 (/ (* x 4.0) y))
   (+ 2.0 (* -4.0 (/ z y)))))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -3.8e+32) || !(x <= 145000000.0)) {
		tmp = 1.0 + ((x * 4.0) / y);
	} else {
		tmp = 2.0 + (-4.0 * (z / y));
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((x <= (-3.8d+32)) .or. (.not. (x <= 145000000.0d0))) then
        tmp = 1.0d0 + ((x * 4.0d0) / y)
    else
        tmp = 2.0d0 + ((-4.0d0) * (z / y))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((x <= -3.8e+32) || !(x <= 145000000.0)) {
		tmp = 1.0 + ((x * 4.0) / y);
	} else {
		tmp = 2.0 + (-4.0 * (z / y));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x <= -3.8e+32) or not (x <= 145000000.0):
		tmp = 1.0 + ((x * 4.0) / y)
	else:
		tmp = 2.0 + (-4.0 * (z / y))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((x <= -3.8e+32) || !(x <= 145000000.0))
		tmp = Float64(1.0 + Float64(Float64(x * 4.0) / y));
	else
		tmp = Float64(2.0 + Float64(-4.0 * Float64(z / y)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= -3.8e+32) || ~((x <= 145000000.0)))
		tmp = 1.0 + ((x * 4.0) / y);
	else
		tmp = 2.0 + (-4.0 * (z / y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.8e+32], N[Not[LessEqual[x, 145000000.0]], $MachinePrecision]], N[(1.0 + N[(N[(x * 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.8 \cdot 10^{+32} \lor \neg \left(x \leq 145000000\right):\\
\;\;\;\;1 + \frac{x \cdot 4}{y}\\

\mathbf{else}:\\
\;\;\;\;2 + -4 \cdot \frac{z}{y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.8000000000000003e32 or 1.45e8 < x

    1. Initial program 100.0%

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

      \[\leadsto 1 + \color{blue}{4 \cdot \frac{x}{y}} \]
    4. Step-by-step derivation
      1. *-commutative69.1%

        \[\leadsto 1 + \color{blue}{\frac{x}{y} \cdot 4} \]
      2. associate-*l/69.1%

        \[\leadsto 1 + \color{blue}{\frac{x \cdot 4}{y}} \]
    5. Simplified69.1%

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

    if -3.8000000000000003e32 < x < 1.45e8

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{\frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} + 1} \]
      2. associate-*l/99.8%

        \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(\left(x + y \cdot 0.25\right) - z\right)} + 1 \]
      3. +-commutative99.8%

        \[\leadsto \frac{4}{y} \cdot \left(\color{blue}{\left(y \cdot 0.25 + x\right)} - z\right) + 1 \]
      4. associate--l+99.8%

        \[\leadsto \frac{4}{y} \cdot \color{blue}{\left(y \cdot 0.25 + \left(x - z\right)\right)} + 1 \]
      5. +-commutative99.8%

        \[\leadsto \frac{4}{y} \cdot \color{blue}{\left(\left(x - z\right) + y \cdot 0.25\right)} + 1 \]
      6. distribute-lft-in99.8%

        \[\leadsto \color{blue}{\left(\frac{4}{y} \cdot \left(x - z\right) + \frac{4}{y} \cdot \left(y \cdot 0.25\right)\right)} + 1 \]
      7. associate-+l+99.9%

        \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(x - z\right) + \left(\frac{4}{y} \cdot \left(y \cdot 0.25\right) + 1\right)} \]
      8. associate-*l/99.9%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\color{blue}{\frac{4 \cdot \left(y \cdot 0.25\right)}{y}} + 1\right) \]
      9. *-commutative99.9%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{\left(y \cdot 0.25\right) \cdot 4}}{y} + 1\right) \]
      10. associate-*l*99.9%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{y \cdot \left(0.25 \cdot 4\right)}}{y} + 1\right) \]
      11. metadata-eval99.9%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{y \cdot \color{blue}{1}}{y} + 1\right) \]
      12. *-rgt-identity99.9%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{y}}{y} + 1\right) \]
      13. *-inverses99.9%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\color{blue}{1} + 1\right) \]
      14. metadata-eval99.9%

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

      \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(x - z\right) + 2} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num99.9%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{4}}} \cdot \left(x - z\right) + 2 \]
      2. div-inv99.9%

        \[\leadsto \frac{1}{\color{blue}{y \cdot \frac{1}{4}}} \cdot \left(x - z\right) + 2 \]
      3. metadata-eval99.9%

        \[\leadsto \frac{1}{y \cdot \color{blue}{0.25}} \cdot \left(x - z\right) + 2 \]
      4. associate-*l/100.0%

        \[\leadsto \color{blue}{\frac{1 \cdot \left(x - z\right)}{y \cdot 0.25}} + 2 \]
      5. *-un-lft-identity100.0%

        \[\leadsto \frac{\color{blue}{x - z}}{y \cdot 0.25} + 2 \]
    6. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\frac{x - z}{y \cdot 0.25}} + 2 \]
    7. Taylor expanded in x around 0 94.5%

      \[\leadsto \color{blue}{-4 \cdot \frac{z}{y}} + 2 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification82.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.8 \cdot 10^{+32} \lor \neg \left(x \leq 145000000\right):\\ \;\;\;\;1 + \frac{x \cdot 4}{y}\\ \mathbf{else}:\\ \;\;\;\;2 + -4 \cdot \frac{z}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 54.5% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.35 \cdot 10^{+61} \lor \neg \left(z \leq 3.5 \cdot 10^{+63}\right):\\ \;\;\;\;-4 \cdot \frac{z}{y}\\ \mathbf{else}:\\ \;\;\;\;2\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -1.35e+61) (not (<= z 3.5e+63))) (* -4.0 (/ z y)) 2.0))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.35e+61) || !(z <= 3.5e+63)) {
		tmp = -4.0 * (z / y);
	} else {
		tmp = 2.0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((z <= (-1.35d+61)) .or. (.not. (z <= 3.5d+63))) then
        tmp = (-4.0d0) * (z / y)
    else
        tmp = 2.0d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.35e+61) || !(z <= 3.5e+63)) {
		tmp = -4.0 * (z / y);
	} else {
		tmp = 2.0;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -1.35e+61) or not (z <= 3.5e+63):
		tmp = -4.0 * (z / y)
	else:
		tmp = 2.0
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -1.35e+61) || !(z <= 3.5e+63))
		tmp = Float64(-4.0 * Float64(z / y));
	else
		tmp = 2.0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -1.35e+61) || ~((z <= 3.5e+63)))
		tmp = -4.0 * (z / y);
	else
		tmp = 2.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.35e+61], N[Not[LessEqual[z, 3.5e+63]], $MachinePrecision]], N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision], 2.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.35 \cdot 10^{+61} \lor \neg \left(z \leq 3.5 \cdot 10^{+63}\right):\\
\;\;\;\;-4 \cdot \frac{z}{y}\\

\mathbf{else}:\\
\;\;\;\;2\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.3500000000000001e61 or 3.50000000000000029e63 < z

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{\frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} + 1} \]
      2. associate-*l/99.8%

        \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(\left(x + y \cdot 0.25\right) - z\right)} + 1 \]
      3. +-commutative99.8%

        \[\leadsto \frac{4}{y} \cdot \left(\color{blue}{\left(y \cdot 0.25 + x\right)} - z\right) + 1 \]
      4. associate--l+99.8%

        \[\leadsto \frac{4}{y} \cdot \color{blue}{\left(y \cdot 0.25 + \left(x - z\right)\right)} + 1 \]
      5. +-commutative99.8%

        \[\leadsto \frac{4}{y} \cdot \color{blue}{\left(\left(x - z\right) + y \cdot 0.25\right)} + 1 \]
      6. distribute-lft-in99.8%

        \[\leadsto \color{blue}{\left(\frac{4}{y} \cdot \left(x - z\right) + \frac{4}{y} \cdot \left(y \cdot 0.25\right)\right)} + 1 \]
      7. associate-+l+99.8%

        \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(x - z\right) + \left(\frac{4}{y} \cdot \left(y \cdot 0.25\right) + 1\right)} \]
      8. associate-*l/99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\color{blue}{\frac{4 \cdot \left(y \cdot 0.25\right)}{y}} + 1\right) \]
      9. *-commutative99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{\left(y \cdot 0.25\right) \cdot 4}}{y} + 1\right) \]
      10. associate-*l*99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{y \cdot \left(0.25 \cdot 4\right)}}{y} + 1\right) \]
      11. metadata-eval99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{y \cdot \color{blue}{1}}{y} + 1\right) \]
      12. *-rgt-identity99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{y}}{y} + 1\right) \]
      13. *-inverses99.8%

        \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\color{blue}{1} + 1\right) \]
      14. metadata-eval99.8%

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

      \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(x - z\right) + 2} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num99.8%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{4}}} \cdot \left(x - z\right) + 2 \]
      2. div-inv99.8%

        \[\leadsto \frac{1}{\color{blue}{y \cdot \frac{1}{4}}} \cdot \left(x - z\right) + 2 \]
      3. metadata-eval99.8%

        \[\leadsto \frac{1}{y \cdot \color{blue}{0.25}} \cdot \left(x - z\right) + 2 \]
      4. associate-*l/100.0%

        \[\leadsto \color{blue}{\frac{1 \cdot \left(x - z\right)}{y \cdot 0.25}} + 2 \]
      5. *-un-lft-identity100.0%

        \[\leadsto \frac{\color{blue}{x - z}}{y \cdot 0.25} + 2 \]
    6. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\frac{x - z}{y \cdot 0.25}} + 2 \]
    7. Taylor expanded in x around 0 84.5%

      \[\leadsto \color{blue}{-4 \cdot \frac{z}{y}} + 2 \]
    8. Taylor expanded in z around inf 64.4%

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

    if -1.3500000000000001e61 < z < 3.50000000000000029e63

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{2} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification55.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.35 \cdot 10^{+61} \lor \neg \left(z \leq 3.5 \cdot 10^{+63}\right):\\ \;\;\;\;-4 \cdot \frac{z}{y}\\ \mathbf{else}:\\ \;\;\;\;2\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 99.8% accurate, 1.4× speedup?

\[\begin{array}{l} \\ 2 + \left(x - z\right) \cdot \frac{4}{y} \end{array} \]
(FPCore (x y z) :precision binary64 (+ 2.0 (* (- x z) (/ 4.0 y))))
double code(double x, double y, double z) {
	return 2.0 + ((x - z) * (4.0 / y));
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = 2.0d0 + ((x - z) * (4.0d0 / y))
end function
public static double code(double x, double y, double z) {
	return 2.0 + ((x - z) * (4.0 / y));
}
def code(x, y, z):
	return 2.0 + ((x - z) * (4.0 / y))
function code(x, y, z)
	return Float64(2.0 + Float64(Float64(x - z) * Float64(4.0 / y)))
end
function tmp = code(x, y, z)
	tmp = 2.0 + ((x - z) * (4.0 / y));
end
code[x_, y_, z_] := N[(2.0 + N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
2 + \left(x - z\right) \cdot \frac{4}{y}
\end{array}
Derivation
  1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} + 1} \]
    2. associate-*l/99.8%

      \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(\left(x + y \cdot 0.25\right) - z\right)} + 1 \]
    3. +-commutative99.8%

      \[\leadsto \frac{4}{y} \cdot \left(\color{blue}{\left(y \cdot 0.25 + x\right)} - z\right) + 1 \]
    4. associate--l+99.8%

      \[\leadsto \frac{4}{y} \cdot \color{blue}{\left(y \cdot 0.25 + \left(x - z\right)\right)} + 1 \]
    5. +-commutative99.8%

      \[\leadsto \frac{4}{y} \cdot \color{blue}{\left(\left(x - z\right) + y \cdot 0.25\right)} + 1 \]
    6. distribute-lft-in99.8%

      \[\leadsto \color{blue}{\left(\frac{4}{y} \cdot \left(x - z\right) + \frac{4}{y} \cdot \left(y \cdot 0.25\right)\right)} + 1 \]
    7. associate-+l+99.8%

      \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(x - z\right) + \left(\frac{4}{y} \cdot \left(y \cdot 0.25\right) + 1\right)} \]
    8. associate-*l/99.8%

      \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\color{blue}{\frac{4 \cdot \left(y \cdot 0.25\right)}{y}} + 1\right) \]
    9. *-commutative99.8%

      \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{\left(y \cdot 0.25\right) \cdot 4}}{y} + 1\right) \]
    10. associate-*l*99.8%

      \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{y \cdot \left(0.25 \cdot 4\right)}}{y} + 1\right) \]
    11. metadata-eval99.8%

      \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{y \cdot \color{blue}{1}}{y} + 1\right) \]
    12. *-rgt-identity99.8%

      \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\frac{\color{blue}{y}}{y} + 1\right) \]
    13. *-inverses99.8%

      \[\leadsto \frac{4}{y} \cdot \left(x - z\right) + \left(\color{blue}{1} + 1\right) \]
    14. metadata-eval99.8%

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

    \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(x - z\right) + 2} \]
  4. Add Preprocessing
  5. Final simplification99.8%

    \[\leadsto 2 + \left(x - z\right) \cdot \frac{4}{y} \]
  6. Add Preprocessing

Alternative 10: 34.1% accurate, 13.0× speedup?

\[\begin{array}{l} \\ 2 \end{array} \]
(FPCore (x y z) :precision binary64 2.0)
double code(double x, double y, double z) {
	return 2.0;
}
real(8) function code(x, y, z)
    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
\begin{array}{l}

\\
2
\end{array}
Derivation
  1. Initial program 100.0%

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

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

Alternative 11: 8.1% accurate, 13.0× speedup?

\[\begin{array}{l} \\ 1 \end{array} \]
(FPCore (x y z) :precision binary64 1.0)
double code(double x, double y, double z) {
	return 1.0;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = 1.0d0
end function
public static double code(double x, double y, double z) {
	return 1.0;
}
def code(x, y, z):
	return 1.0
function code(x, y, z)
	return 1.0
end
function tmp = code(x, y, z)
	tmp = 1.0;
end
code[x_, y_, z_] := 1.0
\begin{array}{l}

\\
1
\end{array}
Derivation
  1. Initial program 100.0%

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

    \[\leadsto 1 + \color{blue}{4 \cdot \frac{x}{y}} \]
  4. Step-by-step derivation
    1. associate-*r/40.6%

      \[\leadsto 1 + \color{blue}{\frac{4 \cdot x}{y}} \]
    2. associate-*l/40.5%

      \[\leadsto 1 + \color{blue}{\frac{4}{y} \cdot x} \]
    3. *-commutative40.5%

      \[\leadsto 1 + \color{blue}{x \cdot \frac{4}{y}} \]
  5. Simplified40.5%

    \[\leadsto 1 + \color{blue}{x \cdot \frac{4}{y}} \]
  6. Taylor expanded in x around 0 8.8%

    \[\leadsto \color{blue}{1} \]
  7. Add Preprocessing

Reproduce

?
herbie shell --seed 2024089 
(FPCore (x y z)
  :name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, C"
  :precision binary64
  (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))