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

Percentage Accurate: 69.6% → 90.1%
Time: 9.6s
Alternatives: 8
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 8 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.6% 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: 90.1% accurate, 0.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 9.6 \cdot 10^{+89}:\\ \;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, \left(y\_m - z\_m\right) \cdot \left(y\_m + z\_m\right)\right)}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\left(y\_m + z\_m\right) \cdot \frac{y\_m - 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 (<= y_m 9.6e+89)
    (* 0.5 (/ (fma x x (* (- y_m z_m) (+ y_m z_m))) y_m))
    (* 0.5 (* (+ y_m 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 (y_m <= 9.6e+89) {
		tmp = 0.5 * (fma(x, x, ((y_m - z_m) * (y_m + z_m))) / y_m);
	} else {
		tmp = 0.5 * ((y_m + 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 (y_m <= 9.6e+89)
		tmp = Float64(0.5 * Float64(fma(x, x, Float64(Float64(y_m - z_m) * Float64(y_m + z_m))) / y_m));
	else
		tmp = Float64(0.5 * Float64(Float64(y_m + z_m) * Float64(Float64(y_m - z_m) / y_m)));
	end
	return Float64(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, 9.6e+89], N[(0.5 * N[(N[(x * x + N[(N[(y$95$m - z$95$m), $MachinePrecision] * N[(y$95$m + z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(y$95$m + z$95$m), $MachinePrecision] * N[(N[(y$95$m - 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}\;y\_m \leq 9.6 \cdot 10^{+89}:\\
\;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, \left(y\_m - z\_m\right) \cdot \left(y\_m + z\_m\right)\right)}{y\_m}\\

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


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

    1. Initial program 73.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.60000000000000018e89 < y

    1. Initial program 29.0%

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified30.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. Step-by-step derivation
      1. difference-of-squares33.7%

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

        \[\leadsto 0.5 \cdot \frac{\mathsf{fma}\left(x, x, \color{blue}{\left(y - z\right) \cdot \left(y + z\right)}\right)}{y} \]
    6. Applied egg-rr33.7%

      \[\leadsto 0.5 \cdot \frac{\mathsf{fma}\left(x, x, \color{blue}{\left(y - z\right) \cdot \left(y + z\right)}\right)}{y} \]
    7. Taylor expanded in x around 0 33.7%

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

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

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

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

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

Alternative 2: 53.0% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;y\_m \leq 4.7 \cdot 10^{-206}:\\
\;\;\;\;\frac{0.5 \cdot z\_m}{\frac{y\_m}{y\_m - z\_m}}\\

\mathbf{elif}\;y\_m \leq 4.3 \cdot 10^{-125}:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < 1.35e-268 or 4.6999999999999999e-206 < y < 4.3000000000000002e-125

    1. Initial program 69.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.35e-268 < y < 4.6999999999999999e-206

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \frac{\mathsf{fma}\left(x, x, \color{blue}{\left(y - z\right) \cdot \left(y + z\right)}\right)}{y} \]
    7. Taylor expanded in x around 0 67.5%

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

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

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

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

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

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

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

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

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

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

    if 4.3000000000000002e-125 < y < 6.7999999999999999e-5

    1. Initial program 83.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\mathsf{fma}\left(x, x, \color{blue}{\left(y - z\right) \cdot \left(y + z\right)}\right)}{y} \]
    6. Applied egg-rr91.5%

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

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

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

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

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

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

    if 6.7999999999999999e-5 < y

    1. Initial program 39.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.35 \cdot 10^{-268}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \frac{0.5}{y}\\ \mathbf{elif}\;y \leq 4.7 \cdot 10^{-206}:\\ \;\;\;\;\frac{0.5 \cdot z}{\frac{y}{y - z}}\\ \mathbf{elif}\;y \leq 4.3 \cdot 10^{-125}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \frac{0.5}{y}\\ \mathbf{elif}\;y \leq 6.8 \cdot 10^{-5}:\\ \;\;\;\;0.5 \cdot \left(z \cdot \frac{y - z}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 53.1% accurate, 0.5× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := 0.5 \cdot \left(z\_m \cdot \frac{y\_m - z\_m}{y\_m}\right)\\ t_1 := \left(x \cdot x\right) \cdot \frac{0.5}{y\_m}\\ y\_s \cdot \begin{array}{l} \mathbf{if}\;y\_m \leq 5.4 \cdot 10^{-271}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y\_m \leq 8.5 \cdot 10^{-203}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y\_m \leq 2.25 \cdot 10^{-125}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y\_m \leq 6.8 \cdot 10^{-5}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;y\_m \cdot 0.5\\ \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 (* 0.5 (* z_m (/ (- y_m z_m) y_m))))
        (t_1 (* (* x x) (/ 0.5 y_m))))
   (*
    y_s
    (if (<= y_m 5.4e-271)
      t_1
      (if (<= y_m 8.5e-203)
        t_0
        (if (<= y_m 2.25e-125) t_1 (if (<= y_m 6.8e-5) t_0 (* 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 t_0 = 0.5 * (z_m * ((y_m - z_m) / y_m));
	double t_1 = (x * x) * (0.5 / y_m);
	double tmp;
	if (y_m <= 5.4e-271) {
		tmp = t_1;
	} else if (y_m <= 8.5e-203) {
		tmp = t_0;
	} else if (y_m <= 2.25e-125) {
		tmp = t_1;
	} else if (y_m <= 6.8e-5) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 0.5d0 * (z_m * ((y_m - z_m) / y_m))
    t_1 = (x * x) * (0.5d0 / y_m)
    if (y_m <= 5.4d-271) then
        tmp = t_1
    else if (y_m <= 8.5d-203) then
        tmp = t_0
    else if (y_m <= 2.25d-125) then
        tmp = t_1
    else if (y_m <= 6.8d-5) then
        tmp = t_0
    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 t_0 = 0.5 * (z_m * ((y_m - z_m) / y_m));
	double t_1 = (x * x) * (0.5 / y_m);
	double tmp;
	if (y_m <= 5.4e-271) {
		tmp = t_1;
	} else if (y_m <= 8.5e-203) {
		tmp = t_0;
	} else if (y_m <= 2.25e-125) {
		tmp = t_1;
	} else if (y_m <= 6.8e-5) {
		tmp = t_0;
	} 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):
	t_0 = 0.5 * (z_m * ((y_m - z_m) / y_m))
	t_1 = (x * x) * (0.5 / y_m)
	tmp = 0
	if y_m <= 5.4e-271:
		tmp = t_1
	elif y_m <= 8.5e-203:
		tmp = t_0
	elif y_m <= 2.25e-125:
		tmp = t_1
	elif y_m <= 6.8e-5:
		tmp = t_0
	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)
	t_0 = Float64(0.5 * Float64(z_m * Float64(Float64(y_m - z_m) / y_m)))
	t_1 = Float64(Float64(x * x) * Float64(0.5 / y_m))
	tmp = 0.0
	if (y_m <= 5.4e-271)
		tmp = t_1;
	elseif (y_m <= 8.5e-203)
		tmp = t_0;
	elseif (y_m <= 2.25e-125)
		tmp = t_1;
	elseif (y_m <= 6.8e-5)
		tmp = t_0;
	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)
	t_0 = 0.5 * (z_m * ((y_m - z_m) / y_m));
	t_1 = (x * x) * (0.5 / y_m);
	tmp = 0.0;
	if (y_m <= 5.4e-271)
		tmp = t_1;
	elseif (y_m <= 8.5e-203)
		tmp = t_0;
	elseif (y_m <= 2.25e-125)
		tmp = t_1;
	elseif (y_m <= 6.8e-5)
		tmp = t_0;
	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_] := Block[{t$95$0 = N[(0.5 * N[(z$95$m * N[(N[(y$95$m - z$95$m), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] * N[(0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[y$95$m, 5.4e-271], t$95$1, If[LessEqual[y$95$m, 8.5e-203], t$95$0, If[LessEqual[y$95$m, 2.25e-125], t$95$1, If[LessEqual[y$95$m, 6.8e-5], t$95$0, 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)

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(z\_m \cdot \frac{y\_m - z\_m}{y\_m}\right)\\
t_1 := \left(x \cdot x\right) \cdot \frac{0.5}{y\_m}\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 5.4 \cdot 10^{-271}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y\_m \leq 8.5 \cdot 10^{-203}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y\_m \leq 2.25 \cdot 10^{-125}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y\_m \leq 6.8 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 5.3999999999999997e-271 or 8.50000000000000031e-203 < y < 2.25000000000000006e-125

    1. Initial program 69.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.3999999999999997e-271 < y < 8.50000000000000031e-203 or 2.25000000000000006e-125 < y < 6.7999999999999999e-5

    1. Initial program 89.3%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \frac{\mathsf{fma}\left(x, x, \color{blue}{\left(y - z\right) \cdot \left(y + z\right)}\right)}{y} \]
    7. Taylor expanded in x around 0 64.8%

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

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

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

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

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

    if 6.7999999999999999e-5 < y

    1. Initial program 39.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 5.4 \cdot 10^{-271}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \frac{0.5}{y}\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{-203}:\\ \;\;\;\;0.5 \cdot \left(z \cdot \frac{y - z}{y}\right)\\ \mathbf{elif}\;y \leq 2.25 \cdot 10^{-125}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \frac{0.5}{y}\\ \mathbf{elif}\;y \leq 6.8 \cdot 10^{-5}:\\ \;\;\;\;0.5 \cdot \left(z \cdot \frac{y - z}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 88.3% accurate, 0.7× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;y\_m \leq 2.1 \cdot 10^{+90}:\\ \;\;\;\;\frac{\left(x \cdot x + y\_m \cdot y\_m\right) - z\_m \cdot z\_m}{y\_m \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\left(y\_m + z\_m\right) \cdot \frac{y\_m - 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 (<= y_m 2.1e+90)
    (/ (- (+ (* x x) (* y_m y_m)) (* z_m z_m)) (* y_m 2.0))
    (* 0.5 (* (+ y_m 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 (y_m <= 2.1e+90) {
		tmp = (((x * x) + (y_m * y_m)) - (z_m * z_m)) / (y_m * 2.0);
	} else {
		tmp = 0.5 * ((y_m + 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 (y_m <= 2.1d+90) then
        tmp = (((x * x) + (y_m * y_m)) - (z_m * z_m)) / (y_m * 2.0d0)
    else
        tmp = 0.5d0 * ((y_m + 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 (y_m <= 2.1e+90) {
		tmp = (((x * x) + (y_m * y_m)) - (z_m * z_m)) / (y_m * 2.0);
	} else {
		tmp = 0.5 * ((y_m + 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 y_m <= 2.1e+90:
		tmp = (((x * x) + (y_m * y_m)) - (z_m * z_m)) / (y_m * 2.0)
	else:
		tmp = 0.5 * ((y_m + 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 (y_m <= 2.1e+90)
		tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y_m * y_m)) - Float64(z_m * z_m)) / Float64(y_m * 2.0));
	else
		tmp = Float64(0.5 * Float64(Float64(y_m + z_m) * Float64(Float64(y_m - 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 (y_m <= 2.1e+90)
		tmp = (((x * x) + (y_m * y_m)) - (z_m * z_m)) / (y_m * 2.0);
	else
		tmp = 0.5 * ((y_m + 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[y$95$m, 2.1e+90], 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[(0.5 * N[(N[(y$95$m + z$95$m), $MachinePrecision] * N[(N[(y$95$m - 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}\;y\_m \leq 2.1 \cdot 10^{+90}:\\
\;\;\;\;\frac{\left(x \cdot x + y\_m \cdot y\_m\right) - z\_m \cdot z\_m}{y\_m \cdot 2}\\

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


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

    1. Initial program 73.9%

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

    if 2.09999999999999981e90 < y

    1. Initial program 29.0%

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified30.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. Step-by-step derivation
      1. difference-of-squares33.7%

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

        \[\leadsto 0.5 \cdot \frac{\mathsf{fma}\left(x, x, \color{blue}{\left(y - z\right) \cdot \left(y + z\right)}\right)}{y} \]
    6. Applied egg-rr33.7%

      \[\leadsto 0.5 \cdot \frac{\mathsf{fma}\left(x, x, \color{blue}{\left(y - z\right) \cdot \left(y + z\right)}\right)}{y} \]
    7. Taylor expanded in x around 0 33.7%

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

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

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

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

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

Alternative 5: 76.9% accurate, 0.8× speedup?

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

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


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

    1. Initial program 69.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \frac{\mathsf{fma}\left(x, x, \color{blue}{\left(y - z\right) \cdot \left(y + z\right)}\right)}{y} \]
    7. Taylor expanded in x around 0 60.8%

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

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

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

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

    if 8.1999999999999996e152 < (*.f64 x x)

    1. Initial program 58.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 71.6% 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}\;x \leq 3.7 \cdot 10^{+76}:\\ \;\;\;\;\frac{0.5 \cdot \left(y\_m + z\_m\right)}{\frac{y\_m}{y\_m - z\_m}}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\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 (<= x 3.7e+76)
    (/ (* 0.5 (+ y_m z_m)) (/ y_m (- y_m z_m)))
    (* (* x x) (/ 0.5 y_m)))))
z_m = fabs(z);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z_m) {
	double tmp;
	if (x <= 3.7e+76) {
		tmp = (0.5 * (y_m + z_m)) / (y_m / (y_m - z_m));
	} else {
		tmp = (x * x) * (0.5 / y_m);
	}
	return y_s * tmp;
}
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z_m)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if (x <= 3.7d+76) then
        tmp = (0.5d0 * (y_m + z_m)) / (y_m / (y_m - z_m))
    else
        tmp = (x * x) * (0.5d0 / y_m)
    end if
    code = y_s * tmp
end function
z_m = Math.abs(z);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z_m) {
	double tmp;
	if (x <= 3.7e+76) {
		tmp = (0.5 * (y_m + z_m)) / (y_m / (y_m - z_m));
	} else {
		tmp = (x * x) * (0.5 / y_m);
	}
	return y_s * tmp;
}
z_m = math.fabs(z)
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z_m):
	tmp = 0
	if x <= 3.7e+76:
		tmp = (0.5 * (y_m + z_m)) / (y_m / (y_m - z_m))
	else:
		tmp = (x * x) * (0.5 / y_m)
	return y_s * tmp
z_m = abs(z)
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z_m)
	tmp = 0.0
	if (x <= 3.7e+76)
		tmp = Float64(Float64(0.5 * Float64(y_m + z_m)) / Float64(y_m / Float64(y_m - z_m)));
	else
		tmp = Float64(Float64(x * x) * Float64(0.5 / y_m));
	end
	return Float64(y_s * tmp)
end
z_m = abs(z);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x, y_m, z_m)
	tmp = 0.0;
	if (x <= 3.7e+76)
		tmp = (0.5 * (y_m + z_m)) / (y_m / (y_m - z_m));
	else
		tmp = (x * x) * (0.5 / y_m);
	end
	tmp_2 = y_s * tmp;
end
z_m = N[Abs[z], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z$95$m_] := N[(y$95$s * If[LessEqual[x, 3.7e+76], N[(N[(0.5 * N[(y$95$m + z$95$m), $MachinePrecision]), $MachinePrecision] / N[(y$95$m / N[(y$95$m - z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $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}\;x \leq 3.7 \cdot 10^{+76}:\\
\;\;\;\;\frac{0.5 \cdot \left(y\_m + z\_m\right)}{\frac{y\_m}{y\_m - z\_m}}\\

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


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

    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.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-define69.3%

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

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

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

        \[\leadsto 0.5 \cdot \frac{\mathsf{fma}\left(x, x, \color{blue}{\left(y - z\right) \cdot \left(y + z\right)}\right)}{y} \]
    6. Applied egg-rr71.2%

      \[\leadsto 0.5 \cdot \frac{\mathsf{fma}\left(x, x, \color{blue}{\left(y - z\right) \cdot \left(y + z\right)}\right)}{y} \]
    7. Taylor expanded in x around 0 50.4%

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

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

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

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

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

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

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

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

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

    if 3.6999999999999999e76 < x

    1. Initial program 56.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 52.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}\;y\_m \leq 5 \cdot 10^{+59}:\\ \;\;\;\;\left(x \cdot x\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 5e+59) (* (* x x) (/ 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 <= 5e+59) {
		tmp = (x * x) * (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 <= 5d+59) then
        tmp = (x * x) * (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 <= 5e+59) {
		tmp = (x * x) * (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 <= 5e+59:
		tmp = (x * x) * (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 <= 5e+59)
		tmp = Float64(Float64(x * x) * 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 <= 5e+59)
		tmp = (x * x) * (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, 5e+59], N[(N[(x * x), $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 5 \cdot 10^{+59}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \frac{0.5}{y\_m}\\

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


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

    1. Initial program 73.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.9999999999999997e59 < y

    1. Initial program 34.6%

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 34.1% 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 64.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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 2024172 
(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)))