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

Percentage Accurate: 68.3% → 89.7%
Time: 9.8s
Alternatives: 10
Speedup: 0.8×

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 10 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.3% 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.7% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.48 \cdot 10^{+113} \lor \neg \left(y \leq 3.2 \cdot 10^{+163}\right):\\ \;\;\;\;\frac{\mathsf{hypot}\left(x, y\right)}{y} \cdot \frac{\mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, x, -z \cdot z\right)\right)}{y \cdot 2}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -1.48e+113) (not (<= y 3.2e+163)))
   (* (/ (hypot x y) y) (/ (hypot y (hypot x z)) 2.0))
   (/ (fma y y (fma x x (- (* z z)))) (* y 2.0))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -1.48e+113) || !(y <= 3.2e+163)) {
		tmp = (hypot(x, y) / y) * (hypot(y, hypot(x, z)) / 2.0);
	} else {
		tmp = fma(y, y, fma(x, x, -(z * z))) / (y * 2.0);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if ((y <= -1.48e+113) || !(y <= 3.2e+163))
		tmp = Float64(Float64(hypot(x, y) / y) * Float64(hypot(y, hypot(x, z)) / 2.0));
	else
		tmp = Float64(fma(y, y, fma(x, x, Float64(-Float64(z * z)))) / Float64(y * 2.0));
	end
	return tmp
end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.48e+113], N[Not[LessEqual[y, 3.2e+163]], $MachinePrecision]], N[(N[(N[Sqrt[x ^ 2 + y ^ 2], $MachinePrecision] / y), $MachinePrecision] * N[(N[Sqrt[y ^ 2 + N[Sqrt[x ^ 2 + z ^ 2], $MachinePrecision] ^ 2], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(y * y + N[(x * x + (-N[(z * z), $MachinePrecision])), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.48 \cdot 10^{+113} \lor \neg \left(y \leq 3.2 \cdot 10^{+163}\right):\\
\;\;\;\;\frac{\mathsf{hypot}\left(x, y\right)}{y} \cdot \frac{\mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)}{2}\\

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, x, -z \cdot z\right)\right)}{y \cdot 2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.48000000000000002e113 or 3.1999999999999998e163 < y

    1. Initial program 15.5%

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

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

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

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

      \[\leadsto \color{blue}{\left(\frac{1}{y} \cdot \sqrt{{x}^{2} + {y}^{2}}\right)} \cdot \frac{\mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)}{2} \]
    5. Step-by-step derivation
      1. associate-*l/19.4%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{hypot}\left(x, y\right)}{y}} \cdot \frac{\mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)}{2} \]

    if -1.48000000000000002e113 < y < 3.1999999999999998e163

    1. Initial program 90.6%

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y, y, \color{blue}{\mathsf{fma}\left(x, x, -z \cdot z\right)}\right)}{y \cdot 2} \]
      7. distribute-rgt-neg-in92.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.48 \cdot 10^{+113} \lor \neg \left(y \leq 3.2 \cdot 10^{+163}\right):\\ \;\;\;\;\frac{\mathsf{hypot}\left(x, y\right)}{y} \cdot \frac{\mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, x, -z \cdot z\right)\right)}{y \cdot 2}\\ \end{array} \]

Alternative 2: 87.1% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)\\ \mathbf{if}\;y \leq -7.4 \cdot 10^{+160}:\\ \;\;\;\;\frac{-t_0}{2}\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{+163}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, x, -z \cdot z\right)\right)}{y \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{2}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (hypot y (hypot x z))))
   (if (<= y -7.4e+160)
     (/ (- t_0) 2.0)
     (if (<= y 3.2e+163)
       (/ (fma y y (fma x x (- (* z z)))) (* y 2.0))
       (/ t_0 2.0)))))
