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

Percentage Accurate: 99.9% → 99.9%
Time: 6.0s
Alternatives: 9
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 9 alternatives:

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

Initial Program: 99.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \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, 0.0× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(x, y, z\right), y, t\right) \end{array} \]
(FPCore (x y z t) :precision binary64 (fma (fma x y z) y t))
double code(double x, double y, double z, double t) {
	return fma(fma(x, y, z), y, t);
}
function code(x, y, z, t)
	return fma(fma(x, y, z), y, t)
end
code[x_, y_, z_, t_] := N[(N[(x * y + z), $MachinePrecision] * y + t), $MachinePrecision]
\begin{array}{l}

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

    \[\left(x \cdot y + z\right) \cdot y + t \]
  2. Step-by-step derivation
    1. fma-def99.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x \cdot y + z, y, t\right)} \]
    2. fma-def99.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(x, y, z\right)}, y, t\right) \]
  3. Simplified99.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(x, y, z\right), y, t\right)} \]
  4. Final simplification99.9%

    \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x, y, z\right), y, t\right) \]

Alternative 2: 64.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := y \cdot \left(x \cdot y\right)\\ \mathbf{if}\;y \leq -4 \cdot 10^{+35}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -4000000:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq -1.4 \cdot 10^{-14}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{-24}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{+28}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 6.6 \cdot 10^{+82}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{+103}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* y (* x y))))
   (if (<= y -4e+35)
     t_1
     (if (<= y -4000000.0)
       (* y z)
       (if (<= y -1.4e-14)
         t_1
         (if (<= y 2.3e-24)
           t
           (if (<= y 1.15e+28)
             t_1
             (if (<= y 6.6e+82) t (if (<= y 3.5e+103) (* y z) t_1)))))))))
