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

Percentage Accurate: 99.7% → 99.9%
Time: 6.4s
Alternatives: 7
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 7 alternatives:

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

Initial Program: 99.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 99.5%

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

      \[\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 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.4% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -4 \cdot \frac{z}{y} + 1\\ \mathbf{if}\;y \leq -3.25 \cdot 10^{+53}:\\ \;\;\;\;4\\ \mathbf{elif}\;y \leq -5.6 \cdot 10^{-51}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 2.7 \cdot 10^{-286}:\\ \;\;\;\;1 + x \cdot \frac{4}{y}\\ \mathbf{elif}\;y \leq 3.9 \cdot 10^{+79}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;4\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ (* -4.0 (/ z y)) 1.0)))
   (if (<= y -3.25e+53)
     4.0
     (if (<= y -5.6e-51)
       t_0
       (if (<= y 2.7e-286)
         (+ 1.0 (* x (/ 4.0 y)))
         (if (<= y 3.9e+79) t_0 4.0))))))
double code(double x, double y, double z) {
	double t_0 = (-4.0 * (z / y)) + 1.0;
	double tmp;
	if (y <= -3.25e+53) {
		tmp = 4.0;
	} else if (y <= -5.6e-51) {
		tmp = t_0;
	} else if (y <= 2.7e-286) {
		tmp = 1.0 + (x * (4.0 / y));
	} else if (y <= 3.9e+79) {
		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) :: tmp
    t_0 = ((-4.0d0) * (z / y)) + 1.0d0
    if (y <= (-3.25d+53)) then
        tmp = 4.0d0
    else if (y <= (-5.6d-51)) then
        tmp = t_0
    else if (y <= 2.7d-286) then
        tmp = 1.0d0 + (x * (4.0d0 / y))
    else if (y <= 3.9d+79) 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 tmp;
	if (y <= -3.25e+53) {
		tmp = 4.0;
	} else if (y <= -5.6e-51) {
		tmp = t_0;
	} else if (y <= 2.7e-286) {
		tmp = 1.0 + (x * (4.0 / y));
	} else if (y <= 3.9e+79) {
		tmp = t_0;
	} else {
		tmp = 4.0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (-4.0 * (z / y)) + 1.0
	tmp = 0
	if y <= -3.25e+53:
		tmp = 4.0
	elif y <= -5.6e-51:
		tmp = t_0
	elif y <= 2.7e-286:
		tmp = 1.0 + (x * (4.0 / y))
	elif y <= 3.9e+79:
		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)
	tmp = 0.0
	if (y <= -3.25e+53)
		tmp = 4.0;
	elseif (y <= -5.6e-51)
		tmp = t_0;
	elseif (y <= 2.7e-286)
		tmp = Float64(1.0 + Float64(x * Float64(4.0 / y)));
	elseif (y <= 3.9e+79)
		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;
	tmp = 0.0;
	if (y <= -3.25e+53)
		tmp = 4.0;
	elseif (y <= -5.6e-51)
		tmp = t_0;
	elseif (y <= 2.7e-286)
		tmp = 1.0 + (x * (4.0 / y));
	elseif (y <= 3.9e+79)
		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]}, If[LessEqual[y, -3.25e+53], 4.0, If[LessEqual[y, -5.6e-51], t$95$0, If[LessEqual[y, 2.7e-286], N[(1.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.9e+79], t$95$0, 4.0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := -4 \cdot \frac{z}{y} + 1\\
\mathbf{if}\;y \leq -3.25 \cdot 10^{+53}:\\
\;\;\;\;4\\

\mathbf{elif}\;y \leq -5.6 \cdot 10^{-51}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 2.7 \cdot 10^{-286}:\\
\;\;\;\;1 + x \cdot \frac{4}{y}\\

\mathbf{elif}\;y \leq 3.9 \cdot 10^{+79}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -3.25000000000000008e53 or 3.8999999999999997e79 < y

    1. Initial program 98.7%

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

        \[\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.6%

        \[\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.6%

        \[\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.6%

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

      \[\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 75.0%

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

    if -3.25000000000000008e53 < y < -5.6e-51 or 2.7000000000000002e-286 < y < 3.8999999999999997e79

    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. associate-*l/99.7%

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

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

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

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

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

      \[\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 58.1%

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

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

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

    if -5.6e-51 < y < 2.7000000000000002e-286

    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. sub-neg99.9%

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

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

        \[\leadsto 1 + \frac{4}{y} \cdot \left(\color{blue}{\left(y \cdot 0.75 + x\right)} - z\right) \]
      5. 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 66.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.25 \cdot 10^{+53}:\\ \;\;\;\;4\\ \mathbf{elif}\;y \leq -5.6 \cdot 10^{-51}:\\ \;\;\;\;-4 \cdot \frac{z}{y} + 1\\ \mathbf{elif}\;y \leq 2.7 \cdot 10^{-286}:\\ \;\;\;\;1 + x \cdot \frac{4}{y}\\ \mathbf{elif}\;y \leq 3.9 \cdot 10^{+79}:\\ \;\;\;\;-4 \cdot \frac{z}{y} + 1\\ \mathbf{else}:\\ \;\;\;\;4\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 55.4% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -4 \cdot \frac{z}{y} + 1\\ \mathbf{if}\;y \leq -1.48 \cdot 10^{+53}:\\ \;\;\;\;4\\ \mathbf{elif}\;y \leq -9.5 \cdot 10^{-56}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{-285}:\\ \;\;\;\;1 + \frac{4 \cdot x}{y}\\ \mathbf{elif}\;y \leq 3.7 \cdot 10^{+79}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;4\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ (* -4.0 (/ z y)) 1.0)))
   (if (<= y -1.48e+53)
     4.0
     (if (<= y -9.5e-56)
       t_0
       (if (<= y 8.5e-285)
         (+ 1.0 (/ (* 4.0 x) y))
         (if (<= y 3.7e+79) t_0 4.0))))))
double code(double x, double y, double z) {
	double t_0 = (-4.0 * (z / y)) + 1.0;
	double tmp;
	if (y <= -1.48e+53) {
		tmp = 4.0;
	} else if (y <= -9.5e-56) {
		tmp = t_0;
	} else if (y <= 8.5e-285) {
		tmp = 1.0 + ((4.0 * x) / y);
	} else if (y <= 3.7e+79) {
		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) :: tmp
    t_0 = ((-4.0d0) * (z / y)) + 1.0d0
    if (y <= (-1.48d+53)) then
        tmp = 4.0d0
    else if (y <= (-9.5d-56)) then
        tmp = t_0
    else if (y <= 8.5d-285) then
        tmp = 1.0d0 + ((4.0d0 * x) / y)
    else if (y <= 3.7d+79) 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 tmp;
	if (y <= -1.48e+53) {
		tmp = 4.0;
	} else if (y <= -9.5e-56) {
		tmp = t_0;
	} else if (y <= 8.5e-285) {
		tmp = 1.0 + ((4.0 * x) / y);
	} else if (y <= 3.7e+79) {
		tmp = t_0;
	} else {
		tmp = 4.0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (-4.0 * (z / y)) + 1.0
	tmp = 0
	if y <= -1.48e+53:
		tmp = 4.0
	elif y <= -9.5e-56:
		tmp = t_0
	elif y <= 8.5e-285:
		tmp = 1.0 + ((4.0 * x) / y)
	elif y <= 3.7e+79:
		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)
	tmp = 0.0
	if (y <= -1.48e+53)
		tmp = 4.0;
	elseif (y <= -9.5e-56)
		tmp = t_0;
	elseif (y <= 8.5e-285)
		tmp = Float64(1.0 + Float64(Float64(4.0 * x) / y));
	elseif (y <= 3.7e+79)
		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;
	tmp = 0.0;
	if (y <= -1.48e+53)
		tmp = 4.0;
	elseif (y <= -9.5e-56)
		tmp = t_0;
	elseif (y <= 8.5e-285)
		tmp = 1.0 + ((4.0 * x) / y);
	elseif (y <= 3.7e+79)
		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]}, If[LessEqual[y, -1.48e+53], 4.0, If[LessEqual[y, -9.5e-56], t$95$0, If[LessEqual[y, 8.5e-285], N[(1.0 + N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.7e+79], t$95$0, 4.0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := -4 \cdot \frac{z}{y} + 1\\
\mathbf{if}\;y \leq -1.48 \cdot 10^{+53}:\\
\;\;\;\;4\\

\mathbf{elif}\;y \leq -9.5 \cdot 10^{-56}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 8.5 \cdot 10^{-285}:\\
\;\;\;\;1 + \frac{4 \cdot x}{y}\\

\mathbf{elif}\;y \leq 3.7 \cdot 10^{+79}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.48e53 or 3.70000000000000009e79 < y

    1. Initial program 98.7%

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

        \[\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.6%

        \[\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.6%

        \[\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.6%

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

      \[\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 75.0%

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

    if -1.48e53 < y < -9.4999999999999991e-56 or 8.49999999999999979e-285 < y < 3.70000000000000009e79

    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. associate-*l/99.7%

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

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

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

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

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

      \[\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 58.1%

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

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

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

    if -9.4999999999999991e-56 < y < 8.49999999999999979e-285

    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. sub-neg99.9%

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

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

        \[\leadsto 1 + \frac{4}{y} \cdot \left(\color{blue}{\left(y \cdot 0.75 + x\right)} - z\right) \]
      5. 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 66.1%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.48 \cdot 10^{+53}:\\ \;\;\;\;4\\ \mathbf{elif}\;y \leq -9.5 \cdot 10^{-56}:\\ \;\;\;\;-4 \cdot \frac{z}{y} + 1\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{-285}:\\ \;\;\;\;1 + \frac{4 \cdot x}{y}\\ \mathbf{elif}\;y \leq 3.7 \cdot 10^{+79}:\\ \;\;\;\;-4 \cdot \frac{z}{y} + 1\\ \mathbf{else}:\\ \;\;\;\;4\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 81.4% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \cdot 10^{+84} \lor \neg \left(x \leq 5.3 \cdot 10^{+107}\right):\\
\;\;\;\;1 + \frac{4 \cdot x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.49999999999999998e84 or 5.3e107 < x

    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. associate-*l/99.8%

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

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

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

        \[\leadsto 1 + \frac{4}{y} \cdot \left(\color{blue}{\left(y \cdot 0.75 + x\right)} - z\right) \]
      5. 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 79.2%

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

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

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

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

    if -1.49999999999999998e84 < x < 5.3e107

    1. Initial program 99.4%

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

        \[\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 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 86.7%

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

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

Alternative 5: 85.7% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.1 \cdot 10^{+62} \lor \neg \left(x \leq 1.05 \cdot 10^{-40}\right):\\
\;\;\;\;4 + 4 \cdot \frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -8.09999999999999998e62 or 1.05000000000000009e-40 < x

    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 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 87.6%

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

    if -8.09999999999999998e62 < x < 1.05000000000000009e-40

    1. Initial program 99.2%

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

        \[\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 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 92.4%

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

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

Alternative 6: 53.1% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.02 \cdot 10^{-12}:\\
\;\;\;\;4\\

\mathbf{elif}\;y \leq 2.6 \cdot 10^{-40}:\\
\;\;\;\;1 + x \cdot \frac{4}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.02e-12 or 2.6000000000000001e-40 < y

    1. Initial program 99.1%

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

        \[\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 61.7%

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

    if -1.02e-12 < y < 2.6000000000000001e-40

    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. sub-neg99.8%

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

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

        \[\leadsto 1 + \frac{4}{y} \cdot \left(\color{blue}{\left(y \cdot 0.75 + x\right)} - z\right) \]
      5. 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 51.7%

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

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

Alternative 7: 33.9% 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 99.5%

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

      \[\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 34.1%

    \[\leadsto \color{blue}{4} \]
  6. Final simplification34.1%

    \[\leadsto 4 \]
  7. Add Preprocessing

Reproduce

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