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

Percentage Accurate: 69.1% → 91.6%
Time: 9.8s
Alternatives: 9
Speedup: 0.7×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 69.1% accurate, 1.0× speedup?

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

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

Alternative 1: 91.6% accurate, 0.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x x) < 1e303

    1. Initial program 78.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e303 < (*.f64 x x)

    1. Initial program 55.1%

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified65.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. Step-by-step derivation
      1. prod-diff55.3%

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

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

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

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

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

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

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

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

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

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

Alternative 2: 86.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 6.7 \cdot 10^{+152}:\\ \;\;\;\;0.5 \cdot \left(y + \frac{{x}^{2} - {z}^{2}}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x 6.7e+152)
   (* 0.5 (+ y (/ (- (pow x 2.0) (pow z 2.0)) y)))
   (* x (* x (/ 0.5 y)))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= 6.7e+152) {
		tmp = 0.5 * (y + ((pow(x, 2.0) - pow(z, 2.0)) / y));
	} 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) :: tmp
    if (x <= 6.7d+152) then
        tmp = 0.5d0 * (y + (((x ** 2.0d0) - (z ** 2.0d0)) / y))
    else
        tmp = x * (x * (0.5d0 / y))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= 6.7e+152) {
		tmp = 0.5 * (y + ((Math.pow(x, 2.0) - Math.pow(z, 2.0)) / y));
	} else {
		tmp = x * (x * (0.5 / y));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= 6.7e+152:
		tmp = 0.5 * (y + ((math.pow(x, 2.0) - math.pow(z, 2.0)) / y))
	else:
		tmp = x * (x * (0.5 / y))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= 6.7e+152)
		tmp = Float64(0.5 * Float64(y + Float64(Float64((x ^ 2.0) - (z ^ 2.0)) / y)));
	else
		tmp = Float64(x * Float64(x * Float64(0.5 / y)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= 6.7e+152)
		tmp = 0.5 * (y + (((x ^ 2.0) - (z ^ 2.0)) / y));
	else
		tmp = x * (x * (0.5 / y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, 6.7e+152], N[(0.5 * N[(y + N[(N[(N[Power[x, 2.0], $MachinePrecision] - N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 77.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.69999999999999987e152 < x

    1. Initial program 47.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{0.5}{y} \cdot {x}^{2}} \]
      2. add-sqr-sqrt44.8%

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(\sqrt{\frac{0.5}{y}} \cdot \color{blue}{\sqrt{\frac{0.5}{y}}}\right) \cdot x\right) \cdot x \]
      11. add-sqr-sqrt75.9%

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

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

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

Alternative 3: 70.0% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\ \mathbf{if}\;t\_0 \leq 5 \cdot 10^{+120}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(y + \left(2 \cdot z + \frac{{x}^{2}}{y}\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0))))
   (if (<= t_0 5e+120) t_0 (* 0.5 (+ y (+ (* 2.0 z) (/ (pow x 2.0) y)))))))
double code(double x, double y, double z) {
	double t_0 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
	double tmp;
	if (t_0 <= 5e+120) {
		tmp = t_0;
	} else {
		tmp = 0.5 * (y + ((2.0 * z) + (pow(x, 2.0) / 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 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
    if (t_0 <= 5d+120) then
        tmp = t_0
    else
        tmp = 0.5d0 * (y + ((2.0d0 * z) + ((x ** 2.0d0) / y)))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
	double tmp;
	if (t_0 <= 5e+120) {
		tmp = t_0;
	} else {
		tmp = 0.5 * (y + ((2.0 * z) + (Math.pow(x, 2.0) / y)));
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
	tmp = 0
	if t_0 <= 5e+120:
		tmp = t_0
	else:
		tmp = 0.5 * (y + ((2.0 * z) + (math.pow(x, 2.0) / y)))
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0))
	tmp = 0.0
	if (t_0 <= 5e+120)
		tmp = t_0;
	else
		tmp = Float64(0.5 * Float64(y + Float64(Float64(2.0 * z) + Float64((x ^ 2.0) / y))));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
	tmp = 0.0;
	if (t_0 <= 5e+120)
		tmp = t_0;
	else
		tmp = 0.5 * (y + ((2.0 * z) + ((x ^ 2.0) / y)));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e+120], t$95$0, N[(0.5 * N[(y + N[(N[(2.0 * z), $MachinePrecision] + N[(N[Power[x, 2.0], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{+120}:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 88.2%

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

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

    1. Initial program 54.6%

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified60.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. Step-by-step derivation
      1. prod-diff44.9%

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{\mathsf{hypot}\left(x, z + y\right)}{{\left(\sqrt[3]{y}\right)}^{2}} \cdot \frac{\mathsf{hypot}\left(x, z + y\right)}{\sqrt[3]{y}}\right)} \]
    8. Taylor expanded in z around 0 58.8%

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

Alternative 4: 79.2% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 4.1 \cdot 10^{+145}:\\ \;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot y\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y 4.1e+145) (* 0.5 (/ (fma x x (- (* y y) (* z z))) y)) (* 0.5 y)))
double code(double x, double y, double z) {
	double tmp;
	if (y <= 4.1e+145) {
		tmp = 0.5 * (fma(x, x, ((y * y) - (z * z))) / y);
	} else {
		tmp = 0.5 * y;
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (y <= 4.1e+145)
		tmp = Float64(0.5 * Float64(fma(x, x, Float64(Float64(y * y) - Float64(z * z))) / y));
	else
		tmp = Float64(0.5 * y);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[y, 4.1e+145], N[(0.5 * N[(N[(x * x + N[(N[(y * y), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.1 \cdot 10^{+145}:\\
\;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, 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 < 4.1000000000000001e145

    1. Initial program 83.0%

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified86.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 4.1000000000000001e145 < y

    1. Initial program 12.9%

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

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

Alternative 5: 43.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(z \cdot \frac{z}{y}\right) \cdot -0.5\\ t_1 := x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \mathbf{if}\;y \leq 1.8 \cdot 10^{-292}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 5.4 \cdot 10^{-267}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{-169}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{-69}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 0.085:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot y\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (* z (/ z y)) -0.5)) (t_1 (* x (* x (/ 0.5 y)))))
   (if (<= y 1.8e-292)
     t_0
     (if (<= y 5.4e-267)
       t_1
       (if (<= y 1.35e-169)
         t_0
         (if (<= y 3.2e-69) t_1 (if (<= y 0.085) t_0 (* 0.5 y))))))))
double code(double x, double y, double z) {
	double t_0 = (z * (z / y)) * -0.5;
	double t_1 = x * (x * (0.5 / y));
	double tmp;
	if (y <= 1.8e-292) {
		tmp = t_0;
	} else if (y <= 5.4e-267) {
		tmp = t_1;
	} else if (y <= 1.35e-169) {
		tmp = t_0;
	} else if (y <= 3.2e-69) {
		tmp = t_1;
	} else if (y <= 0.085) {
		tmp = t_0;
	} else {
		tmp = 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) :: t_1
    real(8) :: tmp
    t_0 = (z * (z / y)) * (-0.5d0)
    t_1 = x * (x * (0.5d0 / y))
    if (y <= 1.8d-292) then
        tmp = t_0
    else if (y <= 5.4d-267) then
        tmp = t_1
    else if (y <= 1.35d-169) then
        tmp = t_0
    else if (y <= 3.2d-69) then
        tmp = t_1
    else if (y <= 0.085d0) then
        tmp = t_0
    else
        tmp = 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 t_1 = x * (x * (0.5 / y));
	double tmp;
	if (y <= 1.8e-292) {
		tmp = t_0;
	} else if (y <= 5.4e-267) {
		tmp = t_1;
	} else if (y <= 1.35e-169) {
		tmp = t_0;
	} else if (y <= 3.2e-69) {
		tmp = t_1;
	} else if (y <= 0.085) {
		tmp = t_0;
	} else {
		tmp = 0.5 * y;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (z * (z / y)) * -0.5
	t_1 = x * (x * (0.5 / y))
	tmp = 0
	if y <= 1.8e-292:
		tmp = t_0
	elif y <= 5.4e-267:
		tmp = t_1
	elif y <= 1.35e-169:
		tmp = t_0
	elif y <= 3.2e-69:
		tmp = t_1
	elif y <= 0.085:
		tmp = t_0
	else:
		tmp = 0.5 * y
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(z * Float64(z / y)) * -0.5)
	t_1 = Float64(x * Float64(x * Float64(0.5 / y)))
	tmp = 0.0
	if (y <= 1.8e-292)
		tmp = t_0;
	elseif (y <= 5.4e-267)
		tmp = t_1;
	elseif (y <= 1.35e-169)
		tmp = t_0;
	elseif (y <= 3.2e-69)
		tmp = t_1;
	elseif (y <= 0.085)
		tmp = t_0;
	else
		tmp = Float64(0.5 * y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (z * (z / y)) * -0.5;
	t_1 = x * (x * (0.5 / y));
	tmp = 0.0;
	if (y <= 1.8e-292)
		tmp = t_0;
	elseif (y <= 5.4e-267)
		tmp = t_1;
	elseif (y <= 1.35e-169)
		tmp = t_0;
	elseif (y <= 3.2e-69)
		tmp = t_1;
	elseif (y <= 0.085)
		tmp = t_0;
	else
		tmp = 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]}, Block[{t$95$1 = N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 1.8e-292], t$95$0, If[LessEqual[y, 5.4e-267], t$95$1, If[LessEqual[y, 1.35e-169], t$95$0, If[LessEqual[y, 3.2e-69], t$95$1, If[LessEqual[y, 0.085], t$95$0, N[(0.5 * y), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(z \cdot \frac{z}{y}\right) \cdot -0.5\\
t_1 := x \cdot \left(x \cdot \frac{0.5}{y}\right)\\
\mathbf{if}\;y \leq 1.8 \cdot 10^{-292}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 5.4 \cdot 10^{-267}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 1.35 \cdot 10^{-169}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 3.2 \cdot 10^{-69}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 0.085:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 1.8000000000000001e-292 or 5.39999999999999975e-267 < y < 1.3500000000000001e-169 or 3.19999999999999999e-69 < y < 0.0850000000000000061

    1. Initial program 81.8%

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

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

        \[\leadsto \color{blue}{\frac{{z}^{2}}{y} \cdot -0.5} \]
    5. Simplified41.2%

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

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

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

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

    if 1.8000000000000001e-292 < y < 5.39999999999999975e-267 or 1.3500000000000001e-169 < y < 3.19999999999999999e-69

    1. Initial program 93.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified96.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. Step-by-step derivation
      1. clear-num96.7%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{0.5}{y} \cdot {x}^{2}} \]
      2. add-sqr-sqrt69.7%

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(\frac{\sqrt{0.5}}{\sqrt{y}} \cdot \frac{\sqrt{0.5}}{\sqrt{y}}\right)} \cdot x\right) \cdot x \]
      9. sqrt-undiv69.7%

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

        \[\leadsto \left(\left(\sqrt{\frac{0.5}{y}} \cdot \color{blue}{\sqrt{\frac{0.5}{y}}}\right) \cdot x\right) \cdot x \]
      11. add-sqr-sqrt69.8%

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

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

    if 0.0850000000000000061 < y

    1. Initial program 37.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.8 \cdot 10^{-292}:\\ \;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\ \mathbf{elif}\;y \leq 5.4 \cdot 10^{-267}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{-169}:\\ \;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{-69}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \mathbf{elif}\;y \leq 0.085:\\ \;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot y\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 77.2% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 4.1 \cdot 10^{+145}:\\ \;\;\;\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot y\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y 4.1e+145) (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)) (* 0.5 y)))
double code(double x, double y, double z) {
	double tmp;
	if (y <= 4.1e+145) {
		tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
	} else {
		tmp = 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) :: tmp
    if (y <= 4.1d+145) then
        tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
    else
        tmp = 0.5d0 * y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= 4.1e+145) {
		tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
	} else {
		tmp = 0.5 * y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= 4.1e+145:
		tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
	else:
		tmp = 0.5 * y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= 4.1e+145)
		tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0));
	else
		tmp = Float64(0.5 * y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= 4.1e+145)
		tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
	else
		tmp = 0.5 * y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, 4.1e+145], N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.1 \cdot 10^{+145}:\\
\;\;\;\;\frac{\left(x \cdot x + y \cdot y\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 < 4.1000000000000001e145

    1. Initial program 83.0%

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

    if 4.1000000000000001e145 < y

    1. Initial program 12.9%

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

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

Alternative 7: 43.9% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 0.11:\\ \;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot y\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y 0.11) (* (* z (/ z y)) -0.5) (* 0.5 y)))
double code(double x, double y, double z) {
	double tmp;
	if (y <= 0.11) {
		tmp = (z * (z / y)) * -0.5;
	} else {
		tmp = 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) :: tmp
    if (y <= 0.11d0) then
        tmp = (z * (z / y)) * (-0.5d0)
    else
        tmp = 0.5d0 * y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= 0.11) {
		tmp = (z * (z / y)) * -0.5;
	} else {
		tmp = 0.5 * y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= 0.11:
		tmp = (z * (z / y)) * -0.5
	else:
		tmp = 0.5 * y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= 0.11)
		tmp = Float64(Float64(z * Float64(z / y)) * -0.5);
	else
		tmp = Float64(0.5 * y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= 0.11)
		tmp = (z * (z / y)) * -0.5;
	else
		tmp = 0.5 * y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, 0.11], N[(N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.11:\\
\;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\

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


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

    1. Initial program 83.9%

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

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

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

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

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

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

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

    if 0.110000000000000001 < y

    1. Initial program 37.7%

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

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

Alternative 8: 41.4% accurate, 2.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{\mathsf{hypot}\left(x, z + y\right)}{{\left(\sqrt[3]{y}\right)}^{2}} \cdot \frac{\mathsf{hypot}\left(x, z + y\right)}{\sqrt[3]{y}}\right)} \]
  8. Taylor expanded in y around inf 41.5%

    \[\leadsto \color{blue}{y \cdot \left(0.5 + \frac{z}{y}\right)} \]
  9. Add Preprocessing

Alternative 9: 35.3% accurate, 5.0× speedup?

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

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

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

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

Developer target: 99.9% accurate, 1.0× speedup?

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

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

Reproduce

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

  :alt
  (- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x)))

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