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

Percentage Accurate: 69.5% → 89.6%
Time: 11.9s
Alternatives: 9
Speedup: 1.1×

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.5% accurate, 1.0× speedup?

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

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

Alternative 1: 89.6% accurate, 0.1× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \begin{array}{l} \mathbf{if}\;y\_m \leq 1.4 \cdot 10^{+177}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y\_m - z, y\_m + z, x \cdot x\right)}{y\_m \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(y\_m - z \cdot \frac{z}{y\_m}\right)\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
 :precision binary64
 (*
  y_s
  (if (<= y_m 1.4e+177)
    (/ (fma (- y_m z) (+ y_m z) (* x x)) (* y_m 2.0))
    (* 0.5 (- y_m (* z (/ z y_m)))))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	double tmp;
	if (y_m <= 1.4e+177) {
		tmp = fma((y_m - z), (y_m + z), (x * x)) / (y_m * 2.0);
	} else {
		tmp = 0.5 * (y_m - (z * (z / y_m)));
	}
	return y_s * tmp;
}
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	tmp = 0.0
	if (y_m <= 1.4e+177)
		tmp = Float64(fma(Float64(y_m - z), Float64(y_m + z), Float64(x * x)) / Float64(y_m * 2.0));
	else
		tmp = Float64(0.5 * Float64(y_m - Float64(z * Float64(z / y_m))));
	end
	return Float64(y_s * tmp)
end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[y$95$m, 1.4e+177], N[(N[(N[(y$95$m - z), $MachinePrecision] * N[(y$95$m + z), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y$95$m - N[(z * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

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

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


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

    1. Initial program 76.3%

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

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

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

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

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

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

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

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

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

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

    if 1.40000000000000001e177 < y

    1. Initial program 6.4%

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y - \frac{\color{blue}{z \cdot z}}{y}\right) \]
      2. add-sqr-sqrt89.2%

        \[\leadsto 0.5 \cdot \left(y - \frac{z \cdot z}{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}\right) \]
      3. times-frac93.4%

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

      \[\leadsto 0.5 \cdot \left(y - \color{blue}{\frac{z}{\sqrt{y}} \cdot \frac{z}{\sqrt{y}}}\right) \]
    8. Step-by-step derivation
      1. unpow293.4%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y - z \cdot \color{blue}{\frac{1 \cdot z}{\sqrt{y} \cdot \sqrt{y}}}\right) \]
      5. *-un-lft-identity93.4%

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

        \[\leadsto 0.5 \cdot \left(y - z \cdot \frac{z}{\color{blue}{y}}\right) \]
    11. Applied egg-rr93.4%

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

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

Alternative 2: 89.2% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 76.9%

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

    if 3.9999999999999999e120 < y

    1. Initial program 24.7%

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y - \frac{\color{blue}{z \cdot z}}{y}\right) \]
      2. add-sqr-sqrt84.5%

        \[\leadsto 0.5 \cdot \left(y - \frac{z \cdot z}{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}\right) \]
      3. times-frac87.4%

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y - z \cdot \color{blue}{\frac{1 \cdot z}{\sqrt{y} \cdot \sqrt{y}}}\right) \]
      5. *-un-lft-identity87.4%

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

        \[\leadsto 0.5 \cdot \left(y - z \cdot \frac{z}{\color{blue}{y}}\right) \]
    11. Applied egg-rr87.4%

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

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

Alternative 3: 73.5% accurate, 0.9× speedup?

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

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 7.5 \cdot 10^{+75}:\\
\;\;\;\;\frac{y\_m + z}{\frac{y\_m \cdot 2}{y\_m - z}}\\

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


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

    1. Initial program 72.7%

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{y - z}, y - \left(-z\right), x \cdot x\right)}{y \cdot 2} \]
      7. sub-neg75.5%

        \[\leadsto \frac{\mathsf{fma}\left(y - z, \color{blue}{y + \left(-\left(-z\right)\right)}, x \cdot x\right)}{y \cdot 2} \]
      8. remove-double-neg75.5%

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

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

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

        \[\leadsto \color{blue}{\frac{y + z}{\frac{y \cdot 2}{y - z}}} \]
      2. div-inv78.8%

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

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

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

        \[\leadsto \frac{\color{blue}{y + z}}{\frac{y \cdot 2}{y - z}} \]
      3. +-commutative78.9%

        \[\leadsto \frac{\color{blue}{z + y}}{\frac{y \cdot 2}{y - z}} \]
      4. *-commutative78.9%

        \[\leadsto \frac{z + y}{\frac{\color{blue}{2 \cdot y}}{y - z}} \]
    9. Simplified78.9%

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

    if 7.4999999999999995e75 < x

    1. Initial program 60.1%

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

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

        \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot 2} \]
      2. times-frac71.1%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{2}} \]
    5. Applied egg-rr71.1%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{2}} \]
    6. Step-by-step derivation
      1. div-inv71.1%

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

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

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

        \[\leadsto \left(x \cdot 0.5\right) \cdot \color{blue}{\frac{1}{\frac{y}{x}}} \]
      5. un-div-inv71.2%

        \[\leadsto \color{blue}{\frac{x \cdot 0.5}{\frac{y}{x}}} \]
    7. Applied egg-rr71.2%

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

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

