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

Percentage Accurate: 70.2% → 93.1%
Time: 11.8s
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: 70.2% accurate, 1.0× speedup?

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

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

Alternative 1: 93.1% accurate, 0.0× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := \mathsf{hypot}\left(\mathsf{hypot}\left(x, y\_m\right), z\right)\\ y\_s \cdot \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot x + y\_m \cdot y\_m\right) - z \cdot z}{y\_m \cdot 2} \leq -5 \cdot 10^{-53}:\\ \;\;\;\;\frac{z}{\frac{y\_m \cdot \left(-2\right)}{z}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(t\_0 \cdot \frac{t\_0}{y\_m}\right)\\ \end{array} \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
 :precision binary64
 (let* ((t_0 (hypot (hypot x y_m) z)))
   (*
    y_s
    (if (<= (/ (- (+ (* x x) (* y_m y_m)) (* z z)) (* y_m 2.0)) -5e-53)
      (/ z (/ (* y_m (- 2.0)) z))
      (* 0.5 (* t_0 (/ t_0 y_m)))))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double t_0 = hypot(hypot(x, y_m), z);
	double tmp;
	if (((((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)) <= -5e-53) {
		tmp = z / ((y_m * -2.0) / z);
	} else {
		tmp = 0.5 * (t_0 * (t_0 / y_m));
	}
	return y_s * tmp;
}
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double t_0 = Math.hypot(Math.hypot(x, y_m), z);
	double tmp;
	if (((((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)) <= -5e-53) {
		tmp = z / ((y_m * -2.0) / z);
	} else {
		tmp = 0.5 * (t_0 * (t_0 / y_m));
	}
	return y_s * tmp;
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	t_0 = math.hypot(math.hypot(x, y_m), z)
	tmp = 0
	if ((((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)) <= -5e-53:
		tmp = z / ((y_m * -2.0) / z)
	else:
		tmp = 0.5 * (t_0 * (t_0 / y_m))
	return y_s * tmp
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	t_0 = hypot(hypot(x, y_m), z)
	tmp = 0.0
	if (Float64(Float64(Float64(Float64(x * x) + Float64(y_m * y_m)) - Float64(z * z)) / Float64(y_m * 2.0)) <= -5e-53)
		tmp = Float64(z / Float64(Float64(y_m * Float64(-2.0)) / z));
	else
		tmp = Float64(0.5 * Float64(t_0 * Float64(t_0 / y_m)));
	end
	return Float64(y_s * tmp)
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	t_0 = hypot(hypot(x, y_m), z);
	tmp = 0.0;
	if (((((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)) <= -5e-53)
		tmp = z / ((y_m * -2.0) / z);
	else
		tmp = 0.5 * (t_0 * (t_0 / y_m));
	end
	tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := Block[{t$95$0 = N[Sqrt[N[Sqrt[x ^ 2 + y$95$m ^ 2], $MachinePrecision] ^ 2 + z ^ 2], $MachinePrecision]}, N[(y$95$s * If[LessEqual[N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y$95$m * y$95$m), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision], -5e-53], N[(z / N[(N[(y$95$m * (-2.0)), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(t$95$0 * N[(t$95$0 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(\mathsf{hypot}\left(x, y\_m\right), z\right)\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{\left(x \cdot x + y\_m \cdot y\_m\right) - z \cdot z}{y\_m \cdot 2} \leq -5 \cdot 10^{-53}:\\
\;\;\;\;\frac{z}{\frac{y\_m \cdot \left(-2\right)}{z}}\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(t\_0 \cdot \frac{t\_0}{y\_m}\right)\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < -5e-53

    1. Initial program 75.7%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num75.6%

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

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

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

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

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

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

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

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

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

        \[\leadsto {\color{blue}{\left(\frac{y \cdot -2}{{z}^{2}}\right)}}^{-1} \]
      2. metadata-eval35.4%

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

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

        \[\leadsto {\left(\frac{\frac{y}{-0.5}}{\color{blue}{z \cdot z}}\right)}^{-1} \]
      5. associate-/r*36.3%

        \[\leadsto {\color{blue}{\left(\frac{\frac{\frac{y}{-0.5}}{z}}{z}\right)}}^{-1} \]
      6. div-inv36.3%

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

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

      \[\leadsto {\color{blue}{\left(\frac{\frac{y \cdot -2}{z}}{z}\right)}}^{-1} \]
    8. Step-by-step derivation
      1. unpow-136.3%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{y \cdot -2}{z}}{z}}} \]
      2. clear-num36.3%

        \[\leadsto \color{blue}{\frac{z}{\frac{y \cdot -2}{z}}} \]
      3. frac-2neg36.3%

        \[\leadsto \color{blue}{\frac{-z}{-\frac{y \cdot -2}{z}}} \]
      4. distribute-neg-frac36.3%

        \[\leadsto \frac{-z}{\color{blue}{\frac{-y \cdot -2}{z}}} \]
      5. distribute-rgt-neg-in36.3%

        \[\leadsto \frac{-z}{\frac{\color{blue}{y \cdot \left(--2\right)}}{z}} \]
      6. metadata-eval36.3%

        \[\leadsto \frac{-z}{\frac{y \cdot \color{blue}{2}}{z}} \]
    9. Applied egg-rr36.3%

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

    if -5e-53 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64)))

    1. Initial program 63.0%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg63.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-out63.0%

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

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg63.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-163.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-out63.0%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative63.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-in63.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-frac63.0%

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine63.0%

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\left(x \cdot x + y \cdot y\right) - z \cdot z}}{y} \]
      3. add-cube-cbrt62.5%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\left(\sqrt[3]{\left(x \cdot x + y \cdot y\right) - z \cdot z} \cdot \sqrt[3]{\left(x \cdot x + y \cdot y\right) - z \cdot z}\right) \cdot \sqrt[3]{\left(x \cdot x + y \cdot y\right) - z \cdot z}}}{y} \]
      4. pow362.5%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{{\left(\sqrt[3]{\left(x \cdot x + y \cdot y\right) - z \cdot z}\right)}^{3}}}{y} \]
      5. add-sqr-sqrt62.5%

        \[\leadsto 0.5 \cdot \frac{{\left(\sqrt[3]{\color{blue}{\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y}} - z \cdot z}\right)}^{3}}{y} \]
      6. pow262.5%

        \[\leadsto 0.5 \cdot \frac{{\left(\sqrt[3]{\color{blue}{{\left(\sqrt{x \cdot x + y \cdot y}\right)}^{2}} - z \cdot z}\right)}^{3}}{y} \]
      7. hypot-define62.5%

        \[\leadsto 0.5 \cdot \frac{{\left(\sqrt[3]{{\color{blue}{\left(\mathsf{hypot}\left(x, y\right)\right)}}^{2} - z \cdot z}\right)}^{3}}{y} \]
      8. pow262.5%

        \[\leadsto 0.5 \cdot \frac{{\left(\sqrt[3]{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - \color{blue}{{z}^{2}}}\right)}^{3}}{y} \]
    6. Applied egg-rr62.5%

      \[\leadsto 0.5 \cdot \frac{\color{blue}{{\left(\sqrt[3]{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}\right)}^{3}}}{y} \]
    7. Step-by-step derivation
      1. sqr-pow42.5%

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

        \[\leadsto 0.5 \cdot \color{blue}{\left({\left(\sqrt[3]{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}\right)}^{\left(\frac{3}{2}\right)} \cdot \frac{{\left(\sqrt[3]{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}\right)}^{\left(\frac{3}{2}\right)}}{y}\right)} \]
    8. Applied egg-rr69.5%

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

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

Alternative 2: 92.8% accurate, 0.0× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot x + y\_m \cdot y\_m\right) - z \cdot z}{y\_m \cdot 2} \leq -5 \cdot 10^{-53}:\\ \;\;\;\;\frac{z}{\frac{y\_m \cdot \left(-2\right)}{z}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot {\left(\frac{\mathsf{hypot}\left(\mathsf{hypot}\left(x, y\_m\right), z\right)}{\sqrt{y\_m}}\right)}^{2}\\ \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
 :precision binary64
 (*
  y_s
  (if (<= (/ (- (+ (* x x) (* y_m y_m)) (* z z)) (* y_m 2.0)) -5e-53)
    (/ z (/ (* y_m (- 2.0)) z))
    (* 0.5 (pow (/ (hypot (hypot x y_m) z) (sqrt y_m)) 2.0)))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (((((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)) <= -5e-53) {
		tmp = z / ((y_m * -2.0) / z);
	} else {
		tmp = 0.5 * pow((hypot(hypot(x, y_m), z) / sqrt(y_m)), 2.0);
	}
	return y_s * tmp;
}
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (((((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)) <= -5e-53) {
		tmp = z / ((y_m * -2.0) / z);
	} else {
		tmp = 0.5 * Math.pow((Math.hypot(Math.hypot(x, y_m), z) / Math.sqrt(y_m)), 2.0);
	}
	return y_s * tmp;
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	tmp = 0
	if ((((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)) <= -5e-53:
		tmp = z / ((y_m * -2.0) / z)
	else:
		tmp = 0.5 * math.pow((math.hypot(math.hypot(x, y_m), z) / math.sqrt(y_m)), 2.0)
	return y_s * tmp
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (Float64(Float64(Float64(Float64(x * x) + Float64(y_m * y_m)) - Float64(z * z)) / Float64(y_m * 2.0)) <= -5e-53)
		tmp = Float64(z / Float64(Float64(y_m * Float64(-2.0)) / z));
	else
		tmp = Float64(0.5 * (Float64(hypot(hypot(x, y_m), z) / sqrt(y_m)) ^ 2.0));
	end
	return Float64(y_s * tmp)
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	tmp = 0.0;
	if (((((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)) <= -5e-53)
		tmp = z / ((y_m * -2.0) / z);
	else
		tmp = 0.5 * ((hypot(hypot(x, y_m), z) / sqrt(y_m)) ^ 2.0);
	end
	tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y$95$m * y$95$m), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision], -5e-53], N[(z / N[(N[(y$95$m * (-2.0)), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Power[N[(N[Sqrt[N[Sqrt[x ^ 2 + y$95$m ^ 2], $MachinePrecision] ^ 2 + z ^ 2], $MachinePrecision] / N[Sqrt[y$95$m], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

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

\mathbf{else}:\\
\;\;\;\;0.5 \cdot {\left(\frac{\mathsf{hypot}\left(\mathsf{hypot}\left(x, y\_m\right), z\right)}{\sqrt{y\_m}}\right)}^{2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < -5e-53

    1. Initial program 75.7%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num75.6%

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

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

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

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

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

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

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

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

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

        \[\leadsto {\color{blue}{\left(\frac{y \cdot -2}{{z}^{2}}\right)}}^{-1} \]
      2. metadata-eval35.4%

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

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

        \[\leadsto {\left(\frac{\frac{y}{-0.5}}{\color{blue}{z \cdot z}}\right)}^{-1} \]
      5. associate-/r*36.3%

        \[\leadsto {\color{blue}{\left(\frac{\frac{\frac{y}{-0.5}}{z}}{z}\right)}}^{-1} \]
      6. div-inv36.3%

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

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

      \[\leadsto {\color{blue}{\left(\frac{\frac{y \cdot -2}{z}}{z}\right)}}^{-1} \]
    8. Step-by-step derivation
      1. unpow-136.3%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{y \cdot -2}{z}}{z}}} \]
      2. clear-num36.3%

        \[\leadsto \color{blue}{\frac{z}{\frac{y \cdot -2}{z}}} \]
      3. frac-2neg36.3%

        \[\leadsto \color{blue}{\frac{-z}{-\frac{y \cdot -2}{z}}} \]
      4. distribute-neg-frac36.3%

        \[\leadsto \frac{-z}{\color{blue}{\frac{-y \cdot -2}{z}}} \]
      5. distribute-rgt-neg-in36.3%

        \[\leadsto \frac{-z}{\frac{\color{blue}{y \cdot \left(--2\right)}}{z}} \]
      6. metadata-eval36.3%

        \[\leadsto \frac{-z}{\frac{y \cdot \color{blue}{2}}{z}} \]
    9. Applied egg-rr36.3%

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

    if -5e-53 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64)))

    1. Initial program 63.0%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg63.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-out63.0%

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

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg63.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-163.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-out63.0%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative63.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-in63.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-frac63.0%

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine63.0%

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\left(x \cdot x + y \cdot y\right) - z \cdot z}}{y} \]
      3. add-cube-cbrt62.5%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\left(\sqrt[3]{\left(x \cdot x + y \cdot y\right) - z \cdot z} \cdot \sqrt[3]{\left(x \cdot x + y \cdot y\right) - z \cdot z}\right) \cdot \sqrt[3]{\left(x \cdot x + y \cdot y\right) - z \cdot z}}}{y} \]
      4. pow362.5%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{{\left(\sqrt[3]{\left(x \cdot x + y \cdot y\right) - z \cdot z}\right)}^{3}}}{y} \]
      5. add-sqr-sqrt62.5%

        \[\leadsto 0.5 \cdot \frac{{\left(\sqrt[3]{\color{blue}{\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y}} - z \cdot z}\right)}^{3}}{y} \]
      6. pow262.5%

        \[\leadsto 0.5 \cdot \frac{{\left(\sqrt[3]{\color{blue}{{\left(\sqrt{x \cdot x + y \cdot y}\right)}^{2}} - z \cdot z}\right)}^{3}}{y} \]
      7. hypot-define62.5%

        \[\leadsto 0.5 \cdot \frac{{\left(\sqrt[3]{{\color{blue}{\left(\mathsf{hypot}\left(x, y\right)\right)}}^{2} - z \cdot z}\right)}^{3}}{y} \]
      8. pow262.5%

        \[\leadsto 0.5 \cdot \frac{{\left(\sqrt[3]{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - \color{blue}{{z}^{2}}}\right)}^{3}}{y} \]
    6. Applied egg-rr62.5%

      \[\leadsto 0.5 \cdot \frac{\color{blue}{{\left(\sqrt[3]{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}\right)}^{3}}}{y} \]
    7. Step-by-step derivation
      1. rem-cube-cbrt63.0%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}{y} \]
      2. add-sqr-sqrt61.5%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\sqrt{\frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}{y}} \cdot \sqrt{\frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}{y}}\right)} \]
    8. Applied egg-rr62.0%

      \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{\mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right)}{\sqrt{y}} \cdot \frac{\mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right)}{\sqrt{y}}\right)} \]
    9. Step-by-step derivation
      1. unpow262.0%

        \[\leadsto 0.5 \cdot \color{blue}{{\left(\frac{\mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right)}{\sqrt{y}}\right)}^{2}} \]
    10. Simplified62.0%

      \[\leadsto 0.5 \cdot \color{blue}{{\left(\frac{\mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right)}{\sqrt{y}}\right)}^{2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification51.3%

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

Alternative 3: 88.5% accurate, 0.1× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;y\_m \leq 1.32 \cdot 10^{+154}:\\ \;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, y\_m \cdot y\_m - z \cdot z\right)}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;y\_m \cdot 0.5\\ \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
 :precision binary64
 (*
  y_s
  (if (<= y_m 1.32e+154)
    (* 0.5 (/ (fma x x (- (* y_m y_m) (* z z))) y_m))
    (* y_m 0.5))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (y_m <= 1.32e+154) {
		tmp = 0.5 * (fma(x, x, ((y_m * y_m) - (z * z))) / y_m);
	} else {
		tmp = y_m * 0.5;
	}
	return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (y_m <= 1.32e+154)
		tmp = Float64(0.5 * Float64(fma(x, x, Float64(Float64(y_m * y_m) - Float64(z * z))) / y_m));
	else
		tmp = Float64(y_m * 0.5);
	end
	return Float64(y_s * tmp)
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[y$95$m, 1.32e+154], N[(0.5 * N[(N[(x * x + N[(N[(y$95$m * y$95$m), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision], N[(y$95$m * 0.5), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

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

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


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

    1. Initial program 75.2%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg75.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-out75.2%

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

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg75.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-175.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-out75.2%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative75.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-in75.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-frac75.2%

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified77.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.31999999999999998e154 < y

    1. Initial program 9.1%

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

      \[\leadsto \color{blue}{0.5 \cdot y} \]
    4. Step-by-step derivation
      1. *-commutative79.1%

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified79.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.32 \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 4: 42.8% accurate, 0.7× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;x \leq 3.6 \cdot 10^{-149}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{elif}\;x \leq 1.02 \cdot 10^{-53}:\\ \;\;\;\;z \cdot \left(\frac{z}{y\_m} \cdot -0.5\right)\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{+82}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{x}{y\_m}\right)\\ \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
 :precision binary64
 (*
  y_s
  (if (<= x 3.6e-149)
    (* y_m 0.5)
    (if (<= x 1.02e-53)
      (* z (* (/ z y_m) -0.5))
      (if (<= x 3.1e+82) (* y_m 0.5) (* 0.5 (* x (/ x y_m))))))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (x <= 3.6e-149) {
		tmp = y_m * 0.5;
	} else if (x <= 1.02e-53) {
		tmp = z * ((z / y_m) * -0.5);
	} else if (x <= 3.1e+82) {
		tmp = y_m * 0.5;
	} else {
		tmp = 0.5 * (x * (x / y_m));
	}
	return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= 3.6d-149) then
        tmp = y_m * 0.5d0
    else if (x <= 1.02d-53) then
        tmp = z * ((z / y_m) * (-0.5d0))
    else if (x <= 3.1d+82) then
        tmp = y_m * 0.5d0
    else
        tmp = 0.5d0 * (x * (x / y_m))
    end if
    code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (x <= 3.6e-149) {
		tmp = y_m * 0.5;
	} else if (x <= 1.02e-53) {
		tmp = z * ((z / y_m) * -0.5);
	} else if (x <= 3.1e+82) {
		tmp = y_m * 0.5;
	} else {
		tmp = 0.5 * (x * (x / y_m));
	}
	return y_s * tmp;
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	tmp = 0
	if x <= 3.6e-149:
		tmp = y_m * 0.5
	elif x <= 1.02e-53:
		tmp = z * ((z / y_m) * -0.5)
	elif x <= 3.1e+82:
		tmp = y_m * 0.5
	else:
		tmp = 0.5 * (x * (x / y_m))
	return y_s * tmp
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (x <= 3.6e-149)
		tmp = Float64(y_m * 0.5);
	elseif (x <= 1.02e-53)
		tmp = Float64(z * Float64(Float64(z / y_m) * -0.5));
	elseif (x <= 3.1e+82)
		tmp = Float64(y_m * 0.5);
	else
		tmp = Float64(0.5 * Float64(x * Float64(x / y_m)));
	end
	return Float64(y_s * tmp)
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	tmp = 0.0;
	if (x <= 3.6e-149)
		tmp = y_m * 0.5;
	elseif (x <= 1.02e-53)
		tmp = z * ((z / y_m) * -0.5);
	elseif (x <= 3.1e+82)
		tmp = y_m * 0.5;
	else
		tmp = 0.5 * (x * (x / y_m));
	end
	tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[x, 3.6e-149], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[x, 1.02e-53], N[(z * N[(N[(z / y$95$m), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.1e+82], N[(y$95$m * 0.5), $MachinePrecision], N[(0.5 * N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 3.6 \cdot 10^{-149}:\\
\;\;\;\;y\_m \cdot 0.5\\

\mathbf{elif}\;x \leq 1.02 \cdot 10^{-53}:\\
\;\;\;\;z \cdot \left(\frac{z}{y\_m} \cdot -0.5\right)\\

\mathbf{elif}\;x \leq 3.1 \cdot 10^{+82}:\\
\;\;\;\;y\_m \cdot 0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 3.6000000000000002e-149 or 1.02000000000000002e-53 < x < 3.10000000000000032e82

    1. Initial program 67.5%

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

      \[\leadsto \color{blue}{0.5 \cdot y} \]
    4. Step-by-step derivation
      1. *-commutative42.2%

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified42.2%

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

    if 3.6000000000000002e-149 < x < 1.02000000000000002e-53

    1. Initial program 77.8%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num77.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\frac{\color{blue}{\frac{y}{-0.5}}}{{z}^{2}}\right)}^{-1} \]
      4. unpow267.6%

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

        \[\leadsto {\color{blue}{\left(\frac{\frac{\frac{y}{-0.5}}{z}}{z}\right)}}^{-1} \]
      6. div-inv71.7%

        \[\leadsto {\left(\frac{\frac{\color{blue}{y \cdot \frac{1}{-0.5}}}{z}}{z}\right)}^{-1} \]
      7. metadata-eval71.7%

        \[\leadsto {\left(\frac{\frac{y \cdot \color{blue}{-2}}{z}}{z}\right)}^{-1} \]
    7. Applied egg-rr71.7%

      \[\leadsto {\color{blue}{\left(\frac{\frac{y \cdot -2}{z}}{z}\right)}}^{-1} \]
    8. Step-by-step derivation
      1. unpow-171.7%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{y \cdot -2}{z}}{z}}} \]
      2. associate-/r/71.9%

        \[\leadsto \color{blue}{\frac{1}{\frac{y \cdot -2}{z}} \cdot z} \]
      3. clear-num71.8%

        \[\leadsto \color{blue}{\frac{z}{y \cdot -2}} \cdot z \]
      4. *-un-lft-identity71.8%

        \[\leadsto \frac{\color{blue}{1 \cdot z}}{y \cdot -2} \cdot z \]
      5. *-commutative71.8%

        \[\leadsto \frac{1 \cdot z}{\color{blue}{-2 \cdot y}} \cdot z \]
      6. times-frac71.8%

        \[\leadsto \color{blue}{\left(\frac{1}{-2} \cdot \frac{z}{y}\right)} \cdot z \]
      7. metadata-eval71.8%

        \[\leadsto \left(\color{blue}{-0.5} \cdot \frac{z}{y}\right) \cdot z \]
    9. Applied egg-rr71.8%

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

    if 3.10000000000000032e82 < x

    1. Initial program 67.2%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg67.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-out67.2%

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

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg67.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-167.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-out67.2%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative67.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-in67.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-frac67.2%

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine67.2%

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\left(x \cdot x + y \cdot y\right) - z \cdot z}}{y} \]
      3. *-un-lft-identity67.2%

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

        \[\leadsto 0.5 \cdot \frac{1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\sqrt{y} \cdot \sqrt{y}}} \]
      5. times-frac35.4%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{1}{\sqrt{y}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\sqrt{y}}\right)} \]
      6. add-sqr-sqrt35.4%

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

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

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

        \[\leadsto 0.5 \cdot \left(\frac{1}{\sqrt{y}} \cdot \frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - \color{blue}{{z}^{2}}}{\sqrt{y}}\right) \]
    6. Applied egg-rr35.4%

      \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{1}{\sqrt{y}} \cdot \frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}{\sqrt{y}}\right)} \]
    7. Step-by-step derivation
      1. associate-*l/35.4%

        \[\leadsto 0.5 \cdot \color{blue}{\frac{1 \cdot \frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}{\sqrt{y}}}{\sqrt{y}}} \]
      2. *-lft-identity35.4%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}{\sqrt{y}}}}{\sqrt{y}} \]
      3. div-sub33.7%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}{\sqrt{y}} - \frac{{z}^{2}}{\sqrt{y}}}}{\sqrt{y}} \]
      4. +-rgt-identity33.7%

        \[\leadsto 0.5 \cdot \frac{\frac{\color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} + 0}}{\sqrt{y}} - \frac{{z}^{2}}{\sqrt{y}}}{\sqrt{y}} \]
      5. div-sub35.4%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\frac{\left({\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} + 0\right) - {z}^{2}}{\sqrt{y}}}}{\sqrt{y}} \]
      6. +-rgt-identity35.4%

        \[\leadsto 0.5 \cdot \frac{\frac{\color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}} - {z}^{2}}{\sqrt{y}}}{\sqrt{y}} \]
      7. hypot-undefine35.4%

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\frac{{\color{blue}{\left(\mathsf{hypot}\left(y, x\right)\right)}}^{2} - {z}^{2}}{\sqrt{y}}}{\sqrt{y}} \]
    8. Simplified35.4%

      \[\leadsto 0.5 \cdot \color{blue}{\frac{\frac{{\left(\mathsf{hypot}\left(y, x\right)\right)}^{2} - {z}^{2}}{\sqrt{y}}}{\sqrt{y}}} \]
    9. Taylor expanded in x around inf 33.6%

      \[\leadsto 0.5 \cdot \frac{\frac{\color{blue}{{x}^{2}}}{\sqrt{y}}}{\sqrt{y}} \]
    10. Step-by-step derivation
      1. associate-/l/33.6%

        \[\leadsto 0.5 \cdot \color{blue}{\frac{{x}^{2}}{\sqrt{y} \cdot \sqrt{y}}} \]
      2. unpow233.6%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x}}{\sqrt{y} \cdot \sqrt{y}} \]
      3. add-sqr-sqrt60.5%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 3.6 \cdot 10^{-149}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 1.02 \cdot 10^{-53}:\\ \;\;\;\;z \cdot \left(\frac{z}{y} \cdot -0.5\right)\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{+82}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{x}{y}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 42.7% accurate, 0.7× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;x \leq 3.3 \cdot 10^{-152}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{-55}:\\ \;\;\;\;\frac{z}{y\_m \cdot \frac{-2}{z}}\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{+82}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{x}{y\_m}\right)\\ \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
 :precision binary64
 (*
  y_s
  (if (<= x 3.3e-152)
    (* y_m 0.5)
    (if (<= x 4.5e-55)
      (/ z (* y_m (/ -2.0 z)))
      (if (<= x 3.6e+82) (* y_m 0.5) (* 0.5 (* x (/ x y_m))))))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (x <= 3.3e-152) {
		tmp = y_m * 0.5;
	} else if (x <= 4.5e-55) {
		tmp = z / (y_m * (-2.0 / z));
	} else if (x <= 3.6e+82) {
		tmp = y_m * 0.5;
	} else {
		tmp = 0.5 * (x * (x / y_m));
	}
	return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= 3.3d-152) then
        tmp = y_m * 0.5d0
    else if (x <= 4.5d-55) then
        tmp = z / (y_m * ((-2.0d0) / z))
    else if (x <= 3.6d+82) then
        tmp = y_m * 0.5d0
    else
        tmp = 0.5d0 * (x * (x / y_m))
    end if
    code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (x <= 3.3e-152) {
		tmp = y_m * 0.5;
	} else if (x <= 4.5e-55) {
		tmp = z / (y_m * (-2.0 / z));
	} else if (x <= 3.6e+82) {
		tmp = y_m * 0.5;
	} else {
		tmp = 0.5 * (x * (x / y_m));
	}
	return y_s * tmp;
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	tmp = 0
	if x <= 3.3e-152:
		tmp = y_m * 0.5
	elif x <= 4.5e-55:
		tmp = z / (y_m * (-2.0 / z))
	elif x <= 3.6e+82:
		tmp = y_m * 0.5
	else:
		tmp = 0.5 * (x * (x / y_m))
	return y_s * tmp
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (x <= 3.3e-152)
		tmp = Float64(y_m * 0.5);
	elseif (x <= 4.5e-55)
		tmp = Float64(z / Float64(y_m * Float64(-2.0 / z)));
	elseif (x <= 3.6e+82)
		tmp = Float64(y_m * 0.5);
	else
		tmp = Float64(0.5 * Float64(x * Float64(x / y_m)));
	end
	return Float64(y_s * tmp)
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	tmp = 0.0;
	if (x <= 3.3e-152)
		tmp = y_m * 0.5;
	elseif (x <= 4.5e-55)
		tmp = z / (y_m * (-2.0 / z));
	elseif (x <= 3.6e+82)
		tmp = y_m * 0.5;
	else
		tmp = 0.5 * (x * (x / y_m));
	end
	tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[x, 3.3e-152], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[x, 4.5e-55], N[(z / N[(y$95$m * N[(-2.0 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.6e+82], N[(y$95$m * 0.5), $MachinePrecision], N[(0.5 * N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 3.3 \cdot 10^{-152}:\\
\;\;\;\;y\_m \cdot 0.5\\

\mathbf{elif}\;x \leq 4.5 \cdot 10^{-55}:\\
\;\;\;\;\frac{z}{y\_m \cdot \frac{-2}{z}}\\

\mathbf{elif}\;x \leq 3.6 \cdot 10^{+82}:\\
\;\;\;\;y\_m \cdot 0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 3.29999999999999998e-152 or 4.4999999999999997e-55 < x < 3.60000000000000014e82

    1. Initial program 67.5%

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

      \[\leadsto \color{blue}{0.5 \cdot y} \]
    4. Step-by-step derivation
      1. *-commutative42.2%

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified42.2%

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

    if 3.29999999999999998e-152 < x < 4.4999999999999997e-55

    1. Initial program 77.8%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num77.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\frac{\color{blue}{\frac{y}{-0.5}}}{{z}^{2}}\right)}^{-1} \]
      4. unpow267.6%

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

        \[\leadsto {\color{blue}{\left(\frac{\frac{\frac{y}{-0.5}}{z}}{z}\right)}}^{-1} \]
      6. div-inv71.7%

        \[\leadsto {\left(\frac{\frac{\color{blue}{y \cdot \frac{1}{-0.5}}}{z}}{z}\right)}^{-1} \]
      7. metadata-eval71.7%

        \[\leadsto {\left(\frac{\frac{y \cdot \color{blue}{-2}}{z}}{z}\right)}^{-1} \]
    7. Applied egg-rr71.7%

      \[\leadsto {\color{blue}{\left(\frac{\frac{y \cdot -2}{z}}{z}\right)}}^{-1} \]
    8. Step-by-step derivation
      1. unpow-171.7%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{y \cdot -2}{z}}{z}}} \]
      2. clear-num71.9%

        \[\leadsto \color{blue}{\frac{z}{\frac{y \cdot -2}{z}}} \]
      3. associate-/l*71.8%

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

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

    if 3.60000000000000014e82 < x

    1. Initial program 67.2%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg67.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-out67.2%

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

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg67.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-167.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-out67.2%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative67.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-in67.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-frac67.2%

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine67.2%

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\left(x \cdot x + y \cdot y\right) - z \cdot z}}{y} \]
      3. *-un-lft-identity67.2%

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

        \[\leadsto 0.5 \cdot \frac{1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\sqrt{y} \cdot \sqrt{y}}} \]
      5. times-frac35.4%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{1}{\sqrt{y}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\sqrt{y}}\right)} \]
      6. add-sqr-sqrt35.4%

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

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

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

        \[\leadsto 0.5 \cdot \left(\frac{1}{\sqrt{y}} \cdot \frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - \color{blue}{{z}^{2}}}{\sqrt{y}}\right) \]
    6. Applied egg-rr35.4%

      \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{1}{\sqrt{y}} \cdot \frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}{\sqrt{y}}\right)} \]
    7. Step-by-step derivation
      1. associate-*l/35.4%

        \[\leadsto 0.5 \cdot \color{blue}{\frac{1 \cdot \frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}{\sqrt{y}}}{\sqrt{y}}} \]
      2. *-lft-identity35.4%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}{\sqrt{y}}}}{\sqrt{y}} \]
      3. div-sub33.7%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}{\sqrt{y}} - \frac{{z}^{2}}{\sqrt{y}}}}{\sqrt{y}} \]
      4. +-rgt-identity33.7%

        \[\leadsto 0.5 \cdot \frac{\frac{\color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} + 0}}{\sqrt{y}} - \frac{{z}^{2}}{\sqrt{y}}}{\sqrt{y}} \]
      5. div-sub35.4%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\frac{\left({\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} + 0\right) - {z}^{2}}{\sqrt{y}}}}{\sqrt{y}} \]
      6. +-rgt-identity35.4%

        \[\leadsto 0.5 \cdot \frac{\frac{\color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}} - {z}^{2}}{\sqrt{y}}}{\sqrt{y}} \]
      7. hypot-undefine35.4%

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\frac{{\color{blue}{\left(\mathsf{hypot}\left(y, x\right)\right)}}^{2} - {z}^{2}}{\sqrt{y}}}{\sqrt{y}} \]
    8. Simplified35.4%

      \[\leadsto 0.5 \cdot \color{blue}{\frac{\frac{{\left(\mathsf{hypot}\left(y, x\right)\right)}^{2} - {z}^{2}}{\sqrt{y}}}{\sqrt{y}}} \]
    9. Taylor expanded in x around inf 33.6%

      \[\leadsto 0.5 \cdot \frac{\frac{\color{blue}{{x}^{2}}}{\sqrt{y}}}{\sqrt{y}} \]
    10. Step-by-step derivation
      1. associate-/l/33.6%

        \[\leadsto 0.5 \cdot \color{blue}{\frac{{x}^{2}}{\sqrt{y} \cdot \sqrt{y}}} \]
      2. unpow233.6%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x}}{\sqrt{y} \cdot \sqrt{y}} \]
      3. add-sqr-sqrt60.5%

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

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

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

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

