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

Percentage Accurate: 69.2% → 95.7%
Time: 10.4s
Alternatives: 9
Speedup: 0.7×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 69.2% accurate, 1.0× speedup?

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

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

Alternative 1: 95.7% accurate, 0.1× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;y\_m \leq 1500000000000:\\ \;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, y\_m \cdot y\_m - z \cdot z\right)}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\left(y\_m + \frac{x}{y\_m \cdot \frac{1}{x}}\right) - z \cdot \frac{z}{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 (<= y_m 1500000000000.0)
    (* 0.5 (/ (fma x x (- (* y_m y_m) (* z z))) y_m))
    (* 0.5 (- (+ y_m (/ x (* y_m (/ 1.0 x)))) (* z (/ 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 <= 1500000000000.0) {
		tmp = 0.5 * (fma(x, x, ((y_m * y_m) - (z * z))) / y_m);
	} else {
		tmp = 0.5 * ((y_m + (x / (y_m * (1.0 / x)))) - (z * (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 <= 1500000000000.0)
		tmp = Float64(0.5 * Float64(fma(x, x, Float64(Float64(y_m * y_m) - Float64(z * z))) / y_m));
	else
		tmp = Float64(0.5 * Float64(Float64(y_m + Float64(x / Float64(y_m * Float64(1.0 / x)))) - Float64(z * Float64(z / y_m))));
	end
	return Float64(y_s * tmp)
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[y$95$m, 1500000000000.0], N[(0.5 * N[(N[(x * x + N[(N[(y$95$m * y$95$m), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(y$95$m + N[(x / N[(y$95$m * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(z * N[(z / y$95$m), $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 1500000000000:\\
\;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, y\_m \cdot y\_m - z \cdot z\right)}{y\_m}\\

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


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

    1. Initial program 74.7%

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

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

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

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

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

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

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

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

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

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

    if 1.5e12 < y

    1. Initial program 55.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(\left(y + \color{blue}{\frac{1 \cdot \left(-x\right)}{\frac{1}{x} \cdot \left(-y\right)}}\right) - \frac{z}{1} \cdot \frac{z}{y}\right) \]
      4. *-un-lft-identity99.9%

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

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

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

Alternative 2: 94.2% accurate, 0.1× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;x \cdot x \leq 10^{+273}:\\ \;\;\;\;0.5 \cdot \left(\left(y\_m + x \cdot \frac{x}{y\_m}\right) - z \cdot \frac{z}{y\_m}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \mathsf{fma}\left(x, \frac{x}{y\_m}, 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+273)
    (* 0.5 (- (+ y_m (* x (/ x y_m))) (* z (/ z y_m))))
    (* 0.5 (fma x (/ x y_m) 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+273) {
		tmp = 0.5 * ((y_m + (x * (x / y_m))) - (z * (z / y_m)));
	} else {
		tmp = 0.5 * fma(x, (x / y_m), 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+273)
		tmp = Float64(0.5 * Float64(Float64(y_m + Float64(x * Float64(x / y_m))) - Float64(z * Float64(z / y_m))));
	else
		tmp = Float64(0.5 * fma(x, Float64(x / y_m), y_m));
	end
	return Float64(y_s * tmp)
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[N[(x * x), $MachinePrecision], 1e+273], N[(0.5 * N[(N[(y$95$m + N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(z * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(x * N[(x / y$95$m), $MachinePrecision] + y$95$m), $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^{+273}:\\
\;\;\;\;0.5 \cdot \left(\left(y\_m + x \cdot \frac{x}{y\_m}\right) - z \cdot \frac{z}{y\_m}\right)\\

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


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

    1. Initial program 73.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.99999999999999945e272 < (*.f64 x x)

    1. Initial program 61.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 87.4% accurate, 0.5× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 3.8500000000000001e67

    1. Initial program 70.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.8500000000000001e67 < x < 2.4999999999999999e146

    1. Initial program 91.6%

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

    if 2.4999999999999999e146 < x < 1.8499999999999999e235

    1. Initial program 50.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(\frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{\sqrt{y}}, \sqrt{\frac{x \cdot x}{y}}, y\right) - \frac{{z}^{2}}{y}\right) \]
      7. add-sqr-sqrt14.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.8499999999999999e235 < x

    1. Initial program 75.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 88.1% accurate, 0.6× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;x \leq 2 \cdot 10^{+137}:\\ \;\;\;\;0.5 \cdot \left(\left(y\_m + \frac{x \cdot x}{y\_m}\right) - z \cdot \frac{z}{y\_m}\right)\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{+238}:\\ \;\;\;\;0.5 \cdot \left(\left(y\_m + \frac{x}{\frac{y\_m}{x}}\right) - \frac{z \cdot z}{y\_m}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \frac{0.5}{y\_m}\\ \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 2e+137)
    (* 0.5 (- (+ y_m (/ (* x x) y_m)) (* z (/ z y_m))))
    (if (<= x 3.1e+238)
      (* 0.5 (- (+ y_m (/ x (/ y_m x))) (/ (* z z) y_m)))
      (* (* x x) (/ 0.5 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 <= 2e+137) {
		tmp = 0.5 * ((y_m + ((x * x) / y_m)) - (z * (z / y_m)));
	} else if (x <= 3.1e+238) {
		tmp = 0.5 * ((y_m + (x / (y_m / x))) - ((z * z) / y_m));
	} else {
		tmp = (x * x) * (0.5 / 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 <= 2d+137) then
        tmp = 0.5d0 * ((y_m + ((x * x) / y_m)) - (z * (z / y_m)))
    else if (x <= 3.1d+238) then
        tmp = 0.5d0 * ((y_m + (x / (y_m / x))) - ((z * z) / y_m))
    else
        tmp = (x * x) * (0.5d0 / 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 <= 2e+137) {
		tmp = 0.5 * ((y_m + ((x * x) / y_m)) - (z * (z / y_m)));
	} else if (x <= 3.1e+238) {
		tmp = 0.5 * ((y_m + (x / (y_m / x))) - ((z * z) / y_m));
	} else {
		tmp = (x * x) * (0.5 / 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 <= 2e+137:
		tmp = 0.5 * ((y_m + ((x * x) / y_m)) - (z * (z / y_m)))
	elif x <= 3.1e+238:
		tmp = 0.5 * ((y_m + (x / (y_m / x))) - ((z * z) / y_m))
	else:
		tmp = (x * x) * (0.5 / y_m)
	return y_s * tmp
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (x <= 2e+137)
		tmp = Float64(0.5 * Float64(Float64(y_m + Float64(Float64(x * x) / y_m)) - Float64(z * Float64(z / y_m))));
	elseif (x <= 3.1e+238)
		tmp = Float64(0.5 * Float64(Float64(y_m + Float64(x / Float64(y_m / x))) - Float64(Float64(z * z) / y_m)));
	else
		tmp = Float64(Float64(x * x) * Float64(0.5 / 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 <= 2e+137)
		tmp = 0.5 * ((y_m + ((x * x) / y_m)) - (z * (z / y_m)));
	elseif (x <= 3.1e+238)
		tmp = 0.5 * ((y_m + (x / (y_m / x))) - ((z * z) / y_m));
	else
		tmp = (x * x) * (0.5 / y_m);
	end
	tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[x, 2e+137], N[(0.5 * N[(N[(y$95$m + N[(N[(x * x), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision] - N[(z * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.1e+238], N[(0.5 * N[(N[(y$95$m + N[(x / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(z * z), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 2.0000000000000001e137

    1. Initial program 71.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.0000000000000001e137 < x < 3.10000000000000012e238

    1. Initial program 57.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(\mathsf{fma}\left(\frac{x}{\sqrt{y}}, \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{\sqrt{y}}, y\right) - \frac{{z}^{2}}{y}\right) \]
      10. add-sqr-sqrt36.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.10000000000000012e238 < x

    1. Initial program 75.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 94.2% 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 2 \cdot 10^{-7}:\\ \;\;\;\;\frac{\left(y\_m \cdot y\_m + x \cdot x\right) - z \cdot z}{y\_m \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\left(y\_m - \frac{\frac{x}{y\_m}}{\frac{-1}{x}}\right) - z \cdot \frac{z}{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 (<= y_m 2e-7)
    (/ (- (+ (* y_m y_m) (* x x)) (* z z)) (* y_m 2.0))
    (* 0.5 (- (- y_m (/ (/ x y_m) (/ -1.0 x))) (* z (/ 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 <= 2e-7) {
		tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0);
	} else {
		tmp = 0.5 * ((y_m - ((x / y_m) / (-1.0 / x))) - (z * (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 <= 2d-7) then
        tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0d0)
    else
        tmp = 0.5d0 * ((y_m - ((x / y_m) / ((-1.0d0) / x))) - (z * (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 <= 2e-7) {
		tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0);
	} else {
		tmp = 0.5 * ((y_m - ((x / y_m) / (-1.0 / x))) - (z * (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 <= 2e-7:
		tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0)
	else:
		tmp = 0.5 * ((y_m - ((x / y_m) / (-1.0 / x))) - (z * (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 <= 2e-7)
		tmp = Float64(Float64(Float64(Float64(y_m * y_m) + Float64(x * x)) - Float64(z * z)) / Float64(y_m * 2.0));
	else
		tmp = Float64(0.5 * Float64(Float64(y_m - Float64(Float64(x / y_m) / Float64(-1.0 / x))) - Float64(z * Float64(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 <= 2e-7)
		tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0);
	else
		tmp = 0.5 * ((y_m - ((x / y_m) / (-1.0 / x))) - (z * (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, 2e-7], N[(N[(N[(N[(y$95$m * y$95$m), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(y$95$m - N[(N[(x / y$95$m), $MachinePrecision] / N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(z * N[(z / y$95$m), $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 2 \cdot 10^{-7}:\\
\;\;\;\;\frac{\left(y\_m \cdot y\_m + x \cdot x\right) - z \cdot z}{y\_m \cdot 2}\\

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


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

    1. Initial program 74.5%

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

    if 1.9999999999999999e-7 < y

    1. Initial program 56.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 94.2% 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 7 \cdot 10^{-11}:\\ \;\;\;\;\frac{\left(y\_m \cdot y\_m + x \cdot x\right) - z \cdot z}{y\_m \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\left(y\_m + x \cdot \frac{x}{y\_m}\right) - z \cdot \frac{z}{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 (<= y_m 7e-11)
    (/ (- (+ (* y_m y_m) (* x x)) (* z z)) (* y_m 2.0))
    (* 0.5 (- (+ y_m (* x (/ x y_m))) (* z (/ 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 <= 7e-11) {
		tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0);
	} else {
		tmp = 0.5 * ((y_m + (x * (x / y_m))) - (z * (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 <= 7d-11) then
        tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0d0)
    else
        tmp = 0.5d0 * ((y_m + (x * (x / y_m))) - (z * (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 <= 7e-11) {
		tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0);
	} else {
		tmp = 0.5 * ((y_m + (x * (x / y_m))) - (z * (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 <= 7e-11:
		tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0)
	else:
		tmp = 0.5 * ((y_m + (x * (x / y_m))) - (z * (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 <= 7e-11)
		tmp = Float64(Float64(Float64(Float64(y_m * y_m) + Float64(x * x)) - Float64(z * z)) / Float64(y_m * 2.0));
	else
		tmp = Float64(0.5 * Float64(Float64(y_m + Float64(x * Float64(x / y_m))) - Float64(z * Float64(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 <= 7e-11)
		tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0);
	else
		tmp = 0.5 * ((y_m + (x * (x / y_m))) - (z * (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, 7e-11], N[(N[(N[(N[(y$95$m * y$95$m), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(y$95$m + N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(z * N[(z / y$95$m), $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 7 \cdot 10^{-11}:\\
\;\;\;\;\frac{\left(y\_m \cdot y\_m + x \cdot x\right) - z \cdot z}{y\_m \cdot 2}\\

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


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

    1. Initial program 74.3%

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

    if 7.00000000000000038e-11 < y

    1. Initial program 57.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 86.7% accurate, 0.7× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;x \leq 4 \cdot 10^{+145}:\\ \;\;\;\;0.5 \cdot \left(\left(y\_m + \frac{x \cdot x}{y\_m}\right) - z \cdot \frac{z}{y\_m}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \frac{0.5}{y\_m}\\ \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 4e+145)
    (* 0.5 (- (+ y_m (/ (* x x) y_m)) (* z (/ z y_m))))
    (* (* x x) (/ 0.5 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 <= 4e+145) {
		tmp = 0.5 * ((y_m + ((x * x) / y_m)) - (z * (z / y_m)));
	} else {
		tmp = (x * x) * (0.5 / 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 <= 4d+145) then
        tmp = 0.5d0 * ((y_m + ((x * x) / y_m)) - (z * (z / y_m)))
    else
        tmp = (x * x) * (0.5d0 / 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 <= 4e+145) {
		tmp = 0.5 * ((y_m + ((x * x) / y_m)) - (z * (z / y_m)));
	} else {
		tmp = (x * x) * (0.5 / 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 <= 4e+145:
		tmp = 0.5 * ((y_m + ((x * x) / y_m)) - (z * (z / y_m)))
	else:
		tmp = (x * x) * (0.5 / y_m)
	return y_s * tmp
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (x <= 4e+145)
		tmp = Float64(0.5 * Float64(Float64(y_m + Float64(Float64(x * x) / y_m)) - Float64(z * Float64(z / y_m))));
	else
		tmp = Float64(Float64(x * x) * Float64(0.5 / 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 <= 4e+145)
		tmp = 0.5 * ((y_m + ((x * x) / y_m)) - (z * (z / y_m)));
	else
		tmp = (x * x) * (0.5 / y_m);
	end
	tmp_2 = y_s * tmp;
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[x, 4e+145], N[(0.5 * N[(N[(y$95$m + N[(N[(x * x), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision] - N[(z * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

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

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


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

    1. Initial program 71.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4e145 < x

    1. Initial program 64.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 50.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 1.65 \cdot 10^{+72}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \frac{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 1.65e+72) (* (* x x) (/ 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 <= 1.65e+72) {
		tmp = (x * x) * (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 <= 1.65d+72) then
        tmp = (x * x) * (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 <= 1.65e+72) {
		tmp = (x * x) * (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 <= 1.65e+72:
		tmp = (x * x) * (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 <= 1.65e+72)
		tmp = Float64(Float64(x * x) * Float64(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 <= 1.65e+72)
		tmp = (x * x) * (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, 1.65e+72], N[(N[(x * x), $MachinePrecision] * N[(0.5 / y$95$m), $MachinePrecision]), $MachinePrecision], N[(y$95$m * 0.5), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

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

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


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

    1. Initial program 75.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.65e72 < y

    1. Initial program 45.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    7. Simplified74.3%

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

Alternative 9: 33.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 70.2%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{y \cdot 0.5} \]
  7. Simplified33.7%

    \[\leadsto \color{blue}{y \cdot 0.5} \]
  8. Add Preprocessing

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

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

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

Reproduce

?
herbie shell --seed 2024119 
(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)))