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

Percentage Accurate: 99.9% → 100.0%
Time: 6.8s
Alternatives: 11
Speedup: 1.4×

Specification

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

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

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

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

Alternative 1: 100.0% accurate, 1.4× speedup?

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

\\
\frac{x - z}{y \cdot 0.25} + 2
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

      \[\leadsto \frac{4}{y} \cdot \color{blue}{\left(\left(x - z\right) + y \cdot 0.25\right)} + 1 \]
    6. distribute-lft-in99.7%

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(x - z\right) + 2} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. *-commutative99.7%

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

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

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

      \[\leadsto \left(x - z\right) \cdot \frac{1}{y \cdot \color{blue}{0.25}} + 2 \]
    5. un-div-inv100.0%

      \[\leadsto \color{blue}{\frac{x - z}{y \cdot 0.25}} + 2 \]
  6. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\frac{x - z}{y \cdot 0.25}} + 2 \]
  7. Final simplification100.0%

    \[\leadsto \frac{x - z}{y \cdot 0.25} + 2 \]
  8. Add Preprocessing

Alternative 2: 57.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + z \cdot \frac{-4}{y}\\ \mathbf{if}\;z \leq -1.45 \cdot 10^{+44}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{-82}:\\ \;\;\;\;1 + x \cdot \frac{4}{y}\\ \mathbf{elif}\;z \leq 520000000000:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ 1.0 (* z (/ -4.0 y)))))
   (if (<= z -1.45e+44)
     t_0
     (if (<= z 2.8e-82)
       (+ 1.0 (* x (/ 4.0 y)))
       (if (<= z 520000000000.0) 2.0 t_0)))))
double code(double x, double y, double z) {
	double t_0 = 1.0 + (z * (-4.0 / y));
	double tmp;
	if (z <= -1.45e+44) {
		tmp = t_0;
	} else if (z <= 2.8e-82) {
		tmp = 1.0 + (x * (4.0 / y));
	} else if (z <= 520000000000.0) {
		tmp = 2.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 = 1.0d0 + (z * ((-4.0d0) / y))
    if (z <= (-1.45d+44)) then
        tmp = t_0
    else if (z <= 2.8d-82) then
        tmp = 1.0d0 + (x * (4.0d0 / y))
    else if (z <= 520000000000.0d0) then
        tmp = 2.0d0
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = 1.0 + (z * (-4.0 / y));
	double tmp;
	if (z <= -1.45e+44) {
		tmp = t_0;
	} else if (z <= 2.8e-82) {
		tmp = 1.0 + (x * (4.0 / y));
	} else if (z <= 520000000000.0) {
		tmp = 2.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 1.0 + (z * (-4.0 / y))
	tmp = 0
	if z <= -1.45e+44:
		tmp = t_0
	elif z <= 2.8e-82:
		tmp = 1.0 + (x * (4.0 / y))
	elif z <= 520000000000.0:
		tmp = 2.0
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(1.0 + Float64(z * Float64(-4.0 / y)))
	tmp = 0.0
	if (z <= -1.45e+44)
		tmp = t_0;
	elseif (z <= 2.8e-82)
		tmp = Float64(1.0 + Float64(x * Float64(4.0 / y)));
	elseif (z <= 520000000000.0)
		tmp = 2.0;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 1.0 + (z * (-4.0 / y));
	tmp = 0.0;
	if (z <= -1.45e+44)
		tmp = t_0;
	elseif (z <= 2.8e-82)
		tmp = 1.0 + (x * (4.0 / y));
	elseif (z <= 520000000000.0)
		tmp = 2.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.45e+44], t$95$0, If[LessEqual[z, 2.8e-82], N[(1.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 520000000000.0], 2.0, t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 1 + z \cdot \frac{-4}{y}\\
\mathbf{if}\;z \leq -1.45 \cdot 10^{+44}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 2.8 \cdot 10^{-82}:\\
\;\;\;\;1 + x \cdot \frac{4}{y}\\

\mathbf{elif}\;z \leq 520000000000:\\
\;\;\;\;2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.4500000000000001e44 or 5.2e11 < z

    1. Initial program 100.0%

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

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

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

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

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

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

        \[\leadsto 1 + \color{blue}{\frac{4}{y} \cdot \left(-z\right)} \]
      6. *-commutative68.5%

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

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

        \[\leadsto 1 + \color{blue}{z \cdot \left(-\frac{4}{y}\right)} \]
      9. distribute-neg-frac68.5%

        \[\leadsto 1 + z \cdot \color{blue}{\frac{-4}{y}} \]
      10. metadata-eval68.5%

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

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

    if -1.4500000000000001e44 < z < 2.80000000000000024e-82

    1. Initial program 100.0%

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

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

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

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

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

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

    if 2.80000000000000024e-82 < z < 5.2e11

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.45 \cdot 10^{+44}:\\ \;\;\;\;1 + z \cdot \frac{-4}{y}\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{-82}:\\ \;\;\;\;1 + x \cdot \frac{4}{y}\\ \mathbf{elif}\;z \leq 520000000000:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;1 + z \cdot \frac{-4}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 57.9% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + z \cdot \frac{-4}{y}\\ \mathbf{if}\;z \leq -2.3 \cdot 10^{+44}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-83}:\\ \;\;\;\;1 + \frac{x \cdot 4}{y}\\ \mathbf{elif}\;z \leq 5400000000:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ 1.0 (* z (/ -4.0 y)))))
   (if (<= z -2.3e+44)
     t_0
     (if (<= z 3.3e-83)
       (+ 1.0 (/ (* x 4.0) y))
       (if (<= z 5400000000.0) 2.0 t_0)))))
