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

Percentage Accurate: 68.7% → 84.1%
Time: 10.3s
Alternatives: 10
Speedup: 0.7×

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 10 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: 68.7% 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: 84.1% accurate, 0.0× speedup?

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

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

\mathbf{elif}\;z \cdot z \leq 10^{+304}:\\
\;\;\;\;0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, \frac{-1}{y}\right)\right)\right)\\

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


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

    1. Initial program 79.2%

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

    if 2e-136 < (*.f64 z z) < 9.9999999999999994e303

    1. Initial program 75.0%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg75.0%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out75.0%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{-\color{blue}{\left(-y\right) \cdot 2}} \]
      3. distribute-frac-neg275.0%

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg75.0%

        \[\leadsto \color{blue}{\frac{-\left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\left(-y\right) \cdot 2}} \]
      5. neg-mul-175.0%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}}{\left(-y\right) \cdot 2} \]
      6. distribute-lft-neg-out75.0%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative75.0%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in75.0%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\left(-2\right) \cdot y}} \]
      9. times-frac75.0%

        \[\leadsto \color{blue}{\frac{-1}{-2} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}} \]
      10. metadata-eval75.0%

        \[\leadsto \frac{-1}{\color{blue}{-2}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      11. metadata-eval75.0%

        \[\leadsto \color{blue}{0.5} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      12. associate--l+75.0%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define75.0%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified75.0%

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

      \[\leadsto 0.5 \cdot \color{blue}{\left({z}^{2} \cdot \left(\left(\frac{y}{{z}^{2}} + \frac{{x}^{2}}{y \cdot {z}^{2}}\right) - \frac{1}{y}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+87.8%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \color{blue}{\left(\frac{y}{{z}^{2}} + \left(\frac{{x}^{2}}{y \cdot {z}^{2}} - \frac{1}{y}\right)\right)}\right) \]
      2. unpow287.8%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \left(\frac{\color{blue}{x \cdot x}}{y \cdot {z}^{2}} - \frac{1}{y}\right)\right)\right) \]
      3. times-frac98.8%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \left(\color{blue}{\frac{x}{y} \cdot \frac{x}{{z}^{2}}} - \frac{1}{y}\right)\right)\right) \]
      4. fmm-def98.8%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \color{blue}{\mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, -\frac{1}{y}\right)}\right)\right) \]
      5. distribute-neg-frac98.8%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, \color{blue}{\frac{-1}{y}}\right)\right)\right) \]
      6. metadata-eval98.8%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, \frac{\color{blue}{-1}}{y}\right)\right)\right) \]
    7. Simplified98.8%

      \[\leadsto 0.5 \cdot \color{blue}{\left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, \frac{-1}{y}\right)\right)\right)} \]

    if 9.9999999999999994e303 < (*.f64 z z)

    1. Initial program 57.2%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg57.2%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out57.2%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{-\color{blue}{\left(-y\right) \cdot 2}} \]
      3. distribute-frac-neg257.2%

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg57.2%

        \[\leadsto \color{blue}{\frac{-\left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\left(-y\right) \cdot 2}} \]
      5. neg-mul-157.2%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}}{\left(-y\right) \cdot 2} \]
      6. distribute-lft-neg-out57.2%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative57.2%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in57.2%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\left(-2\right) \cdot y}} \]
      9. times-frac57.2%

        \[\leadsto \color{blue}{\frac{-1}{-2} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}} \]
      10. metadata-eval57.2%

        \[\leadsto \frac{-1}{\color{blue}{-2}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      11. metadata-eval57.2%

        \[\leadsto \color{blue}{0.5} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      12. associate--l+57.2%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define61.8%

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left({z}^{2} \cdot \left(\left(\frac{y}{{z}^{2}} + \frac{{x}^{2}}{y \cdot {z}^{2}}\right) - \frac{1}{y}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+65.2%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \color{blue}{\left(\frac{y}{{z}^{2}} + \left(\frac{{x}^{2}}{y \cdot {z}^{2}} - \frac{1}{y}\right)\right)}\right) \]
      2. unpow265.2%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \left(\frac{\color{blue}{x \cdot x}}{y \cdot {z}^{2}} - \frac{1}{y}\right)\right)\right) \]
      3. times-frac66.7%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \left(\color{blue}{\frac{x}{y} \cdot \frac{x}{{z}^{2}}} - \frac{1}{y}\right)\right)\right) \]
      4. fmm-def66.7%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \color{blue}{\mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, -\frac{1}{y}\right)}\right)\right) \]
      5. distribute-neg-frac66.7%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, \color{blue}{\frac{-1}{y}}\right)\right)\right) \]
      6. metadata-eval66.7%

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\left(\frac{{x}^{2}}{{z}^{2}} - 1\right) \cdot {z}^{2}}}{y} \]
      2. associate-/l*65.2%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\left(\frac{{x}^{2}}{{z}^{2}} - 1\right) \cdot \frac{{z}^{2}}{y}\right)} \]
      3. unpow265.2%

        \[\leadsto 0.5 \cdot \left(\left(\frac{\color{blue}{x \cdot x}}{{z}^{2}} - 1\right) \cdot \frac{{z}^{2}}{y}\right) \]
      4. associate-/l*69.8%

        \[\leadsto 0.5 \cdot \left(\left(\color{blue}{x \cdot \frac{x}{{z}^{2}}} - 1\right) \cdot \frac{{z}^{2}}{y}\right) \]
      5. fmm-def69.8%

        \[\leadsto 0.5 \cdot \left(\color{blue}{\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right)} \cdot \frac{{z}^{2}}{y}\right) \]
      6. metadata-eval69.8%

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, \color{blue}{-1}\right) \cdot \frac{{z}^{2}}{y}\right) \]
    10. Simplified69.8%

      \[\leadsto \color{blue}{0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right) \cdot \frac{{z}^{2}}{y}\right)} \]
    11. Step-by-step derivation
      1. div-inv69.8%

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right) \cdot \color{blue}{\left({z}^{2} \cdot \frac{1}{y}\right)}\right) \]
      2. pow269.8%

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right) \cdot \left(\color{blue}{\left(z \cdot z\right)} \cdot \frac{1}{y}\right)\right) \]
      3. associate-*l*74.2%

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right) \cdot \color{blue}{\left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)}\right) \]
    12. Applied egg-rr74.2%

      \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right) \cdot \color{blue}{\left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)}\right) \]
    13. Step-by-step derivation
      1. *-un-lft-identity74.2%

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

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{1 \cdot x}{\color{blue}{z \cdot z}}, -1\right) \cdot \left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)\right) \]
      3. times-frac89.5%

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \color{blue}{\frac{1}{z} \cdot \frac{x}{z}}, -1\right) \cdot \left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)\right) \]
    14. Applied egg-rr89.5%

      \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \color{blue}{\frac{1}{z} \cdot \frac{x}{z}}, -1\right) \cdot \left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)\right) \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 2: 84.1% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{z} \cdot \frac{x}{z}\\ \mathbf{if}\;z \cdot z \leq 2 \cdot 10^{-136}:\\ \;\;\;\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\ \mathbf{elif}\;z \cdot z \leq 10^{+304}:\\ \;\;\;\;0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \mathsf{fma}\left(\frac{x}{y}, t\_0, \frac{-1}{y}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\mathsf{fma}\left(x, t\_0, -1\right) \cdot \left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (/ 1.0 z) (/ x z))))
   (if (<= (* z z) 2e-136)
     (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0))
     (if (<= (* z z) 1e+304)
       (*
        0.5
        (* (pow z 2.0) (+ (/ y (pow z 2.0)) (fma (/ x y) t_0 (/ -1.0 y)))))
       (* 0.5 (* (fma x t_0 -1.0) (* z (* z (/ 1.0 y)))))))))
