Language.Haskell.HsColour.ColourHighlight:unbase from hscolour-1.23

Percentage Accurate: 99.9% → 99.9%
Time: 4.7s
Alternatives: 7
Speedup: 1.0×

Specification

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

\\
\left(x \cdot y + z\right) \cdot y + t
\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 7 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} \\ \left(x \cdot y + z\right) \cdot y + t \end{array} \]
(FPCore (x y z t) :precision binary64 (+ (* (+ (* x y) z) y) t))
double code(double x, double y, double z, double t) {
	return (((x * y) + z) * y) + t;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = (((x * y) + z) * y) + t
end function
public static double code(double x, double y, double z, double t) {
	return (((x * y) + z) * y) + t;
}
def code(x, y, z, t):
	return (((x * y) + z) * y) + t
function code(x, y, z, t)
	return Float64(Float64(Float64(Float64(x * y) + z) * y) + t)
end
function tmp = code(x, y, z, t)
	tmp = (((x * y) + z) * y) + t;
end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * y), $MachinePrecision] + z), $MachinePrecision] * y), $MachinePrecision] + t), $MachinePrecision]
\begin{array}{l}

\\
\left(x \cdot y + z\right) \cdot y + t
\end{array}

Alternative 1: 99.9% accurate, 1.0× speedup?

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

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

    \[\left(x \cdot y + z\right) \cdot y + t \]
  2. Final simplification99.9%

    \[\leadsto t + y \cdot \left(z + x \cdot y\right) \]

Alternative 2: 63.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \left(y \cdot y\right)\\ \mathbf{if}\;y \leq -2 \cdot 10^{+71}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -8.2 \cdot 10^{+39}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq -3.5 \cdot 10^{-19}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.9 \cdot 10^{-108}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-89}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 2.25 \cdot 10^{-13}:\\ \;\;\;\;t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (* y y))))
   (if (<= y -2e+71)
     t_1
     (if (<= y -8.2e+39)
       (* y z)
       (if (<= y -3.5e-19)
         t_1
         (if (<= y 4.9e-108)
           t
           (if (<= y 1.1e-89) (* y z) (if (<= y 2.25e-13) t t_1))))))))