double code(double x, double y, double z, double t) {
	double t_1 = y * (x * y);
	double tmp;
	if (y <= -4e+35) {
		tmp = t_1;
	} else if (y <= -4000000.0) {
		tmp = y * z;
	} else if (y <= -1.4e-14) {
		tmp = t_1;
	} else if (y <= 2.3e-24) {
		tmp = t;
	} else if (y <= 1.15e+28) {
		tmp = t_1;
	} else if (y <= 6.6e+82) {
		tmp = t;
	} else if (y <= 3.5e+103) {
		tmp = y * z;
	} 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 <= (-4d+35)) then
        tmp = t_1
    else if (y <= (-4000000.0d0)) then
        tmp = y * z
    else if (y <= (-1.4d-14)) then
        tmp = t_1
    else if (y <= 2.3d-24) then
        tmp = t
    else if (y <= 1.15d+28) then
        tmp = t_1
    else if (y <= 6.6d+82) then
        tmp = t
    else if (y <= 3.5d+103) then
        tmp = y * z
    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 <= -4e+35) {
		tmp = t_1;
	} else if (y <= -4000000.0) {
		tmp = y * z;
	} else if (y <= -1.4e-14) {
		tmp = t_1;
	} else if (y <= 2.3e-24) {
		tmp = t;
	} else if (y <= 1.15e+28) {
		tmp = t_1;
	} else if (y <= 6.6e+82) {
		tmp = t;
	} else if (y <= 3.5e+103) {
		tmp = y * z;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = y * (x * y)
	tmp = 0
	if y <= -4e+35:
		tmp = t_1
	elif y <= -4000000.0:
		tmp = y * z
	elif y <= -1.4e-14:
		tmp = t_1
	elif y <= 2.3e-24:
		tmp = t
	elif y <= 1.15e+28:
		tmp = t_1
	elif y <= 6.6e+82:
		tmp = t
	elif y <= 3.5e+103:
		tmp = y * z
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(y * Float64(x * y))
	tmp = 0.0
	if (y <= -4e+35)
		tmp = t_1;
	elseif (y <= -4000000.0)
		tmp = Float64(y * z);
	elseif (y <= -1.4e-14)
		tmp = t_1;
	elseif (y <= 2.3e-24)
		tmp = t;
	elseif (y <= 1.15e+28)
		tmp = t_1;
	elseif (y <= 6.6e+82)
		tmp = t;
	elseif (y <= 3.5e+103)
		tmp = Float64(y * z);
	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 <= -4e+35)
		tmp = t_1;
	elseif (y <= -4000000.0)
		tmp = y * z;
	elseif (y <= -1.4e-14)
		tmp = t_1;
	elseif (y <= 2.3e-24)
		tmp = t;
	elseif (y <= 1.15e+28)
		tmp = t_1;
	elseif (y <= 6.6e+82)
		tmp = t;
	elseif (y <= 3.5e+103)
		tmp = y * z;
	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, -4e+35], t$95$1, If[LessEqual[y, -4000000.0], N[(y * z), $MachinePrecision], If[LessEqual[y, -1.4e-14], t$95$1, If[LessEqual[y, 2.3e-24], t, If[LessEqual[y, 1.15e+28], t$95$1, If[LessEqual[y, 6.6e+82], t, If[LessEqual[y, 3.5e+103], N[(y * z), $MachinePrecision], t$95$1]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -4000000:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;y \leq -1.4 \cdot 10^{-14}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 2.3 \cdot 10^{-24}:\\
\;\;\;\;t\\

\mathbf{elif}\;y \leq 1.15 \cdot 10^{+28}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 6.6 \cdot 10^{+82}:\\
\;\;\;\;t\\

\mathbf{elif}\;y \leq 3.5 \cdot 10^{+103}:\\
\;\;\;\;y \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -3.9999999999999999e35 or -4e6 < y < -1.4e-14 or 2.3000000000000001e-24 < y < 1.14999999999999992e28 or 3.5e103 < y

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{y \cdot z + \left(t + {y}^{2} \cdot x\right)} \]
    3. Step-by-step derivation
      1. associate-+r+83.7%

        \[\leadsto \color{blue}{\left(y \cdot z + t\right) + {y}^{2} \cdot x} \]
      2. fma-def83.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, z, t\right)} + {y}^{2} \cdot x \]
      3. unpow283.7%

        \[\leadsto \mathsf{fma}\left(y, z, t\right) + \color{blue}{\left(y \cdot y\right)} \cdot x \]
      4. associate-*r*96.1%

        \[\leadsto \mathsf{fma}\left(y, z, t\right) + \color{blue}{y \cdot \left(y \cdot x\right)} \]
    4. Simplified96.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, z, t\right) + y \cdot \left(y \cdot x\right)} \]
    5. Taylor expanded in y around inf 67.5%

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

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

        \[\leadsto \color{blue}{y \cdot \left(y \cdot x\right)} \]
    7. Simplified72.9%

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

    if -3.9999999999999999e35 < y < -4e6 or 6.5999999999999997e82 < y < 3.5e103

    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}{y \cdot z + \left(t + {y}^{2} \cdot x\right)} \]
    3. Step-by-step derivation
      1. associate-+r+100.0%

        \[\leadsto \color{blue}{\left(y \cdot z + t\right) + {y}^{2} \cdot x} \]
      2. fma-def100.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, z, t\right)} + {y}^{2} \cdot x \]
      3. unpow2100.0%

        \[\leadsto \mathsf{fma}\left(y, z, t\right) + \color{blue}{\left(y \cdot y\right)} \cdot x \]
      4. associate-*r*100.0%

        \[\leadsto \mathsf{fma}\left(y, z, t\right) + \color{blue}{y \cdot \left(y \cdot x\right)} \]
    4. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, z, t\right) + y \cdot \left(y \cdot x\right)} \]
    5. Taylor expanded in z around inf 68.6%

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

    if -1.4e-14 < y < 2.3000000000000001e-24 or 1.14999999999999992e28 < y < 6.5999999999999997e82

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4 \cdot 10^{+35}:\\ \;\;\;\;y \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;y \leq -4000000:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq -1.4 \cdot 10^{-14}:\\ \;\;\;\;y \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{-24}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{+28}:\\ \;\;\;\;y \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;y \leq 6.6 \cdot 10^{+82}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{+103}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(x \cdot y\right)\\ \end{array} \]