double code(double x, double y, double z) {
	double t_0 = (1.0 / z) * (x / z);
	double tmp;
	if ((z * z) <= 2e-136) {
		tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
	} else if ((z * z) <= 1e+304) {
		tmp = 0.5 * (pow(z, 2.0) * ((y / pow(z, 2.0)) + fma((x / y), t_0, (-1.0 / y))));
	} else {
		tmp = 0.5 * (fma(x, t_0, -1.0) * (z * (z * (1.0 / y))));
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(Float64(1.0 / z) * Float64(x / z))
	tmp = 0.0
	if (Float64(z * z) <= 2e-136)
		tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0));
	elseif (Float64(z * z) <= 1e+304)
		tmp = Float64(0.5 * Float64((z ^ 2.0) * Float64(Float64(y / (z ^ 2.0)) + fma(Float64(x / y), t_0, Float64(-1.0 / y)))));
	else
		tmp = Float64(0.5 * Float64(fma(x, t_0, -1.0) * Float64(z * Float64(z * Float64(1.0 / y)))));
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(1.0 / z), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * z), $MachinePrecision], 2e-136], N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 1e+304], N[(0.5 * N[(N[Power[z, 2.0], $MachinePrecision] * N[(N[(y / N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[(x / y), $MachinePrecision] * t$95$0 + N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(x * t$95$0 + -1.0), $MachinePrecision] * N[(z * N[(z * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \cdot z \leq 10^{+304}:\\
\;\;\;\;0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \mathsf{fma}\left(\frac{x}{y}, t\_0, \frac{-1}{y}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\mathsf{fma}\left(x, t\_0, -1\right) \cdot \left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)\right)\\


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

    1. Initial program 79.2%

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

    if 2e-136 < (*.f64 z z) < 9.9999999999999994e303

    1. Initial program 75.0%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg75.0%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out75.0%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{-\color{blue}{\left(-y\right) \cdot 2}} \]
      3. distribute-frac-neg275.0%

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg75.0%

        \[\leadsto \color{blue}{\frac{-\left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\left(-y\right) \cdot 2}} \]
      5. neg-mul-175.0%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}}{\left(-y\right) \cdot 2} \]
      6. distribute-lft-neg-out75.0%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative75.0%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in75.0%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\left(-2\right) \cdot y}} \]
      9. times-frac75.0%

        \[\leadsto \color{blue}{\frac{-1}{-2} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}} \]
      10. metadata-eval75.0%

        \[\leadsto \frac{-1}{\color{blue}{-2}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      11. metadata-eval75.0%

        \[\leadsto \color{blue}{0.5} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      12. associate--l+75.0%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define75.0%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified75.0%

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

      \[\leadsto 0.5 \cdot \color{blue}{\left({z}^{2} \cdot \left(\left(\frac{y}{{z}^{2}} + \frac{{x}^{2}}{y \cdot {z}^{2}}\right) - \frac{1}{y}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+87.8%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \color{blue}{\left(\frac{y}{{z}^{2}} + \left(\frac{{x}^{2}}{y \cdot {z}^{2}} - \frac{1}{y}\right)\right)}\right) \]
      2. unpow287.8%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \left(\frac{\color{blue}{x \cdot x}}{y \cdot {z}^{2}} - \frac{1}{y}\right)\right)\right) \]
      3. times-frac98.8%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \left(\color{blue}{\frac{x}{y} \cdot \frac{x}{{z}^{2}}} - \frac{1}{y}\right)\right)\right) \]
      4. fmm-def98.8%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \color{blue}{\mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, -\frac{1}{y}\right)}\right)\right) \]
      5. distribute-neg-frac98.8%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, \color{blue}{\frac{-1}{y}}\right)\right)\right) \]
      6. metadata-eval98.8%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, \frac{\color{blue}{-1}}{y}\right)\right)\right) \]
    7. Simplified98.8%

      \[\leadsto 0.5 \cdot \color{blue}{\left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, \frac{-1}{y}\right)\right)\right)} \]
    8. Step-by-step derivation
      1. *-un-lft-identity69.0%

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{\color{blue}{1 \cdot x}}{{z}^{2}}, -1\right) \cdot \left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)\right) \]
      2. pow269.0%

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{1 \cdot x}{\color{blue}{z \cdot z}}, -1\right) \cdot \left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)\right) \]
      3. times-frac69.0%

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \color{blue}{\frac{1}{z} \cdot \frac{x}{z}}, -1\right) \cdot \left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)\right) \]
    9. Applied egg-rr98.8%

      \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \mathsf{fma}\left(\frac{x}{y}, \color{blue}{\frac{1}{z} \cdot \frac{x}{z}}, \frac{-1}{y}\right)\right)\right) \]

    if 9.9999999999999994e303 < (*.f64 z z)

    1. Initial program 57.2%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg57.2%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out57.2%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{-\color{blue}{\left(-y\right) \cdot 2}} \]
      3. distribute-frac-neg257.2%

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg57.2%

        \[\leadsto \color{blue}{\frac{-\left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\left(-y\right) \cdot 2}} \]
      5. neg-mul-157.2%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}}{\left(-y\right) \cdot 2} \]
      6. distribute-lft-neg-out57.2%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative57.2%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in57.2%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\left(-2\right) \cdot y}} \]
      9. times-frac57.2%

        \[\leadsto \color{blue}{\frac{-1}{-2} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}} \]
      10. metadata-eval57.2%

        \[\leadsto \frac{-1}{\color{blue}{-2}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      11. metadata-eval57.2%

        \[\leadsto \color{blue}{0.5} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      12. associate--l+57.2%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define61.8%

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left({z}^{2} \cdot \left(\left(\frac{y}{{z}^{2}} + \frac{{x}^{2}}{y \cdot {z}^{2}}\right) - \frac{1}{y}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+65.2%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \color{blue}{\left(\frac{y}{{z}^{2}} + \left(\frac{{x}^{2}}{y \cdot {z}^{2}} - \frac{1}{y}\right)\right)}\right) \]
      2. unpow265.2%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \left(\frac{\color{blue}{x \cdot x}}{y \cdot {z}^{2}} - \frac{1}{y}\right)\right)\right) \]
      3. times-frac66.7%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \left(\color{blue}{\frac{x}{y} \cdot \frac{x}{{z}^{2}}} - \frac{1}{y}\right)\right)\right) \]
      4. fmm-def66.7%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \color{blue}{\mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, -\frac{1}{y}\right)}\right)\right) \]
      5. distribute-neg-frac66.7%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, \color{blue}{\frac{-1}{y}}\right)\right)\right) \]
      6. metadata-eval66.7%

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\left(\frac{{x}^{2}}{{z}^{2}} - 1\right) \cdot {z}^{2}}}{y} \]
      2. associate-/l*65.2%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\left(\frac{{x}^{2}}{{z}^{2}} - 1\right) \cdot \frac{{z}^{2}}{y}\right)} \]
      3. unpow265.2%

        \[\leadsto 0.5 \cdot \left(\left(\frac{\color{blue}{x \cdot x}}{{z}^{2}} - 1\right) \cdot \frac{{z}^{2}}{y}\right) \]
      4. associate-/l*69.8%

        \[\leadsto 0.5 \cdot \left(\left(\color{blue}{x \cdot \frac{x}{{z}^{2}}} - 1\right) \cdot \frac{{z}^{2}}{y}\right) \]
      5. fmm-def69.8%

        \[\leadsto 0.5 \cdot \left(\color{blue}{\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right)} \cdot \frac{{z}^{2}}{y}\right) \]
      6. metadata-eval69.8%

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, \color{blue}{-1}\right) \cdot \frac{{z}^{2}}{y}\right) \]
    10. Simplified69.8%

      \[\leadsto \color{blue}{0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right) \cdot \frac{{z}^{2}}{y}\right)} \]
    11. Step-by-step derivation
      1. div-inv69.8%

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right) \cdot \color{blue}{\left({z}^{2} \cdot \frac{1}{y}\right)}\right) \]
      2. pow269.8%

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right) \cdot \left(\color{blue}{\left(z \cdot z\right)} \cdot \frac{1}{y}\right)\right) \]
      3. associate-*l*74.2%

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right) \cdot \color{blue}{\left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)}\right) \]
    12. Applied egg-rr74.2%

      \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right) \cdot \color{blue}{\left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)}\right) \]
    13. Step-by-step derivation
      1. *-un-lft-identity74.2%

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

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{1 \cdot x}{\color{blue}{z \cdot z}}, -1\right) \cdot \left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)\right) \]
      3. times-frac89.5%

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \color{blue}{\frac{1}{z} \cdot \frac{x}{z}}, -1\right) \cdot \left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)\right) \]
    14. Applied egg-rr89.5%

      \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \color{blue}{\frac{1}{z} \cdot \frac{x}{z}}, -1\right) \cdot \left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)\right) \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 76.1% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{z} \cdot \frac{x}{z}\\ \mathbf{if}\;z \leq 10^{-64}:\\ \;\;\;\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\ \mathbf{elif}\;z \leq 2.2 \cdot 10^{+161}:\\ \;\;\;\;0.5 \cdot \left({z}^{2} \cdot \left(\mathsf{fma}\left(\frac{x}{y}, t\_0, \frac{-1}{y}\right) + \frac{1}{z} \cdot \frac{y}{z}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\mathsf{fma}\left(x, t\_0, -1\right) \cdot \left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (/ 1.0 z) (/ x z))))
   (if (<= z 1e-64)
     (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0))
     (if (<= z 2.2e+161)
       (*
        0.5
        (* (pow z 2.0) (+ (fma (/ x y) t_0 (/ -1.0 y)) (* (/ 1.0 z) (/ y z)))))
       (* 0.5 (* (fma x t_0 -1.0) (* z (* z (/ 1.0 y)))))))))
