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

Percentage Accurate: 97.9% → 100.0%
Time: 2.7s
Alternatives: 6
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 6 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: 97.9% 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, 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 99.2%

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

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

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

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

      \[\leadsto \color{blue}{\left(x \cdot y + x \cdot z\right) + \left(-1\right) \cdot z} \]
    5. metadata-eval99.2%

      \[\leadsto \left(x \cdot y + x \cdot z\right) + \color{blue}{-1} \cdot z \]
    6. mul-1-neg99.2%

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

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

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

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

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

Alternative 2: 61.7% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -17000000:\\
\;\;\;\;x \cdot z\\

\mathbf{elif}\;x \leq 1.25 \cdot 10^{-23}:\\
\;\;\;\;-z\\

\mathbf{elif}\;x \leq 3.2 \cdot 10^{+24}:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;x \leq 5.2 \cdot 10^{+238}:\\
\;\;\;\;x \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.7e7 or 3.1999999999999997e24 < x < 5.1999999999999999e238

    1. Initial program 97.9%

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

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

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

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

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

    if -1.7e7 < x < 1.2500000000000001e-23

    1. Initial program 100.0%

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

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

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

      \[\leadsto \color{blue}{-z} \]

    if 1.2500000000000001e-23 < x < 3.1999999999999997e24 or 5.1999999999999999e238 < x

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -17000000:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-23}:\\ \;\;\;\;-z\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{+24}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{+238}:\\ \;\;\;\;x \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]

Alternative 3: 85.2% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-11} \lor \neg \left(x \leq 3.8 \cdot 10^{-25}\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.99999999999999988e-11 or 3.7999999999999998e-25 < x

    1. Initial program 98.3%

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

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

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

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

    if -1.99999999999999988e-11 < x < 3.7999999999999998e-25

    1. Initial program 100.0%

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

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

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

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

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

Alternative 4: 78.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.2 \cdot 10^{+72} \lor \neg \left(y \leq 5.5 \cdot 10^{-16}\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 y < -5.19999999999999963e72 or 5.49999999999999964e-16 < y

    1. Initial program 98.3%

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

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

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

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

    if -5.19999999999999963e72 < y < 5.49999999999999964e-16

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{z \cdot \left(x - 1\right)} \]
      2. distribute-lft-out--89.6%

        \[\leadsto \color{blue}{z \cdot x - z \cdot 1} \]
      3. *-rgt-identity89.6%

        \[\leadsto z \cdot x - \color{blue}{z} \]
    4. Simplified89.6%

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

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

Alternative 5: 61.9% accurate, 1.3× speedup?

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

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

\mathbf{elif}\;x \leq 2.1 \cdot 10^{-26}:\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.7999999999999998e-11 or 2.10000000000000008e-26 < x

    1. Initial program 98.3%

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

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

    if -3.7999999999999998e-11 < x < 2.10000000000000008e-26

    1. Initial program 100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.8 \cdot 10^{-11}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-26}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]

Alternative 6: 36.4% 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 99.2%

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

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

      \[\leadsto \color{blue}{-z} \]
  4. Simplified39.9%

    \[\leadsto \color{blue}{-z} \]
  5. Final simplification39.9%

    \[\leadsto -z \]

Reproduce

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