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

Percentage Accurate: 99.9% → 99.9%
Time: 6.0s
Alternatives: 9
Speedup: 1.0×

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 9 alternatives:

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

Initial Program: 99.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: 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}
Derivation
  1. Initial program 100.0%

    \[1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} \]
  2. Final simplification100.0%

    \[\leadsto 1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} \]

Alternative 2: 58.5% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + z \cdot \frac{-4}{y}\\ t_1 := 1 + 4 \cdot \frac{x}{y}\\ \mathbf{if}\;x \leq -9.4 \cdot 10^{+80}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -4.5 \cdot 10^{-199}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -3.9 \cdot 10^{-278}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq 3.85 \cdot 10^{+43}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ 1.0 (* z (/ -4.0 y)))) (t_1 (+ 1.0 (* 4.0 (/ x y)))))
   (if (<= x -9.4e+80)
     t_1
     (if (<= x -4.5e-199)
       t_0
       (if (<= x -3.9e-278) 2.0 (if (<= x 3.85e+43) t_0 t_1))))))
double code(double x, double y, double z) {
	double t_0 = 1.0 + (z * (-4.0 / y));
	double t_1 = 1.0 + (4.0 * (x / y));
	double tmp;
	if (x <= -9.4e+80) {
		tmp = t_1;
	} else if (x <= -4.5e-199) {
		tmp = t_0;
	} else if (x <= -3.9e-278) {
		tmp = 2.0;
	} else if (x <= 3.85e+43) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 1.0d0 + (z * ((-4.0d0) / y))
    t_1 = 1.0d0 + (4.0d0 * (x / y))
    if (x <= (-9.4d+80)) then
        tmp = t_1
    else if (x <= (-4.5d-199)) then
        tmp = t_0
    else if (x <= (-3.9d-278)) then
        tmp = 2.0d0
    else if (x <= 3.85d+43) then
        tmp = t_0
    else
        tmp = t_1
    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 t_1 = 1.0 + (4.0 * (x / y));
	double tmp;
	if (x <= -9.4e+80) {
		tmp = t_1;
	} else if (x <= -4.5e-199) {
		tmp = t_0;
	} else if (x <= -3.9e-278) {
		tmp = 2.0;
	} else if (x <= 3.85e+43) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 1.0 + (z * (-4.0 / y))
	t_1 = 1.0 + (4.0 * (x / y))
	tmp = 0
	if x <= -9.4e+80:
		tmp = t_1
	elif x <= -4.5e-199:
		tmp = t_0
	elif x <= -3.9e-278:
		tmp = 2.0
	elif x <= 3.85e+43:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(1.0 + Float64(z * Float64(-4.0 / y)))
	t_1 = Float64(1.0 + Float64(4.0 * Float64(x / y)))
	tmp = 0.0
	if (x <= -9.4e+80)
		tmp = t_1;
	elseif (x <= -4.5e-199)
		tmp = t_0;
	elseif (x <= -3.9e-278)
		tmp = 2.0;
	elseif (x <= 3.85e+43)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 1.0 + (z * (-4.0 / y));
	t_1 = 1.0 + (4.0 * (x / y));
	tmp = 0.0;
	if (x <= -9.4e+80)
		tmp = t_1;
	elseif (x <= -4.5e-199)
		tmp = t_0;
	elseif (x <= -3.9e-278)
		tmp = 2.0;
	elseif (x <= 3.85e+43)
		tmp = t_0;
	else
		tmp = t_1;
	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]}, Block[{t$95$1 = N[(1.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -9.4e+80], t$95$1, If[LessEqual[x, -4.5e-199], t$95$0, If[LessEqual[x, -3.9e-278], 2.0, If[LessEqual[x, 3.85e+43], t$95$0, t$95$1]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -4.5 \cdot 10^{-199}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -3.9 \cdot 10^{-278}:\\
\;\;\;\;2\\

\mathbf{elif}\;x \leq 3.85 \cdot 10^{+43}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -9.40000000000000019e80 or 3.8499999999999998e43 < x

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

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

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

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

    if -9.40000000000000019e80 < x < -4.49999999999999998e-199 or -3.9000000000000001e-278 < x < 3.8499999999999998e43

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

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

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

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

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

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

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

        \[\leadsto 1 + -4 \cdot \color{blue}{\frac{1}{\frac{y}{z}}} \]
      3. un-div-inv60.7%

        \[\leadsto 1 + \color{blue}{\frac{-4}{\frac{y}{z}}} \]
    8. Applied egg-rr60.7%

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

        \[\leadsto 1 + \color{blue}{\frac{-4}{y} \cdot z} \]
    10. Applied egg-rr60.7%

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

    if -4.49999999999999998e-199 < x < -3.9000000000000001e-278

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 + \color{blue}{x \cdot \frac{4}{y}} \]
    8. Simplified68.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9.4 \cdot 10^{+80}:\\ \;\;\;\;1 + 4 \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq -4.5 \cdot 10^{-199}:\\ \;\;\;\;1 + z \cdot \frac{-4}{y}\\ \mathbf{elif}\;x \leq -3.9 \cdot 10^{-278}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq 3.85 \cdot 10^{+43}:\\ \;\;\;\;1 + z \cdot \frac{-4}{y}\\ \mathbf{else}:\\ \;\;\;\;1 + 4 \cdot \frac{x}{y}\\ \end{array} \]

Alternative 3: 58.5% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + -4 \cdot \frac{z}{y}\\ t_1 := 1 + 4 \cdot \frac{x}{y}\\ \mathbf{if}\;x \leq -1.1 \cdot 10^{+82}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.5 \cdot 10^{-194}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -9 \cdot 10^{-282}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq 2.75 \cdot 10^{+43}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ 1.0 (* -4.0 (/ z y)))) (t_1 (+ 1.0 (* 4.0 (/ x y)))))
   (if (<= x -1.1e+82)
     t_1
     (if (<= x -2.5e-194)
       t_0
       (if (<= x -9e-282) 2.0 (if (<= x 2.75e+43) t_0 t_1))))))
