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

Percentage Accurate: 99.7% → 100.0%
Time: 6.8s
Alternatives: 9
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 9 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: 100.0% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(4, 0.75 + \frac{x - z}{y}, 1\right) \end{array} \]
(FPCore (x y z) :precision binary64 (fma 4.0 (+ 0.75 (/ (- x z) y)) 1.0))
double code(double x, double y, double z) {
	return fma(4.0, (0.75 + ((x - z) / y)), 1.0);
}
function code(x, y, z)
	return fma(4.0, Float64(0.75 + Float64(Float64(x - z) / y)), 1.0)
end
code[x_, y_, z_] := N[(4.0 * N[(0.75 + N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(4, 0.75 + \frac{x - z}{y}, 1\right)
\end{array}
Derivation
  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*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x + \left(-z\right)\right)}}{-y}, 1\right) \]
    18. sub-neg100.0%

      \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x - z\right)}}{-y}, 1\right) \]
    19. distribute-frac-neg100.0%

      \[\leadsto \mathsf{fma}\left(4, 0.75 + \color{blue}{\left(-\frac{x - z}{-y}\right)}, 1\right) \]
    20. distribute-frac-neg2100.0%

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

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

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

Alternative 2: 54.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{z \cdot -4}{y}\\ t_1 := 4 \cdot \frac{x}{y}\\ \mathbf{if}\;y \leq -5 \cdot 10^{+43}:\\ \;\;\;\;4\\ \mathbf{elif}\;y \leq -8.4 \cdot 10^{-187}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 4.8 \cdot 10^{-292}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{-42}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 0.118:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;4\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (* z -4.0) y)) (t_1 (* 4.0 (/ x y))))
   (if (<= y -5e+43)
     4.0
     (if (<= y -8.4e-187)
       t_1
       (if (<= y 4.8e-292)
         t_0
         (if (<= y 1.35e-42) t_1 (if (<= y 0.118) t_0 4.0)))))))
double code(double x, double y, double z) {
	double t_0 = (z * -4.0) / y;
	double t_1 = 4.0 * (x / y);
	double tmp;
	if (y <= -5e+43) {
		tmp = 4.0;
	} else if (y <= -8.4e-187) {
		tmp = t_1;
	} else if (y <= 4.8e-292) {
		tmp = t_0;
	} else if (y <= 1.35e-42) {
		tmp = t_1;
	} else if (y <= 0.118) {
		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 = (z * (-4.0d0)) / y
    t_1 = 4.0d0 * (x / y)
    if (y <= (-5d+43)) then
        tmp = 4.0d0
    else if (y <= (-8.4d-187)) then
        tmp = t_1
    else if (y <= 4.8d-292) then
        tmp = t_0
    else if (y <= 1.35d-42) then
        tmp = t_1
    else if (y <= 0.118d0) 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 = (z * -4.0) / y;
	double t_1 = 4.0 * (x / y);
	double tmp;
	if (y <= -5e+43) {
		tmp = 4.0;
	} else if (y <= -8.4e-187) {
		tmp = t_1;
	} else if (y <= 4.8e-292) {
		tmp = t_0;
	} else if (y <= 1.35e-42) {
		tmp = t_1;
	} else if (y <= 0.118) {
		tmp = t_0;
	} else {
		tmp = 4.0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (z * -4.0) / y
	t_1 = 4.0 * (x / y)
	tmp = 0
	if y <= -5e+43:
		tmp = 4.0
	elif y <= -8.4e-187:
		tmp = t_1
	elif y <= 4.8e-292:
		tmp = t_0
	elif y <= 1.35e-42:
		tmp = t_1
	elif y <= 0.118:
		tmp = t_0
	else:
		tmp = 4.0
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(z * -4.0) / y)
	t_1 = Float64(4.0 * Float64(x / y))
	tmp = 0.0
	if (y <= -5e+43)
		tmp = 4.0;
	elseif (y <= -8.4e-187)
		tmp = t_1;
	elseif (y <= 4.8e-292)
		tmp = t_0;
	elseif (y <= 1.35e-42)
		tmp = t_1;
	elseif (y <= 0.118)
		tmp = t_0;
	else
		tmp = 4.0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (z * -4.0) / y;
	t_1 = 4.0 * (x / y);
	tmp = 0.0;
	if (y <= -5e+43)
		tmp = 4.0;
	elseif (y <= -8.4e-187)
		tmp = t_1;
	elseif (y <= 4.8e-292)
		tmp = t_0;
	elseif (y <= 1.35e-42)
		tmp = t_1;
	elseif (y <= 0.118)
		tmp = t_0;
	else
		tmp = 4.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]}, Block[{t$95$1 = N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5e+43], 4.0, If[LessEqual[y, -8.4e-187], t$95$1, If[LessEqual[y, 4.8e-292], t$95$0, If[LessEqual[y, 1.35e-42], t$95$1, If[LessEqual[y, 0.118], t$95$0, 4.0]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -8.4 \cdot 10^{-187}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 4.8 \cdot 10^{-292}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 1.35 \cdot 10^{-42}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 0.118:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -5.0000000000000004e43 or 0.11799999999999999 < y

    1. Initial program 98.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x + \left(-z\right)\right)}}{-y}, 1\right) \]
      18. sub-neg100.0%

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x - z\right)}}{-y}, 1\right) \]
      19. distribute-frac-neg100.0%

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \color{blue}{\left(-\frac{x - z}{-y}\right)}, 1\right) \]
      20. distribute-frac-neg2100.0%

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

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

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

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

    if -5.0000000000000004e43 < y < -8.3999999999999997e-187 or 4.8000000000000002e-292 < y < 1.35e-42

    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*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x + \left(-z\right)\right)}}{-y}, 1\right) \]
      18. sub-neg100.0%

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x - z\right)}}{-y}, 1\right) \]
      19. distribute-frac-neg100.0%

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \color{blue}{\left(-\frac{x - z}{-y}\right)}, 1\right) \]
      20. distribute-frac-neg2100.0%

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot 4} \]
    7. Simplified61.0%

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

    if -8.3999999999999997e-187 < y < 4.8000000000000002e-292 or 1.35e-42 < y < 0.11799999999999999

    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*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x + \left(-z\right)\right)}}{-y}, 1\right) \]
      18. sub-neg100.0%

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x - z\right)}}{-y}, 1\right) \]
      19. distribute-frac-neg100.0%

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \color{blue}{\left(-\frac{x - z}{-y}\right)}, 1\right) \]
      20. distribute-frac-neg2100.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{+43}:\\ \;\;\;\;4\\ \mathbf{elif}\;y \leq -8.4 \cdot 10^{-187}:\\ \;\;\;\;4 \cdot \frac{x}{y}\\ \mathbf{elif}\;y \leq 4.8 \cdot 10^{-292}:\\ \;\;\;\;\frac{z \cdot -4}{y}\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{-42}:\\ \;\;\;\;4 \cdot \frac{x}{y}\\ \mathbf{elif}\;y \leq 0.118:\\ \;\;\;\;\frac{z \cdot -4}{y}\\ \mathbf{else}:\\ \;\;\;\;4\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 77.9% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -6 \cdot 10^{+85} \lor \neg \left(z \leq -0.27\right) \land \left(z \leq -4.6 \cdot 10^{-30} \lor \neg \left(z \leq 5 \cdot 10^{+190}\right)\right):\\
