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

Percentage Accurate: 69.0% → 97.7%
Time: 11.1s
Alternatives: 12
Speedup: 0.9×

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 12 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 69.0% 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: 97.7% accurate, 0.6× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := \left(x + z\_m\right) \cdot \frac{x - z\_m}{y\_m}\\ y\_s \cdot \begin{array}{l} \mathbf{if}\;y\_m \leq 6.4 \cdot 10^{-96}:\\ \;\;\;\;0.5 \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;y\_m \cdot \left(0.5 + 0.5 \cdot \frac{1}{\frac{y\_m}{t\_0}}\right)\\ \end{array} \end{array} \end{array} \]
z_m = (fabs.f64 z)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z_m)
 :precision binary64
 (let* ((t_0 (* (+ x z_m) (/ (- x z_m) y_m))))
   (*
    y_s
    (if (<= y_m 6.4e-96)
      (* 0.5 t_0)
      (* y_m (+ 0.5 (* 0.5 (/ 1.0 (/ y_m t_0)))))))))
z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
	double t_0 = (x + z_m) * ((x - z_m) / y_m);
	double tmp;
	if (y_m <= 6.4e-96) {
		tmp = 0.5 * t_0;
	} else {
		tmp = y_m * (0.5 + (0.5 * (1.0 / (y_m / t_0))));
	}
	return y_s * tmp;
}
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z_m)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (x + z_m) * ((x - z_m) / y_m)
    if (y_m <= 6.4d-96) then
        tmp = 0.5d0 * t_0
    else
        tmp = y_m * (0.5d0 + (0.5d0 * (1.0d0 / (y_m / t_0))))
    end if
    code = y_s * tmp
end function
z_m = Math.abs(z);
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_m) {
	double t_0 = (x + z_m) * ((x - z_m) / y_m);
	double tmp;
	if (y_m <= 6.4e-96) {
		tmp = 0.5 * t_0;
	} else {
		tmp = y_m * (0.5 + (0.5 * (1.0 / (y_m / t_0))));
	}
	return y_s * tmp;
}
z_m = math.fabs(z)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z_m):
	t_0 = (x + z_m) * ((x - z_m) / y_m)
	tmp = 0
	if y_m <= 6.4e-96:
		tmp = 0.5 * t_0
	else:
		tmp = y_m * (0.5 + (0.5 * (1.0 / (y_m / t_0))))
	return y_s * tmp
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z_m)
	t_0 = Float64(Float64(x + z_m) * Float64(Float64(x - z_m) / y_m))
	tmp = 0.0
	if (y_m <= 6.4e-96)
		tmp = Float64(0.5 * t_0);
	else
		tmp = Float64(y_m * Float64(0.5 + Float64(0.5 * Float64(1.0 / Float64(y_m / t_0)))));
	end
	return Float64(y_s * tmp)
end
z_m = abs(z);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z_m)
	t_0 = (x + z_m) * ((x - z_m) / y_m);
	tmp = 0.0;
	if (y_m <= 6.4e-96)
		tmp = 0.5 * t_0;
	else
		tmp = y_m * (0.5 + (0.5 * (1.0 / (y_m / t_0))));
	end
	tmp_2 = y_s * tmp;
