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

Percentage Accurate: 99.9% → 100.0%
Time: 3.4s
Alternatives: 8
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 8 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} \\ 2 + \frac{x - z}{y \cdot 0.25} \end{array} \]
(FPCore (x y z) :precision binary64 (+ 2.0 (/ (- x z) (* y 0.25))))
double code(double x, double y, double z) {
	return 2.0 + ((x - z) / (y * 0.25));
}
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) / (y * 0.25d0))
end function
public static double code(double x, double y, double z) {
	return 2.0 + ((x - z) / (y * 0.25));
}
def code(x, y, z):
	return 2.0 + ((x - z) / (y * 0.25))
function code(x, y, z)
	return Float64(2.0 + Float64(Float64(x - z) / Float64(y * 0.25)))
end
function tmp = code(x, y, z)
	tmp = 2.0 + ((x - z) / (y * 0.25));
end
code[x_, y_, z_] := N[(2.0 + N[(N[(x - z), $MachinePrecision] / N[(y * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} \]
  2. Step-by-step derivation
    1. associate-*l/99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(1 + \frac{\color{blue}{-1 \cdot \left(y \cdot 0.25\right)}}{\left(-y\right) \cdot 0.25}\right) + \frac{4}{y} \cdot \left(x - z\right) \]
    16. neg-mul-199.8%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 2 + \frac{x - z}{y \cdot 0.25} \]

Alternative 2: 55.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{z}{\frac{y}{-4}}\\ t_1 := 1 + 4 \cdot \frac{x}{y}\\ \mathbf{if}\;x \leq -27:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.75 \cdot 10^{-43}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.85 \cdot 10^{-244}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-301}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 7 \cdot 10^{-147}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq 20000000000000:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ z (/ y -4.0))) (t_1 (+ 1.0 (* 4.0 (/ x y)))))
   (if (<= x -27.0)
     t_1
     (if (<= x -1.75e-43)
       t_0
       (if (<= x -1.85e-244)
         2.0
         (if (<= x 1.45e-301)
           t_0
           (if (<= x 7e-147) 2.0 (if (<= x 20000000000000.0) t_0 t_1))))))))