double code(double x, double y, double z) {
	double t_0 = (1.0 / z) * (x / z);
	double tmp;
	if (z <= 1e-64) {
		tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
	} else if (z <= 2.2e+161) {
		tmp = 0.5 * (pow(z, 2.0) * (fma((x / y), t_0, (-1.0 / y)) + ((1.0 / z) * (y / z))));
	} else {
		tmp = 0.5 * (fma(x, t_0, -1.0) * (z * (z * (1.0 / y))));
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(Float64(1.0 / z) * Float64(x / z))
	tmp = 0.0
	if (z <= 1e-64)
		tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0));
	elseif (z <= 2.2e+161)
		tmp = Float64(0.5 * Float64((z ^ 2.0) * Float64(fma(Float64(x / y), t_0, Float64(-1.0 / y)) + Float64(Float64(1.0 / z) * Float64(y / z)))));
	else
		tmp = Float64(0.5 * Float64(fma(x, t_0, -1.0) * Float64(z * Float64(z * Float64(1.0 / y)))));
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(1.0 / z), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 1e-64], N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.2e+161], N[(0.5 * N[(N[Power[z, 2.0], $MachinePrecision] * N[(N[(N[(x / y), $MachinePrecision] * t$95$0 + N[(-1.0 / y), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / z), $MachinePrecision] * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(x * t$95$0 + -1.0), $MachinePrecision] * N[(z * N[(z * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq 2.2 \cdot 10^{+161}:\\
\;\;\;\;0.5 \cdot \left({z}^{2} \cdot \left(\mathsf{fma}\left(\frac{x}{y}, t\_0, \frac{-1}{y}\right) + \frac{1}{z} \cdot \frac{y}{z}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\mathsf{fma}\left(x, t\_0, -1\right) \cdot \left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 9.99999999999999965e-65

    1. Initial program 71.9%

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

    if 9.99999999999999965e-65 < z < 2.2e161

    1. Initial program 76.3%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg76.3%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out76.3%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{-\color{blue}{\left(-y\right) \cdot 2}} \]
      3. distribute-frac-neg276.3%

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg76.3%

        \[\leadsto \color{blue}{\frac{-\left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\left(-y\right) \cdot 2}} \]
      5. neg-mul-176.3%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}}{\left(-y\right) \cdot 2} \]
      6. distribute-lft-neg-out76.3%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative76.3%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in76.3%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\left(-2\right) \cdot y}} \]
      9. times-frac76.3%

        \[\leadsto \color{blue}{\frac{-1}{-2} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}} \]
      10. metadata-eval76.3%

        \[\leadsto \frac{-1}{\color{blue}{-2}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      11. metadata-eval76.3%

        \[\leadsto \color{blue}{0.5} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      12. associate--l+76.3%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define76.3%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified76.3%

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

      \[\leadsto 0.5 \cdot \color{blue}{\left({z}^{2} \cdot \left(\left(\frac{y}{{z}^{2}} + \frac{{x}^{2}}{y \cdot {z}^{2}}\right) - \frac{1}{y}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+87.4%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \color{blue}{\left(\frac{y}{{z}^{2}} + \left(\frac{{x}^{2}}{y \cdot {z}^{2}} - \frac{1}{y}\right)\right)}\right) \]
      2. unpow287.4%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \left(\frac{\color{blue}{x \cdot x}}{y \cdot {z}^{2}} - \frac{1}{y}\right)\right)\right) \]
      3. times-frac97.8%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \left(\color{blue}{\frac{x}{y} \cdot \frac{x}{{z}^{2}}} - \frac{1}{y}\right)\right)\right) \]
      4. fmm-def97.8%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \color{blue}{\mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, -\frac{1}{y}\right)}\right)\right) \]
      5. distribute-neg-frac97.8%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, \color{blue}{\frac{-1}{y}}\right)\right)\right) \]
      6. metadata-eval97.8%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, \frac{\color{blue}{-1}}{y}\right)\right)\right) \]
    7. Simplified97.8%

      \[\leadsto 0.5 \cdot \color{blue}{\left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, \frac{-1}{y}\right)\right)\right)} \]
    8. Step-by-step derivation
      1. *-un-lft-identity74.1%

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

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{1 \cdot x}{\color{blue}{z \cdot z}}, -1\right) \cdot \left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)\right) \]
      3. times-frac74.1%

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \color{blue}{\frac{1}{z} \cdot \frac{x}{z}}, -1\right) \cdot \left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)\right) \]
    9. Applied egg-rr97.8%

      \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \mathsf{fma}\left(\frac{x}{y}, \color{blue}{\frac{1}{z} \cdot \frac{x}{z}}, \frac{-1}{y}\right)\right)\right) \]
    10. Step-by-step derivation
      1. *-un-lft-identity97.8%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{\color{blue}{1 \cdot y}}{{z}^{2}} + \mathsf{fma}\left(\frac{x}{y}, \frac{1}{z} \cdot \frac{x}{z}, \frac{-1}{y}\right)\right)\right) \]
      2. pow297.8%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{1 \cdot y}{\color{blue}{z \cdot z}} + \mathsf{fma}\left(\frac{x}{y}, \frac{1}{z} \cdot \frac{x}{z}, \frac{-1}{y}\right)\right)\right) \]
      3. times-frac97.7%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\color{blue}{\frac{1}{z} \cdot \frac{y}{z}} + \mathsf{fma}\left(\frac{x}{y}, \frac{1}{z} \cdot \frac{x}{z}, \frac{-1}{y}\right)\right)\right) \]
    11. Applied egg-rr97.7%

      \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\color{blue}{\frac{1}{z} \cdot \frac{y}{z}} + \mathsf{fma}\left(\frac{x}{y}, \frac{1}{z} \cdot \frac{x}{z}, \frac{-1}{y}\right)\right)\right) \]

    if 2.2e161 < z

    1. Initial program 67.1%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg67.1%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out67.1%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{-\color{blue}{\left(-y\right) \cdot 2}} \]
      3. distribute-frac-neg267.1%

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg67.1%

        \[\leadsto \color{blue}{\frac{-\left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\left(-y\right) \cdot 2}} \]
      5. neg-mul-167.1%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}}{\left(-y\right) \cdot 2} \]
      6. distribute-lft-neg-out67.1%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative67.1%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in67.1%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\left(-2\right) \cdot y}} \]
      9. times-frac67.1%

        \[\leadsto \color{blue}{\frac{-1}{-2} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}} \]
      10. metadata-eval67.1%

        \[\leadsto \frac{-1}{\color{blue}{-2}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      11. metadata-eval67.1%

        \[\leadsto \color{blue}{0.5} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      12. associate--l+67.1%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define69.9%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified69.9%

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

      \[\leadsto 0.5 \cdot \color{blue}{\left({z}^{2} \cdot \left(\left(\frac{y}{{z}^{2}} + \frac{{x}^{2}}{y \cdot {z}^{2}}\right) - \frac{1}{y}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+72.7%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \color{blue}{\left(\frac{y}{{z}^{2}} + \left(\frac{{x}^{2}}{y \cdot {z}^{2}} - \frac{1}{y}\right)\right)}\right) \]
      2. unpow272.7%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \left(\frac{\color{blue}{x \cdot x}}{y \cdot {z}^{2}} - \frac{1}{y}\right)\right)\right) \]
      3. times-frac69.9%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \left(\color{blue}{\frac{x}{y} \cdot \frac{x}{{z}^{2}}} - \frac{1}{y}\right)\right)\right) \]
      4. fmm-def69.9%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \color{blue}{\mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, -\frac{1}{y}\right)}\right)\right) \]
      5. distribute-neg-frac69.9%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, \color{blue}{\frac{-1}{y}}\right)\right)\right) \]
      6. metadata-eval69.9%

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{{z}^{2} \cdot \left(\frac{{x}^{2}}{{z}^{2}} - 1\right)}{y}} \]
    9. Step-by-step derivation
      1. *-commutative72.7%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\left(\frac{{x}^{2}}{{z}^{2}} - 1\right) \cdot {z}^{2}}}{y} \]
      2. associate-/l*72.7%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\left(\frac{{x}^{2}}{{z}^{2}} - 1\right) \cdot \frac{{z}^{2}}{y}\right)} \]
      3. unpow272.7%

        \[\leadsto 0.5 \cdot \left(\left(\frac{\color{blue}{x \cdot x}}{{z}^{2}} - 1\right) \cdot \frac{{z}^{2}}{y}\right) \]
      4. associate-/l*75.5%

        \[\leadsto 0.5 \cdot \left(\left(\color{blue}{x \cdot \frac{x}{{z}^{2}}} - 1\right) \cdot \frac{{z}^{2}}{y}\right) \]
      5. fmm-def75.5%

        \[\leadsto 0.5 \cdot \left(\color{blue}{\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right)} \cdot \frac{{z}^{2}}{y}\right) \]
      6. metadata-eval75.5%

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, \color{blue}{-1}\right) \cdot \frac{{z}^{2}}{y}\right) \]
    10. Simplified75.5%

      \[\leadsto \color{blue}{0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right) \cdot \frac{{z}^{2}}{y}\right)} \]
    11. Step-by-step derivation
      1. div-inv75.5%

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right) \cdot \color{blue}{\left({z}^{2} \cdot \frac{1}{y}\right)}\right) \]
      2. pow275.5%

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right) \cdot \left(\color{blue}{\left(z \cdot z\right)} \cdot \frac{1}{y}\right)\right) \]
      3. associate-*l*80.5%

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right) \cdot \color{blue}{\left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)}\right) \]
    12. Applied egg-rr80.5%

      \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right) \cdot \color{blue}{\left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)}\right) \]
    13. Step-by-step derivation
      1. *-un-lft-identity80.5%

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{\color{blue}{1 \cdot x}}{{z}^{2}}, -1\right) \cdot \left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)\right) \]
      2. pow280.5%

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

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

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

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

