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

Percentage Accurate: 69.5% → 99.9%
Time: 13.0s
Alternatives: 8
Speedup: 1.2×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 alternatives:

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

Initial Program: 69.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: 99.9% accurate, 1.2× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ z_m = \left|z\right| \\ 0.5 \cdot \left(y + \frac{z\_m + x\_m}{y} \cdot \left(x\_m - z\_m\right)\right) \end{array} \]
x_m = (fabs.f64 x)
z_m = (fabs.f64 z)
(FPCore (x_m y z_m)
 :precision binary64
 (* 0.5 (+ y (* (/ (+ z_m x_m) y) (- x_m z_m)))))
x_m = fabs(x);
z_m = fabs(z);
double code(double x_m, double y, double z_m) {
	return 0.5 * (y + (((z_m + x_m) / y) * (x_m - z_m)));
}
x_m = abs(x)
z_m = abs(z)
real(8) function code(x_m, y, z_m)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    code = 0.5d0 * (y + (((z_m + x_m) / y) * (x_m - z_m)))
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
public static double code(double x_m, double y, double z_m) {
	return 0.5 * (y + (((z_m + x_m) / y) * (x_m - z_m)));
}
x_m = math.fabs(x)
z_m = math.fabs(z)
def code(x_m, y, z_m):
	return 0.5 * (y + (((z_m + x_m) / y) * (x_m - z_m)))
x_m = abs(x)
z_m = abs(z)
function code(x_m, y, z_m)
	return Float64(0.5 * Float64(y + Float64(Float64(Float64(z_m + x_m) / y) * Float64(x_m - z_m))))
end
x_m = abs(x);
z_m = abs(z);
function tmp = code(x_m, y, z_m)
	tmp = 0.5 * (y + (((z_m + x_m) / y) * (x_m - z_m)));
