Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A

Percentage Accurate: 69.2% → 99.9%
Time: 10.0s
Alternatives: 13
Speedup: 1.2×

Specification

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

\\
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\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 13 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: 69.2% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 0.1× speedup?

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

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

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

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

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}\right), \color{blue}{2}\right) \]
  3. Simplified84.2%

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

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{x \cdot x - z \cdot z}{y} + y\right), 2\right) \]
    2. difference-of-squaresN/A

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

      \[\leadsto \mathsf{/.f64}\left(\left(\left(x + z\right) \cdot \frac{x - z}{y} + y\right), 2\right) \]
    4. fma-defineN/A

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

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

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{fma.f64}\left(\mathsf{+.f64}\left(x, z\right), \mathsf{/.f64}\left(\left(x - z\right), y\right), y\right), 2\right) \]
    8. --lowering--.f6499.9%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{fma.f64}\left(\mathsf{+.f64}\left(x, z\right), \mathsf{/.f64}\left(\mathsf{\_.f64}\left(x, z\right), y\right), y\right), 2\right) \]
  6. Applied egg-rr99.9%

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

Alternative 2: 85.4% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+73}:\\ \;\;\;\;\frac{\left(z + y\right) \cdot \frac{y - z}{y}}{2}\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+307}:\\ \;\;\;\;\left(x \cdot x - z \cdot z\right) \cdot \frac{0.5}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{y + \frac{x}{\frac{y}{x}}}{2}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= (* x x) 2e+73)
   (/ (* (+ z y) (/ (- y z) y)) 2.0)
   (if (<= (* x x) 2e+307)
     (* (- (* x x) (* z z)) (/ 0.5 y))
     (/ (+ y (/ x (/ y x))) 2.0))))
double code(double x, double y, double z) {
	double tmp;
	if ((x * x) <= 2e+73) {
		tmp = ((z + y) * ((y - z) / y)) / 2.0;
	} else if ((x * x) <= 2e+307) {
		tmp = ((x * x) - (z * z)) * (0.5 / y);
	} else {
		tmp = (y + (x / (y / x))) / 2.0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((x * x) <= 2d+73) then
        tmp = ((z + y) * ((y - z) / y)) / 2.0d0
    else if ((x * x) <= 2d+307) then
        tmp = ((x * x) - (z * z)) * (0.5d0 / y)
    else
        tmp = (y + (x / (y / x))) / 2.0d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((x * x) <= 2e+73) {
		tmp = ((z + y) * ((y - z) / y)) / 2.0;
	} else if ((x * x) <= 2e+307) {
		tmp = ((x * x) - (z * z)) * (0.5 / y);
	} else {
		tmp = (y + (x / (y / x))) / 2.0;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x * x) <= 2e+73:
		tmp = ((z + y) * ((y - z) / y)) / 2.0
	elif (x * x) <= 2e+307:
		tmp = ((x * x) - (z * z)) * (0.5 / y)
	else:
		tmp = (y + (x / (y / x))) / 2.0
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (Float64(x * x) <= 2e+73)
		tmp = Float64(Float64(Float64(z + y) * Float64(Float64(y - z) / y)) / 2.0);
	elseif (Float64(x * x) <= 2e+307)
		tmp = Float64(Float64(Float64(x * x) - Float64(z * z)) * Float64(0.5 / y));
	else
		tmp = Float64(Float64(y + Float64(x / Float64(y / x))) / 2.0);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x * x) <= 2e+73)
		tmp = ((z + y) * ((y - z) / y)) / 2.0;
	elseif ((x * x) <= 2e+307)
		tmp = ((x * x) - (z * z)) * (0.5 / y);
	else
		tmp = (y + (x / (y / x))) / 2.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e+73], N[(N[(N[(z + y), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 2e+307], N[(N[(N[(x * x), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] * N[(0.5 / y), $MachinePrecision]), $MachinePrecision], N[(N[(y + N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+73}:\\
\;\;\;\;\frac{\left(z + y\right) \cdot \frac{y - z}{y}}{2}\\

\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+307}:\\
\;\;\;\;\left(x \cdot x - z \cdot z\right) \cdot \frac{0.5}{y}\\

\mathbf{else}:\\
\;\;\;\;\frac{y + \frac{x}{\frac{y}{x}}}{2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x x) < 1.99999999999999997e73

    1. Initial program 66.8%

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

      \[\leadsto \mathsf{/.f64}\left(\color{blue}{\left({y}^{2} - {z}^{2}\right)}, \mathsf{*.f64}\left(y, 2\right)\right) \]
    4. Step-by-step derivation
      1. --lowering--.f64N/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(y, y\right), \left({z}^{2}\right)\right), \mathsf{*.f64}\left(y, 2\right)\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(y, y\right), \left(z \cdot z\right)\right), \mathsf{*.f64}\left(y, 2\right)\right) \]
      5. *-lowering-*.f6458.6%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(z, z\right)\right), \mathsf{*.f64}\left(y, 2\right)\right) \]
    5. Simplified58.6%

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{y \cdot y - z \cdot z}{y}\right), \color{blue}{2}\right) \]
      3. difference-of-squaresN/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(y + z\right), \left(\frac{y - z}{y}\right)\right), 2\right) \]
      6. +-commutativeN/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(z, y\right), \mathsf{/.f64}\left(\left(y - z\right), y\right)\right), 2\right) \]
      9. --lowering--.f6490.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(z, y\right), \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, z\right), y\right)\right), 2\right) \]
    7. Applied egg-rr90.9%

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

    if 1.99999999999999997e73 < (*.f64 x x) < 1.99999999999999997e307

    1. Initial program 90.6%

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}\right), \color{blue}{2}\right) \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{\frac{y + \frac{x \cdot x - z \cdot z}{y}}{2}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.99999999999999997e307 < (*.f64 x x)

    1. Initial program 66.8%

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}\right), \color{blue}{2}\right) \]
    3. Simplified66.8%

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{x \cdot x - z \cdot z}{y} + y\right), 2\right) \]
      2. difference-of-squaresN/A

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

        \[\leadsto \mathsf{/.f64}\left(\left(\left(x + z\right) \cdot \frac{x - z}{y} + y\right), 2\right) \]
      4. fma-defineN/A

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{fma.f64}\left(\mathsf{+.f64}\left(x, z\right), \mathsf{/.f64}\left(\left(x - z\right), y\right), y\right), 2\right) \]
      8. --lowering--.f6499.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{fma.f64}\left(\mathsf{+.f64}\left(x, z\right), \mathsf{/.f64}\left(\mathsf{\_.f64}\left(x, z\right), y\right), y\right), 2\right) \]
    6. Applied egg-rr99.9%

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\left(x + z\right) \cdot \frac{1}{\frac{y}{x - z}}\right), y\right), 2\right) \]
      3. un-div-invN/A

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(x, z\right), \mathsf{/.f64}\left(y, \left(x - z\right)\right)\right), y\right), 2\right) \]
      7. --lowering--.f64100.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(x, z\right), \mathsf{/.f64}\left(y, \mathsf{\_.f64}\left(x, z\right)\right)\right), y\right), 2\right) \]
    8. Applied egg-rr100.0%

      \[\leadsto \frac{\color{blue}{\frac{x + z}{\frac{y}{x - z}} + y}}{2} \]
    9. Taylor expanded in x around inf

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\color{blue}{\left(\frac{{x}^{2}}{y}\right)}, y\right), 2\right) \]
    10. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\left({x}^{2}\right), y\right), y\right), 2\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\left(x \cdot x\right), y\right), y\right), 2\right) \]
      3. *-lowering-*.f6478.5%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, x\right), y\right), y\right), 2\right) \]
    11. Simplified78.5%

      \[\leadsto \frac{\color{blue}{\frac{x \cdot x}{y}} + y}{2} \]
    12. Step-by-step derivation
      1. associate-*l/N/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\frac{x}{\frac{y}{x}}\right), y\right), 2\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(x, \left(\frac{y}{x}\right)\right), y\right), 2\right) \]
      5. /-lowering-/.f6494.2%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(x, \mathsf{/.f64}\left(y, x\right)\right), y\right), 2\right) \]
    13. Applied egg-rr94.2%

      \[\leadsto \frac{\color{blue}{\frac{x}{\frac{y}{x}} + y}}{2} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification91.2%

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

Alternative 3: 85.4% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+73}:\\ \;\;\;\;\frac{y - z \cdot \frac{z}{y}}{2}\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+307}:\\ \;\;\;\;\left(x \cdot x - z \cdot z\right) \cdot \frac{0.5}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{y + \frac{x}{\frac{y}{x}}}{2}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= (* x x) 2e+73)
   (/ (- y (* z (/ z y))) 2.0)
   (if (<= (* x x) 2e+307)
     (* (- (* x x) (* z z)) (/ 0.5 y))
     (/ (+ y (/ x (/ y x))) 2.0))))