double code(double x, double y, double z) {
	double t_0 = hypot(y, hypot(x, z));
	double tmp;
	if (y <= -7.4e+160) {
		tmp = -t_0 / 2.0;
	} else if (y <= 3.2e+163) {
		tmp = fma(y, y, fma(x, x, -(z * z))) / (y * 2.0);
	} else {
		tmp = t_0 / 2.0;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = hypot(y, hypot(x, z))
	tmp = 0.0
	if (y <= -7.4e+160)
		tmp = Float64(Float64(-t_0) / 2.0);
	elseif (y <= 3.2e+163)
		tmp = Float64(fma(y, y, fma(x, x, Float64(-Float64(z * z)))) / Float64(y * 2.0));
	else
		tmp = Float64(t_0 / 2.0);
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[Sqrt[y ^ 2 + N[Sqrt[x ^ 2 + z ^ 2], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[y, -7.4e+160], N[((-t$95$0) / 2.0), $MachinePrecision], If[LessEqual[y, 3.2e+163], N[(N[(y * y + N[(x * x + (-N[(z * z), $MachinePrecision])), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / 2.0), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)\\
\mathbf{if}\;y \leq -7.4 \cdot 10^{+160}:\\
\;\;\;\;\frac{-t_0}{2}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{t_0}{2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -7.40000000000000033e160

    1. Initial program 5.6%

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

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

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

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

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

    if -7.40000000000000033e160 < y < 3.1999999999999998e163

    1. Initial program 86.9%

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y, y, \color{blue}{\mathsf{fma}\left(x, x, -z \cdot z\right)}\right)}{y \cdot 2} \]
      7. distribute-rgt-neg-in90.1%

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

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

    if 3.1999999999999998e163 < y

    1. Initial program 9.5%

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

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

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

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

      \[\leadsto \color{blue}{1} \cdot \frac{\mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)}{2} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification85.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7.4 \cdot 10^{+160}:\\ \;\;\;\;\frac{-\mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)}{2}\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{+163}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, x, -z \cdot z\right)\right)}{y \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)}{2}\\ \end{array} \]

Alternative 3: 85.1% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)\\ \mathbf{if}\;y \leq -7 \cdot 10^{+143}:\\ \;\;\;\;\frac{-t_0}{2}\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{+146}:\\ \;\;\;\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{2}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (hypot y (hypot x z))))
   (if (<= y -7e+143)
     (/ (- t_0) 2.0)
     (if (<= y 1.8e+146)
       (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0))
       (/ t_0 2.0)))))
double code(double x, double y, double z) {
	double t_0 = hypot(y, hypot(x, z));
	double tmp;
	if (y <= -7e+143) {
		tmp = -t_0 / 2.0;
	} else if (y <= 1.8e+146) {
		tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
	} else {
		tmp = t_0 / 2.0;
	}
	return tmp;
}
public static double code(double x, double y, double z) {
	double t_0 = Math.hypot(y, Math.hypot(x, z));
	double tmp;
	if (y <= -7e+143) {
		tmp = -t_0 / 2.0;
	} else if (y <= 1.8e+146) {
		tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
	} else {
		tmp = t_0 / 2.0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = math.hypot(y, math.hypot(x, z))
	tmp = 0
	if y <= -7e+143:
		tmp = -t_0 / 2.0
	elif y <= 1.8e+146:
		tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
	else:
		tmp = t_0 / 2.0
	return tmp
function code(x, y, z)
	t_0 = hypot(y, hypot(x, z))
	tmp = 0.0
	if (y <= -7e+143)
		tmp = Float64(Float64(-t_0) / 2.0);
	elseif (y <= 1.8e+146)
		tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0));
	else
		tmp = Float64(t_0 / 2.0);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = hypot(y, hypot(x, z));
	tmp = 0.0;
	if (y <= -7e+143)
		tmp = -t_0 / 2.0;
	elseif (y <= 1.8e+146)
		tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
	else
		tmp = t_0 / 2.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[Sqrt[y ^ 2 + N[Sqrt[x ^ 2 + z ^ 2], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[y, -7e+143], N[((-t$95$0) / 2.0), $MachinePrecision], If[LessEqual[y, 1.8e+146], N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / 2.0), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)\\
\mathbf{if}\;y \leq -7 \cdot 10^{+143}:\\
\;\;\;\;\frac{-t_0}{2}\\

\mathbf{elif}\;y \leq 1.8 \cdot 10^{+146}:\\
\;\;\;\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\frac{t_0}{2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -7.00000000000000017e143

    1. Initial program 4.8%

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

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

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

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

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

    if -7.00000000000000017e143 < y < 1.7999999999999999e146

    1. Initial program 90.5%

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

    if 1.7999999999999999e146 < y

    1. Initial program 13.2%

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

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

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

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

      \[\leadsto \color{blue}{1} \cdot \frac{\mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)}{2} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification84.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{+143}:\\ \;\;\;\;\frac{-\mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)}{2}\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{+146}:\\ \;\;\;\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)}{2}\\ \end{array} \]

