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

Percentage Accurate: 68.8% → 90.2%
Time: 12.8s
Alternatives: 7
Speedup: 0.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 7 alternatives:

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

Initial Program: 68.8% 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: 90.2% accurate, 0.6× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 2.3499999999999999e-75

    1. Initial program 75.1%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-cube-cbrt74.8%

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

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

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

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

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

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

      \[\leadsto \frac{{\color{blue}{\left({\left({x}^{2}\right)}^{0.3333333333333333}\right)}}^{3} - z \cdot z}{y \cdot 2} \]
    6. Step-by-step derivation
      1. unpow1/366.8%

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

      \[\leadsto \frac{{\color{blue}{\left(\sqrt[3]{{x}^{2}}\right)}}^{3} - z \cdot z}{y \cdot 2} \]
    8. Step-by-step derivation
      1. rem-cube-cbrt66.9%

        \[\leadsto \frac{\color{blue}{{x}^{2}} - z \cdot z}{y \cdot 2} \]
      2. unpow266.9%

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

      \[\leadsto \frac{\color{blue}{x \cdot x} - z \cdot z}{y \cdot 2} \]
    10. Step-by-step derivation
      1. difference-of-squares71.4%

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

        \[\leadsto \color{blue}{\frac{x + z}{y} \cdot \frac{x - z}{2}} \]
    11. Applied egg-rr75.8%

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

    if 2.3499999999999999e-75 < y < 2e143

    1. Initial program 95.0%

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

    if 2e143 < y

    1. Initial program 7.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 7.7%

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y - \frac{\color{blue}{z \cdot z}}{y}\right) \]
      2. *-un-lft-identity74.2%

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y - z \cdot \color{blue}{\frac{1}{\frac{y}{z}}}\right) \]
      3. un-div-inv91.5%

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

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

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

Alternative 2: 77.8% accurate, 0.4× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ z_m = \left|z\right| \\ y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := 0.5 \cdot \left(y\_m - \frac{z\_m}{\frac{y\_m}{z\_m}}\right)\\ y\_s \cdot \begin{array}{l} \mathbf{if}\;x\_m \leq 62000000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x\_m \leq 3550000000000:\\ \;\;\;\;\frac{x\_m \cdot 0.5}{\frac{y\_m}{x\_m}}\\ \mathbf{elif}\;x\_m \leq 2.35 \cdot 10^{+60} \lor \neg \left(x\_m \leq 3.3 \cdot 10^{+153}\right) \land x\_m \leq 3.5 \cdot 10^{+162}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x\_m}{y\_m} \cdot \frac{x\_m}{2}\\ \end{array} \end{array} \end{array} \]
x_m = (fabs.f64 x)
z_m = (fabs.f64 z)
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x_m y_m z_m)
 :precision binary64
 (let* ((t_0 (* 0.5 (- y_m (/ z_m (/ y_m z_m))))))
   (*
    y_s
    (if (<= x_m 62000000.0)
      t_0
      (if (<= x_m 3550000000000.0)
        (/ (* x_m 0.5) (/ y_m x_m))
        (if (or (<= x_m 2.35e+60)
                (and (not (<= x_m 3.3e+153)) (<= x_m 3.5e+162)))
          t_0
          (* (/ x_m y_m) (/ x_m 2.0))))))))
x_m = fabs(x);
z_m = fabs(z);
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x_m, double y_m, double z_m) {
	double t_0 = 0.5 * (y_m - (z_m / (y_m / z_m)));
	double tmp;
	if (x_m <= 62000000.0) {
		tmp = t_0;
	} else if (x_m <= 3550000000000.0) {
		tmp = (x_m * 0.5) / (y_m / x_m);
	} else if ((x_m <= 2.35e+60) || (!(x_m <= 3.3e+153) && (x_m <= 3.5e+162))) {
		tmp = t_0;
	} else {
		tmp = (x_m / y_m) * (x_m / 2.0);
	}
	return y_s * tmp;
}
x_m = abs(x)
z_m = abs(z)
y_m = abs(y)
y_s = copysign(1.0d0, y)
real(8) function code(y_s, x_m, y_m, z_m)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 0.5d0 * (y_m - (z_m / (y_m / z_m)))
    if (x_m <= 62000000.0d0) then
        tmp = t_0
    else if (x_m <= 3550000000000.0d0) then
        tmp = (x_m * 0.5d0) / (y_m / x_m)
    else if ((x_m <= 2.35d+60) .or. (.not. (x_m <= 3.3d+153)) .and. (x_m <= 3.5d+162)) then
        tmp = t_0
    else
        tmp = (x_m / y_m) * (x_m / 2.0d0)
    end if
    code = y_s * tmp
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
y_m = Math.abs(y);
y_s = Math.copySign(1.0, y);
public static double code(double y_s, double x_m, double y_m, double z_m) {
	double t_0 = 0.5 * (y_m - (z_m / (y_m / z_m)));
	double tmp;
	if (x_m <= 62000000.0) {
		tmp = t_0;
	} else if (x_m <= 3550000000000.0) {
		tmp = (x_m * 0.5) / (y_m / x_m);
	} else if ((x_m <= 2.35e+60) || (!(x_m <= 3.3e+153) && (x_m <= 3.5e+162))) {
		tmp = t_0;
	} else {
		tmp = (x_m / y_m) * (x_m / 2.0);
	}
	return y_s * tmp;
}
x_m = math.fabs(x)
z_m = math.fabs(z)
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x_m, y_m, z_m):
	t_0 = 0.5 * (y_m - (z_m / (y_m / z_m)))
	tmp = 0
	if x_m <= 62000000.0:
		tmp = t_0
	elif x_m <= 3550000000000.0:
		tmp = (x_m * 0.5) / (y_m / x_m)
	elif (x_m <= 2.35e+60) or (not (x_m <= 3.3e+153) and (x_m <= 3.5e+162)):
		tmp = t_0
	else:
		tmp = (x_m / y_m) * (x_m / 2.0)
	return y_s * tmp
