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

Percentage Accurate: 68.9% → 98.5%
Time: 10.7s
Alternatives: 13
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 13 alternatives:

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

Initial Program: 68.9% 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: 98.5% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+303}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;y\_m \cdot \left(0.5 + \frac{0.5 \cdot \frac{x - z}{y\_m}}{\frac{y\_m}{x + z}}\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 82.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-0.5 \cdot {z}^{2}}{y}} \]
    8. Simplified26.3%

      \[\leadsto \color{blue}{\frac{-0.5 \cdot {z}^{2}}{y}} \]
    9. Step-by-step derivation
      1. unpow226.3%

        \[\leadsto \frac{-0.5 \cdot \color{blue}{\left(z \cdot z\right)}}{y} \]
    10. Applied egg-rr26.3%

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

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

        \[\leadsto \frac{\left(-0.5 \cdot z\right) \cdot z}{\color{blue}{1 \cdot y}} \]
      3. times-frac28.6%

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

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

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

    1. Initial program 97.9%

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

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

    1. Initial program 50.0%

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

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

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

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

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

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

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

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

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

      \[\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. unpow265.8%

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

        \[\leadsto y \cdot \left(0.5 + 0.5 \cdot \frac{x \cdot x - \color{blue}{z \cdot z}}{{y}^{2}}\right) \]
      3. difference-of-squares79.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-rr79.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. Step-by-step derivation
      1. *-commutative79.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) \]
      2. unpow279.3%

        \[\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. Step-by-step derivation
      1. associate-*r*99.9%

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

        \[\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-inv100.0%

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

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

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

Alternative 2: 96.7% accurate, 0.2× speedup?

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

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

\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+303}:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 4 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 82.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-0.5 \cdot {z}^{2}}{y}} \]
    8. Simplified26.3%

      \[\leadsto \color{blue}{\frac{-0.5 \cdot {z}^{2}}{y}} \]
    9. Step-by-step derivation
      1. unpow226.3%

        \[\leadsto \frac{-0.5 \cdot \color{blue}{\left(z \cdot z\right)}}{y} \]
    10. Applied egg-rr26.3%

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

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

        \[\leadsto \frac{\left(-0.5 \cdot z\right) \cdot z}{\color{blue}{1 \cdot y}} \]
      3. times-frac28.6%

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

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

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

    1. Initial program 97.9%

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

    if 4e303 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < +inf.0

    1. Initial program 65.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto y \cdot \left(0.5 + 0.5 \cdot \frac{\color{blue}{x \cdot x} - {z}^{2}}{{y}^{2}}\right) \]
      2. unpow286.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-squares86.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-rr86.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. *-commutative86.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. unpow286.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-frac100.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-rr100.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 66.2%

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto y \cdot \left(0.5 + 0.5 \cdot \frac{\color{blue}{x \cdot x} - {z}^{2}}{{y}^{2}}\right) \]
      2. unpow20.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-squares56.0%

        \[\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-rr56.0%

      \[\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. *-commutative56.0%

        \[\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. unpow256.0%

        \[\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 0 83.9%

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

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

Alternative 3: 98.5% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+303}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;y\_m \cdot \left(0.5 + 0.5 \cdot \frac{\frac{x - z}{y\_m} \cdot \left(x + z\right)}{y\_m}\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 82.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-0.5 \cdot {z}^{2}}{y}} \]
    8. Simplified26.3%

      \[\leadsto \color{blue}{\frac{-0.5 \cdot {z}^{2}}{y}} \]
    9. Step-by-step derivation
      1. unpow226.3%

        \[\leadsto \frac{-0.5 \cdot \color{blue}{\left(z \cdot z\right)}}{y} \]
    10. Applied egg-rr26.3%

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

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

        \[\leadsto \frac{\left(-0.5 \cdot z\right) \cdot z}{\color{blue}{1 \cdot y}} \]
      3. times-frac28.6%

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

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

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

    1. Initial program 97.9%

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

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

    1. Initial program 50.0%

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

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

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

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

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

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

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

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

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

      \[\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. unpow265.8%

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

        \[\leadsto y \cdot \left(0.5 + 0.5 \cdot \frac{x \cdot x - \color{blue}{z \cdot z}}{{y}^{2}}\right) \]
      3. difference-of-squares79.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-rr79.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. Step-by-step derivation
      1. *-commutative79.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) \]
      2. unpow279.3%

        \[\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. Step-by-step derivation
      1. associate-*r/100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \leq 0:\\ \;\;\;\;\left(z \cdot -0.5\right) \cdot \frac{z}{y}\\ \mathbf{elif}\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \leq 4 \cdot 10^{+303}:\\ \;\;\;\;\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 \frac{\frac{x - z}{y} \cdot \left(x + z\right)}{y}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 98.4% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+303}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;y\_m \cdot \left(0.5 + 0.5 \cdot \left(\frac{x - z}{y\_m} \cdot \frac{x + z}{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 82.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-0.5 \cdot {z}^{2}}{y}} \]
    8. Simplified26.3%

      \[\leadsto \color{blue}{\frac{-0.5 \cdot {z}^{2}}{y}} \]
    9. Step-by-step derivation
      1. unpow226.3%

        \[\leadsto \frac{-0.5 \cdot \color{blue}{\left(z \cdot z\right)}}{y} \]
    10. Applied egg-rr26.3%

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

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

        \[\leadsto \frac{\left(-0.5 \cdot z\right) \cdot z}{\color{blue}{1 \cdot y}} \]
      3. times-frac28.6%

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

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

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

    1. Initial program 97.9%

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

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

    1. Initial program 50.0%

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

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

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

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

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

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

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

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

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

      \[\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. unpow265.8%

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

        \[\leadsto y \cdot \left(0.5 + 0.5 \cdot \frac{x \cdot x - \color{blue}{z \cdot z}}{{y}^{2}}\right) \]
      3. difference-of-squares79.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-rr79.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. Step-by-step derivation
      1. *-commutative79.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) \]
      2. unpow279.3%

        \[\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) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification69.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \leq 0:\\ \;\;\;\;\left(z \cdot -0.5\right) \cdot \frac{z}{y}\\ \mathbf{elif}\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \leq 4 \cdot 10^{+303}:\\ \;\;\;\;\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 + z}{y}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 85.4% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 78.5%

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified80.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 74.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. unpow274.0%

        \[\leadsto y \cdot \left(0.5 + 0.5 \cdot \frac{\color{blue}{x \cdot x} - {z}^{2}}{{y}^{2}}\right) \]
      2. unpow274.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-squares79.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-rr79.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. Taylor expanded in y around 0 74.2%

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

    if 9e44 < y

    1. Initial program 46.2%

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

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

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

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

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

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

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

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

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

      \[\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.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. unpow278.3%

        \[\leadsto y \cdot \left(0.5 + 0.5 \cdot \frac{\color{blue}{x \cdot x} - {z}^{2}}{{y}^{2}}\right) \]
      2. unpow278.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-squares82.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-rr82.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. Step-by-step derivation
      1. *-commutative82.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) \]
      2. unpow282.3%

        \[\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 0 87.9%

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

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

Alternative 6: 82.6% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 78.6%

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

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

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

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

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

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

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

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

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

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

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

        \[\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.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-rr80.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 74.4%

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

    if 6.4999999999999997e110 < y

    1. Initial program 36.4%

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified36.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 77.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. unpow277.5%

        \[\leadsto y \cdot \left(0.5 + 0.5 \cdot \frac{\color{blue}{x \cdot x} - {z}^{2}}{{y}^{2}}\right) \]
      2. unpow277.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-squares77.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-rr77.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. *-commutative77.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. unpow277.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-frac100.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-rr100.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 92.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 2 regimes into one program.
  4. Final simplification77.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 6.5 \cdot 10^{+110}:\\ \;\;\;\;0.5 \cdot \frac{\left(x - z\right) \cdot \left(x + z\right)}{y}\\ \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 7: 51.5% accurate, 0.9× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 7e59

    1. Initial program 78.6%

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

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

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

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

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

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

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

        \[\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 0 51.3%

      \[\leadsto \color{blue}{0.5 \cdot \frac{{x}^{2} + {y}^{2}}{y}} \]
    6. Step-by-step derivation
      1. rem-square-sqrt51.3%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\sqrt{{x}^{2} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}}}{y} \]
      2. unpow251.3%

        \[\leadsto 0.5 \cdot \frac{\sqrt{\color{blue}{x \cdot x} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}}{y} \]
      3. unpow251.3%

        \[\leadsto 0.5 \cdot \frac{\sqrt{x \cdot x + \color{blue}{y \cdot y}} \cdot \sqrt{{x}^{2} + {y}^{2}}}{y} \]
      4. hypot-undefine51.3%

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

        \[\leadsto 0.5 \cdot \frac{\mathsf{hypot}\left(x, y\right) \cdot \sqrt{\color{blue}{x \cdot x} + {y}^{2}}}{y} \]
      6. unpow251.3%

        \[\leadsto 0.5 \cdot \frac{\mathsf{hypot}\left(x, y\right) \cdot \sqrt{x \cdot x + \color{blue}{y \cdot y}}}{y} \]
      7. hypot-undefine51.3%

        \[\leadsto 0.5 \cdot \frac{\mathsf{hypot}\left(x, y\right) \cdot \color{blue}{\mathsf{hypot}\left(x, y\right)}}{y} \]
      8. unpow251.3%

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{{\left(\sqrt{\color{blue}{{y}^{2} + {x}^{2}}}\right)}^{2}}{y} \]
      13. unpow251.3%

        \[\leadsto 0.5 \cdot \frac{{\left(\sqrt{\color{blue}{y \cdot y} + {x}^{2}}\right)}^{2}}{y} \]
      14. unpow251.3%

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{{\left(\mathsf{hypot}\left(y, x\right)\right)}^{2}}{y}} \]
    8. Step-by-step derivation
      1. unpow251.3%

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

        \[\leadsto 0.5 \cdot \color{blue}{\left(\mathsf{hypot}\left(y, x\right) \cdot \frac{\mathsf{hypot}\left(y, x\right)}{y}\right)} \]
    9. Applied egg-rr61.0%

      \[\leadsto 0.5 \cdot \color{blue}{\left(\mathsf{hypot}\left(y, x\right) \cdot \frac{\mathsf{hypot}\left(y, x\right)}{y}\right)} \]
    10. Taylor expanded in y around 0 22.7%

      \[\leadsto 0.5 \cdot \left(\mathsf{hypot}\left(y, x\right) \cdot \color{blue}{\frac{x}{y}}\right) \]
    11. Taylor expanded in y around 0 42.2%

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

    if 7e59 < y < 6.4999999999999997e110

    1. Initial program 79.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.4999999999999997e110 < y

    1. Initial program 36.4%

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 78.3% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 78.6%

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

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

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

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

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

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

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

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

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

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

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

        \[\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.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-rr80.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 74.4%

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

    if 9.0000000000000005e110 < y

    1. Initial program 36.4%

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 52.3% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 76.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-0.5 \cdot \color{blue}{\left(z \cdot z\right)}}{y} \]
    10. Applied egg-rr51.2%

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

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

        \[\leadsto \frac{\left(-0.5 \cdot z\right) \cdot z}{\color{blue}{1 \cdot y}} \]
      3. times-frac56.3%

        \[\leadsto \color{blue}{\frac{-0.5 \cdot z}{1} \cdot \frac{z}{y}} \]
    12. Applied egg-rr56.3%

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

    if 9.99999999999999945e-21 < (*.f64 x x)

    1. Initial program 67.6%

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

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

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

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

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

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

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

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

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

      \[\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 0 65.6%

      \[\leadsto \color{blue}{0.5 \cdot \frac{{x}^{2} + {y}^{2}}{y}} \]
    6. Step-by-step derivation
      1. rem-square-sqrt65.6%

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

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

        \[\leadsto 0.5 \cdot \frac{\sqrt{x \cdot x + \color{blue}{y \cdot y}} \cdot \sqrt{{x}^{2} + {y}^{2}}}{y} \]
      4. hypot-undefine65.6%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{hypot}\left(x, y\right)} \cdot \sqrt{{x}^{2} + {y}^{2}}}{y} \]
      5. unpow265.6%

        \[\leadsto 0.5 \cdot \frac{\mathsf{hypot}\left(x, y\right) \cdot \sqrt{\color{blue}{x \cdot x} + {y}^{2}}}{y} \]
      6. unpow265.6%

        \[\leadsto 0.5 \cdot \frac{\mathsf{hypot}\left(x, y\right) \cdot \sqrt{x \cdot x + \color{blue}{y \cdot y}}}{y} \]
      7. hypot-undefine65.6%

        \[\leadsto 0.5 \cdot \frac{\mathsf{hypot}\left(x, y\right) \cdot \color{blue}{\mathsf{hypot}\left(x, y\right)}}{y} \]
      8. unpow265.6%

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{{\left(\sqrt{\color{blue}{{y}^{2} + {x}^{2}}}\right)}^{2}}{y} \]
      13. unpow265.6%

        \[\leadsto 0.5 \cdot \frac{{\left(\sqrt{\color{blue}{y \cdot y} + {x}^{2}}\right)}^{2}}{y} \]
      14. unpow265.6%

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

        \[\leadsto 0.5 \cdot \frac{{\color{blue}{\left(\mathsf{hypot}\left(y, x\right)\right)}}^{2}}{y} \]
    7. Simplified65.6%

      \[\leadsto \color{blue}{0.5 \cdot \frac{{\left(\mathsf{hypot}\left(y, x\right)\right)}^{2}}{y}} \]
    8. Step-by-step derivation
      1. unpow265.6%

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(\mathsf{hypot}\left(y, x\right) \cdot \frac{\mathsf{hypot}\left(y, x\right)}{y}\right)} \]
    10. Taylor expanded in y around 0 32.5%

      \[\leadsto 0.5 \cdot \left(\mathsf{hypot}\left(y, x\right) \cdot \color{blue}{\frac{x}{y}}\right) \]
    11. Taylor expanded in y around 0 62.0%

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

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