end
x_m = N[Abs[x], $MachinePrecision]
z_m = N[Abs[z], $MachinePrecision]
code[x$95$m_, y_, z$95$m_] := N[(0.5 * N[(y + N[(N[(N[(z$95$m + x$95$m), $MachinePrecision] / y), $MachinePrecision] * N[(x$95$m - z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|

\\
0.5 \cdot \left(y + \frac{z\_m + x\_m}{y} \cdot \left(x\_m - z\_m\right)\right)
\end{array}
Derivation
  1. Initial program 65.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \frac{\sqrt{{x}^{2} + {y}^{2}} \cdot \color{blue}{\sqrt{x \cdot x + y \cdot y}} - {z}^{2}}{y} \]
    7. unpow265.7%

      \[\leadsto 0.5 \cdot \frac{\sqrt{{x}^{2} + {y}^{2}} \cdot \sqrt{\color{blue}{{x}^{2}} + y \cdot y} - {z}^{2}}{y} \]
    8. unpow265.7%

      \[\leadsto 0.5 \cdot \frac{\sqrt{{x}^{2} + {y}^{2}} \cdot \sqrt{{x}^{2} + \color{blue}{{y}^{2}}} - {z}^{2}}{y} \]
    9. rem-square-sqrt65.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 52.9% accurate, 0.6× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ z_m = \left|z\right| \\ \begin{array}{l} t_0 := \frac{z\_m}{y} \cdot \frac{z\_m}{-2}\\ \mathbf{if}\;x\_m \leq 5.2 \cdot 10^{-280}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x\_m \leq 5 \cdot 10^{-125}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;x\_m \leq 1.2 \cdot 10^{-65}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x\_m \leq 1.04 \cdot 10^{+80}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{else}:\\ \;\;\;\;x\_m \cdot \left(x\_m \cdot \frac{0.5}{y}\right)\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
z_m = (fabs.f64 z)
(FPCore (x_m y z_m)
 :precision binary64
 (let* ((t_0 (* (/ z_m y) (/ z_m -2.0))))
   (if (<= x_m 5.2e-280)
     t_0
     (if (<= x_m 5e-125)
       (* 0.5 y)
       (if (<= x_m 1.2e-65)
         t_0
         (if (<= x_m 1.04e+80) (* 0.5 y) (* x_m (* x_m (/ 0.5 y)))))))))
x_m = fabs(x);
z_m = fabs(z);
double code(double x_m, double y, double z_m) {
	double t_0 = (z_m / y) * (z_m / -2.0);
	double tmp;
	if (x_m <= 5.2e-280) {
		tmp = t_0;
	} else if (x_m <= 5e-125) {
		tmp = 0.5 * y;
	} else if (x_m <= 1.2e-65) {
		tmp = t_0;
	} else if (x_m <= 1.04e+80) {
		tmp = 0.5 * y;
	} else {
		tmp = x_m * (x_m * (0.5 / y));
	}
	return tmp;
}
x_m = abs(x)
z_m = abs(z)
real(8) function code(x_m, y, z_m)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (z_m / y) * (z_m / (-2.0d0))
    if (x_m <= 5.2d-280) then
        tmp = t_0
    else if (x_m <= 5d-125) then
        tmp = 0.5d0 * y
    else if (x_m <= 1.2d-65) then
        tmp = t_0
    else if (x_m <= 1.04d+80) then
        tmp = 0.5d0 * y
    else
        tmp = x_m * (x_m * (0.5d0 / y))
    end if
    code = tmp
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
public static double code(double x_m, double y, double z_m) {
	double t_0 = (z_m / y) * (z_m / -2.0);
	double tmp;
	if (x_m <= 5.2e-280) {
		tmp = t_0;
	} else if (x_m <= 5e-125) {
		tmp = 0.5 * y;
	} else if (x_m <= 1.2e-65) {
		tmp = t_0;
	} else if (x_m <= 1.04e+80) {
		tmp = 0.5 * y;
	} else {
		tmp = x_m * (x_m * (0.5 / y));
	}
	return tmp;
}
x_m = math.fabs(x)
z_m = math.fabs(z)
def code(x_m, y, z_m):
	t_0 = (z_m / y) * (z_m / -2.0)
	tmp = 0
	if x_m <= 5.2e-280:
		tmp = t_0
	elif x_m <= 5e-125:
		tmp = 0.5 * y
	elif x_m <= 1.2e-65:
		tmp = t_0
	elif x_m <= 1.04e+80:
		tmp = 0.5 * y
	else:
		tmp = x_m * (x_m * (0.5 / y))
	return tmp
x_m = abs(x)
z_m = abs(z)
function code(x_m, y, z_m)
	t_0 = Float64(Float64(z_m / y) * Float64(z_m / -2.0))
	tmp = 0.0
	if (x_m <= 5.2e-280)
		tmp = t_0;
	elseif (x_m <= 5e-125)
		tmp = Float64(0.5 * y);
	elseif (x_m <= 1.2e-65)
		tmp = t_0;
	elseif (x_m <= 1.04e+80)
		tmp = Float64(0.5 * y);
	else
		tmp = Float64(x_m * Float64(x_m * Float64(0.5 / y)));
	end
	return tmp
end
x_m = abs(x);
z_m = abs(z);
function tmp_2 = code(x_m, y, z_m)
	t_0 = (z_m / y) * (z_m / -2.0);
	tmp = 0.0;
	if (x_m <= 5.2e-280)
		tmp = t_0;
	elseif (x_m <= 5e-125)
		tmp = 0.5 * y;
	elseif (x_m <= 1.2e-65)
		tmp = t_0;
	elseif (x_m <= 1.04e+80)
		tmp = 0.5 * y;
	else
		tmp = x_m * (x_m * (0.5 / y));
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
z_m = N[Abs[z], $MachinePrecision]
code[x$95$m_, y_, z$95$m_] := Block[{t$95$0 = N[(N[(z$95$m / y), $MachinePrecision] * N[(z$95$m / -2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$95$m, 5.2e-280], t$95$0, If[LessEqual[x$95$m, 5e-125], N[(0.5 * y), $MachinePrecision], If[LessEqual[x$95$m, 1.2e-65], t$95$0, If[LessEqual[x$95$m, 1.04e+80], N[(0.5 * y), $MachinePrecision], N[(x$95$m * N[(x$95$m * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|

\\
\begin{array}{l}
t_0 := \frac{z\_m}{y} \cdot \frac{z\_m}{-2}\\
\mathbf{if}\;x\_m \leq 5.2 \cdot 10^{-280}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x\_m \leq 5 \cdot 10^{-125}:\\
\;\;\;\;0.5 \cdot y\\

\mathbf{elif}\;x\_m \leq 1.2 \cdot 10^{-65}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x\_m \leq 1.04 \cdot 10^{+80}:\\
\;\;\;\;0.5 \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 5.2e-280 or 4.99999999999999967e-125 < x < 1.2000000000000001e-65

    1. Initial program 66.8%

      \[\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-num66.8%

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

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

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

        \[\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. pow265.9%

        \[\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-define65.9%

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

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

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

      \[\leadsto {\color{blue}{\left(-2 \cdot \frac{y}{{z}^{2}}\right)}}^{-1} \]
    6. Step-by-step derivation
      1. associate-*r/30.8%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{z \cdot z}}{y \cdot -2} \]
      4. times-frac34.6%

        \[\leadsto \color{blue}{\frac{z}{y} \cdot \frac{z}{-2}} \]
    9. Applied egg-rr34.6%

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

    if 5.2e-280 < x < 4.99999999999999967e-125 or 1.2000000000000001e-65 < x < 1.04000000000000006e80

    1. Initial program 62.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 52.7%

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

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

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

    if 1.04000000000000006e80 < x

    1. Initial program 65.5%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 5.2 \cdot 10^{-280}:\\ \;\;\;\;\frac{z}{y} \cdot \frac{z}{-2}\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-125}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-65}:\\ \;\;\;\;\frac{z}{y} \cdot \frac{z}{-2}\\ \mathbf{elif}\;x \leq 1.04 \cdot 10^{+80}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 52.9% accurate, 0.6× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ z_m = \left|z\right| \\ \begin{array}{l} t_0 := \frac{z\_m}{y} \cdot \frac{z\_m}{-2}\\ \mathbf{if}\;x\_m \leq 1.3 \cdot 10^{-280}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x\_m \leq 4 \cdot 10^{-125}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;x\_m \leq 1.2 \cdot 10^{-65}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x\_m \leq 10^{+80}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{else}:\\ \;\;\;\;x\_m \cdot \frac{0.5 \cdot x\_m}{y}\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
z_m = (fabs.f64 z)
(FPCore (x_m y z_m)
 :precision binary64
 (let* ((t_0 (* (/ z_m y) (/ z_m -2.0))))
   (if (<= x_m 1.3e-280)
     t_0
     (if (<= x_m 4e-125)
       (* 0.5 y)
       (if (<= x_m 1.2e-65)
         t_0
         (if (<= x_m 1e+80) (* 0.5 y) (* x_m (/ (* 0.5 x_m) y))))))))
x_m = fabs(x);
z_m = fabs(z);
double code(double x_m, double y, double z_m) {
	double t_0 = (z_m / y) * (z_m / -2.0);
	double tmp;
	if (x_m <= 1.3e-280) {
		tmp = t_0;
	} else if (x_m <= 4e-125) {
		tmp = 0.5 * y;
	} else if (x_m <= 1.2e-65) {
		tmp = t_0;
	} else if (x_m <= 1e+80) {
		tmp = 0.5 * y;
	} else {
		tmp = x_m * ((0.5 * x_m) / y);
	}
	return tmp;
}
x_m = abs(x)
z_m = abs(z)
real(8) function code(x_m, y, z_m)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (z_m / y) * (z_m / (-2.0d0))
    if (x_m <= 1.3d-280) then
        tmp = t_0
    else if (x_m <= 4d-125) then
        tmp = 0.5d0 * y
    else if (x_m <= 1.2d-65) then
        tmp = t_0
    else if (x_m <= 1d+80) then
        tmp = 0.5d0 * y
    else
        tmp = x_m * ((0.5d0 * x_m) / y)
    end if
    code = tmp
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
public static double code(double x_m, double y, double z_m) {
	double t_0 = (z_m / y) * (z_m / -2.0);
	double tmp;
	if (x_m <= 1.3e-280) {
		tmp = t_0;
	} else if (x_m <= 4e-125) {
		tmp = 0.5 * y;
	} else if (x_m <= 1.2e-65) {
		tmp = t_0;
	} else if (x_m <= 1e+80) {
		tmp = 0.5 * y;
	} else {
		tmp = x_m * ((0.5 * x_m) / y);
	}
	return tmp;
}
x_m = math.fabs(x)
z_m = math.fabs(z)
def code(x_m, y, z_m):
	t_0 = (z_m / y) * (z_m / -2.0)
	tmp = 0
	if x_m <= 1.3e-280:
		tmp = t_0
	elif x_m <= 4e-125:
		tmp = 0.5 * y
	elif x_m <= 1.2e-65:
		tmp = t_0
	elif x_m <= 1e+80:
		tmp = 0.5 * y
	else:
		tmp = x_m * ((0.5 * x_m) / y)
	return tmp
x_m = abs(x)
z_m = abs(z)
function code(x_m, y, z_m)
	t_0 = Float64(Float64(z_m / y) * Float64(z_m / -2.0))
	tmp = 0.0
	if (x_m <= 1.3e-280)
		tmp = t_0;
	elseif (x_m <= 4e-125)
		tmp = Float64(0.5 * y);
	elseif (x_m <= 1.2e-65)
		tmp = t_0;
	elseif (x_m <= 1e+80)
		tmp = Float64(0.5 * y);
	else
		tmp = Float64(x_m * Float64(Float64(0.5 * x_m) / y));
	end
	return tmp
end
x_m = abs(x);
z_m = abs(z);
function tmp_2 = code(x_m, y, z_m)
	t_0 = (z_m / y) * (z_m / -2.0);
	tmp = 0.0;
	if (x_m <= 1.3e-280)
		tmp = t_0;
	elseif (x_m <= 4e-125)
		tmp = 0.5 * y;
	elseif (x_m <= 1.2e-65)
		tmp = t_0;
	elseif (x_m <= 1e+80)
		tmp = 0.5 * y;
	else
		tmp = x_m * ((0.5 * x_m) / y);
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
z_m = N[Abs[z], $MachinePrecision]
code[x$95$m_, y_, z$95$m_] := Block[{t$95$0 = N[(N[(z$95$m / y), $MachinePrecision] * N[(z$95$m / -2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$95$m, 1.3e-280], t$95$0, If[LessEqual[x$95$m, 4e-125], N[(0.5 * y), $MachinePrecision], If[LessEqual[x$95$m, 1.2e-65], t$95$0, If[LessEqual[x$95$m, 1e+80], N[(0.5 * y), $MachinePrecision], N[(x$95$m * N[(N[(0.5 * x$95$m), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|

\\
\begin{array}{l}
t_0 := \frac{z\_m}{y} \cdot \frac{z\_m}{-2}\\
\mathbf{if}\;x\_m \leq 1.3 \cdot 10^{-280}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x\_m \leq 4 \cdot 10^{-125}:\\
\;\;\;\;0.5 \cdot y\\

\mathbf{elif}\;x\_m \leq 1.2 \cdot 10^{-65}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x\_m \leq 10^{+80}:\\
\;\;\;\;0.5 \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 1.3e-280 or 4.00000000000000005e-125 < x < 1.2000000000000001e-65

    1. Initial program 66.8%

      \[\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-num66.8%

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

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

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

        \[\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. pow265.9%

        \[\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-define65.9%

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

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

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

      \[\leadsto {\color{blue}{\left(-2 \cdot \frac{y}{{z}^{2}}\right)}}^{-1} \]
    6. Step-by-step derivation
      1. associate-*r/30.8%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{z \cdot z}}{y \cdot -2} \]
      4. times-frac34.6%

        \[\leadsto \color{blue}{\frac{z}{y} \cdot \frac{z}{-2}} \]
    9. Applied egg-rr34.6%

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

    if 1.3e-280 < x < 4.00000000000000005e-125 or 1.2000000000000001e-65 < x < 1e80

    1. Initial program 62.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 52.7%

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

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

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

    if 1e80 < x

    1. Initial program 65.5%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{{x}^{2} \cdot 0.5}}} \]
      2. inv-pow65.2%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{\frac{\color{blue}{y \cdot 2}}{x}}{x}} \]
    11. Applied egg-rr70.4%

      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{y \cdot 2}{x}}{x}}} \]
    12. Step-by-step derivation
      1. associate-/l/65.2%

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

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

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

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

        \[\leadsto \color{blue}{\frac{0.5}{y}} \cdot \left(x \cdot x\right) \]
      6. associate-*l*70.5%

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

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

        \[\leadsto \color{blue}{\frac{x \cdot 0.5}{y}} \cdot x \]
    13. Applied egg-rr70.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.3 \cdot 10^{-280}:\\ \;\;\;\;\frac{z}{y} \cdot \frac{z}{-2}\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-125}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-65}:\\ \;\;\;\;\frac{z}{y} \cdot \frac{z}{-2}\\ \mathbf{elif}\;x \leq 10^{+80}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{0.5 \cdot x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 81.2% accurate, 0.6× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;z\_m \leq 2.5 \cdot 10^{+103} \lor \neg \left(z\_m \leq 5.6 \cdot 10^{+118}\right) \land z\_m \leq 1.05 \cdot 10^{+182}:\\ \;\;\;\;0.5 \cdot \left(y + \frac{x\_m}{y} \cdot \left(x\_m - z\_m\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{z\_m}{y} \cdot \frac{z\_m}{-2}\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
z_m = (fabs.f64 z)
(FPCore (x_m y z_m)
 :precision binary64
 (if (or (<= z_m 2.5e+103) (and (not (<= z_m 5.6e+118)) (<= z_m 1.05e+182)))
   (* 0.5 (+ y (* (/ x_m y) (- x_m z_m))))
   (* (/ z_m y) (/ z_m -2.0))))
x_m = fabs(x);
z_m = fabs(z);
double code(double x_m, double y, double z_m) {
	double tmp;
	if ((z_m <= 2.5e+103) || (!(z_m <= 5.6e+118) && (z_m <= 1.05e+182))) {
		tmp = 0.5 * (y + ((x_m / y) * (x_m - z_m)));
	} else {
		tmp = (z_m / y) * (z_m / -2.0);
	}
	return tmp;
}
x_m = abs(x)
z_m = abs(z)
real(8) function code(x_m, y, z_m)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if ((z_m <= 2.5d+103) .or. (.not. (z_m <= 5.6d+118)) .and. (z_m <= 1.05d+182)) then
        tmp = 0.5d0 * (y + ((x_m / y) * (x_m - z_m)))
    else
        tmp = (z_m / y) * (z_m / (-2.0d0))
    end if
    code = tmp
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
public static double code(double x_m, double y, double z_m) {
	double tmp;
	if ((z_m <= 2.5e+103) || (!(z_m <= 5.6e+118) && (z_m <= 1.05e+182))) {
		tmp = 0.5 * (y + ((x_m / y) * (x_m - z_m)));
	} else {
		tmp = (z_m / y) * (z_m / -2.0);
	}
	return tmp;
}
x_m = math.fabs(x)
z_m = math.fabs(z)
def code(x_m, y, z_m):
	tmp = 0
	if (z_m <= 2.5e+103) or (not (z_m <= 5.6e+118) and (z_m <= 1.05e+182)):
		tmp = 0.5 * (y + ((x_m / y) * (x_m - z_m)))
	else:
		tmp = (z_m / y) * (z_m / -2.0)
	return tmp
x_m = abs(x)
z_m = abs(z)
function code(x_m, y, z_m)
	tmp = 0.0
	if ((z_m <= 2.5e+103) || (!(z_m <= 5.6e+118) && (z_m <= 1.05e+182)))
		tmp = Float64(0.5 * Float64(y + Float64(Float64(x_m / y) * Float64(x_m - z_m))));
	else
		tmp = Float64(Float64(z_m / y) * Float64(z_m / -2.0));
	end
	return tmp
end
x_m = abs(x);
z_m = abs(z);
function tmp_2 = code(x_m, y, z_m)
	tmp = 0.0;
	if ((z_m <= 2.5e+103) || (~((z_m <= 5.6e+118)) && (z_m <= 1.05e+182)))
		tmp = 0.5 * (y + ((x_m / y) * (x_m - z_m)));
	else
		tmp = (z_m / y) * (z_m / -2.0);
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
z_m = N[Abs[z], $MachinePrecision]
code[x$95$m_, y_, z$95$m_] := If[Or[LessEqual[z$95$m, 2.5e+103], And[N[Not[LessEqual[z$95$m, 5.6e+118]], $MachinePrecision], LessEqual[z$95$m, 1.05e+182]]], N[(0.5 * N[(y + N[(N[(x$95$m / y), $MachinePrecision] * N[(x$95$m - z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z$95$m / y), $MachinePrecision] * N[(z$95$m / -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|

\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 2.5 \cdot 10^{+103} \lor \neg \left(z\_m \leq 5.6 \cdot 10^{+118}\right) \land z\_m \leq 1.05 \cdot 10^{+182}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{x\_m}{y} \cdot \left(x\_m - z\_m\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{z\_m}{y} \cdot \frac{z\_m}{-2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 2.5e103 or 5.59999999999999972e118 < z < 1.0499999999999999e182

    1. Initial program 66.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\sqrt{{x}^{2} + {y}^{2}} \cdot \color{blue}{\sqrt{x \cdot x + y \cdot y}} - {z}^{2}}{y} \]
      7. unpow266.7%

        \[\leadsto 0.5 \cdot \frac{\sqrt{{x}^{2} + {y}^{2}} \cdot \sqrt{\color{blue}{{x}^{2}} + y \cdot y} - {z}^{2}}{y} \]
      8. unpow266.7%

        \[\leadsto 0.5 \cdot \frac{\sqrt{{x}^{2} + {y}^{2}} \cdot \sqrt{{x}^{2} + \color{blue}{{y}^{2}}} - {z}^{2}}{y} \]
      9. rem-square-sqrt66.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.5e103 < z < 5.59999999999999972e118 or 1.0499999999999999e182 < z

    1. Initial program 58.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-num58.5%

        \[\leadsto \color{blue}{\frac{1}{\frac{y \cdot 2}{\left(x \cdot x + y \cdot y\right) - z \cdot z}}} \]
      2. inv-pow58.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*58.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-sqrt58.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. pow258.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-define58.5%

        \[\leadsto {\left(y \cdot \frac{2}{{\color{blue}{\left(\mathsf{hypot}\left(x, y\right)\right)}}^{2} - z \cdot z}\right)}^{-1} \]
      7. pow258.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-rr58.5%

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

      \[\leadsto {\color{blue}{\left(-2 \cdot \frac{y}{{z}^{2}}\right)}}^{-1} \]
    6. Step-by-step derivation
      1. associate-*r/75.4%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{z}{y} \cdot \frac{z}{-2}} \]
    9. Applied egg-rr87.1%

      \[\leadsto \color{blue}{\frac{z}{y} \cdot \frac{z}{-2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification80.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 2.5 \cdot 10^{+103} \lor \neg \left(z \leq 5.6 \cdot 10^{+118}\right) \land z \leq 1.05 \cdot 10^{+182}:\\ \;\;\;\;0.5 \cdot \left(y + \frac{x}{y} \cdot \left(x - z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{y} \cdot \frac{z}{-2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 91.7% accurate, 0.9× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;z\_m \leq 4.1 \cdot 10^{+21}:\\ \;\;\;\;0.5 \cdot \left(y + \frac{x\_m}{y} \cdot \left(x\_m - z\_m\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(y + \frac{z\_m}{y} \cdot \left(x\_m - z\_m\right)\right)\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
z_m = (fabs.f64 z)
(FPCore (x_m y z_m)
 :precision binary64
 (if (<= z_m 4.1e+21)
   (* 0.5 (+ y (* (/ x_m y) (- x_m z_m))))
   (* 0.5 (+ y (* (/ z_m y) (- x_m z_m))))))
x_m = fabs(x);
z_m = fabs(z);
double code(double x_m, double y, double z_m) {
	double tmp;
	if (z_m <= 4.1e+21) {
		tmp = 0.5 * (y + ((x_m / y) * (x_m - z_m)));
	} else {
		tmp = 0.5 * (y + ((z_m / y) * (x_m - z_m)));
	}
	return tmp;
}
x_m = abs(x)
z_m = abs(z)
real(8) function code(x_m, y, z_m)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if (z_m <= 4.1d+21) then
        tmp = 0.5d0 * (y + ((x_m / y) * (x_m - z_m)))
    else
        tmp = 0.5d0 * (y + ((z_m / y) * (x_m - z_m)))
    end if
    code = tmp
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
public static double code(double x_m, double y, double z_m) {
	double tmp;
	if (z_m <= 4.1e+21) {
		tmp = 0.5 * (y + ((x_m / y) * (x_m - z_m)));
	} else {
		tmp = 0.5 * (y + ((z_m / y) * (x_m - z_m)));
	}
	return tmp;
}
x_m = math.fabs(x)
z_m = math.fabs(z)
def code(x_m, y, z_m):
	tmp = 0
	if z_m <= 4.1e+21:
		tmp = 0.5 * (y + ((x_m / y) * (x_m - z_m)))
	else:
		tmp = 0.5 * (y + ((z_m / y) * (x_m - z_m)))
	return tmp
x_m = abs(x)
z_m = abs(z)
function code(x_m, y, z_m)
	tmp = 0.0
	if (z_m <= 4.1e+21)
		tmp = Float64(0.5 * Float64(y + Float64(Float64(x_m / y) * Float64(x_m - z_m))));
	else
		tmp = Float64(0.5 * Float64(y + Float64(Float64(z_m / y) * Float64(x_m - z_m))));
	end
	return tmp
end
x_m = abs(x);
z_m = abs(z);
function tmp_2 = code(x_m, y, z_m)
	tmp = 0.0;
	if (z_m <= 4.1e+21)
		tmp = 0.5 * (y + ((x_m / y) * (x_m - z_m)));
	else
		tmp = 0.5 * (y + ((z_m / y) * (x_m - z_m)));
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
z_m = N[Abs[z], $MachinePrecision]
code[x$95$m_, y_, z$95$m_] := If[LessEqual[z$95$m, 4.1e+21], N[(0.5 * N[(y + N[(N[(x$95$m / y), $MachinePrecision] * N[(x$95$m - z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y + N[(N[(z$95$m / y), $MachinePrecision] * N[(x$95$m - z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|

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

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


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

    1. Initial program 67.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\sqrt{{x}^{2} + {y}^{2}} \cdot \color{blue}{\sqrt{x \cdot x + y \cdot y}} - {z}^{2}}{y} \]
      7. unpow267.6%

        \[\leadsto 0.5 \cdot \frac{\sqrt{{x}^{2} + {y}^{2}} \cdot \sqrt{\color{blue}{{x}^{2}} + y \cdot y} - {z}^{2}}{y} \]
      8. unpow267.6%

        \[\leadsto 0.5 \cdot \frac{\sqrt{{x}^{2} + {y}^{2}} \cdot \sqrt{{x}^{2} + \color{blue}{{y}^{2}}} - {z}^{2}}{y} \]
      9. rem-square-sqrt67.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.1e21 < z

    1. Initial program 59.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\sqrt{{x}^{2} + {y}^{2}} \cdot \color{blue}{\sqrt{x \cdot x + y \cdot y}} - {z}^{2}}{y} \]
      7. unpow259.0%

        \[\leadsto 0.5 \cdot \frac{\sqrt{{x}^{2} + {y}^{2}} \cdot \sqrt{\color{blue}{{x}^{2}} + y \cdot y} - {z}^{2}}{y} \]
      8. unpow259.0%

        \[\leadsto 0.5 \cdot \frac{\sqrt{{x}^{2} + {y}^{2}} \cdot \sqrt{{x}^{2} + \color{blue}{{y}^{2}}} - {z}^{2}}{y} \]
      9. rem-square-sqrt59.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 52.9% accurate, 1.2× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;x\_m \leq 8.5 \cdot 10^{+79}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{else}:\\ \;\;\;\;x\_m \cdot \left(x\_m \cdot \frac{0.5}{y}\right)\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
z_m = (fabs.f64 z)
(FPCore (x_m y z_m)
 :precision binary64
 (if (<= x_m 8.5e+79) (* 0.5 y) (* x_m (* x_m (/ 0.5 y)))))
x_m = fabs(x);
z_m = fabs(z);
double code(double x_m, double y, double z_m) {
	double tmp;
	if (x_m <= 8.5e+79) {
		tmp = 0.5 * y;
	} else {
		tmp = x_m * (x_m * (0.5 / y));
	}
	return tmp;
}
x_m = abs(x)
z_m = abs(z)
real(8) function code(x_m, y, z_m)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if (x_m <= 8.5d+79) then
        tmp = 0.5d0 * y
    else
        tmp = x_m * (x_m * (0.5d0 / y))
    end if
    code = tmp
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
public static double code(double x_m, double y, double z_m) {
	double tmp;
	if (x_m <= 8.5e+79) {
		tmp = 0.5 * y;
	} else {
		tmp = x_m * (x_m * (0.5 / y));
	}
	return tmp;
}
x_m = math.fabs(x)
z_m = math.fabs(z)
def code(x_m, y, z_m):
	tmp = 0
	if x_m <= 8.5e+79:
		tmp = 0.5 * y
	else:
		tmp = x_m * (x_m * (0.5 / y))
	return tmp
x_m = abs(x)
z_m = abs(z)
function code(x_m, y, z_m)
	tmp = 0.0
	if (x_m <= 8.5e+79)
		tmp = Float64(0.5 * y);
	else
		tmp = Float64(x_m * Float64(x_m * Float64(0.5 / y)));
	end
	return tmp
end
x_m = abs(x);
z_m = abs(z);
function tmp_2 = code(x_m, y, z_m)
	tmp = 0.0;
	if (x_m <= 8.5e+79)
		tmp = 0.5 * y;
	else
		tmp = x_m * (x_m * (0.5 / y));
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
z_m = N[Abs[z], $MachinePrecision]
code[x$95$m_, y_, z$95$m_] := If[LessEqual[x$95$m, 8.5e+79], N[(0.5 * y), $MachinePrecision], N[(x$95$m * N[(x$95$m * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|

\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 8.5 \cdot 10^{+79}:\\
\;\;\;\;0.5 \cdot y\\

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


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

    1. Initial program 65.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.8%

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

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

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

    if 8.4999999999999998e79 < x

    1. Initial program 65.5%

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

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

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

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

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

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

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

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

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

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

Alternative 7: 1.8% accurate, 5.0× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ z_m = \left|z\right| \\ y \cdot -0.5 \end{array} \]
x_m = (fabs.f64 x)
z_m = (fabs.f64 z)
(FPCore (x_m y z_m) :precision binary64 (* y -0.5))
x_m = fabs(x);
z_m = fabs(z);
double code(double x_m, double y, double z_m) {
	return y * -0.5;
}
x_m = abs(x)
z_m = abs(z)
real(8) function code(x_m, y, z_m)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    code = y * (-0.5d0)
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
public static double code(double x_m, double y, double z_m) {
	return y * -0.5;
}
x_m = math.fabs(x)
z_m = math.fabs(z)
def code(x_m, y, z_m):
	return y * -0.5
x_m = abs(x)
z_m = abs(z)
function code(x_m, y, z_m)
	return Float64(y * -0.5)
end
x_m = abs(x);
z_m = abs(z);
function tmp = code(x_m, y, z_m)
	tmp = y * -0.5;
end
x_m = N[Abs[x], $MachinePrecision]
z_m = N[Abs[z], $MachinePrecision]
code[x$95$m_, y_, z$95$m_] := N[(y * -0.5), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|

\\
y \cdot -0.5
\end{array}
Derivation
  1. Initial program 65.7%

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

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

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

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

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

      \[\leadsto \sqrt{\frac{\frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y}}{2} \cdot \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}} \]
    6. associate-/r*32.0%

      \[\leadsto \sqrt{\frac{\frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}}{2} \cdot \color{blue}{\frac{\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y}}{2}}} \]
    7. associate--l+32.0%

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{\frac{{\left(y - \frac{{z}^{2} - {x}^{2}}{y}\right)}^{2}}{4}}} \]
    2. Taylor expanded in y around -inf 1.7%

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

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    4. Simplified1.7%

      \[\leadsto \color{blue}{y \cdot -0.5} \]
    5. Final simplification1.7%

      \[\leadsto y \cdot -0.5 \]
    6. Add Preprocessing

    Alternative 8: 34.6% accurate, 5.0× speedup?

    \[\begin{array}{l} x_m = \left|x\right| \\ z_m = \left|z\right| \\ 0.5 \cdot y \end{array} \]
    x_m = (fabs.f64 x)
    z_m = (fabs.f64 z)
    (FPCore (x_m y z_m) :precision binary64 (* 0.5 y))
    x_m = fabs(x);
    z_m = fabs(z);
    double code(double x_m, double y, double z_m) {
    	return 0.5 * y;
    }
    
    x_m = abs(x)
    z_m = abs(z)
    real(8) function code(x_m, y, z_m)
        real(8), intent (in) :: x_m
        real(8), intent (in) :: y
        real(8), intent (in) :: z_m
        code = 0.5d0 * y
    end function
    
    x_m = Math.abs(x);
    z_m = Math.abs(z);
    public static double code(double x_m, double y, double z_m) {
    	return 0.5 * y;
    }
    
    x_m = math.fabs(x)
    z_m = math.fabs(z)
    def code(x_m, y, z_m):
    	return 0.5 * y
    
    x_m = abs(x)
    z_m = abs(z)
    function code(x_m, y, z_m)
    	return Float64(0.5 * y)
    end
    
    x_m = abs(x);
    z_m = abs(z);
    function tmp = code(x_m, y, z_m)
    	tmp = 0.5 * y;
    end
    
    x_m = N[Abs[x], $MachinePrecision]
    z_m = N[Abs[z], $MachinePrecision]
    code[x$95$m_, y_, z$95$m_] := N[(0.5 * y), $MachinePrecision]
    
    \begin{array}{l}
    x_m = \left|x\right|
    \\
    z_m = \left|z\right|
    
    \\
    0.5 \cdot y
    \end{array}
    
    Derivation
    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 36.4%

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

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

      \[\leadsto \color{blue}{y \cdot 0.5} \]
    6. Final simplification36.4%

      \[\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 2024044 
    (FPCore (x y z)
      :name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
      :precision binary64
    
      :herbie-target
      (- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x)))
    
      (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))