double code(double x, double y, double z) {
	double tmp;
	if ((x * x) <= 2e+73) {
		tmp = (y - (z * (z / y))) / 2.0;
	} else if ((x * x) <= 2e+307) {
		tmp = ((x * x) - (z * z)) * (0.5 / y);
	} else {
		tmp = (y + (x / (y / x))) / 2.0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((x * x) <= 2d+73) then
        tmp = (y - (z * (z / y))) / 2.0d0
    else if ((x * x) <= 2d+307) then
        tmp = ((x * x) - (z * z)) * (0.5d0 / y)
    else
        tmp = (y + (x / (y / x))) / 2.0d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((x * x) <= 2e+73) {
		tmp = (y - (z * (z / y))) / 2.0;
	} else if ((x * x) <= 2e+307) {
		tmp = ((x * x) - (z * z)) * (0.5 / y);
	} else {
		tmp = (y + (x / (y / x))) / 2.0;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x * x) <= 2e+73:
		tmp = (y - (z * (z / y))) / 2.0
	elif (x * x) <= 2e+307:
		tmp = ((x * x) - (z * z)) * (0.5 / y)
	else:
		tmp = (y + (x / (y / x))) / 2.0
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (Float64(x * x) <= 2e+73)
		tmp = Float64(Float64(y - Float64(z * Float64(z / y))) / 2.0);
	elseif (Float64(x * x) <= 2e+307)
		tmp = Float64(Float64(Float64(x * x) - Float64(z * z)) * Float64(0.5 / y));
	else
		tmp = Float64(Float64(y + Float64(x / Float64(y / x))) / 2.0);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x * x) <= 2e+73)
		tmp = (y - (z * (z / y))) / 2.0;
	elseif ((x * x) <= 2e+307)
		tmp = ((x * x) - (z * z)) * (0.5 / y);
	else
		tmp = (y + (x / (y / x))) / 2.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e+73], N[(N[(y - N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 2e+307], N[(N[(N[(x * x), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] * N[(0.5 / y), $MachinePrecision]), $MachinePrecision], N[(N[(y + N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+73}:\\
\;\;\;\;\frac{y - z \cdot \frac{z}{y}}{2}\\

\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+307}:\\
\;\;\;\;\left(x \cdot x - z \cdot z\right) \cdot \frac{0.5}{y}\\

\mathbf{else}:\\
\;\;\;\;\frac{y + \frac{x}{\frac{y}{x}}}{2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x x) < 1.99999999999999997e73

    1. Initial program 66.8%

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}\right), \color{blue}{2}\right) \]
    3. Simplified88.2%

      \[\leadsto \color{blue}{\frac{y + \frac{x \cdot x - z \cdot z}{y}}{2}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, \mathsf{/.f64}\left(\left({z}^{2}\right), y\right)\right), 2\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, \mathsf{/.f64}\left(\left(z \cdot z\right), y\right)\right), 2\right) \]
      4. *-lowering-*.f6480.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, \mathsf{/.f64}\left(\mathsf{*.f64}\left(z, z\right), y\right)\right), 2\right) \]
    7. Simplified80.1%

      \[\leadsto \frac{\color{blue}{y - \frac{z \cdot z}{y}}}{2} \]
    8. Step-by-step derivation
      1. associate-/l*N/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, \mathsf{*.f64}\left(\left(\frac{z}{y}\right), z\right)\right), 2\right) \]
      4. /-lowering-/.f6490.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, \mathsf{*.f64}\left(\mathsf{/.f64}\left(z, y\right), z\right)\right), 2\right) \]
    9. Applied egg-rr90.9%

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

    if 1.99999999999999997e73 < (*.f64 x x) < 1.99999999999999997e307

    1. Initial program 90.6%

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}\right), \color{blue}{2}\right) \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{\frac{y + \frac{x \cdot x - z \cdot z}{y}}{2}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.99999999999999997e307 < (*.f64 x x)

    1. Initial program 66.8%

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}\right), \color{blue}{2}\right) \]
    3. Simplified66.8%

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{x \cdot x - z \cdot z}{y} + y\right), 2\right) \]
      2. difference-of-squaresN/A

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

        \[\leadsto \mathsf{/.f64}\left(\left(\left(x + z\right) \cdot \frac{x - z}{y} + y\right), 2\right) \]
      4. fma-defineN/A

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{fma.f64}\left(\mathsf{+.f64}\left(x, z\right), \mathsf{/.f64}\left(\left(x - z\right), y\right), y\right), 2\right) \]
      8. --lowering--.f6499.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{fma.f64}\left(\mathsf{+.f64}\left(x, z\right), \mathsf{/.f64}\left(\mathsf{\_.f64}\left(x, z\right), y\right), y\right), 2\right) \]
    6. Applied egg-rr99.9%

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\left(x + z\right) \cdot \frac{1}{\frac{y}{x - z}}\right), y\right), 2\right) \]
      3. un-div-invN/A

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(x, z\right), \mathsf{/.f64}\left(y, \left(x - z\right)\right)\right), y\right), 2\right) \]
      7. --lowering--.f64100.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(x, z\right), \mathsf{/.f64}\left(y, \mathsf{\_.f64}\left(x, z\right)\right)\right), y\right), 2\right) \]
    8. Applied egg-rr100.0%

      \[\leadsto \frac{\color{blue}{\frac{x + z}{\frac{y}{x - z}} + y}}{2} \]
    9. Taylor expanded in x around inf

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\color{blue}{\left(\frac{{x}^{2}}{y}\right)}, y\right), 2\right) \]
    10. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\left({x}^{2}\right), y\right), y\right), 2\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\left(x \cdot x\right), y\right), y\right), 2\right) \]
      3. *-lowering-*.f6478.5%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, x\right), y\right), y\right), 2\right) \]
    11. Simplified78.5%

      \[\leadsto \frac{\color{blue}{\frac{x \cdot x}{y}} + y}{2} \]
    12. Step-by-step derivation
      1. associate-*l/N/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\frac{x}{\frac{y}{x}}\right), y\right), 2\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(x, \left(\frac{y}{x}\right)\right), y\right), 2\right) \]
      5. /-lowering-/.f6494.2%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(x, \mathsf{/.f64}\left(y, x\right)\right), y\right), 2\right) \]
    13. Applied egg-rr94.2%

      \[\leadsto \frac{\color{blue}{\frac{x}{\frac{y}{x}} + y}}{2} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification91.2%

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

Alternative 4: 86.4% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+73}:\\ \;\;\;\;\frac{\left(z + y\right) \cdot \frac{y - z}{y}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x - z\right) \cdot \frac{x + z}{y}}{2}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= (* x x) 2e+73)
   (/ (* (+ z y) (/ (- y z) y)) 2.0)
   (/ (* (- x z) (/ (+ x z) y)) 2.0)))
