Diagrams.Solve.Polynomial:quadForm from diagrams-solve-0.1, B

Percentage Accurate: 99.8% → 99.8%
Time: 11.4s
Alternatives: 8
Speedup: 1.0×

Specification

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

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

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

\\
\frac{1}{2} \cdot \left(x + y \cdot \sqrt{z}\right)
\end{array}

Alternative 1: 99.8% accurate, 1.0× speedup?

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

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

    \[\frac{1}{2} \cdot \left(x + y \cdot \sqrt{z}\right) \]
  2. Step-by-step derivation
    1. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2}\right), \color{blue}{\left(x + y \cdot \sqrt{z}\right)}\right) \]
    2. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\color{blue}{x} + y \cdot \sqrt{z}\right)\right) \]
    3. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \color{blue}{\left(y \cdot \sqrt{z}\right)}\right)\right) \]
    4. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \color{blue}{\left(\sqrt{z}\right)}\right)\right)\right) \]
    5. sqrt-lowering-sqrt.f6499.8%

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{sqrt.f64}\left(z\right)\right)\right)\right) \]
  3. Simplified99.8%

    \[\leadsto \color{blue}{0.5 \cdot \left(x + y \cdot \sqrt{z}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in z around inf

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\left(x + \sqrt{\frac{1}{z}} \cdot \left(y \cdot z\right)\right), \color{blue}{\frac{1}{2}}\right) \]
  8. Applied egg-rr99.8%

    \[\leadsto \color{blue}{\left(x + \frac{y}{{z}^{-0.5}}\right) \cdot 0.5} \]
  9. Add Preprocessing

Alternative 2: 73.5% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := y \cdot \sqrt{z}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-37}:\\
\;\;\;\;\frac{y \cdot 0.5}{{z}^{-0.5}}\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-122}:\\
\;\;\;\;0.5 \cdot \left(x - \frac{z \cdot \left(y \cdot y\right)}{x}\right)\\

