Diagrams.TwoD.Segment:bezierClip from diagrams-lib-1.3.0.3

Percentage Accurate: 97.8% → 100.0%
Time: 5.6s
Alternatives: 6
Speedup: 1.7×

Specification

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

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

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

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

Alternative 1: 100.0% accurate, 1.7× speedup?

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

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

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

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

      \[\leadsto \color{blue}{z \cdot \left(1 - y\right) + x \cdot y} \]
    2. *-commutativeN/A

      \[\leadsto \color{blue}{\left(1 - y\right) \cdot z} + x \cdot y \]
    3. *-commutativeN/A

      \[\leadsto \color{blue}{z \cdot \left(1 - y\right)} + x \cdot y \]
    4. distribute-rgt-out--N/A

      \[\leadsto \color{blue}{\left(1 \cdot z - y \cdot z\right)} + x \cdot y \]
    5. *-lft-identityN/A

      \[\leadsto \left(\color{blue}{z} - y \cdot z\right) + x \cdot y \]
    6. associate-+l-N/A

      \[\leadsto \color{blue}{z - \left(y \cdot z - x \cdot y\right)} \]
    7. *-commutativeN/A

      \[\leadsto z - \left(y \cdot z - \color{blue}{y \cdot x}\right) \]
    8. distribute-lft-out--N/A

      \[\leadsto z - \color{blue}{y \cdot \left(z - x\right)} \]
    9. unsub-negN/A

      \[\leadsto z - y \cdot \color{blue}{\left(z + \left(\mathsf{neg}\left(x\right)\right)\right)} \]
    10. mul-1-negN/A

      \[\leadsto z - y \cdot \left(z + \color{blue}{-1 \cdot x}\right) \]
    11. sub-negN/A

      \[\leadsto \color{blue}{z + \left(\mathsf{neg}\left(y \cdot \left(z + -1 \cdot x\right)\right)\right)} \]
    12. mul-1-negN/A

      \[\leadsto z + \color{blue}{-1 \cdot \left(y \cdot \left(z + -1 \cdot x\right)\right)} \]
    13. +-commutativeN/A

      \[\leadsto \color{blue}{-1 \cdot \left(y \cdot \left(z + -1 \cdot x\right)\right) + z} \]
    14. mul-1-negN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(y \cdot \left(z + -1 \cdot x\right)\right)\right)} + z \]
    15. *-commutativeN/A

      \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(z + -1 \cdot x\right) \cdot y}\right)\right) + z \]
    16. distribute-lft-neg-inN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(z + -1 \cdot x\right)\right)\right) \cdot y} + z \]
    17. lower-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(\left(z + -1 \cdot x\right)\right), y, z\right)} \]
    18. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot x + z\right)}\right), y, z\right) \]
    19. distribute-neg-inN/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(z\right)\right)}, y, z\right) \]
    20. mul-1-negN/A

      \[\leadsto \mathsf{fma}\left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)\right) + \left(\mathsf{neg}\left(z\right)\right), y, z\right) \]
    21. remove-double-negN/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{x} + \left(\mathsf{neg}\left(z\right)\right), y, z\right) \]
    22. unsub-negN/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{x - z}, y, z\right) \]
    23. lower--.f64100.0

      \[\leadsto \mathsf{fma}\left(\color{blue}{x - z}, y, z\right) \]
  5. Applied rewrites100.0%

    \[\leadsto \color{blue}{\mathsf{fma}\left(x - z, y, z\right)} \]
  6. Add Preprocessing

Alternative 2: 60.6% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(-z\right) \cdot y\\ \mathbf{if}\;y \leq -1.6 \cdot 10^{+194}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq -5.6 \cdot 10^{-26}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{-71}:\\ \;\;\;\;1 \cdot z\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{+123}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 3.7 \cdot 10^{+251}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (- z) y)))
   (if (<= y -1.6e+194)
     (* y x)
     (if (<= y -5.6e-26)
       t_0
       (if (<= y 3.3e-71)
         (* 1.0 z)
         (if (<= y 1.4e+123) (* y x) (if (<= y 3.7e+251) t_0 (* y x))))))))