double code(double x, double y, double z, double t) {
	double t_1 = x * (y * y);
	double tmp;
	if (y <= -2e+71) {
		tmp = t_1;
	} else if (y <= -8.2e+39) {
		tmp = y * z;
	} else if (y <= -3.5e-19) {
		tmp = t_1;
	} else if (y <= 4.9e-108) {
		tmp = t;
	} else if (y <= 1.1e-89) {
		tmp = y * z;
	} else if (y <= 2.25e-13) {
		tmp = t;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: tmp
    t_1 = x * (y * y)
    if (y <= (-2d+71)) then
        tmp = t_1
    else if (y <= (-8.2d+39)) then
        tmp = y * z
    else if (y <= (-3.5d-19)) then
        tmp = t_1
    else if (y <= 4.9d-108) then
        tmp = t
    else if (y <= 1.1d-89) then
        tmp = y * z
    else if (y <= 2.25d-13) then
        tmp = t
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = x * (y * y);
	double tmp;
	if (y <= -2e+71) {
		tmp = t_1;
	} else if (y <= -8.2e+39) {
		tmp = y * z;
	} else if (y <= -3.5e-19) {
		tmp = t_1;
	} else if (y <= 4.9e-108) {
		tmp = t;
	} else if (y <= 1.1e-89) {
		tmp = y * z;
	} else if (y <= 2.25e-13) {
		tmp = t;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x * (y * y)
	tmp = 0
	if y <= -2e+71:
		tmp = t_1
	elif y <= -8.2e+39:
		tmp = y * z
	elif y <= -3.5e-19:
		tmp = t_1
	elif y <= 4.9e-108:
		tmp = t
	elif y <= 1.1e-89:
		tmp = y * z
	elif y <= 2.25e-13:
		tmp = t
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x * Float64(y * y))
	tmp = 0.0
	if (y <= -2e+71)
		tmp = t_1;
	elseif (y <= -8.2e+39)
		tmp = Float64(y * z);
	elseif (y <= -3.5e-19)
		tmp = t_1;
	elseif (y <= 4.9e-108)
		tmp = t;
	elseif (y <= 1.1e-89)
		tmp = Float64(y * z);
	elseif (y <= 2.25e-13)
		tmp = t;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x * (y * y);
	tmp = 0.0;
	if (y <= -2e+71)
		tmp = t_1;
	elseif (y <= -8.2e+39)
		tmp = y * z;
	elseif (y <= -3.5e-19)
		tmp = t_1;
	elseif (y <= 4.9e-108)
		tmp = t;
	elseif (y <= 1.1e-89)
		tmp = y * z;
	elseif (y <= 2.25e-13)
		tmp = t;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[(y * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2e+71], t$95$1, If[LessEqual[y, -8.2e+39], N[(y * z), $MachinePrecision], If[LessEqual[y, -3.5e-19], t$95$1, If[LessEqual[y, 4.9e-108], t, If[LessEqual[y, 1.1e-89], N[(y * z), $MachinePrecision], If[LessEqual[y, 2.25e-13], t, t$95$1]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \left(y \cdot y\right)\\
\mathbf{if}\;y \leq -2 \cdot 10^{+71}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq -8.2 \cdot 10^{+39}:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;y \leq -3.5 \cdot 10^{-19}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 4.9 \cdot 10^{-108}:\\
\;\;\;\;t\\

\mathbf{elif}\;y \leq 1.1 \cdot 10^{-89}:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;y \leq 2.25 \cdot 10^{-13}:\\
\;\;\;\;t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.0000000000000001e71 or -8.20000000000000008e39 < y < -3.50000000000000015e-19 or 2.25e-13 < y

    1. Initial program 99.9%

      \[\left(x \cdot y + z\right) \cdot y + t \]
    2. Taylor expanded in t around 0 90.9%

      \[\leadsto \color{blue}{\left(y \cdot x + z\right) \cdot y} \]
    3. Taylor expanded in y around inf 71.0%

      \[\leadsto \color{blue}{\left(y \cdot x\right)} \cdot y \]
    4. Taylor expanded in y around 0 69.4%

      \[\leadsto \color{blue}{{y}^{2} \cdot x} \]
    5. Step-by-step derivation
      1. unpow269.4%

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

        \[\leadsto \color{blue}{x \cdot \left(y \cdot y\right)} \]
    6. Simplified69.4%

      \[\leadsto \color{blue}{x \cdot \left(y \cdot y\right)} \]

    if -2.0000000000000001e71 < y < -8.20000000000000008e39 or 4.8999999999999998e-108 < y < 1.10000000000000006e-89

    1. Initial program 100.0%

      \[\left(x \cdot y + z\right) \cdot y + t \]
    2. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{z} \cdot y + t \]
    3. Taylor expanded in z around inf 100.0%

      \[\leadsto \color{blue}{y \cdot z} \]

    if -3.50000000000000015e-19 < y < 4.8999999999999998e-108 or 1.10000000000000006e-89 < y < 2.25e-13

    1. Initial program 99.9%

      \[\left(x \cdot y + z\right) \cdot y + t \]
    2. Taylor expanded in y around 0 71.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{+71}:\\ \;\;\;\;x \cdot \left(y \cdot y\right)\\ \mathbf{elif}\;y \leq -8.2 \cdot 10^{+39}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq -3.5 \cdot 10^{-19}:\\ \;\;\;\;x \cdot \left(y \cdot y\right)\\ \mathbf{elif}\;y \leq 4.9 \cdot 10^{-108}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-89}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 2.25 \cdot 10^{-13}:\\ \;\;\;\;t\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot y\right)\\ \end{array} \]

Alternative 3: 65.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := y \cdot \left(x \cdot y\right)\\ \mathbf{if}\;y \leq -5.1 \cdot 10^{+73}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -5.9 \cdot 10^{+38}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq -4.5 \cdot 10^{-19}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.9 \cdot 10^{-108}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-91}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 3.1 \cdot 10^{-13}:\\ \;\;\;\;t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* y (* x y))))
   (if (<= y -5.1e+73)
     t_1
     (if (<= y -5.9e+38)
       (* y z)
       (if (<= y -4.5e-19)
         t_1
         (if (<= y 4.9e-108)
           t
           (if (<= y 4.2e-91) (* y z) (if (<= y 3.1e-13) t t_1))))))))