double code(double x, double y, double z) {
	double t_0 = 1.0 + (z * (-4.0 / y));
	double tmp;
	if (z <= -2.3e+44) {
		tmp = t_0;
	} else if (z <= 3.3e-83) {
		tmp = 1.0 + ((x * 4.0) / y);
	} else if (z <= 5400000000.0) {
		tmp = 2.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 = 1.0d0 + (z * ((-4.0d0) / y))
    if (z <= (-2.3d+44)) then
        tmp = t_0
    else if (z <= 3.3d-83) then
        tmp = 1.0d0 + ((x * 4.0d0) / y)
    else if (z <= 5400000000.0d0) then
        tmp = 2.0d0
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = 1.0 + (z * (-4.0 / y));
	double tmp;
	if (z <= -2.3e+44) {
		tmp = t_0;
	} else if (z <= 3.3e-83) {
		tmp = 1.0 + ((x * 4.0) / y);
	} else if (z <= 5400000000.0) {
		tmp = 2.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 1.0 + (z * (-4.0 / y))
	tmp = 0
	if z <= -2.3e+44:
		tmp = t_0
	elif z <= 3.3e-83:
		tmp = 1.0 + ((x * 4.0) / y)
	elif z <= 5400000000.0:
		tmp = 2.0
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(1.0 + Float64(z * Float64(-4.0 / y)))
	tmp = 0.0
	if (z <= -2.3e+44)
		tmp = t_0;
	elseif (z <= 3.3e-83)
		tmp = Float64(1.0 + Float64(Float64(x * 4.0) / y));
	elseif (z <= 5400000000.0)
		tmp = 2.0;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 1.0 + (z * (-4.0 / y));
	tmp = 0.0;
	if (z <= -2.3e+44)
		tmp = t_0;
	elseif (z <= 3.3e-83)
		tmp = 1.0 + ((x * 4.0) / y);
	elseif (z <= 5400000000.0)
		tmp = 2.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.3e+44], t$95$0, If[LessEqual[z, 3.3e-83], N[(1.0 + N[(N[(x * 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5400000000.0], 2.0, t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 1 + z \cdot \frac{-4}{y}\\
\mathbf{if}\;z \leq -2.3 \cdot 10^{+44}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 3.3 \cdot 10^{-83}:\\
\;\;\;\;1 + \frac{x \cdot 4}{y}\\

\mathbf{elif}\;z \leq 5400000000:\\
\;\;\;\;2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -2.30000000000000004e44 or 5.4e9 < z

    1. Initial program 100.0%

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

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

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

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

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

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

        \[\leadsto 1 + \color{blue}{\frac{4}{y} \cdot \left(-z\right)} \]
      6. *-commutative68.5%

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

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

        \[\leadsto 1 + \color{blue}{z \cdot \left(-\frac{4}{y}\right)} \]
      9. distribute-neg-frac68.5%

        \[\leadsto 1 + z \cdot \color{blue}{\frac{-4}{y}} \]
      10. metadata-eval68.5%

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

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

    if -2.30000000000000004e44 < z < 3.2999999999999999e-83

    1. Initial program 100.0%

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

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

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

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

    if 3.2999999999999999e-83 < z < 5.4e9

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.3 \cdot 10^{+44}:\\ \;\;\;\;1 + z \cdot \frac{-4}{y}\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-83}:\\ \;\;\;\;1 + \frac{x \cdot 4}{y}\\ \mathbf{elif}\;z \leq 5400000000:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;1 + z \cdot \frac{-4}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 57.6% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{z \cdot -4}{y} + 1\\ \mathbf{if}\;z \leq -2.5 \cdot 10^{-12}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{-83}:\\ \;\;\;\;1 + \frac{x \cdot 4}{y}\\ \mathbf{elif}\;z \leq 212000000:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ (/ (* z -4.0) y) 1.0)))
   (if (<= z -2.5e-12)
     t_0
     (if (<= z 4.8e-83)
       (+ 1.0 (/ (* x 4.0) y))
       (if (<= z 212000000.0) 2.0 t_0)))))
double code(double x, double y, double z) {
	double t_0 = ((z * -4.0) / y) + 1.0;
	double tmp;
	if (z <= -2.5e-12) {
		tmp = t_0;
	} else if (z <= 4.8e-83) {
		tmp = 1.0 + ((x * 4.0) / y);
	} else if (z <= 212000000.0) {
		tmp = 2.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 = ((z * (-4.0d0)) / y) + 1.0d0
    if (z <= (-2.5d-12)) then
        tmp = t_0
    else if (z <= 4.8d-83) then
        tmp = 1.0d0 + ((x * 4.0d0) / y)
    else if (z <= 212000000.0d0) then
        tmp = 2.0d0
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = ((z * -4.0) / y) + 1.0;
	double tmp;
	if (z <= -2.5e-12) {
		tmp = t_0;
	} else if (z <= 4.8e-83) {
		tmp = 1.0 + ((x * 4.0) / y);
	} else if (z <= 212000000.0) {
		tmp = 2.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = ((z * -4.0) / y) + 1.0
	tmp = 0
	if z <= -2.5e-12:
		tmp = t_0
	elif z <= 4.8e-83:
		tmp = 1.0 + ((x * 4.0) / y)
	elif z <= 212000000.0:
		tmp = 2.0
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(Float64(z * -4.0) / y) + 1.0)
	tmp = 0.0
	if (z <= -2.5e-12)
		tmp = t_0;
	elseif (z <= 4.8e-83)
		tmp = Float64(1.0 + Float64(Float64(x * 4.0) / y));
	elseif (z <= 212000000.0)
		tmp = 2.0;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = ((z * -4.0) / y) + 1.0;
	tmp = 0.0;
	if (z <= -2.5e-12)
		tmp = t_0;
	elseif (z <= 4.8e-83)
		tmp = 1.0 + ((x * 4.0) / y);
	elseif (z <= 212000000.0)
		tmp = 2.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[z, -2.5e-12], t$95$0, If[LessEqual[z, 4.8e-83], N[(1.0 + N[(N[(x * 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 212000000.0], 2.0, t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{z \cdot -4}{y} + 1\\
\mathbf{if}\;z \leq -2.5 \cdot 10^{-12}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 4.8 \cdot 10^{-83}:\\
\;\;\;\;1 + \frac{x \cdot 4}{y}\\

\mathbf{elif}\;z \leq 212000000:\\
\;\;\;\;2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -2.49999999999999985e-12 or 2.12e8 < z

    1. Initial program 100.0%

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

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

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

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

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

    if -2.49999999999999985e-12 < z < 4.8000000000000002e-83

    1. Initial program 100.0%

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

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

        \[\leadsto 1 + \color{blue}{\frac{4 \cdot x}{y}} \]
    5. Simplified61.8%

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

    if 4.8000000000000002e-83 < z < 2.12e8

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.5 \cdot 10^{-12}:\\ \;\;\;\;\frac{z \cdot -4}{y} + 1\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{-83}:\\ \;\;\;\;1 + \frac{x \cdot 4}{y}\\ \mathbf{elif}\;z \leq 212000000:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;\frac{z \cdot -4}{y} + 1\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 80.7% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.65 \cdot 10^{+74} \lor \neg \left(z \leq 1.1 \cdot 10^{+120}\right):\\
\;\;\;\;\frac{z \cdot -4}{y} + 1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.6500000000000001e74 or 1.1000000000000001e120 < z

    1. Initial program 100.0%

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

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

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

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

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

    if -1.6500000000000001e74 < z < 1.1000000000000001e120

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto \frac{4}{y} \cdot \color{blue}{\left(\left(x - z\right) + y \cdot 0.25\right)} + 1 \]
      6. distribute-lft-in99.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(x - z\right) + 2} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. *-commutative99.7%

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

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

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

        \[\leadsto \left(x - z\right) \cdot \frac{1}{y \cdot \color{blue}{0.25}} + 2 \]
      5. un-div-inv100.0%

        \[\leadsto \color{blue}{\frac{x - z}{y \cdot 0.25}} + 2 \]
    6. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\frac{x - z}{y \cdot 0.25}} + 2 \]
    7. Taylor expanded in x around inf 86.5%

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

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

Alternative 6: 85.3% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -8.4999999999999996e-10 or 5.1999999999999999e-34 < z

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto \frac{4}{y} \cdot \color{blue}{\left(\left(x - z\right) + y \cdot 0.25\right)} + 1 \]
      6. distribute-lft-in99.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(x - z\right) + 2} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. *-commutative99.7%

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

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

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

        \[\leadsto \left(x - z\right) \cdot \frac{1}{y \cdot \color{blue}{0.25}} + 2 \]
      5. un-div-inv100.0%

        \[\leadsto \color{blue}{\frac{x - z}{y \cdot 0.25}} + 2 \]
    6. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\frac{x - z}{y \cdot 0.25}} + 2 \]
    7. Taylor expanded in x around 0 83.5%

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

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

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

    if -8.4999999999999996e-10 < z < 5.1999999999999999e-34

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto \frac{4}{y} \cdot \color{blue}{\left(\left(x - z\right) + y \cdot 0.25\right)} + 1 \]
      6. distribute-lft-in99.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(x - z\right) + 2} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. *-commutative99.8%

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

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

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

        \[\leadsto \left(x - z\right) \cdot \frac{1}{y \cdot \color{blue}{0.25}} + 2 \]
      5. un-div-inv100.0%

        \[\leadsto \color{blue}{\frac{x - z}{y \cdot 0.25}} + 2 \]
    6. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\frac{x - z}{y \cdot 0.25}} + 2 \]
    7. Taylor expanded in x around inf 95.6%

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

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