\mathbf{else}:\\
\;\;\;\;y \cdot \left(0.5 \cdot \sqrt{z}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 y (sqrt.f64 z)) < -4.9999999999999997e-37

    1. Initial program 99.6%

      \[\frac{1}{2} \cdot \left(x + y \cdot \sqrt{z}\right) \]
    2. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2}\right), \color{blue}{\left(x + y \cdot \sqrt{z}\right)}\right) \]
      2. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\color{blue}{x} + y \cdot \sqrt{z}\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \color{blue}{\left(y \cdot \sqrt{z}\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \color{blue}{\left(\sqrt{z}\right)}\right)\right)\right) \]
      5. sqrt-lowering-sqrt.f6499.6%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{sqrt.f64}\left(z\right)\right)\right)\right) \]
    3. Simplified99.6%

      \[\leadsto \color{blue}{0.5 \cdot \left(x + y \cdot \sqrt{z}\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. flip-+N/A

        \[\leadsto \frac{1}{2} \cdot \frac{x \cdot x - \left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)}{\color{blue}{x - y \cdot \sqrt{z}}} \]
      2. clear-numN/A

        \[\leadsto \frac{1}{2} \cdot \frac{1}{\color{blue}{\frac{x - y \cdot \sqrt{z}}{x \cdot x - \left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)}}} \]
      3. un-div-invN/A

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

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{x - y \cdot \sqrt{z}}{x \cdot x - \left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)}\right)}\right) \]
      5. clear-numN/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \left(\frac{1}{\color{blue}{\frac{x \cdot x - \left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)}{x - y \cdot \sqrt{z}}}}\right)\right) \]
      6. flip-+N/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \left(\frac{1}{x + \color{blue}{y \cdot \sqrt{z}}}\right)\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(1, \color{blue}{\left(x + y \cdot \sqrt{z}\right)}\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(x, \color{blue}{\left(y \cdot \sqrt{z}\right)}\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \color{blue}{\left(\sqrt{z}\right)}\right)\right)\right)\right) \]
      10. rem-square-sqrtN/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \left(\sqrt{\sqrt{z} \cdot \sqrt{z}}\right)\right)\right)\right)\right) \]
      11. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{sqrt.f64}\left(\left(\sqrt{z} \cdot \sqrt{z}\right)\right)\right)\right)\right)\right) \]
      12. rem-square-sqrt99.5%

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{sqrt.f64}\left(z\right)\right)\right)\right)\right) \]
    6. Applied egg-rr99.5%

      \[\leadsto \color{blue}{\frac{0.5}{\frac{1}{x + y \cdot \sqrt{z}}}} \]
    7. Taylor expanded in x around 0

      \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{1}{y} \cdot \sqrt{\frac{1}{z}}\right)}\right) \]
    8. Step-by-step derivation
      1. associate-*l/N/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \sqrt{\frac{1}{z}}}{\color{blue}{y}}\right)\right) \]
      2. *-lft-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \left(\frac{\sqrt{\frac{1}{z}}}{y}\right)\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\left(\sqrt{\frac{1}{z}}\right), \color{blue}{y}\right)\right) \]
      4. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\left(\frac{1}{z}\right)\right), y\right)\right) \]
      5. /-lowering-/.f6474.0%

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, z\right)\right), y\right)\right) \]
    9. Simplified74.0%

      \[\leadsto \frac{0.5}{\color{blue}{\frac{\sqrt{\frac{1}{z}}}{y}}} \]
    10. Step-by-step derivation
      1. associate-/r/N/A

        \[\leadsto \frac{\frac{1}{2}}{\sqrt{\frac{1}{z}}} \cdot \color{blue}{y} \]
      2. associate-*l/N/A

        \[\leadsto \frac{\frac{1}{2} \cdot y}{\color{blue}{\sqrt{\frac{1}{z}}}} \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{2} \cdot y\right), \color{blue}{\left(\sqrt{\frac{1}{z}}\right)}\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, y\right), \left(\sqrt{\color{blue}{\frac{1}{z}}}\right)\right) \]
      5. sqrt-divN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, y\right), \left(\frac{\sqrt{1}}{\color{blue}{\sqrt{z}}}\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, y\right), \left(\frac{1}{\sqrt{\color{blue}{z}}}\right)\right) \]
      7. pow1/2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, y\right), \left(\frac{1}{{z}^{\color{blue}{\frac{1}{2}}}}\right)\right) \]
      8. pow-flipN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, y\right), \left({z}^{\color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}\right)\right) \]
      9. pow-lowering-pow.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, y\right), \mathsf{pow.f64}\left(z, \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right)\right) \]
      10. metadata-eval74.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, y\right), \mathsf{pow.f64}\left(z, \frac{-1}{2}\right)\right) \]
    11. Applied egg-rr74.1%

      \[\leadsto \color{blue}{\frac{0.5 \cdot y}{{z}^{-0.5}}} \]

    if -4.9999999999999997e-37 < (*.f64 y (sqrt.f64 z)) < 4.9999999999999999e-122

    1. Initial program 99.9%

      \[\frac{1}{2} \cdot \left(x + y \cdot \sqrt{z}\right) \]
    2. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2}\right), \color{blue}{\left(x + y \cdot \sqrt{z}\right)}\right) \]
      2. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\color{blue}{x} + y \cdot \sqrt{z}\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \color{blue}{\left(y \cdot \sqrt{z}\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \color{blue}{\left(\sqrt{z}\right)}\right)\right)\right) \]
      5. sqrt-lowering-sqrt.f6499.9%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{sqrt.f64}\left(z\right)\right)\right)\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{0.5 \cdot \left(x + y \cdot \sqrt{z}\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. flip-+N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{x \cdot x - \left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)}{\color{blue}{x - y \cdot \sqrt{z}}}\right)\right) \]
      2. div-subN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{x \cdot x}{x - y \cdot \sqrt{z}} - \color{blue}{\frac{\left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)}{x - y \cdot \sqrt{z}}}\right)\right) \]
      3. frac-2negN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\mathsf{neg}\left(x \cdot x\right)}{\mathsf{neg}\left(\left(x - y \cdot \sqrt{z}\right)\right)} - \frac{\color{blue}{\left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)}}{x - y \cdot \sqrt{z}}\right)\right) \]
      4. frac-2negN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\mathsf{neg}\left(x \cdot x\right)}{\mathsf{neg}\left(\left(x - y \cdot \sqrt{z}\right)\right)} - \frac{\mathsf{neg}\left(\left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)\right)}{\color{blue}{\mathsf{neg}\left(\left(x - y \cdot \sqrt{z}\right)\right)}}\right)\right) \]
      5. sub-divN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\left(\mathsf{neg}\left(x \cdot x\right)\right) - \left(\mathsf{neg}\left(\left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)\right)\right)}{\color{blue}{\mathsf{neg}\left(\left(x - y \cdot \sqrt{z}\right)\right)}}\right)\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\left(\left(\mathsf{neg}\left(x \cdot x\right)\right) - \left(\mathsf{neg}\left(\left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)\right)\right)\right), \color{blue}{\left(\mathsf{neg}\left(\left(x - y \cdot \sqrt{z}\right)\right)\right)}\right)\right) \]
    6. Applied egg-rr60.6%

      \[\leadsto 0.5 \cdot \color{blue}{\frac{\left(-x \cdot x\right) - \left(y \cdot y\right) \cdot \left(-z\right)}{0 - \left(x - y \cdot \sqrt{z}\right)}} \]
    7. Taylor expanded in x around inf

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(x, x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, y\right), \mathsf{neg.f64}\left(z\right)\right)\right), \color{blue}{\left(-1 \cdot x\right)}\right)\right) \]
    8. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(x, x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, y\right), \mathsf{neg.f64}\left(z\right)\right)\right), \left(\mathsf{neg}\left(x\right)\right)\right)\right) \]
      2. neg-sub0N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(x, x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, y\right), \mathsf{neg.f64}\left(z\right)\right)\right), \left(0 - \color{blue}{x}\right)\right)\right) \]
      3. --lowering--.f6454.9%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(x, x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, y\right), \mathsf{neg.f64}\left(z\right)\right)\right), \mathsf{\_.f64}\left(0, \color{blue}{x}\right)\right)\right) \]
    9. Simplified54.9%

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

        \[\leadsto \frac{\left(\mathsf{neg}\left(x \cdot x\right)\right) - \left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}{0 - x} \cdot \color{blue}{\frac{1}{2}} \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\left(\mathsf{neg}\left(x \cdot x\right)\right) - \left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}{0 - x}\right), \color{blue}{\frac{1}{2}}\right) \]
      3. div-subN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\mathsf{neg}\left(x \cdot x\right)}{0 - x} - \frac{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}{0 - x}\right), \frac{1}{2}\right) \]
      4. neg-sub0N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{0 - x \cdot x}{0 - x} - \frac{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}{0 - x}\right), \frac{1}{2}\right) \]
      5. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{0 \cdot 0 - x \cdot x}{0 - x} - \frac{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}{0 - x}\right), \frac{1}{2}\right) \]
      6. flip-+N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(0 + x\right) - \frac{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}{0 - x}\right), \frac{1}{2}\right) \]
      7. +-lft-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\left(x - \frac{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}{0 - x}\right), \frac{1}{2}\right) \]
      8. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \left(\frac{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}{0 - x}\right)\right), \frac{1}{2}\right) \]
      9. frac-2negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \left(\frac{\mathsf{neg}\left(\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)\right)}{\mathsf{neg}\left(\left(0 - x\right)\right)}\right)\right), \frac{1}{2}\right) \]
      10. sub0-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \left(\frac{\mathsf{neg}\left(\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)}\right)\right), \frac{1}{2}\right) \]
      11. remove-double-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \left(\frac{\mathsf{neg}\left(\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)\right)}{x}\right)\right), \frac{1}{2}\right) \]
      12. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\left(\mathsf{neg}\left(\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)\right)\right), x\right)\right), \frac{1}{2}\right) \]
      13. distribute-rgt-neg-outN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(y \cdot y\right) \cdot z\right)\right)\right)\right), x\right)\right), \frac{1}{2}\right) \]
      14. remove-double-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\left(\left(y \cdot y\right) \cdot z\right), x\right)\right), \frac{1}{2}\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\left(z \cdot \left(y \cdot y\right)\right), x\right)\right), \frac{1}{2}\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\mathsf{*.f64}\left(z, \left(y \cdot y\right)\right), x\right)\right), \frac{1}{2}\right) \]
      17. *-lowering-*.f6487.5%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\mathsf{*.f64}\left(z, \mathsf{*.f64}\left(y, y\right)\right), x\right)\right), \frac{1}{2}\right) \]
    11. Applied egg-rr87.5%

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

    if 4.9999999999999999e-122 < (*.f64 y (sqrt.f64 z))

    1. Initial program 99.8%

      \[\frac{1}{2} \cdot \left(x + y \cdot \sqrt{z}\right) \]
    2. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2}\right), \color{blue}{\left(x + y \cdot \sqrt{z}\right)}\right) \]
      2. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\color{blue}{x} + y \cdot \sqrt{z}\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \color{blue}{\left(y \cdot \sqrt{z}\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \color{blue}{\left(\sqrt{z}\right)}\right)\right)\right) \]
      5. sqrt-lowering-sqrt.f6499.8%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{sqrt.f64}\left(z\right)\right)\right)\right) \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{0.5 \cdot \left(x + y \cdot \sqrt{z}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0

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

        \[\leadsto \left(y \cdot \sqrt{z}\right) \cdot \color{blue}{\frac{1}{2}} \]
      2. associate-*r*N/A

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

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

        \[\leadsto \mathsf{*.f64}\left(y, \color{blue}{\left(\frac{1}{2} \cdot \sqrt{z}\right)}\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left(\sqrt{z}\right)}\right)\right) \]
      6. sqrt-lowering-sqrt.f6476.0%

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(z\right)\right)\right) \]
    7. Simplified76.0%

      \[\leadsto \color{blue}{y \cdot \left(0.5 \cdot \sqrt{z}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification79.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \sqrt{z} \leq -5 \cdot 10^{-37}:\\ \;\;\;\;\frac{y \cdot 0.5}{{z}^{-0.5}}\\ \mathbf{elif}\;y \cdot \sqrt{z} \leq 5 \cdot 10^{-122}:\\ \;\;\;\;0.5 \cdot \left(x - \frac{z \cdot \left(y \cdot y\right)}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(0.5 \cdot \sqrt{z}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 73.4% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := y \cdot \sqrt{z}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-37}:\\
\;\;\;\;\frac{0.5}{\frac{{z}^{-0.5}}{y}}\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-122}:\\
\;\;\;\;0.5 \cdot \left(x - \frac{z \cdot \left(y \cdot y\right)}{x}\right)\\

\mathbf{else}:\\
\;\;\;\;y \cdot \left(0.5 \cdot \sqrt{z}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 y (sqrt.f64 z)) < -4.9999999999999997e-37

    1. Initial program 99.6%

      \[\frac{1}{2} \cdot \left(x + y \cdot \sqrt{z}\right) \]
    2. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2}\right), \color{blue}{\left(x + y \cdot \sqrt{z}\right)}\right) \]
      2. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\color{blue}{x} + y \cdot \sqrt{z}\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \color{blue}{\left(y \cdot \sqrt{z}\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \color{blue}{\left(\sqrt{z}\right)}\right)\right)\right) \]
      5. sqrt-lowering-sqrt.f6499.6%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{sqrt.f64}\left(z\right)\right)\right)\right) \]
    3. Simplified99.6%

      \[\leadsto \color{blue}{0.5 \cdot \left(x + y \cdot \sqrt{z}\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. flip-+N/A

        \[\leadsto \frac{1}{2} \cdot \frac{x \cdot x - \left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)}{\color{blue}{x - y \cdot \sqrt{z}}} \]
      2. clear-numN/A

        \[\leadsto \frac{1}{2} \cdot \frac{1}{\color{blue}{\frac{x - y \cdot \sqrt{z}}{x \cdot x - \left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)}}} \]
      3. un-div-invN/A

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

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{x - y \cdot \sqrt{z}}{x \cdot x - \left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)}\right)}\right) \]
      5. clear-numN/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \left(\frac{1}{\color{blue}{\frac{x \cdot x - \left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)}{x - y \cdot \sqrt{z}}}}\right)\right) \]
      6. flip-+N/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \left(\frac{1}{x + \color{blue}{y \cdot \sqrt{z}}}\right)\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(1, \color{blue}{\left(x + y \cdot \sqrt{z}\right)}\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(x, \color{blue}{\left(y \cdot \sqrt{z}\right)}\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \color{blue}{\left(\sqrt{z}\right)}\right)\right)\right)\right) \]
      10. rem-square-sqrtN/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \left(\sqrt{\sqrt{z} \cdot \sqrt{z}}\right)\right)\right)\right)\right) \]
      11. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{sqrt.f64}\left(\left(\sqrt{z} \cdot \sqrt{z}\right)\right)\right)\right)\right)\right) \]
      12. rem-square-sqrt99.5%

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{sqrt.f64}\left(z\right)\right)\right)\right)\right) \]
    6. Applied egg-rr99.5%

      \[\leadsto \color{blue}{\frac{0.5}{\frac{1}{x + y \cdot \sqrt{z}}}} \]
    7. Taylor expanded in x around 0

      \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{1}{y} \cdot \sqrt{\frac{1}{z}}\right)}\right) \]
    8. Step-by-step derivation
      1. associate-*l/N/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \left(\frac{1 \cdot \sqrt{\frac{1}{z}}}{\color{blue}{y}}\right)\right) \]
      2. *-lft-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \left(\frac{\sqrt{\frac{1}{z}}}{y}\right)\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\left(\sqrt{\frac{1}{z}}\right), \color{blue}{y}\right)\right) \]
      4. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\left(\frac{1}{z}\right)\right), y\right)\right) \]
      5. /-lowering-/.f6474.0%

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, z\right)\right), y\right)\right) \]
    9. Simplified74.0%

      \[\leadsto \frac{0.5}{\color{blue}{\frac{\sqrt{\frac{1}{z}}}{y}}} \]
    10. Step-by-step derivation
      1. sqrt-divN/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\left(\frac{\sqrt{1}}{\sqrt{z}}\right), y\right)\right) \]
      2. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\left(\frac{1}{\sqrt{z}}\right), y\right)\right) \]
      3. pow1/2N/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\left(\frac{1}{{z}^{\frac{1}{2}}}\right), y\right)\right) \]
      4. pow-flipN/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\left({z}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right), y\right)\right) \]
      5. pow-lowering-pow.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{pow.f64}\left(z, \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)\right), y\right)\right) \]
      6. metadata-eval74.0%

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{pow.f64}\left(z, \frac{-1}{2}\right), y\right)\right) \]
    11. Applied egg-rr74.0%

      \[\leadsto \frac{0.5}{\frac{\color{blue}{{z}^{-0.5}}}{y}} \]

    if -4.9999999999999997e-37 < (*.f64 y (sqrt.f64 z)) < 4.9999999999999999e-122

    1. Initial program 99.9%

      \[\frac{1}{2} \cdot \left(x + y \cdot \sqrt{z}\right) \]
    2. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2}\right), \color{blue}{\left(x + y \cdot \sqrt{z}\right)}\right) \]
      2. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\color{blue}{x} + y \cdot \sqrt{z}\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \color{blue}{\left(y \cdot \sqrt{z}\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \color{blue}{\left(\sqrt{z}\right)}\right)\right)\right) \]
      5. sqrt-lowering-sqrt.f6499.9%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{sqrt.f64}\left(z\right)\right)\right)\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{0.5 \cdot \left(x + y \cdot \sqrt{z}\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. flip-+N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{x \cdot x - \left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)}{\color{blue}{x - y \cdot \sqrt{z}}}\right)\right) \]
      2. div-subN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{x \cdot x}{x - y \cdot \sqrt{z}} - \color{blue}{\frac{\left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)}{x - y \cdot \sqrt{z}}}\right)\right) \]
      3. frac-2negN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\mathsf{neg}\left(x \cdot x\right)}{\mathsf{neg}\left(\left(x - y \cdot \sqrt{z}\right)\right)} - \frac{\color{blue}{\left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)}}{x - y \cdot \sqrt{z}}\right)\right) \]
      4. frac-2negN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\mathsf{neg}\left(x \cdot x\right)}{\mathsf{neg}\left(\left(x - y \cdot \sqrt{z}\right)\right)} - \frac{\mathsf{neg}\left(\left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)\right)}{\color{blue}{\mathsf{neg}\left(\left(x - y \cdot \sqrt{z}\right)\right)}}\right)\right) \]
      5. sub-divN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\left(\mathsf{neg}\left(x \cdot x\right)\right) - \left(\mathsf{neg}\left(\left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)\right)\right)}{\color{blue}{\mathsf{neg}\left(\left(x - y \cdot \sqrt{z}\right)\right)}}\right)\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\left(\left(\mathsf{neg}\left(x \cdot x\right)\right) - \left(\mathsf{neg}\left(\left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)\right)\right)\right), \color{blue}{\left(\mathsf{neg}\left(\left(x - y \cdot \sqrt{z}\right)\right)\right)}\right)\right) \]
    6. Applied egg-rr60.6%

      \[\leadsto 0.5 \cdot \color{blue}{\frac{\left(-x \cdot x\right) - \left(y \cdot y\right) \cdot \left(-z\right)}{0 - \left(x - y \cdot \sqrt{z}\right)}} \]
    7. Taylor expanded in x around inf

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(x, x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, y\right), \mathsf{neg.f64}\left(z\right)\right)\right), \color{blue}{\left(-1 \cdot x\right)}\right)\right) \]
    8. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(x, x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, y\right), \mathsf{neg.f64}\left(z\right)\right)\right), \left(\mathsf{neg}\left(x\right)\right)\right)\right) \]
      2. neg-sub0N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(x, x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, y\right), \mathsf{neg.f64}\left(z\right)\right)\right), \left(0 - \color{blue}{x}\right)\right)\right) \]
      3. --lowering--.f6454.9%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(x, x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, y\right), \mathsf{neg.f64}\left(z\right)\right)\right), \mathsf{\_.f64}\left(0, \color{blue}{x}\right)\right)\right) \]
    9. Simplified54.9%

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

        \[\leadsto \frac{\left(\mathsf{neg}\left(x \cdot x\right)\right) - \left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}{0 - x} \cdot \color{blue}{\frac{1}{2}} \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\left(\mathsf{neg}\left(x \cdot x\right)\right) - \left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}{0 - x}\right), \color{blue}{\frac{1}{2}}\right) \]
      3. div-subN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\mathsf{neg}\left(x \cdot x\right)}{0 - x} - \frac{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}{0 - x}\right), \frac{1}{2}\right) \]
      4. neg-sub0N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{0 - x \cdot x}{0 - x} - \frac{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}{0 - x}\right), \frac{1}{2}\right) \]
      5. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{0 \cdot 0 - x \cdot x}{0 - x} - \frac{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}{0 - x}\right), \frac{1}{2}\right) \]
      6. flip-+N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(0 + x\right) - \frac{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}{0 - x}\right), \frac{1}{2}\right) \]
      7. +-lft-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\left(x - \frac{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}{0 - x}\right), \frac{1}{2}\right) \]
      8. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \left(\frac{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}{0 - x}\right)\right), \frac{1}{2}\right) \]
      9. frac-2negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \left(\frac{\mathsf{neg}\left(\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)\right)}{\mathsf{neg}\left(\left(0 - x\right)\right)}\right)\right), \frac{1}{2}\right) \]
      10. sub0-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \left(\frac{\mathsf{neg}\left(\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)}\right)\right), \frac{1}{2}\right) \]
      11. remove-double-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \left(\frac{\mathsf{neg}\left(\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)\right)}{x}\right)\right), \frac{1}{2}\right) \]
      12. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\left(\mathsf{neg}\left(\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)\right)\right), x\right)\right), \frac{1}{2}\right) \]
      13. distribute-rgt-neg-outN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(y \cdot y\right) \cdot z\right)\right)\right)\right), x\right)\right), \frac{1}{2}\right) \]
      14. remove-double-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\left(\left(y \cdot y\right) \cdot z\right), x\right)\right), \frac{1}{2}\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\left(z \cdot \left(y \cdot y\right)\right), x\right)\right), \frac{1}{2}\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\mathsf{*.f64}\left(z, \left(y \cdot y\right)\right), x\right)\right), \frac{1}{2}\right) \]
      17. *-lowering-*.f6487.5%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\mathsf{*.f64}\left(z, \mathsf{*.f64}\left(y, y\right)\right), x\right)\right), \frac{1}{2}\right) \]
    11. Applied egg-rr87.5%

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

    if 4.9999999999999999e-122 < (*.f64 y (sqrt.f64 z))

    1. Initial program 99.8%

      \[\frac{1}{2} \cdot \left(x + y \cdot \sqrt{z}\right) \]
    2. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2}\right), \color{blue}{\left(x + y \cdot \sqrt{z}\right)}\right) \]
      2. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\color{blue}{x} + y \cdot \sqrt{z}\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \color{blue}{\left(y \cdot \sqrt{z}\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \color{blue}{\left(\sqrt{z}\right)}\right)\right)\right) \]
      5. sqrt-lowering-sqrt.f6499.8%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{sqrt.f64}\left(z\right)\right)\right)\right) \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{0.5 \cdot \left(x + y \cdot \sqrt{z}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0

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

        \[\leadsto \left(y \cdot \sqrt{z}\right) \cdot \color{blue}{\frac{1}{2}} \]
      2. associate-*r*N/A

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

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

        \[\leadsto \mathsf{*.f64}\left(y, \color{blue}{\left(\frac{1}{2} \cdot \sqrt{z}\right)}\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left(\sqrt{z}\right)}\right)\right) \]
      6. sqrt-lowering-sqrt.f6476.0%

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(z\right)\right)\right) \]
    7. Simplified76.0%

      \[\leadsto \color{blue}{y \cdot \left(0.5 \cdot \sqrt{z}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification79.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \sqrt{z} \leq -5 \cdot 10^{-37}:\\ \;\;\;\;\frac{0.5}{\frac{{z}^{-0.5}}{y}}\\ \mathbf{elif}\;y \cdot \sqrt{z} \leq 5 \cdot 10^{-122}:\\ \;\;\;\;0.5 \cdot \left(x - \frac{z \cdot \left(y \cdot y\right)}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(0.5 \cdot \sqrt{z}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 73.5% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-122}:\\
\;\;\;\;0.5 \cdot \left(x - \frac{z \cdot \left(y \cdot y\right)}{x}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 y (sqrt.f64 z)) < -4.9999999999999997e-37 or 4.9999999999999999e-122 < (*.f64 y (sqrt.f64 z))

    1. Initial program 99.7%

      \[\frac{1}{2} \cdot \left(x + y \cdot \sqrt{z}\right) \]
    2. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2}\right), \color{blue}{\left(x + y \cdot \sqrt{z}\right)}\right) \]
      2. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\color{blue}{x} + y \cdot \sqrt{z}\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \color{blue}{\left(y \cdot \sqrt{z}\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \color{blue}{\left(\sqrt{z}\right)}\right)\right)\right) \]
      5. sqrt-lowering-sqrt.f6499.7%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{sqrt.f64}\left(z\right)\right)\right)\right) \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{0.5 \cdot \left(x + y \cdot \sqrt{z}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0

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

        \[\leadsto \left(y \cdot \sqrt{z}\right) \cdot \color{blue}{\frac{1}{2}} \]
      2. associate-*r*N/A

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

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

        \[\leadsto \mathsf{*.f64}\left(y, \color{blue}{\left(\frac{1}{2} \cdot \sqrt{z}\right)}\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left(\sqrt{z}\right)}\right)\right) \]
      6. sqrt-lowering-sqrt.f6474.9%

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(z\right)\right)\right) \]
    7. Simplified74.9%

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

    if -4.9999999999999997e-37 < (*.f64 y (sqrt.f64 z)) < 4.9999999999999999e-122

    1. Initial program 99.9%

      \[\frac{1}{2} \cdot \left(x + y \cdot \sqrt{z}\right) \]
    2. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2}\right), \color{blue}{\left(x + y \cdot \sqrt{z}\right)}\right) \]
      2. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\color{blue}{x} + y \cdot \sqrt{z}\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \color{blue}{\left(y \cdot \sqrt{z}\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \color{blue}{\left(\sqrt{z}\right)}\right)\right)\right) \]
      5. sqrt-lowering-sqrt.f6499.9%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{sqrt.f64}\left(z\right)\right)\right)\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{0.5 \cdot \left(x + y \cdot \sqrt{z}\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. flip-+N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{x \cdot x - \left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)}{\color{blue}{x - y \cdot \sqrt{z}}}\right)\right) \]
      2. div-subN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{x \cdot x}{x - y \cdot \sqrt{z}} - \color{blue}{\frac{\left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)}{x - y \cdot \sqrt{z}}}\right)\right) \]
      3. frac-2negN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\mathsf{neg}\left(x \cdot x\right)}{\mathsf{neg}\left(\left(x - y \cdot \sqrt{z}\right)\right)} - \frac{\color{blue}{\left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)}}{x - y \cdot \sqrt{z}}\right)\right) \]
      4. frac-2negN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\mathsf{neg}\left(x \cdot x\right)}{\mathsf{neg}\left(\left(x - y \cdot \sqrt{z}\right)\right)} - \frac{\mathsf{neg}\left(\left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)\right)}{\color{blue}{\mathsf{neg}\left(\left(x - y \cdot \sqrt{z}\right)\right)}}\right)\right) \]
      5. sub-divN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\left(\mathsf{neg}\left(x \cdot x\right)\right) - \left(\mathsf{neg}\left(\left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)\right)\right)}{\color{blue}{\mathsf{neg}\left(\left(x - y \cdot \sqrt{z}\right)\right)}}\right)\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\left(\left(\mathsf{neg}\left(x \cdot x\right)\right) - \left(\mathsf{neg}\left(\left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)\right)\right)\right), \color{blue}{\left(\mathsf{neg}\left(\left(x - y \cdot \sqrt{z}\right)\right)\right)}\right)\right) \]
    6. Applied egg-rr60.6%

      \[\leadsto 0.5 \cdot \color{blue}{\frac{\left(-x \cdot x\right) - \left(y \cdot y\right) \cdot \left(-z\right)}{0 - \left(x - y \cdot \sqrt{z}\right)}} \]
    7. Taylor expanded in x around inf

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(x, x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, y\right), \mathsf{neg.f64}\left(z\right)\right)\right), \color{blue}{\left(-1 \cdot x\right)}\right)\right) \]
    8. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(x, x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, y\right), \mathsf{neg.f64}\left(z\right)\right)\right), \left(\mathsf{neg}\left(x\right)\right)\right)\right) \]
      2. neg-sub0N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(x, x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, y\right), \mathsf{neg.f64}\left(z\right)\right)\right), \left(0 - \color{blue}{x}\right)\right)\right) \]
      3. --lowering--.f6454.9%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(x, x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, y\right), \mathsf{neg.f64}\left(z\right)\right)\right), \mathsf{\_.f64}\left(0, \color{blue}{x}\right)\right)\right) \]
    9. Simplified54.9%

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

        \[\leadsto \frac{\left(\mathsf{neg}\left(x \cdot x\right)\right) - \left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}{0 - x} \cdot \color{blue}{\frac{1}{2}} \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\left(\mathsf{neg}\left(x \cdot x\right)\right) - \left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}{0 - x}\right), \color{blue}{\frac{1}{2}}\right) \]
      3. div-subN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\mathsf{neg}\left(x \cdot x\right)}{0 - x} - \frac{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}{0 - x}\right), \frac{1}{2}\right) \]
      4. neg-sub0N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{0 - x \cdot x}{0 - x} - \frac{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}{0 - x}\right), \frac{1}{2}\right) \]
      5. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{0 \cdot 0 - x \cdot x}{0 - x} - \frac{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}{0 - x}\right), \frac{1}{2}\right) \]
      6. flip-+N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(0 + x\right) - \frac{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}{0 - x}\right), \frac{1}{2}\right) \]
      7. +-lft-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\left(x - \frac{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}{0 - x}\right), \frac{1}{2}\right) \]
      8. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \left(\frac{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}{0 - x}\right)\right), \frac{1}{2}\right) \]
      9. frac-2negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \left(\frac{\mathsf{neg}\left(\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)\right)}{\mathsf{neg}\left(\left(0 - x\right)\right)}\right)\right), \frac{1}{2}\right) \]
      10. sub0-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \left(\frac{\mathsf{neg}\left(\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)}\right)\right), \frac{1}{2}\right) \]
      11. remove-double-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \left(\frac{\mathsf{neg}\left(\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)\right)}{x}\right)\right), \frac{1}{2}\right) \]
      12. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\left(\mathsf{neg}\left(\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)\right)\right), x\right)\right), \frac{1}{2}\right) \]
      13. distribute-rgt-neg-outN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(y \cdot y\right) \cdot z\right)\right)\right)\right), x\right)\right), \frac{1}{2}\right) \]
      14. remove-double-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\left(\left(y \cdot y\right) \cdot z\right), x\right)\right), \frac{1}{2}\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\left(z \cdot \left(y \cdot y\right)\right), x\right)\right), \frac{1}{2}\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\mathsf{*.f64}\left(z, \left(y \cdot y\right)\right), x\right)\right), \frac{1}{2}\right) \]
      17. *-lowering-*.f6487.5%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\mathsf{*.f64}\left(z, \mathsf{*.f64}\left(y, y\right)\right), x\right)\right), \frac{1}{2}\right) \]
    11. Applied egg-rr87.5%

      \[\leadsto \color{blue}{\left(x - \frac{z \cdot \left(y \cdot y\right)}{x}\right) \cdot 0.5} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification79.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \sqrt{z} \leq -5 \cdot 10^{-37}:\\ \;\;\;\;y \cdot \left(0.5 \cdot \sqrt{z}\right)\\ \mathbf{elif}\;y \cdot \sqrt{z} \leq 5 \cdot 10^{-122}:\\ \;\;\;\;0.5 \cdot \left(x - \frac{z \cdot \left(y \cdot y\right)}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(0.5 \cdot \sqrt{z}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 99.8% accurate, 1.0× speedup?

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

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

    \[\frac{1}{2} \cdot \left(x + y \cdot \sqrt{z}\right) \]
  2. Step-by-step derivation
    1. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2}\right), \color{blue}{\left(x + y \cdot \sqrt{z}\right)}\right) \]
    2. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\color{blue}{x} + y \cdot \sqrt{z}\right)\right) \]
    3. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \color{blue}{\left(y \cdot \sqrt{z}\right)}\right)\right) \]
    4. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \color{blue}{\left(\sqrt{z}\right)}\right)\right)\right) \]
    5. sqrt-lowering-sqrt.f6499.8%

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{sqrt.f64}\left(z\right)\right)\right)\right) \]
  3. Simplified99.8%

    \[\leadsto \color{blue}{0.5 \cdot \left(x + y \cdot \sqrt{z}\right)} \]
  4. Add Preprocessing
  5. Add Preprocessing