\;\;\;\;\frac{z \cdot -4}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -6.0000000000000001e85 or -0.27000000000000002 < z < -4.59999999999999968e-30 or 5.00000000000000036e190 < z

    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*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x + \left(-z\right)\right)}}{-y}, 1\right) \]
      18. sub-neg100.0%

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x - z\right)}}{-y}, 1\right) \]
      19. distribute-frac-neg100.0%

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \color{blue}{\left(-\frac{x - z}{-y}\right)}, 1\right) \]
      20. distribute-frac-neg2100.0%

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

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

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

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

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

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

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

    if -6.0000000000000001e85 < z < -0.27000000000000002 or -4.59999999999999968e-30 < z < 5.00000000000000036e190

    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*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x + \left(-z\right)\right)}}{-y}, 1\right) \]
      18. sub-neg100.0%

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x - z\right)}}{-y}, 1\right) \]
      19. distribute-frac-neg100.0%

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \color{blue}{\left(-\frac{x - z}{-y}\right)}, 1\right) \]
      20. distribute-frac-neg2100.0%

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

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

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

      \[\leadsto \color{blue}{1 + 4 \cdot \left(0.75 + \frac{x}{y}\right)} \]
    6. Step-by-step derivation
      1. distribute-lft-in87.2%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -6 \cdot 10^{+85} \lor \neg \left(z \leq -0.27\right) \land \left(z \leq -4.6 \cdot 10^{-30} \lor \neg \left(z \leq 5 \cdot 10^{+190}\right)\right):\\ \;\;\;\;\frac{z \cdot -4}{y}\\ \mathbf{else}:\\ \;\;\;\;4 + \frac{4 \cdot x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 85.3% accurate, 0.8× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{4 \cdot \left(x - z\right)}{y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.94999999999999982e-15 or 0.47999999999999998 < y

    1. Initial program 98.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x + \left(-z\right)\right)}}{-y}, 1\right) \]
      18. sub-neg100.0%

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x - z\right)}}{-y}, 1\right) \]
      19. distribute-frac-neg100.0%

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \color{blue}{\left(-\frac{x - z}{-y}\right)}, 1\right) \]
      20. distribute-frac-neg2100.0%

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

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

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

      \[\leadsto \color{blue}{1 + 4 \cdot \left(0.75 + \frac{x}{y}\right)} \]
    6. Step-by-step derivation
      1. distribute-lft-in89.0%

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

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

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

        \[\leadsto \color{blue}{4} + 4 \cdot \frac{x}{y} \]
      5. *-commutative89.0%

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

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

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

    if -2.94999999999999982e-15 < y < 0.47999999999999998

    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*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x + \left(-z\right)\right)}}{-y}, 1\right) \]
      18. sub-neg100.0%

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x - z\right)}}{-y}, 1\right) \]
      19. distribute-frac-neg100.0%

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \color{blue}{\left(-\frac{x - z}{-y}\right)}, 1\right) \]
      20. distribute-frac-neg2100.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\left(x - z\right) \cdot 4}{y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification91.9%

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

Alternative 5: 86.7% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -4.3999999999999997e63 or 3.5000000000000002e-17 < x

    1. Initial program 98.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x + \left(-z\right)\right)}}{-y}, 1\right) \]
      18. sub-neg100.0%

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x - z\right)}}{-y}, 1\right) \]
      19. distribute-frac-neg100.0%

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \color{blue}{\left(-\frac{x - z}{-y}\right)}, 1\right) \]
      20. distribute-frac-neg2100.0%

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

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

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

      \[\leadsto \color{blue}{1 + 4 \cdot \left(0.75 + \frac{x}{y}\right)} \]
    6. Step-by-step derivation
      1. distribute-lft-in87.2%

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

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

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

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

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

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

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

    if -4.3999999999999997e63 < x < 3.5000000000000002e-17

    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*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x + \left(-z\right)\right)}}{-y}, 1\right) \]
      18. sub-neg100.0%

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x - z\right)}}{-y}, 1\right) \]
      19. distribute-frac-neg100.0%

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \color{blue}{\left(-\frac{x - z}{-y}\right)}, 1\right) \]
      20. distribute-frac-neg2100.0%

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

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

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

      \[\leadsto \color{blue}{1 + 4 \cdot \left(0.75 - \frac{z}{y}\right)} \]
    6. Step-by-step derivation
      1. sub-neg89.3%

        \[\leadsto 1 + 4 \cdot \color{blue}{\left(0.75 + \left(-\frac{z}{y}\right)\right)} \]
      2. distribute-rgt-in89.3%

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

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

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

        \[\leadsto \color{blue}{4} + \left(-\frac{z}{y}\right) \cdot 4 \]
      6. distribute-lft-neg-out89.3%

        \[\leadsto 4 + \color{blue}{\left(-\frac{z}{y} \cdot 4\right)} \]
      7. distribute-rgt-neg-in89.3%

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

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

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

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

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