Alternative 4: 73.6% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y - \frac{z \cdot z}{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}\right) \]
      3. times-frac40.1%

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y - z \cdot \color{blue}{\frac{1 \cdot z}{\sqrt{y} \cdot \sqrt{y}}}\right) \]
      5. *-un-lft-identity40.1%

        \[\leadsto 0.5 \cdot \left(y - z \cdot \frac{\color{blue}{z}}{\sqrt{y} \cdot \sqrt{y}}\right) \]
      6. add-sqr-sqrt78.8%

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

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

    if 3.55000000000000001e74 < x

    1. Initial program 60.1%

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

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

        \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot 2} \]
      2. times-frac71.1%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{2}} \]
    5. Applied egg-rr71.1%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{2}} \]
    6. Step-by-step derivation
      1. div-inv71.1%

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

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

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

        \[\leadsto \left(x \cdot 0.5\right) \cdot \color{blue}{\frac{1}{\frac{y}{x}}} \]
      5. un-div-inv71.2%

        \[\leadsto \color{blue}{\frac{x \cdot 0.5}{\frac{y}{x}}} \]
    7. Applied egg-rr71.2%

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

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

Alternative 5: 44.0% accurate, 1.2× speedup?

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

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 4.4 \cdot 10^{+53}:\\
\;\;\;\;y\_m \cdot 0.5\\

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


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

    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 42.7%

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

    if 4.39999999999999997e53 < x

    1. Initial program 62.0%

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

      \[\leadsto \frac{\color{blue}{{x}^{2}}}{y \cdot 2} \]
    4. Step-by-step derivation
      1. div-inv66.7%

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

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

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

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

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

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

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

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

Alternative 6: 44.0% accurate, 1.2× speedup?

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

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 1.32 \cdot 10^{+48}:\\
\;\;\;\;y\_m \cdot 0.5\\

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


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

    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 42.7%

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

    if 1.32e48 < x

    1. Initial program 62.0%

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

      \[\leadsto \frac{\color{blue}{{x}^{2}}}{y \cdot 2} \]
    4. Step-by-step derivation
      1. unpow266.7%

        \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot 2} \]
      2. times-frac70.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.32 \cdot 10^{+48}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 44.0% accurate, 1.2× speedup?

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

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 6.4 \cdot 10^{+42}:\\
\;\;\;\;y\_m \cdot 0.5\\

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


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

    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 42.7%

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

    if 6.40000000000000004e42 < x

    1. Initial program 62.0%

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

      \[\leadsto \frac{\color{blue}{{x}^{2}}}{y \cdot 2} \]
    4. Step-by-step derivation
      1. unpow266.7%

        \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot 2} \]
      2. times-frac70.9%

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

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{2}} \]
    6. Step-by-step derivation
      1. frac-times66.7%

        \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot 2}} \]
      2. *-commutative66.7%

        \[\leadsto \frac{x \cdot x}{\color{blue}{2 \cdot y}} \]
      3. frac-times70.9%

        \[\leadsto \color{blue}{\frac{x}{2} \cdot \frac{x}{y}} \]
      4. clear-num70.9%

        \[\leadsto \color{blue}{\frac{1}{\frac{2}{x}}} \cdot \frac{x}{y} \]
      5. frac-times71.0%

        \[\leadsto \color{blue}{\frac{1 \cdot x}{\frac{2}{x} \cdot y}} \]
      6. *-un-lft-identity71.0%

        \[\leadsto \frac{\color{blue}{x}}{\frac{2}{x} \cdot y} \]
    7. Applied egg-rr71.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 6.4 \cdot 10^{+42}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y \cdot \frac{2}{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 44.0% accurate, 1.2× speedup?

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

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 8.4 \cdot 10^{+48}:\\
\;\;\;\;y\_m \cdot 0.5\\

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


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

    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 42.7%

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

    if 8.3999999999999994e48 < x

    1. Initial program 62.0%

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

      \[\leadsto \frac{\color{blue}{{x}^{2}}}{y \cdot 2} \]
    4. Step-by-step derivation
      1. unpow266.7%

        \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot 2} \]
      2. times-frac70.9%

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

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{2}} \]
    6. Step-by-step derivation
      1. div-inv70.9%

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

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

        \[\leadsto \color{blue}{\left(x \cdot 0.5\right) \cdot \frac{x}{y}} \]
      4. clear-num70.9%

        \[\leadsto \left(x \cdot 0.5\right) \cdot \color{blue}{\frac{1}{\frac{y}{x}}} \]
      5. un-div-inv71.0%

        \[\leadsto \color{blue}{\frac{x \cdot 0.5}{\frac{y}{x}}} \]
    7. Applied egg-rr71.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 8.4 \cdot 10^{+48}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 0.5}{\frac{y}{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 34.9% accurate, 5.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ y\_s \cdot \left(y\_m \cdot 0.5\right) \end{array} \]
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z) :precision binary64 (* y_s (* y_m 0.5)))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
	return y_s * (y_m * 0.5);
}
y_m = abs(y)
y_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    code = y_s * (y_m * 0.5d0)
end function
y_m = Math.abs(y);
y_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
	return y_s * (y_m * 0.5);
}
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x, y_m, z):
	return y_s * (y_m * 0.5)
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x, y_m, z)
	return Float64(y_s * Float64(y_m * 0.5))
end
y_m = abs(y);
y_s = sign(y) * abs(1.0);
function tmp = code(y_s, x, y_m, z)
	tmp = y_s * (y_m * 0.5);
end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * N[(y$95$m * 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
y\_s \cdot \left(y\_m \cdot 0.5\right)
\end{array}
Derivation
  1. Initial program 69.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 35.0%

    \[\leadsto \color{blue}{0.5 \cdot y} \]
  4. Final simplification35.0%

    \[\leadsto y \cdot 0.5 \]
  5. Add Preprocessing

Developer target: 99.8% 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 2024026 
(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)))