Alternative 6: 53.8% accurate, 5.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq 2.25 \cdot 10^{+76}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{-1}{\frac{\frac{x}{z}}{0.5 \cdot \frac{y \cdot y}{x}}} - -0.5\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z 2.25e+76)
   (* x 0.5)
   (* x (- (/ -1.0 (/ (/ x z) (* 0.5 (/ (* y y) x)))) -0.5))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= 2.25e+76) {
		tmp = x * 0.5;
	} else {
		tmp = x * ((-1.0 / ((x / z) / (0.5 * ((y * y) / x)))) - -0.5);
	}
	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 <= 2.25d+76) then
        tmp = x * 0.5d0
    else
        tmp = x * (((-1.0d0) / ((x / z) / (0.5d0 * ((y * y) / x)))) - (-0.5d0))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= 2.25e+76) {
		tmp = x * 0.5;
	} else {
		tmp = x * ((-1.0 / ((x / z) / (0.5 * ((y * y) / x)))) - -0.5);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= 2.25e+76:
		tmp = x * 0.5
	else:
		tmp = x * ((-1.0 / ((x / z) / (0.5 * ((y * y) / x)))) - -0.5)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= 2.25e+76)
		tmp = Float64(x * 0.5);
	else
		tmp = Float64(x * Float64(Float64(-1.0 / Float64(Float64(x / z) / Float64(0.5 * Float64(Float64(y * y) / x)))) - -0.5));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= 2.25e+76)
		tmp = x * 0.5;
	else
		tmp = x * ((-1.0 / ((x / z) / (0.5 * ((y * y) / x)))) - -0.5);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, 2.25e+76], N[(x * 0.5), $MachinePrecision], N[(x * N[(N[(-1.0 / N[(N[(x / z), $MachinePrecision] / N[(0.5 * N[(N[(y * y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq 2.25 \cdot 10^{+76}:\\
\;\;\;\;x \cdot 0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 2.2499999999999999e76

    1. Initial program 99.8%

      \[\frac{1}{2} \cdot \left(x + y \cdot \sqrt{z}\right) \]
    2. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2}\right), \color{blue}{\left(x + y \cdot \sqrt{z}\right)}\right) \]
      2. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\color{blue}{x} + y \cdot \sqrt{z}\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \color{blue}{\left(y \cdot \sqrt{z}\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \color{blue}{\left(\sqrt{z}\right)}\right)\right)\right) \]
      5. sqrt-lowering-sqrt.f6499.8%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{sqrt.f64}\left(z\right)\right)\right)\right) \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{0.5 \cdot \left(x + y \cdot \sqrt{z}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{1}{2} \cdot x} \]
    6. Step-by-step derivation
      1. *-lowering-*.f6460.3%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{x}\right) \]
    7. Simplified60.3%

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

    if 2.2499999999999999e76 < z

    1. Initial program 99.7%

      \[\frac{1}{2} \cdot \left(x + y \cdot \sqrt{z}\right) \]
    2. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2}\right), \color{blue}{\left(x + y \cdot \sqrt{z}\right)}\right) \]
      2. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\color{blue}{x} + y \cdot \sqrt{z}\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \color{blue}{\left(y \cdot \sqrt{z}\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \color{blue}{\left(\sqrt{z}\right)}\right)\right)\right) \]
      5. sqrt-lowering-sqrt.f6499.7%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{sqrt.f64}\left(z\right)\right)\right)\right) \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{0.5 \cdot \left(x + y \cdot \sqrt{z}\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. flip-+N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{x \cdot x - \left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)}{\color{blue}{x - y \cdot \sqrt{z}}}\right)\right) \]
      2. div-subN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{x \cdot x}{x - y \cdot \sqrt{z}} - \color{blue}{\frac{\left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)}{x - y \cdot \sqrt{z}}}\right)\right) \]
      3. frac-2negN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\mathsf{neg}\left(x \cdot x\right)}{\mathsf{neg}\left(\left(x - y \cdot \sqrt{z}\right)\right)} - \frac{\color{blue}{\left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)}}{x - y \cdot \sqrt{z}}\right)\right) \]
      4. frac-2negN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\mathsf{neg}\left(x \cdot x\right)}{\mathsf{neg}\left(\left(x - y \cdot \sqrt{z}\right)\right)} - \frac{\mathsf{neg}\left(\left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)\right)}{\color{blue}{\mathsf{neg}\left(\left(x - y \cdot \sqrt{z}\right)\right)}}\right)\right) \]
      5. sub-divN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\left(\mathsf{neg}\left(x \cdot x\right)\right) - \left(\mathsf{neg}\left(\left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)\right)\right)}{\color{blue}{\mathsf{neg}\left(\left(x - y \cdot \sqrt{z}\right)\right)}}\right)\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\left(\left(\mathsf{neg}\left(x \cdot x\right)\right) - \left(\mathsf{neg}\left(\left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)\right)\right)\right), \color{blue}{\left(\mathsf{neg}\left(\left(x - y \cdot \sqrt{z}\right)\right)\right)}\right)\right) \]
    6. Applied egg-rr41.2%

      \[\leadsto 0.5 \cdot \color{blue}{\frac{\left(-x \cdot x\right) - \left(y \cdot y\right) \cdot \left(-z\right)}{0 - \left(x - y \cdot \sqrt{z}\right)}} \]
    7. Taylor expanded in x around inf

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(x, x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, y\right), \mathsf{neg.f64}\left(z\right)\right)\right), \color{blue}{\left(-1 \cdot x\right)}\right)\right) \]
    8. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(x, x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, y\right), \mathsf{neg.f64}\left(z\right)\right)\right), \left(\mathsf{neg}\left(x\right)\right)\right)\right) \]
      2. neg-sub0N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(x, x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, y\right), \mathsf{neg.f64}\left(z\right)\right)\right), \left(0 - \color{blue}{x}\right)\right)\right) \]
      3. --lowering--.f6420.9%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(x, x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, y\right), \mathsf{neg.f64}\left(z\right)\right)\right), \mathsf{\_.f64}\left(0, \color{blue}{x}\right)\right)\right) \]
    9. Simplified20.9%

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot \frac{{y}^{2} \cdot z}{{x}^{2}} - \frac{1}{2}\right), \color{blue}{\left(-1 \cdot x\right)}\right) \]
    12. Simplified36.3%

      \[\leadsto \color{blue}{\left(-0.5 + \frac{\frac{z \cdot \left(0.5 \cdot \left(y \cdot y\right)\right)}{x}}{x}\right) \cdot \left(0 - x\right)} \]
    13. Step-by-step derivation
      1. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{-1}{2}, \left(\frac{1}{\frac{x}{\frac{z \cdot \left(\frac{1}{2} \cdot \left(y \cdot y\right)\right)}{x}}}\right)\right), \mathsf{\_.f64}\left(0, x\right)\right) \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(1, \left(\frac{x}{\frac{z \cdot \left(\frac{1}{2} \cdot \left(y \cdot y\right)\right)}{x}}\right)\right)\right), \mathsf{\_.f64}\left(0, x\right)\right) \]
      3. associate-/l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(1, \left(\frac{x}{z \cdot \frac{\frac{1}{2} \cdot \left(y \cdot y\right)}{x}}\right)\right)\right), \mathsf{\_.f64}\left(0, x\right)\right) \]
      4. associate-/r*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(1, \left(\frac{\frac{x}{z}}{\frac{\frac{1}{2} \cdot \left(y \cdot y\right)}{x}}\right)\right)\right), \mathsf{\_.f64}\left(0, x\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\left(\frac{x}{z}\right), \left(\frac{\frac{1}{2} \cdot \left(y \cdot y\right)}{x}\right)\right)\right)\right), \mathsf{\_.f64}\left(0, x\right)\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{/.f64}\left(x, z\right), \left(\frac{\frac{1}{2} \cdot \left(y \cdot y\right)}{x}\right)\right)\right)\right), \mathsf{\_.f64}\left(0, x\right)\right) \]
      7. associate-/l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{/.f64}\left(x, z\right), \left(\frac{1}{2} \cdot \frac{y \cdot y}{x}\right)\right)\right)\right), \mathsf{\_.f64}\left(0, x\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{/.f64}\left(x, z\right), \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{y \cdot y}{x}\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(0, x\right)\right) \]
      9. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{/.f64}\left(x, z\right), \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\left(y \cdot y\right), x\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(0, x\right)\right) \]
      10. *-lowering-*.f6438.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{/.f64}\left(x, z\right), \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{*.f64}\left(y, y\right), x\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(0, x\right)\right) \]
    14. Applied egg-rr38.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 2.25 \cdot 10^{+76}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{-1}{\frac{\frac{x}{z}}{0.5 \cdot \frac{y \cdot y}{x}}} - -0.5\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 52.3% accurate, 9.9× speedup?

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

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

    \[\frac{1}{2} \cdot \left(x + y \cdot \sqrt{z}\right) \]
  2. Step-by-step derivation
    1. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2}\right), \color{blue}{\left(x + y \cdot \sqrt{z}\right)}\right) \]
    2. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\color{blue}{x} + y \cdot \sqrt{z}\right)\right) \]
    3. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \color{blue}{\left(y \cdot \sqrt{z}\right)}\right)\right) \]
    4. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \color{blue}{\left(\sqrt{z}\right)}\right)\right)\right) \]
    5. sqrt-lowering-sqrt.f6499.8%

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{sqrt.f64}\left(z\right)\right)\right)\right) \]
  3. Simplified99.8%

    \[\leadsto \color{blue}{0.5 \cdot \left(x + y \cdot \sqrt{z}\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. flip-+N/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{x \cdot x - \left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)}{\color{blue}{x - y \cdot \sqrt{z}}}\right)\right) \]
    2. div-subN/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{x \cdot x}{x - y \cdot \sqrt{z}} - \color{blue}{\frac{\left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)}{x - y \cdot \sqrt{z}}}\right)\right) \]
    3. frac-2negN/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\mathsf{neg}\left(x \cdot x\right)}{\mathsf{neg}\left(\left(x - y \cdot \sqrt{z}\right)\right)} - \frac{\color{blue}{\left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)}}{x - y \cdot \sqrt{z}}\right)\right) \]
    4. frac-2negN/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\mathsf{neg}\left(x \cdot x\right)}{\mathsf{neg}\left(\left(x - y \cdot \sqrt{z}\right)\right)} - \frac{\mathsf{neg}\left(\left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)\right)}{\color{blue}{\mathsf{neg}\left(\left(x - y \cdot \sqrt{z}\right)\right)}}\right)\right) \]
    5. sub-divN/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\left(\mathsf{neg}\left(x \cdot x\right)\right) - \left(\mathsf{neg}\left(\left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)\right)\right)}{\color{blue}{\mathsf{neg}\left(\left(x - y \cdot \sqrt{z}\right)\right)}}\right)\right) \]
    6. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\left(\left(\mathsf{neg}\left(x \cdot x\right)\right) - \left(\mathsf{neg}\left(\left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)\right)\right)\right), \color{blue}{\left(\mathsf{neg}\left(\left(x - y \cdot \sqrt{z}\right)\right)\right)}\right)\right) \]
  6. Applied egg-rr47.1%

    \[\leadsto 0.5 \cdot \color{blue}{\frac{\left(-x \cdot x\right) - \left(y \cdot y\right) \cdot \left(-z\right)}{0 - \left(x - y \cdot \sqrt{z}\right)}} \]
  7. Taylor expanded in x around inf

    \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(x, x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, y\right), \mathsf{neg.f64}\left(z\right)\right)\right), \color{blue}{\left(-1 \cdot x\right)}\right)\right) \]
  8. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(x, x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, y\right), \mathsf{neg.f64}\left(z\right)\right)\right), \left(\mathsf{neg}\left(x\right)\right)\right)\right) \]
    2. neg-sub0N/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(x, x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, y\right), \mathsf{neg.f64}\left(z\right)\right)\right), \left(0 - \color{blue}{x}\right)\right)\right) \]
    3. --lowering--.f6429.0%

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{neg.f64}\left(\mathsf{*.f64}\left(x, x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, y\right), \mathsf{neg.f64}\left(z\right)\right)\right), \mathsf{\_.f64}\left(0, \color{blue}{x}\right)\right)\right) \]
  9. Simplified29.0%

    \[\leadsto 0.5 \cdot \frac{\left(-x \cdot x\right) - \left(y \cdot y\right) \cdot \left(-z\right)}{\color{blue}{0 - x}} \]
  10. Step-by-step derivation
    1. div-subN/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\mathsf{neg}\left(x \cdot x\right)}{0 - x} - \color{blue}{\frac{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}{0 - x}}\right)\right) \]
    2. frac-2negN/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(x \cdot x\right)\right)\right)}{\mathsf{neg}\left(\left(0 - x\right)\right)} - \frac{\color{blue}{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}}{0 - x}\right)\right) \]
    3. sub0-negN/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(x \cdot x\right)\right)\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)} - \frac{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(\color{blue}{z}\right)\right)}{0 - x}\right)\right) \]
    4. remove-double-negN/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(x \cdot x\right)\right)\right)}{x} - \frac{\left(y \cdot y\right) \cdot \color{blue}{\left(\mathsf{neg}\left(z\right)\right)}}{0 - x}\right)\right) \]
    5. clear-numN/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(x \cdot x\right)\right)\right)}{x} - \frac{1}{\color{blue}{\frac{0 - x}{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}}}\right)\right) \]
    6. frac-subN/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x \cdot x\right)\right)\right)\right) \cdot \frac{0 - x}{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)} - x \cdot 1}{\color{blue}{x \cdot \frac{0 - x}{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}}}\right)\right) \]
    7. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x \cdot x\right)\right)\right)\right) \cdot \frac{0 - x}{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)} - x \cdot 1\right), \color{blue}{\left(x \cdot \frac{0 - x}{\left(y \cdot y\right) \cdot \left(\mathsf{neg}\left(z\right)\right)}\right)}\right)\right) \]
  11. Applied egg-rr7.7%

    \[\leadsto 0.5 \cdot \color{blue}{\frac{\left(-\left(0 - x \cdot x\right)\right) \cdot \frac{x}{z \cdot \left(y \cdot y\right)} - x}{x \cdot \frac{x}{z \cdot \left(y \cdot y\right)}}} \]
  12. Taylor expanded in x around 0

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

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{{x}^{2} + -1 \cdot \left({y}^{2} \cdot z\right)}{x}\right)\right) \]
    2. mul-1-negN/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{{x}^{2} + \left(\mathsf{neg}\left({y}^{2} \cdot z\right)\right)}{x}\right)\right) \]
    3. sub-negN/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{{x}^{2} - {y}^{2} \cdot z}{x}\right)\right) \]
    4. div-subN/A

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

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

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(x \cdot \frac{x}{x} - \frac{\color{blue}{{y}^{2} \cdot z}}{x}\right)\right) \]
    7. fmsub-defineN/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{fmsub}\left(x, \color{blue}{\left(\frac{x}{x}\right)}, \left(\frac{{y}^{2} \cdot z}{x}\right)\right)\right) \]
    8. *-inversesN/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{fmsub}\left(x, 1, \left(\frac{{y}^{2} \cdot z}{x}\right)\right)\right) \]
    9. fmsub-defineN/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(x \cdot 1 - \color{blue}{\frac{{y}^{2} \cdot z}{x}}\right)\right) \]
    10. *-rgt-identityN/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(x - \frac{\color{blue}{{y}^{2} \cdot z}}{x}\right)\right) \]
    11. --lowering--.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{\_.f64}\left(x, \color{blue}{\left(\frac{{y}^{2} \cdot z}{x}\right)}\right)\right) \]
    12. /-lowering-/.f64N/A

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

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\left(\left(y \cdot y\right) \cdot z\right), x\right)\right)\right) \]
    14. associate-*l*N/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\left(y \cdot \left(y \cdot z\right)\right), x\right)\right)\right) \]
    15. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\left(y \cdot \left(z \cdot y\right)\right), x\right)\right)\right) \]
    16. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\mathsf{*.f64}\left(y, \left(z \cdot y\right)\right), x\right)\right)\right) \]
    17. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\mathsf{*.f64}\left(y, \left(y \cdot z\right)\right), x\right)\right)\right) \]
    18. *-lowering-*.f6450.3%

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{\_.f64}\left(x, \mathsf{/.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, z\right)\right), x\right)\right)\right) \]
  14. Simplified50.3%

    \[\leadsto 0.5 \cdot \color{blue}{\left(x - \frac{y \cdot \left(y \cdot z\right)}{x}\right)} \]
  15. Add Preprocessing