Alternative 6: 42.7% accurate, 0.7× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;x \leq 3.3 \cdot 10^{-148}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{elif}\;x \leq 3.05 \cdot 10^{-52}:\\ \;\;\;\;\frac{\frac{z}{y\_m}}{\frac{-2}{z}}\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{+82}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{x}{y\_m}\right)\\ \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
 :precision binary64
 (*
  y_s
  (if (<= x 3.3e-148)
    (* y_m 0.5)
    (if (<= x 3.05e-52)
      (/ (/ z y_m) (/ -2.0 z))
      (if (<= x 3.1e+82) (* y_m 0.5) (* 0.5 (* x (/ x y_m))))))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (x <= 3.3e-148) {
		tmp = y_m * 0.5;
	} else if (x <= 3.05e-52) {
		tmp = (z / y_m) / (-2.0 / z);
	} else if (x <= 3.1e+82) {
		tmp = y_m * 0.5;
	} else {
		tmp = 0.5 * (x * (x / y_m));
	}
	return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= 3.3d-148) then
        tmp = y_m * 0.5d0
    else if (x <= 3.05d-52) then
        tmp = (z / y_m) / ((-2.0d0) / z)
    else if (x <= 3.1d+82) then
        tmp = y_m * 0.5d0
    else
        tmp = 0.5d0 * (x * (x / y_m))
    end if
    code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (x <= 3.3e-148) {
		tmp = y_m * 0.5;
	} else if (x <= 3.05e-52) {
		tmp = (z / y_m) / (-2.0 / z);
	} else if (x <= 3.1e+82) {
		tmp = y_m * 0.5;
	} else {
		tmp = 0.5 * (x * (x / y_m));
	}
	return y_s * tmp;
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	tmp = 0
	if x <= 3.3e-148:
		tmp = y_m * 0.5
	elif x <= 3.05e-52:
		tmp = (z / y_m) / (-2.0 / z)
	elif x <= 3.1e+82:
		tmp = y_m * 0.5
	else:
		tmp = 0.5 * (x * (x / y_m))
	return y_s * tmp
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (x <= 3.3e-148)
		tmp = Float64(y_m * 0.5);
	elseif (x <= 3.05e-52)
		tmp = Float64(Float64(z / y_m) / Float64(-2.0 / z));
	elseif (x <= 3.1e+82)
		tmp = Float64(y_m * 0.5);
	else
		tmp = Float64(0.5 * Float64(x * Float64(x / y_m)));
	end
	return Float64(y_s * tmp)
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	tmp = 0.0;
	if (x <= 3.3e-148)
		tmp = y_m * 0.5;
	elseif (x <= 3.05e-52)
		tmp = (z / y_m) / (-2.0 / z);
	elseif (x <= 3.1e+82)
		tmp = y_m * 0.5;
	else
		tmp = 0.5 * (x * (x / y_m));
	end
	tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[x, 3.3e-148], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[x, 3.05e-52], N[(N[(z / y$95$m), $MachinePrecision] / N[(-2.0 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.1e+82], N[(y$95$m * 0.5), $MachinePrecision], N[(0.5 * N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 3.3 \cdot 10^{-148}:\\
\;\;\;\;y\_m \cdot 0.5\\

\mathbf{elif}\;x \leq 3.05 \cdot 10^{-52}:\\
\;\;\;\;\frac{\frac{z}{y\_m}}{\frac{-2}{z}}\\

\mathbf{elif}\;x \leq 3.1 \cdot 10^{+82}:\\
\;\;\;\;y\_m \cdot 0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 3.29999999999999974e-148 or 3.04999999999999995e-52 < x < 3.10000000000000032e82

    1. Initial program 67.5%

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

      \[\leadsto \color{blue}{0.5 \cdot y} \]
    4. Step-by-step derivation
      1. *-commutative42.2%

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified42.2%

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

    if 3.29999999999999974e-148 < x < 3.04999999999999995e-52

    1. Initial program 77.8%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num77.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\frac{\color{blue}{\frac{y}{-0.5}}}{{z}^{2}}\right)}^{-1} \]
      4. unpow267.6%

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

        \[\leadsto {\color{blue}{\left(\frac{\frac{\frac{y}{-0.5}}{z}}{z}\right)}}^{-1} \]
      6. div-inv71.7%

        \[\leadsto {\left(\frac{\frac{\color{blue}{y \cdot \frac{1}{-0.5}}}{z}}{z}\right)}^{-1} \]
      7. metadata-eval71.7%

        \[\leadsto {\left(\frac{\frac{y \cdot \color{blue}{-2}}{z}}{z}\right)}^{-1} \]
    7. Applied egg-rr71.7%

      \[\leadsto {\color{blue}{\left(\frac{\frac{y \cdot -2}{z}}{z}\right)}}^{-1} \]
    8. Step-by-step derivation
      1. unpow-171.7%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{y \cdot -2}{z}}{z}}} \]
      2. clear-num71.9%

        \[\leadsto \color{blue}{\frac{z}{\frac{y \cdot -2}{z}}} \]
      3. associate-/l*71.8%

        \[\leadsto \frac{z}{\color{blue}{y \cdot \frac{-2}{z}}} \]
      4. associate-/r*71.8%

        \[\leadsto \color{blue}{\frac{\frac{z}{y}}{\frac{-2}{z}}} \]
    9. Applied egg-rr71.8%

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

    if 3.10000000000000032e82 < x

    1. Initial program 67.2%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg67.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-out67.2%

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

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg67.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-167.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-out67.2%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative67.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-in67.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-frac67.2%

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine67.2%

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\left(x \cdot x + y \cdot y\right) - z \cdot z}}{y} \]
      3. *-un-lft-identity67.2%

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

        \[\leadsto 0.5 \cdot \frac{1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\sqrt{y} \cdot \sqrt{y}}} \]
      5. times-frac35.4%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{1}{\sqrt{y}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\sqrt{y}}\right)} \]
      6. add-sqr-sqrt35.4%

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

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

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

        \[\leadsto 0.5 \cdot \left(\frac{1}{\sqrt{y}} \cdot \frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - \color{blue}{{z}^{2}}}{\sqrt{y}}\right) \]
    6. Applied egg-rr35.4%

      \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{1}{\sqrt{y}} \cdot \frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}{\sqrt{y}}\right)} \]
    7. Step-by-step derivation
      1. associate-*l/35.4%

        \[\leadsto 0.5 \cdot \color{blue}{\frac{1 \cdot \frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}{\sqrt{y}}}{\sqrt{y}}} \]
      2. *-lft-identity35.4%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}{\sqrt{y}}}}{\sqrt{y}} \]
      3. div-sub33.7%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}{\sqrt{y}} - \frac{{z}^{2}}{\sqrt{y}}}}{\sqrt{y}} \]
      4. +-rgt-identity33.7%

        \[\leadsto 0.5 \cdot \frac{\frac{\color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} + 0}}{\sqrt{y}} - \frac{{z}^{2}}{\sqrt{y}}}{\sqrt{y}} \]
      5. div-sub35.4%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\frac{\left({\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} + 0\right) - {z}^{2}}{\sqrt{y}}}}{\sqrt{y}} \]
      6. +-rgt-identity35.4%

        \[\leadsto 0.5 \cdot \frac{\frac{\color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}} - {z}^{2}}{\sqrt{y}}}{\sqrt{y}} \]
      7. hypot-undefine35.4%

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\frac{{\color{blue}{\left(\mathsf{hypot}\left(y, x\right)\right)}}^{2} - {z}^{2}}{\sqrt{y}}}{\sqrt{y}} \]
    8. Simplified35.4%

      \[\leadsto 0.5 \cdot \color{blue}{\frac{\frac{{\left(\mathsf{hypot}\left(y, x\right)\right)}^{2} - {z}^{2}}{\sqrt{y}}}{\sqrt{y}}} \]
    9. Taylor expanded in x around inf 33.6%

      \[\leadsto 0.5 \cdot \frac{\frac{\color{blue}{{x}^{2}}}{\sqrt{y}}}{\sqrt{y}} \]
    10. Step-by-step derivation
      1. associate-/l/33.6%

        \[\leadsto 0.5 \cdot \color{blue}{\frac{{x}^{2}}{\sqrt{y} \cdot \sqrt{y}}} \]
      2. unpow233.6%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x}}{\sqrt{y} \cdot \sqrt{y}} \]
      3. add-sqr-sqrt60.5%

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

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

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

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