Alternative 4: 72.0% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 8.6 \cdot 10^{-241}:\\ \;\;\;\;0.5 \cdot \left(\mathsf{fma}\left(x, \frac{1}{z} \cdot \frac{x}{z}, -1\right) \cdot \left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)\right)\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y 8.6e-241)
   (* 0.5 (* (fma x (* (/ 1.0 z) (/ x z)) -1.0) (* z (* z (/ 1.0 y)))))
   (if (<= y 1.35e+154)
     (* 0.5 (/ (fma x x (- (* y y) (* z z))) y))
     (* y 0.5))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= 8.6e-241) {
		tmp = 0.5 * (fma(x, ((1.0 / z) * (x / z)), -1.0) * (z * (z * (1.0 / y))));
	} else if (y <= 1.35e+154) {
		tmp = 0.5 * (fma(x, x, ((y * y) - (z * z))) / y);
	} else {
		tmp = y * 0.5;
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (y <= 8.6e-241)
		tmp = Float64(0.5 * Float64(fma(x, Float64(Float64(1.0 / z) * Float64(x / z)), -1.0) * Float64(z * Float64(z * Float64(1.0 / y)))));
	elseif (y <= 1.35e+154)
		tmp = Float64(0.5 * Float64(fma(x, x, Float64(Float64(y * y) - Float64(z * z))) / y));
	else
		tmp = Float64(y * 0.5);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[y, 8.6e-241], N[(0.5 * N[(N[(x * N[(N[(1.0 / z), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision] * N[(z * N[(z * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.35e+154], N[(0.5 * N[(N[(x * x + N[(N[(y * y), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.6 \cdot 10^{-241}:\\
\;\;\;\;0.5 \cdot \left(\mathsf{fma}\left(x, \frac{1}{z} \cdot \frac{x}{z}, -1\right) \cdot \left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)\right)\\

\mathbf{elif}\;y \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 8.5999999999999997e-241

    1. Initial program 74.8%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg74.8%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out74.8%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{-\color{blue}{\left(-y\right) \cdot 2}} \]
      3. distribute-frac-neg274.8%

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg74.8%

        \[\leadsto \color{blue}{\frac{-\left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\left(-y\right) \cdot 2}} \]
      5. neg-mul-174.8%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}}{\left(-y\right) \cdot 2} \]
      6. distribute-lft-neg-out74.8%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative74.8%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in74.8%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\left(-2\right) \cdot y}} \]
      9. times-frac74.8%

        \[\leadsto \color{blue}{\frac{-1}{-2} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}} \]
      10. metadata-eval74.8%

        \[\leadsto \frac{-1}{\color{blue}{-2}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      11. metadata-eval74.8%

        \[\leadsto \color{blue}{0.5} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      12. associate--l+74.8%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define75.6%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified75.6%

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

      \[\leadsto 0.5 \cdot \color{blue}{\left({z}^{2} \cdot \left(\left(\frac{y}{{z}^{2}} + \frac{{x}^{2}}{y \cdot {z}^{2}}\right) - \frac{1}{y}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+55.5%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \color{blue}{\left(\frac{y}{{z}^{2}} + \left(\frac{{x}^{2}}{y \cdot {z}^{2}} - \frac{1}{y}\right)\right)}\right) \]
      2. unpow255.5%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \left(\frac{\color{blue}{x \cdot x}}{y \cdot {z}^{2}} - \frac{1}{y}\right)\right)\right) \]
      3. times-frac61.1%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \left(\color{blue}{\frac{x}{y} \cdot \frac{x}{{z}^{2}}} - \frac{1}{y}\right)\right)\right) \]
      4. fmm-def61.1%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \color{blue}{\mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, -\frac{1}{y}\right)}\right)\right) \]
      5. distribute-neg-frac61.1%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, \color{blue}{\frac{-1}{y}}\right)\right)\right) \]
      6. metadata-eval61.1%

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\left(\frac{{x}^{2}}{{z}^{2}} - 1\right) \cdot {z}^{2}}}{y} \]
      2. associate-/l*50.1%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\left(\frac{{x}^{2}}{{z}^{2}} - 1\right) \cdot \frac{{z}^{2}}{y}\right)} \]
      3. unpow250.1%

        \[\leadsto 0.5 \cdot \left(\left(\frac{\color{blue}{x \cdot x}}{{z}^{2}} - 1\right) \cdot \frac{{z}^{2}}{y}\right) \]
      4. associate-/l*51.7%

        \[\leadsto 0.5 \cdot \left(\left(\color{blue}{x \cdot \frac{x}{{z}^{2}}} - 1\right) \cdot \frac{{z}^{2}}{y}\right) \]
      5. fmm-def51.7%

        \[\leadsto 0.5 \cdot \left(\color{blue}{\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right)} \cdot \frac{{z}^{2}}{y}\right) \]
      6. metadata-eval51.7%

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

      \[\leadsto \color{blue}{0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right) \cdot \frac{{z}^{2}}{y}\right)} \]
    11. Step-by-step derivation
      1. div-inv51.7%

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

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right) \cdot \left(\color{blue}{\left(z \cdot z\right)} \cdot \frac{1}{y}\right)\right) \]
      3. associate-*l*55.7%

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

      \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right) \cdot \color{blue}{\left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)}\right) \]
    13. Step-by-step derivation
      1. *-un-lft-identity55.7%

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

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{1 \cdot x}{\color{blue}{z \cdot z}}, -1\right) \cdot \left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)\right) \]
      3. times-frac64.5%

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \color{blue}{\frac{1}{z} \cdot \frac{x}{z}}, -1\right) \cdot \left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)\right) \]
    14. Applied egg-rr64.5%

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

    if 8.5999999999999997e-241 < y < 1.35000000000000003e154

    1. Initial program 91.7%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg91.7%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out91.7%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{-\color{blue}{\left(-y\right) \cdot 2}} \]
      3. distribute-frac-neg291.7%

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg91.7%

        \[\leadsto \color{blue}{\frac{-\left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\left(-y\right) \cdot 2}} \]
      5. neg-mul-191.7%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}}{\left(-y\right) \cdot 2} \]
      6. distribute-lft-neg-out91.7%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative91.7%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in91.7%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\left(-2\right) \cdot y}} \]
      9. times-frac91.7%

        \[\leadsto \color{blue}{\frac{-1}{-2} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}} \]
      10. metadata-eval91.7%

        \[\leadsto \frac{-1}{\color{blue}{-2}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      11. metadata-eval91.7%

        \[\leadsto \color{blue}{0.5} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      12. associate--l+91.7%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define93.8%

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

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

    if 1.35000000000000003e154 < y

    1. Initial program 14.8%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg14.8%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out14.8%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{-\color{blue}{\left(-y\right) \cdot 2}} \]
      3. distribute-frac-neg214.8%

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg14.8%

        \[\leadsto \color{blue}{\frac{-\left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\left(-y\right) \cdot 2}} \]
      5. neg-mul-114.8%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}}{\left(-y\right) \cdot 2} \]
      6. distribute-lft-neg-out14.8%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative14.8%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in14.8%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\left(-2\right) \cdot y}} \]
      9. times-frac14.8%

        \[\leadsto \color{blue}{\frac{-1}{-2} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}} \]
      10. metadata-eval14.8%

        \[\leadsto \frac{-1}{\color{blue}{-2}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      11. metadata-eval14.8%

        \[\leadsto \color{blue}{0.5} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      12. associate--l+14.8%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define14.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 8.6 \cdot 10^{-241}:\\ \;\;\;\;0.5 \cdot \left(\mathsf{fma}\left(x, \frac{1}{z} \cdot \frac{x}{z}, -1\right) \cdot \left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)\right)\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 79.7% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y 1.35e+154) (* 0.5 (/ (fma x x (- (* y y) (* z z))) y)) (* y 0.5)))