double code(double x, double y, double z) {
	double t_0 = 1.0 + (-4.0 * (z / y));
	double t_1 = 1.0 + (4.0 * (x / y));
	double tmp;
	if (x <= -1.1e+82) {
		tmp = t_1;
	} else if (x <= -2.5e-194) {
		tmp = t_0;
	} else if (x <= -9e-282) {
		tmp = 2.0;
	} else if (x <= 2.75e+43) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 1.0d0 + ((-4.0d0) * (z / y))
    t_1 = 1.0d0 + (4.0d0 * (x / y))
    if (x <= (-1.1d+82)) then
        tmp = t_1
    else if (x <= (-2.5d-194)) then
        tmp = t_0
    else if (x <= (-9d-282)) then
        tmp = 2.0d0
    else if (x <= 2.75d+43) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = 1.0 + (-4.0 * (z / y));
	double t_1 = 1.0 + (4.0 * (x / y));
	double tmp;
	if (x <= -1.1e+82) {
		tmp = t_1;
	} else if (x <= -2.5e-194) {
		tmp = t_0;
	} else if (x <= -9e-282) {
		tmp = 2.0;
	} else if (x <= 2.75e+43) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 1.0 + (-4.0 * (z / y))
	t_1 = 1.0 + (4.0 * (x / y))
	tmp = 0
	if x <= -1.1e+82:
		tmp = t_1
	elif x <= -2.5e-194:
		tmp = t_0
	elif x <= -9e-282:
		tmp = 2.0
	elif x <= 2.75e+43:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(1.0 + Float64(-4.0 * Float64(z / y)))
	t_1 = Float64(1.0 + Float64(4.0 * Float64(x / y)))
	tmp = 0.0
	if (x <= -1.1e+82)
		tmp = t_1;
	elseif (x <= -2.5e-194)
		tmp = t_0;
	elseif (x <= -9e-282)
		tmp = 2.0;
	elseif (x <= 2.75e+43)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 1.0 + (-4.0 * (z / y));
	t_1 = 1.0 + (4.0 * (x / y));
	tmp = 0.0;
	if (x <= -1.1e+82)
		tmp = t_1;
	elseif (x <= -2.5e-194)
		tmp = t_0;
	elseif (x <= -9e-282)
		tmp = 2.0;
	elseif (x <= 2.75e+43)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.1e+82], t$95$1, If[LessEqual[x, -2.5e-194], t$95$0, If[LessEqual[x, -9e-282], 2.0, If[LessEqual[x, 2.75e+43], t$95$0, t$95$1]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -2.5 \cdot 10^{-194}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -9 \cdot 10^{-282}:\\
\;\;\;\;2\\

\mathbf{elif}\;x \leq 2.75 \cdot 10^{+43}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.1000000000000001e82 or 2.74999999999999995e43 < x

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

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

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

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

    if -1.1000000000000001e82 < x < -2.5000000000000001e-194 or -9.00000000000000017e-282 < x < 2.74999999999999995e43

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

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

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

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

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

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

    if -2.5000000000000001e-194 < x < -9.00000000000000017e-282

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 + \color{blue}{x \cdot \frac{4}{y}} \]
    8. Simplified68.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.1 \cdot 10^{+82}:\\ \;\;\;\;1 + 4 \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq -2.5 \cdot 10^{-194}:\\ \;\;\;\;1 + -4 \cdot \frac{z}{y}\\ \mathbf{elif}\;x \leq -9 \cdot 10^{-282}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq 2.75 \cdot 10^{+43}:\\ \;\;\;\;1 + -4 \cdot \frac{z}{y}\\ \mathbf{else}:\\ \;\;\;\;1 + 4 \cdot \frac{x}{y}\\ \end{array} \]

