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

Percentage Accurate: 69.5% → 97.2%
Time: 13.0s
Alternatives: 11
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 11 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.5% accurate, 1.0× speedup?

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

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

Alternative 1: 97.2% accurate, 0.1× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 3.1500000000000001e-109

    1. Initial program 69.8%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 65.2%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\left(x + z\right) \cdot \left(x - z\right)\right)} \cdot \frac{0.5}{y} \]
    8. Taylor expanded in y around 0 73.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-*r/73.5%

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

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

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

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

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

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

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

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

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

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

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

    if 3.1500000000000001e-109 < y < 2.4e23

    1. Initial program 85.8%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 85.9%

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

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

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

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

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

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

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

    if 2.4e23 < y

    1. Initial program 50.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.6% accurate, 0.0× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := \mathsf{hypot}\left(\frac{x}{\sqrt{y\_m}}, \sqrt{y\_m}\right)\\ t_1 := \frac{z}{\sqrt{y\_m}}\\ y\_s \cdot \left(0.5 \cdot \left(\left(t\_0 + t\_1\right) \cdot \left(t\_0 - t\_1\right)\right)\right) \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
 :precision binary64
 (let* ((t_0 (hypot (/ x (sqrt y_m)) (sqrt y_m))) (t_1 (/ z (sqrt y_m))))
   (* y_s (* 0.5 (* (+ t_0 t_1) (- t_0 t_1))))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double t_0 = hypot((x / sqrt(y_m)), sqrt(y_m));
	double t_1 = z / sqrt(y_m);
	return y_s * (0.5 * ((t_0 + t_1) * (t_0 - t_1)));
}
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	double t_0 = Math.hypot((x / Math.sqrt(y_m)), Math.sqrt(y_m));
	double t_1 = z / Math.sqrt(y_m);
	return y_s * (0.5 * ((t_0 + t_1) * (t_0 - t_1)));
}
y\_m = math.fabs(y)
y\_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	t_0 = math.hypot((x / math.sqrt(y_m)), math.sqrt(y_m))
	t_1 = z / math.sqrt(y_m)
	return y_s * (0.5 * ((t_0 + t_1) * (t_0 - t_1)))
y\_m = abs(y)
y\_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	t_0 = hypot(Float64(x / sqrt(y_m)), sqrt(y_m))
	t_1 = Float64(z / sqrt(y_m))
	return Float64(y_s * Float64(0.5 * Float64(Float64(t_0 + t_1) * Float64(t_0 - t_1))))
