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

Percentage Accurate: 68.9% → 89.0%
Time: 9.1s
Alternatives: 7
Speedup: 0.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 7 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.9% 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: 89.0% accurate, 0.0× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} \mathbf{if}\;x\_m \leq 2.1 \cdot 10^{+145}:\\ \;\;\;\;0.5 \cdot \left(y + \frac{{x\_m}^{2} - {z}^{2}}{y}\right)\\ \mathbf{elif}\;x\_m \leq 4.5 \cdot 10^{+171}:\\ \;\;\;\;y \cdot \left(0.5 + \mathsf{fma}\left(x\_m, \frac{x\_m}{2 \cdot {y}^{2}}, \frac{{z}^{2}}{{y}^{2} \cdot -2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x\_m + z\right) \cdot \left(x\_m - z\right)\right) \cdot \frac{0.5}{y}\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m y z)
 :precision binary64
 (if (<= x_m 2.1e+145)
   (* 0.5 (+ y (/ (- (pow x_m 2.0) (pow z 2.0)) y)))
   (if (<= x_m 4.5e+171)
     (*
      y
      (+
       0.5
       (fma
        x_m
        (/ x_m (* 2.0 (pow y 2.0)))
        (/ (pow z 2.0) (* (pow y 2.0) -2.0)))))
     (* (* (+ x_m z) (- x_m z)) (/ 0.5 y)))))
x_m = fabs(x);
double code(double x_m, double y, double z) {
	double tmp;
	if (x_m <= 2.1e+145) {
		tmp = 0.5 * (y + ((pow(x_m, 2.0) - pow(z, 2.0)) / y));
	} else if (x_m <= 4.5e+171) {
		tmp = y * (0.5 + fma(x_m, (x_m / (2.0 * pow(y, 2.0))), (pow(z, 2.0) / (pow(y, 2.0) * -2.0))));
	} else {
		tmp = ((x_m + z) * (x_m - z)) * (0.5 / y);
	}
	return tmp;
}
x_m = abs(x)
function code(x_m, y, z)
	tmp = 0.0
	if (x_m <= 2.1e+145)
		tmp = Float64(0.5 * Float64(y + Float64(Float64((x_m ^ 2.0) - (z ^ 2.0)) / y)));
	elseif (x_m <= 4.5e+171)
		tmp = Float64(y * Float64(0.5 + fma(x_m, Float64(x_m / Float64(2.0 * (y ^ 2.0))), Float64((z ^ 2.0) / Float64((y ^ 2.0) * -2.0)))));
	else
		tmp = Float64(Float64(Float64(x_m + z) * Float64(x_m - z)) * Float64(0.5 / y));
	end
	return tmp
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_] := If[LessEqual[x$95$m, 2.1e+145], N[(0.5 * N[(y + N[(N[(N[Power[x$95$m, 2.0], $MachinePrecision] - N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$95$m, 4.5e+171], N[(y * N[(0.5 + N[(x$95$m * N[(x$95$m / N[(2.0 * N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[z, 2.0], $MachinePrecision] / N[(N[Power[y, 2.0], $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x$95$m + z), $MachinePrecision] * N[(x$95$m - z), $MachinePrecision]), $MachinePrecision] * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|

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

\mathbf{elif}\;x\_m \leq 4.5 \cdot 10^{+171}:\\
\;\;\;\;y \cdot \left(0.5 + \mathsf{fma}\left(x\_m, \frac{x\_m}{2 \cdot {y}^{2}}, \frac{{z}^{2}}{{y}^{2} \cdot -2}\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 2.09999999999999989e145

    1. Initial program 72.5%

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

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

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

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

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

        \[\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-out72.5%

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

        \[\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-in72.5%

        \[\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-frac72.5%

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

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

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

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

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

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

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

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

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

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

    if 2.09999999999999989e145 < x < 4.49999999999999969e171

    1. Initial program 31.0%

      \[\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-sqrt31.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.49999999999999969e171 < x

    1. Initial program 73.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 79.4% accurate, 0.1× speedup?

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

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

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


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

    1. Initial program 72.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.9999999999999997e157 < x

    1. Initial program 71.5%

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

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

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

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

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

        \[\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-out71.5%

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

        \[\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-in71.5%

        \[\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-frac71.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 79.7% accurate, 0.1× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} \mathbf{if}\;y \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x\_m, x\_m, y \cdot y - z \cdot z\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot y\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m y z)
 :precision binary64
 (if (<= y 1.35e+154)
   (* 0.5 (/ (fma x_m x_m (- (* y y) (* z z))) y))
   (* 0.5 y)))
x_m = fabs(x);
double code(double x_m, double y, double z) {
	double tmp;
	if (y <= 1.35e+154) {
		tmp = 0.5 * (fma(x_m, x_m, ((y * y) - (z * z))) / y);
	} else {
		tmp = 0.5 * y;
	}
	return tmp;
}
x_m = abs(x)
function code(x_m, y, z)
	tmp = 0.0
	if (y <= 1.35e+154)
		tmp = Float64(0.5 * Float64(fma(x_m, x_m, Float64(Float64(y * y) - Float64(z * z))) / y));
	else
		tmp = Float64(0.5 * y);
	end
	return tmp
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_] := If[LessEqual[y, 1.35e+154], N[(0.5 * N[(N[(x$95$m * x$95$m + N[(N[(y * y), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|

\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x\_m, x\_m, y \cdot y - z \cdot z\right)}{y}\\

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


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

    1. Initial program 79.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.35000000000000003e154 < y

    1. Initial program 8.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 77.2% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 79.8%

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

    if 1.35000000000000003e154 < y

    1. Initial program 8.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 70.1% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 79.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.10000000000000006e94 < y

    1. Initial program 34.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 41.9% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 79.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.7e18 < y

    1. Initial program 47.4%

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

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

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

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

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

        \[\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-out47.4%

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

        \[\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-in47.4%

        \[\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-frac47.4%

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

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

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

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

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

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

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

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

Alternative 7: 34.7% accurate, 5.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{0.5 \cdot y} \]
  6. Add Preprocessing

Developer Target 1: 99.9% accurate, 1.0× speedup?

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

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

Reproduce

?
herbie shell --seed 2024163 
(FPCore (x y z)
  :name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
  :precision binary64

  :alt
  (! :herbie-platform default (- (* y 1/2) (* (* (/ 1/2 y) (+ z x)) (- z x))))

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