Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendOutside from plot-0.2.3.4, B

Percentage Accurate: 99.9% → 100.0%
Time: 5.4s
Alternatives: 10
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 99.9% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 0.1× speedup?

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

\\
\mathsf{fma}\left(y, 5, x \cdot \mathsf{fma}\left(y + z, 2, t\right)\right)
\end{array}
Derivation
  1. Initial program 98.9%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, 5, x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right)\right)} \]
    3. distribute-rgt-in96.5%

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

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

      \[\leadsto \mathsf{fma}\left(y, 5, \left(\left(y + z\right) + \color{blue}{\left(y + z\right)}\right) \cdot x + t \cdot x\right) \]
    6. count-296.5%

      \[\leadsto \mathsf{fma}\left(y, 5, \color{blue}{\left(2 \cdot \left(y + z\right)\right)} \cdot x + t \cdot x\right) \]
    7. distribute-rgt-in99.3%

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

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

      \[\leadsto \mathsf{fma}\left(y, 5, x \cdot \color{blue}{\mathsf{fma}\left(y + z, 2, t\right)}\right) \]
  3. Applied egg-rr99.3%

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

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

Alternative 2: 99.9% accurate, 0.1× speedup?

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

\\
\mathsf{fma}\left(x, t + \left(y + z\right) \cdot 2, y \cdot 5\right)
\end{array}
Derivation
  1. Initial program 98.9%

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

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

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

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

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

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

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

Alternative 3: 43.3% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := 2 \cdot \left(x \cdot z\right)\\ \mathbf{if}\;z \leq -2.6 \cdot 10^{+103}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -6.5 \cdot 10^{-5}:\\ \;\;\;\;x \cdot t\\ \mathbf{elif}\;z \leq -2 \cdot 10^{-209}:\\ \;\;\;\;y \cdot 5\\ \mathbf{elif}\;z \leq -1.16 \cdot 10^{-270}:\\ \;\;\;\;x \cdot t\\ \mathbf{elif}\;z \leq 10^{-247}:\\ \;\;\;\;y \cdot \left(x \cdot 2\right)\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{+51}:\\ \;\;\;\;x \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* 2.0 (* x z))))
   (if (<= z -2.6e+103)
     t_1
     (if (<= z -6.5e-5)
       (* x t)
       (if (<= z -2e-209)
         (* y 5.0)
         (if (<= z -1.16e-270)
           (* x t)
           (if (<= z 1e-247)
             (* y (* x 2.0))
             (if (<= z 4.5e+51) (* x t) t_1))))))))
