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

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

\\
4 \cdot \frac{x - z}{y} + 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.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 y around 0 100.0%

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

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

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

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

Alternative 2: 58.2% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -4 \cdot \frac{z}{y} + 1\\ t_1 := 1 + \frac{4}{\frac{y}{x}}\\ \mathbf{if}\;x \leq -6.6 \cdot 10^{-5}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.8 \cdot 10^{-275}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{-181}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq 1200:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ (* -4.0 (/ z y)) 1.0)) (t_1 (+ 1.0 (/ 4.0 (/ y x)))))
   (if (<= x -6.6e-5)
     t_1
     (if (<= x 5.8e-275)
       t_0
       (if (<= x 5.5e-181) 2.0 (if (<= x 1200.0) t_0 t_1))))))
double code(double x, double y, double z) {
	double t_0 = (-4.0 * (z / y)) + 1.0;
	double t_1 = 1.0 + (4.0 / (y / x));
	double tmp;
	if (x <= -6.6e-5) {
		tmp = t_1;
	} else if (x <= 5.8e-275) {
		tmp = t_0;
	} else if (x <= 5.5e-181) {
		tmp = 2.0;
	} else if (x <= 1200.0) {
		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 = ((-4.0d0) * (z / y)) + 1.0d0
    t_1 = 1.0d0 + (4.0d0 / (y / x))
    if (x <= (-6.6d-5)) then
        tmp = t_1
    else if (x <= 5.8d-275) then
        tmp = t_0
    else if (x <= 5.5d-181) then
        tmp = 2.0d0
    else if (x <= 1200.0d0) 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 = (-4.0 * (z / y)) + 1.0;
	double t_1 = 1.0 + (4.0 / (y / x));
	double tmp;
	if (x <= -6.6e-5) {
		tmp = t_1;
	} else if (x <= 5.8e-275) {
		tmp = t_0;
	} else if (x <= 5.5e-181) {
		tmp = 2.0;
	} else if (x <= 1200.0) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (-4.0 * (z / y)) + 1.0
	t_1 = 1.0 + (4.0 / (y / x))
	tmp = 0
	if x <= -6.6e-5:
		tmp = t_1
	elif x <= 5.8e-275:
		tmp = t_0
	elif x <= 5.5e-181:
		tmp = 2.0
	elif x <= 1200.0:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(-4.0 * Float64(z / y)) + 1.0)
	t_1 = Float64(1.0 + Float64(4.0 / Float64(y / x)))
	tmp = 0.0
	if (x <= -6.6e-5)
		tmp = t_1;
	elseif (x <= 5.8e-275)
		tmp = t_0;
	elseif (x <= 5.5e-181)
		tmp = 2.0;
	elseif (x <= 1200.0)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (-4.0 * (z / y)) + 1.0;
	t_1 = 1.0 + (4.0 / (y / x));
	tmp = 0.0;
	if (x <= -6.6e-5)
		tmp = t_1;
	elseif (x <= 5.8e-275)
		tmp = t_0;
	elseif (x <= 5.5e-181)
		tmp = 2.0;
	elseif (x <= 1200.0)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(4.0 / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -6.6e-5], t$95$1, If[LessEqual[x, 5.8e-275], t$95$0, If[LessEqual[x, 5.5e-181], 2.0, If[LessEqual[x, 1200.0], t$95$0, t$95$1]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 5.8 \cdot 10^{-275}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 5.5 \cdot 10^{-181}:\\
\;\;\;\;2\\

\mathbf{elif}\;x \leq 1200:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -6.6000000000000005e-5 or 1200 < 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 65.8%

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

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

        \[\leadsto 1 + \color{blue}{\frac{4}{\frac{y}{x}}} \]
    6. Simplified65.7%

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

    if -6.6000000000000005e-5 < x < 5.800000000000001e-275 or 5.50000000000000033e-181 < x < 1200

    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 63.3%

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

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

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

    if 5.800000000000001e-275 < x < 5.50000000000000033e-181

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.6 \cdot 10^{-5}:\\ \;\;\;\;1 + \frac{4}{\frac{y}{x}}\\ \mathbf{elif}\;x \leq 5.8 \cdot 10^{-275}:\\ \;\;\;\;-4 \cdot \frac{z}{y} + 1\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{-181}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq 1200:\\ \;\;\;\;-4 \cdot \frac{z}{y} + 1\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{4}{\frac{y}{x}}\\ \end{array} \]

Alternative 3: 58.3% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;x \leq 2.3 \cdot 10^{-270}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 7.2 \cdot 10^{-181}:\\
\;\;\;\;2\\

\mathbf{elif}\;x \leq 220:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.55e-6 or 220 < x

    1. Initial program 100.0%

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

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

    if -1.55e-6 < x < 2.3000000000000001e-270 or 7.1999999999999998e-181 < x < 220

    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 63.3%

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

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

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

    if 2.3000000000000001e-270 < x < 7.1999999999999998e-181

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.55 \cdot 10^{-6}:\\ \;\;\;\;1 + \frac{4 \cdot x}{y}\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-270}:\\ \;\;\;\;-4 \cdot \frac{z}{y} + 1\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{-181}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq 220:\\ \;\;\;\;-4 \cdot \frac{z}{y} + 1\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{4 \cdot x}{y}\\ \end{array} \]

Alternative 4: 54.8% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.9 \cdot 10^{-14} \lor \neg \left(z \leq 260000000\right):\\
\;\;\;\;-4 \cdot \frac{z}{y} + 1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.8999999999999998e-14 or 2.6e8 < 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 64.2%

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

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

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

    if -3.8999999999999998e-14 < z < 2.6e8

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

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

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

Alternative 5: 81.5% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.18 \cdot 10^{+107} \lor \neg \left(x \leq 3.8 \cdot 10^{+93}\right):\\
\;\;\;\;1 + \frac{4 \cdot x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.18000000000000005e107 or 3.7999999999999998e93 < x

    1. Initial program 100.0%

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

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

    if -1.18000000000000005e107 < x < 3.7999999999999998e93

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

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

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

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

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

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

Alternative 6: 85.8% accurate, 1.2× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -8.2000000000000004e-13 or 240 < 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 y around 0 100.0%

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

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

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

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

    if -8.2000000000000004e-13 < x < 240

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

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

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

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

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

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

Alternative 7: 53.3% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.15 \cdot 10^{+95} \lor \neg \left(z \leq 250000000\right):\\
\;\;\;\;z \cdot \frac{-4}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.15e95 or 2.5e8 < 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 y around 0 100.0%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-4 \cdot z}{y}} \]
      2. *-commutative68.1%

        \[\leadsto \frac{\color{blue}{z \cdot -4}}{y} \]
      3. associate-*r/67.9%

        \[\leadsto \color{blue}{z \cdot \frac{-4}{y}} \]
    10. Simplified67.9%

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

    if -2.15e95 < z < 2.5e8

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

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

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

Alternative 8: 53.4% accurate, 1.4× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.00000000000000002e95 or 7e7 < 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 y around 0 100.0%

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

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

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

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

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

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

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

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

    if -1.00000000000000002e95 < z < 7e7

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

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

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

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. 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.4%

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

      \[\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 + \left(x - z\right) \cdot \frac{4}{y} \]

Alternative 10: 33.0% 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.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 y around inf 30.3%

    \[\leadsto \color{blue}{2} \]
  5. Final simplification30.3%

    \[\leadsto 2 \]

Reproduce

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