Alternative 10: 51.9% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 78.6%

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified81.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 z around 0 50.2%

      \[\leadsto \color{blue}{0.5 \cdot \frac{{x}^{2} + {y}^{2}}{y}} \]
    6. Step-by-step derivation
      1. rem-square-sqrt50.2%

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

        \[\leadsto 0.5 \cdot \frac{\sqrt{\color{blue}{x \cdot x} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}}{y} \]
      3. unpow250.2%

        \[\leadsto 0.5 \cdot \frac{\sqrt{x \cdot x + \color{blue}{y \cdot y}} \cdot \sqrt{{x}^{2} + {y}^{2}}}{y} \]
      4. hypot-undefine50.2%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{hypot}\left(x, y\right)} \cdot \sqrt{{x}^{2} + {y}^{2}}}{y} \]
      5. unpow250.2%

        \[\leadsto 0.5 \cdot \frac{\mathsf{hypot}\left(x, y\right) \cdot \sqrt{\color{blue}{x \cdot x} + {y}^{2}}}{y} \]
      6. unpow250.2%

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{{\left(\sqrt{\color{blue}{y \cdot y} + {x}^{2}}\right)}^{2}}{y} \]
      14. unpow250.2%

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

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

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\left(\mathsf{hypot}\left(y, x\right) \cdot \frac{\mathsf{hypot}\left(y, x\right)}{y}\right)} \]
    9. Applied egg-rr59.5%

      \[\leadsto 0.5 \cdot \color{blue}{\left(\mathsf{hypot}\left(y, x\right) \cdot \frac{\mathsf{hypot}\left(y, x\right)}{y}\right)} \]
    10. Taylor expanded in y around 0 22.6%

      \[\leadsto 0.5 \cdot \left(\mathsf{hypot}\left(y, x\right) \cdot \color{blue}{\frac{x}{y}}\right) \]
    11. Taylor expanded in y around 0 40.7%

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

    if 9.2000000000000001e110 < y

    1. Initial program 36.4%

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 34.4% accurate, 5.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 2.9% accurate, 5.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
  3. Simplified74.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 z around 0 47.3%

    \[\leadsto \color{blue}{0.5 \cdot \frac{{x}^{2} + {y}^{2}}{y}} \]
  6. Step-by-step derivation
    1. rem-square-sqrt47.3%

      \[\leadsto 0.5 \cdot \frac{\color{blue}{\sqrt{{x}^{2} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}}}{y} \]
    2. unpow247.3%

      \[\leadsto 0.5 \cdot \frac{\sqrt{\color{blue}{x \cdot x} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}}{y} \]
    3. unpow247.3%

      \[\leadsto 0.5 \cdot \frac{\sqrt{x \cdot x + \color{blue}{y \cdot y}} \cdot \sqrt{{x}^{2} + {y}^{2}}}{y} \]
    4. hypot-undefine47.3%

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

      \[\leadsto 0.5 \cdot \frac{\mathsf{hypot}\left(x, y\right) \cdot \sqrt{\color{blue}{x \cdot x} + {y}^{2}}}{y} \]
    6. unpow247.3%

      \[\leadsto 0.5 \cdot \frac{\mathsf{hypot}\left(x, y\right) \cdot \sqrt{x \cdot x + \color{blue}{y \cdot y}}}{y} \]
    7. hypot-undefine47.3%

      \[\leadsto 0.5 \cdot \frac{\mathsf{hypot}\left(x, y\right) \cdot \color{blue}{\mathsf{hypot}\left(x, y\right)}}{y} \]
    8. unpow247.3%

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

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

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

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

      \[\leadsto 0.5 \cdot \frac{{\left(\sqrt{\color{blue}{{y}^{2} + {x}^{2}}}\right)}^{2}}{y} \]
    13. unpow247.3%

      \[\leadsto 0.5 \cdot \frac{{\left(\sqrt{\color{blue}{y \cdot y} + {x}^{2}}\right)}^{2}}{y} \]
    14. unpow247.3%

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

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

    \[\leadsto \color{blue}{0.5 \cdot \frac{{\left(\mathsf{hypot}\left(y, x\right)\right)}^{2}}{y}} \]
  8. Step-by-step derivation
    1. unpow247.3%

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(\mathsf{hypot}\left(y, x\right) \cdot \frac{\mathsf{hypot}\left(y, x\right)}{y}\right)} \]
  9. Applied egg-rr64.3%

    \[\leadsto 0.5 \cdot \color{blue}{\left(\mathsf{hypot}\left(y, x\right) \cdot \frac{\mathsf{hypot}\left(y, x\right)}{y}\right)} \]
  10. Taylor expanded in y around 0 20.1%

    \[\leadsto 0.5 \cdot \left(\mathsf{hypot}\left(y, x\right) \cdot \color{blue}{\frac{x}{y}}\right) \]
  11. Taylor expanded in y around inf 2.7%

    \[\leadsto \color{blue}{0.5 \cdot x} \]
  12. Final simplification2.7%

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