double code(double x, double y, double z) {
	double t_0 = -z * y;
	double tmp;
	if (y <= -1.6e+194) {
		tmp = y * x;
	} else if (y <= -5.6e-26) {
		tmp = t_0;
	} else if (y <= 3.3e-71) {
		tmp = 1.0 * z;
	} else if (y <= 1.4e+123) {
		tmp = y * x;
	} else if (y <= 3.7e+251) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: tmp
    t_0 = -z * y
    if (y <= (-1.6d+194)) then
        tmp = y * x
    else if (y <= (-5.6d-26)) then
        tmp = t_0
    else if (y <= 3.3d-71) then
        tmp = 1.0d0 * z
    else if (y <= 1.4d+123) then
        tmp = y * x
    else if (y <= 3.7d+251) then
        tmp = t_0
    else
        tmp = y * x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = -z * y;
	double tmp;
	if (y <= -1.6e+194) {
		tmp = y * x;
	} else if (y <= -5.6e-26) {
		tmp = t_0;
	} else if (y <= 3.3e-71) {
		tmp = 1.0 * z;
	} else if (y <= 1.4e+123) {
		tmp = y * x;
	} else if (y <= 3.7e+251) {
		tmp = t_0;
	} else {
		tmp = y * x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = -z * y
	tmp = 0
	if y <= -1.6e+194:
		tmp = y * x
	elif y <= -5.6e-26:
		tmp = t_0
	elif y <= 3.3e-71:
		tmp = 1.0 * z
	elif y <= 1.4e+123:
		tmp = y * x
	elif y <= 3.7e+251:
		tmp = t_0
	else:
		tmp = y * x
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(-z) * y)
	tmp = 0.0
	if (y <= -1.6e+194)
		tmp = Float64(y * x);
	elseif (y <= -5.6e-26)
		tmp = t_0;
	elseif (y <= 3.3e-71)
		tmp = Float64(1.0 * z);
	elseif (y <= 1.4e+123)
		tmp = Float64(y * x);
	elseif (y <= 3.7e+251)
		tmp = t_0;
	else
		tmp = Float64(y * x);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = -z * y;
	tmp = 0.0;
	if (y <= -1.6e+194)
		tmp = y * x;
	elseif (y <= -5.6e-26)
		tmp = t_0;
	elseif (y <= 3.3e-71)
		tmp = 1.0 * z;
	elseif (y <= 1.4e+123)
		tmp = y * x;
	elseif (y <= 3.7e+251)
		tmp = t_0;
	else
		tmp = y * x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[((-z) * y), $MachinePrecision]}, If[LessEqual[y, -1.6e+194], N[(y * x), $MachinePrecision], If[LessEqual[y, -5.6e-26], t$95$0, If[LessEqual[y, 3.3e-71], N[(1.0 * z), $MachinePrecision], If[LessEqual[y, 1.4e+123], N[(y * x), $MachinePrecision], If[LessEqual[y, 3.7e+251], t$95$0, N[(y * x), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(-z\right) \cdot y\\
\mathbf{if}\;y \leq -1.6 \cdot 10^{+194}:\\
\;\;\;\;y \cdot x\\

\mathbf{elif}\;y \leq -5.6 \cdot 10^{-26}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 3.3 \cdot 10^{-71}:\\
\;\;\;\;1 \cdot z\\

\mathbf{elif}\;y \leq 1.4 \cdot 10^{+123}:\\
\;\;\;\;y \cdot x\\

\mathbf{elif}\;y \leq 3.7 \cdot 10^{+251}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.60000000000000011e194 or 3.3000000000000002e-71 < y < 1.40000000000000006e123 or 3.6999999999999999e251 < y

    1. Initial program 96.9%

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

      \[\leadsto \color{blue}{x \cdot y} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{y \cdot x} \]
      2. lower-*.f6473.4

        \[\leadsto \color{blue}{y \cdot x} \]
    5. Applied rewrites73.4%

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

    if -1.60000000000000011e194 < y < -5.6000000000000002e-26 or 1.40000000000000006e123 < y < 3.6999999999999999e251

    1. Initial program 97.1%

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

      \[\leadsto \color{blue}{y \cdot \left(x + -1 \cdot z\right)} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\left(x + -1 \cdot z\right) \cdot y} \]
      2. +-commutativeN/A

        \[\leadsto \color{blue}{\left(-1 \cdot z + x\right)} \cdot y \]
      3. remove-double-negN/A

        \[\leadsto \left(-1 \cdot z + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)}\right) \cdot y \]
      4. mul-1-negN/A

        \[\leadsto \left(-1 \cdot z + \left(\mathsf{neg}\left(\color{blue}{-1 \cdot x}\right)\right)\right) \cdot y \]
      5. mul-1-negN/A

        \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(z\right)\right)} + \left(\mathsf{neg}\left(-1 \cdot x\right)\right)\right) \cdot y \]
      6. distribute-neg-inN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(z + -1 \cdot x\right)\right)\right)} \cdot y \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(z + -1 \cdot x\right)\right)\right) \cdot y} \]
      8. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot x + z\right)}\right)\right) \cdot y \]
      9. distribute-neg-inN/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(z\right)\right)\right)} \cdot y \]
      10. mul-1-negN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)\right) + \left(\mathsf{neg}\left(z\right)\right)\right) \cdot y \]
      11. remove-double-negN/A

        \[\leadsto \left(\color{blue}{x} + \left(\mathsf{neg}\left(z\right)\right)\right) \cdot y \]
      12. unsub-negN/A

        \[\leadsto \color{blue}{\left(x - z\right)} \cdot y \]
      13. lower--.f6498.1

        \[\leadsto \color{blue}{\left(x - z\right)} \cdot y \]
    5. Applied rewrites98.1%

      \[\leadsto \color{blue}{\left(x - z\right) \cdot y} \]
    6. Taylor expanded in z around inf

      \[\leadsto \left(-1 \cdot z\right) \cdot y \]
    7. Step-by-step derivation
      1. Applied rewrites67.2%

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

      if -5.6000000000000002e-26 < y < 3.3000000000000002e-71

      1. Initial program 100.0%

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

        \[\leadsto \color{blue}{z \cdot \left(1 - y\right)} \]
      4. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \color{blue}{\left(1 - y\right) \cdot z} \]
        2. lower-*.f64N/A

          \[\leadsto \color{blue}{\left(1 - y\right) \cdot z} \]
        3. lower--.f6475.2

          \[\leadsto \color{blue}{\left(1 - y\right)} \cdot z \]
      5. Applied rewrites75.2%

        \[\leadsto \color{blue}{\left(1 - y\right) \cdot z} \]
      6. Taylor expanded in y around 0

        \[\leadsto 1 \cdot z \]
      7. Step-by-step derivation
        1. Applied rewrites75.2%

          \[\leadsto 1 \cdot z \]
      8. Recombined 3 regimes into one program.
      9. Add Preprocessing

      Alternative 3: 84.4% accurate, 0.8× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(x - z\right) \cdot y\\ \mathbf{if}\;y \leq -7.8 \cdot 10^{-44}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{-71}:\\ \;\;\;\;1 \cdot z\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (let* ((t_0 (* (- x z) y)))
         (if (<= y -7.8e-44) t_0 (if (<= y 3.3e-71) (* 1.0 z) t_0))))
      double code(double x, double y, double z) {
      	double t_0 = (x - z) * y;
      	double tmp;
      	if (y <= -7.8e-44) {
      		tmp = t_0;
      	} else if (y <= 3.3e-71) {
      		tmp = 1.0 * z;
      	} else {
      		tmp = t_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) :: t_0
          real(8) :: tmp
          t_0 = (x - z) * y
          if (y <= (-7.8d-44)) then
              tmp = t_0
          else if (y <= 3.3d-71) then
              tmp = 1.0d0 * z
          else
              tmp = t_0
          end if
          code = tmp
      end function
      
      public static double code(double x, double y, double z) {
      	double t_0 = (x - z) * y;
      	double tmp;
      	if (y <= -7.8e-44) {
      		tmp = t_0;
      	} else if (y <= 3.3e-71) {
      		tmp = 1.0 * z;
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      def code(x, y, z):
      	t_0 = (x - z) * y
      	tmp = 0
      	if y <= -7.8e-44:
      		tmp = t_0
      	elif y <= 3.3e-71:
      		tmp = 1.0 * z
      	else:
      		tmp = t_0
      	return tmp
      
      function code(x, y, z)
      	t_0 = Float64(Float64(x - z) * y)
      	tmp = 0.0
      	if (y <= -7.8e-44)
      		tmp = t_0;
      	elseif (y <= 3.3e-71)
      		tmp = Float64(1.0 * z);
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y, z)
      	t_0 = (x - z) * y;
      	tmp = 0.0;
      	if (y <= -7.8e-44)
      		tmp = t_0;
      	elseif (y <= 3.3e-71)
      		tmp = 1.0 * z;
      	else
      		tmp = t_0;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - z), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[y, -7.8e-44], t$95$0, If[LessEqual[y, 3.3e-71], N[(1.0 * z), $MachinePrecision], t$95$0]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \left(x - z\right) \cdot y\\
      \mathbf{if}\;y \leq -7.8 \cdot 10^{-44}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;y \leq 3.3 \cdot 10^{-71}:\\
      \;\;\;\;1 \cdot z\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if y < -7.8000000000000004e-44 or 3.3000000000000002e-71 < y

        1. Initial program 97.1%

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

          \[\leadsto \color{blue}{y \cdot \left(x + -1 \cdot z\right)} \]
        4. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \color{blue}{\left(x + -1 \cdot z\right) \cdot y} \]
          2. +-commutativeN/A

            \[\leadsto \color{blue}{\left(-1 \cdot z + x\right)} \cdot y \]
          3. remove-double-negN/A

            \[\leadsto \left(-1 \cdot z + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)}\right) \cdot y \]
          4. mul-1-negN/A

            \[\leadsto \left(-1 \cdot z + \left(\mathsf{neg}\left(\color{blue}{-1 \cdot x}\right)\right)\right) \cdot y \]
          5. mul-1-negN/A

            \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(z\right)\right)} + \left(\mathsf{neg}\left(-1 \cdot x\right)\right)\right) \cdot y \]
          6. distribute-neg-inN/A

            \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(z + -1 \cdot x\right)\right)\right)} \cdot y \]
          7. lower-*.f64N/A

            \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(z + -1 \cdot x\right)\right)\right) \cdot y} \]
          8. +-commutativeN/A

            \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot x + z\right)}\right)\right) \cdot y \]
          9. distribute-neg-inN/A

            \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(z\right)\right)\right)} \cdot y \]
          10. mul-1-negN/A

            \[\leadsto \left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)\right) + \left(\mathsf{neg}\left(z\right)\right)\right) \cdot y \]
          11. remove-double-negN/A

            \[\leadsto \left(\color{blue}{x} + \left(\mathsf{neg}\left(z\right)\right)\right) \cdot y \]
          12. unsub-negN/A

            \[\leadsto \color{blue}{\left(x - z\right)} \cdot y \]
          13. lower--.f6493.1

            \[\leadsto \color{blue}{\left(x - z\right)} \cdot y \]
        5. Applied rewrites93.1%

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

        if -7.8000000000000004e-44 < y < 3.3000000000000002e-71

        1. Initial program 100.0%

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

          \[\leadsto \color{blue}{z \cdot \left(1 - y\right)} \]
        4. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \color{blue}{\left(1 - y\right) \cdot z} \]
          2. lower-*.f64N/A

            \[\leadsto \color{blue}{\left(1 - y\right) \cdot z} \]
          3. lower--.f6477.1

            \[\leadsto \color{blue}{\left(1 - y\right)} \cdot z \]
        5. Applied rewrites77.1%

          \[\leadsto \color{blue}{\left(1 - y\right) \cdot z} \]
        6. Taylor expanded in y around 0

          \[\leadsto 1 \cdot z \]
        7. Step-by-step derivation
          1. Applied rewrites77.1%

            \[\leadsto 1 \cdot z \]
        8. Recombined 2 regimes into one program.
        9. Add Preprocessing

        Alternative 4: 75.5% accurate, 0.8× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(1 - y\right) \cdot z\\ \mathbf{if}\;z \leq -5.8 \cdot 10^{-90}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 8.8 \cdot 10^{-110}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
        (FPCore (x y z)
         :precision binary64
         (let* ((t_0 (* (- 1.0 y) z)))
           (if (<= z -5.8e-90) t_0 (if (<= z 8.8e-110) (* y x) t_0))))
        double code(double x, double y, double z) {
        	double t_0 = (1.0 - y) * z;
        	double tmp;
        	if (z <= -5.8e-90) {
        		tmp = t_0;
        	} else if (z <= 8.8e-110) {
        		tmp = y * x;
        	} else {
        		tmp = t_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) :: t_0
            real(8) :: tmp
            t_0 = (1.0d0 - y) * z
            if (z <= (-5.8d-90)) then
                tmp = t_0
            else if (z <= 8.8d-110) then
                tmp = y * x
            else
                tmp = t_0
            end if
            code = tmp
        end function
        
        public static double code(double x, double y, double z) {
        	double t_0 = (1.0 - y) * z;
        	double tmp;
        	if (z <= -5.8e-90) {
        		tmp = t_0;
        	} else if (z <= 8.8e-110) {
        		tmp = y * x;
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        def code(x, y, z):
        	t_0 = (1.0 - y) * z
        	tmp = 0
        	if z <= -5.8e-90:
        		tmp = t_0
        	elif z <= 8.8e-110:
        		tmp = y * x
        	else:
        		tmp = t_0
        	return tmp
        
        function code(x, y, z)
        	t_0 = Float64(Float64(1.0 - y) * z)
        	tmp = 0.0
        	if (z <= -5.8e-90)
        		tmp = t_0;
        	elseif (z <= 8.8e-110)
        		tmp = Float64(y * x);
        	else
        		tmp = t_0;
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y, z)
        	t_0 = (1.0 - y) * z;
        	tmp = 0.0;
        	if (z <= -5.8e-90)
        		tmp = t_0;
        	elseif (z <= 8.8e-110)
        		tmp = y * x;
        	else
        		tmp = t_0;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_] := Block[{t$95$0 = N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -5.8e-90], t$95$0, If[LessEqual[z, 8.8e-110], N[(y * x), $MachinePrecision], t$95$0]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \left(1 - y\right) \cdot z\\
        \mathbf{if}\;z \leq -5.8 \cdot 10^{-90}:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;z \leq 8.8 \cdot 10^{-110}:\\
        \;\;\;\;y \cdot x\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_0\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if z < -5.79999999999999967e-90 or 8.7999999999999997e-110 < z

          1. Initial program 97.7%

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

            \[\leadsto \color{blue}{z \cdot \left(1 - y\right)} \]
          4. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto \color{blue}{\left(1 - y\right) \cdot z} \]
            2. lower-*.f64N/A

              \[\leadsto \color{blue}{\left(1 - y\right) \cdot z} \]
            3. lower--.f6478.3

              \[\leadsto \color{blue}{\left(1 - y\right)} \cdot z \]
          5. Applied rewrites78.3%

            \[\leadsto \color{blue}{\left(1 - y\right) \cdot z} \]

          if -5.79999999999999967e-90 < z < 8.7999999999999997e-110

          1. Initial program 100.0%

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

            \[\leadsto \color{blue}{x \cdot y} \]
          4. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto \color{blue}{y \cdot x} \]
            2. lower-*.f6474.8

              \[\leadsto \color{blue}{y \cdot x} \]
          5. Applied rewrites74.8%

            \[\leadsto \color{blue}{y \cdot x} \]
        3. Recombined 2 regimes into one program.
        4. Add Preprocessing

        Alternative 5: 60.8% accurate, 0.9× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -8 \cdot 10^{-44}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{-71}:\\ \;\;\;\;1 \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \end{array} \]
        (FPCore (x y z)
         :precision binary64
         (if (<= y -8e-44) (* y x) (if (<= y 3.3e-71) (* 1.0 z) (* y x))))
        double code(double x, double y, double z) {
        	double tmp;
        	if (y <= -8e-44) {
        		tmp = y * x;
        	} else if (y <= 3.3e-71) {
        		tmp = 1.0 * z;
        	} 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 <= (-8d-44)) then
                tmp = y * x
            else if (y <= 3.3d-71) then
                tmp = 1.0d0 * z
            else
                tmp = y * x
            end if
            code = tmp
        end function
        
        public static double code(double x, double y, double z) {
        	double tmp;
        	if (y <= -8e-44) {
        		tmp = y * x;
        	} else if (y <= 3.3e-71) {
        		tmp = 1.0 * z;
        	} else {
        		tmp = y * x;
        	}
        	return tmp;
        }
        
        def code(x, y, z):
        	tmp = 0
        	if y <= -8e-44:
        		tmp = y * x
        	elif y <= 3.3e-71:
        		tmp = 1.0 * z
        	else:
        		tmp = y * x
        	return tmp
        
        function code(x, y, z)
        	tmp = 0.0
        	if (y <= -8e-44)
        		tmp = Float64(y * x);
        	elseif (y <= 3.3e-71)
        		tmp = Float64(1.0 * z);
        	else
        		tmp = Float64(y * x);
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y, z)
        	tmp = 0.0;
        	if (y <= -8e-44)
        		tmp = y * x;
        	elseif (y <= 3.3e-71)
        		tmp = 1.0 * z;
        	else
        		tmp = y * x;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_] := If[LessEqual[y, -8e-44], N[(y * x), $MachinePrecision], If[LessEqual[y, 3.3e-71], N[(1.0 * z), $MachinePrecision], N[(y * x), $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;y \leq -8 \cdot 10^{-44}:\\
        \;\;\;\;y \cdot x\\
        
        \mathbf{elif}\;y \leq 3.3 \cdot 10^{-71}:\\
        \;\;\;\;1 \cdot z\\
        
        \mathbf{else}:\\
        \;\;\;\;y \cdot x\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if y < -7.99999999999999962e-44 or 3.3000000000000002e-71 < y

          1. Initial program 97.1%

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

            \[\leadsto \color{blue}{x \cdot y} \]
          4. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto \color{blue}{y \cdot x} \]
            2. lower-*.f6455.3

              \[\leadsto \color{blue}{y \cdot x} \]
          5. Applied rewrites55.3%

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

          if -7.99999999999999962e-44 < y < 3.3000000000000002e-71

          1. Initial program 100.0%

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

            \[\leadsto \color{blue}{z \cdot \left(1 - y\right)} \]
          4. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto \color{blue}{\left(1 - y\right) \cdot z} \]
            2. lower-*.f64N/A

              \[\leadsto \color{blue}{\left(1 - y\right) \cdot z} \]
            3. lower--.f6477.1

              \[\leadsto \color{blue}{\left(1 - y\right)} \cdot z \]
          5. Applied rewrites77.1%

            \[\leadsto \color{blue}{\left(1 - y\right) \cdot z} \]
          6. Taylor expanded in y around 0

            \[\leadsto 1 \cdot z \]
          7. Step-by-step derivation
            1. Applied rewrites77.1%

              \[\leadsto 1 \cdot z \]
          8. Recombined 2 regimes into one program.
          9. Add Preprocessing

          Alternative 6: 41.4% accurate, 2.8× speedup?

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

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

            \[\leadsto \color{blue}{x \cdot y} \]
          4. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto \color{blue}{y \cdot x} \]
            2. lower-*.f6441.2

              \[\leadsto \color{blue}{y \cdot x} \]
          5. Applied rewrites41.2%

            \[\leadsto \color{blue}{y \cdot x} \]
          6. Add Preprocessing

          Developer Target 1: 100.0% accurate, 1.4× speedup?

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

          Reproduce

          ?
          herbie shell --seed 2024257 
          (FPCore (x y z)
            :name "Diagrams.TwoD.Segment:bezierClip from diagrams-lib-1.3.0.3"
            :precision binary64
          
            :alt
            (! :herbie-platform default (- z (* (- z x) y)))
          
            (+ (* x y) (* z (- 1.0 y))))