double code(double x, double y, double z) {
	double tmp;
	if ((x * x) <= 2e+73) {
		tmp = ((z + y) * ((y - z) / y)) / 2.0;
	} else {
		tmp = ((x - z) * ((x + z) / y)) / 2.0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((x * x) <= 2d+73) then
        tmp = ((z + y) * ((y - z) / y)) / 2.0d0
    else
        tmp = ((x - z) * ((x + z) / y)) / 2.0d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((x * x) <= 2e+73) {
		tmp = ((z + y) * ((y - z) / y)) / 2.0;
	} else {
		tmp = ((x - z) * ((x + z) / y)) / 2.0;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x * x) <= 2e+73:
		tmp = ((z + y) * ((y - z) / y)) / 2.0
	else:
		tmp = ((x - z) * ((x + z) / y)) / 2.0
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (Float64(x * x) <= 2e+73)
		tmp = Float64(Float64(Float64(z + y) * Float64(Float64(y - z) / y)) / 2.0);
	else
		tmp = Float64(Float64(Float64(x - z) * Float64(Float64(x + z) / y)) / 2.0);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x * x) <= 2e+73)
		tmp = ((z + y) * ((y - z) / y)) / 2.0;
	else
		tmp = ((x - z) * ((x + z) / y)) / 2.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e+73], N[(N[(N[(z + y), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(x - z), $MachinePrecision] * N[(N[(x + z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+73}:\\
\;\;\;\;\frac{\left(z + y\right) \cdot \frac{y - z}{y}}{2}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x x) < 1.99999999999999997e73

    1. Initial program 66.8%

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

      \[\leadsto \mathsf{/.f64}\left(\color{blue}{\left({y}^{2} - {z}^{2}\right)}, \mathsf{*.f64}\left(y, 2\right)\right) \]
    4. Step-by-step derivation
      1. --lowering--.f64N/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(y, y\right), \left({z}^{2}\right)\right), \mathsf{*.f64}\left(y, 2\right)\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(y, y\right), \left(z \cdot z\right)\right), \mathsf{*.f64}\left(y, 2\right)\right) \]
      5. *-lowering-*.f6458.6%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(y, y\right), \mathsf{*.f64}\left(z, z\right)\right), \mathsf{*.f64}\left(y, 2\right)\right) \]
    5. Simplified58.6%

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{y \cdot y - z \cdot z}{y}\right), \color{blue}{2}\right) \]
      3. difference-of-squaresN/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(y + z\right), \left(\frac{y - z}{y}\right)\right), 2\right) \]
      6. +-commutativeN/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(z, y\right), \mathsf{/.f64}\left(\left(y - z\right), y\right)\right), 2\right) \]
      9. --lowering--.f6490.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(z, y\right), \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, z\right), y\right)\right), 2\right) \]
    7. Applied egg-rr90.9%

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

    if 1.99999999999999997e73 < (*.f64 x x)

    1. Initial program 75.5%

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}\right), \color{blue}{2}\right) \]
    3. Simplified78.8%

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{x \cdot x - z \cdot z}{y} + y\right), 2\right) \]
      2. difference-of-squaresN/A

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

        \[\leadsto \mathsf{/.f64}\left(\left(\left(x + z\right) \cdot \frac{x - z}{y} + y\right), 2\right) \]
      4. fma-defineN/A

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{fma.f64}\left(\mathsf{+.f64}\left(x, z\right), \mathsf{/.f64}\left(\left(x - z\right), y\right), y\right), 2\right) \]
      8. --lowering--.f6499.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{fma.f64}\left(\mathsf{+.f64}\left(x, z\right), \mathsf{/.f64}\left(\mathsf{\_.f64}\left(x, z\right), y\right), y\right), 2\right) \]
    6. Applied egg-rr99.9%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, z\right), \mathsf{/.f64}\left(\left(z + x\right), y\right)\right), 2\right) \]
      7. +-lowering-+.f6494.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, z\right), \mathsf{/.f64}\left(\mathsf{+.f64}\left(z, x\right), y\right)\right), 2\right) \]
    9. Simplified94.0%

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

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