Alternative 7: 42.7% accurate, 0.7× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;x \leq 4.2 \cdot 10^{-152}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{elif}\;x \leq 3.5 \cdot 10^{-53}:\\ \;\;\;\;\frac{z}{\frac{y\_m \cdot \left(-2\right)}{z}}\\ \mathbf{elif}\;x \leq 3.9 \cdot 10^{+82}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{x}{y\_m}\right)\\ \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
 :precision binary64
 (*
  y_s
  (if (<= x 4.2e-152)
    (* y_m 0.5)
    (if (<= x 3.5e-53)
      (/ z (/ (* y_m (- 2.0)) z))
      (if (<= x 3.9e+82) (* y_m 0.5) (* 0.5 (* x (/ x y_m))))))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (x <= 4.2e-152) {
		tmp = y_m * 0.5;
	} else if (x <= 3.5e-53) {
		tmp = z / ((y_m * -2.0) / z);
	} else if (x <= 3.9e+82) {
		tmp = y_m * 0.5;
	} else {
		tmp = 0.5 * (x * (x / y_m));
	}
	return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= 4.2d-152) then
        tmp = y_m * 0.5d0
    else if (x <= 3.5d-53) then
        tmp = z / ((y_m * -2.0d0) / z)
    else if (x <= 3.9d+82) then
        tmp = y_m * 0.5d0
    else
        tmp = 0.5d0 * (x * (x / y_m))
    end if
    code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (x <= 4.2e-152) {
		tmp = y_m * 0.5;
	} else if (x <= 3.5e-53) {
		tmp = z / ((y_m * -2.0) / z);
	} else if (x <= 3.9e+82) {
		tmp = y_m * 0.5;
	} else {
		tmp = 0.5 * (x * (x / y_m));
	}
	return y_s * tmp;
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	tmp = 0
	if x <= 4.2e-152:
		tmp = y_m * 0.5
	elif x <= 3.5e-53:
		tmp = z / ((y_m * -2.0) / z)
	elif x <= 3.9e+82:
		tmp = y_m * 0.5
	else:
		tmp = 0.5 * (x * (x / y_m))
	return y_s * tmp
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (x <= 4.2e-152)
		tmp = Float64(y_m * 0.5);
	elseif (x <= 3.5e-53)
		tmp = Float64(z / Float64(Float64(y_m * Float64(-2.0)) / z));
	elseif (x <= 3.9e+82)
		tmp = Float64(y_m * 0.5);
	else
		tmp = Float64(0.5 * Float64(x * Float64(x / y_m)));
	end
	return Float64(y_s * tmp)
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	tmp = 0.0;
	if (x <= 4.2e-152)
		tmp = y_m * 0.5;
	elseif (x <= 3.5e-53)
		tmp = z / ((y_m * -2.0) / z);
	elseif (x <= 3.9e+82)
		tmp = y_m * 0.5;
	else
		tmp = 0.5 * (x * (x / y_m));
	end
	tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[x, 4.2e-152], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[x, 3.5e-53], N[(z / N[(N[(y$95$m * (-2.0)), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.9e+82], N[(y$95$m * 0.5), $MachinePrecision], N[(0.5 * N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 4.2 \cdot 10^{-152}:\\
\;\;\;\;y\_m \cdot 0.5\\

\mathbf{elif}\;x \leq 3.5 \cdot 10^{-53}:\\
\;\;\;\;\frac{z}{\frac{y\_m \cdot \left(-2\right)}{z}}\\

\mathbf{elif}\;x \leq 3.9 \cdot 10^{+82}:\\
\;\;\;\;y\_m \cdot 0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 4.19999999999999998e-152 or 3.49999999999999993e-53 < x < 3.89999999999999976e82

    1. Initial program 67.5%

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

      \[\leadsto \color{blue}{0.5 \cdot y} \]
    4. Step-by-step derivation
      1. *-commutative42.2%

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified42.2%

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

    if 4.19999999999999998e-152 < x < 3.49999999999999993e-53

    1. Initial program 77.8%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num77.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\frac{\color{blue}{\frac{y}{-0.5}}}{{z}^{2}}\right)}^{-1} \]
      4. unpow267.6%

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

        \[\leadsto {\color{blue}{\left(\frac{\frac{\frac{y}{-0.5}}{z}}{z}\right)}}^{-1} \]
      6. div-inv71.7%

        \[\leadsto {\left(\frac{\frac{\color{blue}{y \cdot \frac{1}{-0.5}}}{z}}{z}\right)}^{-1} \]
      7. metadata-eval71.7%

        \[\leadsto {\left(\frac{\frac{y \cdot \color{blue}{-2}}{z}}{z}\right)}^{-1} \]
    7. Applied egg-rr71.7%

      \[\leadsto {\color{blue}{\left(\frac{\frac{y \cdot -2}{z}}{z}\right)}}^{-1} \]
    8. Step-by-step derivation
      1. unpow-171.7%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{y \cdot -2}{z}}{z}}} \]
      2. clear-num71.9%

        \[\leadsto \color{blue}{\frac{z}{\frac{y \cdot -2}{z}}} \]
      3. frac-2neg71.9%

        \[\leadsto \color{blue}{\frac{-z}{-\frac{y \cdot -2}{z}}} \]
      4. distribute-neg-frac71.9%

        \[\leadsto \frac{-z}{\color{blue}{\frac{-y \cdot -2}{z}}} \]
      5. distribute-rgt-neg-in71.9%

        \[\leadsto \frac{-z}{\frac{\color{blue}{y \cdot \left(--2\right)}}{z}} \]
      6. metadata-eval71.9%

        \[\leadsto \frac{-z}{\frac{y \cdot \color{blue}{2}}{z}} \]
    9. Applied egg-rr71.9%

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

    if 3.89999999999999976e82 < x

    1. Initial program 67.2%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg67.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-out67.2%

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

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg67.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-167.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-out67.2%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative67.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-in67.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-frac67.2%

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine67.2%

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\left(x \cdot x + y \cdot y\right) - z \cdot z}}{y} \]
      3. *-un-lft-identity67.2%

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

        \[\leadsto 0.5 \cdot \frac{1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\sqrt{y} \cdot \sqrt{y}}} \]
      5. times-frac35.4%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{1}{\sqrt{y}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\sqrt{y}}\right)} \]
      6. add-sqr-sqrt35.4%

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

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

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

        \[\leadsto 0.5 \cdot \left(\frac{1}{\sqrt{y}} \cdot \frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - \color{blue}{{z}^{2}}}{\sqrt{y}}\right) \]
    6. Applied egg-rr35.4%

      \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{1}{\sqrt{y}} \cdot \frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}{\sqrt{y}}\right)} \]
    7. Step-by-step derivation
      1. associate-*l/35.4%

        \[\leadsto 0.5 \cdot \color{blue}{\frac{1 \cdot \frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}{\sqrt{y}}}{\sqrt{y}}} \]
      2. *-lft-identity35.4%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}{\sqrt{y}}}}{\sqrt{y}} \]
      3. div-sub33.7%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}{\sqrt{y}} - \frac{{z}^{2}}{\sqrt{y}}}}{\sqrt{y}} \]
      4. +-rgt-identity33.7%

        \[\leadsto 0.5 \cdot \frac{\frac{\color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} + 0}}{\sqrt{y}} - \frac{{z}^{2}}{\sqrt{y}}}{\sqrt{y}} \]
      5. div-sub35.4%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\frac{\left({\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} + 0\right) - {z}^{2}}{\sqrt{y}}}}{\sqrt{y}} \]
      6. +-rgt-identity35.4%

        \[\leadsto 0.5 \cdot \frac{\frac{\color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}} - {z}^{2}}{\sqrt{y}}}{\sqrt{y}} \]
      7. hypot-undefine35.4%

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\frac{{\color{blue}{\left(\mathsf{hypot}\left(y, x\right)\right)}}^{2} - {z}^{2}}{\sqrt{y}}}{\sqrt{y}} \]
    8. Simplified35.4%

      \[\leadsto 0.5 \cdot \color{blue}{\frac{\frac{{\left(\mathsf{hypot}\left(y, x\right)\right)}^{2} - {z}^{2}}{\sqrt{y}}}{\sqrt{y}}} \]
    9. Taylor expanded in x around inf 33.6%

      \[\leadsto 0.5 \cdot \frac{\frac{\color{blue}{{x}^{2}}}{\sqrt{y}}}{\sqrt{y}} \]
    10. Step-by-step derivation
      1. associate-/l/33.6%

        \[\leadsto 0.5 \cdot \color{blue}{\frac{{x}^{2}}{\sqrt{y} \cdot \sqrt{y}}} \]
      2. unpow233.6%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x}}{\sqrt{y} \cdot \sqrt{y}} \]
      3. add-sqr-sqrt60.5%

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

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

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

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