Alternative 8: 51.8% accurate, 36.3× speedup?

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

\\
x \cdot 0.5
\end{array}
Derivation
  1. Initial program 99.8%

    \[\frac{1}{2} \cdot \left(x + y \cdot \sqrt{z}\right) \]
  2. Step-by-step derivation
    1. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2}\right), \color{blue}{\left(x + y \cdot \sqrt{z}\right)}\right) \]
    2. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\color{blue}{x} + y \cdot \sqrt{z}\right)\right) \]
    3. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \color{blue}{\left(y \cdot \sqrt{z}\right)}\right)\right) \]
    4. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \color{blue}{\left(\sqrt{z}\right)}\right)\right)\right) \]
    5. sqrt-lowering-sqrt.f6499.8%

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(y, \mathsf{sqrt.f64}\left(z\right)\right)\right)\right) \]
  3. Simplified99.8%

    \[\leadsto \color{blue}{0.5 \cdot \left(x + y \cdot \sqrt{z}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around inf

    \[\leadsto \color{blue}{\frac{1}{2} \cdot x} \]
  6. Step-by-step derivation
    1. *-lowering-*.f6449.7%

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{x}\right) \]
  7. Simplified49.7%

    \[\leadsto \color{blue}{0.5 \cdot x} \]
  8. Final simplification49.7%

    \[\leadsto x \cdot 0.5 \]
  9. Add Preprocessing

Reproduce

?
herbie shell --seed 2024150 
(FPCore (x y z)
  :name "Diagrams.Solve.Polynomial:quadForm from diagrams-solve-0.1, B"
  :precision binary64
  (* (/ 1.0 2.0) (+ x (* y (sqrt z)))))