Alternative 5: 85.6% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot x \leq 10^{+153}:\\ \;\;\;\;\frac{y - z \cdot \frac{z}{y}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{y + \frac{x}{\frac{y}{x}}}{2}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= (* x x) 1e+153)
   (/ (- y (* z (/ z y))) 2.0)
   (/ (+ y (/ x (/ y x))) 2.0)))
double code(double x, double y, double z) {
	double tmp;
	if ((x * x) <= 1e+153) {
		tmp = (y - (z * (z / y))) / 2.0;
	} else {
		tmp = (y + (x / (y / x))) / 2.0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((x * x) <= 1d+153) then
        tmp = (y - (z * (z / y))) / 2.0d0
    else
        tmp = (y + (x / (y / x))) / 2.0d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((x * x) <= 1e+153) {
		tmp = (y - (z * (z / y))) / 2.0;
	} else {
		tmp = (y + (x / (y / x))) / 2.0;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x * x) <= 1e+153:
		tmp = (y - (z * (z / y))) / 2.0
	else:
		tmp = (y + (x / (y / x))) / 2.0
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (Float64(x * x) <= 1e+153)
		tmp = Float64(Float64(y - Float64(z * Float64(z / y))) / 2.0);
	else
		tmp = Float64(Float64(y + Float64(x / Float64(y / x))) / 2.0);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x * x) <= 1e+153)
		tmp = (y - (z * (z / y))) / 2.0;
	else
		tmp = (y + (x / (y / x))) / 2.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 1e+153], N[(N[(y - N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(y + N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 10^{+153}:\\
\;\;\;\;\frac{y - z \cdot \frac{z}{y}}{2}\\

\mathbf{else}:\\
\;\;\;\;\frac{y + \frac{x}{\frac{y}{x}}}{2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x x) < 1e153

    1. Initial program 69.2%

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}\right), \color{blue}{2}\right) \]
    3. Simplified89.3%

      \[\leadsto \color{blue}{\frac{y + \frac{x \cdot x - z \cdot z}{y}}{2}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, \mathsf{/.f64}\left(\left({z}^{2}\right), y\right)\right), 2\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, \mathsf{/.f64}\left(\left(z \cdot z\right), y\right)\right), 2\right) \]
      4. *-lowering-*.f6478.3%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, \mathsf{/.f64}\left(\mathsf{*.f64}\left(z, z\right), y\right)\right), 2\right) \]
    7. Simplified78.3%

      \[\leadsto \frac{\color{blue}{y - \frac{z \cdot z}{y}}}{2} \]
    8. Step-by-step derivation
      1. associate-/l*N/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, \mathsf{*.f64}\left(\left(\frac{z}{y}\right), z\right)\right), 2\right) \]
      4. /-lowering-/.f6488.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, \mathsf{*.f64}\left(\mathsf{/.f64}\left(z, y\right), z\right)\right), 2\right) \]
    9. Applied egg-rr88.1%

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

    if 1e153 < (*.f64 x x)

    1. Initial program 72.7%

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}\right), \color{blue}{2}\right) \]
    3. Simplified75.5%

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{x \cdot x - z \cdot z}{y} + y\right), 2\right) \]
      2. difference-of-squaresN/A

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

        \[\leadsto \mathsf{/.f64}\left(\left(\left(x + z\right) \cdot \frac{x - z}{y} + y\right), 2\right) \]
      4. fma-defineN/A

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{fma.f64}\left(\mathsf{+.f64}\left(x, z\right), \mathsf{/.f64}\left(\left(x - z\right), y\right), y\right), 2\right) \]
      8. --lowering--.f6499.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{fma.f64}\left(\mathsf{+.f64}\left(x, z\right), \mathsf{/.f64}\left(\mathsf{\_.f64}\left(x, z\right), y\right), y\right), 2\right) \]
    6. Applied egg-rr99.9%

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\left(x + z\right) \cdot \frac{1}{\frac{y}{x - z}}\right), y\right), 2\right) \]
      3. un-div-invN/A

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(x, z\right), \mathsf{/.f64}\left(y, \left(x - z\right)\right)\right), y\right), 2\right) \]
      7. --lowering--.f6499.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(x, z\right), \mathsf{/.f64}\left(y, \mathsf{\_.f64}\left(x, z\right)\right)\right), y\right), 2\right) \]
    8. Applied egg-rr99.9%

      \[\leadsto \frac{\color{blue}{\frac{x + z}{\frac{y}{x - z}} + y}}{2} \]
    9. Taylor expanded in x around inf

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\color{blue}{\left(\frac{{x}^{2}}{y}\right)}, y\right), 2\right) \]
    10. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\left({x}^{2}\right), y\right), y\right), 2\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\left(x \cdot x\right), y\right), y\right), 2\right) \]
      3. *-lowering-*.f6477.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, x\right), y\right), y\right), 2\right) \]
    11. Simplified77.8%

      \[\leadsto \frac{\color{blue}{\frac{x \cdot x}{y}} + y}{2} \]
    12. Step-by-step derivation
      1. associate-*l/N/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\frac{x}{\frac{y}{x}}\right), y\right), 2\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(x, \left(\frac{y}{x}\right)\right), y\right), 2\right) \]
      5. /-lowering-/.f6489.4%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(x, \mathsf{/.f64}\left(y, x\right)\right), y\right), 2\right) \]
    13. Applied egg-rr89.4%

      \[\leadsto \frac{\color{blue}{\frac{x}{\frac{y}{x}} + y}}{2} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification88.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \leq 10^{+153}:\\ \;\;\;\;\frac{y - z \cdot \frac{z}{y}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{y + \frac{x}{\frac{y}{x}}}{2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 73.7% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.75 \cdot 10^{+113}:\\
\;\;\;\;\frac{y + \frac{x}{\frac{y}{x}}}{2}\\

\mathbf{else}:\\
\;\;\;\;\frac{z}{\frac{y}{z}} \cdot -0.5\\


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

    1. Initial program 73.0%

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}\right), \color{blue}{2}\right) \]
    3. Simplified87.4%

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{x \cdot x - z \cdot z}{y} + y\right), 2\right) \]
      2. difference-of-squaresN/A

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

        \[\leadsto \mathsf{/.f64}\left(\left(\left(x + z\right) \cdot \frac{x - z}{y} + y\right), 2\right) \]
      4. fma-defineN/A

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{fma.f64}\left(\mathsf{+.f64}\left(x, z\right), \mathsf{/.f64}\left(\left(x - z\right), y\right), y\right), 2\right) \]
      8. --lowering--.f6499.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{fma.f64}\left(\mathsf{+.f64}\left(x, z\right), \mathsf{/.f64}\left(\mathsf{\_.f64}\left(x, z\right), y\right), y\right), 2\right) \]
    6. Applied egg-rr99.9%

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\left(x + z\right) \cdot \frac{1}{\frac{y}{x - z}}\right), y\right), 2\right) \]
      3. un-div-invN/A

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(x, z\right), \mathsf{/.f64}\left(y, \left(x - z\right)\right)\right), y\right), 2\right) \]
      7. --lowering--.f6499.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(x, z\right), \mathsf{/.f64}\left(y, \mathsf{\_.f64}\left(x, z\right)\right)\right), y\right), 2\right) \]
    8. Applied egg-rr99.9%

      \[\leadsto \frac{\color{blue}{\frac{x + z}{\frac{y}{x - z}} + y}}{2} \]
    9. Taylor expanded in x around inf

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\color{blue}{\left(\frac{{x}^{2}}{y}\right)}, y\right), 2\right) \]
    10. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\left({x}^{2}\right), y\right), y\right), 2\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\left(x \cdot x\right), y\right), y\right), 2\right) \]
      3. *-lowering-*.f6469.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, x\right), y\right), y\right), 2\right) \]
    11. Simplified69.1%

      \[\leadsto \frac{\color{blue}{\frac{x \cdot x}{y}} + y}{2} \]
    12. Step-by-step derivation
      1. associate-*l/N/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\frac{x}{\frac{y}{x}}\right), y\right), 2\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(x, \left(\frac{y}{x}\right)\right), y\right), 2\right) \]
      5. /-lowering-/.f6473.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(x, \mathsf{/.f64}\left(y, x\right)\right), y\right), 2\right) \]
    13. Applied egg-rr73.9%

      \[\leadsto \frac{\color{blue}{\frac{x}{\frac{y}{x}} + y}}{2} \]

    if 1.75e113 < z

    1. Initial program 50.6%

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}\right), \color{blue}{2}\right) \]
    3. Simplified58.0%

      \[\leadsto \color{blue}{\frac{y + \frac{x \cdot x - z \cdot z}{y}}{2}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf

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

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

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

        \[\leadsto \left(z \cdot \frac{z}{y}\right) \cdot \frac{-1}{2} \]
      4. associate-*l*N/A

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

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

        \[\leadsto \mathsf{*.f64}\left(z, \mathsf{*.f64}\left(\left(\frac{z}{y}\right), \color{blue}{\frac{-1}{2}}\right)\right) \]
      7. /-lowering-/.f6463.4%

        \[\leadsto \mathsf{*.f64}\left(z, \mathsf{*.f64}\left(\mathsf{/.f64}\left(z, y\right), \frac{-1}{2}\right)\right) \]
    7. Simplified63.4%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 1.75 \cdot 10^{+113}:\\ \;\;\;\;\frac{y + \frac{x}{\frac{y}{x}}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{\frac{y}{z}} \cdot -0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 68.8% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq 2.55 \cdot 10^{+113}:\\
\;\;\;\;\frac{y + \frac{x \cdot x}{y}}{2}\\

\mathbf{else}:\\
\;\;\;\;\frac{z}{\frac{y}{z}} \cdot -0.5\\


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

    1. Initial program 73.0%

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}\right), \color{blue}{2}\right) \]
    3. Simplified87.4%

      \[\leadsto \color{blue}{\frac{y + \frac{x \cdot x - z \cdot z}{y}}{2}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(y, \left(\frac{{x}^{2}}{y}\right)\right), 2\right) \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(y, \mathsf{/.f64}\left(\left({x}^{2}\right), y\right)\right), 2\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(y, \mathsf{/.f64}\left(\left(x \cdot x\right), y\right)\right), 2\right) \]
      4. *-lowering-*.f6469.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(y, \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, x\right), y\right)\right), 2\right) \]
    7. Simplified69.1%

      \[\leadsto \frac{\color{blue}{y + \frac{x \cdot x}{y}}}{2} \]

    if 2.54999999999999997e113 < z

    1. Initial program 50.6%

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}\right), \color{blue}{2}\right) \]
    3. Simplified58.0%

      \[\leadsto \color{blue}{\frac{y + \frac{x \cdot x - z \cdot z}{y}}{2}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf

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

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

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

        \[\leadsto \left(z \cdot \frac{z}{y}\right) \cdot \frac{-1}{2} \]
      4. associate-*l*N/A

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

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

        \[\leadsto \mathsf{*.f64}\left(z, \mathsf{*.f64}\left(\left(\frac{z}{y}\right), \color{blue}{\frac{-1}{2}}\right)\right) \]
      7. /-lowering-/.f6463.4%

        \[\leadsto \mathsf{*.f64}\left(z, \mathsf{*.f64}\left(\mathsf{/.f64}\left(z, y\right), \frac{-1}{2}\right)\right) \]
    7. Simplified63.4%

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

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

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

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

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

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

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

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

Alternative 8: 99.9% accurate, 1.2× speedup?

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

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

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

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

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}\right), \color{blue}{2}\right) \]
  3. Simplified84.2%

    \[\leadsto \color{blue}{\frac{y + \frac{x \cdot x - z \cdot z}{y}}{2}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. difference-of-squaresN/A

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

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

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

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(y, \mathsf{*.f64}\left(\mathsf{+.f64}\left(x, z\right), \mathsf{/.f64}\left(\left(x - z\right), y\right)\right)\right), 2\right) \]
    6. --lowering--.f6499.9%

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

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

