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

Percentage Accurate: 68.4% → 91.4%
Time: 10.5s
Alternatives: 6
Speedup: 0.7×

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 6 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.4% 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: 91.4% accurate, 0.1× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := \frac{\left(x \cdot x + y\_m \cdot y\_m\right) - z \cdot z}{y\_m \cdot 2}\\ y\_s \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq 5 \cdot 10^{+282}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;y\_m \cdot \left(0.5 + 0.5 \cdot {\left(\frac{x}{y\_m}\right)}^{2}\right)\\ \end{array} \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
 :precision binary64
 (let* ((t_0 (/ (- (+ (* x x) (* y_m y_m)) (* z z)) (* y_m 2.0))))
   (*
    y_s
    (if (<= t_0 5e+282) t_0 (* y_m (+ 0.5 (* 0.5 (pow (/ x y_m) 2.0))))))))
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 * y_m)) - (z * z)) / (y_m * 2.0);
	double tmp;
	if (t_0 <= 5e+282) {
		tmp = t_0;
	} else {
		tmp = y_m * (0.5 + (0.5 * pow((x / y_m), 2.0)));
	}
	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 * y_m)) - (z * z)) / (y_m * 2.0d0)
    if (t_0 <= 5d+282) then
        tmp = t_0
    else
        tmp = y_m * (0.5d0 + (0.5d0 * ((x / y_m) ** 2.0d0)))
    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 * y_m)) - (z * z)) / (y_m * 2.0);
	double tmp;
	if (t_0 <= 5e+282) {
		tmp = t_0;
	} else {
		tmp = y_m * (0.5 + (0.5 * Math.pow((x / y_m), 2.0)));
	}
	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 * y_m)) - (z * z)) / (y_m * 2.0)
	tmp = 0
	if t_0 <= 5e+282:
		tmp = t_0
	else:
		tmp = y_m * (0.5 + (0.5 * math.pow((x / y_m), 2.0)))
	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(Float64(Float64(x * x) + Float64(y_m * y_m)) - Float64(z * z)) / Float64(y_m * 2.0))
	tmp = 0.0
	if (t_0 <= 5e+282)
		tmp = t_0;
	else
		tmp = Float64(y_m * Float64(0.5 + Float64(0.5 * (Float64(x / y_m) ^ 2.0))));
	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 * y_m)) - (z * z)) / (y_m * 2.0);
	tmp = 0.0;
	if (t_0 <= 5e+282)
		tmp = t_0;
	else
		tmp = y_m * (0.5 + (0.5 * ((x / y_m) ^ 2.0)));
	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[(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]}, N[(y$95$s * If[LessEqual[t$95$0, 5e+282], t$95$0, N[(y$95$m * N[(0.5 + N[(0.5 * N[Power[N[(x / y$95$m), $MachinePrecision], 2.0], $MachinePrecision]), $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{\left(x \cdot x + y\_m \cdot y\_m\right) - z \cdot z}{y\_m \cdot 2}\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{+282}:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 79.5%

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

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

    1. Initial program 48.9%

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

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

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

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

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

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

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

        \[\leadsto y \cdot \left(0.5 + \color{blue}{\left(\frac{x}{y} \cdot \frac{x}{y}\right)} \cdot 0.5\right) \]
      4. unpow270.1%

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

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

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

Alternative 2: 86.5% accurate, 0.1× speedup?

\[\begin{array}{l} y\_m = \left|y\right| \\ y\_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := \frac{\left(x \cdot x + y\_m \cdot y\_m\right) - z \cdot z}{y\_m \cdot 2}\\ y\_s \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq 2 \cdot 10^{+63}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(y\_m + \frac{{x}^{2}}{y\_m}\right)\\ \end{array} \end{array} \end{array} \]
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
 :precision binary64
 (let* ((t_0 (/ (- (+ (* x x) (* y_m y_m)) (* z z)) (* y_m 2.0))))
   (* y_s (if (<= t_0 2e+63) t_0 (* 0.5 (+ y_m (/ (pow x 2.0) 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 * y_m)) - (z * z)) / (y_m * 2.0);
	double tmp;
	if (t_0 <= 2e+63) {
		tmp = t_0;
	} else {
		tmp = 0.5 * (y_m + (pow(x, 2.0) / 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 * y_m)) - (z * z)) / (y_m * 2.0d0)
    if (t_0 <= 2d+63) then
        tmp = t_0
    else
        tmp = 0.5d0 * (y_m + ((x ** 2.0d0) / 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 * y_m)) - (z * z)) / (y_m * 2.0);
	double tmp;
	if (t_0 <= 2e+63) {
		tmp = t_0;
	} else {
		tmp = 0.5 * (y_m + (Math.pow(x, 2.0) / 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 * y_m)) - (z * z)) / (y_m * 2.0)
	tmp = 0
	if t_0 <= 2e+63:
		tmp = t_0
	else:
		tmp = 0.5 * (y_m + (math.pow(x, 2.0) / 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(Float64(Float64(x * x) + Float64(y_m * y_m)) - Float64(z * z)) / Float64(y_m * 2.0))
	tmp = 0.0
	if (t_0 <= 2e+63)
		tmp = t_0;
	else
		tmp = Float64(0.5 * Float64(y_m + Float64((x ^ 2.0) / 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 * y_m)) - (z * z)) / (y_m * 2.0);
	tmp = 0.0;
	if (t_0 <= 2e+63)
		tmp = t_0;
	else
		tmp = 0.5 * (y_m + ((x ^ 2.0) / 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[(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]}, N[(y$95$s * If[LessEqual[t$95$0, 2e+63], t$95$0, N[(0.5 * N[(y$95$m + N[(N[Power[x, 2.0], $MachinePrecision] / 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{\left(x \cdot x + y\_m \cdot y\_m\right) - z \cdot z}{y\_m \cdot 2}\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 2 \cdot 10^{+63}:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 74.8%

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

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

    1. Initial program 60.3%

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

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

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

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

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

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

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

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

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

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

      \[\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+47.1%

        \[\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. unpow247.1%

        \[\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. times-frac53.2%

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

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

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

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

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

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

Alternative 3: 85.5% accurate, 0.7× speedup?

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

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


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

    1. Initial program 75.6%

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

    if 8.99999999999999944e162 < y

    1. Initial program 8.9%

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

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

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

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

Alternative 4: 62.3% accurate, 0.9× speedup?

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

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


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

    1. Initial program 75.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-num75.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.89999999999999998e163 < y

    1. Initial program 8.9%

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

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

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

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

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

Alternative 5: 62.3% accurate, 0.9× speedup?

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

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


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

    1. Initial program 75.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-num75.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.89999999999999998e163 < y

    1. Initial program 8.9%

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

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

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

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

Alternative 6: 35.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 #s(literal 1 binary64) 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 67.5%

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

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

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

    \[\leadsto \color{blue}{y \cdot 0.5} \]
  6. 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 2024101 
(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)))