Alternative 4: 85.0% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{+143}:\\ \;\;\;\;\frac{-\mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)}{2}\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{+146}:\\ \;\;\;\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -7e+143)
   (/ (- (hypot y (hypot x z))) 2.0)
   (if (<= y 1.8e+146)
     (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0))
     (* y 0.5))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -7e+143) {
		tmp = -hypot(y, hypot(x, z)) / 2.0;
	} else if (y <= 1.8e+146) {
		tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
	} else {
		tmp = y * 0.5;
	}
	return tmp;
}
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -7e+143) {
		tmp = -Math.hypot(y, Math.hypot(x, z)) / 2.0;
	} else if (y <= 1.8e+146) {
		tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
	} else {
		tmp = y * 0.5;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -7e+143:
		tmp = -math.hypot(y, math.hypot(x, z)) / 2.0
	elif y <= 1.8e+146:
		tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
	else:
		tmp = y * 0.5
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -7e+143)
		tmp = Float64(Float64(-hypot(y, hypot(x, z))) / 2.0);
	elseif (y <= 1.8e+146)
		tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0));
	else
		tmp = Float64(y * 0.5);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -7e+143)
		tmp = -hypot(y, hypot(x, z)) / 2.0;
	elseif (y <= 1.8e+146)
		tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
	else
		tmp = y * 0.5;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -7e+143], N[((-N[Sqrt[y ^ 2 + N[Sqrt[x ^ 2 + z ^ 2], $MachinePrecision] ^ 2], $MachinePrecision]) / 2.0), $MachinePrecision], If[LessEqual[y, 1.8e+146], N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+143}:\\
\;\;\;\;\frac{-\mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)}{2}\\

\mathbf{elif}\;y \leq 1.8 \cdot 10^{+146}:\\
\;\;\;\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -7.00000000000000017e143

    1. Initial program 4.8%

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

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

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

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

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

    if -7.00000000000000017e143 < y < 1.7999999999999999e146

    1. Initial program 90.5%

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

    if 1.7999999999999999e146 < y

    1. Initial program 13.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{+143}:\\ \;\;\;\;\frac{-\mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)}{2}\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{+146}:\\ \;\;\;\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]

Alternative 5: 43.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(z \cdot \frac{z}{y}\right) \cdot -0.5\\ \mathbf{if}\;x \leq 2.55 \cdot 10^{-232}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{-104}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 9 \cdot 10^{-62}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 6 \cdot 10^{+19}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{+62} \lor \neg \left(x \leq 2.2 \cdot 10^{+99}\right) \land x \leq 1.8 \cdot 10^{+115}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (* z (/ z y)) -0.5)))
   (if (<= x 2.55e-232)
     t_0
     (if (<= x 1.8e-104)
       (* y 0.5)
       (if (<= x 9e-62)
         t_0
         (if (<= x 6e+19)
           (* y 0.5)
           (if (or (<= x 3.1e+62) (and (not (<= x 2.2e+99)) (<= x 1.8e+115)))
             t_0
             (* x (* x (/ 0.5 y))))))))))