double code(double x, double y, double z) {
	double tmp;
	if (y <= 1.35e+154) {
		tmp = 0.5 * (fma(x, x, ((y * y) - (z * z))) / y);
	} else {
		tmp = y * 0.5;
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (y <= 1.35e+154)
		tmp = Float64(0.5 * Float64(fma(x, x, Float64(Float64(y * y) - Float64(z * z))) / y));
	else
		tmp = Float64(y * 0.5);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[y, 1.35e+154], N[(0.5 * N[(N[(x * x + N[(N[(y * y), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1.35000000000000003e154

    1. Initial program 82.0%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg82.0%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out82.0%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{-\color{blue}{\left(-y\right) \cdot 2}} \]
      3. distribute-frac-neg282.0%

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg82.0%

        \[\leadsto \color{blue}{\frac{-\left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\left(-y\right) \cdot 2}} \]
      5. neg-mul-182.0%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}}{\left(-y\right) \cdot 2} \]
      6. distribute-lft-neg-out82.0%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative82.0%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in82.0%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\left(-2\right) \cdot y}} \]
      9. times-frac82.0%

        \[\leadsto \color{blue}{\frac{-1}{-2} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}} \]
      10. metadata-eval82.0%

        \[\leadsto \frac{-1}{\color{blue}{-2}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      11. metadata-eval82.0%

        \[\leadsto \color{blue}{0.5} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      12. associate--l+82.0%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define83.4%

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

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

    if 1.35000000000000003e154 < y

    1. Initial program 14.8%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg14.8%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out14.8%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{-\color{blue}{\left(-y\right) \cdot 2}} \]
      3. distribute-frac-neg214.8%

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg14.8%

        \[\leadsto \color{blue}{\frac{-\left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\left(-y\right) \cdot 2}} \]
      5. neg-mul-114.8%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}}{\left(-y\right) \cdot 2} \]
      6. distribute-lft-neg-out14.8%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative14.8%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in14.8%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\left(-2\right) \cdot y}} \]
      9. times-frac14.8%

        \[\leadsto \color{blue}{\frac{-1}{-2} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}} \]
      10. metadata-eval14.8%

        \[\leadsto \frac{-1}{\color{blue}{-2}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      11. metadata-eval14.8%

        \[\leadsto \color{blue}{0.5} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      12. associate--l+14.8%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define14.8%

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

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

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

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

Alternative 6: 43.7% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(z \cdot \left(z \cdot \frac{-1}{y}\right)\right)\\
\mathbf{if}\;x \leq 3.5 \cdot 10^{-277}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 5.2 \cdot 10^{-167}:\\
\;\;\;\;y \cdot 0.5\\

\mathbf{elif}\;x \leq 3.3 \cdot 10^{+72}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 3.49999999999999983e-277 or 5.1999999999999998e-167 < x < 3.3e72

    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. remove-double-neg72.7%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out72.7%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{-\color{blue}{\left(-y\right) \cdot 2}} \]
      3. distribute-frac-neg272.7%

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg72.7%

        \[\leadsto \color{blue}{\frac{-\left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\left(-y\right) \cdot 2}} \]
      5. neg-mul-172.7%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}}{\left(-y\right) \cdot 2} \]
      6. distribute-lft-neg-out72.7%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative72.7%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in72.7%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\left(-2\right) \cdot y}} \]
      9. times-frac72.7%

        \[\leadsto \color{blue}{\frac{-1}{-2} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}} \]
      10. metadata-eval72.7%

        \[\leadsto \frac{-1}{\color{blue}{-2}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      11. metadata-eval72.7%

        \[\leadsto \color{blue}{0.5} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      12. associate--l+72.7%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define73.7%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified73.7%

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

      \[\leadsto 0.5 \cdot \color{blue}{\left({z}^{2} \cdot \left(\left(\frac{y}{{z}^{2}} + \frac{{x}^{2}}{y \cdot {z}^{2}}\right) - \frac{1}{y}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+57.6%

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

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \left(\frac{\color{blue}{x \cdot x}}{y \cdot {z}^{2}} - \frac{1}{y}\right)\right)\right) \]
      3. times-frac61.5%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \left(\color{blue}{\frac{x}{y} \cdot \frac{x}{{z}^{2}}} - \frac{1}{y}\right)\right)\right) \]
      4. fmm-def61.5%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \color{blue}{\mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, -\frac{1}{y}\right)}\right)\right) \]
      5. distribute-neg-frac61.5%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, \color{blue}{\frac{-1}{y}}\right)\right)\right) \]
      6. metadata-eval61.5%

        \[\leadsto 0.5 \cdot \left({z}^{2} \cdot \left(\frac{y}{{z}^{2}} + \mathsf{fma}\left(\frac{x}{y}, \frac{x}{{z}^{2}}, \frac{\color{blue}{-1}}{y}\right)\right)\right) \]
    7. Simplified61.5%

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{{z}^{2} \cdot \left(\frac{{x}^{2}}{{z}^{2}} - 1\right)}{y}} \]
    9. Step-by-step derivation
      1. *-commutative49.5%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\left(\frac{{x}^{2}}{{z}^{2}} - 1\right) \cdot {z}^{2}}}{y} \]
      2. associate-/l*49.4%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\left(\frac{{x}^{2}}{{z}^{2}} - 1\right) \cdot \frac{{z}^{2}}{y}\right)} \]
      3. unpow249.4%

        \[\leadsto 0.5 \cdot \left(\left(\frac{\color{blue}{x \cdot x}}{{z}^{2}} - 1\right) \cdot \frac{{z}^{2}}{y}\right) \]
      4. associate-/l*50.4%

        \[\leadsto 0.5 \cdot \left(\left(\color{blue}{x \cdot \frac{x}{{z}^{2}}} - 1\right) \cdot \frac{{z}^{2}}{y}\right) \]
      5. fmm-def50.4%

        \[\leadsto 0.5 \cdot \left(\color{blue}{\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right)} \cdot \frac{{z}^{2}}{y}\right) \]
      6. metadata-eval50.4%

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, \color{blue}{-1}\right) \cdot \frac{{z}^{2}}{y}\right) \]
    10. Simplified50.4%

      \[\leadsto \color{blue}{0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right) \cdot \frac{{z}^{2}}{y}\right)} \]
    11. Step-by-step derivation
      1. div-inv50.4%

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

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right) \cdot \left(\color{blue}{\left(z \cdot z\right)} \cdot \frac{1}{y}\right)\right) \]
      3. associate-*l*54.0%

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right) \cdot \color{blue}{\left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)}\right) \]
    12. Applied egg-rr54.0%

      \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(x, \frac{x}{{z}^{2}}, -1\right) \cdot \color{blue}{\left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)}\right) \]
    13. Taylor expanded in x around 0 40.7%

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

    if 3.49999999999999983e-277 < x < 5.1999999999999998e-167

    1. Initial program 76.2%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg76.2%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out76.2%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{-\color{blue}{\left(-y\right) \cdot 2}} \]
      3. distribute-frac-neg276.2%

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg76.2%

        \[\leadsto \color{blue}{\frac{-\left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\left(-y\right) \cdot 2}} \]
      5. neg-mul-176.2%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}}{\left(-y\right) \cdot 2} \]
      6. distribute-lft-neg-out76.2%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative76.2%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in76.2%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\left(-2\right) \cdot y}} \]
      9. times-frac76.2%

        \[\leadsto \color{blue}{\frac{-1}{-2} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}} \]
      10. metadata-eval76.2%

        \[\leadsto \frac{-1}{\color{blue}{-2}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      11. metadata-eval76.2%

        \[\leadsto \color{blue}{0.5} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      12. associate--l+76.2%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define76.2%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified76.2%

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

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

    if 3.3e72 < x

    1. Initial program 66.5%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg66.5%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out66.5%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{-\color{blue}{\left(-y\right) \cdot 2}} \]
      3. distribute-frac-neg266.5%

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg66.5%

        \[\leadsto \color{blue}{\frac{-\left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\left(-y\right) \cdot 2}} \]
      5. neg-mul-166.5%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}}{\left(-y\right) \cdot 2} \]
      6. distribute-lft-neg-out66.5%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative66.5%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in66.5%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\left(-2\right) \cdot y}} \]
      9. times-frac66.5%

        \[\leadsto \color{blue}{\frac{-1}{-2} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}} \]
      10. metadata-eval66.5%

        \[\leadsto \frac{-1}{\color{blue}{-2}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      11. metadata-eval66.5%

        \[\leadsto \color{blue}{0.5} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      12. associate--l+66.5%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define69.2%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified69.2%

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{{x}^{2}}{y}} \]
    6. Step-by-step derivation
      1. *-commutative71.7%

        \[\leadsto \color{blue}{\frac{{x}^{2}}{y} \cdot 0.5} \]
      2. associate-*l/71.7%

        \[\leadsto \color{blue}{\frac{{x}^{2} \cdot 0.5}{y}} \]
      3. associate-*r/71.7%

        \[\leadsto \color{blue}{{x}^{2} \cdot \frac{0.5}{y}} \]
    7. Simplified71.7%

      \[\leadsto \color{blue}{{x}^{2} \cdot \frac{0.5}{y}} \]
    8. Step-by-step derivation
      1. pow271.7%

        \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot \frac{0.5}{y} \]
      2. associate-*r/71.7%

        \[\leadsto \color{blue}{\frac{\left(x \cdot x\right) \cdot 0.5}{y}} \]
      3. clear-num71.8%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{\left(x \cdot x\right) \cdot 0.5}}} \]
      4. pow271.8%

        \[\leadsto \frac{1}{\frac{y}{\color{blue}{{x}^{2}} \cdot 0.5}} \]
    9. Applied egg-rr71.8%

      \[\leadsto \color{blue}{\frac{1}{\frac{y}{{x}^{2} \cdot 0.5}}} \]
    10. Step-by-step derivation
      1. pow271.8%

        \[\leadsto \frac{1}{\frac{y}{\color{blue}{\left(x \cdot x\right)} \cdot 0.5}} \]
      2. clear-num71.7%

        \[\leadsto \color{blue}{\frac{\left(x \cdot x\right) \cdot 0.5}{y}} \]
      3. associate-*r/71.7%

        \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot \frac{0.5}{y}} \]
      4. *-commutative71.7%

        \[\leadsto \color{blue}{\frac{0.5}{y} \cdot \left(x \cdot x\right)} \]
      5. associate-*r*83.1%

        \[\leadsto \color{blue}{\left(\frac{0.5}{y} \cdot x\right) \cdot x} \]
    11. Applied egg-rr83.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 3.5 \cdot 10^{-277}:\\ \;\;\;\;0.5 \cdot \left(z \cdot \left(z \cdot \frac{-1}{y}\right)\right)\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-167}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 3.3 \cdot 10^{+72}:\\ \;\;\;\;0.5 \cdot \left(z \cdot \left(z \cdot \frac{-1}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 77.1% accurate, 0.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1.35000000000000003e154

    1. Initial program 82.0%

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

    if 1.35000000000000003e154 < y

    1. Initial program 14.8%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg14.8%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out14.8%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{-\color{blue}{\left(-y\right) \cdot 2}} \]
      3. distribute-frac-neg214.8%

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg14.8%

        \[\leadsto \color{blue}{\frac{-\left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\left(-y\right) \cdot 2}} \]
      5. neg-mul-114.8%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}}{\left(-y\right) \cdot 2} \]
      6. distribute-lft-neg-out14.8%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative14.8%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in14.8%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\left(-2\right) \cdot y}} \]
      9. times-frac14.8%

        \[\leadsto \color{blue}{\frac{-1}{-2} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}} \]
      10. metadata-eval14.8%

        \[\leadsto \frac{-1}{\color{blue}{-2}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      11. metadata-eval14.8%

        \[\leadsto \color{blue}{0.5} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      12. associate--l+14.8%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define14.8%

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

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

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

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

Alternative 8: 52.8% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 10^{+112}:\\
\;\;\;\;y \cdot 0.5\\

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


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

    1. Initial program 74.6%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg74.6%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out74.6%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{-\color{blue}{\left(-y\right) \cdot 2}} \]
      3. distribute-frac-neg274.6%

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg74.6%

        \[\leadsto \color{blue}{\frac{-\left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\left(-y\right) \cdot 2}} \]
      5. neg-mul-174.6%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}}{\left(-y\right) \cdot 2} \]
      6. distribute-lft-neg-out74.6%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative74.6%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in74.6%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\left(-2\right) \cdot y}} \]
      9. times-frac74.6%

        \[\leadsto \color{blue}{\frac{-1}{-2} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}} \]
      10. metadata-eval74.6%

        \[\leadsto \frac{-1}{\color{blue}{-2}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      11. metadata-eval74.6%

        \[\leadsto \color{blue}{0.5} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      12. associate--l+74.6%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define74.6%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified74.6%

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

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

    if 9.9999999999999993e111 < (*.f64 x x)

    1. Initial program 67.8%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg67.8%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out67.8%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{-\color{blue}{\left(-y\right) \cdot 2}} \]
      3. distribute-frac-neg267.8%

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg67.8%

        \[\leadsto \color{blue}{\frac{-\left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\left(-y\right) \cdot 2}} \]
      5. neg-mul-167.8%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}}{\left(-y\right) \cdot 2} \]
      6. distribute-lft-neg-out67.8%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative67.8%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in67.8%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\left(-2\right) \cdot y}} \]
      9. times-frac67.8%

        \[\leadsto \color{blue}{\frac{-1}{-2} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}} \]
      10. metadata-eval67.8%

        \[\leadsto \frac{-1}{\color{blue}{-2}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      11. metadata-eval67.8%

        \[\leadsto \color{blue}{0.5} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      12. associate--l+67.8%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define70.8%

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{{x}^{2}}{y}} \]
    6. Step-by-step derivation
      1. *-commutative67.4%

        \[\leadsto \color{blue}{\frac{{x}^{2}}{y} \cdot 0.5} \]
      2. associate-*l/67.4%

        \[\leadsto \color{blue}{\frac{{x}^{2} \cdot 0.5}{y}} \]
      3. associate-*r/67.4%

        \[\leadsto \color{blue}{{x}^{2} \cdot \frac{0.5}{y}} \]
    7. Simplified67.4%

      \[\leadsto \color{blue}{{x}^{2} \cdot \frac{0.5}{y}} \]
    8. Step-by-step derivation
      1. pow267.4%

        \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot \frac{0.5}{y} \]
      2. associate-*r/67.4%

        \[\leadsto \color{blue}{\frac{\left(x \cdot x\right) \cdot 0.5}{y}} \]
      3. clear-num67.4%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{\left(x \cdot x\right) \cdot 0.5}}} \]
      4. pow267.4%

        \[\leadsto \frac{1}{\frac{y}{\color{blue}{{x}^{2}} \cdot 0.5}} \]
    9. Applied egg-rr67.4%

      \[\leadsto \color{blue}{\frac{1}{\frac{y}{{x}^{2} \cdot 0.5}}} \]
    10. Step-by-step derivation
      1. pow267.4%

        \[\leadsto \frac{1}{\frac{y}{\color{blue}{\left(x \cdot x\right)} \cdot 0.5}} \]
      2. clear-num67.4%

        \[\leadsto \color{blue}{\frac{\left(x \cdot x\right) \cdot 0.5}{y}} \]
      3. associate-*r/67.4%

        \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot \frac{0.5}{y}} \]
      4. associate-*l*74.3%

        \[\leadsto \color{blue}{x \cdot \left(x \cdot \frac{0.5}{y}\right)} \]
      5. clear-num74.3%

        \[\leadsto x \cdot \left(x \cdot \color{blue}{\frac{1}{\frac{y}{0.5}}}\right) \]
      6. div-inv74.3%

        \[\leadsto x \cdot \left(x \cdot \frac{1}{\color{blue}{y \cdot \frac{1}{0.5}}}\right) \]
      7. metadata-eval74.3%

        \[\leadsto x \cdot \left(x \cdot \frac{1}{y \cdot \color{blue}{2}}\right) \]
      8. add-sqr-sqrt40.1%

        \[\leadsto x \cdot \left(x \cdot \frac{1}{\color{blue}{\sqrt{y \cdot 2} \cdot \sqrt{y \cdot 2}}}\right) \]
      9. pow240.1%

        \[\leadsto x \cdot \left(x \cdot \frac{1}{\color{blue}{{\left(\sqrt{y \cdot 2}\right)}^{2}}}\right) \]
      10. add-cbrt-cube37.4%

        \[\leadsto x \cdot \left(x \cdot \frac{1}{{\color{blue}{\left(\sqrt[3]{\left(\sqrt{y \cdot 2} \cdot \sqrt{y \cdot 2}\right) \cdot \sqrt{y \cdot 2}}\right)}}^{2}}\right) \]
      11. add-sqr-sqrt37.4%

        \[\leadsto x \cdot \left(x \cdot \frac{1}{{\left(\sqrt[3]{\color{blue}{\left(y \cdot 2\right)} \cdot \sqrt{y \cdot 2}}\right)}^{2}}\right) \]
      12. cbrt-unprod40.0%

        \[\leadsto x \cdot \left(x \cdot \frac{1}{{\color{blue}{\left(\sqrt[3]{y \cdot 2} \cdot \sqrt[3]{\sqrt{y \cdot 2}}\right)}}^{2}}\right) \]
      13. un-div-inv40.0%

        \[\leadsto x \cdot \color{blue}{\frac{x}{{\left(\sqrt[3]{y \cdot 2} \cdot \sqrt[3]{\sqrt{y \cdot 2}}\right)}^{2}}} \]
      14. cbrt-unprod37.4%

        \[\leadsto x \cdot \frac{x}{{\color{blue}{\left(\sqrt[3]{\left(y \cdot 2\right) \cdot \sqrt{y \cdot 2}}\right)}}^{2}} \]
      15. add-sqr-sqrt37.3%

        \[\leadsto x \cdot \frac{x}{{\left(\sqrt[3]{\color{blue}{\left(\sqrt{y \cdot 2} \cdot \sqrt{y \cdot 2}\right)} \cdot \sqrt{y \cdot 2}}\right)}^{2}} \]
      16. add-cbrt-cube40.1%

        \[\leadsto x \cdot \frac{x}{{\color{blue}{\left(\sqrt{y \cdot 2}\right)}}^{2}} \]
    11. Applied egg-rr74.3%

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

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

