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

Percentage Accurate: 69.1% → 96.5%
Time: 10.6s
Alternatives: 10
Speedup: 0.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 69.1% 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: 96.5% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 59.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(x + z\right) \cdot \color{blue}{\left(-1 \cdot z\right)}\right) \cdot \frac{0.5}{y} \]
    11. Step-by-step derivation
      1. neg-mul-123.7%

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

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

      \[\leadsto \color{blue}{z \cdot \left(-0.5 \cdot \frac{x}{y} + -0.5 \cdot \frac{z}{y}\right)} \]
    14. Step-by-step derivation
      1. distribute-lft-out28.7%

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 70.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 97.1% accurate, 0.2× speedup?

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

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

\mathbf{elif}\;t\_1 \leq 10^{+298}:\\
\;\;\;\;t\_1\\

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

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


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

    1. Initial program 64.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 99.6%

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

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

    1. Initial program 69.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 84.0% accurate, 0.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 7.4999999999999999e47

    1. Initial program 67.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.4999999999999999e47 < z

    1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 82.8% accurate, 0.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 1.46e34

    1. Initial program 66.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.46e34 < z

    1. Initial program 68.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 79.5% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.1999999999999997e100 < y

    1. Initial program 26.4%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 55.1% accurate, 1.1× speedup?

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

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 1.25 \cdot 10^{+77}:\\
\;\;\;\;\left(x \cdot \left(x - z\_m\right)\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.25000000000000001e77

    1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.25000000000000001e77 < y

    1. Initial program 34.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 54.6% accurate, 1.1× speedup?

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

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 2.1 \cdot 10^{+63}:\\
\;\;\;\;y\_m \cdot 0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 2.1000000000000002e63

    1. Initial program 67.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.1000000000000002e63 < z

    1. Initial program 63.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(x + z\right) \cdot \color{blue}{\left(-1 \cdot z\right)}\right) \cdot \frac{0.5}{y} \]
    11. Step-by-step derivation
      1. neg-mul-170.7%

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

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

      \[\leadsto \color{blue}{z \cdot \left(-0.5 \cdot \frac{x}{y} + -0.5 \cdot \frac{z}{y}\right)} \]
    14. Step-by-step derivation
      1. distribute-lft-out65.4%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 49.8% accurate, 1.2× speedup?

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

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 5.2 \cdot 10^{+63}:\\
\;\;\;\;y\_m \cdot 0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 5.2000000000000002e63

    1. Initial program 67.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.2000000000000002e63 < z

    1. Initial program 63.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(x + z\right) \cdot \color{blue}{\left(-1 \cdot z\right)}\right) \cdot \frac{0.5}{y} \]
    11. Step-by-step derivation
      1. neg-mul-170.7%

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

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

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

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

Alternative 9: 36.6% accurate, 1.2× speedup?

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

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 7.8 \cdot 10^{+154}:\\
\;\;\;\;y\_m \cdot 0.5\\

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


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

    1. Initial program 68.3%

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

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

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

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

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

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

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

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

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

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

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

    if 7.8000000000000006e154 < z

    1. Initial program 52.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(x + z\right) \cdot \color{blue}{\left(-1 \cdot z\right)}\right) \cdot \frac{0.5}{y} \]
    11. Step-by-step derivation
      1. neg-mul-183.6%

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

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{x \cdot z}{y}} \]
    14. Step-by-step derivation
      1. associate-/l*27.3%

        \[\leadsto -0.5 \cdot \color{blue}{\left(x \cdot \frac{z}{y}\right)} \]
    15. Simplified27.3%

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

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

Alternative 10: 33.0% accurate, 5.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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