double code(double x, double y, double z) {
	double t_0 = (z * (z / y)) * -0.5;
	double tmp;
	if (x <= 2.55e-232) {
		tmp = t_0;
	} else if (x <= 1.8e-104) {
		tmp = y * 0.5;
	} else if (x <= 9e-62) {
		tmp = t_0;
	} else if (x <= 6e+19) {
		tmp = y * 0.5;
	} else if ((x <= 3.1e+62) || (!(x <= 2.2e+99) && (x <= 1.8e+115))) {
		tmp = t_0;
	} else {
		tmp = x * (x * (0.5 / y));
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (z * (z / y)) * (-0.5d0)
    if (x <= 2.55d-232) then
        tmp = t_0
    else if (x <= 1.8d-104) then
        tmp = y * 0.5d0
    else if (x <= 9d-62) then
        tmp = t_0
    else if (x <= 6d+19) then
        tmp = y * 0.5d0
    else if ((x <= 3.1d+62) .or. (.not. (x <= 2.2d+99)) .and. (x <= 1.8d+115)) then
        tmp = t_0
    else
        tmp = x * (x * (0.5d0 / y))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = (z * (z / y)) * -0.5;
	double tmp;
	if (x <= 2.55e-232) {
		tmp = t_0;
	} else if (x <= 1.8e-104) {
		tmp = y * 0.5;
	} else if (x <= 9e-62) {
		tmp = t_0;
	} else if (x <= 6e+19) {
		tmp = y * 0.5;
	} else if ((x <= 3.1e+62) || (!(x <= 2.2e+99) && (x <= 1.8e+115))) {
		tmp = t_0;
	} else {
		tmp = x * (x * (0.5 / y));
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (z * (z / y)) * -0.5
	tmp = 0
	if x <= 2.55e-232:
		tmp = t_0
	elif x <= 1.8e-104:
		tmp = y * 0.5
	elif x <= 9e-62:
		tmp = t_0
	elif x <= 6e+19:
		tmp = y * 0.5
	elif (x <= 3.1e+62) or (not (x <= 2.2e+99) and (x <= 1.8e+115)):
		tmp = t_0
	else:
		tmp = x * (x * (0.5 / y))
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(z * Float64(z / y)) * -0.5)
	tmp = 0.0
	if (x <= 2.55e-232)
		tmp = t_0;
	elseif (x <= 1.8e-104)
		tmp = Float64(y * 0.5);
	elseif (x <= 9e-62)
		tmp = t_0;
	elseif (x <= 6e+19)
		tmp = Float64(y * 0.5);
	elseif ((x <= 3.1e+62) || (!(x <= 2.2e+99) && (x <= 1.8e+115)))
		tmp = t_0;
	else
		tmp = Float64(x * Float64(x * Float64(0.5 / y)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (z * (z / y)) * -0.5;
	tmp = 0.0;
	if (x <= 2.55e-232)
		tmp = t_0;
	elseif (x <= 1.8e-104)
		tmp = y * 0.5;
	elseif (x <= 9e-62)
		tmp = t_0;
	elseif (x <= 6e+19)
		tmp = y * 0.5;
	elseif ((x <= 3.1e+62) || (~((x <= 2.2e+99)) && (x <= 1.8e+115)))
		tmp = t_0;
	else
		tmp = x * (x * (0.5 / y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]}, If[LessEqual[x, 2.55e-232], t$95$0, If[LessEqual[x, 1.8e-104], N[(y * 0.5), $MachinePrecision], If[LessEqual[x, 9e-62], t$95$0, If[LessEqual[x, 6e+19], N[(y * 0.5), $MachinePrecision], If[Or[LessEqual[x, 3.1e+62], And[N[Not[LessEqual[x, 2.2e+99]], $MachinePrecision], LessEqual[x, 1.8e+115]]], t$95$0, N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 1.8 \cdot 10^{-104}:\\
\;\;\;\;y \cdot 0.5\\

\mathbf{elif}\;x \leq 9 \cdot 10^{-62}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 6 \cdot 10^{+19}:\\
\;\;\;\;y \cdot 0.5\\

\mathbf{elif}\;x \leq 3.1 \cdot 10^{+62} \lor \neg \left(x \leq 2.2 \cdot 10^{+99}\right) \land x \leq 1.8 \cdot 10^{+115}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 2.55000000000000014e-232 or 1.7999999999999999e-104 < x < 9.00000000000000036e-62 or 6e19 < x < 3.10000000000000014e62 or 2.19999999999999978e99 < x < 1.8e115

    1. Initial program 72.1%

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

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

        \[\leadsto \color{blue}{\frac{{z}^{2}}{y} \cdot -0.5} \]
    4. Simplified36.9%

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

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

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

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

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

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

    if 2.55000000000000014e-232 < x < 1.7999999999999999e-104 or 9.00000000000000036e-62 < x < 6e19

    1. Initial program 55.9%

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

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

    if 3.10000000000000014e62 < x < 2.19999999999999978e99 or 1.8e115 < x

    1. Initial program 59.0%

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

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

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

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

      \[\leadsto \color{blue}{\frac{0.5}{\frac{y}{{x}^{2}}}} \]
    5. Step-by-step derivation
      1. associate-/r/63.4%

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

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

        \[\leadsto \color{blue}{\left(\frac{0.5}{y} \cdot x\right) \cdot x} \]
    6. Applied egg-rr76.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.55 \cdot 10^{-232}:\\ \;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{-104}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 9 \cdot 10^{-62}:\\ \;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\ \mathbf{elif}\;x \leq 6 \cdot 10^{+19}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{+62} \lor \neg \left(x \leq 2.2 \cdot 10^{+99}\right) \land x \leq 1.8 \cdot 10^{+115}:\\ \;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \end{array} \]

Alternative 6: 43.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(z \cdot \frac{z}{y}\right) \cdot -0.5\\ \mathbf{if}\;x \leq 3.05 \cdot 10^{-232}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 7 \cdot 10^{-108}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-61}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{+17}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{+63} \lor \neg \left(x \leq 1.15 \cdot 10^{+99}\right) \land x \leq 9 \cdot 10^{+114}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{x \cdot 0.5}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (* z (/ z y)) -0.5)))
   (if (<= x 3.05e-232)
     t_0
     (if (<= x 7e-108)
       (* y 0.5)
       (if (<= x 6.2e-61)
         t_0
         (if (<= x 5.5e+17)
           (* y 0.5)
           (if (or (<= x 2.7e+63) (and (not (<= x 1.15e+99)) (<= x 9e+114)))
             t_0
             (* x (/ (* x 0.5) y)))))))))
double code(double x, double y, double z) {
	double t_0 = (z * (z / y)) * -0.5;
	double tmp;
	if (x <= 3.05e-232) {
		tmp = t_0;
	} else if (x <= 7e-108) {
		tmp = y * 0.5;
	} else if (x <= 6.2e-61) {
		tmp = t_0;
	} else if (x <= 5.5e+17) {
		tmp = y * 0.5;
	} else if ((x <= 2.7e+63) || (!(x <= 1.15e+99) && (x <= 9e+114))) {
		tmp = t_0;
	} else {
		tmp = x * ((x * 0.5) / y);
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (z * (z / y)) * (-0.5d0)
    if (x <= 3.05d-232) then
        tmp = t_0
    else if (x <= 7d-108) then
        tmp = y * 0.5d0
    else if (x <= 6.2d-61) then
        tmp = t_0
    else if (x <= 5.5d+17) then
        tmp = y * 0.5d0
    else if ((x <= 2.7d+63) .or. (.not. (x <= 1.15d+99)) .and. (x <= 9d+114)) then
        tmp = t_0
    else
        tmp = x * ((x * 0.5d0) / y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = (z * (z / y)) * -0.5;
	double tmp;
	if (x <= 3.05e-232) {
		tmp = t_0;
	} else if (x <= 7e-108) {
		tmp = y * 0.5;
	} else if (x <= 6.2e-61) {
		tmp = t_0;
	} else if (x <= 5.5e+17) {
		tmp = y * 0.5;
	} else if ((x <= 2.7e+63) || (!(x <= 1.15e+99) && (x <= 9e+114))) {
		tmp = t_0;
	} else {
		tmp = x * ((x * 0.5) / y);
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (z * (z / y)) * -0.5
	tmp = 0
	if x <= 3.05e-232:
		tmp = t_0
	elif x <= 7e-108:
		tmp = y * 0.5
	elif x <= 6.2e-61:
		tmp = t_0
	elif x <= 5.5e+17:
		tmp = y * 0.5
	elif (x <= 2.7e+63) or (not (x <= 1.15e+99) and (x <= 9e+114)):
		tmp = t_0
	else:
		tmp = x * ((x * 0.5) / y)
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(z * Float64(z / y)) * -0.5)
	tmp = 0.0
	if (x <= 3.05e-232)
		tmp = t_0;
	elseif (x <= 7e-108)
		tmp = Float64(y * 0.5);
	elseif (x <= 6.2e-61)
		tmp = t_0;
	elseif (x <= 5.5e+17)
		tmp = Float64(y * 0.5);
	elseif ((x <= 2.7e+63) || (!(x <= 1.15e+99) && (x <= 9e+114)))
		tmp = t_0;
	else
		tmp = Float64(x * Float64(Float64(x * 0.5) / y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (z * (z / y)) * -0.5;
	tmp = 0.0;
	if (x <= 3.05e-232)
		tmp = t_0;
	elseif (x <= 7e-108)
		tmp = y * 0.5;
	elseif (x <= 6.2e-61)
		tmp = t_0;
	elseif (x <= 5.5e+17)
		tmp = y * 0.5;
	elseif ((x <= 2.7e+63) || (~((x <= 1.15e+99)) && (x <= 9e+114)))
		tmp = t_0;
	else
		tmp = x * ((x * 0.5) / y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]}, If[LessEqual[x, 3.05e-232], t$95$0, If[LessEqual[x, 7e-108], N[(y * 0.5), $MachinePrecision], If[LessEqual[x, 6.2e-61], t$95$0, If[LessEqual[x, 5.5e+17], N[(y * 0.5), $MachinePrecision], If[Or[LessEqual[x, 2.7e+63], And[N[Not[LessEqual[x, 1.15e+99]], $MachinePrecision], LessEqual[x, 9e+114]]], t$95$0, N[(x * N[(N[(x * 0.5), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 7 \cdot 10^{-108}:\\
\;\;\;\;y \cdot 0.5\\

\mathbf{elif}\;x \leq 6.2 \cdot 10^{-61}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 5.5 \cdot 10^{+17}:\\
\;\;\;\;y \cdot 0.5\\

\mathbf{elif}\;x \leq 2.7 \cdot 10^{+63} \lor \neg \left(x \leq 1.15 \cdot 10^{+99}\right) \land x \leq 9 \cdot 10^{+114}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 3.0500000000000001e-232 or 6.9999999999999997e-108 < x < 6.1999999999999999e-61 or 5.5e17 < x < 2.70000000000000017e63 or 1.1500000000000001e99 < x < 9.0000000000000001e114

    1. Initial program 72.1%

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

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

        \[\leadsto \color{blue}{\frac{{z}^{2}}{y} \cdot -0.5} \]
    4. Simplified36.9%

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

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

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

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

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

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

    if 3.0500000000000001e-232 < x < 6.9999999999999997e-108 or 6.1999999999999999e-61 < x < 5.5e17

    1. Initial program 55.9%

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

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

    if 2.70000000000000017e63 < x < 1.1500000000000001e99 or 9.0000000000000001e114 < x

    1. Initial program 59.0%

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

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

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

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

      \[\leadsto \color{blue}{\frac{0.5}{\frac{y}{{x}^{2}}}} \]
    5. Step-by-step derivation
      1. associate-/r/63.4%

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

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

        \[\leadsto \color{blue}{\left(\frac{0.5}{y} \cdot x\right) \cdot x} \]
    6. Applied egg-rr76.8%

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

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

        \[\leadsto \color{blue}{\frac{x \cdot 0.5}{y}} \cdot x \]
    8. Applied egg-rr76.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 3.05 \cdot 10^{-232}:\\ \;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\ \mathbf{elif}\;x \leq 7 \cdot 10^{-108}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-61}:\\ \;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{+17}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{+63} \lor \neg \left(x \leq 1.15 \cdot 10^{+99}\right) \land x \leq 9 \cdot 10^{+114}:\\ \;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{x \cdot 0.5}{y}\\ \end{array} \]

Alternative 7: 43.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(z \cdot \frac{z}{y}\right) \cdot -0.5\\ \mathbf{if}\;x \leq 2.65 \cdot 10^{-233}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-104}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-61}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{+20}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{+63}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{+99}:\\ \;\;\;\;\frac{0.5}{\frac{\frac{y}{x}}{x}}\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{+115}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{x \cdot 0.5}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (* z (/ z y)) -0.5)))
   (if (<= x 2.65e-233)
     t_0
     (if (<= x 3.2e-104)
       (* y 0.5)
       (if (<= x 5.2e-61)
         t_0
         (if (<= x 1.05e+20)
           (* y 0.5)
           (if (<= x 2.6e+63)
             t_0
             (if (<= x 1.25e+99)
               (/ 0.5 (/ (/ y x) x))
               (if (<= x 1.15e+115) t_0 (* x (/ (* x 0.5) y)))))))))))
double code(double x, double y, double z) {
	double t_0 = (z * (z / y)) * -0.5;
	double tmp;
	if (x <= 2.65e-233) {
		tmp = t_0;
	} else if (x <= 3.2e-104) {
		tmp = y * 0.5;
	} else if (x <= 5.2e-61) {
		tmp = t_0;
	} else if (x <= 1.05e+20) {
		tmp = y * 0.5;
	} else if (x <= 2.6e+63) {
		tmp = t_0;
	} else if (x <= 1.25e+99) {
		tmp = 0.5 / ((y / x) / x);
	} else if (x <= 1.15e+115) {
		tmp = t_0;
	} else {
		tmp = x * ((x * 0.5) / y);
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (z * (z / y)) * (-0.5d0)
    if (x <= 2.65d-233) then
        tmp = t_0
    else if (x <= 3.2d-104) then
        tmp = y * 0.5d0
    else if (x <= 5.2d-61) then
        tmp = t_0
    else if (x <= 1.05d+20) then
        tmp = y * 0.5d0
    else if (x <= 2.6d+63) then
        tmp = t_0
    else if (x <= 1.25d+99) then
        tmp = 0.5d0 / ((y / x) / x)
    else if (x <= 1.15d+115) then
        tmp = t_0
    else
        tmp = x * ((x * 0.5d0) / y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = (z * (z / y)) * -0.5;
	double tmp;
	if (x <= 2.65e-233) {
		tmp = t_0;
	} else if (x <= 3.2e-104) {
		tmp = y * 0.5;
	} else if (x <= 5.2e-61) {
		tmp = t_0;
	} else if (x <= 1.05e+20) {
		tmp = y * 0.5;
	} else if (x <= 2.6e+63) {
		tmp = t_0;
	} else if (x <= 1.25e+99) {
		tmp = 0.5 / ((y / x) / x);
	} else if (x <= 1.15e+115) {
		tmp = t_0;
	} else {
		tmp = x * ((x * 0.5) / y);
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (z * (z / y)) * -0.5
	tmp = 0
	if x <= 2.65e-233:
		tmp = t_0
	elif x <= 3.2e-104:
		tmp = y * 0.5
	elif x <= 5.2e-61:
		tmp = t_0
	elif x <= 1.05e+20:
		tmp = y * 0.5
	elif x <= 2.6e+63:
		tmp = t_0
	elif x <= 1.25e+99:
		tmp = 0.5 / ((y / x) / x)
	elif x <= 1.15e+115:
		tmp = t_0
	else:
		tmp = x * ((x * 0.5) / y)
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(z * Float64(z / y)) * -0.5)
	tmp = 0.0
	if (x <= 2.65e-233)
		tmp = t_0;
	elseif (x <= 3.2e-104)
		tmp = Float64(y * 0.5);
	elseif (x <= 5.2e-61)
		tmp = t_0;
	elseif (x <= 1.05e+20)
		tmp = Float64(y * 0.5);
	elseif (x <= 2.6e+63)
		tmp = t_0;
	elseif (x <= 1.25e+99)
		tmp = Float64(0.5 / Float64(Float64(y / x) / x));
	elseif (x <= 1.15e+115)
		tmp = t_0;
	else
		tmp = Float64(x * Float64(Float64(x * 0.5) / y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (z * (z / y)) * -0.5;
	tmp = 0.0;
	if (x <= 2.65e-233)
		tmp = t_0;
	elseif (x <= 3.2e-104)
		tmp = y * 0.5;
	elseif (x <= 5.2e-61)
		tmp = t_0;
	elseif (x <= 1.05e+20)
		tmp = y * 0.5;
	elseif (x <= 2.6e+63)
		tmp = t_0;
	elseif (x <= 1.25e+99)
		tmp = 0.5 / ((y / x) / x);
	elseif (x <= 1.15e+115)
		tmp = t_0;
	else
		tmp = x * ((x * 0.5) / y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]}, If[LessEqual[x, 2.65e-233], t$95$0, If[LessEqual[x, 3.2e-104], N[(y * 0.5), $MachinePrecision], If[LessEqual[x, 5.2e-61], t$95$0, If[LessEqual[x, 1.05e+20], N[(y * 0.5), $MachinePrecision], If[LessEqual[x, 2.6e+63], t$95$0, If[LessEqual[x, 1.25e+99], N[(0.5 / N[(N[(y / x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.15e+115], t$95$0, N[(x * N[(N[(x * 0.5), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 3.2 \cdot 10^{-104}:\\
\;\;\;\;y \cdot 0.5\\

\mathbf{elif}\;x \leq 5.2 \cdot 10^{-61}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 1.05 \cdot 10^{+20}:\\
\;\;\;\;y \cdot 0.5\\

\mathbf{elif}\;x \leq 2.6 \cdot 10^{+63}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 1.25 \cdot 10^{+99}:\\
\;\;\;\;\frac{0.5}{\frac{\frac{y}{x}}{x}}\\

\mathbf{elif}\;x \leq 1.15 \cdot 10^{+115}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 2.64999999999999986e-233 or 3.19999999999999989e-104 < x < 5.20000000000000021e-61 or 1.05e20 < x < 2.6000000000000001e63 or 1.25000000000000002e99 < x < 1.15000000000000002e115

    1. Initial program 72.1%

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

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

        \[\leadsto \color{blue}{\frac{{z}^{2}}{y} \cdot -0.5} \]
    4. Simplified36.9%

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

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

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

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

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

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

    if 2.64999999999999986e-233 < x < 3.19999999999999989e-104 or 5.20000000000000021e-61 < x < 1.05e20

    1. Initial program 55.9%

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

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

    if 2.6000000000000001e63 < x < 1.25000000000000002e99

    1. Initial program 81.4%

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

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

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

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

      \[\leadsto \color{blue}{\frac{0.5}{\frac{y}{{x}^{2}}}} \]
    5. Step-by-step derivation
      1. *-un-lft-identity80.5%

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

        \[\leadsto \frac{0.5}{\frac{1 \cdot y}{\color{blue}{x \cdot x}}} \]
      3. times-frac80.5%

        \[\leadsto \frac{0.5}{\color{blue}{\frac{1}{x} \cdot \frac{y}{x}}} \]
    6. Applied egg-rr80.5%

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

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

        \[\leadsto \frac{0.5}{\frac{\color{blue}{\frac{y}{x}}}{x}} \]
    8. Simplified80.5%

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

    if 1.15000000000000002e115 < x

    1. Initial program 56.2%

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

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

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

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

      \[\leadsto \color{blue}{\frac{0.5}{\frac{y}{{x}^{2}}}} \]
    5. Step-by-step derivation
      1. associate-/r/61.4%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot 0.5}{y}} \cdot x \]
    8. Applied egg-rr76.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.65 \cdot 10^{-233}:\\ \;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-104}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-61}:\\ \;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{+20}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{+63}:\\ \;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{+99}:\\ \;\;\;\;\frac{0.5}{\frac{\frac{y}{x}}{x}}\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{+115}:\\ \;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{x \cdot 0.5}{y}\\ \end{array} \]

Alternative 8: 85.0% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{+143} \lor \neg \left(y \leq 1.8 \cdot 10^{+146}\right):\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -7e+143) (not (<= y 1.8e+146)))
   (* y 0.5)
   (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -7e+143) || !(y <= 1.8e+146)) {
		tmp = y * 0.5;
	} else {
		tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((y <= (-7d+143)) .or. (.not. (y <= 1.8d+146))) then
        tmp = y * 0.5d0
    else
        tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= -7e+143) || !(y <= 1.8e+146)) {
		tmp = y * 0.5;
	} else {
		tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -7e+143) or not (y <= 1.8e+146):
		tmp = y * 0.5
	else:
		tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -7e+143) || !(y <= 1.8e+146))
		tmp = Float64(y * 0.5);
	else
		tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -7e+143) || ~((y <= 1.8e+146)))
		tmp = y * 0.5;
	else
		tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -7e+143], N[Not[LessEqual[y, 1.8e+146]], $MachinePrecision]], N[(y * 0.5), $MachinePrecision], 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}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+143} \lor \neg \left(y \leq 1.8 \cdot 10^{+146}\right):\\
\;\;\;\;y \cdot 0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -7.00000000000000017e143 or 1.7999999999999999e146 < y

    1. Initial program 9.8%

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

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

    if -7.00000000000000017e143 < y < 1.7999999999999999e146

    1. Initial program 90.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{+143} \lor \neg \left(y \leq 1.8 \cdot 10^{+146}\right):\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\ \end{array} \]

Alternative 9: 52.8% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -8.5 \cdot 10^{+93} \lor \neg \left(y \leq 6.1 \cdot 10^{+100}\right):\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -8.5e+93) (not (<= y 6.1e+100)))
   (* y 0.5)
   (* (* z (/ z y)) -0.5)))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -8.5e+93) || !(y <= 6.1e+100)) {
		tmp = y * 0.5;
	} else {
		tmp = (z * (z / y)) * -0.5;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((y <= (-8.5d+93)) .or. (.not. (y <= 6.1d+100))) then
        tmp = y * 0.5d0
    else
        tmp = (z * (z / y)) * (-0.5d0)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= -8.5e+93) || !(y <= 6.1e+100)) {
		tmp = y * 0.5;
	} else {
		tmp = (z * (z / y)) * -0.5;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -8.5e+93) or not (y <= 6.1e+100):
		tmp = y * 0.5
	else:
		tmp = (z * (z / y)) * -0.5
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -8.5e+93) || !(y <= 6.1e+100))
		tmp = Float64(y * 0.5);
	else
		tmp = Float64(Float64(z * Float64(z / y)) * -0.5);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -8.5e+93) || ~((y <= 6.1e+100)))
		tmp = y * 0.5;
	else
		tmp = (z * (z / y)) * -0.5;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -8.5e+93], N[Not[LessEqual[y, 6.1e+100]], $MachinePrecision]], N[(y * 0.5), $MachinePrecision], N[(N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.5 \cdot 10^{+93} \lor \neg \left(y \leq 6.1 \cdot 10^{+100}\right):\\
\;\;\;\;y \cdot 0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -8.5000000000000005e93 or 6.0999999999999999e100 < y

    1. Initial program 25.7%

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

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

    if -8.5000000000000005e93 < y < 6.0999999999999999e100

    1. Initial program 91.6%

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

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

        \[\leadsto \color{blue}{\frac{{z}^{2}}{y} \cdot -0.5} \]
    4. Simplified43.6%

      \[\leadsto \color{blue}{\frac{{z}^{2}}{y} \cdot -0.5} \]
    5. Step-by-step derivation
      1. div-inv43.5%

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

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

        \[\leadsto \color{blue}{\left(z \cdot \left(z \cdot \frac{1}{y}\right)\right)} \cdot -0.5 \]
      4. div-inv45.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -8.5 \cdot 10^{+93} \lor \neg \left(y \leq 6.1 \cdot 10^{+100}\right):\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\ \end{array} \]

Alternative 10: 34.3% accurate, 5.0× speedup?

\[\begin{array}{l} \\ y \cdot 0.5 \end{array} \]
(FPCore (x y z) :precision binary64 (* y 0.5))
double code(double x, double y, double z) {
	return y * 0.5;
}
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
end function
public static double code(double x, double y, double z) {
	return y * 0.5;
}
def code(x, y, z):
	return y * 0.5
function code(x, y, z)
	return Float64(y * 0.5)
end
function tmp = code(x, y, z)
	tmp = y * 0.5;
end
code[x_, y_, z_] := N[(y * 0.5), $MachinePrecision]
\begin{array}{l}

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

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

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

    \[\leadsto y \cdot 0.5 \]

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

  :herbie-target
  (- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x)))

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