Alternative 4: 55.4% accurate, 1.2× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -5.30000000000000015e76 or 2.2e52 < x

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

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

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

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

    if -5.30000000000000015e76 < x < 2.2e52

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

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

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

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

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

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

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

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

        \[\leadsto 2 + \color{blue}{\frac{4}{\frac{y}{x - z}}} \]
    5. Applied egg-rr99.8%

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

      \[\leadsto 2 + \color{blue}{4 \cdot \frac{x}{y}} \]
    7. Step-by-step derivation
      1. *-commutative50.5%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.3 \cdot 10^{+76} \lor \neg \left(x \leq 2.2 \cdot 10^{+52}\right):\\ \;\;\;\;1 + 4 \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;2\\ \end{array} \]

Alternative 5: 80.3% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.4 \cdot 10^{+127} \lor \neg \left(z \leq 3 \cdot 10^{+194}\right):\\
\;\;\;\;1 + -4 \cdot \frac{z}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.4000000000000001e127 or 3.0000000000000003e194 < 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. associate-/l*99.7%

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

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

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

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

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

    if -1.4000000000000001e127 < z < 3.0000000000000003e194

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

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

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

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

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

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

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

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

        \[\leadsto 2 + \color{blue}{\frac{4}{\frac{y}{x - z}}} \]
    5. Applied egg-rr99.8%

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

      \[\leadsto 2 + \color{blue}{4 \cdot \frac{x}{y}} \]
    7. Step-by-step derivation
      1. *-commutative82.5%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.4 \cdot 10^{+127} \lor \neg \left(z \leq 3 \cdot 10^{+194}\right):\\ \;\;\;\;1 + -4 \cdot \frac{z}{y}\\ \mathbf{else}:\\ \;\;\;\;2 + x \cdot \frac{4}{y}\\ \end{array} \]

Alternative 6: 86.6% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.25 \cdot 10^{+78} \lor \neg \left(x \leq 1.26 \cdot 10^{+44}\right):\\
\;\;\;\;2 + x \cdot \frac{4}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.24999999999999996e78 or 1.25999999999999996e44 < x

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

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

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

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

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

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

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

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

        \[\leadsto 2 + \color{blue}{\frac{4}{\frac{y}{x - z}}} \]
    5. Applied egg-rr99.7%

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

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

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

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

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

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

    if -1.24999999999999996e78 < x < 1.25999999999999996e44

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

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

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

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

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

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

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

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

        \[\leadsto 2 + \color{blue}{\frac{4}{\frac{y}{x - z}}} \]
    5. Applied egg-rr99.8%

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

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

        \[\leadsto 2 + \color{blue}{\frac{z}{y} \cdot -4} \]
      2. associate-/r/91.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.25 \cdot 10^{+78} \lor \neg \left(x \leq 1.26 \cdot 10^{+44}\right):\\ \;\;\;\;2 + x \cdot \frac{4}{y}\\ \mathbf{else}:\\ \;\;\;\;2 + \frac{z}{\frac{y}{-4}}\\ \end{array} \]

Alternative 7: 99.8% accurate, 1.4× speedup?

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

\\
2 + \frac{4}{y} \cdot \left(x - z\right)
\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. associate-*l/99.8%

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

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

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

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

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

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

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

Alternative 8: 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. Step-by-step derivation
    1. associate-/l*99.8%

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

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

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

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

    \[\leadsto 1 \]

Alternative 9: 34.6% 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. Step-by-step derivation
    1. associate-*l/99.8%

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

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

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

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

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

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

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

      \[\leadsto 2 + \color{blue}{\frac{4}{\frac{y}{x - z}}} \]
  5. Applied egg-rr99.8%

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

    \[\leadsto 2 + \color{blue}{4 \cdot \frac{x}{y}} \]
  7. Step-by-step derivation
    1. *-commutative67.9%

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

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

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

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

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

    \[\leadsto 2 \]

Reproduce

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