Alternative 3: 78.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -7.2 \cdot 10^{+123} \lor \neg \left(y \leq -6.8 \cdot 10^{+64} \lor \neg \left(y \leq -4 \cdot 10^{+37}\right) \land y \leq 2.4 \cdot 10^{+109}\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 -7.2e+123)
         (not (or (<= y -6.8e+64) (and (not (<= y -4e+37)) (<= y 2.4e+109)))))
   (* y (* x y))
   (+ t (* y z))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((y <= -7.2e+123) || !((y <= -6.8e+64) || (!(y <= -4e+37) && (y <= 2.4e+109)))) {
		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 <= (-7.2d+123)) .or. (.not. (y <= (-6.8d+64)) .or. (.not. (y <= (-4d+37))) .and. (y <= 2.4d+109))) 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 <= -7.2e+123) || !((y <= -6.8e+64) || (!(y <= -4e+37) && (y <= 2.4e+109)))) {
		tmp = y * (x * y);
	} else {
		tmp = t + (y * z);
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (y <= -7.2e+123) or not ((y <= -6.8e+64) or (not (y <= -4e+37) and (y <= 2.4e+109))):
		tmp = y * (x * y)
	else:
		tmp = t + (y * z)
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((y <= -7.2e+123) || !((y <= -6.8e+64) || (!(y <= -4e+37) && (y <= 2.4e+109))))
		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 <= -7.2e+123) || ~(((y <= -6.8e+64) || (~((y <= -4e+37)) && (y <= 2.4e+109)))))
		tmp = y * (x * y);
	else
		tmp = t + (y * z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -7.2e+123], N[Not[Or[LessEqual[y, -6.8e+64], And[N[Not[LessEqual[y, -4e+37]], $MachinePrecision], LessEqual[y, 2.4e+109]]]], $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 -7.2 \cdot 10^{+123} \lor \neg \left(y \leq -6.8 \cdot 10^{+64} \lor \neg \left(y \leq -4 \cdot 10^{+37}\right) \land y \leq 2.4 \cdot 10^{+109}\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 < -7.19999999999999996e123 or -6.8000000000000003e64 < y < -3.99999999999999982e37 or 2.39999999999999987e109 < y

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{y \cdot z + \left(t + {y}^{2} \cdot x\right)} \]
    3. Step-by-step derivation
      1. associate-+r+77.6%

        \[\leadsto \color{blue}{\left(y \cdot z + t\right) + {y}^{2} \cdot x} \]
      2. fma-def77.6%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, z, t\right)} + {y}^{2} \cdot x \]
      3. unpow277.6%

        \[\leadsto \mathsf{fma}\left(y, z, t\right) + \color{blue}{\left(y \cdot y\right)} \cdot x \]
      4. associate-*r*94.7%

        \[\leadsto \mathsf{fma}\left(y, z, t\right) + \color{blue}{y \cdot \left(y \cdot x\right)} \]
    4. Simplified94.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, z, t\right) + y \cdot \left(y \cdot x\right)} \]
    5. Taylor expanded in y around inf 76.1%

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

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

        \[\leadsto \color{blue}{y \cdot \left(y \cdot x\right)} \]
    7. Simplified83.5%

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

    if -7.19999999999999996e123 < y < -6.8000000000000003e64 or -3.99999999999999982e37 < y < 2.39999999999999987e109

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7.2 \cdot 10^{+123} \lor \neg \left(y \leq -6.8 \cdot 10^{+64} \lor \neg \left(y \leq -4 \cdot 10^{+37}\right) \land y \leq 2.4 \cdot 10^{+109}\right):\\ \;\;\;\;y \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t + y \cdot z\\ \end{array} \]