Alternative 8: 86.1% accurate, 0.7× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;y\_m \leq 1.32 \cdot 10^{+154}:\\ \;\;\;\;\frac{\left(x \cdot x + y\_m \cdot y\_m\right) - z \cdot z}{y\_m \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;y\_m \cdot 0.5\\ \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
 :precision binary64
 (*
  y_s
  (if (<= y_m 1.32e+154)
    (/ (- (+ (* x x) (* y_m y_m)) (* z z)) (* y_m 2.0))
    (* y_m 0.5))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (y_m <= 1.32e+154) {
		tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
	} else {
		tmp = y_m * 0.5;
	}
	return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y_m <= 1.32d+154) then
        tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0d0)
    else
        tmp = y_m * 0.5d0
    end if
    code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (y_m <= 1.32e+154) {
		tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
	} else {
		tmp = y_m * 0.5;
	}
	return y_s * tmp;
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	tmp = 0
	if y_m <= 1.32e+154:
		tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)
	else:
		tmp = y_m * 0.5
	return y_s * tmp
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (y_m <= 1.32e+154)
		tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y_m * y_m)) - Float64(z * z)) / Float64(y_m * 2.0));
	else
		tmp = Float64(y_m * 0.5);
	end
	return Float64(y_s * tmp)
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	tmp = 0.0;
	if (y_m <= 1.32e+154)
		tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
	else
		tmp = y_m * 0.5;
	end
	tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[y$95$m, 1.32e+154], N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y$95$m * y$95$m), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision], N[(y$95$m * 0.5), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

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

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


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

    1. Initial program 75.2%

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

    if 1.31999999999999998e154 < y

    1. Initial program 9.1%

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

      \[\leadsto \color{blue}{0.5 \cdot y} \]
    4. Step-by-step derivation
      1. *-commutative79.1%

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified79.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.32 \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 9: 42.7% accurate, 1.2× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;x \leq 3.2 \cdot 10^{+82}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{x}{y\_m}\right)\\ \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
 :precision binary64
 (* y_s (if (<= x 3.2e+82) (* y_m 0.5) (* 0.5 (* x (/ x y_m))))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (x <= 3.2e+82) {
		tmp = y_m * 0.5;
	} else {
		tmp = 0.5 * (x * (x / y_m));
	}
	return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= 3.2d+82) then
        tmp = y_m * 0.5d0
    else
        tmp = 0.5d0 * (x * (x / y_m))
    end if
    code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (x <= 3.2e+82) {
		tmp = y_m * 0.5;
	} else {
		tmp = 0.5 * (x * (x / y_m));
	}
	return y_s * tmp;
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	tmp = 0
	if x <= 3.2e+82:
		tmp = y_m * 0.5
	else:
		tmp = 0.5 * (x * (x / y_m))
	return y_s * tmp
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (x <= 3.2e+82)
		tmp = Float64(y_m * 0.5);
	else
		tmp = Float64(0.5 * Float64(x * Float64(x / y_m)));
	end
	return Float64(y_s * tmp)
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z)
	tmp = 0.0;
	if (x <= 3.2e+82)
		tmp = y_m * 0.5;
	else
		tmp = 0.5 * (x * (x / y_m));
	end
	tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[x, 3.2e+82], N[(y$95$m * 0.5), $MachinePrecision], N[(0.5 * N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 3.2 \cdot 10^{+82}:\\
\;\;\;\;y\_m \cdot 0.5\\

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


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

    1. Initial program 68.6%

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

      \[\leadsto \color{blue}{0.5 \cdot y} \]
    4. Step-by-step derivation
      1. *-commutative39.9%

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified39.9%

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

    if 3.19999999999999975e82 < x

    1. Initial program 67.2%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg67.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-out67.2%

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

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg67.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-167.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-out67.2%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative67.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-in67.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-frac67.2%

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine67.2%

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\left(x \cdot x + y \cdot y\right) - z \cdot z}}{y} \]
      3. *-un-lft-identity67.2%

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

        \[\leadsto 0.5 \cdot \frac{1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{\sqrt{y} \cdot \sqrt{y}}} \]
      5. times-frac35.4%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{1}{\sqrt{y}} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\sqrt{y}}\right)} \]
      6. add-sqr-sqrt35.4%

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

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

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

        \[\leadsto 0.5 \cdot \left(\frac{1}{\sqrt{y}} \cdot \frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - \color{blue}{{z}^{2}}}{\sqrt{y}}\right) \]
    6. Applied egg-rr35.4%

      \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{1}{\sqrt{y}} \cdot \frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}{\sqrt{y}}\right)} \]
    7. Step-by-step derivation
      1. associate-*l/35.4%

        \[\leadsto 0.5 \cdot \color{blue}{\frac{1 \cdot \frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}{\sqrt{y}}}{\sqrt{y}}} \]
      2. *-lft-identity35.4%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}{\sqrt{y}}}}{\sqrt{y}} \]
      3. div-sub33.7%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\frac{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}{\sqrt{y}} - \frac{{z}^{2}}{\sqrt{y}}}}{\sqrt{y}} \]
      4. +-rgt-identity33.7%

        \[\leadsto 0.5 \cdot \frac{\frac{\color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} + 0}}{\sqrt{y}} - \frac{{z}^{2}}{\sqrt{y}}}{\sqrt{y}} \]
      5. div-sub35.4%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\frac{\left({\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} + 0\right) - {z}^{2}}{\sqrt{y}}}}{\sqrt{y}} \]
      6. +-rgt-identity35.4%

        \[\leadsto 0.5 \cdot \frac{\frac{\color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}} - {z}^{2}}{\sqrt{y}}}{\sqrt{y}} \]
      7. hypot-undefine35.4%

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\frac{{\color{blue}{\left(\mathsf{hypot}\left(y, x\right)\right)}}^{2} - {z}^{2}}{\sqrt{y}}}{\sqrt{y}} \]
    8. Simplified35.4%

      \[\leadsto 0.5 \cdot \color{blue}{\frac{\frac{{\left(\mathsf{hypot}\left(y, x\right)\right)}^{2} - {z}^{2}}{\sqrt{y}}}{\sqrt{y}}} \]
    9. Taylor expanded in x around inf 33.6%

      \[\leadsto 0.5 \cdot \frac{\frac{\color{blue}{{x}^{2}}}{\sqrt{y}}}{\sqrt{y}} \]
    10. Step-by-step derivation
      1. associate-/l/33.6%

        \[\leadsto 0.5 \cdot \color{blue}{\frac{{x}^{2}}{\sqrt{y} \cdot \sqrt{y}}} \]
      2. unpow233.6%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x}}{\sqrt{y} \cdot \sqrt{y}} \]
      3. add-sqr-sqrt60.5%

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

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

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

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

Alternative 10: 33.2% accurate, 5.0× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \left(y\_m \cdot 0.5\right) \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z) :precision binary64 (* y_s (* y_m 0.5)))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	return y_s * (y_m * 0.5);
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    code = y_s * (y_m * 0.5d0)
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	return y_s * (y_m * 0.5);
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	return y_s * (y_m * 0.5)
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	return Float64(y_s * Float64(y_m * 0.5))
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp = code(y_s, x, y_m, z)
	tmp = y_s * (y_m * 0.5);
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * N[(y$95$m * 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
y\_s \cdot \left(y\_m \cdot 0.5\right)
\end{array}
Derivation
  1. Initial program 68.3%

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

    \[\leadsto \color{blue}{0.5 \cdot y} \]
  4. Step-by-step derivation
    1. *-commutative34.2%

      \[\leadsto \color{blue}{y \cdot 0.5} \]
  5. Simplified34.2%

    \[\leadsto \color{blue}{y \cdot 0.5} \]
  6. Final simplification34.2%

    \[\leadsto y \cdot 0.5 \]
  7. Add Preprocessing

Developer target: 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 2024084 
(FPCore (x y z)
  :name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
  :precision binary64

  :alt
  (- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x)))

  (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))