Graphics.Rendering.Chart.Drawing:drawTextsR from Chart-1.5.3

Percentage Accurate: 98.2% → 100.0%
Time: 4.8s
Alternatives: 7
Speedup: 1.3×

Specification

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

\\
x \cdot y + \left(x - 1\right) \cdot z
\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: 98.2% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 0.1× speedup?

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

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

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

      \[\leadsto x \cdot y + \color{blue}{z \cdot \left(x - 1\right)} \]
    2. sub-neg96.8%

      \[\leadsto x \cdot y + z \cdot \color{blue}{\left(x + \left(-1\right)\right)} \]
    3. distribute-rgt-in96.9%

      \[\leadsto x \cdot y + \color{blue}{\left(x \cdot z + \left(-1\right) \cdot z\right)} \]
    4. metadata-eval96.9%

      \[\leadsto x \cdot y + \left(x \cdot z + \color{blue}{-1} \cdot z\right) \]
    5. neg-mul-196.9%

      \[\leadsto x \cdot y + \left(x \cdot z + \color{blue}{\left(-z\right)}\right) \]
    6. associate-+r+96.9%

      \[\leadsto \color{blue}{\left(x \cdot y + x \cdot z\right) + \left(-z\right)} \]
    7. distribute-lft-out100.0%

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

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

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

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

Alternative 2: 61.0% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.4 \cdot 10^{+83}:\\
\;\;\;\;x \cdot z\\

\mathbf{elif}\;x \leq -1.75 \cdot 10^{-6}:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;x \leq 1:\\
\;\;\;\;-z\\

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


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

    1. Initial program 92.1%

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

      \[\leadsto \color{blue}{\left(y + z\right) \cdot x} \]
    3. Step-by-step derivation
      1. +-commutative100.0%

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

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

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

    if -6.3999999999999998e83 < x < -1.74999999999999997e-6

    1. Initial program 100.0%

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

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

    if -1.74999999999999997e-6 < x < 1

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    3. Step-by-step derivation
      1. mul-1-neg69.1%

        \[\leadsto \color{blue}{-z} \]
    4. Simplified69.1%

      \[\leadsto \color{blue}{-z} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification64.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.4 \cdot 10^{+83}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;x \leq -1.75 \cdot 10^{-6}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;x \cdot z\\ \end{array} \]

Alternative 3: 84.9% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;-z\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.39999999999999994e-6 or 5.4999999999999996e-10 < x

    1. Initial program 93.6%

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

      \[\leadsto \color{blue}{\left(y + z\right) \cdot x} \]
    3. Step-by-step derivation
      1. +-commutative98.1%

        \[\leadsto \color{blue}{\left(z + y\right)} \cdot x \]
    4. Simplified98.1%

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

    if -1.39999999999999994e-6 < x < 5.4999999999999996e-10

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    3. Step-by-step derivation
      1. mul-1-neg70.5%

        \[\leadsto \color{blue}{-z} \]
    4. Simplified70.5%

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

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

Alternative 4: 84.9% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;x \cdot z - z\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.04999999999999994e-5 or 85 < x

    1. Initial program 93.4%

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

      \[\leadsto \color{blue}{\left(y + z\right) \cdot x} \]
    3. Step-by-step derivation
      1. +-commutative99.7%

        \[\leadsto \color{blue}{\left(z + y\right)} \cdot x \]
    4. Simplified99.7%

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

    if -1.04999999999999994e-5 < x < 85

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\left(x - 1\right) \cdot z} \]
    3. Step-by-step derivation
      1. *-commutative71.1%

        \[\leadsto \color{blue}{z \cdot \left(x - 1\right)} \]
      2. sub-neg71.1%

        \[\leadsto z \cdot \color{blue}{\left(x + \left(-1\right)\right)} \]
      3. metadata-eval71.1%

        \[\leadsto z \cdot \left(x + \color{blue}{-1}\right) \]
      4. distribute-lft-in71.1%

        \[\leadsto \color{blue}{z \cdot x + z \cdot -1} \]
      5. *-commutative71.1%

        \[\leadsto z \cdot x + \color{blue}{-1 \cdot z} \]
      6. mul-1-neg71.1%

        \[\leadsto z \cdot x + \color{blue}{\left(-z\right)} \]
      7. sub-neg71.1%

        \[\leadsto \color{blue}{z \cdot x - z} \]
    4. Simplified71.1%

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

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

Alternative 5: 61.6% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.75 \cdot 10^{-6}:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;x \leq 10^{-9}:\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.74999999999999997e-6 or 1.00000000000000006e-9 < x

    1. Initial program 93.6%

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

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

    if -1.74999999999999997e-6 < x < 1.00000000000000006e-9

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    3. Step-by-step derivation
      1. mul-1-neg70.5%

        \[\leadsto \color{blue}{-z} \]
    4. Simplified70.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.75 \cdot 10^{-6}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 10^{-9}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]

Alternative 6: 100.0% accurate, 1.3× speedup?

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

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

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

      \[\leadsto x \cdot y + \color{blue}{z \cdot \left(x - 1\right)} \]
    2. sub-neg96.8%

      \[\leadsto x \cdot y + z \cdot \color{blue}{\left(x + \left(-1\right)\right)} \]
    3. distribute-rgt-in96.9%

      \[\leadsto x \cdot y + \color{blue}{\left(x \cdot z + \left(-1\right) \cdot z\right)} \]
    4. metadata-eval96.9%

      \[\leadsto x \cdot y + \left(x \cdot z + \color{blue}{-1} \cdot z\right) \]
    5. neg-mul-196.9%

      \[\leadsto x \cdot y + \left(x \cdot z + \color{blue}{\left(-z\right)}\right) \]
    6. associate-+r+96.9%

      \[\leadsto \color{blue}{\left(x \cdot y + x \cdot z\right) + \left(-z\right)} \]
    7. unsub-neg96.9%

      \[\leadsto \color{blue}{\left(x \cdot y + x \cdot z\right) - z} \]
    8. +-commutative96.9%

      \[\leadsto \color{blue}{\left(x \cdot z + x \cdot y\right)} - z \]
    9. distribute-lft-out100.0%

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

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

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

Alternative 7: 35.9% accurate, 4.5× speedup?

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

\\
-z
\end{array}
Derivation
  1. Initial program 96.8%

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

    \[\leadsto \color{blue}{-1 \cdot z} \]
  3. Step-by-step derivation
    1. mul-1-neg37.8%

      \[\leadsto \color{blue}{-z} \]
  4. Simplified37.8%

    \[\leadsto \color{blue}{-z} \]
  5. Final simplification37.8%

    \[\leadsto -z \]

Reproduce

?
herbie shell --seed 2023274 
(FPCore (x y z)
  :name "Graphics.Rendering.Chart.Drawing:drawTextsR from Chart-1.5.3"
  :precision binary64
  (+ (* x y) (* (- x 1.0) z)))