double code(double x, double y, double z, double t) {
	double t_1 = y * (x * y);
	double tmp;
	if (y <= -5.1e+73) {
		tmp = t_1;
	} else if (y <= -5.9e+38) {
		tmp = y * z;
	} else if (y <= -4.5e-19) {
		tmp = t_1;
	} else if (y <= 4.9e-108) {
		tmp = t;
	} else if (y <= 4.2e-91) {
		tmp = y * z;
	} else if (y <= 3.1e-13) {
		tmp = t;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: tmp
    t_1 = y * (x * y)
    if (y <= (-5.1d+73)) then
        tmp = t_1
    else if (y <= (-5.9d+38)) then
        tmp = y * z
    else if (y <= (-4.5d-19)) then
        tmp = t_1
    else if (y <= 4.9d-108) then
        tmp = t
    else if (y <= 4.2d-91) then
        tmp = y * z
    else if (y <= 3.1d-13) then
        tmp = t
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = y * (x * y);
	double tmp;
	if (y <= -5.1e+73) {
		tmp = t_1;
	} else if (y <= -5.9e+38) {
		tmp = y * z;
	} else if (y <= -4.5e-19) {
		tmp = t_1;
	} else if (y <= 4.9e-108) {
		tmp = t;
	} else if (y <= 4.2e-91) {
		tmp = y * z;
	} else if (y <= 3.1e-13) {
		tmp = t;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = y * (x * y)
	tmp = 0
	if y <= -5.1e+73:
		tmp = t_1
	elif y <= -5.9e+38:
		tmp = y * z
	elif y <= -4.5e-19:
		tmp = t_1
	elif y <= 4.9e-108:
		tmp = t
	elif y <= 4.2e-91:
		tmp = y * z
	elif y <= 3.1e-13:
		tmp = t
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(y * Float64(x * y))
	tmp = 0.0
	if (y <= -5.1e+73)
		tmp = t_1;
	elseif (y <= -5.9e+38)
		tmp = Float64(y * z);
	elseif (y <= -4.5e-19)
		tmp = t_1;
	elseif (y <= 4.9e-108)
		tmp = t;
	elseif (y <= 4.2e-91)
		tmp = Float64(y * z);
	elseif (y <= 3.1e-13)
		tmp = t;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = y * (x * y);
	tmp = 0.0;
	if (y <= -5.1e+73)
		tmp = t_1;
	elseif (y <= -5.9e+38)
		tmp = y * z;
	elseif (y <= -4.5e-19)
		tmp = t_1;
	elseif (y <= 4.9e-108)
		tmp = t;
	elseif (y <= 4.2e-91)
		tmp = y * z;
	elseif (y <= 3.1e-13)
		tmp = t;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5.1e+73], t$95$1, If[LessEqual[y, -5.9e+38], N[(y * z), $MachinePrecision], If[LessEqual[y, -4.5e-19], t$95$1, If[LessEqual[y, 4.9e-108], t, If[LessEqual[y, 4.2e-91], N[(y * z), $MachinePrecision], If[LessEqual[y, 3.1e-13], t, t$95$1]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := y \cdot \left(x \cdot y\right)\\
\mathbf{if}\;y \leq -5.1 \cdot 10^{+73}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq -5.9 \cdot 10^{+38}:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;y \leq -4.5 \cdot 10^{-19}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 4.9 \cdot 10^{-108}:\\
\;\;\;\;t\\

\mathbf{elif}\;y \leq 4.2 \cdot 10^{-91}:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;y \leq 3.1 \cdot 10^{-13}:\\
\;\;\;\;t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -5.10000000000000024e73 or -5.89999999999999981e38 < y < -4.50000000000000013e-19 or 3.0999999999999999e-13 < y

    1. Initial program 99.9%

      \[\left(x \cdot y + z\right) \cdot y + t \]
    2. Taylor expanded in t around 0 90.9%

      \[\leadsto \color{blue}{\left(y \cdot x + z\right) \cdot y} \]
    3. Taylor expanded in y around inf 71.0%

      \[\leadsto \color{blue}{\left(y \cdot x\right)} \cdot y \]

    if -5.10000000000000024e73 < y < -5.89999999999999981e38 or 4.8999999999999998e-108 < y < 4.1999999999999998e-91

    1. Initial program 100.0%

      \[\left(x \cdot y + z\right) \cdot y + t \]
    2. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{z} \cdot y + t \]
    3. Taylor expanded in z around inf 100.0%

      \[\leadsto \color{blue}{y \cdot z} \]

    if -4.50000000000000013e-19 < y < 4.8999999999999998e-108 or 4.1999999999999998e-91 < y < 3.0999999999999999e-13

    1. Initial program 99.9%

      \[\left(x \cdot y + z\right) \cdot y + t \]
    2. Taylor expanded in y around 0 71.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.1 \cdot 10^{+73}:\\ \;\;\;\;y \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;y \leq -5.9 \cdot 10^{+38}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq -4.5 \cdot 10^{-19}:\\ \;\;\;\;y \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;y \leq 4.9 \cdot 10^{-108}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-91}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 3.1 \cdot 10^{-13}:\\ \;\;\;\;t\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(x \cdot y\right)\\ \end{array} \]

Alternative 4: 78.1% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.1 \cdot 10^{+71} \lor \neg \left(y \leq 6.4 \cdot 10^{+43}\right) \land \left(y \leq 1.65 \cdot 10^{+90} \lor \neg \left(y \leq 1.16 \cdot 10^{+175}\right)\right):\\ \;\;\;\;y \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t + y \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= y -2.1e+71)
         (and (not (<= y 6.4e+43))
              (or (<= y 1.65e+90) (not (<= y 1.16e+175)))))
   (* y (* x y))
   (+ t (* y z))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((y <= -2.1e+71) || (!(y <= 6.4e+43) && ((y <= 1.65e+90) || !(y <= 1.16e+175)))) {
		tmp = y * (x * y);
	} else {
		tmp = t + (y * z);
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((y <= (-2.1d+71)) .or. (.not. (y <= 6.4d+43)) .and. (y <= 1.65d+90) .or. (.not. (y <= 1.16d+175))) then
        tmp = y * (x * y)
    else
        tmp = t + (y * z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((y <= -2.1e+71) || (!(y <= 6.4e+43) && ((y <= 1.65e+90) || !(y <= 1.16e+175)))) {
		tmp = y * (x * y);
	} else {
		tmp = t + (y * z);
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (y <= -2.1e+71) or (not (y <= 6.4e+43) and ((y <= 1.65e+90) or not (y <= 1.16e+175))):
		tmp = y * (x * y)
	else:
		tmp = t + (y * z)
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((y <= -2.1e+71) || (!(y <= 6.4e+43) && ((y <= 1.65e+90) || !(y <= 1.16e+175))))
		tmp = Float64(y * Float64(x * y));
	else
		tmp = Float64(t + Float64(y * z));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((y <= -2.1e+71) || (~((y <= 6.4e+43)) && ((y <= 1.65e+90) || ~((y <= 1.16e+175)))))
		tmp = y * (x * y);
	else
		tmp = t + (y * z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -2.1e+71], And[N[Not[LessEqual[y, 6.4e+43]], $MachinePrecision], Or[LessEqual[y, 1.65e+90], N[Not[LessEqual[y, 1.16e+175]], $MachinePrecision]]]], N[(y * N[(x * y), $MachinePrecision]), $MachinePrecision], N[(t + N[(y * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.1 \cdot 10^{+71} \lor \neg \left(y \leq 6.4 \cdot 10^{+43}\right) \land \left(y \leq 1.65 \cdot 10^{+90} \lor \neg \left(y \leq 1.16 \cdot 10^{+175}\right)\right):\\
\;\;\;\;y \cdot \left(x \cdot y\right)\\

\mathbf{else}:\\
\;\;\;\;t + y \cdot z\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.09999999999999989e71 or 6.40000000000000029e43 < y < 1.65000000000000004e90 or 1.16e175 < y

    1. Initial program 99.9%

      \[\left(x \cdot y + z\right) \cdot y + t \]
    2. Taylor expanded in t around 0 98.6%

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

      \[\leadsto \color{blue}{\left(y \cdot x\right)} \cdot y \]

    if -2.09999999999999989e71 < y < 6.40000000000000029e43 or 1.65000000000000004e90 < y < 1.16e175

    1. Initial program 99.9%

      \[\left(x \cdot y + z\right) \cdot y + t \]
    2. Taylor expanded in x around 0 81.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.1 \cdot 10^{+71} \lor \neg \left(y \leq 6.4 \cdot 10^{+43}\right) \land \left(y \leq 1.65 \cdot 10^{+90} \lor \neg \left(y \leq 1.16 \cdot 10^{+175}\right)\right):\\ \;\;\;\;y \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t + y \cdot z\\ \end{array} \]

Alternative 5: 89.4% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3 \cdot 10^{-25} \lor \neg \left(y \leq 7.5 \cdot 10^{-13}\right):\\
\;\;\;\;y \cdot \left(z + x \cdot y\right)\\

\mathbf{else}:\\
\;\;\;\;t + y \cdot z\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.9999999999999998e-25 or 7.5000000000000004e-13 < y

    1. Initial program 99.9%

      \[\left(x \cdot y + z\right) \cdot y + t \]
    2. Taylor expanded in t around 0 90.8%

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

    if -2.9999999999999998e-25 < y < 7.5000000000000004e-13

    1. Initial program 100.0%

      \[\left(x \cdot y + z\right) \cdot y + t \]
    2. Taylor expanded in x around 0 92.3%

      \[\leadsto \color{blue}{z} \cdot y + t \]
  3. Recombined 2 regimes into one program.
  4. Final simplification91.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3 \cdot 10^{-25} \lor \neg \left(y \leq 7.5 \cdot 10^{-13}\right):\\ \;\;\;\;y \cdot \left(z + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t + y \cdot z\\ \end{array} \]

Alternative 6: 51.4% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -2.35 \cdot 10^{+43}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{+90}:\\ \;\;\;\;t\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= z -2.35e+43) (* y z) (if (<= z 3.5e+90) t (* y z))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -2.35e+43) {
		tmp = y * z;
	} else if (z <= 3.5e+90) {
		tmp = t;
	} else {
		tmp = y * z;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (z <= (-2.35d+43)) then
        tmp = y * z
    else if (z <= 3.5d+90) then
        tmp = t
    else
        tmp = y * z
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -2.35e+43) {
		tmp = y * z;
	} else if (z <= 3.5e+90) {
		tmp = t;
	} else {
		tmp = y * z;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if z <= -2.35e+43:
		tmp = y * z
	elif z <= 3.5e+90:
		tmp = t
	else:
		tmp = y * z
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (z <= -2.35e+43)
		tmp = Float64(y * z);
	elseif (z <= 3.5e+90)
		tmp = t;
	else
		tmp = Float64(y * z);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (z <= -2.35e+43)
		tmp = y * z;
	elseif (z <= 3.5e+90)
		tmp = t;
	else
		tmp = y * z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[z, -2.35e+43], N[(y * z), $MachinePrecision], If[LessEqual[z, 3.5e+90], t, N[(y * z), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.35 \cdot 10^{+43}:\\
\;\;\;\;y \cdot z\\

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

\mathbf{else}:\\
\;\;\;\;y \cdot z\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.34999999999999999e43 or 3.4999999999999998e90 < z

    1. Initial program 100.0%

      \[\left(x \cdot y + z\right) \cdot y + t \]
    2. Taylor expanded in x around 0 80.9%

      \[\leadsto \color{blue}{z} \cdot y + t \]
    3. Taylor expanded in z around inf 57.2%

      \[\leadsto \color{blue}{y \cdot z} \]

    if -2.34999999999999999e43 < z < 3.4999999999999998e90

    1. Initial program 99.9%

      \[\left(x \cdot y + z\right) \cdot y + t \]
    2. Taylor expanded in y around 0 49.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.35 \cdot 10^{+43}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{+90}:\\ \;\;\;\;t\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]

Alternative 7: 38.9% accurate, 9.0× speedup?

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

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

    \[\left(x \cdot y + z\right) \cdot y + t \]
  2. Taylor expanded in y around 0 39.2%

    \[\leadsto \color{blue}{t} \]
  3. Final simplification39.2%

    \[\leadsto t \]

Reproduce

?
herbie shell --seed 2023181 
(FPCore (x y z t)
  :name "Language.Haskell.HsColour.ColourHighlight:unbase from hscolour-1.23"
  :precision binary64
  (+ (* (+ (* x y) z) y) t))