double code(double x, double y, double z) {
	double t_0 = z / (y / -4.0);
	double t_1 = 1.0 + (4.0 * (x / y));
	double tmp;
	if (x <= -27.0) {
		tmp = t_1;
	} else if (x <= -1.75e-43) {
		tmp = t_0;
	} else if (x <= -1.85e-244) {
		tmp = 2.0;
	} else if (x <= 1.45e-301) {
		tmp = t_0;
	} else if (x <= 7e-147) {
		tmp = 2.0;
	} else if (x <= 20000000000000.0) {
		tmp = t_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 = z / (y / (-4.0d0))
    t_1 = 1.0d0 + (4.0d0 * (x / y))
    if (x <= (-27.0d0)) then
        tmp = t_1
    else if (x <= (-1.75d-43)) then
        tmp = t_0
    else if (x <= (-1.85d-244)) then
        tmp = 2.0d0
    else if (x <= 1.45d-301) then
        tmp = t_0
    else if (x <= 7d-147) then
        tmp = 2.0d0
    else if (x <= 20000000000000.0d0) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = z / (y / -4.0);
	double t_1 = 1.0 + (4.0 * (x / y));
	double tmp;
	if (x <= -27.0) {
		tmp = t_1;
	} else if (x <= -1.75e-43) {
		tmp = t_0;
	} else if (x <= -1.85e-244) {
		tmp = 2.0;
	} else if (x <= 1.45e-301) {
		tmp = t_0;
	} else if (x <= 7e-147) {
		tmp = 2.0;
	} else if (x <= 20000000000000.0) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = z / (y / -4.0)
	t_1 = 1.0 + (4.0 * (x / y))
	tmp = 0
	if x <= -27.0:
		tmp = t_1
	elif x <= -1.75e-43:
		tmp = t_0
	elif x <= -1.85e-244:
		tmp = 2.0
	elif x <= 1.45e-301:
		tmp = t_0
	elif x <= 7e-147:
		tmp = 2.0
	elif x <= 20000000000000.0:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(z / Float64(y / -4.0))
	t_1 = Float64(1.0 + Float64(4.0 * Float64(x / y)))
	tmp = 0.0
	if (x <= -27.0)
		tmp = t_1;
	elseif (x <= -1.75e-43)
		tmp = t_0;
	elseif (x <= -1.85e-244)
		tmp = 2.0;
	elseif (x <= 1.45e-301)
		tmp = t_0;
	elseif (x <= 7e-147)
		tmp = 2.0;
	elseif (x <= 20000000000000.0)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = z / (y / -4.0);
	t_1 = 1.0 + (4.0 * (x / y));
	tmp = 0.0;
	if (x <= -27.0)
		tmp = t_1;
	elseif (x <= -1.75e-43)
		tmp = t_0;
	elseif (x <= -1.85e-244)
		tmp = 2.0;
	elseif (x <= 1.45e-301)
		tmp = t_0;
	elseif (x <= 7e-147)
		tmp = 2.0;
	elseif (x <= 20000000000000.0)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(z / N[(y / -4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -27.0], t$95$1, If[LessEqual[x, -1.75e-43], t$95$0, If[LessEqual[x, -1.85e-244], 2.0, If[LessEqual[x, 1.45e-301], t$95$0, If[LessEqual[x, 7e-147], 2.0, If[LessEqual[x, 20000000000000.0], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{z}{\frac{y}{-4}}\\
t_1 := 1 + 4 \cdot \frac{x}{y}\\
\mathbf{if}\;x \leq -27:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -1.75 \cdot 10^{-43}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -1.85 \cdot 10^{-244}:\\
\;\;\;\;2\\

\mathbf{elif}\;x \leq 1.45 \cdot 10^{-301}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 7 \cdot 10^{-147}:\\
\;\;\;\;2\\

\mathbf{elif}\;x \leq 20000000000000:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -27 or 2e13 < x

    1. Initial program 99.2%

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

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

    if -27 < x < -1.74999999999999999e-43 or -1.8500000000000001e-244 < x < 1.44999999999999992e-301 or 7.00000000000000007e-147 < x < 2e13

    1. Initial program 100.0%

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

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

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

      \[\leadsto 1 + \color{blue}{\frac{-4 \cdot z}{y}} \]
    5. Taylor expanded in z around inf 67.6%

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

        \[\leadsto \color{blue}{\frac{-4 \cdot z}{y}} \]
      2. *-commutative67.6%

        \[\leadsto \frac{\color{blue}{z \cdot -4}}{y} \]
      3. associate-/l*67.6%

        \[\leadsto \color{blue}{\frac{z}{\frac{y}{-4}}} \]
    7. Simplified67.6%

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

    if -1.74999999999999999e-43 < x < -1.8500000000000001e-244 or 1.44999999999999992e-301 < x < 7.00000000000000007e-147

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -27:\\ \;\;\;\;1 + 4 \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq -1.75 \cdot 10^{-43}:\\ \;\;\;\;\frac{z}{\frac{y}{-4}}\\ \mathbf{elif}\;x \leq -1.85 \cdot 10^{-244}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-301}:\\ \;\;\;\;\frac{z}{\frac{y}{-4}}\\ \mathbf{elif}\;x \leq 7 \cdot 10^{-147}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq 20000000000000:\\ \;\;\;\;\frac{z}{\frac{y}{-4}}\\ \mathbf{else}:\\ \;\;\;\;1 + 4 \cdot \frac{x}{y}\\ \end{array} \]

Alternative 3: 58.3% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + \frac{z \cdot -4}{y}\\ t_1 := 1 + 4 \cdot \frac{x}{y}\\ \mathbf{if}\;x \leq -2.1 \cdot 10^{+27}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.75 \cdot 10^{-43}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.1 \cdot 10^{-244}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{-300}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-278}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq 3400000000000:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ 1.0 (/ (* z -4.0) y))) (t_1 (+ 1.0 (* 4.0 (/ x y)))))
   (if (<= x -2.1e+27)
     t_1
     (if (<= x -1.75e-43)
       t_0
       (if (<= x -1.1e-244)
         2.0
         (if (<= x 1.95e-300)
           t_0
           (if (<= x 4e-278) 2.0 (if (<= x 3400000000000.0) t_0 t_1))))))))
double code(double x, double y, double z) {
	double t_0 = 1.0 + ((z * -4.0) / y);
	double t_1 = 1.0 + (4.0 * (x / y));
	double tmp;
	if (x <= -2.1e+27) {
		tmp = t_1;
	} else if (x <= -1.75e-43) {
		tmp = t_0;
	} else if (x <= -1.1e-244) {
		tmp = 2.0;
	} else if (x <= 1.95e-300) {
		tmp = t_0;
	} else if (x <= 4e-278) {
		tmp = 2.0;
	} else if (x <= 3400000000000.0) {
		tmp = t_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 = 1.0d0 + ((z * (-4.0d0)) / y)
    t_1 = 1.0d0 + (4.0d0 * (x / y))
    if (x <= (-2.1d+27)) then
        tmp = t_1
    else if (x <= (-1.75d-43)) then
        tmp = t_0
    else if (x <= (-1.1d-244)) then
        tmp = 2.0d0
    else if (x <= 1.95d-300) then
        tmp = t_0
    else if (x <= 4d-278) then
        tmp = 2.0d0
    else if (x <= 3400000000000.0d0) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = 1.0 + ((z * -4.0) / y);
	double t_1 = 1.0 + (4.0 * (x / y));
	double tmp;
	if (x <= -2.1e+27) {
		tmp = t_1;
	} else if (x <= -1.75e-43) {
		tmp = t_0;
	} else if (x <= -1.1e-244) {
		tmp = 2.0;
	} else if (x <= 1.95e-300) {
		tmp = t_0;
	} else if (x <= 4e-278) {
		tmp = 2.0;
	} else if (x <= 3400000000000.0) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 1.0 + ((z * -4.0) / y)
	t_1 = 1.0 + (4.0 * (x / y))
	tmp = 0
	if x <= -2.1e+27:
		tmp = t_1
	elif x <= -1.75e-43:
		tmp = t_0
	elif x <= -1.1e-244:
		tmp = 2.0
	elif x <= 1.95e-300:
		tmp = t_0
	elif x <= 4e-278:
		tmp = 2.0
	elif x <= 3400000000000.0:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(1.0 + Float64(Float64(z * -4.0) / y))
	t_1 = Float64(1.0 + Float64(4.0 * Float64(x / y)))
	tmp = 0.0
	if (x <= -2.1e+27)
		tmp = t_1;
	elseif (x <= -1.75e-43)
		tmp = t_0;
	elseif (x <= -1.1e-244)
		tmp = 2.0;
	elseif (x <= 1.95e-300)
		tmp = t_0;
	elseif (x <= 4e-278)
		tmp = 2.0;
	elseif (x <= 3400000000000.0)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 1.0 + ((z * -4.0) / y);
	t_1 = 1.0 + (4.0 * (x / y));
	tmp = 0.0;
	if (x <= -2.1e+27)
		tmp = t_1;
	elseif (x <= -1.75e-43)
		tmp = t_0;
	elseif (x <= -1.1e-244)
		tmp = 2.0;
	elseif (x <= 1.95e-300)
		tmp = t_0;
	elseif (x <= 4e-278)
		tmp = 2.0;
	elseif (x <= 3400000000000.0)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.1e+27], t$95$1, If[LessEqual[x, -1.75e-43], t$95$0, If[LessEqual[x, -1.1e-244], 2.0, If[LessEqual[x, 1.95e-300], t$95$0, If[LessEqual[x, 4e-278], 2.0, If[LessEqual[x, 3400000000000.0], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -1.75 \cdot 10^{-43}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 1.95 \cdot 10^{-300}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 4 \cdot 10^{-278}:\\
\;\;\;\;2\\

\mathbf{elif}\;x \leq 3400000000000:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.09999999999999995e27 or 3.4e12 < x

    1. Initial program 99.2%

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

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

    if -2.09999999999999995e27 < x < -1.74999999999999999e-43 or -1.09999999999999992e-244 < x < 1.9500000000000001e-300 or 3.99999999999999975e-278 < x < 3.4e12

    1. Initial program 100.0%

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

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

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

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

    if -1.74999999999999999e-43 < x < -1.09999999999999992e-244 or 1.9500000000000001e-300 < x < 3.99999999999999975e-278

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.1 \cdot 10^{+27}:\\ \;\;\;\;1 + 4 \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq -1.75 \cdot 10^{-43}:\\ \;\;\;\;1 + \frac{z \cdot -4}{y}\\ \mathbf{elif}\;x \leq -1.1 \cdot 10^{-244}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{-300}:\\ \;\;\;\;1 + \frac{z \cdot -4}{y}\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-278}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq 3400000000000:\\ \;\;\;\;1 + \frac{z \cdot -4}{y}\\ \mathbf{else}:\\ \;\;\;\;1 + 4 \cdot \frac{x}{y}\\ \end{array} \]

Alternative 4: 54.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 4 \cdot \frac{x}{y}\\ t_1 := \frac{z}{\frac{y}{-4}}\\ \mathbf{if}\;x \leq -1.45 \cdot 10^{+29}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -2.15 \cdot 10^{-43}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -3 \cdot 10^{-239}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-303}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3 \cdot 10^{-147}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{+69}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* 4.0 (/ x y))) (t_1 (/ z (/ y -4.0))))
   (if (<= x -1.45e+29)
     t_0
     (if (<= x -2.15e-43)
       t_1
       (if (<= x -3e-239)
         2.0
         (if (<= x 1.4e-303)
           t_1
           (if (<= x 3e-147) 2.0 (if (<= x 1.05e+69) t_1 t_0))))))))