end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := Block[{t$95$0 = N[(N[(x + z$95$m), $MachinePrecision] * N[(N[(x - z$95$m), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[y$95$m, 6.4e-96], N[(0.5 * t$95$0), $MachinePrecision], N[(y$95$m * N[(0.5 + N[(0.5 * N[(1.0 / N[(y$95$m / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
\begin{array}{l}
t_0 := \left(x + z\_m\right) \cdot \frac{x - z\_m}{y\_m}\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 6.4 \cdot 10^{-96}:\\
\;\;\;\;0.5 \cdot t\_0\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 6.40000000000000023e-96

    1. Initial program 78.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{\left(x + z\right) \cdot \left(x - z\right)}{y}} \]
    9. Step-by-step derivation
      1. associate-/l*68.2%

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

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

    if 6.40000000000000023e-96 < y

    1. Initial program 60.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto y \cdot \left(0.5 + 0.5 \cdot \color{blue}{\left(\frac{x - z}{y} \cdot \frac{x + z}{y}\right)}\right) \]
    9. Applied egg-rr98.7%

      \[\leadsto y \cdot \left(0.5 + 0.5 \cdot \color{blue}{\left(\frac{x - z}{y} \cdot \frac{x + z}{y}\right)}\right) \]
    10. Step-by-step derivation
      1. associate-*r/98.8%

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

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

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

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

Alternative 2: 95.1% accurate, 0.3× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := \frac{\left(x \cdot x + y\_m \cdot y\_m\right) - z\_m \cdot z\_m}{y\_m \cdot 2}\\ y\_s \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq 0:\\ \;\;\;\;0.5 \cdot \left(\left(x + z\_m\right) \cdot \frac{x - z\_m}{y\_m}\right)\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+302}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;y\_m \cdot \left(0.5 + 0.5 \cdot \left(\frac{x + z\_m}{y\_m} \cdot \frac{x}{y\_m}\right)\right)\\ \end{array} \end{array} \end{array} \]
z_m = (fabs.f64 z)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z_m)
 :precision binary64
 (let* ((t_0 (/ (- (+ (* x x) (* y_m y_m)) (* z_m z_m)) (* y_m 2.0))))
   (*
    y_s
    (if (<= t_0 0.0)
      (* 0.5 (* (+ x z_m) (/ (- x z_m) y_m)))
      (if (<= t_0 5e+302)
        t_0
        (* y_m (+ 0.5 (* 0.5 (* (/ (+ x z_m) y_m) (/ x y_m))))))))))
z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
	double t_0 = (((x * x) + (y_m * y_m)) - (z_m * z_m)) / (y_m * 2.0);
	double tmp;
	if (t_0 <= 0.0) {
		tmp = 0.5 * ((x + z_m) * ((x - z_m) / y_m));
	} else if (t_0 <= 5e+302) {
		tmp = t_0;
	} else {
		tmp = y_m * (0.5 + (0.5 * (((x + z_m) / y_m) * (x / y_m))));
	}
	return y_s * tmp;
}
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z_m)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (((x * x) + (y_m * y_m)) - (z_m * z_m)) / (y_m * 2.0d0)
    if (t_0 <= 0.0d0) then
        tmp = 0.5d0 * ((x + z_m) * ((x - z_m) / y_m))
    else if (t_0 <= 5d+302) then
        tmp = t_0
    else
        tmp = y_m * (0.5d0 + (0.5d0 * (((x + z_m) / y_m) * (x / y_m))))
    end if
    code = y_s * tmp
end function
z_m = Math.abs(z);
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_m) {
	double t_0 = (((x * x) + (y_m * y_m)) - (z_m * z_m)) / (y_m * 2.0);
	double tmp;
	if (t_0 <= 0.0) {
		tmp = 0.5 * ((x + z_m) * ((x - z_m) / y_m));
	} else if (t_0 <= 5e+302) {
		tmp = t_0;
	} else {
		tmp = y_m * (0.5 + (0.5 * (((x + z_m) / y_m) * (x / y_m))));
	}
	return y_s * tmp;
}
z_m = math.fabs(z)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z_m):
	t_0 = (((x * x) + (y_m * y_m)) - (z_m * z_m)) / (y_m * 2.0)
	tmp = 0
	if t_0 <= 0.0:
		tmp = 0.5 * ((x + z_m) * ((x - z_m) / y_m))
	elif t_0 <= 5e+302:
		tmp = t_0
	else:
		tmp = y_m * (0.5 + (0.5 * (((x + z_m) / y_m) * (x / y_m))))
	return y_s * tmp
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z_m)
	t_0 = Float64(Float64(Float64(Float64(x * x) + Float64(y_m * y_m)) - Float64(z_m * z_m)) / Float64(y_m * 2.0))
	tmp = 0.0
	if (t_0 <= 0.0)
		tmp = Float64(0.5 * Float64(Float64(x + z_m) * Float64(Float64(x - z_m) / y_m)));
	elseif (t_0 <= 5e+302)
		tmp = t_0;
	else
		tmp = Float64(y_m * Float64(0.5 + Float64(0.5 * Float64(Float64(Float64(x + z_m) / y_m) * Float64(x / y_m)))));
	end
	return Float64(y_s * tmp)
end
z_m = abs(z);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z_m)
	t_0 = (((x * x) + (y_m * y_m)) - (z_m * z_m)) / (y_m * 2.0);
	tmp = 0.0;
	if (t_0 <= 0.0)
		tmp = 0.5 * ((x + z_m) * ((x - z_m) / y_m));
	elseif (t_0 <= 5e+302)
		tmp = t_0;
	else
		tmp = y_m * (0.5 + (0.5 * (((x + z_m) / y_m) * (x / y_m))));
	end
	tmp_2 = y_s * tmp;
end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := Block[{t$95$0 = N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y$95$m * y$95$m), $MachinePrecision]), $MachinePrecision] - N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[t$95$0, 0.0], N[(0.5 * N[(N[(x + z$95$m), $MachinePrecision] * N[(N[(x - z$95$m), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+302], t$95$0, N[(y$95$m * N[(0.5 + N[(0.5 * N[(N[(N[(x + z$95$m), $MachinePrecision] / y$95$m), $MachinePrecision] * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
\begin{array}{l}
t_0 := \frac{\left(x \cdot x + y\_m \cdot y\_m\right) - z\_m \cdot z\_m}{y\_m \cdot 2}\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;0.5 \cdot \left(\left(x + z\_m\right) \cdot \frac{x - z\_m}{y\_m}\right)\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+302}:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 78.4%

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

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

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

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

        \[\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-178.4%

        \[\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-out78.4%

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

        \[\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-in78.4%

        \[\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-frac78.4%

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified78.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. Taylor expanded in y around inf 82.7%

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{\left(x + z\right) \cdot \left(x - z\right)}{y}} \]
    9. Step-by-step derivation
      1. associate-/l*58.4%

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

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

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

    1. Initial program 99.8%

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

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

    1. Initial program 53.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto y \cdot \left(0.5 + 0.5 \cdot \color{blue}{\left(\frac{x - z}{y} \cdot \frac{x + z}{y}\right)}\right) \]
    9. Applied egg-rr99.0%

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

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

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

Alternative 3: 50.9% accurate, 0.5× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;z\_m \cdot z\_m \leq 5 \cdot 10^{-289}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{elif}\;z\_m \cdot z\_m \leq 2 \cdot 10^{-187}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot \left(x + z\_m\right)}{y\_m}\\ \mathbf{elif}\;z\_m \cdot z\_m \leq 2 \cdot 10^{+277}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{\frac{-1}{z\_m} \cdot \frac{y\_m}{z\_m}}\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z_m)
 :precision binary64
 (*
  y_s
  (if (<= (* z_m z_m) 5e-289)
    (* y_m 0.5)
    (if (<= (* z_m z_m) 2e-187)
      (* 0.5 (/ (* x (+ x z_m)) y_m))
      (if (<= (* z_m z_m) 2e+277)
        (* y_m 0.5)
        (/ 0.5 (* (/ -1.0 z_m) (/ y_m z_m))))))))
z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
	double tmp;
	if ((z_m * z_m) <= 5e-289) {
		tmp = y_m * 0.5;
	} else if ((z_m * z_m) <= 2e-187) {
		tmp = 0.5 * ((x * (x + z_m)) / y_m);
	} else if ((z_m * z_m) <= 2e+277) {
		tmp = y_m * 0.5;
	} else {
		tmp = 0.5 / ((-1.0 / z_m) * (y_m / z_m));
	}
	return y_s * tmp;
}
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z_m)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if ((z_m * z_m) <= 5d-289) then
        tmp = y_m * 0.5d0
    else if ((z_m * z_m) <= 2d-187) then
        tmp = 0.5d0 * ((x * (x + z_m)) / y_m)
    else if ((z_m * z_m) <= 2d+277) then
        tmp = y_m * 0.5d0
    else
        tmp = 0.5d0 / (((-1.0d0) / z_m) * (y_m / z_m))
    end if
    code = y_s * tmp
end function
z_m = Math.abs(z);
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_m) {
	double tmp;
	if ((z_m * z_m) <= 5e-289) {
		tmp = y_m * 0.5;
	} else if ((z_m * z_m) <= 2e-187) {
		tmp = 0.5 * ((x * (x + z_m)) / y_m);
	} else if ((z_m * z_m) <= 2e+277) {
		tmp = y_m * 0.5;
	} else {
		tmp = 0.5 / ((-1.0 / z_m) * (y_m / z_m));
	}
	return y_s * tmp;
}
z_m = math.fabs(z)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z_m):
	tmp = 0
	if (z_m * z_m) <= 5e-289:
		tmp = y_m * 0.5
	elif (z_m * z_m) <= 2e-187:
		tmp = 0.5 * ((x * (x + z_m)) / y_m)
	elif (z_m * z_m) <= 2e+277:
		tmp = y_m * 0.5
	else:
		tmp = 0.5 / ((-1.0 / z_m) * (y_m / z_m))
	return y_s * tmp
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z_m)
	tmp = 0.0
	if (Float64(z_m * z_m) <= 5e-289)
		tmp = Float64(y_m * 0.5);
	elseif (Float64(z_m * z_m) <= 2e-187)
		tmp = Float64(0.5 * Float64(Float64(x * Float64(x + z_m)) / y_m));
	elseif (Float64(z_m * z_m) <= 2e+277)
		tmp = Float64(y_m * 0.5);
	else
		tmp = Float64(0.5 / Float64(Float64(-1.0 / z_m) * Float64(y_m / z_m)));
	end
	return Float64(y_s * tmp)
end
z_m = abs(z);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z_m)
	tmp = 0.0;
	if ((z_m * z_m) <= 5e-289)
		tmp = y_m * 0.5;
	elseif ((z_m * z_m) <= 2e-187)
		tmp = 0.5 * ((x * (x + z_m)) / y_m);
	elseif ((z_m * z_m) <= 2e+277)
		tmp = y_m * 0.5;
	else
		tmp = 0.5 / ((-1.0 / z_m) * (y_m / z_m));
	end
	tmp_2 = y_s * tmp;
end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := N[(y$95$s * If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 5e-289], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 2e-187], N[(0.5 * N[(N[(x * N[(x + z$95$m), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 2e+277], N[(y$95$m * 0.5), $MachinePrecision], N[(0.5 / N[(N[(-1.0 / z$95$m), $MachinePrecision] * N[(y$95$m / z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \cdot z\_m \leq 5 \cdot 10^{-289}:\\
\;\;\;\;y\_m \cdot 0.5\\

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

\mathbf{elif}\;z\_m \cdot z\_m \leq 2 \cdot 10^{+277}:\\
\;\;\;\;y\_m \cdot 0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 z z) < 5.00000000000000029e-289 or 2e-187 < (*.f64 z z) < 2.00000000000000001e277

    1. Initial program 70.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.00000000000000029e-289 < (*.f64 z z) < 2e-187

    1. Initial program 96.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.00000000000000001e277 < (*.f64 z z)

    1. Initial program 68.9%

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

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

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

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

        \[\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-168.9%

        \[\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-out68.9%

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

        \[\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-in68.9%

        \[\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-frac68.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{0.5}{\frac{y}{\color{blue}{\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y}} - z \cdot z}} \]
      6. pow268.9%

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

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

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

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

      \[\leadsto \frac{0.5}{\color{blue}{-1 \cdot \frac{y}{{z}^{2}}}} \]
    8. Step-by-step derivation
      1. associate-*r/74.6%

        \[\leadsto \frac{0.5}{\color{blue}{\frac{-1 \cdot y}{{z}^{2}}}} \]
      2. neg-mul-174.6%

        \[\leadsto \frac{0.5}{\frac{\color{blue}{-y}}{{z}^{2}}} \]
    9. Simplified74.6%

      \[\leadsto \frac{0.5}{\color{blue}{\frac{-y}{{z}^{2}}}} \]
    10. Step-by-step derivation
      1. neg-mul-174.6%

        \[\leadsto \frac{0.5}{\frac{\color{blue}{-1 \cdot y}}{{z}^{2}}} \]
      2. unpow274.6%

        \[\leadsto \frac{0.5}{\frac{-1 \cdot y}{\color{blue}{z \cdot z}}} \]
      3. times-frac78.6%

        \[\leadsto \frac{0.5}{\color{blue}{\frac{-1}{z} \cdot \frac{y}{z}}} \]
    11. Applied egg-rr78.6%

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

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

Alternative 4: 83.7% accurate, 0.5× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := \frac{x - z\_m}{y\_m}\\ y\_s \cdot \begin{array}{l} \mathbf{if}\;z\_m \cdot z\_m \leq 5 \cdot 10^{-66}:\\ \;\;\;\;y\_m \cdot \left(0.5 + 0.5 \cdot \left(\frac{x + z\_m}{y\_m} \cdot \frac{x}{y\_m}\right)\right)\\ \mathbf{elif}\;z\_m \cdot z\_m \leq 10^{+138}:\\ \;\;\;\;0.5 \cdot \left(\left(x + z\_m\right) \cdot t\_0\right)\\ \mathbf{else}:\\ \;\;\;\;y\_m \cdot \left(0.5 + 0.5 \cdot \left(t\_0 \cdot \frac{z\_m}{y\_m}\right)\right)\\ \end{array} \end{array} \end{array} \]
z_m = (fabs.f64 z)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z_m)
 :precision binary64
 (let* ((t_0 (/ (- x z_m) y_m)))
   (*
    y_s
    (if (<= (* z_m z_m) 5e-66)
      (* y_m (+ 0.5 (* 0.5 (* (/ (+ x z_m) y_m) (/ x y_m)))))
      (if (<= (* z_m z_m) 1e+138)
        (* 0.5 (* (+ x z_m) t_0))
        (* y_m (+ 0.5 (* 0.5 (* t_0 (/ z_m y_m))))))))))
z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
	double t_0 = (x - z_m) / y_m;
	double tmp;
	if ((z_m * z_m) <= 5e-66) {
		tmp = y_m * (0.5 + (0.5 * (((x + z_m) / y_m) * (x / y_m))));
	} else if ((z_m * z_m) <= 1e+138) {
		tmp = 0.5 * ((x + z_m) * t_0);
	} else {
		tmp = y_m * (0.5 + (0.5 * (t_0 * (z_m / y_m))));
	}
	return y_s * tmp;
}
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z_m)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (x - z_m) / y_m
    if ((z_m * z_m) <= 5d-66) then
        tmp = y_m * (0.5d0 + (0.5d0 * (((x + z_m) / y_m) * (x / y_m))))
    else if ((z_m * z_m) <= 1d+138) then
        tmp = 0.5d0 * ((x + z_m) * t_0)
    else
        tmp = y_m * (0.5d0 + (0.5d0 * (t_0 * (z_m / y_m))))
    end if
    code = y_s * tmp
end function
z_m = Math.abs(z);
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_m) {
	double t_0 = (x - z_m) / y_m;
	double tmp;
	if ((z_m * z_m) <= 5e-66) {
		tmp = y_m * (0.5 + (0.5 * (((x + z_m) / y_m) * (x / y_m))));
	} else if ((z_m * z_m) <= 1e+138) {
		tmp = 0.5 * ((x + z_m) * t_0);
	} else {
		tmp = y_m * (0.5 + (0.5 * (t_0 * (z_m / y_m))));
	}
	return y_s * tmp;
}
z_m = math.fabs(z)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z_m):
	t_0 = (x - z_m) / y_m
	tmp = 0
	if (z_m * z_m) <= 5e-66:
		tmp = y_m * (0.5 + (0.5 * (((x + z_m) / y_m) * (x / y_m))))
	elif (z_m * z_m) <= 1e+138:
		tmp = 0.5 * ((x + z_m) * t_0)
	else:
		tmp = y_m * (0.5 + (0.5 * (t_0 * (z_m / y_m))))
	return y_s * tmp
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z_m)
	t_0 = Float64(Float64(x - z_m) / y_m)
	tmp = 0.0
	if (Float64(z_m * z_m) <= 5e-66)
		tmp = Float64(y_m * Float64(0.5 + Float64(0.5 * Float64(Float64(Float64(x + z_m) / y_m) * Float64(x / y_m)))));
	elseif (Float64(z_m * z_m) <= 1e+138)
		tmp = Float64(0.5 * Float64(Float64(x + z_m) * t_0));
	else
		tmp = Float64(y_m * Float64(0.5 + Float64(0.5 * Float64(t_0 * Float64(z_m / y_m)))));
	end
	return Float64(y_s * tmp)
end
z_m = abs(z);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z_m)
	t_0 = (x - z_m) / y_m;
	tmp = 0.0;
	if ((z_m * z_m) <= 5e-66)
		tmp = y_m * (0.5 + (0.5 * (((x + z_m) / y_m) * (x / y_m))));
	elseif ((z_m * z_m) <= 1e+138)
		tmp = 0.5 * ((x + z_m) * t_0);
	else
		tmp = y_m * (0.5 + (0.5 * (t_0 * (z_m / y_m))));
	end
	tmp_2 = y_s * tmp;
end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := Block[{t$95$0 = N[(N[(x - z$95$m), $MachinePrecision] / y$95$m), $MachinePrecision]}, N[(y$95$s * If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 5e-66], N[(y$95$m * N[(0.5 + N[(0.5 * N[(N[(N[(x + z$95$m), $MachinePrecision] / y$95$m), $MachinePrecision] * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 1e+138], N[(0.5 * N[(N[(x + z$95$m), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(y$95$m * N[(0.5 + N[(0.5 * N[(t$95$0 * N[(z$95$m / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

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

\mathbf{elif}\;z\_m \cdot z\_m \leq 10^{+138}:\\
\;\;\;\;0.5 \cdot \left(\left(x + z\_m\right) \cdot t\_0\right)\\

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


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

    1. Initial program 72.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto y \cdot \left(0.5 + 0.5 \cdot \color{blue}{\left(\frac{x - z}{y} \cdot \frac{x + z}{y}\right)}\right) \]
    9. Applied egg-rr96.5%

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

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

    if 4.99999999999999962e-66 < (*.f64 z z) < 1e138

    1. Initial program 84.9%

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

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

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

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

        \[\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-184.9%

        \[\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-out84.9%

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

        \[\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-in84.9%

        \[\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-frac84.9%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{\left(x + z\right) \cdot \left(x - z\right)}{y}} \]
    9. Step-by-step derivation
      1. associate-/l*75.2%

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

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

    if 1e138 < (*.f64 z z)

    1. Initial program 67.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto y \cdot \left(0.5 + 0.5 \cdot \color{blue}{\left(\frac{x - z}{y} \cdot \frac{x + z}{y}\right)}\right) \]
    9. Applied egg-rr98.0%

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

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

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

Alternative 5: 48.4% accurate, 0.5× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;z\_m \cdot z\_m \leq 5 \cdot 10^{-289}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{elif}\;z\_m \cdot z\_m \leq 2 \cdot 10^{-187}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot \left(x + z\_m\right)}{y\_m}\\ \mathbf{elif}\;z\_m \cdot z\_m \leq 2 \cdot 10^{+277}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(z\_m \cdot z\_m\right) \cdot -0.5}{y\_m}\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z_m)
 :precision binary64
 (*
  y_s
  (if (<= (* z_m z_m) 5e-289)
    (* y_m 0.5)
    (if (<= (* z_m z_m) 2e-187)
      (* 0.5 (/ (* x (+ x z_m)) y_m))
      (if (<= (* z_m z_m) 2e+277) (* y_m 0.5) (/ (* (* z_m z_m) -0.5) y_m))))))
z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
	double tmp;
	if ((z_m * z_m) <= 5e-289) {
		tmp = y_m * 0.5;
	} else if ((z_m * z_m) <= 2e-187) {
		tmp = 0.5 * ((x * (x + z_m)) / y_m);
	} else if ((z_m * z_m) <= 2e+277) {
		tmp = y_m * 0.5;
	} else {
		tmp = ((z_m * z_m) * -0.5) / y_m;
	}
	return y_s * tmp;
}
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z_m)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if ((z_m * z_m) <= 5d-289) then
        tmp = y_m * 0.5d0
    else if ((z_m * z_m) <= 2d-187) then
        tmp = 0.5d0 * ((x * (x + z_m)) / y_m)
    else if ((z_m * z_m) <= 2d+277) then
        tmp = y_m * 0.5d0
    else
        tmp = ((z_m * z_m) * (-0.5d0)) / y_m
    end if
    code = y_s * tmp
end function
z_m = Math.abs(z);
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_m) {
	double tmp;
	if ((z_m * z_m) <= 5e-289) {
		tmp = y_m * 0.5;
	} else if ((z_m * z_m) <= 2e-187) {
		tmp = 0.5 * ((x * (x + z_m)) / y_m);
	} else if ((z_m * z_m) <= 2e+277) {
		tmp = y_m * 0.5;
	} else {
		tmp = ((z_m * z_m) * -0.5) / y_m;
	}
	return y_s * tmp;
}
z_m = math.fabs(z)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z_m):
	tmp = 0
	if (z_m * z_m) <= 5e-289:
		tmp = y_m * 0.5
	elif (z_m * z_m) <= 2e-187:
		tmp = 0.5 * ((x * (x + z_m)) / y_m)
	elif (z_m * z_m) <= 2e+277:
		tmp = y_m * 0.5
	else:
		tmp = ((z_m * z_m) * -0.5) / y_m
	return y_s * tmp
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z_m)
	tmp = 0.0
	if (Float64(z_m * z_m) <= 5e-289)
		tmp = Float64(y_m * 0.5);
	elseif (Float64(z_m * z_m) <= 2e-187)
		tmp = Float64(0.5 * Float64(Float64(x * Float64(x + z_m)) / y_m));
	elseif (Float64(z_m * z_m) <= 2e+277)
		tmp = Float64(y_m * 0.5);
	else
		tmp = Float64(Float64(Float64(z_m * z_m) * -0.5) / y_m);
	end
	return Float64(y_s * tmp)
end
z_m = abs(z);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z_m)
	tmp = 0.0;
	if ((z_m * z_m) <= 5e-289)
		tmp = y_m * 0.5;
	elseif ((z_m * z_m) <= 2e-187)
		tmp = 0.5 * ((x * (x + z_m)) / y_m);
	elseif ((z_m * z_m) <= 2e+277)
		tmp = y_m * 0.5;
	else
		tmp = ((z_m * z_m) * -0.5) / y_m;
	end
	tmp_2 = y_s * tmp;
end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := N[(y$95$s * If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 5e-289], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 2e-187], N[(0.5 * N[(N[(x * N[(x + z$95$m), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 2e+277], N[(y$95$m * 0.5), $MachinePrecision], N[(N[(N[(z$95$m * z$95$m), $MachinePrecision] * -0.5), $MachinePrecision] / y$95$m), $MachinePrecision]]]]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \cdot z\_m \leq 5 \cdot 10^{-289}:\\
\;\;\;\;y\_m \cdot 0.5\\

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

\mathbf{elif}\;z\_m \cdot z\_m \leq 2 \cdot 10^{+277}:\\
\;\;\;\;y\_m \cdot 0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 z z) < 5.00000000000000029e-289 or 2e-187 < (*.f64 z z) < 2.00000000000000001e277

    1. Initial program 70.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.00000000000000029e-289 < (*.f64 z z) < 2e-187

    1. Initial program 96.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.00000000000000001e277 < (*.f64 z z)

    1. Initial program 68.9%

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

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

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

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

        \[\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-168.9%

        \[\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-out68.9%

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

        \[\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-in68.9%

        \[\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-frac68.9%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{{z}^{2} \cdot -0.5}{y}} \]
    7. Simplified74.6%

      \[\leadsto \color{blue}{\frac{{z}^{2} \cdot -0.5}{y}} \]
    8. Step-by-step derivation
      1. unpow274.6%

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

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

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

Alternative 6: 97.7% accurate, 0.7× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := \frac{x - z\_m}{y\_m}\\ y\_s \cdot \begin{array}{l} \mathbf{if}\;y\_m \leq 4.2 \cdot 10^{-96}:\\ \;\;\;\;0.5 \cdot \left(\left(x + z\_m\right) \cdot t\_0\right)\\ \mathbf{else}:\\ \;\;\;\;y\_m \cdot \left(0.5 + \frac{0.5 \cdot t\_0}{\frac{y\_m}{x + z\_m}}\right)\\ \end{array} \end{array} \end{array} \]
z_m = (fabs.f64 z)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z_m)
 :precision binary64
 (let* ((t_0 (/ (- x z_m) y_m)))
   (*
    y_s
    (if (<= y_m 4.2e-96)
      (* 0.5 (* (+ x z_m) t_0))
      (* y_m (+ 0.5 (/ (* 0.5 t_0) (/ y_m (+ x z_m)))))))))
z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
	double t_0 = (x - z_m) / y_m;
	double tmp;
	if (y_m <= 4.2e-96) {
		tmp = 0.5 * ((x + z_m) * t_0);
	} else {
		tmp = y_m * (0.5 + ((0.5 * t_0) / (y_m / (x + z_m))));
	}
	return y_s * tmp;
}
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z_m)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (x - z_m) / y_m
    if (y_m <= 4.2d-96) then
        tmp = 0.5d0 * ((x + z_m) * t_0)
    else
        tmp = y_m * (0.5d0 + ((0.5d0 * t_0) / (y_m / (x + z_m))))
    end if
    code = y_s * tmp
end function
z_m = Math.abs(z);
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_m) {
	double t_0 = (x - z_m) / y_m;
	double tmp;
	if (y_m <= 4.2e-96) {
		tmp = 0.5 * ((x + z_m) * t_0);
	} else {
		tmp = y_m * (0.5 + ((0.5 * t_0) / (y_m / (x + z_m))));
	}
	return y_s * tmp;
}
z_m = math.fabs(z)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z_m):
	t_0 = (x - z_m) / y_m
	tmp = 0
	if y_m <= 4.2e-96:
		tmp = 0.5 * ((x + z_m) * t_0)
	else:
		tmp = y_m * (0.5 + ((0.5 * t_0) / (y_m / (x + z_m))))
	return y_s * tmp
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z_m)
	t_0 = Float64(Float64(x - z_m) / y_m)
	tmp = 0.0
	if (y_m <= 4.2e-96)
		tmp = Float64(0.5 * Float64(Float64(x + z_m) * t_0));
	else
		tmp = Float64(y_m * Float64(0.5 + Float64(Float64(0.5 * t_0) / Float64(y_m / Float64(x + z_m)))));
	end
	return Float64(y_s * tmp)
end
z_m = abs(z);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z_m)
	t_0 = (x - z_m) / y_m;
	tmp = 0.0;
	if (y_m <= 4.2e-96)
		tmp = 0.5 * ((x + z_m) * t_0);
	else
		tmp = y_m * (0.5 + ((0.5 * t_0) / (y_m / (x + z_m))));
	end
	tmp_2 = y_s * tmp;
end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := Block[{t$95$0 = N[(N[(x - z$95$m), $MachinePrecision] / y$95$m), $MachinePrecision]}, N[(y$95$s * If[LessEqual[y$95$m, 4.2e-96], N[(0.5 * N[(N[(x + z$95$m), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(y$95$m * N[(0.5 + N[(N[(0.5 * t$95$0), $MachinePrecision] / N[(y$95$m / N[(x + z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
\begin{array}{l}
t_0 := \frac{x - z\_m}{y\_m}\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 4.2 \cdot 10^{-96}:\\
\;\;\;\;0.5 \cdot \left(\left(x + z\_m\right) \cdot t\_0\right)\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 4.20000000000000002e-96

    1. Initial program 78.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{\left(x + z\right) \cdot \left(x - z\right)}{y}} \]
    9. Step-by-step derivation
      1. associate-/l*68.2%

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

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

    if 4.20000000000000002e-96 < y

    1. Initial program 60.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto y \cdot \left(0.5 + 0.5 \cdot \color{blue}{\left(\frac{x - z}{y} \cdot \frac{x + z}{y}\right)}\right) \]
    9. Applied egg-rr98.7%

      \[\leadsto y \cdot \left(0.5 + 0.5 \cdot \color{blue}{\left(\frac{x - z}{y} \cdot \frac{x + z}{y}\right)}\right) \]
    10. Step-by-step derivation
      1. associate-*r*98.7%

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

        \[\leadsto y \cdot \left(0.5 + \left(0.5 \cdot \frac{x - z}{y}\right) \cdot \color{blue}{\frac{1}{\frac{y}{x + z}}}\right) \]
      3. un-div-inv98.8%

        \[\leadsto y \cdot \left(0.5 + \color{blue}{\frac{0.5 \cdot \frac{x - z}{y}}{\frac{y}{x + z}}}\right) \]
    11. Applied egg-rr98.8%

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

Alternative 7: 97.8% accurate, 0.7× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := \frac{x - z\_m}{y\_m}\\ y\_s \cdot \begin{array}{l} \mathbf{if}\;y\_m \leq 5 \cdot 10^{-102}:\\ \;\;\;\;0.5 \cdot \left(\left(x + z\_m\right) \cdot t\_0\right)\\ \mathbf{else}:\\ \;\;\;\;y\_m \cdot \left(0.5 + 0.5 \cdot \left(t\_0 \cdot \frac{x + z\_m}{y\_m}\right)\right)\\ \end{array} \end{array} \end{array} \]
z_m = (fabs.f64 z)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z_m)
 :precision binary64
 (let* ((t_0 (/ (- x z_m) y_m)))
   (*
    y_s
    (if (<= y_m 5e-102)
      (* 0.5 (* (+ x z_m) t_0))
      (* y_m (+ 0.5 (* 0.5 (* t_0 (/ (+ x z_m) y_m)))))))))
z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
	double t_0 = (x - z_m) / y_m;
	double tmp;
	if (y_m <= 5e-102) {
		tmp = 0.5 * ((x + z_m) * t_0);
	} else {
		tmp = y_m * (0.5 + (0.5 * (t_0 * ((x + z_m) / y_m))));
	}
	return y_s * tmp;
}
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z_m)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (x - z_m) / y_m
    if (y_m <= 5d-102) then
        tmp = 0.5d0 * ((x + z_m) * t_0)
    else
        tmp = y_m * (0.5d0 + (0.5d0 * (t_0 * ((x + z_m) / y_m))))
    end if
    code = y_s * tmp
end function
z_m = Math.abs(z);
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_m) {
	double t_0 = (x - z_m) / y_m;
	double tmp;
	if (y_m <= 5e-102) {
		tmp = 0.5 * ((x + z_m) * t_0);
	} else {
		tmp = y_m * (0.5 + (0.5 * (t_0 * ((x + z_m) / y_m))));
	}
	return y_s * tmp;
}
z_m = math.fabs(z)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z_m):
	t_0 = (x - z_m) / y_m
	tmp = 0
	if y_m <= 5e-102:
		tmp = 0.5 * ((x + z_m) * t_0)
	else:
		tmp = y_m * (0.5 + (0.5 * (t_0 * ((x + z_m) / y_m))))
	return y_s * tmp
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z_m)
	t_0 = Float64(Float64(x - z_m) / y_m)
	tmp = 0.0
	if (y_m <= 5e-102)
		tmp = Float64(0.5 * Float64(Float64(x + z_m) * t_0));
	else
		tmp = Float64(y_m * Float64(0.5 + Float64(0.5 * Float64(t_0 * Float64(Float64(x + z_m) / y_m)))));
	end
	return Float64(y_s * tmp)
end
z_m = abs(z);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z_m)
	t_0 = (x - z_m) / y_m;
	tmp = 0.0;
	if (y_m <= 5e-102)
		tmp = 0.5 * ((x + z_m) * t_0);
	else
		tmp = y_m * (0.5 + (0.5 * (t_0 * ((x + z_m) / y_m))));
	end
	tmp_2 = y_s * tmp;
end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := Block[{t$95$0 = N[(N[(x - z$95$m), $MachinePrecision] / y$95$m), $MachinePrecision]}, N[(y$95$s * If[LessEqual[y$95$m, 5e-102], N[(0.5 * N[(N[(x + z$95$m), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(y$95$m * N[(0.5 + N[(0.5 * N[(t$95$0 * N[(N[(x + z$95$m), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
\begin{array}{l}
t_0 := \frac{x - z\_m}{y\_m}\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 5 \cdot 10^{-102}:\\
\;\;\;\;0.5 \cdot \left(\left(x + z\_m\right) \cdot t\_0\right)\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 5.00000000000000026e-102

    1. Initial program 77.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{\left(x + z\right) \cdot \left(x - z\right)}{y}} \]
    9. Step-by-step derivation
      1. associate-/l*67.7%

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

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

    if 5.00000000000000026e-102 < y

    1. Initial program 61.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 85.6% accurate, 0.7× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;y\_m \leq 7.2 \cdot 10^{+28}:\\ \;\;\;\;0.5 \cdot \left(\left(x + z\_m\right) \cdot \frac{x - z\_m}{y\_m}\right)\\ \mathbf{else}:\\ \;\;\;\;y\_m \cdot \left(0.5 + 0.5 \cdot \left(\frac{x + z\_m}{y\_m} \cdot \frac{x}{y\_m}\right)\right)\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z_m)
 :precision binary64
 (*
  y_s
  (if (<= y_m 7.2e+28)
    (* 0.5 (* (+ x z_m) (/ (- x z_m) y_m)))
    (* y_m (+ 0.5 (* 0.5 (* (/ (+ x z_m) y_m) (/ x y_m))))))))
z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
	double tmp;
	if (y_m <= 7.2e+28) {
		tmp = 0.5 * ((x + z_m) * ((x - z_m) / y_m));
	} else {
		tmp = y_m * (0.5 + (0.5 * (((x + z_m) / y_m) * (x / y_m))));
	}
	return y_s * tmp;
}
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z_m)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if (y_m <= 7.2d+28) then
        tmp = 0.5d0 * ((x + z_m) * ((x - z_m) / y_m))
    else
        tmp = y_m * (0.5d0 + (0.5d0 * (((x + z_m) / y_m) * (x / y_m))))
    end if
    code = y_s * tmp
end function
z_m = Math.abs(z);
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_m) {
	double tmp;
	if (y_m <= 7.2e+28) {
		tmp = 0.5 * ((x + z_m) * ((x - z_m) / y_m));
	} else {
		tmp = y_m * (0.5 + (0.5 * (((x + z_m) / y_m) * (x / y_m))));
	}
	return y_s * tmp;
}
z_m = math.fabs(z)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z_m):
	tmp = 0
	if y_m <= 7.2e+28:
		tmp = 0.5 * ((x + z_m) * ((x - z_m) / y_m))
	else:
		tmp = y_m * (0.5 + (0.5 * (((x + z_m) / y_m) * (x / y_m))))
	return y_s * tmp
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z_m)
	tmp = 0.0
	if (y_m <= 7.2e+28)
		tmp = Float64(0.5 * Float64(Float64(x + z_m) * Float64(Float64(x - z_m) / y_m)));
	else
		tmp = Float64(y_m * Float64(0.5 + Float64(0.5 * Float64(Float64(Float64(x + z_m) / y_m) * Float64(x / y_m)))));
	end
	return Float64(y_s * tmp)
end
z_m = abs(z);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z_m)
	tmp = 0.0;
	if (y_m <= 7.2e+28)
		tmp = 0.5 * ((x + z_m) * ((x - z_m) / y_m));
	else
		tmp = y_m * (0.5 + (0.5 * (((x + z_m) / y_m) * (x / y_m))));
	end
	tmp_2 = y_s * tmp;
end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := N[(y$95$s * If[LessEqual[y$95$m, 7.2e+28], N[(0.5 * N[(N[(x + z$95$m), $MachinePrecision] * N[(N[(x - z$95$m), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y$95$m * N[(0.5 + N[(0.5 * N[(N[(N[(x + z$95$m), $MachinePrecision] / y$95$m), $MachinePrecision] * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

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

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


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

    1. Initial program 80.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{\left(x + z\right) \cdot \left(x - z\right)}{y}} \]
    9. Step-by-step derivation
      1. associate-/l*70.5%

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

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

    if 7.1999999999999999e28 < y

    1. Initial program 45.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 80.4% accurate, 0.9× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;y\_m \leq 3.1 \cdot 10^{+134}:\\ \;\;\;\;0.5 \cdot \left(\left(x + z\_m\right) \cdot \frac{x - z\_m}{y\_m}\right)\\ \mathbf{else}:\\ \;\;\;\;y\_m \cdot 0.5\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z_m)
 :precision binary64
 (*
  y_s
  (if (<= y_m 3.1e+134) (* 0.5 (* (+ x z_m) (/ (- x z_m) y_m))) (* y_m 0.5))))
z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
	double tmp;
	if (y_m <= 3.1e+134) {
		tmp = 0.5 * ((x + z_m) * ((x - z_m) / y_m));
	} else {
		tmp = y_m * 0.5;
	}
	return y_s * tmp;
}
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z_m)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if (y_m <= 3.1d+134) then
        tmp = 0.5d0 * ((x + z_m) * ((x - z_m) / y_m))
    else
        tmp = y_m * 0.5d0
    end if
    code = y_s * tmp
end function
z_m = Math.abs(z);
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_m) {
	double tmp;
	if (y_m <= 3.1e+134) {
		tmp = 0.5 * ((x + z_m) * ((x - z_m) / y_m));
	} else {
		tmp = y_m * 0.5;
	}
	return y_s * tmp;
}
z_m = math.fabs(z)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z_m):
	tmp = 0
	if y_m <= 3.1e+134:
		tmp = 0.5 * ((x + z_m) * ((x - z_m) / y_m))
	else:
		tmp = y_m * 0.5
	return y_s * tmp
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z_m)
	tmp = 0.0
	if (y_m <= 3.1e+134)
		tmp = Float64(0.5 * Float64(Float64(x + z_m) * Float64(Float64(x - z_m) / y_m)));
	else
		tmp = Float64(y_m * 0.5);
	end
	return Float64(y_s * tmp)
end
z_m = abs(z);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z_m)
	tmp = 0.0;
	if (y_m <= 3.1e+134)
		tmp = 0.5 * ((x + z_m) * ((x - z_m) / y_m));
	else
		tmp = y_m * 0.5;
	end
	tmp_2 = y_s * tmp;
end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := N[(y$95$s * If[LessEqual[y$95$m, 3.1e+134], N[(0.5 * N[(N[(x + z$95$m), $MachinePrecision] * N[(N[(x - z$95$m), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y$95$m * 0.5), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

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

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


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

    1. Initial program 80.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{\left(x + z\right) \cdot \left(x - z\right)}{y}} \]
    9. Step-by-step derivation
      1. associate-/l*70.8%

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

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

    if 3.09999999999999982e134 < y

    1. Initial program 11.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 52.7% accurate, 1.2× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;y\_m \leq 7.2 \cdot 10^{+27}:\\ \;\;\;\;\frac{\left(z\_m \cdot z\_m\right) \cdot -0.5}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;y\_m \cdot 0.5\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z_m)
 :precision binary64
 (* y_s (if (<= y_m 7.2e+27) (/ (* (* z_m z_m) -0.5) y_m) (* y_m 0.5))))
z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
	double tmp;
	if (y_m <= 7.2e+27) {
		tmp = ((z_m * z_m) * -0.5) / y_m;
	} else {
		tmp = y_m * 0.5;
	}
	return y_s * tmp;
}
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z_m)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if (y_m <= 7.2d+27) then
        tmp = ((z_m * z_m) * (-0.5d0)) / y_m
    else
        tmp = y_m * 0.5d0
    end if
    code = y_s * tmp
end function
z_m = Math.abs(z);
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_m) {
	double tmp;
	if (y_m <= 7.2e+27) {
		tmp = ((z_m * z_m) * -0.5) / y_m;
	} else {
		tmp = y_m * 0.5;
	}
	return y_s * tmp;
}
z_m = math.fabs(z)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z_m):
	tmp = 0
	if y_m <= 7.2e+27:
		tmp = ((z_m * z_m) * -0.5) / y_m
	else:
		tmp = y_m * 0.5
	return y_s * tmp
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z_m)
	tmp = 0.0
	if (y_m <= 7.2e+27)
		tmp = Float64(Float64(Float64(z_m * z_m) * -0.5) / y_m);
	else
		tmp = Float64(y_m * 0.5);
	end
	return Float64(y_s * tmp)
end
z_m = abs(z);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z_m)
	tmp = 0.0;
	if (y_m <= 7.2e+27)
		tmp = ((z_m * z_m) * -0.5) / y_m;
	else
		tmp = y_m * 0.5;
	end
	tmp_2 = y_s * tmp;
end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := N[(y$95$s * If[LessEqual[y$95$m, 7.2e+27], N[(N[(N[(z$95$m * z$95$m), $MachinePrecision] * -0.5), $MachinePrecision] / y$95$m), $MachinePrecision], N[(y$95$m * 0.5), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 7.2 \cdot 10^{+27}:\\
\;\;\;\;\frac{\left(z\_m \cdot z\_m\right) \cdot -0.5}{y\_m}\\

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


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

    1. Initial program 80.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{{z}^{2} \cdot -0.5}{y}} \]
    7. Simplified34.7%

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

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

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

    if 7.19999999999999966e27 < y

    1. Initial program 45.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 35.5% accurate, 1.2× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;x \leq 5.8 \cdot 10^{+219}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;z\_m \cdot \left(z\_m \cdot \frac{0.5}{y\_m}\right)\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z_m)
 :precision binary64
 (* y_s (if (<= x 5.8e+219) (* y_m 0.5) (* z_m (* z_m (/ 0.5 y_m))))))
z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
	double tmp;
	if (x <= 5.8e+219) {
		tmp = y_m * 0.5;
	} else {
		tmp = z_m * (z_m * (0.5 / y_m));
	}
	return y_s * tmp;
}
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z_m)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if (x <= 5.8d+219) then
        tmp = y_m * 0.5d0
    else
        tmp = z_m * (z_m * (0.5d0 / y_m))
    end if
    code = y_s * tmp
end function
z_m = Math.abs(z);
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_m) {
	double tmp;
	if (x <= 5.8e+219) {
		tmp = y_m * 0.5;
	} else {
		tmp = z_m * (z_m * (0.5 / y_m));
	}
	return y_s * tmp;
}
z_m = math.fabs(z)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z_m):
	tmp = 0
	if x <= 5.8e+219:
		tmp = y_m * 0.5
	else:
		tmp = z_m * (z_m * (0.5 / y_m))
	return y_s * tmp
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z_m)
	tmp = 0.0
	if (x <= 5.8e+219)
		tmp = Float64(y_m * 0.5);
	else
		tmp = Float64(z_m * Float64(z_m * Float64(0.5 / y_m)));
	end
	return Float64(y_s * tmp)
end
z_m = abs(z);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z_m)
	tmp = 0.0;
	if (x <= 5.8e+219)
		tmp = y_m * 0.5;
	else
		tmp = z_m * (z_m * (0.5 / y_m));
	end
	tmp_2 = y_s * tmp;
end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := N[(y$95$s * If[LessEqual[x, 5.8e+219], N[(y$95$m * 0.5), $MachinePrecision], N[(z$95$m * N[(z$95$m * N[(0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

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

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


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

    1. Initial program 73.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.79999999999999958e219 < x

    1. Initial program 54.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{0.5}{\frac{y}{\color{blue}{\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y}} - z \cdot z}} \]
      6. pow254.5%

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

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

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

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

      \[\leadsto \frac{0.5}{\color{blue}{-1 \cdot \frac{y}{{z}^{2}}}} \]
    8. Step-by-step derivation
      1. associate-*r/0.4%

        \[\leadsto \frac{0.5}{\color{blue}{\frac{-1 \cdot y}{{z}^{2}}}} \]
      2. neg-mul-10.4%

        \[\leadsto \frac{0.5}{\frac{\color{blue}{-y}}{{z}^{2}}} \]
    9. Simplified0.4%

      \[\leadsto \frac{0.5}{\color{blue}{\frac{-y}{{z}^{2}}}} \]
    10. Step-by-step derivation
      1. associate-/r/0.4%

        \[\leadsto \color{blue}{\frac{0.5}{-y} \cdot {z}^{2}} \]
      2. unpow20.4%

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

        \[\leadsto \color{blue}{\left(\frac{0.5}{-y} \cdot z\right) \cdot z} \]
      4. add-sqr-sqrt0.2%

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

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

        \[\leadsto \left(\frac{0.5}{\sqrt{\color{blue}{y \cdot y}}} \cdot z\right) \cdot z \]
      7. sqrt-prod16.9%

        \[\leadsto \left(\frac{0.5}{\color{blue}{\sqrt{y} \cdot \sqrt{y}}} \cdot z\right) \cdot z \]
      8. add-sqr-sqrt33.8%

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

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

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

Alternative 12: 34.8% accurate, 5.0× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ 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} \]
z_m = (fabs.f64 z)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z_m) :precision binary64 (* y_s (* y_m 0.5)))
z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
	return y_s * (y_m * 0.5);
}
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z_m)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z_m
    code = y_s * (y_m * 0.5d0)
end function
z_m = Math.abs(z);
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_m) {
	return y_s * (y_m * 0.5);
}
z_m = math.fabs(z)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z_m):
	return y_s * (y_m * 0.5)
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z_m)
	return Float64(y_s * Float64(y_m * 0.5))
end
z_m = abs(z);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp = code(y_s, x, y_m, z_m)
	tmp = y_s * (y_m * 0.5);
end
z_m = N[Abs[z], $MachinePrecision]
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$95$m_] := N[(y$95$s * N[(y$95$m * 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
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 72.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  :alt
  (! :herbie-platform default (- (* y 1/2) (* (* (/ 1/2 y) (+ z x)) (- z x))))

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