Alternative 13: 3.0% accurate, 5.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
  3. Simplified74.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 z around 0 47.3%

    \[\leadsto \color{blue}{0.5 \cdot \frac{{x}^{2} + {y}^{2}}{y}} \]
  6. Step-by-step derivation
    1. rem-square-sqrt47.3%

      \[\leadsto 0.5 \cdot \frac{\color{blue}{\sqrt{{x}^{2} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}}}{y} \]
    2. unpow247.3%

      \[\leadsto 0.5 \cdot \frac{\sqrt{\color{blue}{x \cdot x} + {y}^{2}} \cdot \sqrt{{x}^{2} + {y}^{2}}}{y} \]
    3. unpow247.3%

      \[\leadsto 0.5 \cdot \frac{\sqrt{x \cdot x + \color{blue}{y \cdot y}} \cdot \sqrt{{x}^{2} + {y}^{2}}}{y} \]
    4. hypot-undefine47.3%

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

      \[\leadsto 0.5 \cdot \frac{\mathsf{hypot}\left(x, y\right) \cdot \sqrt{\color{blue}{x \cdot x} + {y}^{2}}}{y} \]
    6. unpow247.3%

      \[\leadsto 0.5 \cdot \frac{\mathsf{hypot}\left(x, y\right) \cdot \sqrt{x \cdot x + \color{blue}{y \cdot y}}}{y} \]
    7. hypot-undefine47.3%

      \[\leadsto 0.5 \cdot \frac{\mathsf{hypot}\left(x, y\right) \cdot \color{blue}{\mathsf{hypot}\left(x, y\right)}}{y} \]
    8. unpow247.3%

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

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

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

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

      \[\leadsto 0.5 \cdot \frac{{\left(\sqrt{\color{blue}{{y}^{2} + {x}^{2}}}\right)}^{2}}{y} \]
    13. unpow247.3%

      \[\leadsto 0.5 \cdot \frac{{\left(\sqrt{\color{blue}{y \cdot y} + {x}^{2}}\right)}^{2}}{y} \]
    14. unpow247.3%

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

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

    \[\leadsto \color{blue}{0.5 \cdot \frac{{\left(\mathsf{hypot}\left(y, x\right)\right)}^{2}}{y}} \]
  8. Step-by-step derivation
    1. unpow247.3%

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(\mathsf{hypot}\left(y, x\right) \cdot \frac{\mathsf{hypot}\left(y, x\right)}{y}\right)} \]
  9. Applied egg-rr64.3%

    \[\leadsto 0.5 \cdot \color{blue}{\left(\mathsf{hypot}\left(y, x\right) \cdot \frac{\mathsf{hypot}\left(y, x\right)}{y}\right)} \]
  10. Taylor expanded in y around 0 20.1%

    \[\leadsto 0.5 \cdot \left(\mathsf{hypot}\left(y, x\right) \cdot \color{blue}{\frac{x}{y}}\right) \]
  11. Taylor expanded in y around -inf 3.2%

    \[\leadsto \color{blue}{-0.5 \cdot x} \]
  12. Final simplification3.2%

    \[\leadsto x \cdot -0.5 \]
  13. 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 2024145 
(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)))