double code(double x, double y, double z) {
	double t_0 = 4.0 * (x / y);
	double t_1 = z / (y / -4.0);
	double tmp;
	if (x <= -1.45e+29) {
		tmp = t_0;
	} else if (x <= -2.15e-43) {
		tmp = t_1;
	} else if (x <= -3e-239) {
		tmp = 2.0;
	} else if (x <= 1.4e-303) {
		tmp = t_1;
	} else if (x <= 3e-147) {
		tmp = 2.0;
	} else if (x <= 1.05e+69) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_0 = 4.0d0 * (x / y)
    t_1 = z / (y / (-4.0d0))
    if (x <= (-1.45d+29)) then
        tmp = t_0
    else if (x <= (-2.15d-43)) then
        tmp = t_1
    else if (x <= (-3d-239)) then
        tmp = 2.0d0
    else if (x <= 1.4d-303) then
        tmp = t_1
    else if (x <= 3d-147) then
        tmp = 2.0d0
    else if (x <= 1.05d+69) then
        tmp = t_1
    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 t_1 = z / (y / -4.0);
	double tmp;
	if (x <= -1.45e+29) {
		tmp = t_0;
	} else if (x <= -2.15e-43) {
		tmp = t_1;
	} else if (x <= -3e-239) {
		tmp = 2.0;
	} else if (x <= 1.4e-303) {
		tmp = t_1;
	} else if (x <= 3e-147) {
		tmp = 2.0;
	} else if (x <= 1.05e+69) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 4.0 * (x / y)
	t_1 = z / (y / -4.0)
	tmp = 0
	if x <= -1.45e+29:
		tmp = t_0
	elif x <= -2.15e-43:
		tmp = t_1
	elif x <= -3e-239:
		tmp = 2.0
	elif x <= 1.4e-303:
		tmp = t_1
	elif x <= 3e-147:
		tmp = 2.0
	elif x <= 1.05e+69:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(4.0 * Float64(x / y))
	t_1 = Float64(z / Float64(y / -4.0))
	tmp = 0.0
	if (x <= -1.45e+29)
		tmp = t_0;
	elseif (x <= -2.15e-43)
		tmp = t_1;
	elseif (x <= -3e-239)
		tmp = 2.0;
	elseif (x <= 1.4e-303)
		tmp = t_1;
	elseif (x <= 3e-147)
		tmp = 2.0;
	elseif (x <= 1.05e+69)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 4.0 * (x / y);
	t_1 = z / (y / -4.0);
	tmp = 0.0;
	if (x <= -1.45e+29)
		tmp = t_0;
	elseif (x <= -2.15e-43)
		tmp = t_1;
	elseif (x <= -3e-239)
		tmp = 2.0;
	elseif (x <= 1.4e-303)
		tmp = t_1;
	elseif (x <= 3e-147)
		tmp = 2.0;
	elseif (x <= 1.05e+69)
		tmp = t_1;
	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]}, Block[{t$95$1 = N[(z / N[(y / -4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.45e+29], t$95$0, If[LessEqual[x, -2.15e-43], t$95$1, If[LessEqual[x, -3e-239], 2.0, If[LessEqual[x, 1.4e-303], t$95$1, If[LessEqual[x, 3e-147], 2.0, If[LessEqual[x, 1.05e+69], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{y}\\
t_1 := \frac{z}{\frac{y}{-4}}\\
\mathbf{if}\;x \leq -1.45 \cdot 10^{+29}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -2.15 \cdot 10^{-43}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -3 \cdot 10^{-239}:\\
\;\;\;\;2\\

\mathbf{elif}\;x \leq 1.4 \cdot 10^{-303}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 3 \cdot 10^{-147}:\\
\;\;\;\;2\\

\mathbf{elif}\;x \leq 1.05 \cdot 10^{+69}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.45e29 or 1.05000000000000008e69 < x

    1. Initial program 99.1%

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

      \[\leadsto 1 + \color{blue}{4 \cdot \frac{x}{y}} \]
    3. Taylor expanded in x around inf 70.6%

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

    if -1.45e29 < x < -2.14999999999999982e-43 or -2.9999999999999998e-239 < x < 1.4e-303 or 3.0000000000000002e-147 < x < 1.05000000000000008e69

    1. Initial program 100.0%

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

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

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

      \[\leadsto 1 + \color{blue}{\frac{-4 \cdot z}{y}} \]
    5. Taylor expanded in z around inf 59.7%

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

        \[\leadsto \color{blue}{\frac{-4 \cdot z}{y}} \]
      2. *-commutative59.7%

        \[\leadsto \frac{\color{blue}{z \cdot -4}}{y} \]
      3. associate-/l*59.7%

        \[\leadsto \color{blue}{\frac{z}{\frac{y}{-4}}} \]
    7. Simplified59.7%

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

    if -2.14999999999999982e-43 < x < -2.9999999999999998e-239 or 1.4e-303 < x < 3.0000000000000002e-147

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.45 \cdot 10^{+29}:\\ \;\;\;\;4 \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq -2.15 \cdot 10^{-43}:\\ \;\;\;\;\frac{z}{\frac{y}{-4}}\\ \mathbf{elif}\;x \leq -3 \cdot 10^{-239}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-303}:\\ \;\;\;\;\frac{z}{\frac{y}{-4}}\\ \mathbf{elif}\;x \leq 3 \cdot 10^{-147}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{+69}:\\ \;\;\;\;\frac{z}{\frac{y}{-4}}\\ \mathbf{else}:\\ \;\;\;\;4 \cdot \frac{x}{y}\\ \end{array} \]

Alternative 5: 53.9% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.75 \cdot 10^{+31} \lor \neg \left(x \leq 58000000000000\right):\\
\;\;\;\;4 \cdot \frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.75e31 or 5.8e13 < x

    1. Initial program 99.2%

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

      \[\leadsto 1 + \color{blue}{4 \cdot \frac{x}{y}} \]
    3. Taylor expanded in x around inf 68.4%

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

    if -3.75e31 < x < 5.8e13

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.75 \cdot 10^{+31} \lor \neg \left(x \leq 58000000000000\right):\\ \;\;\;\;4 \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;2\\ \end{array} \]

Alternative 6: 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 99.6%

    \[1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} \]
  2. Step-by-step derivation
    1. associate-*l/99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(1 + \frac{\color{blue}{-1 \cdot \left(y \cdot 0.25\right)}}{\left(-y\right) \cdot 0.25}\right) + \frac{4}{y} \cdot \left(x - z\right) \]
    16. neg-mul-199.8%

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

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

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

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

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

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

Alternative 7: 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 99.6%

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

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

    \[\leadsto \color{blue}{1} \]
  4. Final simplification8.2%

    \[\leadsto 1 \]

Alternative 8: 33.4% 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 99.6%

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

    \[\leadsto \color{blue}{2} \]
  3. Final simplification34.9%

    \[\leadsto 2 \]

Reproduce

?
herbie shell --seed 2023320 
(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)))