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

Percentage Accurate: 99.7% → 100.0%
Time: 8.8s
Alternatives: 8
Speedup: 1.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 alternatives:

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

Initial Program: 99.7% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.4× speedup?

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

\\
4 + 4 \cdot \frac{x - z}{y}
\end{array}
Derivation
  1. Initial program 99.5%

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

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

    \[\leadsto \color{blue}{4 + 4 \cdot \frac{x - z}{y}} \]
  6. Add Preprocessing

Alternative 2: 54.6% accurate, 0.6× speedup?

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

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

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

\mathbf{elif}\;x \leq 5.2 \cdot 10^{+37}:\\
\;\;\;\;4\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -5.6e32 or 5.1999999999999998e37 < x

    1. Initial program 99.0%

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

        \[\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 y around inf 100.0%

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

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

    if -5.6e32 < x < -2.3999999999999999e-177

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

        \[\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 y around inf 100.0%

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

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

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

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

    if -2.3999999999999999e-177 < x < 5.1999999999999998e37

    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 y around inf 55.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.6 \cdot 10^{+32}:\\ \;\;\;\;4 \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq -2.4 \cdot 10^{-177}:\\ \;\;\;\;\frac{z \cdot -4}{y}\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{+37}:\\ \;\;\;\;4\\ \mathbf{else}:\\ \;\;\;\;4 \cdot \frac{x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 86.3% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.65 \cdot 10^{+16} \lor \neg \left(x \leq 4 \cdot 10^{+34}\right):\\ \;\;\;\;4 + 4 \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;4 + \frac{z \cdot -4}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -2.65e+16) (not (<= x 4e+34)))
   (+ 4.0 (* 4.0 (/ x y)))
   (+ 4.0 (/ (* z -4.0) y))))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -2.65e+16) || !(x <= 4e+34)) {
		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 <= (-2.65d+16)) .or. (.not. (x <= 4d+34))) 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 <= -2.65e+16) || !(x <= 4e+34)) {
		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 <= -2.65e+16) or not (x <= 4e+34):
		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 <= -2.65e+16) || !(x <= 4e+34))
		tmp = Float64(4.0 + Float64(4.0 * Float64(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 <= -2.65e+16) || ~((x <= 4e+34)))
		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, -2.65e+16], N[Not[LessEqual[x, 4e+34]], $MachinePrecision]], N[(4.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.65e16 or 3.99999999999999978e34 < x

    1. Initial program 99.1%

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

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

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

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

    if -2.65e16 < x < 3.99999999999999978e34

    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 x around 0 92.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 85.2% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.8 \cdot 10^{+50} \lor \neg \left(y \leq 9.2 \cdot 10^{+104}\right):\\
\;\;\;\;4 + 4 \cdot \frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.8000000000000004e50 or 9.19999999999999938e104 < 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*99.8%

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

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

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

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

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

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

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

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

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

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

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

    if -4.8000000000000004e50 < y < 9.19999999999999938e104

    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 y around inf 100.0%

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

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

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

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

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

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

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

Alternative 5: 79.1% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -8.8 \cdot 10^{+173}:\\ \;\;\;\;4\\ \mathbf{elif}\;y \leq 6.2 \cdot 10^{+137}:\\ \;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\ \mathbf{else}:\\ \;\;\;\;4\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -8.8e+173) 4.0 (if (<= y 6.2e+137) (* (- x z) (/ 4.0 y)) 4.0)))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -8.8e+173) {
		tmp = 4.0;
	} else if (y <= 6.2e+137) {
		tmp = (x - z) * (4.0 / y);
	} else {
		tmp = 4.0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-8.8d+173)) then
        tmp = 4.0d0
    else if (y <= 6.2d+137) then
        tmp = (x - z) * (4.0d0 / y)
    else
        tmp = 4.0d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -8.8e+173) {
		tmp = 4.0;
	} else if (y <= 6.2e+137) {
		tmp = (x - z) * (4.0 / y);
	} else {
		tmp = 4.0;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -8.8e+173:
		tmp = 4.0
	elif y <= 6.2e+137:
		tmp = (x - z) * (4.0 / y)
	else:
		tmp = 4.0
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -8.8e+173)
		tmp = 4.0;
	elseif (y <= 6.2e+137)
		tmp = Float64(Float64(x - z) * Float64(4.0 / y));
	else
		tmp = 4.0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -8.8e+173)
		tmp = 4.0;
	elseif (y <= 6.2e+137)
		tmp = (x - z) * (4.0 / y);
	else
		tmp = 4.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -8.8e+173], 4.0, If[LessEqual[y, 6.2e+137], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 6.2 \cdot 10^{+137}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -8.7999999999999999e173 or 6.1999999999999999e137 < y

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.7999999999999999e173 < y < 6.1999999999999999e137

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

Alternative 6: 54.6% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{+34} \lor \neg \left(x \leq 5.7 \cdot 10^{+38}\right):\\
\;\;\;\;4 \cdot \frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.99999999999999989e34 or 5.6999999999999997e38 < x

    1. Initial program 99.0%

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

        \[\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 y around inf 100.0%

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

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

    if -1.99999999999999989e34 < x < 5.6999999999999997e38

    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 y around inf 49.3%

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

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

Alternative 7: 34.6% accurate, 13.0× speedup?

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

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

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

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

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

Alternative 8: 7.7% accurate, 13.0× speedup?

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

\\
1
\end{array}
Derivation
  1. Initial program 99.5%

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

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

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

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

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

    \[\leadsto \color{blue}{1} \]
  7. Add Preprocessing

Reproduce

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