Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendInside from plot-0.2.3.4

Percentage Accurate: 99.9% → 100.0%
Time: 10.6s
Alternatives: 8
Speedup: 1.2×

Specification

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

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

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

Alternative 1: 100.0% accurate, 1.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \mathsf{fma}\left(\color{blue}{{x}^{2}}, \frac{1}{x - y}, \left(x + y\right) + \left(x + z\right)\right) \]
  6. Step-by-step derivation
    1. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(3, x, \color{blue}{y \cdot 2} + z\right) \]
    10. lower-fma.f64100.0

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

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

Alternative 2: 53.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5.5 \cdot 10^{+83}:\\ \;\;\;\;3 \cdot x\\ \mathbf{elif}\;x \leq -7.2 \cdot 10^{-196}:\\ \;\;\;\;y \cdot 2\\ \mathbf{elif}\;x \leq -6.8 \cdot 10^{-296}:\\ \;\;\;\;y + z\\ \mathbf{elif}\;x \leq 2.45 \cdot 10^{-116}:\\ \;\;\;\;y \cdot 2\\ \mathbf{elif}\;x \leq 9.8 \cdot 10^{+114}:\\ \;\;\;\;y + z\\ \mathbf{else}:\\ \;\;\;\;3 \cdot x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -5.5e+83)
   (* 3.0 x)
   (if (<= x -7.2e-196)
     (* y 2.0)
     (if (<= x -6.8e-296)
       (+ y z)
       (if (<= x 2.45e-116)
         (* y 2.0)
         (if (<= x 9.8e+114) (+ y z) (* 3.0 x)))))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -5.5e+83) {
		tmp = 3.0 * x;
	} else if (x <= -7.2e-196) {
		tmp = y * 2.0;
	} else if (x <= -6.8e-296) {
		tmp = y + z;
	} else if (x <= 2.45e-116) {
		tmp = y * 2.0;
	} else if (x <= 9.8e+114) {
		tmp = y + z;
	} else {
		tmp = 3.0 * 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 (x <= (-5.5d+83)) then
        tmp = 3.0d0 * x
    else if (x <= (-7.2d-196)) then
        tmp = y * 2.0d0
    else if (x <= (-6.8d-296)) then
        tmp = y + z
    else if (x <= 2.45d-116) then
        tmp = y * 2.0d0
    else if (x <= 9.8d+114) then
        tmp = y + z
    else
        tmp = 3.0d0 * x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -5.5e+83) {
		tmp = 3.0 * x;
	} else if (x <= -7.2e-196) {
		tmp = y * 2.0;
	} else if (x <= -6.8e-296) {
		tmp = y + z;
	} else if (x <= 2.45e-116) {
		tmp = y * 2.0;
	} else if (x <= 9.8e+114) {
		tmp = y + z;
	} else {
		tmp = 3.0 * x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -5.5e+83:
		tmp = 3.0 * x
	elif x <= -7.2e-196:
		tmp = y * 2.0
	elif x <= -6.8e-296:
		tmp = y + z
	elif x <= 2.45e-116:
		tmp = y * 2.0
	elif x <= 9.8e+114:
		tmp = y + z
	else:
		tmp = 3.0 * x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -5.5e+83)
		tmp = Float64(3.0 * x);
	elseif (x <= -7.2e-196)
		tmp = Float64(y * 2.0);
	elseif (x <= -6.8e-296)
		tmp = Float64(y + z);
	elseif (x <= 2.45e-116)
		tmp = Float64(y * 2.0);
	elseif (x <= 9.8e+114)
		tmp = Float64(y + z);
	else
		tmp = Float64(3.0 * x);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -5.5e+83)
		tmp = 3.0 * x;
	elseif (x <= -7.2e-196)
		tmp = y * 2.0;
	elseif (x <= -6.8e-296)
		tmp = y + z;
	elseif (x <= 2.45e-116)
		tmp = y * 2.0;
	elseif (x <= 9.8e+114)
		tmp = y + z;
	else
		tmp = 3.0 * x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -5.5e+83], N[(3.0 * x), $MachinePrecision], If[LessEqual[x, -7.2e-196], N[(y * 2.0), $MachinePrecision], If[LessEqual[x, -6.8e-296], N[(y + z), $MachinePrecision], If[LessEqual[x, 2.45e-116], N[(y * 2.0), $MachinePrecision], If[LessEqual[x, 9.8e+114], N[(y + z), $MachinePrecision], N[(3.0 * x), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -7.2 \cdot 10^{-196}:\\
\;\;\;\;y \cdot 2\\

\mathbf{elif}\;x \leq -6.8 \cdot 10^{-296}:\\
\;\;\;\;y + z\\

\mathbf{elif}\;x \leq 2.45 \cdot 10^{-116}:\\
\;\;\;\;y \cdot 2\\

\mathbf{elif}\;x \leq 9.8 \cdot 10^{+114}:\\
\;\;\;\;y + z\\

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


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

    1. Initial program 99.8%

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

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

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

        \[\leadsto \color{blue}{x \cdot 3} \]
    5. Applied rewrites70.1%

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

    if -5.4999999999999996e83 < x < -7.2000000000000001e-196 or -6.79999999999999993e-296 < x < 2.44999999999999989e-116

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{2 \cdot y} \]
    4. Step-by-step derivation
      1. lower-*.f6457.6

        \[\leadsto \color{blue}{2 \cdot y} \]
    5. Applied rewrites57.6%

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

    if -7.2000000000000001e-196 < x < -6.79999999999999993e-296 or 2.44999999999999989e-116 < x < 9.8000000000000002e114

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{{x}^{2}}, \frac{1}{x - y}, \left(x + y\right) + \left(x + z\right)\right) \]
    6. Step-by-step derivation
      1. unpow2N/A

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

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

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

      \[\leadsto \color{blue}{y + z} \]
    9. Step-by-step derivation
      1. lower-+.f6467.8

        \[\leadsto \color{blue}{y + z} \]
    10. Applied rewrites67.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.5 \cdot 10^{+83}:\\ \;\;\;\;3 \cdot x\\ \mathbf{elif}\;x \leq -7.2 \cdot 10^{-196}:\\ \;\;\;\;y \cdot 2\\ \mathbf{elif}\;x \leq -6.8 \cdot 10^{-296}:\\ \;\;\;\;y + z\\ \mathbf{elif}\;x \leq 2.45 \cdot 10^{-116}:\\ \;\;\;\;y \cdot 2\\ \mathbf{elif}\;x \leq 9.8 \cdot 10^{+114}:\\ \;\;\;\;y + z\\ \mathbf{else}:\\ \;\;\;\;3 \cdot x\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 85.5% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.3 \cdot 10^{+59}:\\ \;\;\;\;\mathsf{fma}\left(2, y, z\right)\\ \mathbf{elif}\;y \leq 3.5:\\ \;\;\;\;\mathsf{fma}\left(x, 3, z\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2, x + y, x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -3.3e+59)
   (fma 2.0 y z)
   (if (<= y 3.5) (fma x 3.0 z) (fma 2.0 (+ x y) x))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -3.3e+59) {
		tmp = fma(2.0, y, z);
	} else if (y <= 3.5) {
		tmp = fma(x, 3.0, z);
	} else {
		tmp = fma(2.0, (x + y), x);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (y <= -3.3e+59)
		tmp = fma(2.0, y, z);
	elseif (y <= 3.5)
		tmp = fma(x, 3.0, z);
	else
		tmp = fma(2.0, Float64(x + y), x);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[y, -3.3e+59], N[(2.0 * y + z), $MachinePrecision], If[LessEqual[y, 3.5], N[(x * 3.0 + z), $MachinePrecision], N[(2.0 * N[(x + y), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.3 \cdot 10^{+59}:\\
\;\;\;\;\mathsf{fma}\left(2, y, z\right)\\

\mathbf{elif}\;y \leq 3.5:\\
\;\;\;\;\mathsf{fma}\left(x, 3, z\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2, x + y, x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -3.2999999999999999e59

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{2 \cdot y + z} \]
      2. lower-fma.f6495.7

        \[\leadsto \color{blue}{\mathsf{fma}\left(2, y, z\right)} \]
    5. Applied rewrites95.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, y, z\right)} \]

    if -3.2999999999999999e59 < y < 3.5

    1. Initial program 99.8%

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

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

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

        \[\leadsto \color{blue}{\left(x + 2 \cdot x\right) + z} \]
      3. distribute-rgt1-inN/A

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

        \[\leadsto \color{blue}{3} \cdot x + z \]
      5. *-commutativeN/A

        \[\leadsto \color{blue}{x \cdot 3} + z \]
      6. lower-fma.f6490.7

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, 3, z\right)} \]
    5. Applied rewrites90.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, 3, z\right)} \]

    if 3.5 < y

    1. Initial program 99.9%

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(2, x + y, x\right)} \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(2, \color{blue}{y + x}, x\right) \]
      5. lower-+.f6484.6

        \[\leadsto \mathsf{fma}\left(2, \color{blue}{y + x}, x\right) \]
    5. Applied rewrites84.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, y + x, x\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification90.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.3 \cdot 10^{+59}:\\ \;\;\;\;\mathsf{fma}\left(2, y, z\right)\\ \mathbf{elif}\;y \leq 3.5:\\ \;\;\;\;\mathsf{fma}\left(x, 3, z\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2, x + y, x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 83.8% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.3 \cdot 10^{+59}:\\ \;\;\;\;\mathsf{fma}\left(2, y, z\right)\\ \mathbf{elif}\;y \leq 1.95 \cdot 10^{+163}:\\ \;\;\;\;\mathsf{fma}\left(x, 3, z\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2, y, z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -3.3e+59)
   (fma 2.0 y z)
   (if (<= y 1.95e+163) (fma x 3.0 z) (fma 2.0 y z))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -3.3e+59) {
		tmp = fma(2.0, y, z);
	} else if (y <= 1.95e+163) {
		tmp = fma(x, 3.0, z);
	} else {
		tmp = fma(2.0, y, z);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (y <= -3.3e+59)
		tmp = fma(2.0, y, z);
	elseif (y <= 1.95e+163)
		tmp = fma(x, 3.0, z);
	else
		tmp = fma(2.0, y, z);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[y, -3.3e+59], N[(2.0 * y + z), $MachinePrecision], If[LessEqual[y, 1.95e+163], N[(x * 3.0 + z), $MachinePrecision], N[(2.0 * y + z), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.3 \cdot 10^{+59}:\\
\;\;\;\;\mathsf{fma}\left(2, y, z\right)\\

\mathbf{elif}\;y \leq 1.95 \cdot 10^{+163}:\\
\;\;\;\;\mathsf{fma}\left(x, 3, z\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2, y, z\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.2999999999999999e59 or 1.95000000000000012e163 < y

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{2 \cdot y + z} \]
      2. lower-fma.f6495.2

        \[\leadsto \color{blue}{\mathsf{fma}\left(2, y, z\right)} \]
    5. Applied rewrites95.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, y, z\right)} \]

    if -3.2999999999999999e59 < y < 1.95000000000000012e163

    1. Initial program 99.8%

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

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

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

        \[\leadsto \color{blue}{\left(x + 2 \cdot x\right) + z} \]
      3. distribute-rgt1-inN/A

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

        \[\leadsto \color{blue}{3} \cdot x + z \]
      5. *-commutativeN/A

        \[\leadsto \color{blue}{x \cdot 3} + z \]
      6. lower-fma.f6485.3

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, 3, z\right)} \]
    5. Applied rewrites85.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, 3, z\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 80.1% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.1 \cdot 10^{+136}:\\ \;\;\;\;3 \cdot x\\ \mathbf{elif}\;x \leq 3.55 \cdot 10^{+115}:\\ \;\;\;\;\mathsf{fma}\left(2, y, z\right)\\ \mathbf{else}:\\ \;\;\;\;3 \cdot x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -1.1e+136) (* 3.0 x) (if (<= x 3.55e+115) (fma 2.0 y z) (* 3.0 x))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -1.1e+136) {
		tmp = 3.0 * x;
	} else if (x <= 3.55e+115) {
		tmp = fma(2.0, y, z);
	} else {
		tmp = 3.0 * x;
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (x <= -1.1e+136)
		tmp = Float64(3.0 * x);
	elseif (x <= 3.55e+115)
		tmp = fma(2.0, y, z);
	else
		tmp = Float64(3.0 * x);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[x, -1.1e+136], N[(3.0 * x), $MachinePrecision], If[LessEqual[x, 3.55e+115], N[(2.0 * y + z), $MachinePrecision], N[(3.0 * x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.1 \cdot 10^{+136}:\\
\;\;\;\;3 \cdot x\\

\mathbf{elif}\;x \leq 3.55 \cdot 10^{+115}:\\
\;\;\;\;\mathsf{fma}\left(2, y, z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.1e136 or 3.5499999999999998e115 < x

    1. Initial program 99.8%

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

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

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

        \[\leadsto \color{blue}{x \cdot 3} \]
    5. Applied rewrites73.1%

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

    if -1.1e136 < x < 3.5499999999999998e115

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{2 \cdot y + z} \]
      2. lower-fma.f6487.5

        \[\leadsto \color{blue}{\mathsf{fma}\left(2, y, z\right)} \]
    5. Applied rewrites87.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, y, z\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification83.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.1 \cdot 10^{+136}:\\ \;\;\;\;3 \cdot x\\ \mathbf{elif}\;x \leq 3.55 \cdot 10^{+115}:\\ \;\;\;\;\mathsf{fma}\left(2, y, z\right)\\ \mathbf{else}:\\ \;\;\;\;3 \cdot x\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 53.6% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{+22}:\\
\;\;\;\;y + z\\

\mathbf{elif}\;z \leq 7 \cdot 10^{+37}:\\
\;\;\;\;y \cdot 2\\

\mathbf{else}:\\
\;\;\;\;y + z\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -5.50000000000000021e22 or 7e37 < z

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{{x}^{2}}, \frac{1}{x - y}, \left(x + y\right) + \left(x + z\right)\right) \]
    6. Step-by-step derivation
      1. unpow2N/A

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

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

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

      \[\leadsto \color{blue}{y + z} \]
    9. Step-by-step derivation
      1. lower-+.f6465.5

        \[\leadsto \color{blue}{y + z} \]
    10. Applied rewrites65.5%

      \[\leadsto \color{blue}{y + z} \]

    if -5.50000000000000021e22 < z < 7e37

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{2 \cdot y} \]
    4. Step-by-step derivation
      1. lower-*.f6453.0

        \[\leadsto \color{blue}{2 \cdot y} \]
    5. Applied rewrites53.0%

      \[\leadsto \color{blue}{2 \cdot y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification59.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5.5 \cdot 10^{+22}:\\ \;\;\;\;y + z\\ \mathbf{elif}\;z \leq 7 \cdot 10^{+37}:\\ \;\;\;\;y \cdot 2\\ \mathbf{else}:\\ \;\;\;\;y + z\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 99.9% accurate, 1.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, x + y, x + z\right)} \]
    13. lower-+.f6499.9

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

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

Alternative 8: 39.2% accurate, 4.0× speedup?

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

\\
y + z
\end{array}
Derivation
  1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \mathsf{fma}\left(\color{blue}{{x}^{2}}, \frac{1}{x - y}, \left(x + y\right) + \left(x + z\right)\right) \]
  6. Step-by-step derivation
    1. unpow2N/A

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

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

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

    \[\leadsto \color{blue}{y + z} \]
  9. Step-by-step derivation
    1. lower-+.f6440.3

      \[\leadsto \color{blue}{y + z} \]
  10. Applied rewrites40.3%

    \[\leadsto \color{blue}{y + z} \]
  11. Add Preprocessing

Reproduce

?
herbie shell --seed 2024212 
(FPCore (x y z)
  :name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendInside from plot-0.2.3.4"
  :precision binary64
  (+ (+ (+ (+ (+ x y) y) x) z) x))