Alternative 7: 54.4% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.8 \cdot 10^{+121}:\\
\;\;\;\;2\\

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

\mathbf{else}:\\
\;\;\;\;2\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5.7999999999999998e121 or 1.27999999999999997e125 < y

    1. Initial program 99.9%

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

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

    if -5.7999999999999998e121 < y < 1.27999999999999997e125

    1. Initial program 100.0%

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

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

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

        \[\leadsto 1 + \color{blue}{\frac{4}{y} \cdot x} \]
      3. *-commutative45.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.8 \cdot 10^{+121}:\\ \;\;\;\;2\\ \mathbf{elif}\;y \leq 1.28 \cdot 10^{+125}:\\ \;\;\;\;1 + x \cdot \frac{4}{y}\\ \mathbf{else}:\\ \;\;\;\;2\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 52.3% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.8 \cdot 10^{+121}:\\
\;\;\;\;2\\

\mathbf{elif}\;y \leq 3.7 \cdot 10^{-66}:\\
\;\;\;\;4 \cdot \frac{x}{y}\\

\mathbf{else}:\\
\;\;\;\;2\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5.7999999999999998e121 or 3.7000000000000002e-66 < y

    1. Initial program 100.0%

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

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

    if -5.7999999999999998e121 < y < 3.7000000000000002e-66

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto \frac{4}{y} \cdot \color{blue}{\left(\left(x - z\right) + y \cdot 0.25\right)} + 1 \]
      6. distribute-lft-in99.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{4}{y} \cdot \left(x - z\right) + 2} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. *-commutative99.7%

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

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

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

        \[\leadsto \left(x - z\right) \cdot \frac{1}{y \cdot \color{blue}{0.25}} + 2 \]
      5. un-div-inv100.0%

        \[\leadsto \color{blue}{\frac{x - z}{y \cdot 0.25}} + 2 \]
    6. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\frac{x - z}{y \cdot 0.25}} + 2 \]
    7. Taylor expanded in x around inf 56.7%

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

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

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

Alternative 9: 99.8% accurate, 1.4× speedup?

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

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

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

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

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

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

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

      \[\leadsto \frac{4}{y} \cdot \color{blue}{\left(\left(x - z\right) + y \cdot 0.25\right)} + 1 \]
    6. distribute-lft-in99.7%

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 8.2% accurate, 13.0× speedup?

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

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

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

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

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

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

      \[\leadsto 1 + \color{blue}{x \cdot \frac{4}{y}} \]
  5. Simplified40.3%

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

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

    \[\leadsto 1 \]
  8. Add Preprocessing

Alternative 11: 34.5% accurate, 13.0× speedup?

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

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

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

    \[\leadsto \color{blue}{2} \]
  4. Final simplification31.1%

    \[\leadsto 2 \]
  5. Add Preprocessing

Reproduce

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