double code(double x, double y, double z, double t) {
	double t_1 = 2.0 * (x * z);
	double tmp;
	if (z <= -2.6e+103) {
		tmp = t_1;
	} else if (z <= -6.5e-5) {
		tmp = x * t;
	} else if (z <= -2e-209) {
		tmp = y * 5.0;
	} else if (z <= -1.16e-270) {
		tmp = x * t;
	} else if (z <= 1e-247) {
		tmp = y * (x * 2.0);
	} else if (z <= 4.5e+51) {
		tmp = x * 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 = 2.0d0 * (x * z)
    if (z <= (-2.6d+103)) then
        tmp = t_1
    else if (z <= (-6.5d-5)) then
        tmp = x * t
    else if (z <= (-2d-209)) then
        tmp = y * 5.0d0
    else if (z <= (-1.16d-270)) then
        tmp = x * t
    else if (z <= 1d-247) then
        tmp = y * (x * 2.0d0)
    else if (z <= 4.5d+51) then
        tmp = x * 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 = 2.0 * (x * z);
	double tmp;
	if (z <= -2.6e+103) {
		tmp = t_1;
	} else if (z <= -6.5e-5) {
		tmp = x * t;
	} else if (z <= -2e-209) {
		tmp = y * 5.0;
	} else if (z <= -1.16e-270) {
		tmp = x * t;
	} else if (z <= 1e-247) {
		tmp = y * (x * 2.0);
	} else if (z <= 4.5e+51) {
		tmp = x * t;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = 2.0 * (x * z)
	tmp = 0
	if z <= -2.6e+103:
		tmp = t_1
	elif z <= -6.5e-5:
		tmp = x * t
	elif z <= -2e-209:
		tmp = y * 5.0
	elif z <= -1.16e-270:
		tmp = x * t
	elif z <= 1e-247:
		tmp = y * (x * 2.0)
	elif z <= 4.5e+51:
		tmp = x * t
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(2.0 * Float64(x * z))
	tmp = 0.0
	if (z <= -2.6e+103)
		tmp = t_1;
	elseif (z <= -6.5e-5)
		tmp = Float64(x * t);
	elseif (z <= -2e-209)
		tmp = Float64(y * 5.0);
	elseif (z <= -1.16e-270)
		tmp = Float64(x * t);
	elseif (z <= 1e-247)
		tmp = Float64(y * Float64(x * 2.0));
	elseif (z <= 4.5e+51)
		tmp = Float64(x * t);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = 2.0 * (x * z);
	tmp = 0.0;
	if (z <= -2.6e+103)
		tmp = t_1;
	elseif (z <= -6.5e-5)
		tmp = x * t;
	elseif (z <= -2e-209)
		tmp = y * 5.0;
	elseif (z <= -1.16e-270)
		tmp = x * t;
	elseif (z <= 1e-247)
		tmp = y * (x * 2.0);
	elseif (z <= 4.5e+51)
		tmp = x * t;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(2.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.6e+103], t$95$1, If[LessEqual[z, -6.5e-5], N[(x * t), $MachinePrecision], If[LessEqual[z, -2e-209], N[(y * 5.0), $MachinePrecision], If[LessEqual[z, -1.16e-270], N[(x * t), $MachinePrecision], If[LessEqual[z, 1e-247], N[(y * N[(x * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4.5e+51], N[(x * t), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -6.5 \cdot 10^{-5}:\\
\;\;\;\;x \cdot t\\

\mathbf{elif}\;z \leq -2 \cdot 10^{-209}:\\
\;\;\;\;y \cdot 5\\

\mathbf{elif}\;z \leq -1.16 \cdot 10^{-270}:\\
\;\;\;\;x \cdot t\\

\mathbf{elif}\;z \leq 10^{-247}:\\
\;\;\;\;y \cdot \left(x \cdot 2\right)\\

\mathbf{elif}\;z \leq 4.5 \cdot 10^{+51}:\\
\;\;\;\;x \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -2.6000000000000002e103 or 4.5e51 < z

    1. Initial program 99.0%

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

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

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

    if -2.6000000000000002e103 < z < -6.49999999999999943e-5 or -2.0000000000000001e-209 < z < -1.16000000000000006e-270 or 1e-247 < z < 4.5e51

    1. Initial program 98.0%

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

      \[\leadsto \color{blue}{t \cdot x} + y \cdot 5 \]
    3. Step-by-step derivation
      1. +-commutative77.0%

        \[\leadsto \color{blue}{y \cdot 5 + t \cdot x} \]
      2. fma-def77.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, 5, t \cdot x\right)} \]
      3. *-commutative77.0%

        \[\leadsto \mathsf{fma}\left(y, 5, \color{blue}{x \cdot t}\right) \]
    4. Applied egg-rr77.0%

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

      \[\leadsto \color{blue}{t \cdot x} \]
    6. Step-by-step derivation
      1. *-commutative55.8%

        \[\leadsto \color{blue}{x \cdot t} \]
    7. Simplified55.8%

      \[\leadsto \color{blue}{x \cdot t} \]

    if -6.49999999999999943e-5 < z < -2.0000000000000001e-209

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{5 \cdot y} \]
    3. Simplified43.2%

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

    if -1.16000000000000006e-270 < z < 1e-247

    1. Initial program 99.9%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(2 \cdot x + 5\right) \cdot y} \]
    5. Step-by-step derivation
      1. *-commutative73.7%

        \[\leadsto \color{blue}{y \cdot \left(2 \cdot x + 5\right)} \]
      2. distribute-rgt-in73.7%

        \[\leadsto \color{blue}{\left(2 \cdot x\right) \cdot y + 5 \cdot y} \]
      3. *-commutative73.7%

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

        \[\leadsto \left(x \cdot 2\right) \cdot y + \color{blue}{y \cdot 5} \]
    6. Applied egg-rr73.7%

      \[\leadsto \color{blue}{\left(x \cdot 2\right) \cdot y + y \cdot 5} \]
    7. Taylor expanded in x around inf 48.8%

      \[\leadsto \color{blue}{2 \cdot \left(y \cdot x\right)} \]
    8. Step-by-step derivation
      1. associate-*r*48.8%

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

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

        \[\leadsto \color{blue}{y \cdot \left(2 \cdot x\right)} \]
    9. Simplified48.8%

      \[\leadsto \color{blue}{y \cdot \left(2 \cdot x\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification57.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.6 \cdot 10^{+103}:\\ \;\;\;\;2 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \leq -6.5 \cdot 10^{-5}:\\ \;\;\;\;x \cdot t\\ \mathbf{elif}\;z \leq -2 \cdot 10^{-209}:\\ \;\;\;\;y \cdot 5\\ \mathbf{elif}\;z \leq -1.16 \cdot 10^{-270}:\\ \;\;\;\;x \cdot t\\ \mathbf{elif}\;z \leq 10^{-247}:\\ \;\;\;\;y \cdot \left(x \cdot 2\right)\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{+51}:\\ \;\;\;\;x \cdot t\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(x \cdot z\right)\\ \end{array} \]

Alternative 4: 62.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := 2 \cdot \left(x \cdot z\right)\\ t_2 := y \cdot 5 + x \cdot t\\ \mathbf{if}\;z \leq -8.2 \cdot 10^{+108}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4.2 \cdot 10^{-35}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 4.6 \cdot 10^{-248}:\\ \;\;\;\;y \cdot \left(5 + x \cdot 2\right)\\ \mathbf{elif}\;z \leq 3 \cdot 10^{+183}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* 2.0 (* x z))) (t_2 (+ (* y 5.0) (* x t))))
   (if (<= z -8.2e+108)
     t_1
     (if (<= z -4.2e-35)
       t_2
       (if (<= z 4.6e-248)
         (* y (+ 5.0 (* x 2.0)))
         (if (<= z 3e+183) t_2 t_1))))))
double code(double x, double y, double z, double t) {
	double t_1 = 2.0 * (x * z);
	double t_2 = (y * 5.0) + (x * t);
	double tmp;
	if (z <= -8.2e+108) {
		tmp = t_1;
	} else if (z <= -4.2e-35) {
		tmp = t_2;
	} else if (z <= 4.6e-248) {
		tmp = y * (5.0 + (x * 2.0));
	} else if (z <= 3e+183) {
		tmp = t_2;
	} 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) :: t_2
    real(8) :: tmp
    t_1 = 2.0d0 * (x * z)
    t_2 = (y * 5.0d0) + (x * t)
    if (z <= (-8.2d+108)) then
        tmp = t_1
    else if (z <= (-4.2d-35)) then
        tmp = t_2
    else if (z <= 4.6d-248) then
        tmp = y * (5.0d0 + (x * 2.0d0))
    else if (z <= 3d+183) then
        tmp = t_2
    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 = 2.0 * (x * z);
	double t_2 = (y * 5.0) + (x * t);
	double tmp;
	if (z <= -8.2e+108) {
		tmp = t_1;
	} else if (z <= -4.2e-35) {
		tmp = t_2;
	} else if (z <= 4.6e-248) {
		tmp = y * (5.0 + (x * 2.0));
	} else if (z <= 3e+183) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = 2.0 * (x * z)
	t_2 = (y * 5.0) + (x * t)
	tmp = 0
	if z <= -8.2e+108:
		tmp = t_1
	elif z <= -4.2e-35:
		tmp = t_2
	elif z <= 4.6e-248:
		tmp = y * (5.0 + (x * 2.0))
	elif z <= 3e+183:
		tmp = t_2
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(2.0 * Float64(x * z))
	t_2 = Float64(Float64(y * 5.0) + Float64(x * t))
	tmp = 0.0
	if (z <= -8.2e+108)
		tmp = t_1;
	elseif (z <= -4.2e-35)
		tmp = t_2;
	elseif (z <= 4.6e-248)
		tmp = Float64(y * Float64(5.0 + Float64(x * 2.0)));
	elseif (z <= 3e+183)
		tmp = t_2;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = 2.0 * (x * z);
	t_2 = (y * 5.0) + (x * t);
	tmp = 0.0;
	if (z <= -8.2e+108)
		tmp = t_1;
	elseif (z <= -4.2e-35)
		tmp = t_2;
	elseif (z <= 4.6e-248)
		tmp = y * (5.0 + (x * 2.0));
	elseif (z <= 3e+183)
		tmp = t_2;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(2.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y * 5.0), $MachinePrecision] + N[(x * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -8.2e+108], t$95$1, If[LessEqual[z, -4.2e-35], t$95$2, If[LessEqual[z, 4.6e-248], N[(y * N[(5.0 + N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3e+183], t$95$2, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := 2 \cdot \left(x \cdot z\right)\\
t_2 := y \cdot 5 + x \cdot t\\
\mathbf{if}\;z \leq -8.2 \cdot 10^{+108}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq -4.2 \cdot 10^{-35}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;z \leq 4.6 \cdot 10^{-248}:\\
\;\;\;\;y \cdot \left(5 + x \cdot 2\right)\\

\mathbf{elif}\;z \leq 3 \cdot 10^{+183}:\\
\;\;\;\;t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -8.1999999999999998e108 or 2.99999999999999996e183 < z

    1. Initial program 98.7%

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

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

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

    if -8.1999999999999998e108 < z < -4.2e-35 or 4.6e-248 < z < 2.99999999999999996e183

    1. Initial program 98.4%

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

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

    if -4.2e-35 < z < 4.6e-248

    1. Initial program 100.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(2 \cdot x + 5\right) \cdot y} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification74.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -8.2 \cdot 10^{+108}:\\ \;\;\;\;2 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \leq -4.2 \cdot 10^{-35}:\\ \;\;\;\;y \cdot 5 + x \cdot t\\ \mathbf{elif}\;z \leq 4.6 \cdot 10^{-248}:\\ \;\;\;\;y \cdot \left(5 + x \cdot 2\right)\\ \mathbf{elif}\;z \leq 3 \cdot 10^{+183}:\\ \;\;\;\;y \cdot 5 + x \cdot t\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(x \cdot z\right)\\ \end{array} \]

Alternative 5: 99.9% accurate, 1.0× speedup?

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

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

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

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

Alternative 6: 44.5% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := 2 \cdot \left(x \cdot z\right)\\ \mathbf{if}\;z \leq -3.7 \cdot 10^{+103}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -7.2 \cdot 10^{-6}:\\ \;\;\;\;x \cdot t\\ \mathbf{elif}\;z \leq -2.4 \cdot 10^{-209}:\\ \;\;\;\;y \cdot 5\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{+48}:\\ \;\;\;\;x \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* 2.0 (* x z))))
   (if (<= z -3.7e+103)
     t_1
     (if (<= z -7.2e-6)
       (* x t)
       (if (<= z -2.4e-209) (* y 5.0) (if (<= z 2.4e+48) (* x t) t_1))))))
