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

Percentage Accurate: 99.7% → 100.0%
Time: 6.6s
Alternatives: 8
Speedup: 0.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 alternatives:

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

Initial Program: 99.7% accurate, 1.0× speedup?

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

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

Alternative 1: 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.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.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-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. Add Preprocessing

Alternative 2: 53.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 4 \cdot \frac{x}{y}\\ \mathbf{if}\;x \leq -2.95 \cdot 10^{+29}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -6 \cdot 10^{-201}:\\ \;\;\;\;4\\ \mathbf{elif}\;x \leq -4.6 \cdot 10^{-290}:\\ \;\;\;\;-4 \cdot \frac{z}{y}\\ \mathbf{elif}\;x \leq 90000000000:\\ \;\;\;\;4\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* 4.0 (/ x y))))
   (if (<= x -2.95e+29)
     t_0
     (if (<= x -6e-201)
       4.0
       (if (<= x -4.6e-290)
         (* -4.0 (/ z y))
         (if (<= x 90000000000.0) 4.0 t_0))))))
double code(double x, double y, double z) {
	double t_0 = 4.0 * (x / y);
	double tmp;
	if (x <= -2.95e+29) {
		tmp = t_0;
	} else if (x <= -6e-201) {
		tmp = 4.0;
	} else if (x <= -4.6e-290) {
		tmp = -4.0 * (z / y);
	} else if (x <= 90000000000.0) {
		tmp = 4.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 4.0d0 * (x / y)
    if (x <= (-2.95d+29)) then
        tmp = t_0
    else if (x <= (-6d-201)) then
        tmp = 4.0d0
    else if (x <= (-4.6d-290)) then
        tmp = (-4.0d0) * (z / y)
    else if (x <= 90000000000.0d0) then
        tmp = 4.0d0
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = 4.0 * (x / y);
	double tmp;
	if (x <= -2.95e+29) {
		tmp = t_0;
	} else if (x <= -6e-201) {
		tmp = 4.0;
	} else if (x <= -4.6e-290) {
		tmp = -4.0 * (z / y);
	} else if (x <= 90000000000.0) {
		tmp = 4.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 4.0 * (x / y)
	tmp = 0
	if x <= -2.95e+29:
		tmp = t_0
	elif x <= -6e-201:
		tmp = 4.0
	elif x <= -4.6e-290:
		tmp = -4.0 * (z / y)
	elif x <= 90000000000.0:
		tmp = 4.0
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(4.0 * Float64(x / y))
	tmp = 0.0
	if (x <= -2.95e+29)
		tmp = t_0;
	elseif (x <= -6e-201)
		tmp = 4.0;
	elseif (x <= -4.6e-290)
		tmp = Float64(-4.0 * Float64(z / y));
	elseif (x <= 90000000000.0)
		tmp = 4.0;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 4.0 * (x / y);
	tmp = 0.0;
	if (x <= -2.95e+29)
		tmp = t_0;
	elseif (x <= -6e-201)
		tmp = 4.0;
	elseif (x <= -4.6e-290)
		tmp = -4.0 * (z / y);
	elseif (x <= 90000000000.0)
		tmp = 4.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.95e+29], t$95$0, If[LessEqual[x, -6e-201], 4.0, If[LessEqual[x, -4.6e-290], N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 90000000000.0], 4.0, t$95$0]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -6 \cdot 10^{-201}:\\
\;\;\;\;4\\

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

\mathbf{elif}\;x \leq 90000000000:\\
\;\;\;\;4\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.9499999999999999e29 or 9e10 < 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.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 84.5%

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

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

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

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

        \[\leadsto \color{blue}{4} + 4 \cdot \frac{x}{y} \]
      5. associate-*r/84.5%

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

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

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

    if -2.9499999999999999e29 < x < -6.00000000000000004e-201 or -4.6000000000000001e-290 < x < 9e10

    1. Initial program 99.9%

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

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

    if -6.00000000000000004e-201 < x < -4.6000000000000001e-290

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

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

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

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

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

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

        \[\leadsto \color{blue}{4} + 4 \cdot \left(-\frac{z}{y}\right) \]
      6. neg-mul-1100.0%

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

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

        \[\leadsto 4 + \color{blue}{-4} \cdot \frac{z}{y} \]
      9. *-commutative100.0%

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

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

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

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

Alternative 3: 86.2% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -2.55 \cdot 10^{+85} \lor \neg \left(z \leq 8 \cdot 10^{+104}\right):\\ \;\;\;\;4 + \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 -2.55e+85) (not (<= z 8e+104)))
   (+ 4.0 (/ (* z -4.0) y))
   (+ 4.0 (/ (* 4.0 x) y))))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -2.55e+85) || !(z <= 8e+104)) {
		tmp = 4.0 + ((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 <= (-2.55d+85)) .or. (.not. (z <= 8d+104))) then
        tmp = 4.0d0 + ((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 <= -2.55e+85) || !(z <= 8e+104)) {
		tmp = 4.0 + ((z * -4.0) / y);
	} else {
		tmp = 4.0 + ((4.0 * x) / y);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -2.55e+85) or not (z <= 8e+104):
		tmp = 4.0 + ((z * -4.0) / y)
	else:
		tmp = 4.0 + ((4.0 * x) / y)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -2.55e+85) || !(z <= 8e+104))
		tmp = Float64(4.0 + 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 <= -2.55e+85) || ~((z <= 8e+104)))
		tmp = 4.0 + ((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, -2.55e+85], N[Not[LessEqual[z, 8e+104]], $MachinePrecision]], N[(4.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.55 \cdot 10^{+85} \lor \neg \left(z \leq 8 \cdot 10^{+104}\right):\\
\;\;\;\;4 + \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 < -2.5499999999999999e85 or 8e104 < z

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{\frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y} + 1} \]
      2. associate-/l*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 0 90.3%

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

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

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

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

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

        \[\leadsto \color{blue}{4} + 4 \cdot \left(-\frac{z}{y}\right) \]
      6. neg-mul-190.3%

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

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

        \[\leadsto 4 + \color{blue}{-4} \cdot \frac{z}{y} \]
      9. *-commutative90.3%

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

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

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

    if -2.5499999999999999e85 < z < 8e104

    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.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-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 z around 0 91.2%

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

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

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

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

        \[\leadsto \color{blue}{4} + 4 \cdot \frac{x}{y} \]
      5. associate-*r/91.2%

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

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

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