x_m = abs(x)
z_m = abs(z)
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x_m, y_m, z_m)
	t_0 = Float64(0.5 * Float64(y_m - Float64(z_m / Float64(y_m / z_m))))
	tmp = 0.0
	if (x_m <= 62000000.0)
		tmp = t_0;
	elseif (x_m <= 3550000000000.0)
		tmp = Float64(Float64(x_m * 0.5) / Float64(y_m / x_m));
	elseif ((x_m <= 2.35e+60) || (!(x_m <= 3.3e+153) && (x_m <= 3.5e+162)))
		tmp = t_0;
	else
		tmp = Float64(Float64(x_m / y_m) * Float64(x_m / 2.0));
	end
	return Float64(y_s * tmp)
end
x_m = abs(x);
z_m = abs(z);
y_m = abs(y);
y_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x_m, y_m, z_m)
	t_0 = 0.5 * (y_m - (z_m / (y_m / z_m)));
	tmp = 0.0;
	if (x_m <= 62000000.0)
		tmp = t_0;
	elseif (x_m <= 3550000000000.0)
		tmp = (x_m * 0.5) / (y_m / x_m);
	elseif ((x_m <= 2.35e+60) || (~((x_m <= 3.3e+153)) && (x_m <= 3.5e+162)))
		tmp = t_0;
	else
		tmp = (x_m / y_m) * (x_m / 2.0);
	end
	tmp_2 = y_s * tmp;