Alternative 4: 86.4% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -2.05 \cdot 10^{+158}:\\ \;\;\;\;y \cdot \left(z + x \cdot y\right)\\ \mathbf{elif}\;z \leq -7.4 \cdot 10^{+63} \lor \neg \left(z \leq 4.4 \cdot 10^{-18}\right):\\ \;\;\;\;t + y \cdot z\\ \mathbf{else}:\\ \;\;\;\;t + y \cdot \left(x \cdot y\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= z -2.05e+158)
   (* y (+ z (* x y)))
   (if (or (<= z -7.4e+63) (not (<= z 4.4e-18)))
     (+ t (* y z))
     (+ t (* y (* x y))))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -2.05e+158) {
		tmp = y * (z + (x * y));
	} else if ((z <= -7.4e+63) || !(z <= 4.4e-18)) {
		tmp = t + (y * z);
	} else {
		tmp = t + (y * (x * y));
	}
	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.05d+158)) then
        tmp = y * (z + (x * y))
    else if ((z <= (-7.4d+63)) .or. (.not. (z <= 4.4d-18))) then
        tmp = t + (y * z)
    else
        tmp = t + (y * (x * y))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -2.05e+158) {
		tmp = y * (z + (x * y));
	} else if ((z <= -7.4e+63) || !(z <= 4.4e-18)) {
		tmp = t + (y * z);
	} else {
		tmp = t + (y * (x * y));
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if z <= -2.05e+158:
		tmp = y * (z + (x * y))
	elif (z <= -7.4e+63) or not (z <= 4.4e-18):
		tmp = t + (y * z)
	else:
		tmp = t + (y * (x * y))
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (z <= -2.05e+158)
		tmp = Float64(y * Float64(z + Float64(x * y)));
	elseif ((z <= -7.4e+63) || !(z <= 4.4e-18))
		tmp = Float64(t + Float64(y * z));
	else
		tmp = Float64(t + Float64(y * Float64(x * y)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (z <= -2.05e+158)
		tmp = y * (z + (x * y));
	elseif ((z <= -7.4e+63) || ~((z <= 4.4e-18)))
		tmp = t + (y * z);
	else
		tmp = t + (y * (x * y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[z, -2.05e+158], N[(y * N[(z + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, -7.4e+63], N[Not[LessEqual[z, 4.4e-18]], $MachinePrecision]], N[(t + N[(y * z), $MachinePrecision]), $MachinePrecision], N[(t + N[(y * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.05 \cdot 10^{+158}:\\
\;\;\;\;y \cdot \left(z + x \cdot y\right)\\

\mathbf{elif}\;z \leq -7.4 \cdot 10^{+63} \lor \neg \left(z \leq 4.4 \cdot 10^{-18}\right):\\
\;\;\;\;t + y \cdot z\\

\mathbf{else}:\\
\;\;\;\;t + y \cdot \left(x \cdot y\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -2.05000000000000002e158

    1. Initial program 100.0%

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

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

    if -2.05000000000000002e158 < z < -7.39999999999999937e63 or 4.3999999999999997e-18 < z

    1. Initial program 99.9%

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

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

    if -7.39999999999999937e63 < z < 4.3999999999999997e-18

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{{y}^{2} \cdot x} + t \]
    3. Step-by-step derivation
      1. unpow290.1%

        \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot x + t \]
      2. associate-*r*96.6%

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

      \[\leadsto \color{blue}{y \cdot \left(y \cdot x\right)} + t \]
  3. Recombined 3 regimes into one program.
  4. Final simplification93.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.05 \cdot 10^{+158}:\\ \;\;\;\;y \cdot \left(z + x \cdot y\right)\\ \mathbf{elif}\;z \leq -7.4 \cdot 10^{+63} \lor \neg \left(z \leq 4.4 \cdot 10^{-18}\right):\\ \;\;\;\;t + y \cdot z\\ \mathbf{else}:\\ \;\;\;\;t + y \cdot \left(x \cdot y\right)\\ \end{array} \]

Alternative 5: 88.2% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := y \cdot \left(z + x \cdot y\right)\\ \mathbf{if}\;y \leq -2.2 \cdot 10^{-11}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{-133}:\\ \;\;\;\;t + y \cdot z\\ \mathbf{elif}\;y \leq 8.4 \cdot 10^{+74}:\\ \;\;\;\;t + x \cdot \left(y \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* y (+ z (* x y)))))
   (if (<= y -2.2e-11)
     t_1
     (if (<= y 4.6e-133)
       (+ t (* y z))
       (if (<= y 8.4e+74) (+ t (* x (* y y))) t_1)))))
double code(double x, double y, double z, double t) {
	double t_1 = y * (z + (x * y));
	double tmp;
	if (y <= -2.2e-11) {
		tmp = t_1;
	} else if (y <= 4.6e-133) {
		tmp = t + (y * z);
	} else if (y <= 8.4e+74) {
		tmp = t + (x * (y * y));
	} 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 * (z + (x * y))
    if (y <= (-2.2d-11)) then
        tmp = t_1
    else if (y <= 4.6d-133) then
        tmp = t + (y * z)
    else if (y <= 8.4d+74) then
        tmp = t + (x * (y * y))
    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 * (z + (x * y));
	double tmp;
	if (y <= -2.2e-11) {
		tmp = t_1;
	} else if (y <= 4.6e-133) {
		tmp = t + (y * z);
	} else if (y <= 8.4e+74) {
		tmp = t + (x * (y * y));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = y * (z + (x * y))
	tmp = 0
	if y <= -2.2e-11:
		tmp = t_1
	elif y <= 4.6e-133:
		tmp = t + (y * z)
	elif y <= 8.4e+74:
		tmp = t + (x * (y * y))
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(y * Float64(z + Float64(x * y)))
	tmp = 0.0
	if (y <= -2.2e-11)
		tmp = t_1;
	elseif (y <= 4.6e-133)
		tmp = Float64(t + Float64(y * z));
	elseif (y <= 8.4e+74)
		tmp = Float64(t + Float64(x * Float64(y * y)));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = y * (z + (x * y));
	tmp = 0.0;
	if (y <= -2.2e-11)
		tmp = t_1;
	elseif (y <= 4.6e-133)
		tmp = t + (y * z);
	elseif (y <= 8.4e+74)
		tmp = t + (x * (y * y));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(z + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.2e-11], t$95$1, If[LessEqual[y, 4.6e-133], N[(t + N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8.4e+74], N[(t + N[(x * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 4.6 \cdot 10^{-133}:\\
\;\;\;\;t + y \cdot z\\

\mathbf{elif}\;y \leq 8.4 \cdot 10^{+74}:\\
\;\;\;\;t + x \cdot \left(y \cdot y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.2000000000000002e-11 or 8.3999999999999995e74 < 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} \]

    if -2.2000000000000002e-11 < y < 4.6000000000000001e-133

    1. Initial program 100.0%

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

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

    if 4.6000000000000001e-133 < y < 8.3999999999999995e74

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{{y}^{2} \cdot x} + t \]
    3. Step-by-step derivation
      1. unpow285.4%

        \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot x + t \]
      2. associate-*r*85.3%

        \[\leadsto \color{blue}{y \cdot \left(y \cdot x\right)} + t \]
    4. Simplified85.3%

      \[\leadsto \color{blue}{y \cdot \left(y \cdot x\right)} + t \]
    5. Step-by-step derivation
      1. flip-+47.3%

        \[\leadsto \color{blue}{\frac{\left(y \cdot \left(y \cdot x\right)\right) \cdot \left(y \cdot \left(y \cdot x\right)\right) - t \cdot t}{y \cdot \left(y \cdot x\right) - t}} \]
      2. div-sub47.3%

        \[\leadsto \color{blue}{\frac{\left(y \cdot \left(y \cdot x\right)\right) \cdot \left(y \cdot \left(y \cdot x\right)\right)}{y \cdot \left(y \cdot x\right) - t} - \frac{t \cdot t}{y \cdot \left(y \cdot x\right) - t}} \]
      3. pow247.3%

        \[\leadsto \frac{\color{blue}{{\left(y \cdot \left(y \cdot x\right)\right)}^{2}}}{y \cdot \left(y \cdot x\right) - t} - \frac{t \cdot t}{y \cdot \left(y \cdot x\right) - t} \]
    6. Applied egg-rr47.3%

      \[\leadsto \color{blue}{\frac{{\left(y \cdot \left(y \cdot x\right)\right)}^{2}}{y \cdot \left(y \cdot x\right) - t} - \frac{t \cdot t}{y \cdot \left(y \cdot x\right) - t}} \]
    7. Step-by-step derivation
      1. div-sub47.3%

        \[\leadsto \color{blue}{\frac{{\left(y \cdot \left(y \cdot x\right)\right)}^{2} - t \cdot t}{y \cdot \left(y \cdot x\right) - t}} \]
      2. unpow247.3%

        \[\leadsto \frac{\color{blue}{\left(y \cdot \left(y \cdot x\right)\right) \cdot \left(y \cdot \left(y \cdot x\right)\right)} - t \cdot t}{y \cdot \left(y \cdot x\right) - t} \]
      3. associate-*r*47.3%

        \[\leadsto \frac{\color{blue}{\left(\left(y \cdot y\right) \cdot x\right)} \cdot \left(y \cdot \left(y \cdot x\right)\right) - t \cdot t}{y \cdot \left(y \cdot x\right) - t} \]
      4. *-commutative47.3%

        \[\leadsto \frac{\color{blue}{\left(x \cdot \left(y \cdot y\right)\right)} \cdot \left(y \cdot \left(y \cdot x\right)\right) - t \cdot t}{y \cdot \left(y \cdot x\right) - t} \]
      5. associate-*r*47.3%

        \[\leadsto \frac{\left(x \cdot \left(y \cdot y\right)\right) \cdot \color{blue}{\left(\left(y \cdot y\right) \cdot x\right)} - t \cdot t}{y \cdot \left(y \cdot x\right) - t} \]
      6. *-commutative47.3%

        \[\leadsto \frac{\left(x \cdot \left(y \cdot y\right)\right) \cdot \color{blue}{\left(x \cdot \left(y \cdot y\right)\right)} - t \cdot t}{y \cdot \left(y \cdot x\right) - t} \]
      7. swap-sqr31.5%

        \[\leadsto \frac{\color{blue}{\left(x \cdot x\right) \cdot \left(\left(y \cdot y\right) \cdot \left(y \cdot y\right)\right)} - t \cdot t}{y \cdot \left(y \cdot x\right) - t} \]
      8. unpow231.5%

        \[\leadsto \frac{\left(x \cdot x\right) \cdot \left(\color{blue}{{y}^{2}} \cdot \left(y \cdot y\right)\right) - t \cdot t}{y \cdot \left(y \cdot x\right) - t} \]
      9. unpow231.5%

        \[\leadsto \frac{\left(x \cdot x\right) \cdot \left({y}^{2} \cdot \color{blue}{{y}^{2}}\right) - t \cdot t}{y \cdot \left(y \cdot x\right) - t} \]
      10. pow-sqr31.5%

        \[\leadsto \frac{\left(x \cdot x\right) \cdot \color{blue}{{y}^{\left(2 \cdot 2\right)}} - t \cdot t}{y \cdot \left(y \cdot x\right) - t} \]
      11. metadata-eval31.5%

        \[\leadsto \frac{\left(x \cdot x\right) \cdot {y}^{\color{blue}{4}} - t \cdot t}{y \cdot \left(y \cdot x\right) - t} \]
    8. Simplified31.5%

      \[\leadsto \color{blue}{\frac{\left(x \cdot x\right) \cdot {y}^{4} - t \cdot t}{y \cdot \left(y \cdot x\right) - t}} \]
    9. Step-by-step derivation
      1. *-commutative31.5%

        \[\leadsto \frac{\color{blue}{{y}^{4} \cdot \left(x \cdot x\right)} - t \cdot t}{y \cdot \left(y \cdot x\right) - t} \]
      2. metadata-eval31.5%

        \[\leadsto \frac{{y}^{\color{blue}{\left(2 + 2\right)}} \cdot \left(x \cdot x\right) - t \cdot t}{y \cdot \left(y \cdot x\right) - t} \]
      3. metadata-eval31.5%

        \[\leadsto \frac{{y}^{\left(\color{blue}{\sqrt{4}} + 2\right)} \cdot \left(x \cdot x\right) - t \cdot t}{y \cdot \left(y \cdot x\right) - t} \]
      4. metadata-eval31.5%

        \[\leadsto \frac{{y}^{\left(\sqrt{4} + \color{blue}{\sqrt{4}}\right)} \cdot \left(x \cdot x\right) - t \cdot t}{y \cdot \left(y \cdot x\right) - t} \]
      5. pow-prod-up31.5%

        \[\leadsto \frac{\color{blue}{\left({y}^{\left(\sqrt{4}\right)} \cdot {y}^{\left(\sqrt{4}\right)}\right)} \cdot \left(x \cdot x\right) - t \cdot t}{y \cdot \left(y \cdot x\right) - t} \]
      6. pow-prod-down31.5%

        \[\leadsto \frac{\color{blue}{{\left(y \cdot y\right)}^{\left(\sqrt{4}\right)}} \cdot \left(x \cdot x\right) - t \cdot t}{y \cdot \left(y \cdot x\right) - t} \]
      7. metadata-eval31.5%

        \[\leadsto \frac{{\left(y \cdot y\right)}^{\color{blue}{2}} \cdot \left(x \cdot x\right) - t \cdot t}{y \cdot \left(y \cdot x\right) - t} \]
      8. pow231.5%

        \[\leadsto \frac{\color{blue}{\left(\left(y \cdot y\right) \cdot \left(y \cdot y\right)\right)} \cdot \left(x \cdot x\right) - t \cdot t}{y \cdot \left(y \cdot x\right) - t} \]
      9. swap-sqr47.3%

        \[\leadsto \frac{\color{blue}{\left(\left(y \cdot y\right) \cdot x\right) \cdot \left(\left(y \cdot y\right) \cdot x\right)} - t \cdot t}{y \cdot \left(y \cdot x\right) - t} \]
      10. associate-*r*47.3%

        \[\leadsto \frac{\color{blue}{\left(y \cdot \left(y \cdot x\right)\right)} \cdot \left(\left(y \cdot y\right) \cdot x\right) - t \cdot t}{y \cdot \left(y \cdot x\right) - t} \]
      11. associate-*r*47.3%

        \[\leadsto \frac{\left(y \cdot \left(y \cdot x\right)\right) \cdot \color{blue}{\left(y \cdot \left(y \cdot x\right)\right)} - t \cdot t}{y \cdot \left(y \cdot x\right) - t} \]
      12. flip-+85.3%

        \[\leadsto \color{blue}{y \cdot \left(y \cdot x\right) + t} \]
    10. Applied egg-rr85.4%

      \[\leadsto \color{blue}{x \cdot \left(y \cdot y\right) + t} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification91.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.2 \cdot 10^{-11}:\\ \;\;\;\;y \cdot \left(z + x \cdot y\right)\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{-133}:\\ \;\;\;\;t + y \cdot z\\ \mathbf{elif}\;y \leq 8.4 \cdot 10^{+74}:\\ \;\;\;\;t + x \cdot \left(y \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z + x \cdot y\right)\\ \end{array} \]

Alternative 6: 48.1% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.05 \cdot 10^{+158}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -1.95 \cdot 10^{+90}:\\ \;\;\;\;t\\ \mathbf{elif}\;\neg \left(z \leq -8.5 \cdot 10^{+59}\right) \land z \leq 3 \cdot 10^{+217}:\\ \;\;\;\;t\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= z -1.05e+158)
   (* y z)
   (if (<= z -1.95e+90)
     t
     (if (and (not (<= z -8.5e+59)) (<= z 3e+217)) t (* y z)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -1.05e+158) {
		tmp = y * z;
	} else if (z <= -1.95e+90) {
		tmp = t;
	} else if (!(z <= -8.5e+59) && (z <= 3e+217)) {
		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 <= (-1.05d+158)) then
        tmp = y * z
    else if (z <= (-1.95d+90)) then
        tmp = t
    else if ((.not. (z <= (-8.5d+59))) .and. (z <= 3d+217)) 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 <= -1.05e+158) {
		tmp = y * z;
	} else if (z <= -1.95e+90) {
		tmp = t;
	} else if (!(z <= -8.5e+59) && (z <= 3e+217)) {
		tmp = t;
	} else {
		tmp = y * z;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if z <= -1.05e+158:
		tmp = y * z
	elif z <= -1.95e+90:
		tmp = t
	elif not (z <= -8.5e+59) and (z <= 3e+217):
		tmp = t
	else:
		tmp = y * z
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (z <= -1.05e+158)
		tmp = Float64(y * z);
	elseif (z <= -1.95e+90)
		tmp = t;
	elseif (!(z <= -8.5e+59) && (z <= 3e+217))
		tmp = t;
	else
		tmp = Float64(y * z);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (z <= -1.05e+158)
		tmp = y * z;
	elseif (z <= -1.95e+90)
		tmp = t;
	elseif (~((z <= -8.5e+59)) && (z <= 3e+217))
		tmp = t;
	else
		tmp = y * z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.05e+158], N[(y * z), $MachinePrecision], If[LessEqual[z, -1.95e+90], t, If[And[N[Not[LessEqual[z, -8.5e+59]], $MachinePrecision], LessEqual[z, 3e+217]], t, N[(y * z), $MachinePrecision]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;\neg \left(z \leq -8.5 \cdot 10^{+59}\right) \land z \leq 3 \cdot 10^{+217}:\\
\;\;\;\;t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.0499999999999999e158 or -1.9500000000000001e90 < z < -8.4999999999999999e59 or 2.99999999999999976e217 < z

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{y \cdot z + \left(t + {y}^{2} \cdot x\right)} \]
    3. Step-by-step derivation
      1. associate-+r+87.8%

        \[\leadsto \color{blue}{\left(y \cdot z + t\right) + {y}^{2} \cdot x} \]
      2. fma-def87.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, z, t\right)} + {y}^{2} \cdot x \]
      3. unpow287.8%

        \[\leadsto \mathsf{fma}\left(y, z, t\right) + \color{blue}{\left(y \cdot y\right)} \cdot x \]
      4. associate-*r*92.9%

        \[\leadsto \mathsf{fma}\left(y, z, t\right) + \color{blue}{y \cdot \left(y \cdot x\right)} \]
    4. Simplified92.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, z, t\right) + y \cdot \left(y \cdot x\right)} \]
    5. Taylor expanded in z around inf 76.6%

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

    if -1.0499999999999999e158 < z < -1.9500000000000001e90 or -8.4999999999999999e59 < z < 2.99999999999999976e217

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.05 \cdot 10^{+158}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -1.95 \cdot 10^{+90}:\\ \;\;\;\;t\\ \mathbf{elif}\;\neg \left(z \leq -8.5 \cdot 10^{+59}\right) \land z \leq 3 \cdot 10^{+217}:\\ \;\;\;\;t\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]

Alternative 7: 89.6% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.8 \cdot 10^{-11} \lor \neg \left(y \leq 4.8 \cdot 10^{-24}\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 -3.8e-11) (not (<= y 4.8e-24)))
   (* y (+ z (* x y)))
   (+ t (* y z))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((y <= -3.8e-11) || !(y <= 4.8e-24)) {
		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 <= (-3.8d-11)) .or. (.not. (y <= 4.8d-24))) 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 <= -3.8e-11) || !(y <= 4.8e-24)) {
		tmp = y * (z + (x * y));
	} else {
		tmp = t + (y * z);
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (y <= -3.8e-11) or not (y <= 4.8e-24):
		tmp = y * (z + (x * y))
	else:
		tmp = t + (y * z)
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((y <= -3.8e-11) || !(y <= 4.8e-24))
		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 <= -3.8e-11) || ~((y <= 4.8e-24)))
		tmp = y * (z + (x * y));
	else
		tmp = t + (y * z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -3.8e-11], N[Not[LessEqual[y, 4.8e-24]], $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.8 \cdot 10^{-11} \lor \neg \left(y \leq 4.8 \cdot 10^{-24}\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 < -3.7999999999999998e-11 or 4.7999999999999996e-24 < y

    1. Initial program 99.9%

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

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

    if -3.7999999999999998e-11 < y < 4.7999999999999996e-24

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.8 \cdot 10^{-11} \lor \neg \left(y \leq 4.8 \cdot 10^{-24}\right):\\ \;\;\;\;y \cdot \left(z + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t + y \cdot z\\ \end{array} \]

Alternative 8: 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 9: 37.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 43.4%

    \[\leadsto \color{blue}{t} \]
  3. Final simplification43.4%

    \[\leadsto t \]

Reproduce

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