Statistics.Sample:robustSumVarWeighted from math-functions-0.1.5.2

Percentage Accurate: 99.9% → 99.9%
Time: 7.6s
Alternatives: 3
Speedup: 1.2×

Specification

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

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

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

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

Alternative 1: 99.9% accurate, 1.2× speedup?

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

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

    \[x + \left(y \cdot z\right) \cdot z \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-+.f64N/A

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

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

      \[\leadsto \color{blue}{\left(y \cdot z\right) \cdot z} + x \]
    4. lower-fma.f6499.9

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot z, z, x\right)} \]
    5. lift-*.f64N/A

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{z \cdot y}, z, x\right) \]
    7. lower-*.f6499.9

      \[\leadsto \mathsf{fma}\left(\color{blue}{z \cdot y}, z, x\right) \]
  4. Applied rewrites99.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(z \cdot y, z, x\right)} \]
  5. Final simplification99.9%

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

Alternative 2: 86.4% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := \left(y \cdot z\right) \cdot z\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-46}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-88}:\\
\;\;\;\;1 \cdot x\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 y z) z) < -4.99999999999999992e-46 or 5.00000000000000009e-88 < (*.f64 (*.f64 y z) z)

    1. Initial program 99.8%

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

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

        \[\leadsto \color{blue}{{z}^{2} \cdot y} \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{{z}^{2} \cdot y} \]
      3. unpow2N/A

        \[\leadsto \color{blue}{\left(z \cdot z\right)} \cdot y \]
      4. lower-*.f6478.0

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

      \[\leadsto \color{blue}{\left(z \cdot z\right) \cdot y} \]
    6. Step-by-step derivation
      1. Applied rewrites86.5%

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

      if -4.99999999999999992e-46 < (*.f64 (*.f64 y z) z) < 5.00000000000000009e-88

      1. Initial program 100.0%

        \[x + \left(y \cdot z\right) \cdot z \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. lift-+.f64N/A

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

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

          \[\leadsto \color{blue}{\frac{\left(\left(y \cdot z\right) \cdot z\right) \cdot \left(\left(y \cdot z\right) \cdot z\right) - x \cdot x}{\left(y \cdot z\right) \cdot z - x}} \]
        4. lower-/.f64N/A

          \[\leadsto \color{blue}{\frac{\left(\left(y \cdot z\right) \cdot z\right) \cdot \left(\left(y \cdot z\right) \cdot z\right) - x \cdot x}{\left(y \cdot z\right) \cdot z - x}} \]
        5. difference-of-squaresN/A

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

          \[\leadsto \frac{\color{blue}{\left(x + \left(y \cdot z\right) \cdot z\right)} \cdot \left(\left(y \cdot z\right) \cdot z - x\right)}{\left(y \cdot z\right) \cdot z - x} \]
        7. lift-+.f64N/A

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

          \[\leadsto \frac{\color{blue}{\left(x + \left(y \cdot z\right) \cdot z\right) \cdot \left(\left(y \cdot z\right) \cdot z - x\right)}}{\left(y \cdot z\right) \cdot z - x} \]
        9. lift-+.f64N/A

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

          \[\leadsto \frac{\color{blue}{\left(\left(y \cdot z\right) \cdot z + x\right)} \cdot \left(\left(y \cdot z\right) \cdot z - x\right)}{\left(y \cdot z\right) \cdot z - x} \]
        11. lift-*.f64N/A

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

          \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(y \cdot z, z, x\right)} \cdot \left(\left(y \cdot z\right) \cdot z - x\right)}{\left(y \cdot z\right) \cdot z - x} \]
        13. lift-*.f64N/A

          \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{y \cdot z}, z, x\right) \cdot \left(\left(y \cdot z\right) \cdot z - x\right)}{\left(y \cdot z\right) \cdot z - x} \]
        14. *-commutativeN/A

          \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{z \cdot y}, z, x\right) \cdot \left(\left(y \cdot z\right) \cdot z - x\right)}{\left(y \cdot z\right) \cdot z - x} \]
        15. lower-*.f64N/A

          \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{z \cdot y}, z, x\right) \cdot \left(\left(y \cdot z\right) \cdot z - x\right)}{\left(y \cdot z\right) \cdot z - x} \]
        16. lower--.f64N/A

          \[\leadsto \frac{\mathsf{fma}\left(z \cdot y, z, x\right) \cdot \color{blue}{\left(\left(y \cdot z\right) \cdot z - x\right)}}{\left(y \cdot z\right) \cdot z - x} \]
        17. lift-*.f64N/A

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

          \[\leadsto \frac{\mathsf{fma}\left(z \cdot y, z, x\right) \cdot \left(\color{blue}{\left(z \cdot y\right)} \cdot z - x\right)}{\left(y \cdot z\right) \cdot z - x} \]
        19. lower-*.f64N/A

          \[\leadsto \frac{\mathsf{fma}\left(z \cdot y, z, x\right) \cdot \left(\color{blue}{\left(z \cdot y\right)} \cdot z - x\right)}{\left(y \cdot z\right) \cdot z - x} \]
        20. lower--.f6454.8

          \[\leadsto \frac{\mathsf{fma}\left(z \cdot y, z, x\right) \cdot \left(\left(z \cdot y\right) \cdot z - x\right)}{\color{blue}{\left(y \cdot z\right) \cdot z - x}} \]
        21. lift-*.f64N/A

          \[\leadsto \frac{\mathsf{fma}\left(z \cdot y, z, x\right) \cdot \left(\left(z \cdot y\right) \cdot z - x\right)}{\color{blue}{\left(y \cdot z\right)} \cdot z - x} \]
        22. *-commutativeN/A

          \[\leadsto \frac{\mathsf{fma}\left(z \cdot y, z, x\right) \cdot \left(\left(z \cdot y\right) \cdot z - x\right)}{\color{blue}{\left(z \cdot y\right)} \cdot z - x} \]
        23. lower-*.f6454.8

          \[\leadsto \frac{\mathsf{fma}\left(z \cdot y, z, x\right) \cdot \left(\left(z \cdot y\right) \cdot z - x\right)}{\color{blue}{\left(z \cdot y\right)} \cdot z - x} \]
      4. Applied rewrites54.8%

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(z \cdot y, z, x\right) \cdot \left(\left(z \cdot y\right) \cdot z - x\right)}{\left(z \cdot y\right) \cdot z - x}} \]
      5. Taylor expanded in x around -inf

        \[\leadsto \color{blue}{-1 \cdot \left(x \cdot \left(-1 \cdot \frac{y \cdot {z}^{2}}{x} - 1\right)\right)} \]
      6. Step-by-step derivation
        1. associate-*r*N/A

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

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

          \[\leadsto \color{blue}{\left(-1 \cdot \frac{y \cdot {z}^{2}}{x} - 1\right) \cdot \left(-1 \cdot x\right)} \]
        4. sub-negN/A

          \[\leadsto \color{blue}{\left(-1 \cdot \frac{y \cdot {z}^{2}}{x} + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(-1 \cdot x\right) \]
        5. associate-/l*N/A

          \[\leadsto \left(-1 \cdot \color{blue}{\left(y \cdot \frac{{z}^{2}}{x}\right)} + \left(\mathsf{neg}\left(1\right)\right)\right) \cdot \left(-1 \cdot x\right) \]
        6. associate-*r*N/A

          \[\leadsto \left(\color{blue}{\left(-1 \cdot y\right) \cdot \frac{{z}^{2}}{x}} + \left(\mathsf{neg}\left(1\right)\right)\right) \cdot \left(-1 \cdot x\right) \]
        7. metadata-evalN/A

          \[\leadsto \left(\left(-1 \cdot y\right) \cdot \frac{{z}^{2}}{x} + \color{blue}{-1}\right) \cdot \left(-1 \cdot x\right) \]
        8. lower-fma.f64N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(-1 \cdot y, \frac{{z}^{2}}{x}, -1\right)} \cdot \left(-1 \cdot x\right) \]
        9. mul-1-negN/A

          \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(y\right)}, \frac{{z}^{2}}{x}, -1\right) \cdot \left(-1 \cdot x\right) \]
        10. lower-neg.f64N/A

          \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(y\right)}, \frac{{z}^{2}}{x}, -1\right) \cdot \left(-1 \cdot x\right) \]
        11. unpow2N/A

          \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(y\right), \frac{\color{blue}{z \cdot z}}{x}, -1\right) \cdot \left(-1 \cdot x\right) \]
        12. associate-/l*N/A

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

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

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

          \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(y\right), z \cdot \frac{z}{x}, -1\right) \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \]
        16. lower-neg.f6498.2

          \[\leadsto \mathsf{fma}\left(-y, z \cdot \frac{z}{x}, -1\right) \cdot \color{blue}{\left(-x\right)} \]
      7. Applied rewrites98.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-y, z \cdot \frac{z}{x}, -1\right) \cdot \left(-x\right)} \]
      8. Taylor expanded in x around inf

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

          \[\leadsto \color{blue}{\left(1 + \frac{y \cdot {z}^{2}}{x}\right) \cdot x} \]
        2. rgt-mult-inverseN/A

          \[\leadsto \left(\color{blue}{y \cdot \frac{1}{y}} + \frac{y \cdot {z}^{2}}{x}\right) \cdot x \]
        3. associate-/l*N/A

          \[\leadsto \left(y \cdot \frac{1}{y} + \color{blue}{y \cdot \frac{{z}^{2}}{x}}\right) \cdot x \]
        4. distribute-lft-inN/A

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

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

          \[\leadsto \left(y \cdot \color{blue}{\left(\frac{{z}^{2}}{x} + \frac{1}{y}\right)}\right) \cdot x \]
        7. distribute-rgt-inN/A

          \[\leadsto \color{blue}{\left(\frac{{z}^{2}}{x} \cdot y + \frac{1}{y} \cdot y\right)} \cdot x \]
        8. lft-mult-inverseN/A

          \[\leadsto \left(\frac{{z}^{2}}{x} \cdot y + \color{blue}{1}\right) \cdot x \]
        9. lower-fma.f64N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{{z}^{2}}{x}, y, 1\right)} \cdot x \]
        10. lower-/.f64N/A

          \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{{z}^{2}}{x}}, y, 1\right) \cdot x \]
        11. unpow2N/A

          \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{z \cdot z}}{x}, y, 1\right) \cdot x \]
        12. lower-*.f6495.3

          \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{z \cdot z}}{x}, y, 1\right) \cdot x \]
      10. Applied rewrites95.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z \cdot z}{x}, y, 1\right) \cdot x} \]
      11. Taylor expanded in z around 0

        \[\leadsto 1 \cdot x \]
      12. Step-by-step derivation
        1. Applied rewrites92.9%

          \[\leadsto 1 \cdot x \]
      13. Recombined 2 regimes into one program.
      14. Add Preprocessing

      Alternative 3: 50.0% accurate, 2.3× speedup?

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

        \[x + \left(y \cdot z\right) \cdot z \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. lift-+.f64N/A

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

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

          \[\leadsto \color{blue}{\frac{\left(\left(y \cdot z\right) \cdot z\right) \cdot \left(\left(y \cdot z\right) \cdot z\right) - x \cdot x}{\left(y \cdot z\right) \cdot z - x}} \]
        4. lower-/.f64N/A

          \[\leadsto \color{blue}{\frac{\left(\left(y \cdot z\right) \cdot z\right) \cdot \left(\left(y \cdot z\right) \cdot z\right) - x \cdot x}{\left(y \cdot z\right) \cdot z - x}} \]
        5. difference-of-squaresN/A

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

          \[\leadsto \frac{\color{blue}{\left(x + \left(y \cdot z\right) \cdot z\right)} \cdot \left(\left(y \cdot z\right) \cdot z - x\right)}{\left(y \cdot z\right) \cdot z - x} \]
        7. lift-+.f64N/A

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

          \[\leadsto \frac{\color{blue}{\left(x + \left(y \cdot z\right) \cdot z\right) \cdot \left(\left(y \cdot z\right) \cdot z - x\right)}}{\left(y \cdot z\right) \cdot z - x} \]
        9. lift-+.f64N/A

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

          \[\leadsto \frac{\color{blue}{\left(\left(y \cdot z\right) \cdot z + x\right)} \cdot \left(\left(y \cdot z\right) \cdot z - x\right)}{\left(y \cdot z\right) \cdot z - x} \]
        11. lift-*.f64N/A

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

          \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(y \cdot z, z, x\right)} \cdot \left(\left(y \cdot z\right) \cdot z - x\right)}{\left(y \cdot z\right) \cdot z - x} \]
        13. lift-*.f64N/A

          \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{y \cdot z}, z, x\right) \cdot \left(\left(y \cdot z\right) \cdot z - x\right)}{\left(y \cdot z\right) \cdot z - x} \]
        14. *-commutativeN/A

          \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{z \cdot y}, z, x\right) \cdot \left(\left(y \cdot z\right) \cdot z - x\right)}{\left(y \cdot z\right) \cdot z - x} \]
        15. lower-*.f64N/A

          \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{z \cdot y}, z, x\right) \cdot \left(\left(y \cdot z\right) \cdot z - x\right)}{\left(y \cdot z\right) \cdot z - x} \]
        16. lower--.f64N/A

          \[\leadsto \frac{\mathsf{fma}\left(z \cdot y, z, x\right) \cdot \color{blue}{\left(\left(y \cdot z\right) \cdot z - x\right)}}{\left(y \cdot z\right) \cdot z - x} \]
        17. lift-*.f64N/A

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

          \[\leadsto \frac{\mathsf{fma}\left(z \cdot y, z, x\right) \cdot \left(\color{blue}{\left(z \cdot y\right)} \cdot z - x\right)}{\left(y \cdot z\right) \cdot z - x} \]
        19. lower-*.f64N/A

          \[\leadsto \frac{\mathsf{fma}\left(z \cdot y, z, x\right) \cdot \left(\color{blue}{\left(z \cdot y\right)} \cdot z - x\right)}{\left(y \cdot z\right) \cdot z - x} \]
        20. lower--.f6439.1

          \[\leadsto \frac{\mathsf{fma}\left(z \cdot y, z, x\right) \cdot \left(\left(z \cdot y\right) \cdot z - x\right)}{\color{blue}{\left(y \cdot z\right) \cdot z - x}} \]
        21. lift-*.f64N/A

          \[\leadsto \frac{\mathsf{fma}\left(z \cdot y, z, x\right) \cdot \left(\left(z \cdot y\right) \cdot z - x\right)}{\color{blue}{\left(y \cdot z\right)} \cdot z - x} \]
        22. *-commutativeN/A

          \[\leadsto \frac{\mathsf{fma}\left(z \cdot y, z, x\right) \cdot \left(\left(z \cdot y\right) \cdot z - x\right)}{\color{blue}{\left(z \cdot y\right)} \cdot z - x} \]
        23. lower-*.f6439.1

          \[\leadsto \frac{\mathsf{fma}\left(z \cdot y, z, x\right) \cdot \left(\left(z \cdot y\right) \cdot z - x\right)}{\color{blue}{\left(z \cdot y\right)} \cdot z - x} \]
      4. Applied rewrites39.1%

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(z \cdot y, z, x\right) \cdot \left(\left(z \cdot y\right) \cdot z - x\right)}{\left(z \cdot y\right) \cdot z - x}} \]
      5. Taylor expanded in x around -inf

        \[\leadsto \color{blue}{-1 \cdot \left(x \cdot \left(-1 \cdot \frac{y \cdot {z}^{2}}{x} - 1\right)\right)} \]
      6. Step-by-step derivation
        1. associate-*r*N/A

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

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

          \[\leadsto \color{blue}{\left(-1 \cdot \frac{y \cdot {z}^{2}}{x} - 1\right) \cdot \left(-1 \cdot x\right)} \]
        4. sub-negN/A

          \[\leadsto \color{blue}{\left(-1 \cdot \frac{y \cdot {z}^{2}}{x} + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(-1 \cdot x\right) \]
        5. associate-/l*N/A

          \[\leadsto \left(-1 \cdot \color{blue}{\left(y \cdot \frac{{z}^{2}}{x}\right)} + \left(\mathsf{neg}\left(1\right)\right)\right) \cdot \left(-1 \cdot x\right) \]
        6. associate-*r*N/A

          \[\leadsto \left(\color{blue}{\left(-1 \cdot y\right) \cdot \frac{{z}^{2}}{x}} + \left(\mathsf{neg}\left(1\right)\right)\right) \cdot \left(-1 \cdot x\right) \]
        7. metadata-evalN/A

          \[\leadsto \left(\left(-1 \cdot y\right) \cdot \frac{{z}^{2}}{x} + \color{blue}{-1}\right) \cdot \left(-1 \cdot x\right) \]
        8. lower-fma.f64N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(-1 \cdot y, \frac{{z}^{2}}{x}, -1\right)} \cdot \left(-1 \cdot x\right) \]
        9. mul-1-negN/A

          \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(y\right)}, \frac{{z}^{2}}{x}, -1\right) \cdot \left(-1 \cdot x\right) \]
        10. lower-neg.f64N/A

          \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(y\right)}, \frac{{z}^{2}}{x}, -1\right) \cdot \left(-1 \cdot x\right) \]
        11. unpow2N/A

          \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(y\right), \frac{\color{blue}{z \cdot z}}{x}, -1\right) \cdot \left(-1 \cdot x\right) \]
        12. associate-/l*N/A

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

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

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

          \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(y\right), z \cdot \frac{z}{x}, -1\right) \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \]
        16. lower-neg.f6488.4

          \[\leadsto \mathsf{fma}\left(-y, z \cdot \frac{z}{x}, -1\right) \cdot \color{blue}{\left(-x\right)} \]
      7. Applied rewrites88.4%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-y, z \cdot \frac{z}{x}, -1\right) \cdot \left(-x\right)} \]
      8. Taylor expanded in x around inf

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

          \[\leadsto \color{blue}{\left(1 + \frac{y \cdot {z}^{2}}{x}\right) \cdot x} \]
        2. rgt-mult-inverseN/A

          \[\leadsto \left(\color{blue}{y \cdot \frac{1}{y}} + \frac{y \cdot {z}^{2}}{x}\right) \cdot x \]
        3. associate-/l*N/A

          \[\leadsto \left(y \cdot \frac{1}{y} + \color{blue}{y \cdot \frac{{z}^{2}}{x}}\right) \cdot x \]
        4. distribute-lft-inN/A

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

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

          \[\leadsto \left(y \cdot \color{blue}{\left(\frac{{z}^{2}}{x} + \frac{1}{y}\right)}\right) \cdot x \]
        7. distribute-rgt-inN/A

          \[\leadsto \color{blue}{\left(\frac{{z}^{2}}{x} \cdot y + \frac{1}{y} \cdot y\right)} \cdot x \]
        8. lft-mult-inverseN/A

          \[\leadsto \left(\frac{{z}^{2}}{x} \cdot y + \color{blue}{1}\right) \cdot x \]
        9. lower-fma.f64N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{{z}^{2}}{x}, y, 1\right)} \cdot x \]
        10. lower-/.f64N/A

          \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{{z}^{2}}{x}}, y, 1\right) \cdot x \]
        11. unpow2N/A

          \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{z \cdot z}}{x}, y, 1\right) \cdot x \]
        12. lower-*.f6485.2

          \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{z \cdot z}}{x}, y, 1\right) \cdot x \]
      10. Applied rewrites85.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z \cdot z}{x}, y, 1\right) \cdot x} \]
      11. Taylor expanded in z around 0

        \[\leadsto 1 \cdot x \]
      12. Step-by-step derivation
        1. Applied rewrites49.4%

          \[\leadsto 1 \cdot x \]
        2. Add Preprocessing

        Reproduce

        ?
        herbie shell --seed 2024235 
        (FPCore (x y z)
          :name "Statistics.Sample:robustSumVarWeighted from math-functions-0.1.5.2"
          :precision binary64
          (+ x (* (* y z) z)))