end
x_m = N[Abs[x], $MachinePrecision]
z_m = N[Abs[z], $MachinePrecision]
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$95$m_, y$95$m_, z$95$m_] := Block[{t$95$0 = N[(0.5 * N[(y$95$m - N[(z$95$m / N[(y$95$m / z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[x$95$m, 62000000.0], t$95$0, If[LessEqual[x$95$m, 3550000000000.0], N[(N[(x$95$m * 0.5), $MachinePrecision] / N[(y$95$m / x$95$m), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x$95$m, 2.35e+60], And[N[Not[LessEqual[x$95$m, 3.3e+153]], $MachinePrecision], LessEqual[x$95$m, 3.5e+162]]], t$95$0, N[(N[(x$95$m / y$95$m), $MachinePrecision] * N[(x$95$m / 2.0), $MachinePrecision]), $MachinePrecision]]]]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|
\\
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(y\_m - \frac{z\_m}{\frac{y\_m}{z\_m}}\right)\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 62000000:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x\_m \leq 3550000000000:\\
\;\;\;\;\frac{x\_m \cdot 0.5}{\frac{y\_m}{x\_m}}\\

\mathbf{elif}\;x\_m \leq 2.35 \cdot 10^{+60} \lor \neg \left(x\_m \leq 3.3 \cdot 10^{+153}\right) \land x\_m \leq 3.5 \cdot 10^{+162}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 6.2e7 or 3.55e12 < x < 2.3499999999999999e60 or 3.29999999999999994e153 < x < 3.50000000000000018e162

    1. Initial program 70.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 0 46.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.2e7 < x < 3.55e12

    1. Initial program 99.2%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{2 \cdot y}{{x}^{2}}}} \]
      3. *-commutative99.2%

        \[\leadsto \frac{1}{\frac{\color{blue}{y \cdot 2}}{{x}^{2}}} \]
      4. clear-num99.2%

        \[\leadsto \color{blue}{\frac{{x}^{2}}{y \cdot 2}} \]
      5. rem-cube-cbrt99.2%

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

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{{\left(\sqrt[3]{{x}^{2}}\right)}^{3}}}}{y} \cdot \frac{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}{2} \]
      9. rem-cube-cbrt100.0%

        \[\leadsto \frac{\sqrt{\color{blue}{{x}^{2}}}}{y} \cdot \frac{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}{2} \]
      10. unpow2100.0%

        \[\leadsto \frac{\sqrt{\color{blue}{x \cdot x}}}{y} \cdot \frac{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}{2} \]
      11. sqrt-prod100.0%

        \[\leadsto \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{y} \cdot \frac{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}{2} \]
      12. add-sqr-sqrt100.0%

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

        \[\leadsto \frac{x}{y} \cdot \frac{\color{blue}{\sqrt{{\left(\sqrt[3]{{x}^{2}}\right)}^{3}}}}{2} \]
      14. rem-cube-cbrt99.2%

        \[\leadsto \frac{x}{y} \cdot \frac{\sqrt{\color{blue}{{x}^{2}}}}{2} \]
      15. unpow299.2%

        \[\leadsto \frac{x}{y} \cdot \frac{\sqrt{\color{blue}{x \cdot x}}}{2} \]
      16. sqrt-prod99.2%

        \[\leadsto \frac{x}{y} \cdot \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{2} \]
      17. add-sqr-sqrt99.2%

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

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

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

        \[\leadsto \frac{x}{2} \cdot \color{blue}{\frac{1}{\frac{y}{x}}} \]
      3. un-div-inv100.0%

        \[\leadsto \color{blue}{\frac{\frac{x}{2}}{\frac{y}{x}}} \]
      4. div-inv100.0%

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

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

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

    if 2.3499999999999999e60 < x < 3.29999999999999994e153 or 3.50000000000000018e162 < x

    1. Initial program 60.0%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num59.9%

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

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

        \[\leadsto {\left(\frac{\color{blue}{2 \cdot y}}{\left(x \cdot x + y \cdot y\right) - z \cdot z}\right)}^{-1} \]
      4. *-un-lft-identity59.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{2 \cdot y}{{x}^{2}}}} \]
      3. *-commutative56.0%

        \[\leadsto \frac{1}{\frac{\color{blue}{y \cdot 2}}{{x}^{2}}} \]
      4. clear-num56.1%

        \[\leadsto \color{blue}{\frac{{x}^{2}}{y \cdot 2}} \]
      5. rem-cube-cbrt56.0%

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

        \[\leadsto \frac{\color{blue}{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}}{y \cdot 2} \]
      7. times-frac56.0%

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

        \[\leadsto \frac{\color{blue}{\sqrt{{\left(\sqrt[3]{{x}^{2}}\right)}^{3}}}}{y} \cdot \frac{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}{2} \]
      9. rem-cube-cbrt56.0%

        \[\leadsto \frac{\sqrt{\color{blue}{{x}^{2}}}}{y} \cdot \frac{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}{2} \]
      10. unpow256.0%

        \[\leadsto \frac{\sqrt{\color{blue}{x \cdot x}}}{y} \cdot \frac{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}{2} \]
      11. sqrt-prod56.0%

        \[\leadsto \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{y} \cdot \frac{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}{2} \]
      12. add-sqr-sqrt56.0%

        \[\leadsto \frac{\color{blue}{x}}{y} \cdot \frac{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}{2} \]
      13. sqrt-pow156.0%

        \[\leadsto \frac{x}{y} \cdot \frac{\color{blue}{\sqrt{{\left(\sqrt[3]{{x}^{2}}\right)}^{3}}}}{2} \]
      14. rem-cube-cbrt56.1%

        \[\leadsto \frac{x}{y} \cdot \frac{\sqrt{\color{blue}{{x}^{2}}}}{2} \]
      15. unpow256.1%

        \[\leadsto \frac{x}{y} \cdot \frac{\sqrt{\color{blue}{x \cdot x}}}{2} \]
      16. sqrt-prod60.1%

        \[\leadsto \frac{x}{y} \cdot \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{2} \]
      17. add-sqr-sqrt60.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 62000000:\\ \;\;\;\;0.5 \cdot \left(y - \frac{z}{\frac{y}{z}}\right)\\ \mathbf{elif}\;x \leq 3550000000000:\\ \;\;\;\;\frac{x \cdot 0.5}{\frac{y}{x}}\\ \mathbf{elif}\;x \leq 2.35 \cdot 10^{+60} \lor \neg \left(x \leq 3.3 \cdot 10^{+153}\right) \land x \leq 3.5 \cdot 10^{+162}:\\ \;\;\;\;0.5 \cdot \left(y - \frac{z}{\frac{y}{z}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 77.9% accurate, 0.4× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ z_m = \left|z\right| \\ y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := 0.5 \cdot \left(y\_m - \frac{z\_m}{\frac{y\_m}{z\_m}}\right)\\ y\_s \cdot \begin{array}{l} \mathbf{if}\;x\_m \leq 62000000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x\_m \leq 3550000000000:\\ \;\;\;\;\frac{x\_m \cdot 0.5}{\frac{y\_m}{x\_m}}\\ \mathbf{elif}\;x\_m \leq 1.65 \cdot 10^{+60}:\\ \;\;\;\;0.5 \cdot \left(y\_m - z\_m \cdot \frac{z\_m}{y\_m}\right)\\ \mathbf{elif}\;x\_m \leq 3.3 \cdot 10^{+153} \lor \neg \left(x\_m \leq 1.35 \cdot 10^{+160}\right):\\ \;\;\;\;\frac{x\_m}{y\_m} \cdot \frac{x\_m}{2}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \end{array} \]
x_m = (fabs.f64 x)
z_m = (fabs.f64 z)
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x_m y_m z_m)
 :precision binary64
 (let* ((t_0 (* 0.5 (- y_m (/ z_m (/ y_m z_m))))))
   (*
    y_s
    (if (<= x_m 62000000.0)
      t_0
      (if (<= x_m 3550000000000.0)
        (/ (* x_m 0.5) (/ y_m x_m))
        (if (<= x_m 1.65e+60)
          (* 0.5 (- y_m (* z_m (/ z_m y_m))))
          (if (or (<= x_m 3.3e+153) (not (<= x_m 1.35e+160)))
            (* (/ x_m y_m) (/ x_m 2.0))
            t_0)))))))