Alternative 9: 43.3% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 2 \cdot 10^{+56}:\\
\;\;\;\;y \cdot 0.5\\

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


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

    1. Initial program 72.6%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg72.6%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out72.6%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{-\color{blue}{\left(-y\right) \cdot 2}} \]
      3. distribute-frac-neg272.6%

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg72.6%

        \[\leadsto \color{blue}{\frac{-\left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\left(-y\right) \cdot 2}} \]
      5. neg-mul-172.6%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}}{\left(-y\right) \cdot 2} \]
      6. distribute-lft-neg-out72.6%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative72.6%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in72.6%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\left(-2\right) \cdot y}} \]
      9. times-frac72.6%

        \[\leadsto \color{blue}{\frac{-1}{-2} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}} \]
      10. metadata-eval72.6%

        \[\leadsto \frac{-1}{\color{blue}{-2}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      11. metadata-eval72.6%

        \[\leadsto \color{blue}{0.5} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      12. associate--l+72.6%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define73.5%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified73.5%

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

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

    if 2.00000000000000018e56 < x

    1. Initial program 69.0%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg69.0%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out69.0%

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{-\color{blue}{\left(-y\right) \cdot 2}} \]
      3. distribute-frac-neg269.0%

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg69.0%

        \[\leadsto \color{blue}{\frac{-\left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\left(-y\right) \cdot 2}} \]
      5. neg-mul-169.0%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}}{\left(-y\right) \cdot 2} \]
      6. distribute-lft-neg-out69.0%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative69.0%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in69.0%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\left(-2\right) \cdot y}} \]
      9. times-frac69.0%

        \[\leadsto \color{blue}{\frac{-1}{-2} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}} \]
      10. metadata-eval69.0%

        \[\leadsto \frac{-1}{\color{blue}{-2}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      11. metadata-eval69.0%

        \[\leadsto \color{blue}{0.5} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
      12. associate--l+69.0%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define71.5%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified71.5%

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{{x}^{2}}{y}} \]
    6. Step-by-step derivation
      1. *-commutative71.4%

        \[\leadsto \color{blue}{\frac{{x}^{2}}{y} \cdot 0.5} \]
      2. associate-*l/71.4%

        \[\leadsto \color{blue}{\frac{{x}^{2} \cdot 0.5}{y}} \]
      3. associate-*r/71.3%

        \[\leadsto \color{blue}{{x}^{2} \cdot \frac{0.5}{y}} \]
    7. Simplified71.3%

      \[\leadsto \color{blue}{{x}^{2} \cdot \frac{0.5}{y}} \]
    8. Step-by-step derivation
      1. pow271.3%

        \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot \frac{0.5}{y} \]
      2. associate-*r/71.4%

        \[\leadsto \color{blue}{\frac{\left(x \cdot x\right) \cdot 0.5}{y}} \]
      3. clear-num71.4%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{\left(x \cdot x\right) \cdot 0.5}}} \]
      4. pow271.4%

        \[\leadsto \frac{1}{\frac{y}{\color{blue}{{x}^{2}} \cdot 0.5}} \]
    9. Applied egg-rr71.4%

      \[\leadsto \color{blue}{\frac{1}{\frac{y}{{x}^{2} \cdot 0.5}}} \]
    10. Step-by-step derivation
      1. pow271.4%

        \[\leadsto \frac{1}{\frac{y}{\color{blue}{\left(x \cdot x\right)} \cdot 0.5}} \]
      2. clear-num71.4%

        \[\leadsto \color{blue}{\frac{\left(x \cdot x\right) \cdot 0.5}{y}} \]
      3. associate-*r/71.3%

        \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot \frac{0.5}{y}} \]
      4. *-commutative71.3%

        \[\leadsto \color{blue}{\frac{0.5}{y} \cdot \left(x \cdot x\right)} \]
      5. associate-*r*81.9%

        \[\leadsto \color{blue}{\left(\frac{0.5}{y} \cdot x\right) \cdot x} \]
    11. Applied egg-rr81.9%

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

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

