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

Percentage Accurate: 98.0% → 100.0%
Time: 3.5s
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.0% 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(z + y\right) - z \end{array} \]
(FPCore (x y z) :precision binary64 (- (* x (+ z y)) z))
double code(double x, double y, double z) {
	return (x * (z + y)) - 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 * (z + y)) - z
end function
public static double code(double x, double y, double z) {
	return (x * (z + y)) - z;
}
def code(x, y, z):
	return (x * (z + y)) - z
function code(x, y, z)
	return Float64(Float64(x * Float64(z + y)) - z)
end
function tmp = code(x, y, z)
	tmp = (x * (z + y)) - z;
end
code[x_, y_, z_] := N[(N[(x * N[(z + y), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

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

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

      \[\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(z + y\right) - z \]

Alternative 2: 61.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5.8 \cdot 10^{+190}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;x \leq -1.5 \cdot 10^{+128}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq -3.2 \cdot 10^{+96}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;x \leq -3.1 \cdot 10^{-25}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 4.15 \cdot 10^{-38}:\\ \;\;\;\;-z\\ \mathbf{elif}\;x \leq 3 \cdot 10^{+35} \lor \neg \left(x \leq 3.7 \cdot 10^{+122}\right):\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -5.8e+190)
   (* x z)
   (if (<= x -1.5e+128)
     (* x y)
     (if (<= x -3.2e+96)
       (* x z)
       (if (<= x -3.1e-25)
         (* x y)
         (if (<= x 4.15e-38)
           (- z)
           (if (or (<= x 3e+35) (not (<= x 3.7e+122))) (* x y) (* x z))))))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -5.8e+190) {
		tmp = x * z;
	} else if (x <= -1.5e+128) {
		tmp = x * y;
	} else if (x <= -3.2e+96) {
		tmp = x * z;
	} else if (x <= -3.1e-25) {
		tmp = x * y;
	} else if (x <= 4.15e-38) {
		tmp = -z;
	} else if ((x <= 3e+35) || !(x <= 3.7e+122)) {
		tmp = x * y;
	} 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 <= (-5.8d+190)) then
        tmp = x * z
    else if (x <= (-1.5d+128)) then
        tmp = x * y
    else if (x <= (-3.2d+96)) then
        tmp = x * z
    else if (x <= (-3.1d-25)) then
        tmp = x * y
    else if (x <= 4.15d-38) then
        tmp = -z
    else if ((x <= 3d+35) .or. (.not. (x <= 3.7d+122))) then
        tmp = x * y
    else
        tmp = x * z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -5.8e+190) {
		tmp = x * z;
	} else if (x <= -1.5e+128) {
		tmp = x * y;
	} else if (x <= -3.2e+96) {
		tmp = x * z;
	} else if (x <= -3.1e-25) {
		tmp = x * y;
	} else if (x <= 4.15e-38) {
		tmp = -z;
	} else if ((x <= 3e+35) || !(x <= 3.7e+122)) {
		tmp = x * y;
	} else {
		tmp = x * z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -5.8e+190:
		tmp = x * z
	elif x <= -1.5e+128:
		tmp = x * y
	elif x <= -3.2e+96:
		tmp = x * z
	elif x <= -3.1e-25:
		tmp = x * y
	elif x <= 4.15e-38:
		tmp = -z
	elif (x <= 3e+35) or not (x <= 3.7e+122):
		tmp = x * y
	else:
		tmp = x * z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -5.8e+190)
		tmp = Float64(x * z);
	elseif (x <= -1.5e+128)
		tmp = Float64(x * y);
	elseif (x <= -3.2e+96)
		tmp = Float64(x * z);
	elseif (x <= -3.1e-25)
		tmp = Float64(x * y);
	elseif (x <= 4.15e-38)
		tmp = Float64(-z);
	elseif ((x <= 3e+35) || !(x <= 3.7e+122))
		tmp = Float64(x * y);
	else
		tmp = Float64(x * z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -5.8e+190)
		tmp = x * z;
	elseif (x <= -1.5e+128)
		tmp = x * y;
	elseif (x <= -3.2e+96)
		tmp = x * z;
	elseif (x <= -3.1e-25)
		tmp = x * y;
	elseif (x <= 4.15e-38)
		tmp = -z;
	elseif ((x <= 3e+35) || ~((x <= 3.7e+122)))
		tmp = x * y;
	else
		tmp = x * z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -5.8e+190], N[(x * z), $MachinePrecision], If[LessEqual[x, -1.5e+128], N[(x * y), $MachinePrecision], If[LessEqual[x, -3.2e+96], N[(x * z), $MachinePrecision], If[LessEqual[x, -3.1e-25], N[(x * y), $MachinePrecision], If[LessEqual[x, 4.15e-38], (-z), If[Or[LessEqual[x, 3e+35], N[Not[LessEqual[x, 3.7e+122]], $MachinePrecision]], N[(x * y), $MachinePrecision], N[(x * z), $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -1.5 \cdot 10^{+128}:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;x \leq -3.2 \cdot 10^{+96}:\\
\;\;\;\;x \cdot z\\

\mathbf{elif}\;x \leq -3.1 \cdot 10^{-25}:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;x \leq 4.15 \cdot 10^{-38}:\\
\;\;\;\;-z\\

\mathbf{elif}\;x \leq 3 \cdot 10^{+35} \lor \neg \left(x \leq 3.7 \cdot 10^{+122}\right):\\
\;\;\;\;x \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -5.79999999999999979e190 or -1.4999999999999999e128 < x < -3.20000000000000006e96 or 2.99999999999999991e35 < x < 3.6999999999999997e122

    1. Initial program 94.0%

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

      \[\leadsto \color{blue}{z \cdot \left(x - 1\right)} \]
    3. Taylor expanded in x around inf 76.6%

      \[\leadsto \color{blue}{x \cdot z} \]
    4. Step-by-step derivation
      1. *-commutative76.6%

        \[\leadsto \color{blue}{z \cdot x} \]
    5. Simplified76.6%

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

    if -5.79999999999999979e190 < x < -1.4999999999999999e128 or -3.20000000000000006e96 < x < -3.09999999999999995e-25 or 4.1499999999999998e-38 < x < 2.99999999999999991e35 or 3.6999999999999997e122 < x

    1. Initial program 93.9%

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

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

    if -3.09999999999999995e-25 < x < 4.1499999999999998e-38

    1. Initial program 100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.8 \cdot 10^{+190}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;x \leq -1.5 \cdot 10^{+128}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq -3.2 \cdot 10^{+96}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;x \leq -3.1 \cdot 10^{-25}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 4.15 \cdot 10^{-38}:\\ \;\;\;\;-z\\ \mathbf{elif}\;x \leq 3 \cdot 10^{+35} \lor \neg \left(x \leq 3.7 \cdot 10^{+122}\right):\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot z\\ \end{array} \]

Alternative 3: 84.5% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.10000000000000002e-25 or 4.20000000000000026e-38 < x

    1. Initial program 93.9%

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

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

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

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

    if -2.10000000000000002e-25 < x < 4.20000000000000026e-38

    1. Initial program 100.0%

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

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

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

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

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

Alternative 4: 84.5% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -4.00000000000000019e-4 or 1.49999999999999994e-38 < x

    1. Initial program 93.6%

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

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

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

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

    if -4.00000000000000019e-4 < x < 1.49999999999999994e-38

    1. Initial program 99.9%

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

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

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

Alternative 5: 84.4% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -0.00110000000000000007 or 3.6000000000000001e-38 < x

    1. Initial program 93.6%

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

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

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

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

    if -0.00110000000000000007 < x < 3.6000000000000001e-38

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

        \[\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. Taylor expanded in y around 0 73.9%

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

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

Alternative 6: 60.9% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.75 \cdot 10^{-25} \lor \neg \left(x \leq 3.8 \cdot 10^{-38}\right):\\
\;\;\;\;x \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.7500000000000001e-25 or 3.8e-38 < x

    1. Initial program 93.9%

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

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

    if -1.7500000000000001e-25 < x < 3.8e-38

    1. Initial program 100.0%

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

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

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

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

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

Alternative 7: 37.0% 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.4%

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

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

      \[\leadsto \color{blue}{-z} \]
  4. Simplified34.7%

    \[\leadsto \color{blue}{-z} \]
  5. Final simplification34.7%

    \[\leadsto -z \]

Reproduce

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