x_m = fabs(x);
z_m = fabs(z);
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x_m, double y_m, double z_m) {
	double t_0 = 0.5 * (y_m - (z_m / (y_m / z_m)));
	double tmp;
	if (x_m <= 62000000.0) {
		tmp = t_0;
	} else if (x_m <= 3550000000000.0) {
		tmp = (x_m * 0.5) / (y_m / x_m);
	} else if (x_m <= 1.65e+60) {
		tmp = 0.5 * (y_m - (z_m * (z_m / y_m)));
	} else if ((x_m <= 3.3e+153) || !(x_m <= 1.35e+160)) {
		tmp = (x_m / y_m) * (x_m / 2.0);
	} else {
		tmp = t_0;
	}
	return y_s * tmp;
}
x_m = abs(x)
z_m = abs(z)
y_m = abs(y)
y_s = copysign(1.0d0, y)
real(8) function code(y_s, x_m, y_m, z_m)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 0.5d0 * (y_m - (z_m / (y_m / z_m)))
    if (x_m <= 62000000.0d0) then
        tmp = t_0
    else if (x_m <= 3550000000000.0d0) then
        tmp = (x_m * 0.5d0) / (y_m / x_m)
    else if (x_m <= 1.65d+60) then
        tmp = 0.5d0 * (y_m - (z_m * (z_m / y_m)))
    else if ((x_m <= 3.3d+153) .or. (.not. (x_m <= 1.35d+160))) then
        tmp = (x_m / y_m) * (x_m / 2.0d0)
    else
        tmp = t_0
    end if
    code = y_s * tmp
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
y_m = Math.abs(y);
y_s = Math.copySign(1.0, y);
public static double code(double y_s, double x_m, double y_m, double z_m) {
	double t_0 = 0.5 * (y_m - (z_m / (y_m / z_m)));
	double tmp;
	if (x_m <= 62000000.0) {
		tmp = t_0;
	} else if (x_m <= 3550000000000.0) {
		tmp = (x_m * 0.5) / (y_m / x_m);
	} else if (x_m <= 1.65e+60) {
		tmp = 0.5 * (y_m - (z_m * (z_m / y_m)));
	} else if ((x_m <= 3.3e+153) || !(x_m <= 1.35e+160)) {
		tmp = (x_m / y_m) * (x_m / 2.0);
	} else {
		tmp = t_0;
	}
	return y_s * tmp;
}
x_m = math.fabs(x)
z_m = math.fabs(z)
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x_m, y_m, z_m):
	t_0 = 0.5 * (y_m - (z_m / (y_m / z_m)))
	tmp = 0
	if x_m <= 62000000.0:
		tmp = t_0
	elif x_m <= 3550000000000.0:
		tmp = (x_m * 0.5) / (y_m / x_m)
	elif x_m <= 1.65e+60:
		tmp = 0.5 * (y_m - (z_m * (z_m / y_m)))
	elif (x_m <= 3.3e+153) or not (x_m <= 1.35e+160):
		tmp = (x_m / y_m) * (x_m / 2.0)
	else:
		tmp = t_0
	return y_s * tmp
x_m = abs(x)
z_m = abs(z)
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x_m, y_m, z_m)
	t_0 = Float64(0.5 * Float64(y_m - Float64(z_m / Float64(y_m / z_m))))
	tmp = 0.0
	if (x_m <= 62000000.0)
		tmp = t_0;
	elseif (x_m <= 3550000000000.0)
		tmp = Float64(Float64(x_m * 0.5) / Float64(y_m / x_m));
	elseif (x_m <= 1.65e+60)
		tmp = Float64(0.5 * Float64(y_m - Float64(z_m * Float64(z_m / y_m))));
	elseif ((x_m <= 3.3e+153) || !(x_m <= 1.35e+160))
		tmp = Float64(Float64(x_m / y_m) * Float64(x_m / 2.0));
	else
		tmp = t_0;
	end
	return Float64(y_s * tmp)
end
x_m = abs(x);
z_m = abs(z);
y_m = abs(y);
y_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x_m, y_m, z_m)
	t_0 = 0.5 * (y_m - (z_m / (y_m / z_m)));
	tmp = 0.0;
	if (x_m <= 62000000.0)
		tmp = t_0;
	elseif (x_m <= 3550000000000.0)
		tmp = (x_m * 0.5) / (y_m / x_m);
	elseif (x_m <= 1.65e+60)
		tmp = 0.5 * (y_m - (z_m * (z_m / y_m)));
	elseif ((x_m <= 3.3e+153) || ~((x_m <= 1.35e+160)))
		tmp = (x_m / y_m) * (x_m / 2.0);
	else
		tmp = t_0;
	end
	tmp_2 = y_s * tmp;
