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

Percentage Accurate: 99.9% → 99.9%
Time: 10.3s
Alternatives: 14
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 14 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, 0.1× speedup?

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

\\
\mathsf{fma}\left(x, 2 \cdot \left(y + z\right) + t, y \cdot 5\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. Step-by-step derivation
    1. fma-define99.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. Add Preprocessing
  5. Add Preprocessing

Alternative 2: 64.0% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := 2 \cdot \left(x \cdot \left(y + z\right)\right)\\ \mathbf{if}\;x \leq -9.2 \cdot 10^{-15}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-178}:\\ \;\;\;\;y \cdot 5\\ \mathbf{elif}\;x \leq 5.9 \cdot 10^{+16} \lor \neg \left(x \leq 1.75 \cdot 10^{+232}\right):\\ \;\;\;\;x \cdot \left(t + 2 \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* 2.0 (* x (+ y z)))))
   (if (<= x -9.2e-15)
     t_1
     (if (<= x 5.2e-178)
       (* y 5.0)
       (if (or (<= x 5.9e+16) (not (<= x 1.75e+232)))
         (* x (+ t (* 2.0 z)))
         t_1)))))
double code(double x, double y, double z, double t) {
	double t_1 = 2.0 * (x * (y + z));
	double tmp;
	if (x <= -9.2e-15) {
		tmp = t_1;
	} else if (x <= 5.2e-178) {
		tmp = y * 5.0;
	} else if ((x <= 5.9e+16) || !(x <= 1.75e+232)) {
		tmp = x * (t + (2.0 * 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 = 2.0d0 * (x * (y + z))
    if (x <= (-9.2d-15)) then
        tmp = t_1
    else if (x <= 5.2d-178) then
        tmp = y * 5.0d0
    else if ((x <= 5.9d+16) .or. (.not. (x <= 1.75d+232))) then
        tmp = x * (t + (2.0d0 * 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 = 2.0 * (x * (y + z));
	double tmp;
	if (x <= -9.2e-15) {
		tmp = t_1;
	} else if (x <= 5.2e-178) {
		tmp = y * 5.0;
	} else if ((x <= 5.9e+16) || !(x <= 1.75e+232)) {
		tmp = x * (t + (2.0 * z));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = 2.0 * (x * (y + z))
	tmp = 0
	if x <= -9.2e-15:
		tmp = t_1
	elif x <= 5.2e-178:
		tmp = y * 5.0
	elif (x <= 5.9e+16) or not (x <= 1.75e+232):
		tmp = x * (t + (2.0 * z))
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(2.0 * Float64(x * Float64(y + z)))
	tmp = 0.0
	if (x <= -9.2e-15)
		tmp = t_1;
	elseif (x <= 5.2e-178)
		tmp = Float64(y * 5.0);
	elseif ((x <= 5.9e+16) || !(x <= 1.75e+232))
		tmp = Float64(x * Float64(t + Float64(2.0 * z)));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = 2.0 * (x * (y + z));
	tmp = 0.0;
	if (x <= -9.2e-15)
		tmp = t_1;
	elseif (x <= 5.2e-178)
		tmp = y * 5.0;
	elseif ((x <= 5.9e+16) || ~((x <= 1.75e+232)))
		tmp = x * (t + (2.0 * z));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(2.0 * N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -9.2e-15], t$95$1, If[LessEqual[x, 5.2e-178], N[(y * 5.0), $MachinePrecision], If[Or[LessEqual[x, 5.9e+16], N[Not[LessEqual[x, 1.75e+232]], $MachinePrecision]], N[(x * N[(t + N[(2.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 5.2 \cdot 10^{-178}:\\
\;\;\;\;y \cdot 5\\

\mathbf{elif}\;x \leq 5.9 \cdot 10^{+16} \lor \neg \left(x \leq 1.75 \cdot 10^{+232}\right):\\
\;\;\;\;x \cdot \left(t + 2 \cdot z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -9.19999999999999961e-15 or 5.9e16 < x < 1.75000000000000006e232

    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-define100.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. Add Preprocessing
    5. Taylor expanded in x around inf 100.0%

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

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

    if -9.19999999999999961e-15 < x < 5.19999999999999997e-178

    1. Initial program 99.8%

      \[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 66.5%

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

    if 5.19999999999999997e-178 < x < 5.9e16 or 1.75000000000000006e232 < x

    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 70.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9.2 \cdot 10^{-15}:\\ \;\;\;\;2 \cdot \left(x \cdot \left(y + z\right)\right)\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-178}:\\ \;\;\;\;y \cdot 5\\ \mathbf{elif}\;x \leq 5.9 \cdot 10^{+16} \lor \neg \left(x \leq 1.75 \cdot 10^{+232}\right):\\ \;\;\;\;x \cdot \left(t + 2 \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(x \cdot \left(y + z\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 47.0% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := y \cdot \left(x \cdot 2\right)\\ \mathbf{if}\;x \leq -2.5:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 1550000:\\ \;\;\;\;y \cdot 5\\ \mathbf{elif}\;x \leq 2.85 \cdot 10^{+230} \lor \neg \left(x \leq 4.6 \cdot 10^{+292}\right):\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot t\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* y (* x 2.0))))
   (if (<= x -2.5)
     t_1
     (if (<= x 1550000.0)
       (* y 5.0)
       (if (or (<= x 2.85e+230) (not (<= x 4.6e+292))) t_1 (* x t))))))
double code(double x, double y, double z, double t) {
	double t_1 = y * (x * 2.0);
	double tmp;
	if (x <= -2.5) {
		tmp = t_1;
	} else if (x <= 1550000.0) {
		tmp = y * 5.0;
	} else if ((x <= 2.85e+230) || !(x <= 4.6e+292)) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_1 = y * (x * 2.0d0)
    if (x <= (-2.5d0)) then
        tmp = t_1
    else if (x <= 1550000.0d0) then
        tmp = y * 5.0d0
    else if ((x <= 2.85d+230) .or. (.not. (x <= 4.6d+292))) then
        tmp = t_1
    else
        tmp = x * t
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = y * (x * 2.0);
	double tmp;
	if (x <= -2.5) {
		tmp = t_1;
	} else if (x <= 1550000.0) {
		tmp = y * 5.0;
	} else if ((x <= 2.85e+230) || !(x <= 4.6e+292)) {
		tmp = t_1;
	} else {
		tmp = x * t;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = y * (x * 2.0)
	tmp = 0
	if x <= -2.5:
		tmp = t_1
	elif x <= 1550000.0:
		tmp = y * 5.0
	elif (x <= 2.85e+230) or not (x <= 4.6e+292):
		tmp = t_1
	else:
		tmp = x * t
	return tmp
function code(x, y, z, t)
	t_1 = Float64(y * Float64(x * 2.0))
	tmp = 0.0
	if (x <= -2.5)
		tmp = t_1;
	elseif (x <= 1550000.0)
		tmp = Float64(y * 5.0);
	elseif ((x <= 2.85e+230) || !(x <= 4.6e+292))
		tmp = t_1;
	else
		tmp = Float64(x * t);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = y * (x * 2.0);
	tmp = 0.0;
	if (x <= -2.5)
		tmp = t_1;
	elseif (x <= 1550000.0)
		tmp = y * 5.0;
	elseif ((x <= 2.85e+230) || ~((x <= 4.6e+292)))
		tmp = t_1;
	else
		tmp = x * t;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(x * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.5], t$95$1, If[LessEqual[x, 1550000.0], N[(y * 5.0), $MachinePrecision], If[Or[LessEqual[x, 2.85e+230], N[Not[LessEqual[x, 4.6e+292]], $MachinePrecision]], t$95$1, N[(x * t), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := y \cdot \left(x \cdot 2\right)\\
\mathbf{if}\;x \leq -2.5:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;x \leq 2.85 \cdot 10^{+230} \lor \neg \left(x \leq 4.6 \cdot 10^{+292}\right):\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.5 or 1.55e6 < x < 2.8500000000000001e230 or 4.59999999999999997e292 < 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 inf 44.9%

      \[\leadsto \color{blue}{y \cdot \left(5 + 2 \cdot x\right)} \]
    4. Simplified44.9%

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

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

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

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

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

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

    if -2.5 < x < 1.55e6

    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 56.0%

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

    if 2.8500000000000001e230 < x < 4.59999999999999997e292

    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 55.5%

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

      \[\leadsto \color{blue}{x \cdot t} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification50.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.5:\\ \;\;\;\;y \cdot \left(x \cdot 2\right)\\ \mathbf{elif}\;x \leq 1550000:\\ \;\;\;\;y \cdot 5\\ \mathbf{elif}\;x \leq 2.85 \cdot 10^{+230} \lor \neg \left(x \leq 4.6 \cdot 10^{+292}\right):\\ \;\;\;\;y \cdot \left(x \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot t\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 47.3% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;x \leq -1.9 \cdot 10^{+125}:\\
\;\;\;\;x \cdot t\\

\mathbf{elif}\;x \leq -2.5:\\
\;\;\;\;y \cdot \left(x \cdot 2\right)\\

\mathbf{elif}\;x \leq 2.75 \cdot 10^{-8}:\\
\;\;\;\;y \cdot 5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -4.9999999999999998e199 or 2.7500000000000001e-8 < 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 z around inf 53.7%

      \[\leadsto \color{blue}{2 \cdot \left(x \cdot z\right)} \]
    4. Simplified53.7%

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

    if -4.9999999999999998e199 < x < -1.90000000000000001e125

    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 58.4%

      \[\leadsto \color{blue}{t \cdot x} \]
    4. Simplified58.4%

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

    if -1.90000000000000001e125 < x < -2.5

    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 inf 57.5%

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

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

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

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

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

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

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

    if -2.5 < x < 2.7500000000000001e-8

    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 57.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{+199}:\\ \;\;\;\;z \cdot \left(x \cdot 2\right)\\ \mathbf{elif}\;x \leq -1.9 \cdot 10^{+125}:\\ \;\;\;\;x \cdot t\\ \mathbf{elif}\;x \leq -2.5:\\ \;\;\;\;y \cdot \left(x \cdot 2\right)\\ \mathbf{elif}\;x \leq 2.75 \cdot 10^{-8}:\\ \;\;\;\;y \cdot 5\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot 2\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 99.5% accurate, 0.6× speedup?

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

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

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

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


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

    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-define100.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. Add Preprocessing
    5. Taylor expanded in x around inf 100.0%

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

    if -2.5 < x < 1.85e-43

    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 99.9%

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

    if 1.85e-43 < 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. Step-by-step derivation
      1. fma-define100.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. Add Preprocessing
    5. Taylor expanded in x around inf 100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.5:\\ \;\;\;\;x \cdot \left(2 \cdot \left(y + z\right) + t\right)\\ \mathbf{elif}\;x \leq 1.85 \cdot 10^{-43}:\\ \;\;\;\;y \cdot 5 + x \cdot \left(t + 2 \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(t + \left(2 \cdot \left(y + z\right) + 5 \cdot \frac{y}{x}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 89.2% accurate, 0.6× speedup?

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

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

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

\mathbf{elif}\;x \leq 9.8 \cdot 10^{-17}:\\
\;\;\;\;y \cdot 5 + x \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.44999999999999995e-25 or 9.80000000000000024e-17 < 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. Step-by-step derivation
      1. fma-define100.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. Add Preprocessing
    5. Taylor expanded in x around inf 99.1%

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

    if -2.44999999999999995e-25 < x < -7.00000000000000054e-163

    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 99.9%

      \[\leadsto x \cdot \left(\color{blue}{2 \cdot z} + t\right) + y \cdot 5 \]
    4. Taylor expanded in t around 0 88.9%

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

    if -7.00000000000000054e-163 < x < 9.80000000000000024e-17

    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 99.9%

      \[\leadsto x \cdot \left(\color{blue}{2 \cdot z} + t\right) + y \cdot 5 \]
    4. Taylor expanded in z around 0 88.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.45 \cdot 10^{-25}:\\ \;\;\;\;x \cdot \left(2 \cdot \left(y + z\right) + t\right)\\ \mathbf{elif}\;x \leq -7 \cdot 10^{-163}:\\ \;\;\;\;2 \cdot \left(x \cdot z\right) + y \cdot 5\\ \mathbf{elif}\;x \leq 9.8 \cdot 10^{-17}:\\ \;\;\;\;y \cdot 5 + x \cdot t\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(2 \cdot \left(y + z\right) + t\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 73.0% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := 2 \cdot \left(x \cdot \left(y + z\right)\right)\\ \mathbf{if}\;x \leq -0.24:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 4.4 \cdot 10^{-8}:\\ \;\;\;\;y \cdot 5 + x \cdot t\\ \mathbf{elif}\;x \leq 1.16 \cdot 10^{+232}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(t + 2 \cdot z\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* 2.0 (* x (+ y z)))))
   (if (<= x -0.24)
     t_1
     (if (<= x 4.4e-8)
       (+ (* y 5.0) (* x t))
       (if (<= x 1.16e+232) t_1 (* x (+ t (* 2.0 z))))))))
double code(double x, double y, double z, double t) {
	double t_1 = 2.0 * (x * (y + z));
	double tmp;
	if (x <= -0.24) {
		tmp = t_1;
	} else if (x <= 4.4e-8) {
		tmp = (y * 5.0) + (x * t);
	} else if (x <= 1.16e+232) {
		tmp = t_1;
	} else {
		tmp = x * (t + (2.0 * z));
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: tmp
    t_1 = 2.0d0 * (x * (y + z))
    if (x <= (-0.24d0)) then
        tmp = t_1
    else if (x <= 4.4d-8) then
        tmp = (y * 5.0d0) + (x * t)
    else if (x <= 1.16d+232) then
        tmp = t_1
    else
        tmp = x * (t + (2.0d0 * z))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = 2.0 * (x * (y + z));
	double tmp;
	if (x <= -0.24) {
		tmp = t_1;
	} else if (x <= 4.4e-8) {
		tmp = (y * 5.0) + (x * t);
	} else if (x <= 1.16e+232) {
		tmp = t_1;
	} else {
		tmp = x * (t + (2.0 * z));
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = 2.0 * (x * (y + z))
	tmp = 0
	if x <= -0.24:
		tmp = t_1
	elif x <= 4.4e-8:
		tmp = (y * 5.0) + (x * t)
	elif x <= 1.16e+232:
		tmp = t_1
	else:
		tmp = x * (t + (2.0 * z))
	return tmp
function code(x, y, z, t)
	t_1 = Float64(2.0 * Float64(x * Float64(y + z)))
	tmp = 0.0
	if (x <= -0.24)
		tmp = t_1;
	elseif (x <= 4.4e-8)
		tmp = Float64(Float64(y * 5.0) + Float64(x * t));
	elseif (x <= 1.16e+232)
		tmp = t_1;
	else
		tmp = Float64(x * Float64(t + Float64(2.0 * z)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = 2.0 * (x * (y + z));
	tmp = 0.0;
	if (x <= -0.24)
		tmp = t_1;
	elseif (x <= 4.4e-8)
		tmp = (y * 5.0) + (x * t);
	elseif (x <= 1.16e+232)
		tmp = t_1;
	else
		tmp = x * (t + (2.0 * z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(2.0 * N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -0.24], t$95$1, If[LessEqual[x, 4.4e-8], N[(N[(y * 5.0), $MachinePrecision] + N[(x * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.16e+232], t$95$1, N[(x * N[(t + N[(2.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 4.4 \cdot 10^{-8}:\\
\;\;\;\;y \cdot 5 + x \cdot t\\

\mathbf{elif}\;x \leq 1.16 \cdot 10^{+232}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -0.23999999999999999 or 4.3999999999999997e-8 < x < 1.16e232

    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-define100.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. Add Preprocessing
    5. Taylor expanded in x around inf 99.8%

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

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

    if -0.23999999999999999 < x < 4.3999999999999997e-8

    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 99.9%

      \[\leadsto x \cdot \left(\color{blue}{2 \cdot z} + t\right) + y \cdot 5 \]
    4. Taylor expanded in z around 0 83.9%

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

    if 1.16e232 < 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 86.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -0.24:\\ \;\;\;\;2 \cdot \left(x \cdot \left(y + z\right)\right)\\ \mathbf{elif}\;x \leq 4.4 \cdot 10^{-8}:\\ \;\;\;\;y \cdot 5 + x \cdot t\\ \mathbf{elif}\;x \leq 1.16 \cdot 10^{+232}:\\ \;\;\;\;2 \cdot \left(x \cdot \left(y + z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(t + 2 \cdot z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 99.1% accurate, 0.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.5 or 7.79999999999999954e-16 < 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. Step-by-step derivation
      1. fma-define100.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. Add Preprocessing
    5. Taylor expanded in x around inf 99.8%

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

    if -2.5 < x < 7.79999999999999954e-16

    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 99.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.5 \lor \neg \left(x \leq 7.8 \cdot 10^{-16}\right):\\ \;\;\;\;x \cdot \left(2 \cdot \left(y + z\right) + t\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot 5 + x \cdot \left(t + 2 \cdot z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 88.9% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.8 \cdot 10^{-15} \lor \neg \left(x \leq 5.4 \cdot 10^{-17}\right):\\
\;\;\;\;x \cdot \left(2 \cdot \left(y + z\right) + t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -4.7999999999999999e-15 or 5.4000000000000002e-17 < 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. Step-by-step derivation
      1. fma-define100.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. Add Preprocessing
    5. Taylor expanded in x around inf 99.8%

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

    if -4.7999999999999999e-15 < x < 5.4000000000000002e-17

    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 99.9%

      \[\leadsto x \cdot \left(\color{blue}{2 \cdot z} + t\right) + y \cdot 5 \]
    4. Taylor expanded in z around 0 84.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.8 \cdot 10^{-15} \lor \neg \left(x \leq 5.4 \cdot 10^{-17}\right):\\ \;\;\;\;x \cdot \left(2 \cdot \left(y + z\right) + t\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot 5 + x \cdot t\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 78.5% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.25 \cdot 10^{+35} \lor \neg \left(y \leq 1.04 \cdot 10^{+77}\right):\\
\;\;\;\;y \cdot \left(5 + x \cdot 2\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.2500000000000002e35 or 1.04e77 < y

    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 inf 83.5%

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

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

    if -3.2500000000000002e35 < y < 1.04e77

    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 76.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.25 \cdot 10^{+35} \lor \neg \left(y \leq 1.04 \cdot 10^{+77}\right):\\ \;\;\;\;y \cdot \left(5 + x \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(t + 2 \cdot z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 63.9% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{-15} \lor \neg \left(x \leq 3.2 \cdot 10^{-8}\right):\\
\;\;\;\;2 \cdot \left(x \cdot \left(y + z\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.19999999999999997e-15 or 3.2000000000000002e-8 < 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. Step-by-step derivation
      1. fma-define100.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. Add Preprocessing
    5. Taylor expanded in x around inf 99.8%

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

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

    if -1.19999999999999997e-15 < x < 3.2000000000000002e-8

    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 58.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.2 \cdot 10^{-15} \lor \neg \left(x \leq 3.2 \cdot 10^{-8}\right):\\ \;\;\;\;2 \cdot \left(x \cdot \left(y + z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot 5\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 99.9% accurate, 1.0× speedup?

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

\\
x \cdot \left(t + \left(y + \left(z + \left(y + z\right)\right)\right)\right) + y \cdot 5
\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. Final simplification99.9%

    \[\leadsto x \cdot \left(t + \left(y + \left(z + \left(y + z\right)\right)\right)\right) + y \cdot 5 \]
  4. Add Preprocessing

Alternative 13: 46.7% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.42 \cdot 10^{-25} \lor \neg \left(x \leq 1.2 \cdot 10^{-100}\right):\\
\;\;\;\;x \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.4200000000000001e-25 or 1.2000000000000001e-100 < 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 33.3%

      \[\leadsto \color{blue}{t \cdot x} \]
    4. Simplified33.3%

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

    if -1.4200000000000001e-25 < x < 1.2000000000000001e-100

    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 62.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.42 \cdot 10^{-25} \lor \neg \left(x \leq 1.2 \cdot 10^{-100}\right):\\ \;\;\;\;x \cdot t\\ \mathbf{else}:\\ \;\;\;\;y \cdot 5\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 29.4% accurate, 5.0× speedup?

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

\\
y \cdot 5
\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 29.2%

    \[\leadsto \color{blue}{5 \cdot y} \]
  4. Final simplification29.2%

    \[\leadsto y \cdot 5 \]
  5. Add Preprocessing

Reproduce

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