Alternative 10: 34.3% accurate, 5.0× speedup?

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

\\
y \cdot 0.5
\end{array}
Derivation
  1. Initial program 72.0%

    \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
  2. Step-by-step derivation
    1. remove-double-neg72.0%

      \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
    2. distribute-lft-neg-out72.0%

      \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{-\color{blue}{\left(-y\right) \cdot 2}} \]
    3. distribute-frac-neg272.0%

      \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
    4. distribute-frac-neg72.0%

      \[\leadsto \color{blue}{\frac{-\left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\left(-y\right) \cdot 2}} \]
    5. neg-mul-172.0%

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}}{\left(-y\right) \cdot 2} \]
    6. distribute-lft-neg-out72.0%

      \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
    7. *-commutative72.0%

      \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
    8. distribute-lft-neg-in72.0%

      \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\left(-2\right) \cdot y}} \]
    9. times-frac72.0%

      \[\leadsto \color{blue}{\frac{-1}{-2} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}} \]
    10. metadata-eval72.0%

      \[\leadsto \frac{-1}{\color{blue}{-2}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
    11. metadata-eval72.0%

      \[\leadsto \color{blue}{0.5} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y} \]
    12. associate--l+72.0%

      \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
    13. fma-define73.2%

      \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
  3. Simplified73.2%

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

    \[\leadsto \color{blue}{0.5 \cdot y} \]
  6. Final simplification32.5%

    \[\leadsto y \cdot 0.5 \]
  7. 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 2024157 
(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)))