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

Percentage Accurate: 99.7% → 99.9%
Time: 6.1s
Alternatives: 8
Speedup: 1.4×

Specification

?
\[\begin{array}{l} \\ 1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))
double code(double x, double y, double z) {
	return 1.0 + ((4.0 * ((x + (y * 0.75)) - 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.75d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
	return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
def code(x, y, z):
	return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y)
function code(x, y, z)
	return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.75)) - z)) / y))
end
function tmp = code(x, y, z)
	tmp = 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\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.7% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{x - \left(z - y \cdot 0.75\right)}, \frac{4}{y}, 1\right) \]
    9. sub-neg99.8%

      \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(z + \left(-y \cdot 0.75\right)\right)}, \frac{4}{y}, 1\right) \]
    10. remove-double-neg99.8%

      \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{\left(-\left(-z\right)\right)} + \left(-y \cdot 0.75\right)\right), \frac{4}{y}, 1\right) \]
    11. distribute-neg-in99.8%

      \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(-\left(\left(-z\right) + y \cdot 0.75\right)\right)}, \frac{4}{y}, 1\right) \]
    12. +-commutative99.8%

      \[\leadsto \mathsf{fma}\left(x - \left(-\color{blue}{\left(y \cdot 0.75 + \left(-z\right)\right)}\right), \frac{4}{y}, 1\right) \]
    13. distribute-neg-in99.8%

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

      \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{\left(-y\right) \cdot 0.75} + \left(-\left(-z\right)\right)\right), \frac{4}{y}, 1\right) \]
    15. sub-neg99.8%

      \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(\left(-y\right) \cdot 0.75 - \left(-z\right)\right)}, \frac{4}{y}, 1\right) \]
    16. distribute-lft-neg-out99.8%

      \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{\left(-y \cdot 0.75\right)} - \left(-z\right)\right), \frac{4}{y}, 1\right) \]
    17. distribute-rgt-neg-in99.8%

      \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{y \cdot \left(-0.75\right)} - \left(-z\right)\right), \frac{4}{y}, 1\right) \]
    18. fma-neg99.8%

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

      \[\leadsto \mathsf{fma}\left(x - \mathsf{fma}\left(y, \color{blue}{-0.75}, -\left(-z\right)\right), \frac{4}{y}, 1\right) \]
    20. remove-double-neg99.8%

      \[\leadsto \mathsf{fma}\left(x - \mathsf{fma}\left(y, -0.75, \color{blue}{z}\right), \frac{4}{y}, 1\right) \]
  3. Simplified99.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(x - \mathsf{fma}\left(y, -0.75, z\right), \frac{4}{y}, 1\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in y around 0 100.0%

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

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

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

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

Alternative 2: 55.0% accurate, 0.8× 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}\;y \leq -1650000000:\\ \;\;\;\;4\\ \mathbf{elif}\;y \leq -2.2 \cdot 10^{-308}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 5.6 \cdot 10^{-251}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 8.6 \cdot 10^{-157}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{+36}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;4\\ \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 (<= y -1650000000.0)
     4.0
     (if (<= y -2.2e-308)
       t_1
       (if (<= y 5.6e-251)
         t_0
         (if (<= y 8.6e-157) t_1 (if (<= y 1.8e+36) t_0 4.0)))))))
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 (y <= -1650000000.0) {
		tmp = 4.0;
	} else if (y <= -2.2e-308) {
		tmp = t_1;
	} else if (y <= 5.6e-251) {
		tmp = t_0;
	} else if (y <= 8.6e-157) {
		tmp = t_1;
	} else if (y <= 1.8e+36) {
		tmp = t_0;
	} else {
		tmp = 4.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) * (z / y)) + 1.0d0
    t_1 = 1.0d0 + (x * (4.0d0 / y))
    if (y <= (-1650000000.0d0)) then
        tmp = 4.0d0
    else if (y <= (-2.2d-308)) then
        tmp = t_1
    else if (y <= 5.6d-251) then
        tmp = t_0
    else if (y <= 8.6d-157) then
        tmp = t_1
    else if (y <= 1.8d+36) then
        tmp = t_0
    else
        tmp = 4.0d0
    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 (y <= -1650000000.0) {
		tmp = 4.0;
	} else if (y <= -2.2e-308) {
		tmp = t_1;
	} else if (y <= 5.6e-251) {
		tmp = t_0;
	} else if (y <= 8.6e-157) {
		tmp = t_1;
	} else if (y <= 1.8e+36) {
		tmp = t_0;
	} else {
		tmp = 4.0;
	}
	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 y <= -1650000000.0:
		tmp = 4.0
	elif y <= -2.2e-308:
		tmp = t_1
	elif y <= 5.6e-251:
		tmp = t_0
	elif y <= 8.6e-157:
		tmp = t_1
	elif y <= 1.8e+36:
		tmp = t_0
	else:
		tmp = 4.0
	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 (y <= -1650000000.0)
		tmp = 4.0;
	elseif (y <= -2.2e-308)
		tmp = t_1;
	elseif (y <= 5.6e-251)
		tmp = t_0;
	elseif (y <= 8.6e-157)
		tmp = t_1;
	elseif (y <= 1.8e+36)
		tmp = t_0;
	else
		tmp = 4.0;
	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 (y <= -1650000000.0)
		tmp = 4.0;
	elseif (y <= -2.2e-308)
		tmp = t_1;
	elseif (y <= 5.6e-251)
		tmp = t_0;
	elseif (y <= 8.6e-157)
		tmp = t_1;
	elseif (y <= 1.8e+36)
		tmp = t_0;
	else
		tmp = 4.0;
	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[y, -1650000000.0], 4.0, If[LessEqual[y, -2.2e-308], t$95$1, If[LessEqual[y, 5.6e-251], t$95$0, If[LessEqual[y, 8.6e-157], t$95$1, If[LessEqual[y, 1.8e+36], t$95$0, 4.0]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -2.2 \cdot 10^{-308}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 5.6 \cdot 10^{-251}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 8.6 \cdot 10^{-157}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 1.8 \cdot 10^{+36}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;4\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.65e9 or 1.7999999999999999e36 < y

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{x - \left(z - y \cdot 0.75\right)}, \frac{4}{y}, 1\right) \]
      9. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(z + \left(-y \cdot 0.75\right)\right)}, \frac{4}{y}, 1\right) \]
      10. remove-double-neg99.7%

        \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{\left(-\left(-z\right)\right)} + \left(-y \cdot 0.75\right)\right), \frac{4}{y}, 1\right) \]
      11. distribute-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(-\left(\left(-z\right) + y \cdot 0.75\right)\right)}, \frac{4}{y}, 1\right) \]
      12. +-commutative99.7%

        \[\leadsto \mathsf{fma}\left(x - \left(-\color{blue}{\left(y \cdot 0.75 + \left(-z\right)\right)}\right), \frac{4}{y}, 1\right) \]
      13. distribute-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(\left(-y \cdot 0.75\right) + \left(-\left(-z\right)\right)\right)}, \frac{4}{y}, 1\right) \]
      14. distribute-lft-neg-out99.7%

        \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{\left(-y\right) \cdot 0.75} + \left(-\left(-z\right)\right)\right), \frac{4}{y}, 1\right) \]
      15. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(\left(-y\right) \cdot 0.75 - \left(-z\right)\right)}, \frac{4}{y}, 1\right) \]
      16. distribute-lft-neg-out99.7%

        \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{\left(-y \cdot 0.75\right)} - \left(-z\right)\right), \frac{4}{y}, 1\right) \]
      17. distribute-rgt-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{y \cdot \left(-0.75\right)} - \left(-z\right)\right), \frac{4}{y}, 1\right) \]
      18. fma-neg99.7%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\mathsf{fma}\left(y, -0.75, -\left(-z\right)\right)}, \frac{4}{y}, 1\right) \]
      19. metadata-eval99.7%

        \[\leadsto \mathsf{fma}\left(x - \mathsf{fma}\left(y, \color{blue}{-0.75}, -\left(-z\right)\right), \frac{4}{y}, 1\right) \]
      20. remove-double-neg99.7%

        \[\leadsto \mathsf{fma}\left(x - \mathsf{fma}\left(y, -0.75, \color{blue}{z}\right), \frac{4}{y}, 1\right) \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x - \mathsf{fma}\left(y, -0.75, z\right), \frac{4}{y}, 1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 70.3%

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

    if -1.65e9 < y < -2.2000000000000002e-308 or 5.59999999999999978e-251 < y < 8.5999999999999995e-157

    1. Initial program 100.0%

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

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

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

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

      \[\leadsto \color{blue}{1 + \frac{4}{y} \cdot \left(\mathsf{fma}\left(y, 0.75, x\right) - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 64.3%

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

    if -2.2000000000000002e-308 < y < 5.59999999999999978e-251 or 8.5999999999999995e-157 < y < 1.7999999999999999e36

    1. Initial program 100.0%

      \[1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\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.75\right) - z\right)} \]
      2. +-commutative99.8%

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

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

      \[\leadsto \color{blue}{1 + \frac{4}{y} \cdot \left(\mathsf{fma}\left(y, 0.75, x\right) - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 64.6%

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

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

      \[\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}\;y \leq -1650000000:\\ \;\;\;\;4\\ \mathbf{elif}\;y \leq -2.2 \cdot 10^{-308}:\\ \;\;\;\;1 + x \cdot \frac{4}{y}\\ \mathbf{elif}\;y \leq 5.6 \cdot 10^{-251}:\\ \;\;\;\;-4 \cdot \frac{z}{y} + 1\\ \mathbf{elif}\;y \leq 8.6 \cdot 10^{-157}:\\ \;\;\;\;1 + x \cdot \frac{4}{y}\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{+36}:\\ \;\;\;\;-4 \cdot \frac{z}{y} + 1\\ \mathbf{else}:\\ \;\;\;\;4\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 55.2% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -4 \cdot \frac{z}{y} + 1\\ t_1 := 1 + \frac{4 \cdot x}{y}\\ \mathbf{if}\;y \leq -3100000000:\\ \;\;\;\;4\\ \mathbf{elif}\;y \leq 1.32 \cdot 10^{-301}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{-253}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{-158}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{+37}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;4\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ (* -4.0 (/ z y)) 1.0)) (t_1 (+ 1.0 (/ (* 4.0 x) y))))
   (if (<= y -3100000000.0)
     4.0
     (if (<= y 1.32e-301)
       t_1
       (if (<= y 3.5e-253)
         t_0
         (if (<= y 1.6e-158) t_1 (if (<= y 1.15e+37) t_0 4.0)))))))