end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
function tmp = code(y_s, x, y_m, z)
	t_0 = hypot((x / sqrt(y_m)), sqrt(y_m));
	t_1 = z / sqrt(y_m);
	tmp = y_s * (0.5 * ((t_0 + t_1) * (t_0 - t_1)));
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := Block[{t$95$0 = N[Sqrt[N[(x / N[Sqrt[y$95$m], $MachinePrecision]), $MachinePrecision] ^ 2 + N[Sqrt[y$95$m], $MachinePrecision] ^ 2], $MachinePrecision]}, Block[{t$95$1 = N[(z / N[Sqrt[y$95$m], $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * N[(0.5 * N[(N[(t$95$0 + t$95$1), $MachinePrecision] * N[(t$95$0 - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)

\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(\frac{x}{\sqrt{y\_m}}, \sqrt{y\_m}\right)\\
t_1 := \frac{z}{\sqrt{y\_m}}\\
y\_s \cdot \left(0.5 \cdot \left(\left(t\_0 + t\_1\right) \cdot \left(t\_0 - t\_1\right)\right)\right)
\end{array}
\end{array}
Derivation
  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.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-define70.5%

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

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

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

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

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

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

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

    \[\leadsto 0.5 \cdot \left(\left(\mathsf{hypot}\left(\frac{x}{\sqrt{y}}, \sqrt{y}\right) + \frac{z}{\sqrt{y}}\right) \cdot \left(\mathsf{hypot}\left(\frac{x}{\sqrt{y}}, \sqrt{y}\right) - \frac{z}{\sqrt{y}}\right)\right) \]
  9. Add Preprocessing

Alternative 3: 44.2% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;z \leq 3.3 \cdot 10^{-152}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 8.6 \cdot 10^{-57}:\\
\;\;\;\;0.5 \cdot y\_m\\

\mathbf{elif}\;z \leq 5.6 \cdot 10^{+64}:\\
\;\;\;\;t\_0\\

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

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

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < 3.0500000000000001e-265 or 3.29999999999999998e-152 < z < 8.60000000000000043e-57 or 5.60000000000000047e64 < z < 3.99999999999999987e90

    1. Initial program 64.8%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 40.4%

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

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified40.4%

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

    if 3.0500000000000001e-265 < z < 3.29999999999999998e-152 or 8.60000000000000043e-57 < z < 5.60000000000000047e64

    1. Initial program 90.1%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 70.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.99999999999999987e90 < z < 1.6999999999999999e92

    1. Initial program 99.5%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 67.0%

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt[3]{\color{blue}{{x}^{6}}} \cdot \frac{0.5}{y} \]
    9. Step-by-step derivation
      1. pow1/367.4%

        \[\leadsto \color{blue}{{\left({x}^{6}\right)}^{0.3333333333333333}} \cdot \frac{0.5}{y} \]
      2. pow-pow67.4%

        \[\leadsto \color{blue}{{x}^{\left(6 \cdot 0.3333333333333333\right)}} \cdot \frac{0.5}{y} \]
      3. metadata-eval67.4%

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

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

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

    if 1.6999999999999999e92 < z

    1. Initial program 51.7%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 51.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 3.05 \cdot 10^{-265}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-152}:\\ \;\;\;\;\left(x + z\right) \cdot \left(0.5 \cdot \frac{x}{y}\right)\\ \mathbf{elif}\;z \leq 8.6 \cdot 10^{-57}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;z \leq 5.6 \cdot 10^{+64}:\\ \;\;\;\;\left(x + z\right) \cdot \left(0.5 \cdot \frac{x}{y}\right)\\ \mathbf{elif}\;z \leq 4 \cdot 10^{+90}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{+92}:\\ \;\;\;\;\frac{0.5}{y} \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x + z\right) \cdot \left(-0.5 \cdot \frac{z}{y}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 44.2% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;z \leq 1.4 \cdot 10^{-155}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 8.5 \cdot 10^{-57}:\\
\;\;\;\;0.5 \cdot y\_m\\

\mathbf{elif}\;z \leq 8.5 \cdot 10^{+64}:\\
\;\;\;\;t\_0\\

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

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

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < 9.0000000000000006e-266 or 1.4e-155 < z < 8.49999999999999955e-57 or 8.4999999999999998e64 < z < 2.90000000000000025e89

    1. Initial program 64.8%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 40.4%

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

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified40.4%

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

    if 9.0000000000000006e-266 < z < 1.4e-155 or 8.49999999999999955e-57 < z < 8.4999999999999998e64

    1. Initial program 90.1%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 70.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.90000000000000025e89 < z < 1.6999999999999999e92

    1. Initial program 99.5%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 67.0%

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt[3]{\color{blue}{{x}^{6}}} \cdot \frac{0.5}{y} \]
    9. Step-by-step derivation
      1. pow1/367.4%

        \[\leadsto \color{blue}{{\left({x}^{6}\right)}^{0.3333333333333333}} \cdot \frac{0.5}{y} \]
      2. pow-pow67.4%

        \[\leadsto \color{blue}{{x}^{\left(6 \cdot 0.3333333333333333\right)}} \cdot \frac{0.5}{y} \]
      3. metadata-eval67.4%

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

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

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

    if 1.6999999999999999e92 < z

    1. Initial program 51.7%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 51.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 9 \cdot 10^{-266}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{-155}:\\ \;\;\;\;\left(x + z\right) \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{-57}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{+64}:\\ \;\;\;\;\left(x + z\right) \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \mathbf{elif}\;z \leq 2.9 \cdot 10^{+89}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{+92}:\\ \;\;\;\;\frac{0.5}{y} \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x + z\right) \cdot \left(-0.5 \cdot \frac{z}{y}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 43.6% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;z \leq 2.1 \cdot 10^{-153}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 8 \cdot 10^{-57}:\\
\;\;\;\;0.5 \cdot y\_m\\

\mathbf{elif}\;z \leq 9.2 \cdot 10^{+64}:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 5.90000000000000012e-265 or 2.10000000000000004e-153 < z < 7.99999999999999964e-57 or 9.2e64 < z < 7.8999999999999999e93

    1. Initial program 65.7%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 40.1%

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

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified40.1%

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

    if 5.90000000000000012e-265 < z < 2.10000000000000004e-153 or 7.99999999999999964e-57 < z < 9.2e64

    1. Initial program 90.1%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 70.0%

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt[3]{\color{blue}{{x}^{6}}} \cdot \frac{0.5}{y} \]
    9. Step-by-step derivation
      1. pow1/340.2%

        \[\leadsto \color{blue}{{\left({x}^{6}\right)}^{0.3333333333333333}} \cdot \frac{0.5}{y} \]
      2. pow-pow55.1%

        \[\leadsto \color{blue}{{x}^{\left(6 \cdot 0.3333333333333333\right)}} \cdot \frac{0.5}{y} \]
      3. metadata-eval55.1%

        \[\leadsto {x}^{\color{blue}{2}} \cdot \frac{0.5}{y} \]
      4. unpow255.1%

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

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

    if 7.8999999999999999e93 < z

    1. Initial program 50.7%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 50.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 5.9 \cdot 10^{-265}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{-153}:\\ \;\;\;\;\frac{0.5}{y} \cdot \left(x \cdot x\right)\\ \mathbf{elif}\;z \leq 8 \cdot 10^{-57}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;z \leq 9.2 \cdot 10^{+64}:\\ \;\;\;\;\frac{0.5}{y} \cdot \left(x \cdot x\right)\\ \mathbf{elif}\;z \leq 7.9 \cdot 10^{+93}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{else}:\\ \;\;\;\;\left(x + z\right) \cdot \left(-0.5 \cdot \frac{z}{y}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 96.4% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 69.6%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 65.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.65e-118 < y

    1. Initial program 61.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 78.2% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 73.5%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 63.0%

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

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

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

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

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

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

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

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

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

    if 5.3999999999999999e120 < y

    1. Initial program 33.1%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 79.5%

      \[\leadsto \color{blue}{0.5 \cdot y} \]
    4. Step-by-step derivation
      1. *-commutative79.5%

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified79.5%

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

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

Alternative 8: 80.5% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 73.5%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 63.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.50000000000000003e122 < y

    1. Initial program 33.1%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 79.5%

      \[\leadsto \color{blue}{0.5 \cdot y} \]
    4. Step-by-step derivation
      1. *-commutative79.5%

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified79.5%

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

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

Alternative 9: 80.5% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 73.5%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 63.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.2e121 < y

    1. Initial program 33.1%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 79.5%

      \[\leadsto \color{blue}{0.5 \cdot y} \]
    4. Step-by-step derivation
      1. *-commutative79.5%

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified79.5%

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

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

Alternative 10: 52.2% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 72.2%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 65.3%

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt[3]{\color{blue}{{x}^{6}}} \cdot \frac{0.5}{y} \]
    9. Step-by-step derivation
      1. pow1/328.9%

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

        \[\leadsto \color{blue}{{x}^{\left(6 \cdot 0.3333333333333333\right)}} \cdot \frac{0.5}{y} \]
      3. metadata-eval36.2%

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

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

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

    if 4.69999999999999976e27 < y

    1. Initial program 50.6%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 66.3%

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

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified66.3%

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

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

Alternative 11: 34.4% accurate, 5.0× speedup?

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

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

    \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
  2. Add Preprocessing
  3. Taylor expanded in y around inf 34.3%

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

      \[\leadsto \color{blue}{y \cdot 0.5} \]
  5. Simplified34.3%

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

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

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

  :alt
  (- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x)))

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