double code(double x, double y, double z, double t) {
	double t_1 = 2.0 * (x * z);
	double tmp;
	if (z <= -3.7e+103) {
		tmp = t_1;
	} else if (z <= -7.2e-6) {
		tmp = x * t;
	} else if (z <= -2.4e-209) {
		tmp = y * 5.0;
	} else if (z <= 2.4e+48) {
		tmp = x * 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 = 2.0d0 * (x * z)
    if (z <= (-3.7d+103)) then
        tmp = t_1
    else if (z <= (-7.2d-6)) then
        tmp = x * t
    else if (z <= (-2.4d-209)) then
        tmp = y * 5.0d0
    else if (z <= 2.4d+48) then
        tmp = x * 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 = 2.0 * (x * z);
	double tmp;
	if (z <= -3.7e+103) {
		tmp = t_1;
	} else if (z <= -7.2e-6) {
		tmp = x * t;
	} else if (z <= -2.4e-209) {
		tmp = y * 5.0;
	} else if (z <= 2.4e+48) {
		tmp = x * t;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = 2.0 * (x * z)
	tmp = 0
	if z <= -3.7e+103:
		tmp = t_1
	elif z <= -7.2e-6:
		tmp = x * t
	elif z <= -2.4e-209:
		tmp = y * 5.0
	elif z <= 2.4e+48:
		tmp = x * t
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(2.0 * Float64(x * z))
	tmp = 0.0
	if (z <= -3.7e+103)
		tmp = t_1;
	elseif (z <= -7.2e-6)
		tmp = Float64(x * t);
	elseif (z <= -2.4e-209)
		tmp = Float64(y * 5.0);
	elseif (z <= 2.4e+48)
		tmp = Float64(x * t);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = 2.0 * (x * z);
	tmp = 0.0;
	if (z <= -3.7e+103)
		tmp = t_1;
	elseif (z <= -7.2e-6)
		tmp = x * t;
	elseif (z <= -2.4e-209)
		tmp = y * 5.0;
	elseif (z <= 2.4e+48)
		tmp = x * t;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(2.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.7e+103], t$95$1, If[LessEqual[z, -7.2e-6], N[(x * t), $MachinePrecision], If[LessEqual[z, -2.4e-209], N[(y * 5.0), $MachinePrecision], If[LessEqual[z, 2.4e+48], N[(x * t), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -7.2 \cdot 10^{-6}:\\
\;\;\;\;x \cdot t\\

\mathbf{elif}\;z \leq -2.4 \cdot 10^{-209}:\\
\;\;\;\;y \cdot 5\\

\mathbf{elif}\;z \leq 2.4 \cdot 10^{+48}:\\
\;\;\;\;x \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -3.70000000000000033e103 or 2.4000000000000001e48 < z

    1. Initial program 99.0%

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

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

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

    if -3.70000000000000033e103 < z < -7.19999999999999967e-6 or -2.4000000000000001e-209 < z < 2.4000000000000001e48

    1. Initial program 98.4%

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

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

        \[\leadsto \color{blue}{y \cdot 5 + t \cdot x} \]
      2. fma-def72.1%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, 5, t \cdot x\right)} \]
      3. *-commutative72.1%

        \[\leadsto \mathsf{fma}\left(y, 5, \color{blue}{x \cdot t}\right) \]
    4. Applied egg-rr72.1%

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

      \[\leadsto \color{blue}{t \cdot x} \]
    6. Step-by-step derivation
      1. *-commutative50.7%

        \[\leadsto \color{blue}{x \cdot t} \]
    7. Simplified50.7%

      \[\leadsto \color{blue}{x \cdot t} \]

    if -7.19999999999999967e-6 < z < -2.4000000000000001e-209

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{5 \cdot y} \]
    3. Simplified43.2%

      \[\leadsto \color{blue}{y \cdot 5} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification56.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.7 \cdot 10^{+103}:\\ \;\;\;\;2 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \leq -7.2 \cdot 10^{-6}:\\ \;\;\;\;x \cdot t\\ \mathbf{elif}\;z \leq -2.4 \cdot 10^{-209}:\\ \;\;\;\;y \cdot 5\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{+48}:\\ \;\;\;\;x \cdot t\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(x \cdot z\right)\\ \end{array} \]

Alternative 7: 57.7% accurate, 1.1× speedup?

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

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

\mathbf{elif}\;y \leq 1.1 \cdot 10^{-284}:\\
\;\;\;\;x \cdot t\\

\mathbf{elif}\;y \leq 1.65 \cdot 10^{-110}:\\
\;\;\;\;2 \cdot \left(x \cdot z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.7000000000000001e73 or 1.65e-110 < y

    1. Initial program 98.4%

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

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

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

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

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

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

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

    if -1.7000000000000001e73 < y < 1.1e-284

    1. Initial program 99.1%

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

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

        \[\leadsto \color{blue}{y \cdot 5 + t \cdot x} \]
      2. fma-def66.4%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, 5, t \cdot x\right)} \]
      3. *-commutative66.4%

        \[\leadsto \mathsf{fma}\left(y, 5, \color{blue}{x \cdot t}\right) \]
    4. Applied egg-rr66.4%

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

      \[\leadsto \color{blue}{t \cdot x} \]
    6. Step-by-step derivation
      1. *-commutative59.9%

        \[\leadsto \color{blue}{x \cdot t} \]
    7. Simplified59.9%

      \[\leadsto \color{blue}{x \cdot t} \]

    if 1.1e-284 < y < 1.65e-110

    1. Initial program 100.0%

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

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

      \[\leadsto \color{blue}{2 \cdot \left(z \cdot x\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification65.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.7 \cdot 10^{+73}:\\ \;\;\;\;y \cdot \left(5 + x \cdot 2\right)\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-284}:\\ \;\;\;\;x \cdot t\\ \mathbf{elif}\;y \leq 1.65 \cdot 10^{-110}:\\ \;\;\;\;2 \cdot \left(x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(5 + x \cdot 2\right)\\ \end{array} \]

Alternative 8: 88.2% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{-45} \lor \neg \left(x \leq 2.05 \cdot 10^{-10}\right):\\
\;\;\;\;x \cdot \left(t + \left(y + z\right) \cdot 2\right)\\

\mathbf{else}:\\
\;\;\;\;y \cdot 5 + x \cdot t\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -8.9999999999999997e-45 or 2.0499999999999999e-10 < x

    1. Initial program 98.8%

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

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

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

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

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

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

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

    if -8.9999999999999997e-45 < x < 2.0499999999999999e-10

    1. Initial program 98.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9 \cdot 10^{-45} \lor \neg \left(x \leq 2.05 \cdot 10^{-10}\right):\\ \;\;\;\;x \cdot \left(t + \left(y + z\right) \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot 5 + x \cdot t\\ \end{array} \]

Alternative 9: 46.7% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.1 \cdot 10^{-95}:\\ \;\;\;\;x \cdot t\\ \mathbf{elif}\;x \leq 17000:\\ \;\;\;\;y \cdot 5\\ \mathbf{else}:\\ \;\;\;\;x \cdot t\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= x -1.1e-95) (* x t) (if (<= x 17000.0) (* y 5.0) (* x t))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (x <= -1.1e-95) {
		tmp = x * t;
	} else if (x <= 17000.0) {
		tmp = y * 5.0;
	} else {
		tmp = x * t;
	}
	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 (x <= (-1.1d-95)) then
        tmp = x * t
    else if (x <= 17000.0d0) then
        tmp = y * 5.0d0
    else
        tmp = x * t
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (x <= -1.1e-95) {
		tmp = x * t;
	} else if (x <= 17000.0) {
		tmp = y * 5.0;
	} else {
		tmp = x * t;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if x <= -1.1e-95:
		tmp = x * t
	elif x <= 17000.0:
		tmp = y * 5.0
	else:
		tmp = x * t
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (x <= -1.1e-95)
		tmp = Float64(x * t);
	elseif (x <= 17000.0)
		tmp = Float64(y * 5.0);
	else
		tmp = Float64(x * t);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (x <= -1.1e-95)
		tmp = x * t;
	elseif (x <= 17000.0)
		tmp = y * 5.0;
	else
		tmp = x * t;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.1e-95], N[(x * t), $MachinePrecision], If[LessEqual[x, 17000.0], N[(y * 5.0), $MachinePrecision], N[(x * t), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.1 \cdot 10^{-95}:\\
\;\;\;\;x \cdot t\\

\mathbf{elif}\;x \leq 17000:\\
\;\;\;\;y \cdot 5\\

\mathbf{else}:\\
\;\;\;\;x \cdot t\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.0999999999999999e-95 or 17000 < x

    1. Initial program 99.4%

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

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

        \[\leadsto \color{blue}{y \cdot 5 + t \cdot x} \]
      2. fma-def43.4%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, 5, t \cdot x\right)} \]
      3. *-commutative43.4%

        \[\leadsto \mathsf{fma}\left(y, 5, \color{blue}{x \cdot t}\right) \]
    4. Applied egg-rr43.4%

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

      \[\leadsto \color{blue}{t \cdot x} \]
    6. Step-by-step derivation
      1. *-commutative40.5%

        \[\leadsto \color{blue}{x \cdot t} \]
    7. Simplified40.5%

      \[\leadsto \color{blue}{x \cdot t} \]

    if -1.0999999999999999e-95 < x < 17000

    1. Initial program 98.0%

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

      \[\leadsto \color{blue}{5 \cdot y} \]
    3. Simplified58.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.1 \cdot 10^{-95}:\\ \;\;\;\;x \cdot t\\ \mathbf{elif}\;x \leq 17000:\\ \;\;\;\;y \cdot 5\\ \mathbf{else}:\\ \;\;\;\;x \cdot t\\ \end{array} \]

Alternative 10: 30.5% accurate, 5.0× speedup?

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

\\
x \cdot t
\end{array}
Derivation
  1. Initial program 98.9%

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

    \[\leadsto \color{blue}{t \cdot x} + y \cdot 5 \]
  3. Step-by-step derivation
    1. +-commutative56.0%

      \[\leadsto \color{blue}{y \cdot 5 + t \cdot x} \]
    2. fma-def56.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, 5, t \cdot x\right)} \]
    3. *-commutative56.0%

      \[\leadsto \mathsf{fma}\left(y, 5, \color{blue}{x \cdot t}\right) \]
  4. Applied egg-rr56.0%

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

    \[\leadsto \color{blue}{t \cdot x} \]
  6. Step-by-step derivation
    1. *-commutative33.8%

      \[\leadsto \color{blue}{x \cdot t} \]
  7. Simplified33.8%

    \[\leadsto \color{blue}{x \cdot t} \]
  8. Final simplification33.8%

    \[\leadsto x \cdot t \]

Reproduce

?
herbie shell --seed 2023196 
(FPCore (x y z t)
  :name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendOutside from plot-0.2.3.4, B"
  :precision binary64
  (+ (* x (+ (+ (+ (+ y z) z) y) t)) (* y 5.0)))