end
x_m = N[Abs[x], $MachinePrecision]
z_m = N[Abs[z], $MachinePrecision]
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$95$m_, y$95$m_, z$95$m_] := Block[{t$95$0 = N[(0.5 * N[(y$95$m - N[(z$95$m / N[(y$95$m / z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[x$95$m, 62000000.0], t$95$0, If[LessEqual[x$95$m, 3550000000000.0], N[(N[(x$95$m * 0.5), $MachinePrecision] / N[(y$95$m / x$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$95$m, 1.65e+60], N[(0.5 * N[(y$95$m - N[(z$95$m * N[(z$95$m / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x$95$m, 3.3e+153], N[Not[LessEqual[x$95$m, 1.35e+160]], $MachinePrecision]], N[(N[(x$95$m / y$95$m), $MachinePrecision] * N[(x$95$m / 2.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|
\\
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(y\_m - \frac{z\_m}{\frac{y\_m}{z\_m}}\right)\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 62000000:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x\_m \leq 3550000000000:\\
\;\;\;\;\frac{x\_m \cdot 0.5}{\frac{y\_m}{x\_m}}\\

\mathbf{elif}\;x\_m \leq 1.65 \cdot 10^{+60}:\\
\;\;\;\;0.5 \cdot \left(y\_m - z\_m \cdot \frac{z\_m}{y\_m}\right)\\

\mathbf{elif}\;x\_m \leq 3.3 \cdot 10^{+153} \lor \neg \left(x\_m \leq 1.35 \cdot 10^{+160}\right):\\
\;\;\;\;\frac{x\_m}{y\_m} \cdot \frac{x\_m}{2}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 6.2e7 or 3.29999999999999994e153 < x < 1.35e160

    1. Initial program 69.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 0 46.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.2e7 < x < 3.55e12

    1. Initial program 99.2%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{2 \cdot y}{{x}^{2}}}} \]
      3. *-commutative99.2%

        \[\leadsto \frac{1}{\frac{\color{blue}{y \cdot 2}}{{x}^{2}}} \]
      4. clear-num99.2%

        \[\leadsto \color{blue}{\frac{{x}^{2}}{y \cdot 2}} \]
      5. rem-cube-cbrt99.2%

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

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{{\left(\sqrt[3]{{x}^{2}}\right)}^{3}}}}{y} \cdot \frac{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}{2} \]
      9. rem-cube-cbrt100.0%

        \[\leadsto \frac{\sqrt{\color{blue}{{x}^{2}}}}{y} \cdot \frac{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}{2} \]
      10. unpow2100.0%

        \[\leadsto \frac{\sqrt{\color{blue}{x \cdot x}}}{y} \cdot \frac{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}{2} \]
      11. sqrt-prod100.0%

        \[\leadsto \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{y} \cdot \frac{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}{2} \]
      12. add-sqr-sqrt100.0%

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

        \[\leadsto \frac{x}{y} \cdot \frac{\color{blue}{\sqrt{{\left(\sqrt[3]{{x}^{2}}\right)}^{3}}}}{2} \]
      14. rem-cube-cbrt99.2%

        \[\leadsto \frac{x}{y} \cdot \frac{\sqrt{\color{blue}{{x}^{2}}}}{2} \]
      15. unpow299.2%

        \[\leadsto \frac{x}{y} \cdot \frac{\sqrt{\color{blue}{x \cdot x}}}{2} \]
      16. sqrt-prod99.2%

        \[\leadsto \frac{x}{y} \cdot \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{2} \]
      17. add-sqr-sqrt99.2%

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

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

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

        \[\leadsto \frac{x}{2} \cdot \color{blue}{\frac{1}{\frac{y}{x}}} \]
      3. un-div-inv100.0%

        \[\leadsto \color{blue}{\frac{\frac{x}{2}}{\frac{y}{x}}} \]
      4. div-inv100.0%

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

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

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

    if 3.55e12 < x < 1.6499999999999999e60

    1. Initial program 90.5%

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y - \frac{\color{blue}{z \cdot z}}{y}\right) \]
      2. *-un-lft-identity50.9%

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

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

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

    if 1.6499999999999999e60 < x < 3.29999999999999994e153 or 1.35e160 < x

    1. Initial program 60.0%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num59.9%

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

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

        \[\leadsto {\left(\frac{\color{blue}{2 \cdot y}}{\left(x \cdot x + y \cdot y\right) - z \cdot z}\right)}^{-1} \]
      4. *-un-lft-identity59.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{2 \cdot y}{{x}^{2}}}} \]
      3. *-commutative56.0%

        \[\leadsto \frac{1}{\frac{\color{blue}{y \cdot 2}}{{x}^{2}}} \]
      4. clear-num56.1%

        \[\leadsto \color{blue}{\frac{{x}^{2}}{y \cdot 2}} \]
      5. rem-cube-cbrt56.0%

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

        \[\leadsto \frac{\color{blue}{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}}{y \cdot 2} \]
      7. times-frac56.0%

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

        \[\leadsto \frac{\color{blue}{\sqrt{{\left(\sqrt[3]{{x}^{2}}\right)}^{3}}}}{y} \cdot \frac{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}{2} \]
      9. rem-cube-cbrt56.0%

        \[\leadsto \frac{\sqrt{\color{blue}{{x}^{2}}}}{y} \cdot \frac{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}{2} \]
      10. unpow256.0%

        \[\leadsto \frac{\sqrt{\color{blue}{x \cdot x}}}{y} \cdot \frac{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}{2} \]
      11. sqrt-prod56.0%

        \[\leadsto \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{y} \cdot \frac{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}{2} \]
      12. add-sqr-sqrt56.0%

        \[\leadsto \frac{\color{blue}{x}}{y} \cdot \frac{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}{2} \]
      13. sqrt-pow156.0%

        \[\leadsto \frac{x}{y} \cdot \frac{\color{blue}{\sqrt{{\left(\sqrt[3]{{x}^{2}}\right)}^{3}}}}{2} \]
      14. rem-cube-cbrt56.1%

        \[\leadsto \frac{x}{y} \cdot \frac{\sqrt{\color{blue}{{x}^{2}}}}{2} \]
      15. unpow256.1%

        \[\leadsto \frac{x}{y} \cdot \frac{\sqrt{\color{blue}{x \cdot x}}}{2} \]
      16. sqrt-prod60.1%

        \[\leadsto \frac{x}{y} \cdot \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{2} \]
      17. add-sqr-sqrt60.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 62000000:\\ \;\;\;\;0.5 \cdot \left(y - \frac{z}{\frac{y}{z}}\right)\\ \mathbf{elif}\;x \leq 3550000000000:\\ \;\;\;\;\frac{x \cdot 0.5}{\frac{y}{x}}\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{+60}:\\ \;\;\;\;0.5 \cdot \left(y - z \cdot \frac{z}{y}\right)\\ \mathbf{elif}\;x \leq 3.3 \cdot 10^{+153} \lor \neg \left(x \leq 1.35 \cdot 10^{+160}\right):\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(y - \frac{z}{\frac{y}{z}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 50.9% accurate, 0.5× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ z_m = \left|z\right| \\ y_m = \left|y\right| \\ y_s = \mathsf{copysign}\left(1, y\right) \\ \begin{array}{l} t_0 := \frac{x\_m}{y\_m} \cdot \frac{x\_m}{2}\\ y\_s \cdot \begin{array}{l} \mathbf{if}\;z\_m \leq 1.25 \cdot 10^{-216}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z\_m \leq 1.02 \cdot 10^{-156}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{elif}\;z\_m \leq 3.55 \cdot 10^{-107}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z\_m \leq 9.2 \cdot 10^{-63}:\\ \;\;\;\;y\_m \cdot 0.5\\ \mathbf{elif}\;z\_m \leq 9.6 \cdot 10^{+140}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;z\_m \cdot \left(z\_m \cdot \frac{-0.5}{y\_m}\right)\\ \end{array} \end{array} \end{array} \]
x_m = (fabs.f64 x)
z_m = (fabs.f64 z)
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x_m y_m z_m)
 :precision binary64
 (let* ((t_0 (* (/ x_m y_m) (/ x_m 2.0))))
   (*
    y_s
    (if (<= z_m 1.25e-216)
      t_0
      (if (<= z_m 1.02e-156)
        (* y_m 0.5)
        (if (<= z_m 3.55e-107)
          t_0
          (if (<= z_m 9.2e-63)
            (* y_m 0.5)
            (if (<= z_m 9.6e+140) t_0 (* z_m (* z_m (/ -0.5 y_m)))))))))))
x_m = fabs(x);
z_m = fabs(z);
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x_m, double y_m, double z_m) {
	double t_0 = (x_m / y_m) * (x_m / 2.0);
	double tmp;
	if (z_m <= 1.25e-216) {
		tmp = t_0;
	} else if (z_m <= 1.02e-156) {
		tmp = y_m * 0.5;
	} else if (z_m <= 3.55e-107) {
		tmp = t_0;
	} else if (z_m <= 9.2e-63) {
		tmp = y_m * 0.5;
	} else if (z_m <= 9.6e+140) {
		tmp = t_0;
	} else {
		tmp = z_m * (z_m * (-0.5 / y_m));
	}
	return y_s * tmp;
}
x_m = abs(x)
z_m = abs(z)
y_m = abs(y)
y_s = copysign(1.0d0, y)
real(8) function code(y_s, x_m, y_m, z_m)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (x_m / y_m) * (x_m / 2.0d0)
    if (z_m <= 1.25d-216) then
        tmp = t_0
    else if (z_m <= 1.02d-156) then
        tmp = y_m * 0.5d0
    else if (z_m <= 3.55d-107) then
        tmp = t_0
    else if (z_m <= 9.2d-63) then
        tmp = y_m * 0.5d0
    else if (z_m <= 9.6d+140) then
        tmp = t_0
    else
        tmp = z_m * (z_m * ((-0.5d0) / y_m))
    end if
    code = y_s * tmp
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
y_m = Math.abs(y);
y_s = Math.copySign(1.0, y);
public static double code(double y_s, double x_m, double y_m, double z_m) {
	double t_0 = (x_m / y_m) * (x_m / 2.0);
	double tmp;
	if (z_m <= 1.25e-216) {
		tmp = t_0;
	} else if (z_m <= 1.02e-156) {
		tmp = y_m * 0.5;
	} else if (z_m <= 3.55e-107) {
		tmp = t_0;
	} else if (z_m <= 9.2e-63) {
		tmp = y_m * 0.5;
	} else if (z_m <= 9.6e+140) {
		tmp = t_0;
	} else {
		tmp = z_m * (z_m * (-0.5 / y_m));
	}
	return y_s * tmp;
}
x_m = math.fabs(x)
z_m = math.fabs(z)
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x_m, y_m, z_m):
	t_0 = (x_m / y_m) * (x_m / 2.0)
	tmp = 0
	if z_m <= 1.25e-216:
		tmp = t_0
	elif z_m <= 1.02e-156:
		tmp = y_m * 0.5
	elif z_m <= 3.55e-107:
		tmp = t_0
	elif z_m <= 9.2e-63:
		tmp = y_m * 0.5
	elif z_m <= 9.6e+140:
		tmp = t_0
	else:
		tmp = z_m * (z_m * (-0.5 / y_m))
	return y_s * tmp
x_m = abs(x)
z_m = abs(z)
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x_m, y_m, z_m)
	t_0 = Float64(Float64(x_m / y_m) * Float64(x_m / 2.0))
	tmp = 0.0
	if (z_m <= 1.25e-216)
		tmp = t_0;
	elseif (z_m <= 1.02e-156)
		tmp = Float64(y_m * 0.5);
	elseif (z_m <= 3.55e-107)
		tmp = t_0;
	elseif (z_m <= 9.2e-63)
		tmp = Float64(y_m * 0.5);
	elseif (z_m <= 9.6e+140)
		tmp = t_0;
	else
		tmp = Float64(z_m * Float64(z_m * Float64(-0.5 / y_m)));
	end
	return Float64(y_s * tmp)
end
x_m = abs(x);
z_m = abs(z);
y_m = abs(y);
y_s = sign(y) * abs(1.0);
function tmp_2 = code(y_s, x_m, y_m, z_m)
	t_0 = (x_m / y_m) * (x_m / 2.0);
	tmp = 0.0;
	if (z_m <= 1.25e-216)
		tmp = t_0;
	elseif (z_m <= 1.02e-156)
		tmp = y_m * 0.5;
	elseif (z_m <= 3.55e-107)
		tmp = t_0;
	elseif (z_m <= 9.2e-63)
		tmp = y_m * 0.5;
	elseif (z_m <= 9.6e+140)
		tmp = t_0;
	else
		tmp = z_m * (z_m * (-0.5 / y_m));
	end
	tmp_2 = y_s * tmp;
end
x_m = N[Abs[x], $MachinePrecision]
z_m = N[Abs[z], $MachinePrecision]
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$95$m_, y$95$m_, z$95$m_] := Block[{t$95$0 = N[(N[(x$95$m / y$95$m), $MachinePrecision] * N[(x$95$m / 2.0), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[z$95$m, 1.25e-216], t$95$0, If[LessEqual[z$95$m, 1.02e-156], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z$95$m, 3.55e-107], t$95$0, If[LessEqual[z$95$m, 9.2e-63], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z$95$m, 9.6e+140], t$95$0, N[(z$95$m * N[(z$95$m * N[(-0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|
\\
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)

\\
\begin{array}{l}
t_0 := \frac{x\_m}{y\_m} \cdot \frac{x\_m}{2}\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 1.25 \cdot 10^{-216}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z\_m \leq 1.02 \cdot 10^{-156}:\\
\;\;\;\;y\_m \cdot 0.5\\

\mathbf{elif}\;z\_m \leq 3.55 \cdot 10^{-107}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z\_m \leq 9.2 \cdot 10^{-63}:\\
\;\;\;\;y\_m \cdot 0.5\\

\mathbf{elif}\;z\_m \leq 9.6 \cdot 10^{+140}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 1.25000000000000005e-216 or 1.02e-156 < z < 3.5499999999999998e-107 or 9.2e-63 < z < 9.5999999999999999e140

    1. Initial program 72.1%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num72.0%

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

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

        \[\leadsto {\left(\frac{\color{blue}{2 \cdot y}}{\left(x \cdot x + y \cdot y\right) - z \cdot z}\right)}^{-1} \]
      4. *-un-lft-identity72.0%

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

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

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

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

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

        \[\leadsto {\left(2 \cdot \frac{y}{{\color{blue}{\left(\mathsf{hypot}\left(x, y\right)\right)}}^{2} - z \cdot z}\right)}^{-1} \]
      10. pow272.0%

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{2 \cdot y}{{x}^{2}}}} \]
      3. *-commutative38.0%

        \[\leadsto \frac{1}{\frac{\color{blue}{y \cdot 2}}{{x}^{2}}} \]
      4. clear-num38.0%

        \[\leadsto \color{blue}{\frac{{x}^{2}}{y \cdot 2}} \]
      5. rem-cube-cbrt37.9%

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

        \[\leadsto \frac{\color{blue}{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}}{y \cdot 2} \]
      7. times-frac37.9%

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

        \[\leadsto \frac{\color{blue}{\sqrt{{\left(\sqrt[3]{{x}^{2}}\right)}^{3}}}}{y} \cdot \frac{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}{2} \]
      9. rem-cube-cbrt37.9%

        \[\leadsto \frac{\sqrt{\color{blue}{{x}^{2}}}}{y} \cdot \frac{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}{2} \]
      10. unpow237.9%

        \[\leadsto \frac{\sqrt{\color{blue}{x \cdot x}}}{y} \cdot \frac{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}{2} \]
      11. sqrt-prod16.7%

        \[\leadsto \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{y} \cdot \frac{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}{2} \]
      12. add-sqr-sqrt20.0%

        \[\leadsto \frac{\color{blue}{x}}{y} \cdot \frac{{\left(\sqrt[3]{{x}^{2}}\right)}^{\left(\frac{3}{2}\right)}}{2} \]
      13. sqrt-pow120.0%

        \[\leadsto \frac{x}{y} \cdot \frac{\color{blue}{\sqrt{{\left(\sqrt[3]{{x}^{2}}\right)}^{3}}}}{2} \]
      14. rem-cube-cbrt20.0%

        \[\leadsto \frac{x}{y} \cdot \frac{\sqrt{\color{blue}{{x}^{2}}}}{2} \]
      15. unpow220.0%

        \[\leadsto \frac{x}{y} \cdot \frac{\sqrt{\color{blue}{x \cdot x}}}{2} \]
      16. sqrt-prod18.0%

        \[\leadsto \frac{x}{y} \cdot \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{2} \]
      17. add-sqr-sqrt40.7%

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

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{2}} \]

    if 1.25000000000000005e-216 < z < 1.02e-156 or 3.5499999999999998e-107 < z < 9.2e-63

    1. Initial program 51.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 65.7%

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

    if 9.5999999999999999e140 < z

    1. Initial program 61.4%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 1.25 \cdot 10^{-216}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \mathbf{elif}\;z \leq 1.02 \cdot 10^{-156}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;z \leq 3.55 \cdot 10^{-107}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \mathbf{elif}\;z \leq 9.2 \cdot 10^{-63}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;z \leq 9.6 \cdot 10^{+140}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 85.2% accurate, 0.9× speedup?

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

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


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

    1. Initial program 77.3%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-cube-cbrt77.0%

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

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

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

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

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

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

      \[\leadsto \frac{{\color{blue}{\left({\left({x}^{2}\right)}^{0.3333333333333333}\right)}}^{3} - z \cdot z}{y \cdot 2} \]
    6. Step-by-step derivation
      1. unpow1/368.3%

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

      \[\leadsto \frac{{\color{blue}{\left(\sqrt[3]{{x}^{2}}\right)}}^{3} - z \cdot z}{y \cdot 2} \]
    8. Step-by-step derivation
      1. rem-cube-cbrt68.4%

        \[\leadsto \frac{\color{blue}{{x}^{2}} - z \cdot z}{y \cdot 2} \]
      2. unpow268.4%

        \[\leadsto \frac{\color{blue}{x \cdot x} - z \cdot z}{y \cdot 2} \]
    9. Applied egg-rr68.4%

      \[\leadsto \frac{\color{blue}{x \cdot x} - z \cdot z}{y \cdot 2} \]
    10. Step-by-step derivation
      1. difference-of-squares72.5%

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

        \[\leadsto \color{blue}{\frac{x + z}{y} \cdot \frac{x - z}{2}} \]
    11. Applied egg-rr76.5%

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

    if 1.52e29 < y

    1. Initial program 36.8%

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y - \frac{\color{blue}{z \cdot z}}{y}\right) \]
      2. *-un-lft-identity72.2%

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

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

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

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

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

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

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

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

Alternative 6: 51.4% accurate, 1.2× speedup?

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

\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 3.5 \cdot 10^{+115}:\\
\;\;\;\;y\_m \cdot 0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 3.50000000000000005e115

    1. Initial program 70.2%

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

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

    if 3.50000000000000005e115 < z

    1. Initial program 59.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 73.3%

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

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

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

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

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

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

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

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

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

Alternative 7: 33.7% accurate, 5.0× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ z_m = \left|z\right| \\ 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} \]
x_m = (fabs.f64 x)
z_m = (fabs.f64 z)
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x_m y_m z_m) :precision binary64 (* y_s (* y_m 0.5)))
x_m = fabs(x);
z_m = fabs(z);
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x_m, double y_m, double z_m) {
	return y_s * (y_m * 0.5);
}
x_m = abs(x)
z_m = abs(z)
y_m = abs(y)
y_s = copysign(1.0d0, y)
real(8) function code(y_s, x_m, y_m, z_m)
    real(8), intent (in) :: y_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z_m
    code = y_s * (y_m * 0.5d0)
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
y_m = Math.abs(y);
y_s = Math.copySign(1.0, y);
public static double code(double y_s, double x_m, double y_m, double z_m) {
	return y_s * (y_m * 0.5);
}
x_m = math.fabs(x)
z_m = math.fabs(z)
y_m = math.fabs(y)
y_s = math.copysign(1.0, y)
def code(y_s, x_m, y_m, z_m):
	return y_s * (y_m * 0.5)
x_m = abs(x)
z_m = abs(z)
y_m = abs(y)
y_s = copysign(1.0, y)
function code(y_s, x_m, y_m, z_m)
	return Float64(y_s * Float64(y_m * 0.5))
end
x_m = abs(x);
z_m = abs(z);
y_m = abs(y);
y_s = sign(y) * abs(1.0);
function tmp = code(y_s, x_m, y_m, z_m)
	tmp = y_s * (y_m * 0.5);
end
x_m = N[Abs[x], $MachinePrecision]
z_m = N[Abs[z], $MachinePrecision]
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$95$m_, y$95$m_, z$95$m_] := N[(y$95$s * N[(y$95$m * 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|
\\
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 68.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 34.6%

    \[\leadsto \color{blue}{0.5 \cdot y} \]
  4. Final simplification34.6%

    \[\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 2024029 
(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)))