Alternative 6: 53.7% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.9 \cdot 10^{+43}:\\
\;\;\;\;4\\

\mathbf{elif}\;y \leq 2 \cdot 10^{+88}:\\
\;\;\;\;4 \cdot \frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.90000000000000004e43 or 1.99999999999999992e88 < y

    1. Initial program 98.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x + \left(-z\right)\right)}}{-y}, 1\right) \]
      18. sub-neg100.0%

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x - z\right)}}{-y}, 1\right) \]
      19. distribute-frac-neg100.0%

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \color{blue}{\left(-\frac{x - z}{-y}\right)}, 1\right) \]
      20. distribute-frac-neg2100.0%

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

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

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

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

    if -1.90000000000000004e43 < y < 1.99999999999999992e88

    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*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x + \left(-z\right)\right)}}{-y}, 1\right) \]
      18. sub-neg100.0%

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x - z\right)}}{-y}, 1\right) \]
      19. distribute-frac-neg100.0%

        \[\leadsto \mathsf{fma}\left(4, 0.75 + \color{blue}{\left(-\frac{x - z}{-y}\right)}, 1\right) \]
      20. distribute-frac-neg2100.0%

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot 4} \]
    7. Simplified51.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{+43}:\\ \;\;\;\;4\\ \mathbf{elif}\;y \leq 2 \cdot 10^{+88}:\\ \;\;\;\;4 \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;4\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 99.9% accurate, 1.0× speedup?

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

\\
1 + 4 \cdot \frac{x + \left(0.75 \cdot y - z\right)}{y}
\end{array}
Derivation
  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. associate-/l*100.0%

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

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

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

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

Alternative 8: 99.7% accurate, 1.4× speedup?

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

\\
\frac{4 \cdot \left(\left(x - z\right) + y\right)}{y}
\end{array}
Derivation
  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*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x + \left(-z\right)\right)}}{-y}, 1\right) \]
    18. sub-neg100.0%

      \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x - z\right)}}{-y}, 1\right) \]
    19. distribute-frac-neg100.0%

      \[\leadsto \mathsf{fma}\left(4, 0.75 + \color{blue}{\left(-\frac{x - z}{-y}\right)}, 1\right) \]
    20. distribute-frac-neg2100.0%

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

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

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

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

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

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

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

Alternative 9: 35.1% 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.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*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x + \left(-z\right)\right)}}{-y}, 1\right) \]
    18. sub-neg100.0%

      \[\leadsto \mathsf{fma}\left(4, 0.75 + \frac{-\color{blue}{\left(x - z\right)}}{-y}, 1\right) \]
    19. distribute-frac-neg100.0%

      \[\leadsto \mathsf{fma}\left(4, 0.75 + \color{blue}{\left(-\frac{x - z}{-y}\right)}, 1\right) \]
    20. distribute-frac-neg2100.0%

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

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

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

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

Reproduce

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