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

Percentage Accurate: 99.9% → 99.9%
Time: 8.3s
Alternatives: 11
Speedup: 1.2×

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 11 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: 99.9% accurate, 1.2× speedup?

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

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

    \[x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right) + y \cdot 5 \]
  2. Add Preprocessing
  3. Taylor expanded in z around -inf

    \[\leadsto \color{blue}{-1 \cdot \left(z \cdot \left(-2 \cdot x + -1 \cdot \frac{5 \cdot y + x \cdot \left(t + 2 \cdot y\right)}{z}\right)\right)} \]
  4. Applied rewrites96.8%

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

    \[\leadsto \color{blue}{5 \cdot y + x \cdot \left(t + \left(2 \cdot y + 2 \cdot z\right)\right)} \]
  6. Applied rewrites100.0%

    \[\leadsto \color{blue}{\mathsf{fma}\left(5, y, x \cdot \mathsf{fma}\left(2, y + z, t\right)\right)} \]
  7. Add Preprocessing

Alternative 2: 88.5% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \mathsf{fma}\left(2, y + z, t\right)\\ \mathbf{if}\;x \leq -6.5 \cdot 10^{-7}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq -7.4 \cdot 10^{-280}:\\ \;\;\;\;\mathsf{fma}\left(5, y, x \cdot \left(2 \cdot z\right)\right)\\ \mathbf{elif}\;x \leq 1.7:\\ \;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(y, 2, t\right), 5 \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (fma 2.0 (+ y z) t))))
   (if (<= x -6.5e-7)
     t_1
     (if (<= x -7.4e-280)
       (fma 5.0 y (* x (* 2.0 z)))
       (if (<= x 1.7) (fma x (fma y 2.0 t) (* 5.0 y)) t_1)))))
double code(double x, double y, double z, double t) {
	double t_1 = x * fma(2.0, (y + z), t);
	double tmp;
	if (x <= -6.5e-7) {
		tmp = t_1;
	} else if (x <= -7.4e-280) {
		tmp = fma(5.0, y, (x * (2.0 * z)));
	} else if (x <= 1.7) {
		tmp = fma(x, fma(y, 2.0, t), (5.0 * y));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t)
	t_1 = Float64(x * fma(2.0, Float64(y + z), t))
	tmp = 0.0
	if (x <= -6.5e-7)
		tmp = t_1;
	elseif (x <= -7.4e-280)
		tmp = fma(5.0, y, Float64(x * Float64(2.0 * z)));
	elseif (x <= 1.7)
		tmp = fma(x, fma(y, 2.0, t), Float64(5.0 * y));
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[(2.0 * N[(y + z), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -6.5e-7], t$95$1, If[LessEqual[x, -7.4e-280], N[(5.0 * y + N[(x * N[(2.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.7], N[(x * N[(y * 2.0 + t), $MachinePrecision] + N[(5.0 * y), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \mathsf{fma}\left(2, y + z, t\right)\\
\mathbf{if}\;x \leq -6.5 \cdot 10^{-7}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq -7.4 \cdot 10^{-280}:\\
\;\;\;\;\mathsf{fma}\left(5, y, x \cdot \left(2 \cdot z\right)\right)\\

\mathbf{elif}\;x \leq 1.7:\\
\;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(y, 2, t\right), 5 \cdot y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -6.50000000000000024e-7 or 1.69999999999999996 < x

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{x \cdot \left(t + \left(2 \cdot y + 2 \cdot z\right)\right)} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(t + \left(2 \cdot y + 2 \cdot z\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left(\left(2 \cdot y + 2 \cdot z\right) + t\right)} \]
      3. distribute-lft-outN/A

        \[\leadsto x \cdot \left(\color{blue}{2 \cdot \left(y + z\right)} + t\right) \]
      4. lower-fma.f64N/A

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

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

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

    if -6.50000000000000024e-7 < x < -7.3999999999999996e-280

    1. Initial program 99.9%

      \[x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right) + y \cdot 5 \]
    2. Add Preprocessing
    3. Taylor expanded in z around -inf

      \[\leadsto \color{blue}{-1 \cdot \left(z \cdot \left(-2 \cdot x + -1 \cdot \frac{5 \cdot y + x \cdot \left(t + 2 \cdot y\right)}{z}\right)\right)} \]
    4. Applied rewrites99.9%

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

      \[\leadsto \color{blue}{5 \cdot y + x \cdot \left(t + \left(2 \cdot y + 2 \cdot z\right)\right)} \]
    6. Applied rewrites100.0%

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

      \[\leadsto \mathsf{fma}\left(5, y, \color{blue}{2 \cdot \left(x \cdot z\right)}\right) \]
    8. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(5, y, \color{blue}{\left(2 \cdot x\right) \cdot z}\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(5, y, \color{blue}{\left(x \cdot 2\right)} \cdot z\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(5, y, \color{blue}{x \cdot \left(2 \cdot z\right)}\right) \]
      4. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(5, y, \color{blue}{x \cdot \left(2 \cdot z\right)}\right) \]
      5. lower-*.f6487.1

        \[\leadsto \mathsf{fma}\left(5, y, x \cdot \color{blue}{\left(2 \cdot z\right)}\right) \]
    9. Applied rewrites87.1%

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

    if -7.3999999999999996e-280 < x < 1.69999999999999996

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{5 \cdot y + x \cdot \left(t + 2 \cdot y\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{x \cdot \left(t + 2 \cdot y\right) + 5 \cdot y} \]
      2. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, t + 2 \cdot y, 5 \cdot y\right)} \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{2 \cdot y + t}, 5 \cdot y\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{y \cdot 2} + t, 5 \cdot y\right) \]
      5. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(y, 2, t\right)}, 5 \cdot y\right) \]
      6. lower-*.f6487.5

        \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(y, 2, t\right), \color{blue}{5 \cdot y}\right) \]
    5. Applied rewrites87.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(y, 2, t\right), 5 \cdot y\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 88.4% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \mathsf{fma}\left(2, y + z, t\right)\\ \mathbf{if}\;x \leq -6.5 \cdot 10^{-7}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq -8.2 \cdot 10^{-265}:\\ \;\;\;\;\mathsf{fma}\left(5, y, x \cdot \left(2 \cdot z\right)\right)\\ \mathbf{elif}\;x \leq 0.34:\\ \;\;\;\;\mathsf{fma}\left(y, 5, x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (fma 2.0 (+ y z) t))))
   (if (<= x -6.5e-7)
     t_1
     (if (<= x -8.2e-265)
       (fma 5.0 y (* x (* 2.0 z)))
       (if (<= x 0.34) (fma y 5.0 (* x t)) t_1)))))
