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

Percentage Accurate: 68.8% → 93.4%
Time: 10.4s
Alternatives: 5
Speedup: 0.5×

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 5 alternatives:

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

Initial Program: 68.8% 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: 93.4% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 74.6%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num74.6%

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

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

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

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

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

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

        \[\leadsto {\left(y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - \color{blue}{{z}^{2}}}\right)}^{-1} \]
    4. Applied egg-rr74.6%

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

        \[\leadsto \color{blue}{\frac{1}{y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
      2. associate-*r/74.6%

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

      \[\leadsto \color{blue}{\frac{1}{\frac{y \cdot 2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt74.6%

        \[\leadsto \frac{1}{\frac{y \cdot 2}{\color{blue}{\sqrt{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}} \cdot \sqrt{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}} - {z}^{2}}} \]
      2. sqrt-unprod58.0%

        \[\leadsto \frac{1}{\frac{y \cdot 2}{\color{blue}{\sqrt{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} \cdot {\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}} - {z}^{2}}} \]
      3. pow-prod-up58.0%

        \[\leadsto \frac{1}{\frac{y \cdot 2}{\sqrt{\color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{\left(2 + 2\right)}}} - {z}^{2}}} \]
      4. metadata-eval58.0%

        \[\leadsto \frac{1}{\frac{y \cdot 2}{\sqrt{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{\color{blue}{4}}} - {z}^{2}}} \]
    8. Applied egg-rr58.0%

      \[\leadsto \frac{1}{\frac{y \cdot 2}{\color{blue}{\sqrt{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{4}}} - {z}^{2}}} \]
    9. Step-by-step derivation
      1. hypot-undefine58.0%

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{y \cdot 2}{\sqrt{{\left(\sqrt{y \cdot y + \color{blue}{x \cdot x}}\right)}^{4}} - {z}^{2}}} \]
      7. hypot-define58.0%

        \[\leadsto \frac{1}{\frac{y \cdot 2}{\sqrt{{\color{blue}{\left(\mathsf{hypot}\left(y, x\right)\right)}}^{4}} - {z}^{2}}} \]
    10. Simplified58.0%

      \[\leadsto \frac{1}{\frac{y \cdot 2}{\color{blue}{\sqrt{{\left(\mathsf{hypot}\left(y, x\right)\right)}^{4}}} - {z}^{2}}} \]
    11. Taylor expanded in z around inf 29.1%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{-2 \cdot y}{{z}^{2}}}} \]
      2. *-commutative29.1%

        \[\leadsto \frac{1}{\frac{\color{blue}{y \cdot -2}}{{z}^{2}}} \]
    13. Simplified29.1%

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

        \[\leadsto \color{blue}{\frac{1}{y \cdot -2} \cdot {z}^{2}} \]
      2. unpow229.1%

        \[\leadsto \frac{1}{y \cdot -2} \cdot \color{blue}{\left(z \cdot z\right)} \]
      3. associate-*r*32.3%

        \[\leadsto \color{blue}{\left(\frac{1}{y \cdot -2} \cdot z\right) \cdot z} \]
      4. *-commutative32.3%

        \[\leadsto \left(\frac{1}{\color{blue}{-2 \cdot y}} \cdot z\right) \cdot z \]
      5. associate-/r*32.3%

        \[\leadsto \left(\color{blue}{\frac{\frac{1}{-2}}{y}} \cdot z\right) \cdot z \]
      6. metadata-eval32.3%

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

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

    if 0.0 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y 2))

    1. Initial program 69.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 42.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 := x \cdot \frac{x}{y\_m \cdot 2}\\ y\_s \cdot \begin{array}{l} \mathbf{if}\;z \leq 1.6 \cdot 10^{-294}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{elif}\;z \leq 5.7 \cdot 10^{-158}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{-128}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{elif}\;z \leq 9 \cdot 10^{-107}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-37}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{+124}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{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 (/ x (* y_m 2.0)))))
   (*
    y_s
    (if (<= z 1.6e-294)
      (* y_m 0.5)
      (if (<= z 5.7e-158)
        t_0
        (if (<= z 3.8e-128)
          (* y_m 0.5)
          (if (<= z 9e-107)
            t_0
            (if (<= z 3.3e-37)
              (* y_m 0.5)
              (if (<= z 1.45e+124) t_0 (* z (* 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 t_0 = x * (x / (y_m * 2.0));
	double tmp;
	if (z <= 1.6e-294) {
		tmp = y_m * 0.5;
	} else if (z <= 5.7e-158) {
		tmp = t_0;
	} else if (z <= 3.8e-128) {
		tmp = y_m * 0.5;
	} else if (z <= 9e-107) {
		tmp = t_0;
	} else if (z <= 3.3e-37) {
		tmp = y_m * 0.5;
	} else if (z <= 1.45e+124) {
		tmp = t_0;
	} else {
		tmp = z * (z * (-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) :: t_0
    real(8) :: tmp
    t_0 = x * (x / (y_m * 2.0d0))
    if (z <= 1.6d-294) then
        tmp = y_m * 0.5d0
    else if (z <= 5.7d-158) then
        tmp = t_0
    else if (z <= 3.8d-128) then
        tmp = y_m * 0.5d0
    else if (z <= 9d-107) then
        tmp = t_0
    else if (z <= 3.3d-37) then
        tmp = y_m * 0.5d0
    else if (z <= 1.45d+124) then
        tmp = t_0
    else
        tmp = z * (z * ((-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 t_0 = x * (x / (y_m * 2.0));
	double tmp;
	if (z <= 1.6e-294) {
		tmp = y_m * 0.5;
	} else if (z <= 5.7e-158) {
		tmp = t_0;
	} else if (z <= 3.8e-128) {
		tmp = y_m * 0.5;
	} else if (z <= 9e-107) {
		tmp = t_0;
	} else if (z <= 3.3e-37) {
		tmp = y_m * 0.5;
	} else if (z <= 1.45e+124) {
		tmp = t_0;
	} else {
		tmp = z * (z * (-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):
	t_0 = x * (x / (y_m * 2.0))
	tmp = 0
	if z <= 1.6e-294:
		tmp = y_m * 0.5
	elif z <= 5.7e-158:
		tmp = t_0
	elif z <= 3.8e-128:
		tmp = y_m * 0.5
	elif z <= 9e-107:
		tmp = t_0
	elif z <= 3.3e-37:
		tmp = y_m * 0.5
	elif z <= 1.45e+124:
		tmp = t_0
	else:
		tmp = z * (z * (-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)
	t_0 = Float64(x * Float64(x / Float64(y_m * 2.0)))
	tmp = 0.0
	if (z <= 1.6e-294)
		tmp = Float64(y_m * 0.5);
	elseif (z <= 5.7e-158)
		tmp = t_0;
	elseif (z <= 3.8e-128)
		tmp = Float64(y_m * 0.5);
	elseif (z <= 9e-107)
		tmp = t_0;
	elseif (z <= 3.3e-37)
		tmp = Float64(y_m * 0.5);
	elseif (z <= 1.45e+124)
		tmp = t_0;
	else
		tmp = Float64(z * Float64(z * 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)
	t_0 = x * (x / (y_m * 2.0));
	tmp = 0.0;
	if (z <= 1.6e-294)
		tmp = y_m * 0.5;
	elseif (z <= 5.7e-158)
		tmp = t_0;
	elseif (z <= 3.8e-128)
		tmp = y_m * 0.5;
	elseif (z <= 9e-107)
		tmp = t_0;
	elseif (z <= 3.3e-37)
		tmp = y_m * 0.5;
	elseif (z <= 1.45e+124)
		tmp = t_0;
	else
		tmp = z * (z * (-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_] := Block[{t$95$0 = N[(x * N[(x / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[z, 1.6e-294], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z, 5.7e-158], t$95$0, If[LessEqual[z, 3.8e-128], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z, 9e-107], t$95$0, If[LessEqual[z, 3.3e-37], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z, 1.45e+124], t$95$0, N[(z * N[(z * N[(-0.5 / 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 := x \cdot \frac{x}{y\_m \cdot 2}\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 1.6 \cdot 10^{-294}:\\
\;\;\;\;y\_m \cdot 0.5\\

\mathbf{elif}\;z \leq 5.7 \cdot 10^{-158}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;z \leq 9 \cdot 10^{-107}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;z \leq 1.45 \cdot 10^{+124}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 1.6000000000000001e-294 or 5.69999999999999982e-158 < z < 3.8000000000000002e-128 or 9.00000000000000032e-107 < z < 3.29999999999999982e-37

    1. Initial program 70.0%

      \[\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 38.1%

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

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

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

    if 1.6000000000000001e-294 < z < 5.69999999999999982e-158 or 3.8000000000000002e-128 < z < 9.00000000000000032e-107 or 3.29999999999999982e-37 < z < 1.45000000000000011e124

    1. Initial program 77.2%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num77.1%

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

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

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

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

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

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

        \[\leadsto {\left(y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - \color{blue}{{z}^{2}}}\right)}^{-1} \]
    4. Applied egg-rr77.1%

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

        \[\leadsto \color{blue}{\frac{1}{y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
      2. associate-*r/77.1%

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

      \[\leadsto \color{blue}{\frac{1}{\frac{y \cdot 2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
    7. Taylor expanded in x around inf 45.3%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{2 \cdot y}{{x}^{2}}}} \]
      2. *-commutative45.3%

        \[\leadsto \frac{1}{\frac{\color{blue}{y \cdot 2}}{{x}^{2}}} \]
      3. unpow245.3%

        \[\leadsto \frac{1}{\frac{y \cdot 2}{\color{blue}{x \cdot x}}} \]
      4. associate-/r*51.3%

        \[\leadsto \frac{1}{\color{blue}{\frac{\frac{y \cdot 2}{x}}{x}}} \]
      5. *-commutative51.3%

        \[\leadsto \frac{1}{\frac{\frac{\color{blue}{2 \cdot y}}{x}}{x}} \]
    9. Applied egg-rr51.3%

      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{2 \cdot y}{x}}{x}}} \]
    10. Step-by-step derivation
      1. associate-/r/51.3%

        \[\leadsto \color{blue}{\frac{1}{\frac{2 \cdot y}{x}} \cdot x} \]
      2. clear-num51.3%

        \[\leadsto \color{blue}{\frac{x}{2 \cdot y}} \cdot x \]
      3. *-commutative51.3%

        \[\leadsto \frac{x}{\color{blue}{y \cdot 2}} \cdot x \]
    11. Applied egg-rr51.3%

      \[\leadsto \color{blue}{\frac{x}{y \cdot 2} \cdot x} \]

    if 1.45000000000000011e124 < z

    1. Initial program 70.4%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num70.4%

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

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

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

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

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

        \[\leadsto {\left(y \cdot \frac{2}{{\color{blue}{\left(\mathsf{hypot}\left(x, y\right)\right)}}^{2} - z \cdot z}\right)}^{-1} \]
      7. pow270.4%

        \[\leadsto {\left(y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - \color{blue}{{z}^{2}}}\right)}^{-1} \]
    4. Applied egg-rr70.4%

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

        \[\leadsto \color{blue}{\frac{1}{y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
      2. associate-*r/70.4%

        \[\leadsto \frac{1}{\color{blue}{\frac{y \cdot 2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
    6. Simplified70.4%

      \[\leadsto \color{blue}{\frac{1}{\frac{y \cdot 2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt70.4%

        \[\leadsto \frac{1}{\frac{y \cdot 2}{\color{blue}{\sqrt{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}} \cdot \sqrt{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}} - {z}^{2}}} \]
      2. sqrt-unprod42.4%

        \[\leadsto \frac{1}{\frac{y \cdot 2}{\color{blue}{\sqrt{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} \cdot {\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}} - {z}^{2}}} \]
      3. pow-prod-up42.4%

        \[\leadsto \frac{1}{\frac{y \cdot 2}{\sqrt{\color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{\left(2 + 2\right)}}} - {z}^{2}}} \]
      4. metadata-eval42.4%

        \[\leadsto \frac{1}{\frac{y \cdot 2}{\sqrt{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{\color{blue}{4}}} - {z}^{2}}} \]
    8. Applied egg-rr42.4%

      \[\leadsto \frac{1}{\frac{y \cdot 2}{\color{blue}{\sqrt{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{4}}} - {z}^{2}}} \]
    9. Step-by-step derivation
      1. hypot-undefine42.4%

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

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{y \cdot 2}{\sqrt{{\color{blue}{\left(\mathsf{hypot}\left(y, x\right)\right)}}^{4}} - {z}^{2}}} \]
    10. Simplified42.4%

      \[\leadsto \frac{1}{\frac{y \cdot 2}{\color{blue}{\sqrt{{\left(\mathsf{hypot}\left(y, x\right)\right)}^{4}}} - {z}^{2}}} \]
    11. Taylor expanded in z around inf 73.4%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{-2 \cdot y}{{z}^{2}}}} \]
      2. *-commutative73.4%

        \[\leadsto \frac{1}{\frac{\color{blue}{y \cdot -2}}{{z}^{2}}} \]
    13. Simplified73.4%

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

        \[\leadsto \color{blue}{\frac{1}{y \cdot -2} \cdot {z}^{2}} \]
      2. unpow273.4%

        \[\leadsto \frac{1}{y \cdot -2} \cdot \color{blue}{\left(z \cdot z\right)} \]
      3. associate-*r*81.8%

        \[\leadsto \color{blue}{\left(\frac{1}{y \cdot -2} \cdot z\right) \cdot z} \]
      4. *-commutative81.8%

        \[\leadsto \left(\frac{1}{\color{blue}{-2 \cdot y}} \cdot z\right) \cdot z \]
      5. associate-/r*81.8%

        \[\leadsto \left(\color{blue}{\frac{\frac{1}{-2}}{y}} \cdot z\right) \cdot z \]
      6. metadata-eval81.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 1.6 \cdot 10^{-294}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;z \leq 5.7 \cdot 10^{-158}:\\ \;\;\;\;x \cdot \frac{x}{y \cdot 2}\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{-128}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;z \leq 9 \cdot 10^{-107}:\\ \;\;\;\;x \cdot \frac{x}{y \cdot 2}\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-37}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{+124}:\\ \;\;\;\;x \cdot \frac{x}{y \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 42.1% 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{\frac{x}{2}}{\frac{y\_m}{x}}\\ y\_s \cdot \begin{array}{l} \mathbf{if}\;z \leq 1.5 \cdot 10^{-294}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{-157}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 5.8 \cdot 10^{-128}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{elif}\;z \leq 3 \cdot 10^{-107}:\\ \;\;\;\;x \cdot \frac{x}{y\_m \cdot 2}\\ \mathbf{elif}\;z \leq 1.6 \cdot 10^{-37}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{elif}\;z \leq 4.3 \cdot 10^{+123}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{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 2.0) (/ y_m x))))
   (*
    y_s
    (if (<= z 1.5e-294)
      (* y_m 0.5)
      (if (<= z 4.8e-157)
        t_0
        (if (<= z 5.8e-128)
          (* y_m 0.5)
          (if (<= z 3e-107)
            (* x (/ x (* y_m 2.0)))
            (if (<= z 1.6e-37)
              (* y_m 0.5)
              (if (<= z 4.3e+123) t_0 (* z (* 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 t_0 = (x / 2.0) / (y_m / x);
	double tmp;
	if (z <= 1.5e-294) {
		tmp = y_m * 0.5;
	} else if (z <= 4.8e-157) {
		tmp = t_0;
	} else if (z <= 5.8e-128) {
		tmp = y_m * 0.5;
	} else if (z <= 3e-107) {
		tmp = x * (x / (y_m * 2.0));
	} else if (z <= 1.6e-37) {
		tmp = y_m * 0.5;
	} else if (z <= 4.3e+123) {
		tmp = t_0;
	} else {
		tmp = z * (z * (-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) :: t_0
    real(8) :: tmp
    t_0 = (x / 2.0d0) / (y_m / x)
    if (z <= 1.5d-294) then
        tmp = y_m * 0.5d0
    else if (z <= 4.8d-157) then
        tmp = t_0
    else if (z <= 5.8d-128) then
        tmp = y_m * 0.5d0
    else if (z <= 3d-107) then
        tmp = x * (x / (y_m * 2.0d0))
    else if (z <= 1.6d-37) then
        tmp = y_m * 0.5d0
    else if (z <= 4.3d+123) then
        tmp = t_0
    else
        tmp = z * (z * ((-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 t_0 = (x / 2.0) / (y_m / x);
	double tmp;
	if (z <= 1.5e-294) {
		tmp = y_m * 0.5;
	} else if (z <= 4.8e-157) {
		tmp = t_0;
	} else if (z <= 5.8e-128) {
		tmp = y_m * 0.5;
	} else if (z <= 3e-107) {
		tmp = x * (x / (y_m * 2.0));
	} else if (z <= 1.6e-37) {
		tmp = y_m * 0.5;
	} else if (z <= 4.3e+123) {
		tmp = t_0;
	} else {
		tmp = z * (z * (-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):
	t_0 = (x / 2.0) / (y_m / x)
	tmp = 0
	if z <= 1.5e-294:
		tmp = y_m * 0.5
	elif z <= 4.8e-157:
		tmp = t_0
	elif z <= 5.8e-128:
		tmp = y_m * 0.5
	elif z <= 3e-107:
		tmp = x * (x / (y_m * 2.0))
	elif z <= 1.6e-37:
		tmp = y_m * 0.5
	elif z <= 4.3e+123:
		tmp = t_0
	else:
		tmp = z * (z * (-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)
	t_0 = Float64(Float64(x / 2.0) / Float64(y_m / x))
	tmp = 0.0
	if (z <= 1.5e-294)
		tmp = Float64(y_m * 0.5);
	elseif (z <= 4.8e-157)
		tmp = t_0;
	elseif (z <= 5.8e-128)
		tmp = Float64(y_m * 0.5);
	elseif (z <= 3e-107)
		tmp = Float64(x * Float64(x / Float64(y_m * 2.0)));
	elseif (z <= 1.6e-37)
		tmp = Float64(y_m * 0.5);
	elseif (z <= 4.3e+123)
		tmp = t_0;
	else
		tmp = Float64(z * Float64(z * 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)
	t_0 = (x / 2.0) / (y_m / x);
	tmp = 0.0;
	if (z <= 1.5e-294)
		tmp = y_m * 0.5;
	elseif (z <= 4.8e-157)
		tmp = t_0;
	elseif (z <= 5.8e-128)
		tmp = y_m * 0.5;
	elseif (z <= 3e-107)
		tmp = x * (x / (y_m * 2.0));
	elseif (z <= 1.6e-37)
		tmp = y_m * 0.5;
	elseif (z <= 4.3e+123)
		tmp = t_0;
	else
		tmp = z * (z * (-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_] := Block[{t$95$0 = N[(N[(x / 2.0), $MachinePrecision] / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[z, 1.5e-294], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z, 4.8e-157], t$95$0, If[LessEqual[z, 5.8e-128], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z, 3e-107], N[(x * N[(x / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.6e-37], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z, 4.3e+123], t$95$0, N[(z * N[(z * N[(-0.5 / 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{\frac{x}{2}}{\frac{y\_m}{x}}\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 1.5 \cdot 10^{-294}:\\
\;\;\;\;y\_m \cdot 0.5\\

\mathbf{elif}\;z \leq 4.8 \cdot 10^{-157}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;z \leq 3 \cdot 10^{-107}:\\
\;\;\;\;x \cdot \frac{x}{y\_m \cdot 2}\\

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

\mathbf{elif}\;z \leq 4.3 \cdot 10^{+123}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < 1.4999999999999999e-294 or 4.8e-157 < z < 5.8000000000000001e-128 or 2.9999999999999997e-107 < z < 1.5999999999999999e-37

    1. Initial program 70.0%

      \[\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 38.1%

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

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

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

    if 1.4999999999999999e-294 < z < 4.8e-157 or 1.5999999999999999e-37 < z < 4.29999999999999986e123

    1. Initial program 77.5%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num77.5%

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

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

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

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

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

        \[\leadsto {\left(y \cdot \frac{2}{{\color{blue}{\left(\mathsf{hypot}\left(x, y\right)\right)}}^{2} - z \cdot z}\right)}^{-1} \]
      7. pow277.4%

        \[\leadsto {\left(y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - \color{blue}{{z}^{2}}}\right)}^{-1} \]
    4. Applied egg-rr77.4%

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

        \[\leadsto \color{blue}{\frac{1}{y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
      2. associate-*r/77.5%

        \[\leadsto \frac{1}{\color{blue}{\frac{y \cdot 2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
    6. Simplified77.5%

      \[\leadsto \color{blue}{\frac{1}{\frac{y \cdot 2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
    7. Taylor expanded in x around inf 44.1%

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

        \[\leadsto \color{blue}{\sqrt{\frac{1}{2 \cdot \frac{y}{{x}^{2}}}} \cdot \sqrt{\frac{1}{2 \cdot \frac{y}{{x}^{2}}}}} \]
      2. pow228.5%

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

        \[\leadsto {\left(\sqrt{\color{blue}{\frac{\frac{1}{2}}{\frac{y}{{x}^{2}}}}}\right)}^{2} \]
      4. metadata-eval28.5%

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

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

        \[\leadsto {\left(\frac{\sqrt{0.5}}{\color{blue}{\frac{\sqrt{y}}{\sqrt{{x}^{2}}}}}\right)}^{2} \]
      7. sqrt-pow131.4%

        \[\leadsto {\left(\frac{\sqrt{0.5}}{\frac{\sqrt{y}}{\color{blue}{{x}^{\left(\frac{2}{2}\right)}}}}\right)}^{2} \]
      8. metadata-eval31.4%

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

        \[\leadsto {\left(\frac{\sqrt{0.5}}{\frac{\sqrt{y}}{\color{blue}{x}}}\right)}^{2} \]
    9. Applied egg-rr31.4%

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

        \[\leadsto \color{blue}{\frac{\sqrt{0.5}}{\frac{\sqrt{y}}{x}} \cdot \frac{\sqrt{0.5}}{\frac{\sqrt{y}}{x}}} \]
      2. div-inv31.3%

        \[\leadsto \color{blue}{\left(\sqrt{0.5} \cdot \frac{1}{\frac{\sqrt{y}}{x}}\right)} \cdot \frac{\sqrt{0.5}}{\frac{\sqrt{y}}{x}} \]
      3. clear-num31.3%

        \[\leadsto \left(\sqrt{0.5} \cdot \color{blue}{\frac{x}{\sqrt{y}}}\right) \cdot \frac{\sqrt{0.5}}{\frac{\sqrt{y}}{x}} \]
      4. div-inv31.3%

        \[\leadsto \left(\sqrt{0.5} \cdot \frac{x}{\sqrt{y}}\right) \cdot \color{blue}{\left(\sqrt{0.5} \cdot \frac{1}{\frac{\sqrt{y}}{x}}\right)} \]
      5. clear-num31.3%

        \[\leadsto \left(\sqrt{0.5} \cdot \frac{x}{\sqrt{y}}\right) \cdot \left(\sqrt{0.5} \cdot \color{blue}{\frac{x}{\sqrt{y}}}\right) \]
      6. swap-sqr31.3%

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

        \[\leadsto \color{blue}{0.5} \cdot \left(\frac{x}{\sqrt{y}} \cdot \frac{x}{\sqrt{y}}\right) \]
      8. metadata-eval31.3%

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

        \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{x \cdot x}{\sqrt{y} \cdot \sqrt{y}}} \]
      10. add-sqr-sqrt44.1%

        \[\leadsto \frac{1}{2} \cdot \frac{x \cdot x}{\color{blue}{y}} \]
      11. associate-*r/48.8%

        \[\leadsto \frac{1}{2} \cdot \color{blue}{\left(x \cdot \frac{x}{y}\right)} \]
      12. clear-num48.8%

        \[\leadsto \frac{1}{2} \cdot \left(x \cdot \color{blue}{\frac{1}{\frac{y}{x}}}\right) \]
      13. un-div-inv48.8%

        \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{x}{\frac{y}{x}}} \]
      14. times-frac48.8%

        \[\leadsto \color{blue}{\frac{1 \cdot x}{2 \cdot \frac{y}{x}}} \]
      15. *-un-lft-identity48.8%

        \[\leadsto \frac{\color{blue}{x}}{2 \cdot \frac{y}{x}} \]
      16. associate-/r*48.8%

        \[\leadsto \color{blue}{\frac{\frac{x}{2}}{\frac{y}{x}}} \]
    11. Applied egg-rr48.8%

      \[\leadsto \color{blue}{\frac{\frac{x}{2}}{\frac{y}{x}}} \]

    if 5.8000000000000001e-128 < z < 2.9999999999999997e-107

    1. Initial program 70.5%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num69.9%

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

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

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

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

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

        \[\leadsto {\left(y \cdot \frac{2}{{\color{blue}{\left(\mathsf{hypot}\left(x, y\right)\right)}}^{2} - z \cdot z}\right)}^{-1} \]
      7. pow270.5%

        \[\leadsto {\left(y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - \color{blue}{{z}^{2}}}\right)}^{-1} \]
    4. Applied egg-rr70.5%

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

        \[\leadsto \color{blue}{\frac{1}{y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
      2. associate-*r/69.9%

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

      \[\leadsto \color{blue}{\frac{1}{\frac{y \cdot 2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
    7. Taylor expanded in x around inf 69.9%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{2 \cdot y}{{x}^{2}}}} \]
      2. *-commutative69.9%

        \[\leadsto \frac{1}{\frac{\color{blue}{y \cdot 2}}{{x}^{2}}} \]
      3. unpow269.9%

        \[\leadsto \frac{1}{\frac{y \cdot 2}{\color{blue}{x \cdot x}}} \]
      4. associate-/r*99.5%

        \[\leadsto \frac{1}{\color{blue}{\frac{\frac{y \cdot 2}{x}}{x}}} \]
      5. *-commutative99.5%

        \[\leadsto \frac{1}{\frac{\frac{\color{blue}{2 \cdot y}}{x}}{x}} \]
    9. Applied egg-rr99.5%

      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{2 \cdot y}{x}}{x}}} \]
    10. Step-by-step derivation
      1. associate-/r/99.5%

        \[\leadsto \color{blue}{\frac{1}{\frac{2 \cdot y}{x}} \cdot x} \]
      2. clear-num100.0%

        \[\leadsto \color{blue}{\frac{x}{2 \cdot y}} \cdot x \]
      3. *-commutative100.0%

        \[\leadsto \frac{x}{\color{blue}{y \cdot 2}} \cdot x \]
    11. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\frac{x}{y \cdot 2} \cdot x} \]

    if 4.29999999999999986e123 < z

    1. Initial program 70.4%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num70.4%

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

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

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

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

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

        \[\leadsto {\left(y \cdot \frac{2}{{\color{blue}{\left(\mathsf{hypot}\left(x, y\right)\right)}}^{2} - z \cdot z}\right)}^{-1} \]
      7. pow270.4%

        \[\leadsto {\left(y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - \color{blue}{{z}^{2}}}\right)}^{-1} \]
    4. Applied egg-rr70.4%

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

        \[\leadsto \color{blue}{\frac{1}{y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
      2. associate-*r/70.4%

        \[\leadsto \frac{1}{\color{blue}{\frac{y \cdot 2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
    6. Simplified70.4%

      \[\leadsto \color{blue}{\frac{1}{\frac{y \cdot 2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt70.4%

        \[\leadsto \frac{1}{\frac{y \cdot 2}{\color{blue}{\sqrt{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}} \cdot \sqrt{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}} - {z}^{2}}} \]
      2. sqrt-unprod42.4%

        \[\leadsto \frac{1}{\frac{y \cdot 2}{\color{blue}{\sqrt{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} \cdot {\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}} - {z}^{2}}} \]
      3. pow-prod-up42.4%

        \[\leadsto \frac{1}{\frac{y \cdot 2}{\sqrt{\color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{\left(2 + 2\right)}}} - {z}^{2}}} \]
      4. metadata-eval42.4%

        \[\leadsto \frac{1}{\frac{y \cdot 2}{\sqrt{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{\color{blue}{4}}} - {z}^{2}}} \]
    8. Applied egg-rr42.4%

      \[\leadsto \frac{1}{\frac{y \cdot 2}{\color{blue}{\sqrt{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{4}}} - {z}^{2}}} \]
    9. Step-by-step derivation
      1. hypot-undefine42.4%

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

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{y \cdot 2}{\sqrt{{\color{blue}{\left(\mathsf{hypot}\left(y, x\right)\right)}}^{4}} - {z}^{2}}} \]
    10. Simplified42.4%

      \[\leadsto \frac{1}{\frac{y \cdot 2}{\color{blue}{\sqrt{{\left(\mathsf{hypot}\left(y, x\right)\right)}^{4}}} - {z}^{2}}} \]
    11. Taylor expanded in z around inf 73.4%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{-2 \cdot y}{{z}^{2}}}} \]
      2. *-commutative73.4%

        \[\leadsto \frac{1}{\frac{\color{blue}{y \cdot -2}}{{z}^{2}}} \]
    13. Simplified73.4%

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

        \[\leadsto \color{blue}{\frac{1}{y \cdot -2} \cdot {z}^{2}} \]
      2. unpow273.4%

        \[\leadsto \frac{1}{y \cdot -2} \cdot \color{blue}{\left(z \cdot z\right)} \]
      3. associate-*r*81.8%

        \[\leadsto \color{blue}{\left(\frac{1}{y \cdot -2} \cdot z\right) \cdot z} \]
      4. *-commutative81.8%

        \[\leadsto \left(\frac{1}{\color{blue}{-2 \cdot y}} \cdot z\right) \cdot z \]
      5. associate-/r*81.8%

        \[\leadsto \left(\color{blue}{\frac{\frac{1}{-2}}{y}} \cdot z\right) \cdot z \]
      6. metadata-eval81.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 1.5 \cdot 10^{-294}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{-157}:\\ \;\;\;\;\frac{\frac{x}{2}}{\frac{y}{x}}\\ \mathbf{elif}\;z \leq 5.8 \cdot 10^{-128}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;z \leq 3 \cdot 10^{-107}:\\ \;\;\;\;x \cdot \frac{x}{y \cdot 2}\\ \mathbf{elif}\;z \leq 1.6 \cdot 10^{-37}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;z \leq 4.3 \cdot 10^{+123}:\\ \;\;\;\;\frac{\frac{x}{2}}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 42.9% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 71.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 37.8%

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

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

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

    if 6.8000000000000005e26 < z

    1. Initial program 74.2%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num74.1%

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

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

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

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

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

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

        \[\leadsto {\left(y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - \color{blue}{{z}^{2}}}\right)}^{-1} \]
    4. Applied egg-rr74.1%

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

        \[\leadsto \color{blue}{\frac{1}{y \cdot \frac{2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
      2. associate-*r/74.1%

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

      \[\leadsto \color{blue}{\frac{1}{\frac{y \cdot 2}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} - {z}^{2}}}} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt74.1%

        \[\leadsto \frac{1}{\frac{y \cdot 2}{\color{blue}{\sqrt{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}} \cdot \sqrt{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}} - {z}^{2}}} \]
      2. sqrt-unprod52.5%

        \[\leadsto \frac{1}{\frac{y \cdot 2}{\color{blue}{\sqrt{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} \cdot {\left(\mathsf{hypot}\left(x, y\right)\right)}^{2}}} - {z}^{2}}} \]
      3. pow-prod-up52.5%

        \[\leadsto \frac{1}{\frac{y \cdot 2}{\sqrt{\color{blue}{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{\left(2 + 2\right)}}} - {z}^{2}}} \]
      4. metadata-eval52.5%

        \[\leadsto \frac{1}{\frac{y \cdot 2}{\sqrt{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{\color{blue}{4}}} - {z}^{2}}} \]
    8. Applied egg-rr52.5%

      \[\leadsto \frac{1}{\frac{y \cdot 2}{\color{blue}{\sqrt{{\left(\mathsf{hypot}\left(x, y\right)\right)}^{4}}} - {z}^{2}}} \]
    9. Step-by-step derivation
      1. hypot-undefine52.5%

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

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{y \cdot 2}{\sqrt{{\color{blue}{\left(\mathsf{hypot}\left(y, x\right)\right)}}^{4}} - {z}^{2}}} \]
    10. Simplified52.5%

      \[\leadsto \frac{1}{\frac{y \cdot 2}{\color{blue}{\sqrt{{\left(\mathsf{hypot}\left(y, x\right)\right)}^{4}}} - {z}^{2}}} \]
    11. Taylor expanded in z around inf 58.7%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{-2 \cdot y}{{z}^{2}}}} \]
      2. *-commutative58.7%

        \[\leadsto \frac{1}{\frac{\color{blue}{y \cdot -2}}{{z}^{2}}} \]
    13. Simplified58.7%

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

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

        \[\leadsto \frac{1}{y \cdot -2} \cdot \color{blue}{\left(z \cdot z\right)} \]
      3. associate-*r*63.7%

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

        \[\leadsto \left(\frac{1}{\color{blue}{-2 \cdot y}} \cdot z\right) \cdot z \]
      5. associate-/r*63.7%

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

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

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

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

Alternative 5: 34.0% accurate, 5.0× speedup?

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

\\
y\_s \cdot \left(y\_m \cdot 0.5\right)
\end{array}
Derivation
  1. Initial program 71.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 32.1%

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

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

    \[\leadsto \color{blue}{y \cdot 0.5} \]
  6. Final simplification32.1%

    \[\leadsto y \cdot 0.5 \]
  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 2024055 
(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)))