Alternative 9: 43.4% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 9.5 \cdot 10^{+37}:\\ \;\;\;\;\frac{y}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{\frac{y}{x}}}{2}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x 9.5e+37) (/ y 2.0) (/ (/ x (/ y x)) 2.0)))
double code(double x, double y, double z) {
	double tmp;
	if (x <= 9.5e+37) {
		tmp = y / 2.0;
	} else {
		tmp = (x / (y / x)) / 2.0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= 9.5d+37) then
        tmp = y / 2.0d0
    else
        tmp = (x / (y / x)) / 2.0d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= 9.5e+37) {
		tmp = y / 2.0;
	} else {
		tmp = (x / (y / x)) / 2.0;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= 9.5e+37:
		tmp = y / 2.0
	else:
		tmp = (x / (y / x)) / 2.0
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= 9.5e+37)
		tmp = Float64(y / 2.0);
	else
		tmp = Float64(Float64(x / Float64(y / x)) / 2.0);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= 9.5e+37)
		tmp = y / 2.0;
	else
		tmp = (x / (y / x)) / 2.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, 9.5e+37], N[(y / 2.0), $MachinePrecision], N[(N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 9.5 \cdot 10^{+37}:\\
\;\;\;\;\frac{y}{2}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{\frac{y}{x}}}{2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 9.4999999999999995e37

    1. Initial program 68.4%

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}\right), \color{blue}{2}\right) \]
    3. Simplified85.0%

      \[\leadsto \color{blue}{\frac{y + \frac{x \cdot x - z \cdot z}{y}}{2}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf

      \[\leadsto \mathsf{/.f64}\left(\color{blue}{y}, 2\right) \]
    6. Step-by-step derivation
      1. Simplified38.8%

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

      if 9.4999999999999995e37 < x

      1. Initial program 79.1%

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

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

          \[\leadsto \mathsf{/.f64}\left(\left(\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}\right), \color{blue}{2}\right) \]
      3. Simplified80.9%

        \[\leadsto \color{blue}{\frac{y + \frac{x \cdot x - z \cdot z}{y}}{2}} \]
      4. Add Preprocessing
      5. Taylor expanded in x around inf

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

          \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left({x}^{2}\right), y\right), 2\right) \]
        2. unpow2N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(x \cdot x\right), y\right), 2\right) \]
        3. *-lowering-*.f6465.0%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, x\right), y\right), 2\right) \]
      7. Simplified65.0%

        \[\leadsto \frac{\color{blue}{\frac{x \cdot x}{y}}}{2} \]
      8. Step-by-step derivation
        1. associate-/l*N/A

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

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

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(\frac{x}{y}\right), x\right), 2\right) \]
        4. /-lowering-/.f6471.4%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(x, y\right), x\right), 2\right) \]
      9. Applied egg-rr71.4%

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

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

          \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{1}{\frac{y}{x}}\right), 2\right) \]
        3. un-div-invN/A

          \[\leadsto \mathsf{/.f64}\left(\left(\frac{x}{\frac{y}{x}}\right), 2\right) \]
        4. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(x, \left(\frac{y}{x}\right)\right), 2\right) \]
        5. /-lowering-/.f6471.4%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(x, \mathsf{/.f64}\left(y, x\right)\right), 2\right) \]
      11. Applied egg-rr71.4%

        \[\leadsto \frac{\color{blue}{\frac{x}{\frac{y}{x}}}}{2} \]
    7. Recombined 2 regimes into one program.
    8. Add Preprocessing

    Alternative 10: 43.3% accurate, 1.2× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1.4 \cdot 10^{+38}:\\ \;\;\;\;\frac{y}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{2}{\frac{x}{y}}}\\ \end{array} \end{array} \]
    (FPCore (x y z)
     :precision binary64
     (if (<= x 1.4e+38) (/ y 2.0) (/ x (/ 2.0 (/ x y)))))
    double code(double x, double y, double z) {
    	double tmp;
    	if (x <= 1.4e+38) {
    		tmp = y / 2.0;
    	} else {
    		tmp = x / (2.0 / (x / y));
    	}
    	return tmp;
    }
    
    real(8) function code(x, y, z)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        real(8), intent (in) :: z
        real(8) :: tmp
        if (x <= 1.4d+38) then
            tmp = y / 2.0d0
        else
            tmp = x / (2.0d0 / (x / y))
        end if
        code = tmp
    end function
    
    public static double code(double x, double y, double z) {
    	double tmp;
    	if (x <= 1.4e+38) {
    		tmp = y / 2.0;
    	} else {
    		tmp = x / (2.0 / (x / y));
    	}
    	return tmp;
    }
    
    def code(x, y, z):
    	tmp = 0
    	if x <= 1.4e+38:
    		tmp = y / 2.0
    	else:
    		tmp = x / (2.0 / (x / y))
    	return tmp
    
    function code(x, y, z)
    	tmp = 0.0
    	if (x <= 1.4e+38)
    		tmp = Float64(y / 2.0);
    	else
    		tmp = Float64(x / Float64(2.0 / Float64(x / y)));
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y, z)
    	tmp = 0.0;
    	if (x <= 1.4e+38)
    		tmp = y / 2.0;
    	else
    		tmp = x / (2.0 / (x / y));
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_, z_] := If[LessEqual[x, 1.4e+38], N[(y / 2.0), $MachinePrecision], N[(x / N[(2.0 / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;x \leq 1.4 \cdot 10^{+38}:\\
    \;\;\;\;\frac{y}{2}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{x}{\frac{2}{\frac{x}{y}}}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < 1.4e38

      1. Initial program 68.4%

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

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

          \[\leadsto \mathsf{/.f64}\left(\left(\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}\right), \color{blue}{2}\right) \]
      3. Simplified85.0%

        \[\leadsto \color{blue}{\frac{y + \frac{x \cdot x - z \cdot z}{y}}{2}} \]
      4. Add Preprocessing
      5. Taylor expanded in y around inf

        \[\leadsto \mathsf{/.f64}\left(\color{blue}{y}, 2\right) \]
      6. Step-by-step derivation
        1. Simplified38.8%

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

        if 1.4e38 < x

        1. Initial program 79.1%

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

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

            \[\leadsto \mathsf{/.f64}\left(\left(\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}\right), \color{blue}{2}\right) \]
        3. Simplified80.9%

          \[\leadsto \color{blue}{\frac{y + \frac{x \cdot x - z \cdot z}{y}}{2}} \]
        4. Add Preprocessing
        5. Taylor expanded in x around inf

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

            \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left({x}^{2}\right), y\right), 2\right) \]
          2. unpow2N/A

            \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(x \cdot x\right), y\right), 2\right) \]
          3. *-lowering-*.f6465.0%

            \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, x\right), y\right), 2\right) \]
        7. Simplified65.0%

          \[\leadsto \frac{\color{blue}{\frac{x \cdot x}{y}}}{2} \]
        8. Step-by-step derivation
          1. associate-/l*N/A

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

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

            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(\frac{x}{y}\right), x\right), 2\right) \]
          4. /-lowering-/.f6471.4%

            \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(x, y\right), x\right), 2\right) \]
        9. Applied egg-rr71.4%

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

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

            \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{1}{\frac{y}{x}}\right), 2\right) \]
          3. un-div-invN/A

            \[\leadsto \mathsf{/.f64}\left(\left(\frac{x}{\frac{y}{x}}\right), 2\right) \]
          4. /-lowering-/.f64N/A

            \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(x, \left(\frac{y}{x}\right)\right), 2\right) \]
          5. /-lowering-/.f6471.4%

            \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(x, \mathsf{/.f64}\left(y, x\right)\right), 2\right) \]
        11. Applied egg-rr71.4%

          \[\leadsto \frac{\color{blue}{\frac{x}{\frac{y}{x}}}}{2} \]
        12. Step-by-step derivation
          1. associate-/l/N/A

            \[\leadsto \frac{x}{\color{blue}{2 \cdot \frac{y}{x}}} \]
          2. /-lowering-/.f64N/A

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

            \[\leadsto \mathsf{/.f64}\left(x, \left(2 \cdot \frac{1}{\color{blue}{\frac{x}{y}}}\right)\right) \]
          4. un-div-invN/A

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

            \[\leadsto \mathsf{/.f64}\left(x, \mathsf{/.f64}\left(2, \color{blue}{\left(\frac{x}{y}\right)}\right)\right) \]
          6. /-lowering-/.f6471.4%

            \[\leadsto \mathsf{/.f64}\left(x, \mathsf{/.f64}\left(2, \mathsf{/.f64}\left(x, \color{blue}{y}\right)\right)\right) \]
        13. Applied egg-rr71.4%

          \[\leadsto \color{blue}{\frac{x}{\frac{2}{\frac{x}{y}}}} \]
      7. Recombined 2 regimes into one program.
      8. Add Preprocessing

      Alternative 11: 42.3% accurate, 1.2× speedup?

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

        1. Initial program 68.4%

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

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

            \[\leadsto \mathsf{/.f64}\left(\left(\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}\right), \color{blue}{2}\right) \]
        3. Simplified85.0%

          \[\leadsto \color{blue}{\frac{y + \frac{x \cdot x - z \cdot z}{y}}{2}} \]
        4. Add Preprocessing
        5. Taylor expanded in y around inf

          \[\leadsto \mathsf{/.f64}\left(\color{blue}{y}, 2\right) \]
        6. Step-by-step derivation
          1. Simplified38.8%

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

          if 8.8000000000000006e39 < x

          1. Initial program 79.1%

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

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

              \[\leadsto \mathsf{/.f64}\left(\left(\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}\right), \color{blue}{2}\right) \]
          3. Simplified80.9%

            \[\leadsto \color{blue}{\frac{y + \frac{x \cdot x - z \cdot z}{y}}{2}} \]
          4. Add Preprocessing
          5. Taylor expanded in x around inf

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

              \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left({x}^{2}\right), y\right), 2\right) \]
            2. unpow2N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(x \cdot x\right), y\right), 2\right) \]
            3. *-lowering-*.f6465.0%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, x\right), y\right), 2\right) \]
          7. Simplified65.0%

            \[\leadsto \frac{\color{blue}{\frac{x \cdot x}{y}}}{2} \]
          8. Step-by-step derivation
            1. associate-/r*N/A

              \[\leadsto \frac{x \cdot x}{\color{blue}{y \cdot 2}} \]
            2. div-invN/A

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

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{/.f64}\left(\left(\frac{1}{2}\right), \color{blue}{y}\right)\right) \]
            8. metadata-eval65.0%

              \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{/.f64}\left(\frac{1}{2}, y\right)\right) \]
          9. Applied egg-rr65.0%

            \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot \frac{0.5}{y}} \]
        7. Recombined 2 regimes into one program.
        8. Add Preprocessing

        Alternative 12: 44.1% accurate, 1.2× speedup?

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

          1. Initial program 72.5%

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

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

              \[\leadsto \mathsf{/.f64}\left(\left(\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}\right), \color{blue}{2}\right) \]
          3. Simplified87.0%

            \[\leadsto \color{blue}{\frac{y + \frac{x \cdot x - z \cdot z}{y}}{2}} \]
          4. Add Preprocessing
          5. Taylor expanded in y around inf

            \[\leadsto \mathsf{/.f64}\left(\color{blue}{y}, 2\right) \]
          6. Step-by-step derivation
            1. Simplified34.7%

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

            if 1.1000000000000001e82 < z

            1. Initial program 57.9%

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

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

                \[\leadsto \mathsf{/.f64}\left(\left(\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}\right), \color{blue}{2}\right) \]
            3. Simplified66.4%

              \[\leadsto \color{blue}{\frac{y + \frac{x \cdot x - z \cdot z}{y}}{2}} \]
            4. Add Preprocessing
            5. Taylor expanded in z around inf

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

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

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

                \[\leadsto \left(z \cdot \frac{z}{y}\right) \cdot \frac{-1}{2} \]
              4. associate-*l*N/A

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

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

                \[\leadsto \mathsf{*.f64}\left(z, \mathsf{*.f64}\left(\left(\frac{z}{y}\right), \color{blue}{\frac{-1}{2}}\right)\right) \]
              7. /-lowering-/.f6456.4%

                \[\leadsto \mathsf{*.f64}\left(z, \mathsf{*.f64}\left(\mathsf{/.f64}\left(z, y\right), \frac{-1}{2}\right)\right) \]
            7. Simplified56.4%

              \[\leadsto \color{blue}{z \cdot \left(\frac{z}{y} \cdot -0.5\right)} \]
          7. Recombined 2 regimes into one program.
          8. Add Preprocessing

          Alternative 13: 34.0% accurate, 5.0× speedup?

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

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

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

              \[\leadsto \mathsf{/.f64}\left(\left(\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}\right), \color{blue}{2}\right) \]
          3. Simplified84.2%

            \[\leadsto \color{blue}{\frac{y + \frac{x \cdot x - z \cdot z}{y}}{2}} \]
          4. Add Preprocessing
          5. Taylor expanded in y around inf

            \[\leadsto \mathsf{/.f64}\left(\color{blue}{y}, 2\right) \]
          6. Step-by-step derivation
            1. Simplified32.4%

              \[\leadsto \frac{\color{blue}{y}}{2} \]
            2. Add Preprocessing

            Developer Target 1: 99.9% accurate, 1.0× speedup?

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

            Reproduce

            ?
            herbie shell --seed 2024138 
            (FPCore (x y z)
              :name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
              :precision binary64
            
              :alt
              (! :herbie-platform default (- (* y 1/2) (* (* (/ 1/2 y) (+ z x)) (- z x))))
            
              (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))