double code(double x, double y, double z, double t) {
	double t_1 = x * fma(2.0, (y + z), t);
	double tmp;
	if (x <= -6.5e-7) {
		tmp = t_1;
	} else if (x <= -8.2e-265) {
		tmp = fma(5.0, y, (x * (2.0 * z)));
	} else if (x <= 0.34) {
		tmp = fma(y, 5.0, (x * t));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t)
	t_1 = Float64(x * fma(2.0, Float64(y + z), t))
	tmp = 0.0
	if (x <= -6.5e-7)
		tmp = t_1;
	elseif (x <= -8.2e-265)
		tmp = fma(5.0, y, Float64(x * Float64(2.0 * z)));
	elseif (x <= 0.34)
		tmp = fma(y, 5.0, Float64(x * t));
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[(2.0 * N[(y + z), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -6.5e-7], t$95$1, If[LessEqual[x, -8.2e-265], N[(5.0 * y + N[(x * N[(2.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.34], N[(y * 5.0 + N[(x * t), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \mathsf{fma}\left(2, y + z, t\right)\\
\mathbf{if}\;x \leq -6.5 \cdot 10^{-7}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq -8.2 \cdot 10^{-265}:\\
\;\;\;\;\mathsf{fma}\left(5, y, x \cdot \left(2 \cdot z\right)\right)\\

\mathbf{elif}\;x \leq 0.34:\\
\;\;\;\;\mathsf{fma}\left(y, 5, x \cdot t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -6.50000000000000024e-7 or 0.340000000000000024 < x

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{x \cdot \left(t + \left(2 \cdot y + 2 \cdot z\right)\right)} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(t + \left(2 \cdot y + 2 \cdot z\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left(\left(2 \cdot y + 2 \cdot z\right) + t\right)} \]
      3. distribute-lft-outN/A

        \[\leadsto x \cdot \left(\color{blue}{2 \cdot \left(y + z\right)} + t\right) \]
      4. lower-fma.f64N/A

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

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

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

    if -6.50000000000000024e-7 < x < -8.2e-265

    1. Initial program 99.9%

      \[x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right) + y \cdot 5 \]
    2. Add Preprocessing
    3. Taylor expanded in z around -inf

      \[\leadsto \color{blue}{-1 \cdot \left(z \cdot \left(-2 \cdot x + -1 \cdot \frac{5 \cdot y + x \cdot \left(t + 2 \cdot y\right)}{z}\right)\right)} \]
    4. Applied rewrites99.9%

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

      \[\leadsto \color{blue}{5 \cdot y + x \cdot \left(t + \left(2 \cdot y + 2 \cdot z\right)\right)} \]
    6. Applied rewrites100.0%

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

      \[\leadsto \mathsf{fma}\left(5, y, \color{blue}{2 \cdot \left(x \cdot z\right)}\right) \]
    8. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(5, y, \color{blue}{\left(2 \cdot x\right) \cdot z}\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(5, y, \color{blue}{\left(x \cdot 2\right)} \cdot z\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(5, y, \color{blue}{x \cdot \left(2 \cdot z\right)}\right) \]
      4. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(5, y, \color{blue}{x \cdot \left(2 \cdot z\right)}\right) \]
      5. lower-*.f6486.8

        \[\leadsto \mathsf{fma}\left(5, y, x \cdot \color{blue}{\left(2 \cdot z\right)}\right) \]
    9. Applied rewrites86.8%

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

    if -8.2e-265 < x < 0.340000000000000024

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{t \cdot x} + y \cdot 5 \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{x \cdot t} + y \cdot 5 \]
      2. lower-*.f6485.9

        \[\leadsto \color{blue}{x \cdot t} + y \cdot 5 \]
    5. Applied rewrites85.9%

      \[\leadsto \color{blue}{x \cdot t} + y \cdot 5 \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{x \cdot t} + y \cdot 5 \]
      2. lift-*.f64N/A

        \[\leadsto x \cdot t + \color{blue}{y \cdot 5} \]
      3. +-commutativeN/A

        \[\leadsto \color{blue}{y \cdot 5 + x \cdot t} \]
      4. lift-*.f64N/A

        \[\leadsto \color{blue}{y \cdot 5} + x \cdot t \]
      5. lower-fma.f6485.9

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, 5, x \cdot t\right)} \]
    7. Applied rewrites85.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, 5, x \cdot t\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 4: 64.9% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \mathsf{fma}\left(2, z, t\right)\\ \mathbf{if}\;x \leq -4.3 \cdot 10^{+21}:\\ \;\;\;\;x \cdot \left(y + \left(y + t\right)\right)\\ \mathbf{elif}\;x \leq -2.1 \cdot 10^{-144}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 0.34:\\ \;\;\;\;5 \cdot y\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (fma 2.0 z t))))
   (if (<= x -4.3e+21)
     (* x (+ y (+ y t)))
     (if (<= x -2.1e-144) t_1 (if (<= x 0.34) (* 5.0 y) t_1)))))
double code(double x, double y, double z, double t) {
	double t_1 = x * fma(2.0, z, t);
	double tmp;
	if (x <= -4.3e+21) {
		tmp = x * (y + (y + t));
	} else if (x <= -2.1e-144) {
		tmp = t_1;
	} else if (x <= 0.34) {
		tmp = 5.0 * y;
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t)
	t_1 = Float64(x * fma(2.0, z, t))
	tmp = 0.0
	if (x <= -4.3e+21)
		tmp = Float64(x * Float64(y + Float64(y + t)));
	elseif (x <= -2.1e-144)
		tmp = t_1;
	elseif (x <= 0.34)
		tmp = Float64(5.0 * y);
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[(2.0 * z + t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.3e+21], N[(x * N[(y + N[(y + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2.1e-144], t$95$1, If[LessEqual[x, 0.34], N[(5.0 * y), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \mathsf{fma}\left(2, z, t\right)\\
\mathbf{if}\;x \leq -4.3 \cdot 10^{+21}:\\
\;\;\;\;x \cdot \left(y + \left(y + t\right)\right)\\

\mathbf{elif}\;x \leq -2.1 \cdot 10^{-144}:\\
\;\;\;\;t\_1\\

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

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


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

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{x \cdot \left(t + \left(2 \cdot y + 2 \cdot z\right)\right)} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(t + \left(2 \cdot y + 2 \cdot z\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left(\left(2 \cdot y + 2 \cdot z\right) + t\right)} \]
      3. distribute-lft-outN/A

        \[\leadsto x \cdot \left(\color{blue}{2 \cdot \left(y + z\right)} + t\right) \]
      4. lower-fma.f64N/A

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

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

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(2, y + z, t\right)} \]
    6. Taylor expanded in z around 0

      \[\leadsto \color{blue}{x \cdot \left(t + 2 \cdot y\right)} \]
    7. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(t + 2 \cdot y\right)} \]
      2. count-2N/A

        \[\leadsto x \cdot \left(t + \color{blue}{\left(y + y\right)}\right) \]
      3. associate-+l+N/A

        \[\leadsto x \cdot \color{blue}{\left(\left(t + y\right) + y\right)} \]
      4. +-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left(y + \left(t + y\right)\right)} \]
      5. lower-+.f64N/A

        \[\leadsto x \cdot \color{blue}{\left(y + \left(t + y\right)\right)} \]
      6. +-commutativeN/A

        \[\leadsto x \cdot \left(y + \color{blue}{\left(y + t\right)}\right) \]
      7. lower-+.f6477.5

        \[\leadsto x \cdot \left(y + \color{blue}{\left(y + t\right)}\right) \]
    8. Applied rewrites77.5%

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

    if -4.3e21 < x < -2.1000000000000001e-144 or 0.340000000000000024 < x

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{x \cdot \left(t + 2 \cdot z\right)} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(t + 2 \cdot z\right)} \]
      2. +-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left(2 \cdot z + t\right)} \]
      3. lower-fma.f6470.6

        \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(2, z, t\right)} \]
    5. Applied rewrites70.6%

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

    if -2.1000000000000001e-144 < x < 0.340000000000000024

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{5 \cdot y} \]
    4. Step-by-step derivation
      1. lower-*.f6468.3

        \[\leadsto \color{blue}{5 \cdot y} \]
    5. Applied rewrites68.3%

      \[\leadsto \color{blue}{5 \cdot y} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 5: 99.1% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \mathsf{fma}\left(2, y + z, t\right)\\ \mathbf{if}\;x \leq -12600:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 2.5:\\ \;\;\;\;\mathsf{fma}\left(y, 5, x \cdot \left(t + \left(z + z\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (fma 2.0 (+ y z) t))))
   (if (<= x -12600.0)
     t_1
     (if (<= x 2.5) (fma y 5.0 (* x (+ t (+ z z)))) t_1))))
