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

Percentage Accurate: 99.8% → 99.9%
Time: 7.1s
Alternatives: 13
Speedup: 1.2×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 13 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.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 1.2× speedup?

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

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

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

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

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

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

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

Alternative 2: 86.1% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + \left(x - z\right) \cdot \frac{4}{y}\\ t_1 := 4 + -4 \cdot \frac{z}{y}\\ t_2 := 4 + 4 \cdot \frac{x}{y}\\ \mathbf{if}\;z \leq -1.2 \cdot 10^{+175}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq -3.5 \cdot 10^{-13}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq -2.55 \cdot 10^{-77}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;z \leq -2.1 \cdot 10^{-94}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 3.7 \cdot 10^{+37}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{+129}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ 1.0 (* (- x z) (/ 4.0 y))))
        (t_1 (+ 4.0 (* -4.0 (/ z y))))
        (t_2 (+ 4.0 (* 4.0 (/ x y)))))
   (if (<= z -1.2e+175)
     t_1
     (if (<= z -3.5e-13)
       t_0
       (if (<= z -2.55e-77)
         t_2
         (if (<= z -2.1e-94)
           t_0
           (if (<= z 3.7e+37) t_2 (if (<= z 3.5e+129) t_0 t_1))))))))
double code(double x, double y, double z) {
	double t_0 = 1.0 + ((x - z) * (4.0 / y));
	double t_1 = 4.0 + (-4.0 * (z / y));
	double t_2 = 4.0 + (4.0 * (x / y));
	double tmp;
	if (z <= -1.2e+175) {
		tmp = t_1;
	} else if (z <= -3.5e-13) {
		tmp = t_0;
	} else if (z <= -2.55e-77) {
		tmp = t_2;
	} else if (z <= -2.1e-94) {
		tmp = t_0;
	} else if (z <= 3.7e+37) {
		tmp = t_2;
	} else if (z <= 3.5e+129) {
		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) :: t_2
    real(8) :: tmp
    t_0 = 1.0d0 + ((x - z) * (4.0d0 / y))
    t_1 = 4.0d0 + ((-4.0d0) * (z / y))
    t_2 = 4.0d0 + (4.0d0 * (x / y))
    if (z <= (-1.2d+175)) then
        tmp = t_1
    else if (z <= (-3.5d-13)) then
        tmp = t_0
    else if (z <= (-2.55d-77)) then
        tmp = t_2
    else if (z <= (-2.1d-94)) then
        tmp = t_0
    else if (z <= 3.7d+37) then
        tmp = t_2
    else if (z <= 3.5d+129) 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 + ((x - z) * (4.0 / y));
	double t_1 = 4.0 + (-4.0 * (z / y));
	double t_2 = 4.0 + (4.0 * (x / y));
	double tmp;
	if (z <= -1.2e+175) {
		tmp = t_1;
	} else if (z <= -3.5e-13) {
		tmp = t_0;
	} else if (z <= -2.55e-77) {
		tmp = t_2;
	} else if (z <= -2.1e-94) {
		tmp = t_0;
	} else if (z <= 3.7e+37) {
		tmp = t_2;
	} else if (z <= 3.5e+129) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 1.0 + ((x - z) * (4.0 / y))
	t_1 = 4.0 + (-4.0 * (z / y))
	t_2 = 4.0 + (4.0 * (x / y))
	tmp = 0
	if z <= -1.2e+175:
		tmp = t_1
	elif z <= -3.5e-13:
		tmp = t_0
	elif z <= -2.55e-77:
		tmp = t_2
	elif z <= -2.1e-94:
		tmp = t_0
	elif z <= 3.7e+37:
		tmp = t_2
	elif z <= 3.5e+129:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(1.0 + Float64(Float64(x - z) * Float64(4.0 / y)))
	t_1 = Float64(4.0 + Float64(-4.0 * Float64(z / y)))
	t_2 = Float64(4.0 + Float64(4.0 * Float64(x / y)))
	tmp = 0.0
	if (z <= -1.2e+175)
		tmp = t_1;
	elseif (z <= -3.5e-13)
		tmp = t_0;
	elseif (z <= -2.55e-77)
		tmp = t_2;
	elseif (z <= -2.1e-94)
		tmp = t_0;
	elseif (z <= 3.7e+37)
		tmp = t_2;
	elseif (z <= 3.5e+129)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 1.0 + ((x - z) * (4.0 / y));
	t_1 = 4.0 + (-4.0 * (z / y));
	t_2 = 4.0 + (4.0 * (x / y));
	tmp = 0.0;
	if (z <= -1.2e+175)
		tmp = t_1;
	elseif (z <= -3.5e-13)
		tmp = t_0;
	elseif (z <= -2.55e-77)
		tmp = t_2;
	elseif (z <= -2.1e-94)
		tmp = t_0;
	elseif (z <= 3.7e+37)
		tmp = t_2;
	elseif (z <= 3.5e+129)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(4.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(4.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.2e+175], t$95$1, If[LessEqual[z, -3.5e-13], t$95$0, If[LessEqual[z, -2.55e-77], t$95$2, If[LessEqual[z, -2.1e-94], t$95$0, If[LessEqual[z, 3.7e+37], t$95$2, If[LessEqual[z, 3.5e+129], t$95$0, t$95$1]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 1 + \left(x - z\right) \cdot \frac{4}{y}\\
t_1 := 4 + -4 \cdot \frac{z}{y}\\
t_2 := 4 + 4 \cdot \frac{x}{y}\\
\mathbf{if}\;z \leq -1.2 \cdot 10^{+175}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq -3.5 \cdot 10^{-13}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq -2.55 \cdot 10^{-77}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;z \leq -2.1 \cdot 10^{-94}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 3.7 \cdot 10^{+37}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;z \leq 3.5 \cdot 10^{+129}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.2e175 or 3.4999999999999998e129 < z

    1. Initial program 99.9%

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

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

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

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

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

      \[\leadsto 1 + \left(\color{blue}{-4 \cdot \frac{z}{y}} + 3\right) \]
    7. Taylor expanded in z around 0 93.0%

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

    if -1.2e175 < z < -3.5000000000000002e-13 or -2.55000000000000016e-77 < z < -2.1000000000000001e-94 or 3.6999999999999999e37 < z < 3.4999999999999998e129

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    if -3.5000000000000002e-13 < z < -2.55000000000000016e-77 or -2.1000000000000001e-94 < z < 3.6999999999999999e37

    1. Initial program 99.9%

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

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

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

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

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

      \[\leadsto 1 + \left(\color{blue}{4 \cdot \frac{x}{y}} + 3\right) \]
    7. Step-by-step derivation
      1. associate-*r/92.1%

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

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

        \[\leadsto 1 + \left(\color{blue}{\frac{4}{\frac{y}{x}}} + 3\right) \]
    8. Simplified92.0%

      \[\leadsto 1 + \left(\color{blue}{\frac{4}{\frac{y}{x}}} + 3\right) \]
    9. Taylor expanded in y around inf 92.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.2 \cdot 10^{+175}:\\ \;\;\;\;4 + -4 \cdot \frac{z}{y}\\ \mathbf{elif}\;z \leq -3.5 \cdot 10^{-13}:\\ \;\;\;\;1 + \left(x - z\right) \cdot \frac{4}{y}\\ \mathbf{elif}\;z \leq -2.55 \cdot 10^{-77}:\\ \;\;\;\;4 + 4 \cdot \frac{x}{y}\\ \mathbf{elif}\;z \leq -2.1 \cdot 10^{-94}:\\ \;\;\;\;1 + \left(x - z\right) \cdot \frac{4}{y}\\ \mathbf{elif}\;z \leq 3.7 \cdot 10^{+37}:\\ \;\;\;\;4 + 4 \cdot \frac{x}{y}\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{+129}:\\ \;\;\;\;1 + \left(x - z\right) \cdot \frac{4}{y}\\ \mathbf{else}:\\ \;\;\;\;4 + -4 \cdot \frac{z}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 85.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.7 \cdot 10^{+134}:\\ \;\;\;\;4 + 4 \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq -3.4 \cdot 10^{-66} \lor \neg \left(x \leq 1.16 \cdot 10^{+27}\right) \land \left(x \leq 1.4 \cdot 10^{+60} \lor \neg \left(x \leq 1.5 \cdot 10^{+77}\right)\right):\\ \;\;\;\;1 + \frac{4 \cdot \left(x - z\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;4 + -4 \cdot \frac{z}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -2.7e+134)
   (+ 4.0 (* 4.0 (/ x y)))
   (if (or (<= x -3.4e-66)
           (and (not (<= x 1.16e+27))
                (or (<= x 1.4e+60) (not (<= x 1.5e+77)))))
     (+ 1.0 (/ (* 4.0 (- x z)) y))
     (+ 4.0 (* -4.0 (/ z y))))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -2.7e+134) {
		tmp = 4.0 + (4.0 * (x / y));
	} else if ((x <= -3.4e-66) || (!(x <= 1.16e+27) && ((x <= 1.4e+60) || !(x <= 1.5e+77)))) {
		tmp = 1.0 + ((4.0 * (x - z)) / y);
	} else {
		tmp = 4.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 <= (-2.7d+134)) then
        tmp = 4.0d0 + (4.0d0 * (x / y))
    else if ((x <= (-3.4d-66)) .or. (.not. (x <= 1.16d+27)) .and. (x <= 1.4d+60) .or. (.not. (x <= 1.5d+77))) then
        tmp = 1.0d0 + ((4.0d0 * (x - z)) / y)
    else
        tmp = 4.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 <= -2.7e+134) {
		tmp = 4.0 + (4.0 * (x / y));
	} else if ((x <= -3.4e-66) || (!(x <= 1.16e+27) && ((x <= 1.4e+60) || !(x <= 1.5e+77)))) {
		tmp = 1.0 + ((4.0 * (x - z)) / y);
	} else {
		tmp = 4.0 + (-4.0 * (z / y));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -2.7e+134:
		tmp = 4.0 + (4.0 * (x / y))
	elif (x <= -3.4e-66) or (not (x <= 1.16e+27) and ((x <= 1.4e+60) or not (x <= 1.5e+77))):
		tmp = 1.0 + ((4.0 * (x - z)) / y)
	else:
		tmp = 4.0 + (-4.0 * (z / y))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -2.7e+134)
		tmp = Float64(4.0 + Float64(4.0 * Float64(x / y)));
	elseif ((x <= -3.4e-66) || (!(x <= 1.16e+27) && ((x <= 1.4e+60) || !(x <= 1.5e+77))))
		tmp = Float64(1.0 + Float64(Float64(4.0 * Float64(x - z)) / y));
	else
		tmp = Float64(4.0 + Float64(-4.0 * Float64(z / y)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -2.7e+134)
		tmp = 4.0 + (4.0 * (x / y));
	elseif ((x <= -3.4e-66) || (~((x <= 1.16e+27)) && ((x <= 1.4e+60) || ~((x <= 1.5e+77)))))
		tmp = 1.0 + ((4.0 * (x - z)) / y);
	else
		tmp = 4.0 + (-4.0 * (z / y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -2.7e+134], N[(4.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, -3.4e-66], And[N[Not[LessEqual[x, 1.16e+27]], $MachinePrecision], Or[LessEqual[x, 1.4e+60], N[Not[LessEqual[x, 1.5e+77]], $MachinePrecision]]]], N[(1.0 + N[(N[(4.0 * N[(x - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{+134}:\\
\;\;\;\;4 + 4 \cdot \frac{x}{y}\\

\mathbf{elif}\;x \leq -3.4 \cdot 10^{-66} \lor \neg \left(x \leq 1.16 \cdot 10^{+27}\right) \land \left(x \leq 1.4 \cdot 10^{+60} \lor \neg \left(x \leq 1.5 \cdot 10^{+77}\right)\right):\\
\;\;\;\;1 + \frac{4 \cdot \left(x - z\right)}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.7e134

    1. Initial program 100.0%

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

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

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

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

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

      \[\leadsto 1 + \left(\color{blue}{4 \cdot \frac{x}{y}} + 3\right) \]
    7. Step-by-step derivation
      1. associate-*r/93.0%

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

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

        \[\leadsto 1 + \left(\color{blue}{\frac{4}{\frac{y}{x}}} + 3\right) \]
    8. Simplified92.9%

      \[\leadsto 1 + \left(\color{blue}{\frac{4}{\frac{y}{x}}} + 3\right) \]
    9. Taylor expanded in y around inf 93.0%

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

    if -2.7e134 < x < -3.39999999999999997e-66 or 1.16e27 < x < 1.4e60 or 1.4999999999999999e77 < x

    1. Initial program 99.9%

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

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

    if -3.39999999999999997e-66 < x < 1.16e27 or 1.4e60 < x < 1.4999999999999999e77

    1. Initial program 99.9%

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

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

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

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

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

      \[\leadsto 1 + \left(\color{blue}{-4 \cdot \frac{z}{y}} + 3\right) \]
    7. Taylor expanded in z around 0 92.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.7 \cdot 10^{+134}:\\ \;\;\;\;4 + 4 \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq -3.4 \cdot 10^{-66} \lor \neg \left(x \leq 1.16 \cdot 10^{+27}\right) \land \left(x \leq 1.4 \cdot 10^{+60} \lor \neg \left(x \leq 1.5 \cdot 10^{+77}\right)\right):\\ \;\;\;\;1 + \frac{4 \cdot \left(x - z\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;4 + -4 \cdot \frac{z}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 86.6% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.5 \cdot 10^{+68} \lor \neg \left(z \leq -4.8 \cdot 10^{-6} \lor \neg \left(z \leq -2.85 \cdot 10^{-15}\right) \land z \leq 1.35 \cdot 10^{+29}\right):\\
\;\;\;\;4 + -4 \cdot \frac{z}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.49999999999999977e68 or -4.7999999999999998e-6 < z < -2.8500000000000002e-15 or 1.35e29 < z

    1. Initial program 99.9%

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

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

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

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

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

      \[\leadsto 1 + \left(\color{blue}{-4 \cdot \frac{z}{y}} + 3\right) \]
    7. Taylor expanded in z around 0 85.5%

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

    if -3.49999999999999977e68 < z < -4.7999999999999998e-6 or -2.8500000000000002e-15 < z < 1.35e29

    1. Initial program 99.9%

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

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

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

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

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

      \[\leadsto 1 + \left(\color{blue}{4 \cdot \frac{x}{y}} + 3\right) \]
    7. Step-by-step derivation
      1. associate-*r/88.7%

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

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

        \[\leadsto 1 + \left(\color{blue}{\frac{4}{\frac{y}{x}}} + 3\right) \]
    8. Simplified88.6%

      \[\leadsto 1 + \left(\color{blue}{\frac{4}{\frac{y}{x}}} + 3\right) \]
    9. Taylor expanded in y around inf 88.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.5 \cdot 10^{+68} \lor \neg \left(z \leq -4.8 \cdot 10^{-6} \lor \neg \left(z \leq -2.85 \cdot 10^{-15}\right) \land z \leq 1.35 \cdot 10^{+29}\right):\\ \;\;\;\;4 + -4 \cdot \frac{z}{y}\\ \mathbf{else}:\\ \;\;\;\;4 + 4 \cdot \frac{x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 53.7% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.42 \cdot 10^{-9} \lor \neg \left(z \leq -2.15 \cdot 10^{-77} \lor \neg \left(z \leq -2.4 \cdot 10^{-111}\right) \land z \leq 3.5 \cdot 10^{+15}\right):\\
\;\;\;\;1 + z \cdot \frac{-4}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.4200000000000001e-9 or -2.1500000000000001e-77 < z < -2.4000000000000001e-111 or 3.5e15 < z

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.4200000000000001e-9 < z < -2.1500000000000001e-77 or -2.4000000000000001e-111 < z < 3.5e15

    1. Initial program 99.9%

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

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

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

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

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

      \[\leadsto 1 + \left(\color{blue}{-4 \cdot \frac{z}{y}} + 3\right) \]
    7. Taylor expanded in z around 0 46.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.42 \cdot 10^{-9} \lor \neg \left(z \leq -2.15 \cdot 10^{-77} \lor \neg \left(z \leq -2.4 \cdot 10^{-111}\right) \land z \leq 3.5 \cdot 10^{+15}\right):\\ \;\;\;\;1 + z \cdot \frac{-4}{y}\\ \mathbf{else}:\\ \;\;\;\;4\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 52.0% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.2 \cdot 10^{-14} \lor \neg \left(z \leq -2.25 \cdot 10^{-76} \lor \neg \left(z \leq -2.45 \cdot 10^{-113}\right) \land z \leq 4.7 \cdot 10^{+16}\right):\\
\;\;\;\;\frac{z \cdot -4}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -7.1999999999999996e-14 or -2.25e-76 < z < -2.4500000000000001e-113 or 4.7e16 < z

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if -7.1999999999999996e-14 < z < -2.25e-76 or -2.4500000000000001e-113 < z < 4.7e16

    1. Initial program 99.9%

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

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

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

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

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

      \[\leadsto 1 + \left(\color{blue}{-4 \cdot \frac{z}{y}} + 3\right) \]
    7. Taylor expanded in z around 0 46.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7.2 \cdot 10^{-14} \lor \neg \left(z \leq -2.25 \cdot 10^{-76} \lor \neg \left(z \leq -2.45 \cdot 10^{-113}\right) \land z \leq 4.7 \cdot 10^{+16}\right):\\ \;\;\;\;\frac{z \cdot -4}{y}\\ \mathbf{else}:\\ \;\;\;\;4\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 52.2% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.2 \cdot 10^{-8} \lor \neg \left(z \leq -1.7 \cdot 10^{-76}\right) \land \left(z \leq -6.9 \cdot 10^{-110} \lor \neg \left(z \leq 26000000000000\right)\right):\\
\;\;\;\;z \cdot \frac{-4}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.1999999999999998e-8 or -1.7e-76 < z < -6.9000000000000004e-110 or 2.6e13 < z

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    if -2.1999999999999998e-8 < z < -1.7e-76 or -6.9000000000000004e-110 < z < 2.6e13

    1. Initial program 99.9%

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

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

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

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

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

      \[\leadsto 1 + \left(\color{blue}{-4 \cdot \frac{z}{y}} + 3\right) \]
    7. Taylor expanded in z around 0 45.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.2 \cdot 10^{-8} \lor \neg \left(z \leq -1.7 \cdot 10^{-76}\right) \land \left(z \leq -6.9 \cdot 10^{-110} \lor \neg \left(z \leq 26000000000000\right)\right):\\ \;\;\;\;z \cdot \frac{-4}{y}\\ \mathbf{else}:\\ \;\;\;\;4\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 52.2% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.6 \cdot 10^{-9}:\\
\;\;\;\;z \cdot \frac{-4}{y}\\

\mathbf{elif}\;z \leq -1.55 \cdot 10^{-75}:\\
\;\;\;\;4\\

\mathbf{elif}\;z \leq -5.5 \cdot 10^{-110} \lor \neg \left(z \leq 9 \cdot 10^{+14}\right):\\
\;\;\;\;\frac{-4}{\frac{y}{z}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -7.60000000000000023e-9

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    if -7.60000000000000023e-9 < z < -1.55000000000000003e-75 or -5.4999999999999998e-110 < z < 9e14

    1. Initial program 99.9%

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

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

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

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

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

      \[\leadsto 1 + \left(\color{blue}{-4 \cdot \frac{z}{y}} + 3\right) \]
    7. Taylor expanded in z around 0 45.5%

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

    if -1.55000000000000003e-75 < z < -5.4999999999999998e-110 or 9e14 < z

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -4 \cdot \color{blue}{\frac{1}{\frac{y}{z}}} \]
      5. un-div-inv55.9%

        \[\leadsto \color{blue}{\frac{-4}{\frac{y}{z}}} \]
    11. Applied egg-rr55.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7.6 \cdot 10^{-9}:\\ \;\;\;\;z \cdot \frac{-4}{y}\\ \mathbf{elif}\;z \leq -1.55 \cdot 10^{-75}:\\ \;\;\;\;4\\ \mathbf{elif}\;z \leq -5.5 \cdot 10^{-110} \lor \neg \left(z \leq 9 \cdot 10^{+14}\right):\\ \;\;\;\;\frac{-4}{\frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;4\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 79.3% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.02 \cdot 10^{+234} \lor \neg \left(x \leq 3 \cdot 10^{+87}\right):\\
\;\;\;\;1 + 4 \cdot \frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.02000000000000002e234 or 2.9999999999999999e87 < x

    1. Initial program 99.9%

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

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

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

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

    if -1.02000000000000002e234 < x < 2.9999999999999999e87

    1. Initial program 99.9%

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

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

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

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

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

      \[\leadsto 1 + \left(\color{blue}{-4 \cdot \frac{z}{y}} + 3\right) \]
    7. Taylor expanded in z around 0 80.7%

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

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

Alternative 10: 57.7% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.7e12 or 5.6999999999999996e-22 < x

    1. Initial program 100.0%

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

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

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

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

    if -1.7e12 < x < 5.6999999999999996e-22

    1. Initial program 99.9%

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

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

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

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

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

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

Alternative 11: 57.6% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1900000000000 \lor \neg \left(x \leq 1.12 \cdot 10^{-27}\right):\\
\;\;\;\;1 + 4 \cdot \frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.9e12 or 1.1199999999999999e-27 < x

    1. Initial program 100.0%

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

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

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

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

    if -1.9e12 < x < 1.1199999999999999e-27

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 34.8% accurate, 13.0× speedup?

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

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

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

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

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

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

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

    \[\leadsto 1 + \left(\color{blue}{-4 \cdot \frac{z}{y}} + 3\right) \]
  7. Taylor expanded in z around 0 31.5%

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

Alternative 13: 7.7% accurate, 13.0× speedup?

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

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

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

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

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

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

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

Reproduce

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