Alternative 4: 85.6% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.06 \cdot 10^{+61} \lor \neg \left(z \leq 4.8 \cdot 10^{+53}\right):\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.0599999999999999e61 or 4.8e53 < z

    1. Initial program 100.0%

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

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

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

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

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

    if -1.0599999999999999e61 < z < 4.8e53

    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.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-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 z around 0 92.9%

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

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

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

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

        \[\leadsto \color{blue}{4} + 4 \cdot \frac{x}{y} \]
      5. associate-*r/92.9%

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

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

      \[\leadsto \color{blue}{\frac{4 \cdot x + 4 \cdot y}{y}} \]
    9. Step-by-step derivation
      1. distribute-lft-out92.9%

        \[\leadsto \frac{\color{blue}{4 \cdot \left(x + y\right)}}{y} \]
      2. associate-*r/92.9%

        \[\leadsto \color{blue}{4 \cdot \frac{x + y}{y}} \]
    10. Simplified92.9%

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

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

Alternative 5: 81.2% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.2 \cdot 10^{+102} \lor \neg \left(z \leq 1.85 \cdot 10^{+144}\right):\\
\;\;\;\;-4 \cdot \frac{z}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -7.2000000000000003e102 or 1.8499999999999998e144 < z

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{\frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y} + 1} \]
      2. associate-/l*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 0 90.8%

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

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

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

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

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

        \[\leadsto \color{blue}{4} + 4 \cdot \left(-\frac{z}{y}\right) \]
      6. neg-mul-190.8%

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

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

        \[\leadsto 4 + \color{blue}{-4} \cdot \frac{z}{y} \]
      9. *-commutative90.8%

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

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

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

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

    if -7.2000000000000003e102 < z < 1.8499999999999998e144

    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.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-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 z around 0 90.4%

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

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

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

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

        \[\leadsto \color{blue}{4} + 4 \cdot \frac{x}{y} \]
      5. associate-*r/90.4%

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

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

      \[\leadsto \color{blue}{\frac{4 \cdot x + 4 \cdot y}{y}} \]
    9. Step-by-step derivation
      1. distribute-lft-out90.4%

        \[\leadsto \frac{\color{blue}{4 \cdot \left(x + y\right)}}{y} \]
      2. associate-*r/90.4%

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

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

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

Alternative 6: 54.5% accurate, 0.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.0999999999999999e61 or 2.89999999999999986e66 < z

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{\frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y} + 1} \]
      2. associate-/l*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 0 84.5%

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

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

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

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

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

        \[\leadsto \color{blue}{4} + 4 \cdot \left(-\frac{z}{y}\right) \]
      6. neg-mul-184.5%

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

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

        \[\leadsto 4 + \color{blue}{-4} \cdot \frac{z}{y} \]
      9. *-commutative84.5%

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

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

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

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

    if -3.0999999999999999e61 < z < 2.89999999999999986e66

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

Alternative 8: 34.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.9%

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

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

Reproduce

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