double code(double x, double y, double z, double t) {
	double t_1 = x * fma(2.0, (y + z), t);
	double tmp;
	if (x <= -12600.0) {
		tmp = t_1;
	} else if (x <= 2.5) {
		tmp = fma(y, 5.0, (x * (t + (z + z))));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t)
	t_1 = Float64(x * fma(2.0, Float64(y + z), t))
	tmp = 0.0
	if (x <= -12600.0)
		tmp = t_1;
	elseif (x <= 2.5)
		tmp = fma(y, 5.0, Float64(x * Float64(t + Float64(z + z))));
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[(2.0 * N[(y + z), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -12600.0], t$95$1, If[LessEqual[x, 2.5], N[(y * 5.0 + N[(x * N[(t + N[(z + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \mathsf{fma}\left(2, y + z, t\right)\\
\mathbf{if}\;x \leq -12600:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 2.5:\\
\;\;\;\;\mathsf{fma}\left(y, 5, x \cdot \left(t + \left(z + z\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -12600 or 2.5 < x

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{x \cdot \left(t + \left(2 \cdot y + 2 \cdot z\right)\right)} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(t + \left(2 \cdot y + 2 \cdot z\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left(\left(2 \cdot y + 2 \cdot z\right) + t\right)} \]
      3. distribute-lft-outN/A

        \[\leadsto x \cdot \left(\color{blue}{2 \cdot \left(y + z\right)} + t\right) \]
      4. lower-fma.f64N/A

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

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

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

    if -12600 < x < 2.5

    1. Initial program 99.9%

      \[x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right) + y \cdot 5 \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto x \cdot \left(\left(\left(\color{blue}{\left(y + z\right)} + z\right) + y\right) + t\right) + y \cdot 5 \]
      2. lift-+.f64N/A

        \[\leadsto x \cdot \left(\left(\color{blue}{\left(\left(y + z\right) + z\right)} + y\right) + t\right) + y \cdot 5 \]
      3. lift-+.f64N/A

        \[\leadsto x \cdot \left(\color{blue}{\left(\left(\left(y + z\right) + z\right) + y\right)} + t\right) + y \cdot 5 \]
      4. lift-+.f64N/A

        \[\leadsto x \cdot \color{blue}{\left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right)} + y \cdot 5 \]
      5. lift-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right)} + y \cdot 5 \]
      6. lift-*.f64N/A

        \[\leadsto x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right) + \color{blue}{y \cdot 5} \]
      7. +-commutativeN/A

        \[\leadsto \color{blue}{y \cdot 5 + x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right)} \]
      8. lift-*.f64N/A

        \[\leadsto \color{blue}{y \cdot 5} + x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right) \]
      9. lower-fma.f64100.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -12600:\\ \;\;\;\;x \cdot \mathsf{fma}\left(2, y + z, t\right)\\ \mathbf{elif}\;x \leq 2.5:\\ \;\;\;\;\mathsf{fma}\left(y, 5, x \cdot \left(t + \left(z + z\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(2, y + z, t\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 87.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \mathsf{fma}\left(2, y + z, t\right)\\ \mathbf{if}\;x \leq -3.4 \cdot 10^{-129}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 0.34:\\ \;\;\;\;\mathsf{fma}\left(y, 5, x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (fma 2.0 (+ y z) t))))
   (if (<= x -3.4e-129) t_1 (if (<= x 0.34) (fma y 5.0 (* x t)) t_1))))
double code(double x, double y, double z, double t) {
	double t_1 = x * fma(2.0, (y + z), t);
	double tmp;
	if (x <= -3.4e-129) {
		tmp = t_1;
	} else if (x <= 0.34) {
		tmp = fma(y, 5.0, (x * t));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t)
	t_1 = Float64(x * fma(2.0, Float64(y + z), t))
	tmp = 0.0
	if (x <= -3.4e-129)
		tmp = t_1;
	elseif (x <= 0.34)
		tmp = fma(y, 5.0, Float64(x * t));
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[(2.0 * N[(y + z), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.4e-129], t$95$1, If[LessEqual[x, 0.34], N[(y * 5.0 + N[(x * t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \mathsf{fma}\left(2, y + z, t\right)\\
\mathbf{if}\;x \leq -3.4 \cdot 10^{-129}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 0.34:\\
\;\;\;\;\mathsf{fma}\left(y, 5, x \cdot t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.40000000000000013e-129 or 0.340000000000000024 < x

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{x \cdot \left(t + \left(2 \cdot y + 2 \cdot z\right)\right)} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(t + \left(2 \cdot y + 2 \cdot z\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left(\left(2 \cdot y + 2 \cdot z\right) + t\right)} \]
      3. distribute-lft-outN/A

        \[\leadsto x \cdot \left(\color{blue}{2 \cdot \left(y + z\right)} + t\right) \]
      4. lower-fma.f64N/A

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

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

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

    if -3.40000000000000013e-129 < x < 0.340000000000000024

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{t \cdot x} + y \cdot 5 \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{x \cdot t} + y \cdot 5 \]
      2. lower-*.f6485.1

        \[\leadsto \color{blue}{x \cdot t} + y \cdot 5 \]
    5. Applied rewrites85.1%

      \[\leadsto \color{blue}{x \cdot t} + y \cdot 5 \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{x \cdot t} + y \cdot 5 \]
      2. lift-*.f64N/A

        \[\leadsto x \cdot t + \color{blue}{y \cdot 5} \]
      3. +-commutativeN/A

        \[\leadsto \color{blue}{y \cdot 5 + x \cdot t} \]
      4. lift-*.f64N/A

        \[\leadsto \color{blue}{y \cdot 5} + x \cdot t \]
      5. lower-fma.f6485.1

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, 5, x \cdot t\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 78.0% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := y \cdot \mathsf{fma}\left(x, 2, 5\right)\\ \mathbf{if}\;y \leq -4.4 \cdot 10^{+74}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{+28}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(2, z, t\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* y (fma x 2.0 5.0))))
   (if (<= y -4.4e+74) t_1 (if (<= y 3.3e+28) (* x (fma 2.0 z t)) t_1))))
double code(double x, double y, double z, double t) {
	double t_1 = y * fma(x, 2.0, 5.0);
	double tmp;
	if (y <= -4.4e+74) {
		tmp = t_1;
	} else if (y <= 3.3e+28) {
		tmp = x * fma(2.0, z, t);
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t)
	t_1 = Float64(y * fma(x, 2.0, 5.0))
	tmp = 0.0
	if (y <= -4.4e+74)
		tmp = t_1;
	elseif (y <= 3.3e+28)
		tmp = Float64(x * fma(2.0, z, t));
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(x * 2.0 + 5.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.4e+74], t$95$1, If[LessEqual[y, 3.3e+28], N[(x * N[(2.0 * z + t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := y \cdot \mathsf{fma}\left(x, 2, 5\right)\\
\mathbf{if}\;y \leq -4.4 \cdot 10^{+74}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 3.3 \cdot 10^{+28}:\\
\;\;\;\;x \cdot \mathsf{fma}\left(2, z, t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.4000000000000002e74 or 3.3e28 < y

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{y \cdot \left(5 + 2 \cdot x\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto y \cdot \color{blue}{\left(2 \cdot x + 5\right)} \]
      2. metadata-evalN/A

        \[\leadsto y \cdot \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot x + 5\right) \]
      3. distribute-lft-neg-inN/A

        \[\leadsto y \cdot \left(\color{blue}{\left(\mathsf{neg}\left(-2 \cdot x\right)\right)} + 5\right) \]
      4. neg-sub0N/A

        \[\leadsto y \cdot \left(\color{blue}{\left(0 - -2 \cdot x\right)} + 5\right) \]
      5. associate--r-N/A

        \[\leadsto y \cdot \color{blue}{\left(0 - \left(-2 \cdot x - 5\right)\right)} \]
      6. neg-sub0N/A

        \[\leadsto y \cdot \color{blue}{\left(\mathsf{neg}\left(\left(-2 \cdot x - 5\right)\right)\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{y \cdot \left(\mathsf{neg}\left(\left(-2 \cdot x - 5\right)\right)\right)} \]
      8. neg-sub0N/A

        \[\leadsto y \cdot \color{blue}{\left(0 - \left(-2 \cdot x - 5\right)\right)} \]
      9. associate--r-N/A

        \[\leadsto y \cdot \color{blue}{\left(\left(0 - -2 \cdot x\right) + 5\right)} \]
      10. neg-sub0N/A

        \[\leadsto y \cdot \left(\color{blue}{\left(\mathsf{neg}\left(-2 \cdot x\right)\right)} + 5\right) \]
      11. distribute-lft-neg-inN/A

        \[\leadsto y \cdot \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right) \cdot x} + 5\right) \]
      12. metadata-evalN/A

        \[\leadsto y \cdot \left(\color{blue}{2} \cdot x + 5\right) \]
      13. *-commutativeN/A

        \[\leadsto y \cdot \left(\color{blue}{x \cdot 2} + 5\right) \]
      14. lower-fma.f6483.5

        \[\leadsto y \cdot \color{blue}{\mathsf{fma}\left(x, 2, 5\right)} \]
    5. Applied rewrites83.5%

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

    if -4.4000000000000002e74 < y < 3.3e28

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{x \cdot \left(t + 2 \cdot z\right)} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(t + 2 \cdot z\right)} \]
      2. +-commutativeN/A

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

        \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(2, z, t\right)} \]
    5. Applied rewrites76.5%

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(2, z, t\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 63.0% accurate, 1.1× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -6.50000000000000024e-7 or 0.340000000000000024 < x

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{x \cdot \left(t + \left(2 \cdot y + 2 \cdot z\right)\right)} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(t + \left(2 \cdot y + 2 \cdot z\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left(\left(2 \cdot y + 2 \cdot z\right) + t\right)} \]
      3. distribute-lft-outN/A

        \[\leadsto x \cdot \left(\color{blue}{2 \cdot \left(y + z\right)} + t\right) \]
      4. lower-fma.f64N/A

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

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

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(2, y + z, t\right)} \]
    6. Taylor expanded in z around 0

      \[\leadsto \color{blue}{x \cdot \left(t + 2 \cdot y\right)} \]
    7. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(t + 2 \cdot y\right)} \]
      2. count-2N/A

        \[\leadsto x \cdot \left(t + \color{blue}{\left(y + y\right)}\right) \]
      3. associate-+l+N/A

        \[\leadsto x \cdot \color{blue}{\left(\left(t + y\right) + y\right)} \]
      4. +-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left(y + \left(t + y\right)\right)} \]
      5. lower-+.f64N/A

        \[\leadsto x \cdot \color{blue}{\left(y + \left(t + y\right)\right)} \]
      6. +-commutativeN/A

        \[\leadsto x \cdot \left(y + \color{blue}{\left(y + t\right)}\right) \]
      7. lower-+.f6472.3

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

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

    if -6.50000000000000024e-7 < x < 0.340000000000000024

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{5 \cdot y} \]
    4. Step-by-step derivation
      1. lower-*.f6462.0

        \[\leadsto \color{blue}{5 \cdot y} \]
    5. Applied rewrites62.0%

      \[\leadsto \color{blue}{5 \cdot y} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 46.8% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0135:\\
\;\;\;\;x \cdot \left(y + y\right)\\

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

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


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

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{x \cdot \left(t + \left(2 \cdot y + 2 \cdot z\right)\right)} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(t + \left(2 \cdot y + 2 \cdot z\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left(\left(2 \cdot y + 2 \cdot z\right) + t\right)} \]
      3. distribute-lft-outN/A

        \[\leadsto x \cdot \left(\color{blue}{2 \cdot \left(y + z\right)} + t\right) \]
      4. lower-fma.f64N/A

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

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

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

      \[\leadsto \color{blue}{2 \cdot \left(x \cdot y\right)} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

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

        \[\leadsto \color{blue}{x \cdot \left(y \cdot 2\right)} \]
      3. *-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left(2 \cdot y\right)} \]
      4. lower-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(2 \cdot y\right)} \]
      5. count-2N/A

        \[\leadsto x \cdot \color{blue}{\left(y + y\right)} \]
      6. lower-+.f6441.1

        \[\leadsto x \cdot \color{blue}{\left(y + y\right)} \]
    8. Applied rewrites41.1%

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

    if -0.0134999999999999998 < x < 0.340000000000000024

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{5 \cdot y} \]
    4. Step-by-step derivation
      1. lower-*.f6461.5

        \[\leadsto \color{blue}{5 \cdot y} \]
    5. Applied rewrites61.5%

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

    if 0.340000000000000024 < x

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{t \cdot x} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{x \cdot t} \]
      2. lower-*.f6444.4

        \[\leadsto \color{blue}{x \cdot t} \]
    5. Applied rewrites44.4%

      \[\leadsto \color{blue}{x \cdot t} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 10: 47.4% accurate, 1.4× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -6.50000000000000024e-7 or 0.340000000000000024 < x

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{t \cdot x} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{x \cdot t} \]
      2. lower-*.f6441.0

        \[\leadsto \color{blue}{x \cdot t} \]
    5. Applied rewrites41.0%

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

    if -6.50000000000000024e-7 < x < 0.340000000000000024

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{5 \cdot y} \]
    4. Step-by-step derivation
      1. lower-*.f6462.0

        \[\leadsto \color{blue}{5 \cdot y} \]
    5. Applied rewrites62.0%

      \[\leadsto \color{blue}{5 \cdot y} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 11: 29.4% accurate, 4.3× speedup?

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

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

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

    \[\leadsto \color{blue}{5 \cdot y} \]
  4. Step-by-step derivation
    1. lower-*.f6432.1

      \[\leadsto \color{blue}{5 \cdot y} \]
  5. Applied rewrites32.1%

    \[\leadsto \color{blue}{5 \cdot y} \]
  6. Add Preprocessing

Reproduce

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