Main:bigenough2 from A

Percentage Accurate: 100.0% → 100.0%
Time: 2.1s
Alternatives: 7
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 7 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 0.1× speedup?

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

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

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

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

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

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

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

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

Alternative 2: 60.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.4 \cdot 10^{+117}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq -2.2 \cdot 10^{+73}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq -1:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 6.2 \cdot 10^{-98}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{+52}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+93} \lor \neg \left(y \leq 4.2 \cdot 10^{+197}\right) \land y \leq 3.1 \cdot 10^{+297}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -2.4e+117)
   (* y x)
   (if (<= y -2.2e+73)
     (* y z)
     (if (<= y -1.0)
       (* y x)
       (if (<= y 6.2e-98)
         x
         (if (<= y 2.1e+52)
           (* y z)
           (if (or (<= y 1.35e+93) (and (not (<= y 4.2e+197)) (<= y 3.1e+297)))
             (* y x)
             (* y z))))))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -2.4e+117) {
		tmp = y * x;
	} else if (y <= -2.2e+73) {
		tmp = y * z;
	} else if (y <= -1.0) {
		tmp = y * x;
	} else if (y <= 6.2e-98) {
		tmp = x;
	} else if (y <= 2.1e+52) {
		tmp = y * z;
	} else if ((y <= 1.35e+93) || (!(y <= 4.2e+197) && (y <= 3.1e+297))) {
		tmp = y * x;
	} else {
		tmp = y * z;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-2.4d+117)) then
        tmp = y * x
    else if (y <= (-2.2d+73)) then
        tmp = y * z
    else if (y <= (-1.0d0)) then
        tmp = y * x
    else if (y <= 6.2d-98) then
        tmp = x
    else if (y <= 2.1d+52) then
        tmp = y * z
    else if ((y <= 1.35d+93) .or. (.not. (y <= 4.2d+197)) .and. (y <= 3.1d+297)) then
        tmp = y * x
    else
        tmp = y * z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -2.4e+117) {
		tmp = y * x;
	} else if (y <= -2.2e+73) {
		tmp = y * z;
	} else if (y <= -1.0) {
		tmp = y * x;
	} else if (y <= 6.2e-98) {
		tmp = x;
	} else if (y <= 2.1e+52) {
		tmp = y * z;
	} else if ((y <= 1.35e+93) || (!(y <= 4.2e+197) && (y <= 3.1e+297))) {
		tmp = y * x;
	} else {
		tmp = y * z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -2.4e+117:
		tmp = y * x
	elif y <= -2.2e+73:
		tmp = y * z
	elif y <= -1.0:
		tmp = y * x
	elif y <= 6.2e-98:
		tmp = x
	elif y <= 2.1e+52:
		tmp = y * z
	elif (y <= 1.35e+93) or (not (y <= 4.2e+197) and (y <= 3.1e+297)):
		tmp = y * x
	else:
		tmp = y * z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -2.4e+117)
		tmp = Float64(y * x);
	elseif (y <= -2.2e+73)
		tmp = Float64(y * z);
	elseif (y <= -1.0)
		tmp = Float64(y * x);
	elseif (y <= 6.2e-98)
		tmp = x;
	elseif (y <= 2.1e+52)
		tmp = Float64(y * z);
	elseif ((y <= 1.35e+93) || (!(y <= 4.2e+197) && (y <= 3.1e+297)))
		tmp = Float64(y * x);
	else
		tmp = Float64(y * z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -2.4e+117)
		tmp = y * x;
	elseif (y <= -2.2e+73)
		tmp = y * z;
	elseif (y <= -1.0)
		tmp = y * x;
	elseif (y <= 6.2e-98)
		tmp = x;
	elseif (y <= 2.1e+52)
		tmp = y * z;
	elseif ((y <= 1.35e+93) || (~((y <= 4.2e+197)) && (y <= 3.1e+297)))
		tmp = y * x;
	else
		tmp = y * z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -2.4e+117], N[(y * x), $MachinePrecision], If[LessEqual[y, -2.2e+73], N[(y * z), $MachinePrecision], If[LessEqual[y, -1.0], N[(y * x), $MachinePrecision], If[LessEqual[y, 6.2e-98], x, If[LessEqual[y, 2.1e+52], N[(y * z), $MachinePrecision], If[Or[LessEqual[y, 1.35e+93], And[N[Not[LessEqual[y, 4.2e+197]], $MachinePrecision], LessEqual[y, 3.1e+297]]], N[(y * x), $MachinePrecision], N[(y * z), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.4 \cdot 10^{+117}:\\
\;\;\;\;y \cdot x\\

\mathbf{elif}\;y \leq -2.2 \cdot 10^{+73}:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;y \leq -1:\\
\;\;\;\;y \cdot x\\

\mathbf{elif}\;y \leq 6.2 \cdot 10^{-98}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 2.1 \cdot 10^{+52}:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;y \leq 1.35 \cdot 10^{+93} \lor \neg \left(y \leq 4.2 \cdot 10^{+197}\right) \land y \leq 3.1 \cdot 10^{+297}:\\
\;\;\;\;y \cdot x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.3999999999999999e117 or -2.2e73 < y < -1 or 2.1e52 < y < 1.35e93 or 4.20000000000000013e197 < y < 3.09999999999999985e297

    1. Initial program 100.0%

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

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

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

    if -2.3999999999999999e117 < y < -2.2e73 or 6.2e-98 < y < 2.1e52 or 1.35e93 < y < 4.20000000000000013e197 or 3.09999999999999985e297 < y

    1. Initial program 100.0%

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

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

    if -1 < y < 6.2e-98

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification68.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.4 \cdot 10^{+117}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq -2.2 \cdot 10^{+73}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq -1:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 6.2 \cdot 10^{-98}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{+52}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+93} \lor \neg \left(y \leq 4.2 \cdot 10^{+197}\right) \land y \leq 3.1 \cdot 10^{+297}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]

Alternative 3: 84.2% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.054 \lor \neg \left(y \leq 6.2 \cdot 10^{-98}\right):\\
\;\;\;\;y \cdot \left(x + z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -0.0539999999999999994 or 6.2e-98 < y

    1. Initial program 100.0%

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

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

    if -0.0539999999999999994 < y < 6.2e-98

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification84.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -0.054 \lor \neg \left(y \leq 6.2 \cdot 10^{-98}\right):\\ \;\;\;\;y \cdot \left(x + z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 4: 78.5% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.86 \cdot 10^{+84} \lor \neg \left(z \leq 2.1 \cdot 10^{-21}\right):\\
\;\;\;\;y \cdot \left(x + z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.86000000000000006e84 or 2.10000000000000013e-21 < z

    1. Initial program 100.0%

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

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

    if -1.86000000000000006e84 < z < 2.10000000000000013e-21

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.86 \cdot 10^{+84} \lor \neg \left(z \leq 2.1 \cdot 10^{-21}\right):\\ \;\;\;\;y \cdot \left(x + z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y + 1\right)\\ \end{array} \]

Alternative 5: 61.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 13000000:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -1.0) (* y x) (if (<= y 13000000.0) x (* y x))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.0) {
		tmp = y * x;
	} else if (y <= 13000000.0) {
		tmp = x;
	} else {
		tmp = y * x;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-1.0d0)) then
        tmp = y * x
    else if (y <= 13000000.0d0) then
        tmp = x
    else
        tmp = y * x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.0) {
		tmp = y * x;
	} else if (y <= 13000000.0) {
		tmp = x;
	} else {
		tmp = y * x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -1.0:
		tmp = y * x
	elif y <= 13000000.0:
		tmp = x
	else:
		tmp = y * x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -1.0)
		tmp = Float64(y * x);
	elseif (y <= 13000000.0)
		tmp = x;
	else
		tmp = Float64(y * x);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -1.0)
		tmp = y * x;
	elseif (y <= 13000000.0)
		tmp = x;
	else
		tmp = y * x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -1.0], N[(y * x), $MachinePrecision], If[LessEqual[y, 13000000.0], x, N[(y * x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;y \cdot x\\

\mathbf{elif}\;y \leq 13000000:\\
\;\;\;\;x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1 or 1.3e7 < y

    1. Initial program 100.0%

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

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

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

    if -1 < y < 1.3e7

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification61.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 13000000:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]

Alternative 6: 100.0% accurate, 1.0× speedup?

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

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

    \[x + y \cdot \left(z + x\right) \]
  2. Final simplification100.0%

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

Alternative 7: 37.1% accurate, 7.0× speedup?

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

\\
x
\end{array}
Derivation
  1. Initial program 100.0%

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

    \[\leadsto \color{blue}{x} \]
  3. Final simplification36.2%

    \[\leadsto x \]

Reproduce

?
herbie shell --seed 2023257 
(FPCore (x y z)
  :name "Main:bigenough2 from A"
  :precision binary64
  (+ x (* y (+ z x))))