double code(double x, double y, double z) {
	double t_0 = (-4.0 * (z / y)) + 1.0;
	double t_1 = 1.0 + ((4.0 * x) / y);
	double tmp;
	if (y <= -3100000000.0) {
		tmp = 4.0;
	} else if (y <= 1.32e-301) {
		tmp = t_1;
	} else if (y <= 3.5e-253) {
		tmp = t_0;
	} else if (y <= 1.6e-158) {
		tmp = t_1;
	} else if (y <= 1.15e+37) {
		tmp = t_0;
	} else {
		tmp = 4.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) * (z / y)) + 1.0d0
    t_1 = 1.0d0 + ((4.0d0 * x) / y)
    if (y <= (-3100000000.0d0)) then
        tmp = 4.0d0
    else if (y <= 1.32d-301) then
        tmp = t_1
    else if (y <= 3.5d-253) then
        tmp = t_0
    else if (y <= 1.6d-158) then
        tmp = t_1
    else if (y <= 1.15d+37) then
        tmp = t_0
    else
        tmp = 4.0d0
    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 + ((4.0 * x) / y);
	double tmp;
	if (y <= -3100000000.0) {
		tmp = 4.0;
	} else if (y <= 1.32e-301) {
		tmp = t_1;
	} else if (y <= 3.5e-253) {
		tmp = t_0;
	} else if (y <= 1.6e-158) {
		tmp = t_1;
	} else if (y <= 1.15e+37) {
		tmp = t_0;
	} else {
		tmp = 4.0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (-4.0 * (z / y)) + 1.0
	t_1 = 1.0 + ((4.0 * x) / y)
	tmp = 0
	if y <= -3100000000.0:
		tmp = 4.0
	elif y <= 1.32e-301:
		tmp = t_1
	elif y <= 3.5e-253:
		tmp = t_0
	elif y <= 1.6e-158:
		tmp = t_1
	elif y <= 1.15e+37:
		tmp = t_0
	else:
		tmp = 4.0
	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(4.0 * x) / y))
	tmp = 0.0
	if (y <= -3100000000.0)
		tmp = 4.0;
	elseif (y <= 1.32e-301)
		tmp = t_1;
	elseif (y <= 3.5e-253)
		tmp = t_0;
	elseif (y <= 1.6e-158)
		tmp = t_1;
	elseif (y <= 1.15e+37)
		tmp = t_0;
	else
		tmp = 4.0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (-4.0 * (z / y)) + 1.0;
	t_1 = 1.0 + ((4.0 * x) / y);
	tmp = 0.0;
	if (y <= -3100000000.0)
		tmp = 4.0;
	elseif (y <= 1.32e-301)
		tmp = t_1;
	elseif (y <= 3.5e-253)
		tmp = t_0;
	elseif (y <= 1.6e-158)
		tmp = t_1;
	elseif (y <= 1.15e+37)
		tmp = t_0;
	else
		tmp = 4.0;
	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[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3100000000.0], 4.0, If[LessEqual[y, 1.32e-301], t$95$1, If[LessEqual[y, 3.5e-253], t$95$0, If[LessEqual[y, 1.6e-158], t$95$1, If[LessEqual[y, 1.15e+37], t$95$0, 4.0]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 1.32 \cdot 10^{-301}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 3.5 \cdot 10^{-253}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 1.6 \cdot 10^{-158}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 1.15 \cdot 10^{+37}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;4\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -3.1e9 or 1.15000000000000001e37 < y

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{x - \left(z - y \cdot 0.75\right)}, \frac{4}{y}, 1\right) \]
      9. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(z + \left(-y \cdot 0.75\right)\right)}, \frac{4}{y}, 1\right) \]
      10. remove-double-neg99.7%

        \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{\left(-\left(-z\right)\right)} + \left(-y \cdot 0.75\right)\right), \frac{4}{y}, 1\right) \]
      11. distribute-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(-\left(\left(-z\right) + y \cdot 0.75\right)\right)}, \frac{4}{y}, 1\right) \]
      12. +-commutative99.7%

        \[\leadsto \mathsf{fma}\left(x - \left(-\color{blue}{\left(y \cdot 0.75 + \left(-z\right)\right)}\right), \frac{4}{y}, 1\right) \]
      13. distribute-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(\left(-y \cdot 0.75\right) + \left(-\left(-z\right)\right)\right)}, \frac{4}{y}, 1\right) \]
      14. distribute-lft-neg-out99.7%

        \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{\left(-y\right) \cdot 0.75} + \left(-\left(-z\right)\right)\right), \frac{4}{y}, 1\right) \]
      15. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(\left(-y\right) \cdot 0.75 - \left(-z\right)\right)}, \frac{4}{y}, 1\right) \]
      16. distribute-lft-neg-out99.7%

        \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{\left(-y \cdot 0.75\right)} - \left(-z\right)\right), \frac{4}{y}, 1\right) \]
      17. distribute-rgt-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{y \cdot \left(-0.75\right)} - \left(-z\right)\right), \frac{4}{y}, 1\right) \]
      18. fma-neg99.7%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\mathsf{fma}\left(y, -0.75, -\left(-z\right)\right)}, \frac{4}{y}, 1\right) \]
      19. metadata-eval99.7%

        \[\leadsto \mathsf{fma}\left(x - \mathsf{fma}\left(y, \color{blue}{-0.75}, -\left(-z\right)\right), \frac{4}{y}, 1\right) \]
      20. remove-double-neg99.7%

        \[\leadsto \mathsf{fma}\left(x - \mathsf{fma}\left(y, -0.75, \color{blue}{z}\right), \frac{4}{y}, 1\right) \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x - \mathsf{fma}\left(y, -0.75, z\right), \frac{4}{y}, 1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 70.3%

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

    if -3.1e9 < y < 1.3200000000000001e-301 or 3.50000000000000022e-253 < y < 1.59999999999999998e-158

    1. Initial program 100.0%

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

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

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

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

      \[\leadsto \color{blue}{1 + \frac{4}{y} \cdot \left(\mathsf{fma}\left(y, 0.75, x\right) - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 64.4%

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

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

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

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

    if 1.3200000000000001e-301 < y < 3.50000000000000022e-253 or 1.59999999999999998e-158 < y < 1.15000000000000001e37

    1. Initial program 100.0%

      \[1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\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.75\right) - z\right)} \]
      2. +-commutative99.8%

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

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

      \[\leadsto \color{blue}{1 + \frac{4}{y} \cdot \left(\mathsf{fma}\left(y, 0.75, x\right) - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 64.6%

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

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

      \[\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}\;y \leq -3100000000:\\ \;\;\;\;4\\ \mathbf{elif}\;y \leq 1.32 \cdot 10^{-301}:\\ \;\;\;\;1 + \frac{4 \cdot x}{y}\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{-253}:\\ \;\;\;\;-4 \cdot \frac{z}{y} + 1\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{-158}:\\ \;\;\;\;1 + \frac{4 \cdot x}{y}\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{+37}:\\ \;\;\;\;-4 \cdot \frac{z}{y} + 1\\ \mathbf{else}:\\ \;\;\;\;4\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 81.7% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.6 \cdot 10^{+130} \lor \neg \left(z \leq 2.2 \cdot 10^{+101}\right):\\
\;\;\;\;-4 \cdot \frac{z}{y} + 1\\

\mathbf{else}:\\
\;\;\;\;4 + 4 \cdot \frac{x}{y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.6000000000000001e130 or 2.2000000000000001e101 < z

    1. Initial program 100.0%

      \[1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\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.75\right) - z\right)} \]
      2. +-commutative99.8%

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

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

      \[\leadsto \color{blue}{1 + \frac{4}{y} \cdot \left(\mathsf{fma}\left(y, 0.75, x\right) - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 76.6%

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

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

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

    if -3.6000000000000001e130 < z < 2.2000000000000001e101

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{x - \left(z - y \cdot 0.75\right)}, \frac{4}{y}, 1\right) \]
      9. sub-neg99.8%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(z + \left(-y \cdot 0.75\right)\right)}, \frac{4}{y}, 1\right) \]
      10. remove-double-neg99.8%

        \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{\left(-\left(-z\right)\right)} + \left(-y \cdot 0.75\right)\right), \frac{4}{y}, 1\right) \]
      11. distribute-neg-in99.8%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(-\left(\left(-z\right) + y \cdot 0.75\right)\right)}, \frac{4}{y}, 1\right) \]
      12. +-commutative99.8%

        \[\leadsto \mathsf{fma}\left(x - \left(-\color{blue}{\left(y \cdot 0.75 + \left(-z\right)\right)}\right), \frac{4}{y}, 1\right) \]
      13. distribute-neg-in99.8%

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

        \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{\left(-y\right) \cdot 0.75} + \left(-\left(-z\right)\right)\right), \frac{4}{y}, 1\right) \]
      15. sub-neg99.8%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(\left(-y\right) \cdot 0.75 - \left(-z\right)\right)}, \frac{4}{y}, 1\right) \]
      16. distribute-lft-neg-out99.8%

        \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{\left(-y \cdot 0.75\right)} - \left(-z\right)\right), \frac{4}{y}, 1\right) \]
      17. distribute-rgt-neg-in99.8%

        \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{y \cdot \left(-0.75\right)} - \left(-z\right)\right), \frac{4}{y}, 1\right) \]
      18. fma-neg99.8%

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

        \[\leadsto \mathsf{fma}\left(x - \mathsf{fma}\left(y, \color{blue}{-0.75}, -\left(-z\right)\right), \frac{4}{y}, 1\right) \]
      20. remove-double-neg99.8%

        \[\leadsto \mathsf{fma}\left(x - \mathsf{fma}\left(y, -0.75, \color{blue}{z}\right), \frac{4}{y}, 1\right) \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x - \mathsf{fma}\left(y, -0.75, z\right), \frac{4}{y}, 1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 100.0%

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

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

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

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

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

Alternative 5: 86.9% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.02 \cdot 10^{+46} \lor \neg \left(z \leq 3.1 \cdot 10^{+97}\right):\\
\;\;\;\;4 + -4 \cdot \frac{z}{y}\\

\mathbf{else}:\\
\;\;\;\;4 + 4 \cdot \frac{x}{y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.0199999999999999e46 or 3.09999999999999981e97 < z

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{x - \left(z - y \cdot 0.75\right)}, \frac{4}{y}, 1\right) \]
      9. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(z + \left(-y \cdot 0.75\right)\right)}, \frac{4}{y}, 1\right) \]
      10. remove-double-neg99.7%

        \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{\left(-\left(-z\right)\right)} + \left(-y \cdot 0.75\right)\right), \frac{4}{y}, 1\right) \]
      11. distribute-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(-\left(\left(-z\right) + y \cdot 0.75\right)\right)}, \frac{4}{y}, 1\right) \]
      12. +-commutative99.7%

        \[\leadsto \mathsf{fma}\left(x - \left(-\color{blue}{\left(y \cdot 0.75 + \left(-z\right)\right)}\right), \frac{4}{y}, 1\right) \]
      13. distribute-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(\left(-y \cdot 0.75\right) + \left(-\left(-z\right)\right)\right)}, \frac{4}{y}, 1\right) \]
      14. distribute-lft-neg-out99.7%

        \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{\left(-y\right) \cdot 0.75} + \left(-\left(-z\right)\right)\right), \frac{4}{y}, 1\right) \]
      15. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(\left(-y\right) \cdot 0.75 - \left(-z\right)\right)}, \frac{4}{y}, 1\right) \]
      16. distribute-lft-neg-out99.7%

        \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{\left(-y \cdot 0.75\right)} - \left(-z\right)\right), \frac{4}{y}, 1\right) \]
      17. distribute-rgt-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{y \cdot \left(-0.75\right)} - \left(-z\right)\right), \frac{4}{y}, 1\right) \]
      18. fma-neg99.7%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\mathsf{fma}\left(y, -0.75, -\left(-z\right)\right)}, \frac{4}{y}, 1\right) \]
      19. metadata-eval99.7%

        \[\leadsto \mathsf{fma}\left(x - \mathsf{fma}\left(y, \color{blue}{-0.75}, -\left(-z\right)\right), \frac{4}{y}, 1\right) \]
      20. remove-double-neg99.7%

        \[\leadsto \mathsf{fma}\left(x - \mathsf{fma}\left(y, -0.75, \color{blue}{z}\right), \frac{4}{y}, 1\right) \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x - \mathsf{fma}\left(y, -0.75, z\right), \frac{4}{y}, 1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 100.0%

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

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

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

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

        \[\leadsto \color{blue}{-4 \cdot \frac{z}{y} + 4} \]
    10. Simplified88.2%

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

    if -1.0199999999999999e46 < z < 3.09999999999999981e97

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{x - \left(z - y \cdot 0.75\right)}, \frac{4}{y}, 1\right) \]
      9. sub-neg99.8%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(z + \left(-y \cdot 0.75\right)\right)}, \frac{4}{y}, 1\right) \]
      10. remove-double-neg99.8%

        \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{\left(-\left(-z\right)\right)} + \left(-y \cdot 0.75\right)\right), \frac{4}{y}, 1\right) \]
      11. distribute-neg-in99.8%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(-\left(\left(-z\right) + y \cdot 0.75\right)\right)}, \frac{4}{y}, 1\right) \]
      12. +-commutative99.8%

        \[\leadsto \mathsf{fma}\left(x - \left(-\color{blue}{\left(y \cdot 0.75 + \left(-z\right)\right)}\right), \frac{4}{y}, 1\right) \]
      13. distribute-neg-in99.8%

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

        \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{\left(-y\right) \cdot 0.75} + \left(-\left(-z\right)\right)\right), \frac{4}{y}, 1\right) \]
      15. sub-neg99.8%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(\left(-y\right) \cdot 0.75 - \left(-z\right)\right)}, \frac{4}{y}, 1\right) \]
      16. distribute-lft-neg-out99.8%

        \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{\left(-y \cdot 0.75\right)} - \left(-z\right)\right), \frac{4}{y}, 1\right) \]
      17. distribute-rgt-neg-in99.8%

        \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{y \cdot \left(-0.75\right)} - \left(-z\right)\right), \frac{4}{y}, 1\right) \]
      18. fma-neg99.8%

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

        \[\leadsto \mathsf{fma}\left(x - \mathsf{fma}\left(y, \color{blue}{-0.75}, -\left(-z\right)\right), \frac{4}{y}, 1\right) \]
      20. remove-double-neg99.8%

        \[\leadsto \mathsf{fma}\left(x - \mathsf{fma}\left(y, -0.75, \color{blue}{z}\right), \frac{4}{y}, 1\right) \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x - \mathsf{fma}\left(y, -0.75, z\right), \frac{4}{y}, 1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 100.0%

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

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

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

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

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

Alternative 6: 54.9% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -5600000000:\\ \;\;\;\;4\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{+67}:\\ \;\;\;\;1 + x \cdot \frac{4}{y}\\ \mathbf{else}:\\ \;\;\;\;4\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -5600000000.0) 4.0 (if (<= y 1.5e+67) (+ 1.0 (* x (/ 4.0 y))) 4.0)))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -5600000000.0) {
		tmp = 4.0;
	} else if (y <= 1.5e+67) {
		tmp = 1.0 + (x * (4.0 / y));
	} else {
		tmp = 4.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 (y <= (-5600000000.0d0)) then
        tmp = 4.0d0
    else if (y <= 1.5d+67) then
        tmp = 1.0d0 + (x * (4.0d0 / y))
    else
        tmp = 4.0d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -5600000000.0) {
		tmp = 4.0;
	} else if (y <= 1.5e+67) {
		tmp = 1.0 + (x * (4.0 / y));
	} else {
		tmp = 4.0;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -5600000000.0:
		tmp = 4.0
	elif y <= 1.5e+67:
		tmp = 1.0 + (x * (4.0 / y))
	else:
		tmp = 4.0
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -5600000000.0)
		tmp = 4.0;
	elseif (y <= 1.5e+67)
		tmp = Float64(1.0 + Float64(x * Float64(4.0 / y)));
	else
		tmp = 4.0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -5600000000.0)
		tmp = 4.0;
	elseif (y <= 1.5e+67)
		tmp = 1.0 + (x * (4.0 / y));
	else
		tmp = 4.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -5600000000.0], 4.0, If[LessEqual[y, 1.5e+67], N[(1.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -5600000000:\\
\;\;\;\;4\\

\mathbf{elif}\;y \leq 1.5 \cdot 10^{+67}:\\
\;\;\;\;1 + x \cdot \frac{4}{y}\\

\mathbf{else}:\\
\;\;\;\;4\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5.6e9 or 1.50000000000000005e67 < y

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{x - \left(z - y \cdot 0.75\right)}, \frac{4}{y}, 1\right) \]
      9. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(z + \left(-y \cdot 0.75\right)\right)}, \frac{4}{y}, 1\right) \]
      10. remove-double-neg99.7%

        \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{\left(-\left(-z\right)\right)} + \left(-y \cdot 0.75\right)\right), \frac{4}{y}, 1\right) \]
      11. distribute-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(-\left(\left(-z\right) + y \cdot 0.75\right)\right)}, \frac{4}{y}, 1\right) \]
      12. +-commutative99.7%

        \[\leadsto \mathsf{fma}\left(x - \left(-\color{blue}{\left(y \cdot 0.75 + \left(-z\right)\right)}\right), \frac{4}{y}, 1\right) \]
      13. distribute-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(\left(-y \cdot 0.75\right) + \left(-\left(-z\right)\right)\right)}, \frac{4}{y}, 1\right) \]
      14. distribute-lft-neg-out99.7%

        \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{\left(-y\right) \cdot 0.75} + \left(-\left(-z\right)\right)\right), \frac{4}{y}, 1\right) \]
      15. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(\left(-y\right) \cdot 0.75 - \left(-z\right)\right)}, \frac{4}{y}, 1\right) \]
      16. distribute-lft-neg-out99.7%

        \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{\left(-y \cdot 0.75\right)} - \left(-z\right)\right), \frac{4}{y}, 1\right) \]
      17. distribute-rgt-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{y \cdot \left(-0.75\right)} - \left(-z\right)\right), \frac{4}{y}, 1\right) \]
      18. fma-neg99.7%

        \[\leadsto \mathsf{fma}\left(x - \color{blue}{\mathsf{fma}\left(y, -0.75, -\left(-z\right)\right)}, \frac{4}{y}, 1\right) \]
      19. metadata-eval99.7%

        \[\leadsto \mathsf{fma}\left(x - \mathsf{fma}\left(y, \color{blue}{-0.75}, -\left(-z\right)\right), \frac{4}{y}, 1\right) \]
      20. remove-double-neg99.7%

        \[\leadsto \mathsf{fma}\left(x - \mathsf{fma}\left(y, -0.75, \color{blue}{z}\right), \frac{4}{y}, 1\right) \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x - \mathsf{fma}\left(y, -0.75, z\right), \frac{4}{y}, 1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 70.9%

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

    if -5.6e9 < y < 1.50000000000000005e67

    1. Initial program 100.0%

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

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

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

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

      \[\leadsto \color{blue}{1 + \frac{4}{y} \cdot \left(\mathsf{fma}\left(y, 0.75, x\right) - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 51.6%

      \[\leadsto 1 + \frac{4}{y} \cdot \color{blue}{x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification61.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5600000000:\\ \;\;\;\;4\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{+67}:\\ \;\;\;\;1 + x \cdot \frac{4}{y}\\ \mathbf{else}:\\ \;\;\;\;4\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 7.7% 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.75\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.75\right) - z\right)} \]
    2. +-commutative99.8%

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

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

    \[\leadsto \color{blue}{1 + \frac{4}{y} \cdot \left(\mathsf{fma}\left(y, 0.75, x\right) - z\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around inf 38.1%

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

    \[\leadsto \color{blue}{1} \]
  7. Final simplification8.8%

    \[\leadsto 1 \]
  8. Add Preprocessing

Alternative 8: 35.0% accurate, 13.0× speedup?

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{x - \left(z - y \cdot 0.75\right)}, \frac{4}{y}, 1\right) \]
    9. sub-neg99.8%

      \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(z + \left(-y \cdot 0.75\right)\right)}, \frac{4}{y}, 1\right) \]
    10. remove-double-neg99.8%

      \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{\left(-\left(-z\right)\right)} + \left(-y \cdot 0.75\right)\right), \frac{4}{y}, 1\right) \]
    11. distribute-neg-in99.8%

      \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(-\left(\left(-z\right) + y \cdot 0.75\right)\right)}, \frac{4}{y}, 1\right) \]
    12. +-commutative99.8%

      \[\leadsto \mathsf{fma}\left(x - \left(-\color{blue}{\left(y \cdot 0.75 + \left(-z\right)\right)}\right), \frac{4}{y}, 1\right) \]
    13. distribute-neg-in99.8%

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

      \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{\left(-y\right) \cdot 0.75} + \left(-\left(-z\right)\right)\right), \frac{4}{y}, 1\right) \]
    15. sub-neg99.8%

      \[\leadsto \mathsf{fma}\left(x - \color{blue}{\left(\left(-y\right) \cdot 0.75 - \left(-z\right)\right)}, \frac{4}{y}, 1\right) \]
    16. distribute-lft-neg-out99.8%

      \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{\left(-y \cdot 0.75\right)} - \left(-z\right)\right), \frac{4}{y}, 1\right) \]
    17. distribute-rgt-neg-in99.8%

      \[\leadsto \mathsf{fma}\left(x - \left(\color{blue}{y \cdot \left(-0.75\right)} - \left(-z\right)\right), \frac{4}{y}, 1\right) \]
    18. fma-neg99.8%

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

      \[\leadsto \mathsf{fma}\left(x - \mathsf{fma}\left(y, \color{blue}{-0.75}, -\left(-z\right)\right), \frac{4}{y}, 1\right) \]
    20. remove-double-neg99.8%

      \[\leadsto \mathsf{fma}\left(x - \mathsf{fma}\left(y, -0.75, \color{blue}{z}\right), \frac{4}{y}, 1\right) \]
  3. Simplified99.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(x - \mathsf{fma}\left(y, -0.75, z\right), \frac{4}{y}, 1\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in y around inf 41.8%

    \[\leadsto \color{blue}{4} \]
  6. Final simplification41.8%

    \[\leadsto 4 \]
  7. Add Preprocessing

Reproduce

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