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

Percentage Accurate: 69.6% → 99.9%
Time: 8.4s
Alternatives: 11
Speedup: 1.2×

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 11 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.6% 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: 99.9% accurate, 1.2× speedup?

\[\begin{array}{l} z = |z|\\ \\ \left(\left(x + z\right) \cdot \frac{z - x}{y} - y\right) \cdot -0.5 \end{array} \]
NOTE: z should be positive before calling this function
(FPCore (x y z) :precision binary64 (* (- (* (+ x z) (/ (- z x) y)) y) -0.5))
z = abs(z);
double code(double x, double y, double z) {
	return (((x + z) * ((z - x) / y)) - y) * -0.5;
}
NOTE: z should be positive before calling this function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (((x + z) * ((z - x) / y)) - y) * (-0.5d0)
end function
z = Math.abs(z);
public static double code(double x, double y, double z) {
	return (((x + z) * ((z - x) / y)) - y) * -0.5;
}
z = abs(z)
def code(x, y, z):
	return (((x + z) * ((z - x) / y)) - y) * -0.5
z = abs(z)
function code(x, y, z)
	return Float64(Float64(Float64(Float64(x + z) * Float64(Float64(z - x) / y)) - y) * -0.5)
end
z = abs(z)
function tmp = code(x, y, z)
	tmp = (((x + z) * ((z - x) / y)) - y) * -0.5;
end
NOTE: z should be positive before calling this function
code[x_, y_, z_] := N[(N[(N[(N[(x + z), $MachinePrecision] * N[(N[(z - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision] * -0.5), $MachinePrecision]
\begin{array}{l}
z = |z|\\
\\
\left(\left(x + z\right) \cdot \frac{z - x}{y} - y\right) \cdot -0.5
\end{array}
Derivation
  1. Initial program 70.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\color{blue}{\left(x + z\right) \cdot \frac{z - x}{y}} - \frac{y \cdot y}{y}\right) \cdot \frac{-1}{2} \]
    14. associate-/l*99.9%

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

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

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

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

    \[\leadsto \color{blue}{\left(\left(x + z\right) \cdot \frac{z - x}{y} - y\right) \cdot -0.5} \]
  4. Final simplification99.9%

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

Alternative 2: 84.3% accurate, 0.7× speedup?

\[\begin{array}{l} z = |z|\\ \\ \begin{array}{l} \mathbf{if}\;x \cdot x \leq 10^{-68}:\\ \;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y} - y\right)\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+101} \lor \neg \left(x \cdot x \leq 2 \cdot 10^{+161}\right):\\ \;\;\;\;-0.5 \cdot \left(\frac{-x}{\frac{y}{x}} - y\right)\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\ \end{array} \end{array} \]
NOTE: z should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (<= (* x x) 1e-68)
   (* -0.5 (- (* z (/ z y)) y))
   (if (or (<= (* x x) 2e+101) (not (<= (* x x) 2e+161)))
     (* -0.5 (- (/ (- x) (/ y x)) y))
     (* -0.5 (- (/ z (/ y z)) y)))))
z = abs(z);
double code(double x, double y, double z) {
	double tmp;
	if ((x * x) <= 1e-68) {
		tmp = -0.5 * ((z * (z / y)) - y);
	} else if (((x * x) <= 2e+101) || !((x * x) <= 2e+161)) {
		tmp = -0.5 * ((-x / (y / x)) - y);
	} else {
		tmp = -0.5 * ((z / (y / z)) - y);
	}
	return tmp;
}
NOTE: z should be positive before calling this function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((x * x) <= 1d-68) then
        tmp = (-0.5d0) * ((z * (z / y)) - y)
    else if (((x * x) <= 2d+101) .or. (.not. ((x * x) <= 2d+161))) then
        tmp = (-0.5d0) * ((-x / (y / x)) - y)
    else
        tmp = (-0.5d0) * ((z / (y / z)) - y)
    end if
    code = tmp
end function
z = Math.abs(z);
public static double code(double x, double y, double z) {
	double tmp;
	if ((x * x) <= 1e-68) {
		tmp = -0.5 * ((z * (z / y)) - y);
	} else if (((x * x) <= 2e+101) || !((x * x) <= 2e+161)) {
		tmp = -0.5 * ((-x / (y / x)) - y);
	} else {
		tmp = -0.5 * ((z / (y / z)) - y);
	}
	return tmp;
}
z = abs(z)
def code(x, y, z):
	tmp = 0
	if (x * x) <= 1e-68:
		tmp = -0.5 * ((z * (z / y)) - y)
	elif ((x * x) <= 2e+101) or not ((x * x) <= 2e+161):
		tmp = -0.5 * ((-x / (y / x)) - y)
	else:
		tmp = -0.5 * ((z / (y / z)) - y)
	return tmp
z = abs(z)
function code(x, y, z)
	tmp = 0.0
	if (Float64(x * x) <= 1e-68)
		tmp = Float64(-0.5 * Float64(Float64(z * Float64(z / y)) - y));
	elseif ((Float64(x * x) <= 2e+101) || !(Float64(x * x) <= 2e+161))
		tmp = Float64(-0.5 * Float64(Float64(Float64(-x) / Float64(y / x)) - y));
	else
		tmp = Float64(-0.5 * Float64(Float64(z / Float64(y / z)) - y));
	end
	return tmp
end
z = abs(z)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x * x) <= 1e-68)
		tmp = -0.5 * ((z * (z / y)) - y);
	elseif (((x * x) <= 2e+101) || ~(((x * x) <= 2e+161)))
		tmp = -0.5 * ((-x / (y / x)) - y);
	else
		tmp = -0.5 * ((z / (y / z)) - y);
	end
	tmp_2 = tmp;
end
NOTE: z should be positive before calling this function
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 1e-68], N[(-0.5 * N[(N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[N[(x * x), $MachinePrecision], 2e+101], N[Not[LessEqual[N[(x * x), $MachinePrecision], 2e+161]], $MachinePrecision]], N[(-0.5 * N[(N[((-x) / N[(y / x), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 10^{-68}:\\
\;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y} - y\right)\\

\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+101} \lor \neg \left(x \cdot x \leq 2 \cdot 10^{+161}\right):\\
\;\;\;\;-0.5 \cdot \left(\frac{-x}{\frac{y}{x}} - y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x x) < 1.00000000000000007e-68

    1. Initial program 70.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{\color{blue}{\left(x + z\right)} \cdot \left(z - x\right)}{y} - \frac{y \cdot y}{y}\right) \cdot \frac{-1}{2} \]
      13. associate-*l/75.6%

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

        \[\leadsto \left(\color{blue}{\left(z - x\right) \cdot \frac{x + z}{y}} - \frac{y \cdot y}{y}\right) \cdot \frac{-1}{2} \]
      15. associate-/l*99.9%

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

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

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

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

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

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

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

      \[\leadsto \left(\color{blue}{\frac{z - x}{\frac{y}{x + z}}} - y\right) \cdot -0.5 \]
    6. Taylor expanded in z around inf 82.7%

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

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

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

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

    if 1.00000000000000007e-68 < (*.f64 x x) < 2e101 or 2.0000000000000001e161 < (*.f64 x x)

    1. Initial program 70.2%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{\color{blue}{\left(x + z\right)} \cdot \left(z - x\right)}{y} - \frac{y \cdot y}{y}\right) \cdot \frac{-1}{2} \]
      13. associate-*l/81.8%

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

        \[\leadsto \left(\color{blue}{\left(z - x\right) \cdot \frac{x + z}{y}} - \frac{y \cdot y}{y}\right) \cdot \frac{-1}{2} \]
      15. associate-/l*99.9%

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

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

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

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

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

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

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

      \[\leadsto \left(\color{blue}{\frac{z - x}{\frac{y}{x + z}}} - y\right) \cdot -0.5 \]
    6. Taylor expanded in z around 0 75.6%

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

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

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

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

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

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

    if 2e101 < (*.f64 x x) < 2.0000000000000001e161

    1. Initial program 67.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{\color{blue}{\left(x + z\right)} \cdot \left(z - x\right)}{y} - \frac{y \cdot y}{y}\right) \cdot \frac{-1}{2} \]
      13. associate-*l/67.9%

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

        \[\leadsto \left(\color{blue}{\left(z - x\right) \cdot \frac{x + z}{y}} - \frac{y \cdot y}{y}\right) \cdot \frac{-1}{2} \]
      15. associate-/l*99.6%

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

        \[\leadsto \left(\left(z - x\right) \cdot \frac{x + z}{y} - \frac{y}{\color{blue}{1}}\right) \cdot \frac{-1}{2} \]
      17. /-rgt-identity99.6%

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

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

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

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

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

      \[\leadsto \left(\color{blue}{\frac{z - x}{\frac{y}{x + z}}} - y\right) \cdot -0.5 \]
    6. Step-by-step derivation
      1. *-un-lft-identity99.7%

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

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

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

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

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

      \[\leadsto \left(\frac{z - x}{\color{blue}{\frac{1}{\sqrt{z + x}} \cdot \frac{y}{\sqrt{z + x}}}} - y\right) \cdot -0.5 \]
    8. Step-by-step derivation
      1. associate-*l/49.8%

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

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

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

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

      \[\leadsto \left(\frac{z - x}{\color{blue}{\frac{\frac{y}{\sqrt{x + z}}}{\sqrt{x + z}}}} - y\right) \cdot -0.5 \]
    10. Taylor expanded in z around inf 68.3%

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

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

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

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

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

Alternative 3: 84.3% accurate, 0.7× speedup?

\[\begin{array}{l} z = |z|\\ \\ \begin{array}{l} \mathbf{if}\;x \cdot x \leq 10^{-68}:\\ \;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y} - y\right)\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+101}:\\ \;\;\;\;-0.5 \cdot \left(\frac{-x \cdot x}{y} - y\right)\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+161}:\\ \;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \left(\frac{-x}{\frac{y}{x}} - y\right)\\ \end{array} \end{array} \]
NOTE: z should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (<= (* x x) 1e-68)
   (* -0.5 (- (* z (/ z y)) y))
   (if (<= (* x x) 2e+101)
     (* -0.5 (- (/ (- (* x x)) y) y))
     (if (<= (* x x) 2e+161)
       (* -0.5 (- (/ z (/ y z)) y))
       (* -0.5 (- (/ (- x) (/ y x)) y))))))
z = abs(z);
double code(double x, double y, double z) {
	double tmp;
	if ((x * x) <= 1e-68) {
		tmp = -0.5 * ((z * (z / y)) - y);
	} else if ((x * x) <= 2e+101) {
		tmp = -0.5 * ((-(x * x) / y) - y);
	} else if ((x * x) <= 2e+161) {
		tmp = -0.5 * ((z / (y / z)) - y);
	} else {
		tmp = -0.5 * ((-x / (y / x)) - y);
	}
	return tmp;
}
NOTE: z should be positive before calling this function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((x * x) <= 1d-68) then
        tmp = (-0.5d0) * ((z * (z / y)) - y)
    else if ((x * x) <= 2d+101) then
        tmp = (-0.5d0) * ((-(x * x) / y) - y)
    else if ((x * x) <= 2d+161) then
        tmp = (-0.5d0) * ((z / (y / z)) - y)
    else
        tmp = (-0.5d0) * ((-x / (y / x)) - y)
    end if
    code = tmp
end function
z = Math.abs(z);
public static double code(double x, double y, double z) {
	double tmp;
	if ((x * x) <= 1e-68) {
		tmp = -0.5 * ((z * (z / y)) - y);
	} else if ((x * x) <= 2e+101) {
		tmp = -0.5 * ((-(x * x) / y) - y);
	} else if ((x * x) <= 2e+161) {
		tmp = -0.5 * ((z / (y / z)) - y);
	} else {
		tmp = -0.5 * ((-x / (y / x)) - y);
	}
	return tmp;
}
z = abs(z)
def code(x, y, z):
	tmp = 0
	if (x * x) <= 1e-68:
		tmp = -0.5 * ((z * (z / y)) - y)
	elif (x * x) <= 2e+101:
		tmp = -0.5 * ((-(x * x) / y) - y)
	elif (x * x) <= 2e+161:
		tmp = -0.5 * ((z / (y / z)) - y)
	else:
		tmp = -0.5 * ((-x / (y / x)) - y)
	return tmp
z = abs(z)
function code(x, y, z)
	tmp = 0.0
	if (Float64(x * x) <= 1e-68)
		tmp = Float64(-0.5 * Float64(Float64(z * Float64(z / y)) - y));
	elseif (Float64(x * x) <= 2e+101)
		tmp = Float64(-0.5 * Float64(Float64(Float64(-Float64(x * x)) / y) - y));
	elseif (Float64(x * x) <= 2e+161)
		tmp = Float64(-0.5 * Float64(Float64(z / Float64(y / z)) - y));
	else
		tmp = Float64(-0.5 * Float64(Float64(Float64(-x) / Float64(y / x)) - y));
	end
	return tmp
end
z = abs(z)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x * x) <= 1e-68)
		tmp = -0.5 * ((z * (z / y)) - y);
	elseif ((x * x) <= 2e+101)
		tmp = -0.5 * ((-(x * x) / y) - y);
	elseif ((x * x) <= 2e+161)
		tmp = -0.5 * ((z / (y / z)) - y);
	else
		tmp = -0.5 * ((-x / (y / x)) - y);
	end
	tmp_2 = tmp;
end
NOTE: z should be positive before calling this function
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 1e-68], N[(-0.5 * N[(N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 2e+101], N[(-0.5 * N[(N[((-N[(x * x), $MachinePrecision]) / y), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 2e+161], N[(-0.5 * N[(N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[((-x) / N[(y / x), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 10^{-68}:\\
\;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y} - y\right)\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 x x) < 1.00000000000000007e-68

    1. Initial program 70.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{\color{blue}{\left(x + z\right)} \cdot \left(z - x\right)}{y} - \frac{y \cdot y}{y}\right) \cdot \frac{-1}{2} \]
      13. associate-*l/75.6%

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

        \[\leadsto \left(\color{blue}{\left(z - x\right) \cdot \frac{x + z}{y}} - \frac{y \cdot y}{y}\right) \cdot \frac{-1}{2} \]
      15. associate-/l*99.9%

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

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

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

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

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

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

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

      \[\leadsto \left(\color{blue}{\frac{z - x}{\frac{y}{x + z}}} - y\right) \cdot -0.5 \]
    6. Taylor expanded in z around inf 82.7%

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

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

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

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

    if 1.00000000000000007e-68 < (*.f64 x x) < 2e101

    1. Initial program 86.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(x + z\right) \cdot \frac{z - x}{y}} - \frac{y \cdot y}{y}\right) \cdot \frac{-1}{2} \]
      14. associate-/l*99.8%

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

        \[\leadsto \left(\left(x + z\right) \cdot \frac{z - x}{y} - \frac{y}{\color{blue}{1}}\right) \cdot \frac{-1}{2} \]
      16. /-rgt-identity99.8%

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

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

      \[\leadsto \color{blue}{\left(\left(x + z\right) \cdot \frac{z - x}{y} - y\right) \cdot -0.5} \]
    4. Taylor expanded in x around inf 84.8%

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

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

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

        \[\leadsto \left(\frac{\color{blue}{-x \cdot x}}{y} - y\right) \cdot -0.5 \]
      4. distribute-rgt-neg-in84.8%

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

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

    if 2e101 < (*.f64 x x) < 2.0000000000000001e161

    1. Initial program 67.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{\color{blue}{\left(x + z\right)} \cdot \left(z - x\right)}{y} - \frac{y \cdot y}{y}\right) \cdot \frac{-1}{2} \]
      13. associate-*l/67.9%

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

        \[\leadsto \left(\color{blue}{\left(z - x\right) \cdot \frac{x + z}{y}} - \frac{y \cdot y}{y}\right) \cdot \frac{-1}{2} \]
      15. associate-/l*99.6%

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

        \[\leadsto \left(\left(z - x\right) \cdot \frac{x + z}{y} - \frac{y}{\color{blue}{1}}\right) \cdot \frac{-1}{2} \]
      17. /-rgt-identity99.6%

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

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

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

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

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

      \[\leadsto \left(\color{blue}{\frac{z - x}{\frac{y}{x + z}}} - y\right) \cdot -0.5 \]
    6. Step-by-step derivation
      1. *-un-lft-identity99.7%

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

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

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

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

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

      \[\leadsto \left(\frac{z - x}{\color{blue}{\frac{1}{\sqrt{z + x}} \cdot \frac{y}{\sqrt{z + x}}}} - y\right) \cdot -0.5 \]
    8. Step-by-step derivation
      1. associate-*l/49.8%

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

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

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

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

      \[\leadsto \left(\frac{z - x}{\color{blue}{\frac{\frac{y}{\sqrt{x + z}}}{\sqrt{x + z}}}} - y\right) \cdot -0.5 \]
    10. Taylor expanded in z around inf 68.3%

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

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

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

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

    if 2.0000000000000001e161 < (*.f64 x x)

    1. Initial program 63.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{\color{blue}{\left(x + z\right)} \cdot \left(z - x\right)}{y} - \frac{y \cdot y}{y}\right) \cdot \frac{-1}{2} \]
      13. associate-*l/79.9%

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

        \[\leadsto \left(\color{blue}{\left(z - x\right) \cdot \frac{x + z}{y}} - \frac{y \cdot y}{y}\right) \cdot \frac{-1}{2} \]
      15. associate-/l*99.9%

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

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

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

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

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

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

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

      \[\leadsto \left(\color{blue}{\frac{z - x}{\frac{y}{x + z}}} - y\right) \cdot -0.5 \]
    6. Taylor expanded in z around 0 71.8%

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

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

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

        \[\leadsto \left(\left(-\color{blue}{\frac{x}{\frac{y}{x}}}\right) - y\right) \cdot -0.5 \]
      4. distribute-neg-frac83.5%

        \[\leadsto \left(\color{blue}{\frac{-x}{\frac{y}{x}}} - y\right) \cdot -0.5 \]
    8. Simplified83.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \leq 10^{-68}:\\ \;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y} - y\right)\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+101}:\\ \;\;\;\;-0.5 \cdot \left(\frac{-x \cdot x}{y} - y\right)\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+161}:\\ \;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \left(\frac{-x}{\frac{y}{x}} - y\right)\\ \end{array} \]

Alternative 4: 51.8% accurate, 0.7× speedup?

\[\begin{array}{l} z = |z|\\ \\ \begin{array}{l} t_0 := -0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\ t_1 := x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \mathbf{if}\;y \leq -2.15 \cdot 10^{+49}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;y \leq -1.45 \cdot 10^{-12}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -9.8 \cdot 10^{-21}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;y \leq -4.1 \cdot 10^{-81}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -3.3 \cdot 10^{-258}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-43}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{+121}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \end{array} \]
NOTE: z should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* -0.5 (* z (/ z y)))) (t_1 (* x (* x (/ 0.5 y)))))
   (if (<= y -2.15e+49)
     (* y 0.5)
     (if (<= y -1.45e-12)
       t_1
       (if (<= y -9.8e-21)
         (* y 0.5)
         (if (<= y -4.1e-81)
           t_0
           (if (<= y -3.3e-258)
             t_1
             (if (<= y 1.1e-43) t_0 (if (<= y 1.05e+121) t_1 (* y 0.5))))))))))
z = abs(z);
double code(double x, double y, double z) {
	double t_0 = -0.5 * (z * (z / y));
	double t_1 = x * (x * (0.5 / y));
	double tmp;
	if (y <= -2.15e+49) {
		tmp = y * 0.5;
	} else if (y <= -1.45e-12) {
		tmp = t_1;
	} else if (y <= -9.8e-21) {
		tmp = y * 0.5;
	} else if (y <= -4.1e-81) {
		tmp = t_0;
	} else if (y <= -3.3e-258) {
		tmp = t_1;
	} else if (y <= 1.1e-43) {
		tmp = t_0;
	} else if (y <= 1.05e+121) {
		tmp = t_1;
	} else {
		tmp = y * 0.5;
	}
	return tmp;
}
NOTE: z should be positive before calling this function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (-0.5d0) * (z * (z / y))
    t_1 = x * (x * (0.5d0 / y))
    if (y <= (-2.15d+49)) then
        tmp = y * 0.5d0
    else if (y <= (-1.45d-12)) then
        tmp = t_1
    else if (y <= (-9.8d-21)) then
        tmp = y * 0.5d0
    else if (y <= (-4.1d-81)) then
        tmp = t_0
    else if (y <= (-3.3d-258)) then
        tmp = t_1
    else if (y <= 1.1d-43) then
        tmp = t_0
    else if (y <= 1.05d+121) then
        tmp = t_1
    else
        tmp = y * 0.5d0
    end if
    code = tmp
end function
z = Math.abs(z);
public static double code(double x, double y, double z) {
	double t_0 = -0.5 * (z * (z / y));
	double t_1 = x * (x * (0.5 / y));
	double tmp;
	if (y <= -2.15e+49) {
		tmp = y * 0.5;
	} else if (y <= -1.45e-12) {
		tmp = t_1;
	} else if (y <= -9.8e-21) {
		tmp = y * 0.5;
	} else if (y <= -4.1e-81) {
		tmp = t_0;
	} else if (y <= -3.3e-258) {
		tmp = t_1;
	} else if (y <= 1.1e-43) {
		tmp = t_0;
	} else if (y <= 1.05e+121) {
		tmp = t_1;
	} else {
		tmp = y * 0.5;
	}
	return tmp;
}
z = abs(z)
def code(x, y, z):
	t_0 = -0.5 * (z * (z / y))
	t_1 = x * (x * (0.5 / y))
	tmp = 0
	if y <= -2.15e+49:
		tmp = y * 0.5
	elif y <= -1.45e-12:
		tmp = t_1
	elif y <= -9.8e-21:
		tmp = y * 0.5
	elif y <= -4.1e-81:
		tmp = t_0
	elif y <= -3.3e-258:
		tmp = t_1
	elif y <= 1.1e-43:
		tmp = t_0
	elif y <= 1.05e+121:
		tmp = t_1
	else:
		tmp = y * 0.5
	return tmp
z = abs(z)
function code(x, y, z)
	t_0 = Float64(-0.5 * Float64(z * Float64(z / y)))
	t_1 = Float64(x * Float64(x * Float64(0.5 / y)))
	tmp = 0.0
	if (y <= -2.15e+49)
		tmp = Float64(y * 0.5);
	elseif (y <= -1.45e-12)
		tmp = t_1;
	elseif (y <= -9.8e-21)
		tmp = Float64(y * 0.5);
	elseif (y <= -4.1e-81)
		tmp = t_0;
	elseif (y <= -3.3e-258)
		tmp = t_1;
	elseif (y <= 1.1e-43)
		tmp = t_0;
	elseif (y <= 1.05e+121)
		tmp = t_1;
	else
		tmp = Float64(y * 0.5);
	end
	return tmp
end
z = abs(z)
function tmp_2 = code(x, y, z)
	t_0 = -0.5 * (z * (z / y));
	t_1 = x * (x * (0.5 / y));
	tmp = 0.0;
	if (y <= -2.15e+49)
		tmp = y * 0.5;
	elseif (y <= -1.45e-12)
		tmp = t_1;
	elseif (y <= -9.8e-21)
		tmp = y * 0.5;
	elseif (y <= -4.1e-81)
		tmp = t_0;
	elseif (y <= -3.3e-258)
		tmp = t_1;
	elseif (y <= 1.1e-43)
		tmp = t_0;
	elseif (y <= 1.05e+121)
		tmp = t_1;
	else
		tmp = y * 0.5;
	end
	tmp_2 = tmp;
end
NOTE: z should be positive before calling this function
code[x_, y_, z_] := Block[{t$95$0 = N[(-0.5 * N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.15e+49], N[(y * 0.5), $MachinePrecision], If[LessEqual[y, -1.45e-12], t$95$1, If[LessEqual[y, -9.8e-21], N[(y * 0.5), $MachinePrecision], If[LessEqual[y, -4.1e-81], t$95$0, If[LessEqual[y, -3.3e-258], t$95$1, If[LessEqual[y, 1.1e-43], t$95$0, If[LessEqual[y, 1.05e+121], t$95$1, N[(y * 0.5), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
z = |z|\\
\\
\begin{array}{l}
t_0 := -0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\
t_1 := x \cdot \left(x \cdot \frac{0.5}{y}\right)\\
\mathbf{if}\;y \leq -2.15 \cdot 10^{+49}:\\
\;\;\;\;y \cdot 0.5\\

\mathbf{elif}\;y \leq -1.45 \cdot 10^{-12}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq -9.8 \cdot 10^{-21}:\\
\;\;\;\;y \cdot 0.5\\

\mathbf{elif}\;y \leq -4.1 \cdot 10^{-81}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq -3.3 \cdot 10^{-258}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 1.1 \cdot 10^{-43}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 1.05 \cdot 10^{+121}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.15e49 or -1.4500000000000001e-12 < y < -9.8000000000000003e-21 or 1.0500000000000001e121 < y

    1. Initial program 41.8%

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

      \[\leadsto \color{blue}{0.5 \cdot y} \]
    3. Step-by-step derivation
      1. *-commutative74.0%

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

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

    if -2.15e49 < y < -1.4500000000000001e-12 or -4.09999999999999984e-81 < y < -3.3e-258 or 1.09999999999999999e-43 < y < 1.0500000000000001e121

    1. Initial program 91.9%

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

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

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

      \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot 2} \]
    5. Taylor expanded in x around 0 57.4%

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \left(x \cdot \frac{0.5}{y}\right)} \]
    7. Simplified59.5%

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

    if -9.8000000000000003e-21 < y < -4.09999999999999984e-81 or -3.3e-258 < y < 1.09999999999999999e-43

    1. Initial program 84.0%

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

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

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

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

      \[\leadsto \frac{\color{blue}{x \cdot x - z \cdot z}}{y \cdot 2} \]
    5. Taylor expanded in x around 0 60.9%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.15 \cdot 10^{+49}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;y \leq -1.45 \cdot 10^{-12}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \mathbf{elif}\;y \leq -9.8 \cdot 10^{-21}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;y \leq -4.1 \cdot 10^{-81}:\\ \;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\ \mathbf{elif}\;y \leq -3.3 \cdot 10^{-258}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-43}:\\ \;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{+121}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]

Alternative 5: 51.8% accurate, 0.7× speedup?

\[\begin{array}{l} z = |z|\\ \\ \begin{array}{l} t_0 := -0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\ t_1 := x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \mathbf{if}\;y \leq -4.5 \cdot 10^{+48}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;y \leq -1.8 \cdot 10^{-11}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.45 \cdot 10^{-21}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;y \leq -3.7 \cdot 10^{-81}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -9 \cdot 10^{-258}:\\ \;\;\;\;x \cdot \frac{x}{y \cdot 2}\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-42}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{+121}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \end{array} \]
NOTE: z should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* -0.5 (* z (/ z y)))) (t_1 (* x (* x (/ 0.5 y)))))
   (if (<= y -4.5e+48)
     (* y 0.5)
     (if (<= y -1.8e-11)
       t_1
       (if (<= y -1.45e-21)
         (* y 0.5)
         (if (<= y -3.7e-81)
           t_0
           (if (<= y -9e-258)
             (* x (/ x (* y 2.0)))
             (if (<= y 1.3e-42) t_0 (if (<= y 1.05e+121) t_1 (* y 0.5))))))))))
z = abs(z);
double code(double x, double y, double z) {
	double t_0 = -0.5 * (z * (z / y));
	double t_1 = x * (x * (0.5 / y));
	double tmp;
	if (y <= -4.5e+48) {
		tmp = y * 0.5;
	} else if (y <= -1.8e-11) {
		tmp = t_1;
	} else if (y <= -1.45e-21) {
		tmp = y * 0.5;
	} else if (y <= -3.7e-81) {
		tmp = t_0;
	} else if (y <= -9e-258) {
		tmp = x * (x / (y * 2.0));
	} else if (y <= 1.3e-42) {
		tmp = t_0;
	} else if (y <= 1.05e+121) {
		tmp = t_1;
	} else {
		tmp = y * 0.5;
	}
	return tmp;
}
NOTE: z should be positive before calling this function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (-0.5d0) * (z * (z / y))
    t_1 = x * (x * (0.5d0 / y))
    if (y <= (-4.5d+48)) then
        tmp = y * 0.5d0
    else if (y <= (-1.8d-11)) then
        tmp = t_1
    else if (y <= (-1.45d-21)) then
        tmp = y * 0.5d0
    else if (y <= (-3.7d-81)) then
        tmp = t_0
    else if (y <= (-9d-258)) then
        tmp = x * (x / (y * 2.0d0))
    else if (y <= 1.3d-42) then
        tmp = t_0
    else if (y <= 1.05d+121) then
        tmp = t_1
    else
        tmp = y * 0.5d0
    end if
    code = tmp
end function
z = Math.abs(z);
public static double code(double x, double y, double z) {
	double t_0 = -0.5 * (z * (z / y));
	double t_1 = x * (x * (0.5 / y));
	double tmp;
	if (y <= -4.5e+48) {
		tmp = y * 0.5;
	} else if (y <= -1.8e-11) {
		tmp = t_1;
	} else if (y <= -1.45e-21) {
		tmp = y * 0.5;
	} else if (y <= -3.7e-81) {
		tmp = t_0;
	} else if (y <= -9e-258) {
		tmp = x * (x / (y * 2.0));
	} else if (y <= 1.3e-42) {
		tmp = t_0;
	} else if (y <= 1.05e+121) {
		tmp = t_1;
	} else {
		tmp = y * 0.5;
	}
	return tmp;
}
z = abs(z)
def code(x, y, z):
	t_0 = -0.5 * (z * (z / y))
	t_1 = x * (x * (0.5 / y))
	tmp = 0
	if y <= -4.5e+48:
		tmp = y * 0.5
	elif y <= -1.8e-11:
		tmp = t_1
	elif y <= -1.45e-21:
		tmp = y * 0.5
	elif y <= -3.7e-81:
		tmp = t_0
	elif y <= -9e-258:
		tmp = x * (x / (y * 2.0))
	elif y <= 1.3e-42:
		tmp = t_0
	elif y <= 1.05e+121:
		tmp = t_1
	else:
		tmp = y * 0.5
	return tmp
z = abs(z)
function code(x, y, z)
	t_0 = Float64(-0.5 * Float64(z * Float64(z / y)))
	t_1 = Float64(x * Float64(x * Float64(0.5 / y)))
	tmp = 0.0
	if (y <= -4.5e+48)
		tmp = Float64(y * 0.5);
	elseif (y <= -1.8e-11)
		tmp = t_1;
	elseif (y <= -1.45e-21)
		tmp = Float64(y * 0.5);
	elseif (y <= -3.7e-81)
		tmp = t_0;
	elseif (y <= -9e-258)
		tmp = Float64(x * Float64(x / Float64(y * 2.0)));
	elseif (y <= 1.3e-42)
		tmp = t_0;
	elseif (y <= 1.05e+121)
		tmp = t_1;
	else
		tmp = Float64(y * 0.5);
	end
	return tmp
end
z = abs(z)
function tmp_2 = code(x, y, z)
	t_0 = -0.5 * (z * (z / y));
	t_1 = x * (x * (0.5 / y));
	tmp = 0.0;
	if (y <= -4.5e+48)
		tmp = y * 0.5;
	elseif (y <= -1.8e-11)
		tmp = t_1;
	elseif (y <= -1.45e-21)
		tmp = y * 0.5;
	elseif (y <= -3.7e-81)
		tmp = t_0;
	elseif (y <= -9e-258)
		tmp = x * (x / (y * 2.0));
	elseif (y <= 1.3e-42)
		tmp = t_0;
	elseif (y <= 1.05e+121)
		tmp = t_1;
	else
		tmp = y * 0.5;
	end
	tmp_2 = tmp;
end
NOTE: z should be positive before calling this function
code[x_, y_, z_] := Block[{t$95$0 = N[(-0.5 * N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.5e+48], N[(y * 0.5), $MachinePrecision], If[LessEqual[y, -1.8e-11], t$95$1, If[LessEqual[y, -1.45e-21], N[(y * 0.5), $MachinePrecision], If[LessEqual[y, -3.7e-81], t$95$0, If[LessEqual[y, -9e-258], N[(x * N[(x / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.3e-42], t$95$0, If[LessEqual[y, 1.05e+121], t$95$1, N[(y * 0.5), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
z = |z|\\
\\
\begin{array}{l}
t_0 := -0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\
t_1 := x \cdot \left(x \cdot \frac{0.5}{y}\right)\\
\mathbf{if}\;y \leq -4.5 \cdot 10^{+48}:\\
\;\;\;\;y \cdot 0.5\\

\mathbf{elif}\;y \leq -1.8 \cdot 10^{-11}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq -1.45 \cdot 10^{-21}:\\
\;\;\;\;y \cdot 0.5\\

\mathbf{elif}\;y \leq -3.7 \cdot 10^{-81}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq -9 \cdot 10^{-258}:\\
\;\;\;\;x \cdot \frac{x}{y \cdot 2}\\

\mathbf{elif}\;y \leq 1.3 \cdot 10^{-42}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 1.05 \cdot 10^{+121}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -4.49999999999999995e48 or -1.79999999999999992e-11 < y < -1.45e-21 or 1.0500000000000001e121 < y

    1. Initial program 41.8%

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

      \[\leadsto \color{blue}{0.5 \cdot y} \]
    3. Step-by-step derivation
      1. *-commutative74.0%

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

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

    if -4.49999999999999995e48 < y < -1.79999999999999992e-11 or 1.3e-42 < y < 1.0500000000000001e121

    1. Initial program 88.4%

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

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

        \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot 2} \]
    4. Simplified54.5%

      \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot 2} \]
    5. Taylor expanded in x around 0 54.5%

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \left(x \cdot \frac{0.5}{y}\right)} \]
    7. Simplified57.1%

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

    if -1.45e-21 < y < -3.69999999999999986e-81 or -9.00000000000000017e-258 < y < 1.3e-42

    1. Initial program 84.0%

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

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

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

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

      \[\leadsto \frac{\color{blue}{x \cdot x - z \cdot z}}{y \cdot 2} \]
    5. Taylor expanded in x around 0 60.9%

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

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

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

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

    if -3.69999999999999986e-81 < y < -9.00000000000000017e-258

    1. Initial program 94.9%

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

      \[\leadsto \frac{\color{blue}{{x}^{2}}}{y \cdot 2} \]
    3. Step-by-step derivation
      1. unpow259.9%

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

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

        \[\leadsto \color{blue}{\frac{x}{\frac{y \cdot 2}{x}}} \]
      2. associate-/r/61.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.5 \cdot 10^{+48}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;y \leq -1.8 \cdot 10^{-11}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \mathbf{elif}\;y \leq -1.45 \cdot 10^{-21}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;y \leq -3.7 \cdot 10^{-81}:\\ \;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\ \mathbf{elif}\;y \leq -9 \cdot 10^{-258}:\\ \;\;\;\;x \cdot \frac{x}{y \cdot 2}\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-42}:\\ \;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{+121}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]

Alternative 6: 51.9% accurate, 0.7× speedup?

\[\begin{array}{l} z = |z|\\ \\ \begin{array}{l} t_0 := -0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\ \mathbf{if}\;y \leq -9.2 \cdot 10^{+48}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;y \leq -6.2 \cdot 10^{-8}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \mathbf{elif}\;y \leq -1.35 \cdot 10^{-21}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;y \leq -3.25 \cdot 10^{-81}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -6.5 \cdot 10^{-258}:\\ \;\;\;\;x \cdot \frac{x}{y \cdot 2}\\ \mathbf{elif}\;y \leq 9.8 \cdot 10^{-43}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{+121}:\\ \;\;\;\;\frac{x}{\frac{y}{x}} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \end{array} \]
NOTE: z should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* -0.5 (* z (/ z y)))))
   (if (<= y -9.2e+48)
     (* y 0.5)
     (if (<= y -6.2e-8)
       (* x (* x (/ 0.5 y)))
       (if (<= y -1.35e-21)
         (* y 0.5)
         (if (<= y -3.25e-81)
           t_0
           (if (<= y -6.5e-258)
             (* x (/ x (* y 2.0)))
             (if (<= y 9.8e-43)
               t_0
               (if (<= y 1.05e+121) (* (/ x (/ y x)) 0.5) (* y 0.5))))))))))
z = abs(z);
double code(double x, double y, double z) {
	double t_0 = -0.5 * (z * (z / y));
	double tmp;
	if (y <= -9.2e+48) {
		tmp = y * 0.5;
	} else if (y <= -6.2e-8) {
		tmp = x * (x * (0.5 / y));
	} else if (y <= -1.35e-21) {
		tmp = y * 0.5;
	} else if (y <= -3.25e-81) {
		tmp = t_0;
	} else if (y <= -6.5e-258) {
		tmp = x * (x / (y * 2.0));
	} else if (y <= 9.8e-43) {
		tmp = t_0;
	} else if (y <= 1.05e+121) {
		tmp = (x / (y / x)) * 0.5;
	} else {
		tmp = y * 0.5;
	}
	return tmp;
}
NOTE: z should be positive before calling this function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (-0.5d0) * (z * (z / y))
    if (y <= (-9.2d+48)) then
        tmp = y * 0.5d0
    else if (y <= (-6.2d-8)) then
        tmp = x * (x * (0.5d0 / y))
    else if (y <= (-1.35d-21)) then
        tmp = y * 0.5d0
    else if (y <= (-3.25d-81)) then
        tmp = t_0
    else if (y <= (-6.5d-258)) then
        tmp = x * (x / (y * 2.0d0))
    else if (y <= 9.8d-43) then
        tmp = t_0
    else if (y <= 1.05d+121) then
        tmp = (x / (y / x)) * 0.5d0
    else
        tmp = y * 0.5d0
    end if
    code = tmp
end function
z = Math.abs(z);
public static double code(double x, double y, double z) {
	double t_0 = -0.5 * (z * (z / y));
	double tmp;
	if (y <= -9.2e+48) {
		tmp = y * 0.5;
	} else if (y <= -6.2e-8) {
		tmp = x * (x * (0.5 / y));
	} else if (y <= -1.35e-21) {
		tmp = y * 0.5;
	} else if (y <= -3.25e-81) {
		tmp = t_0;
	} else if (y <= -6.5e-258) {
		tmp = x * (x / (y * 2.0));
	} else if (y <= 9.8e-43) {
		tmp = t_0;
	} else if (y <= 1.05e+121) {
		tmp = (x / (y / x)) * 0.5;
	} else {
		tmp = y * 0.5;
	}
	return tmp;
}
z = abs(z)
def code(x, y, z):
	t_0 = -0.5 * (z * (z / y))
	tmp = 0
	if y <= -9.2e+48:
		tmp = y * 0.5
	elif y <= -6.2e-8:
		tmp = x * (x * (0.5 / y))
	elif y <= -1.35e-21:
		tmp = y * 0.5
	elif y <= -3.25e-81:
		tmp = t_0
	elif y <= -6.5e-258:
		tmp = x * (x / (y * 2.0))
	elif y <= 9.8e-43:
		tmp = t_0
	elif y <= 1.05e+121:
		tmp = (x / (y / x)) * 0.5
	else:
		tmp = y * 0.5
	return tmp
z = abs(z)
function code(x, y, z)
	t_0 = Float64(-0.5 * Float64(z * Float64(z / y)))
	tmp = 0.0
	if (y <= -9.2e+48)
		tmp = Float64(y * 0.5);
	elseif (y <= -6.2e-8)
		tmp = Float64(x * Float64(x * Float64(0.5 / y)));
	elseif (y <= -1.35e-21)
		tmp = Float64(y * 0.5);
	elseif (y <= -3.25e-81)
		tmp = t_0;
	elseif (y <= -6.5e-258)
		tmp = Float64(x * Float64(x / Float64(y * 2.0)));
	elseif (y <= 9.8e-43)
		tmp = t_0;
	elseif (y <= 1.05e+121)
		tmp = Float64(Float64(x / Float64(y / x)) * 0.5);
	else
		tmp = Float64(y * 0.5);
	end
	return tmp
end
z = abs(z)
function tmp_2 = code(x, y, z)
	t_0 = -0.5 * (z * (z / y));
	tmp = 0.0;
	if (y <= -9.2e+48)
		tmp = y * 0.5;
	elseif (y <= -6.2e-8)
		tmp = x * (x * (0.5 / y));
	elseif (y <= -1.35e-21)
		tmp = y * 0.5;
	elseif (y <= -3.25e-81)
		tmp = t_0;
	elseif (y <= -6.5e-258)
		tmp = x * (x / (y * 2.0));
	elseif (y <= 9.8e-43)
		tmp = t_0;
	elseif (y <= 1.05e+121)
		tmp = (x / (y / x)) * 0.5;
	else
		tmp = y * 0.5;
	end
	tmp_2 = tmp;
end
NOTE: z should be positive before calling this function
code[x_, y_, z_] := Block[{t$95$0 = N[(-0.5 * N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -9.2e+48], N[(y * 0.5), $MachinePrecision], If[LessEqual[y, -6.2e-8], N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -1.35e-21], N[(y * 0.5), $MachinePrecision], If[LessEqual[y, -3.25e-81], t$95$0, If[LessEqual[y, -6.5e-258], N[(x * N[(x / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9.8e-43], t$95$0, If[LessEqual[y, 1.05e+121], N[(N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]]]]]]]]
\begin{array}{l}
z = |z|\\
\\
\begin{array}{l}
t_0 := -0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\
\mathbf{if}\;y \leq -9.2 \cdot 10^{+48}:\\
\;\;\;\;y \cdot 0.5\\

\mathbf{elif}\;y \leq -6.2 \cdot 10^{-8}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\

\mathbf{elif}\;y \leq -1.35 \cdot 10^{-21}:\\
\;\;\;\;y \cdot 0.5\\

\mathbf{elif}\;y \leq -3.25 \cdot 10^{-81}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq -6.5 \cdot 10^{-258}:\\
\;\;\;\;x \cdot \frac{x}{y \cdot 2}\\

\mathbf{elif}\;y \leq 9.8 \cdot 10^{-43}:\\
\;\;\;\;t_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if y < -9.2000000000000001e48 or -6.2e-8 < y < -1.3500000000000001e-21 or 1.0500000000000001e121 < y

    1. Initial program 41.8%

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

      \[\leadsto \color{blue}{0.5 \cdot y} \]
    3. Step-by-step derivation
      1. *-commutative74.0%

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

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

    if -9.2000000000000001e48 < y < -6.2e-8

    1. Initial program 88.7%

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

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

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

      \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot 2} \]
    5. Taylor expanded in x around 0 66.9%

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \left(x \cdot \frac{0.5}{y}\right)} \]
    7. Simplified67.1%

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

    if -1.3500000000000001e-21 < y < -3.2500000000000001e-81 or -6.5000000000000002e-258 < y < 9.79999999999999976e-43

    1. Initial program 84.0%

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

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

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

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

      \[\leadsto \frac{\color{blue}{x \cdot x - z \cdot z}}{y \cdot 2} \]
    5. Taylor expanded in x around 0 60.9%

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

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

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

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

    if -3.2500000000000001e-81 < y < -6.5000000000000002e-258

    1. Initial program 94.9%

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

      \[\leadsto \frac{\color{blue}{{x}^{2}}}{y \cdot 2} \]
    3. Step-by-step derivation
      1. unpow259.9%

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

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

        \[\leadsto \color{blue}{\frac{x}{\frac{y \cdot 2}{x}}} \]
      2. associate-/r/61.6%

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

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

    if 9.79999999999999976e-43 < y < 1.0500000000000001e121

    1. Initial program 88.2%

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

      \[\leadsto \frac{\color{blue}{{x}^{2}}}{y \cdot 2} \]
    3. Step-by-step derivation
      1. unpow250.0%

        \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot 2} \]
    4. Simplified50.0%

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

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

        \[\leadsto \color{blue}{\frac{x \cdot x}{y} \cdot \frac{1}{2}} \]
      3. associate-/l*53.6%

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{x}}} \cdot \frac{1}{2} \]
      4. metadata-eval53.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9.2 \cdot 10^{+48}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;y \leq -6.2 \cdot 10^{-8}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \mathbf{elif}\;y \leq -1.35 \cdot 10^{-21}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;y \leq -3.25 \cdot 10^{-81}:\\ \;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\ \mathbf{elif}\;y \leq -6.5 \cdot 10^{-258}:\\ \;\;\;\;x \cdot \frac{x}{y \cdot 2}\\ \mathbf{elif}\;y \leq 9.8 \cdot 10^{-43}:\\ \;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{+121}:\\ \;\;\;\;\frac{x}{\frac{y}{x}} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]

Alternative 7: 80.6% accurate, 0.7× speedup?

\[\begin{array}{l} z = |z|\\ \\ \begin{array}{l} \mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+161} \lor \neg \left(x \cdot x \leq 4 \cdot 10^{+182}\right) \land x \cdot x \leq 10^{+243}:\\ \;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y} - y\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{x}} \cdot 0.5\\ \end{array} \end{array} \]
NOTE: z should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (or (<= (* x x) 2e+161)
         (and (not (<= (* x x) 4e+182)) (<= (* x x) 1e+243)))
   (* -0.5 (- (* z (/ z y)) y))
   (* (/ x (/ y x)) 0.5)))
z = abs(z);
double code(double x, double y, double z) {
	double tmp;
	if (((x * x) <= 2e+161) || (!((x * x) <= 4e+182) && ((x * x) <= 1e+243))) {
		tmp = -0.5 * ((z * (z / y)) - y);
	} else {
		tmp = (x / (y / x)) * 0.5;
	}
	return tmp;
}
NOTE: z should be positive before calling this function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (((x * x) <= 2d+161) .or. (.not. ((x * x) <= 4d+182)) .and. ((x * x) <= 1d+243)) then
        tmp = (-0.5d0) * ((z * (z / y)) - y)
    else
        tmp = (x / (y / x)) * 0.5d0
    end if
    code = tmp
end function
z = Math.abs(z);
public static double code(double x, double y, double z) {
	double tmp;
	if (((x * x) <= 2e+161) || (!((x * x) <= 4e+182) && ((x * x) <= 1e+243))) {
		tmp = -0.5 * ((z * (z / y)) - y);
	} else {
		tmp = (x / (y / x)) * 0.5;
	}
	return tmp;
}
z = abs(z)
def code(x, y, z):
	tmp = 0
	if ((x * x) <= 2e+161) or (not ((x * x) <= 4e+182) and ((x * x) <= 1e+243)):
		tmp = -0.5 * ((z * (z / y)) - y)
	else:
		tmp = (x / (y / x)) * 0.5
	return tmp
z = abs(z)
function code(x, y, z)
	tmp = 0.0
	if ((Float64(x * x) <= 2e+161) || (!(Float64(x * x) <= 4e+182) && (Float64(x * x) <= 1e+243)))
		tmp = Float64(-0.5 * Float64(Float64(z * Float64(z / y)) - y));
	else
		tmp = Float64(Float64(x / Float64(y / x)) * 0.5);
	end
	return tmp
end
z = abs(z)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (((x * x) <= 2e+161) || (~(((x * x) <= 4e+182)) && ((x * x) <= 1e+243)))
		tmp = -0.5 * ((z * (z / y)) - y);
	else
		tmp = (x / (y / x)) * 0.5;
	end
	tmp_2 = tmp;
end
NOTE: z should be positive before calling this function
code[x_, y_, z_] := If[Or[LessEqual[N[(x * x), $MachinePrecision], 2e+161], And[N[Not[LessEqual[N[(x * x), $MachinePrecision], 4e+182]], $MachinePrecision], LessEqual[N[(x * x), $MachinePrecision], 1e+243]]], N[(-0.5 * N[(N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+161} \lor \neg \left(x \cdot x \leq 4 \cdot 10^{+182}\right) \land x \cdot x \leq 10^{+243}:\\
\;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y} - y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x x) < 2.0000000000000001e161 or 4.0000000000000003e182 < (*.f64 x x) < 1.0000000000000001e243

    1. Initial program 72.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{\color{blue}{\left(x + z\right)} \cdot \left(z - x\right)}{y} - \frac{y \cdot y}{y}\right) \cdot \frac{-1}{2} \]
      13. associate-*l/76.0%

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

        \[\leadsto \left(\color{blue}{\left(z - x\right) \cdot \frac{x + z}{y}} - \frac{y \cdot y}{y}\right) \cdot \frac{-1}{2} \]
      15. associate-/l*99.9%

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

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

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

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

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

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

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

      \[\leadsto \left(\color{blue}{\frac{z - x}{\frac{y}{x + z}}} - y\right) \cdot -0.5 \]
    6. Taylor expanded in z around inf 76.9%

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

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

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

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

    if 2.0000000000000001e161 < (*.f64 x x) < 4.0000000000000003e182 or 1.0000000000000001e243 < (*.f64 x x)

    1. Initial program 64.8%

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

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

        \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot 2} \]
    4. Simplified70.3%

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

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

        \[\leadsto \color{blue}{\frac{x \cdot x}{y} \cdot \frac{1}{2}} \]
      3. associate-/l*76.2%

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{x}}} \cdot \frac{1}{2} \]
      4. metadata-eval76.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+161} \lor \neg \left(x \cdot x \leq 4 \cdot 10^{+182}\right) \land x \cdot x \leq 10^{+243}:\\ \;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y} - y\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{x}} \cdot 0.5\\ \end{array} \]

Alternative 8: 87.7% accurate, 1.0× speedup?

\[\begin{array}{l} z = |z|\\ \\ \begin{array}{l} \mathbf{if}\;x \cdot x \leq 10^{-68}:\\ \;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y} - y\right)\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \left(\left(z - x\right) \cdot \frac{x}{y} - y\right)\\ \end{array} \end{array} \]
NOTE: z should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (<= (* x x) 1e-68)
   (* -0.5 (- (* z (/ z y)) y))
   (* -0.5 (- (* (- z x) (/ x y)) y))))
z = abs(z);
double code(double x, double y, double z) {
	double tmp;
	if ((x * x) <= 1e-68) {
		tmp = -0.5 * ((z * (z / y)) - y);
	} else {
		tmp = -0.5 * (((z - x) * (x / y)) - y);
	}
	return tmp;
}
NOTE: z should be positive before calling this function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((x * x) <= 1d-68) then
        tmp = (-0.5d0) * ((z * (z / y)) - y)
    else
        tmp = (-0.5d0) * (((z - x) * (x / y)) - y)
    end if
    code = tmp
end function
z = Math.abs(z);
public static double code(double x, double y, double z) {
	double tmp;
	if ((x * x) <= 1e-68) {
		tmp = -0.5 * ((z * (z / y)) - y);
	} else {
		tmp = -0.5 * (((z - x) * (x / y)) - y);
	}
	return tmp;
}
z = abs(z)
def code(x, y, z):
	tmp = 0
	if (x * x) <= 1e-68:
		tmp = -0.5 * ((z * (z / y)) - y)
	else:
		tmp = -0.5 * (((z - x) * (x / y)) - y)
	return tmp
z = abs(z)
function code(x, y, z)
	tmp = 0.0
	if (Float64(x * x) <= 1e-68)
		tmp = Float64(-0.5 * Float64(Float64(z * Float64(z / y)) - y));
	else
		tmp = Float64(-0.5 * Float64(Float64(Float64(z - x) * Float64(x / y)) - y));
	end
	return tmp
end
z = abs(z)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x * x) <= 1e-68)
		tmp = -0.5 * ((z * (z / y)) - y);
	else
		tmp = -0.5 * (((z - x) * (x / y)) - y);
	end
	tmp_2 = tmp;
end
NOTE: z should be positive before calling this function
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 1e-68], N[(-0.5 * N[(N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[(N[(z - x), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 10^{-68}:\\
\;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y} - y\right)\\

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


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

    1. Initial program 70.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{\color{blue}{\left(x + z\right)} \cdot \left(z - x\right)}{y} - \frac{y \cdot y}{y}\right) \cdot \frac{-1}{2} \]
      13. associate-*l/75.6%

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

        \[\leadsto \left(\color{blue}{\left(z - x\right) \cdot \frac{x + z}{y}} - \frac{y \cdot y}{y}\right) \cdot \frac{-1}{2} \]
      15. associate-/l*99.9%

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

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

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

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

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

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

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

      \[\leadsto \left(\color{blue}{\frac{z - x}{\frac{y}{x + z}}} - y\right) \cdot -0.5 \]
    6. Taylor expanded in z around inf 82.7%

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

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

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

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

    if 1.00000000000000007e-68 < (*.f64 x x)

    1. Initial program 69.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{\color{blue}{\left(x + z\right)} \cdot \left(z - x\right)}{y} - \frac{y \cdot y}{y}\right) \cdot \frac{-1}{2} \]
      13. associate-*l/80.4%

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

        \[\leadsto \left(\color{blue}{\left(z - x\right) \cdot \frac{x + z}{y}} - \frac{y \cdot y}{y}\right) \cdot \frac{-1}{2} \]
      15. associate-/l*99.9%

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

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

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

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

      \[\leadsto \color{blue}{\left(\left(z - x\right) \cdot \frac{x + z}{y} - y\right) \cdot -0.5} \]
    4. Taylor expanded in x around inf 86.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \leq 10^{-68}:\\ \;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y} - y\right)\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \left(\left(z - x\right) \cdot \frac{x}{y} - y\right)\\ \end{array} \]

Alternative 9: 87.7% accurate, 1.0× speedup?

\[\begin{array}{l} z = |z|\\ \\ \begin{array}{l} \mathbf{if}\;x \cdot x \leq 10^{-68}:\\ \;\;\;\;-0.5 \cdot \left(\frac{z - x}{\frac{y}{z}} - y\right)\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \left(\left(z - x\right) \cdot \frac{x}{y} - y\right)\\ \end{array} \end{array} \]
NOTE: z should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (<= (* x x) 1e-68)
   (* -0.5 (- (/ (- z x) (/ y z)) y))
   (* -0.5 (- (* (- z x) (/ x y)) y))))
z = abs(z);
double code(double x, double y, double z) {
	double tmp;
	if ((x * x) <= 1e-68) {
		tmp = -0.5 * (((z - x) / (y / z)) - y);
	} else {
		tmp = -0.5 * (((z - x) * (x / y)) - y);
	}
	return tmp;
}
NOTE: z should be positive before calling this function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((x * x) <= 1d-68) then
        tmp = (-0.5d0) * (((z - x) / (y / z)) - y)
    else
        tmp = (-0.5d0) * (((z - x) * (x / y)) - y)
    end if
    code = tmp
end function
z = Math.abs(z);
public static double code(double x, double y, double z) {
	double tmp;
	if ((x * x) <= 1e-68) {
		tmp = -0.5 * (((z - x) / (y / z)) - y);
	} else {
		tmp = -0.5 * (((z - x) * (x / y)) - y);
	}
	return tmp;
}
z = abs(z)
def code(x, y, z):
	tmp = 0
	if (x * x) <= 1e-68:
		tmp = -0.5 * (((z - x) / (y / z)) - y)
	else:
		tmp = -0.5 * (((z - x) * (x / y)) - y)
	return tmp
z = abs(z)
function code(x, y, z)
	tmp = 0.0
	if (Float64(x * x) <= 1e-68)
		tmp = Float64(-0.5 * Float64(Float64(Float64(z - x) / Float64(y / z)) - y));
	else
		tmp = Float64(-0.5 * Float64(Float64(Float64(z - x) * Float64(x / y)) - y));
	end
	return tmp
end
z = abs(z)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x * x) <= 1e-68)
		tmp = -0.5 * (((z - x) / (y / z)) - y);
	else
		tmp = -0.5 * (((z - x) * (x / y)) - y);
	end
	tmp_2 = tmp;
end
NOTE: z should be positive before calling this function
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 1e-68], N[(-0.5 * N[(N[(N[(z - x), $MachinePrecision] / N[(y / z), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[(N[(z - x), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 10^{-68}:\\
\;\;\;\;-0.5 \cdot \left(\frac{z - x}{\frac{y}{z}} - y\right)\\

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


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

    1. Initial program 70.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{\color{blue}{\left(x + z\right)} \cdot \left(z - x\right)}{y} - \frac{y \cdot y}{y}\right) \cdot \frac{-1}{2} \]
      13. associate-*l/75.6%

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

        \[\leadsto \left(\color{blue}{\left(z - x\right) \cdot \frac{x + z}{y}} - \frac{y \cdot y}{y}\right) \cdot \frac{-1}{2} \]
      15. associate-/l*99.9%

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

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

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

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

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

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

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

      \[\leadsto \left(\color{blue}{\frac{z - x}{\frac{y}{x + z}}} - y\right) \cdot -0.5 \]
    6. Taylor expanded in x around 0 89.3%

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

    if 1.00000000000000007e-68 < (*.f64 x x)

    1. Initial program 69.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{\color{blue}{\left(x + z\right)} \cdot \left(z - x\right)}{y} - \frac{y \cdot y}{y}\right) \cdot \frac{-1}{2} \]
      13. associate-*l/80.4%

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

        \[\leadsto \left(\color{blue}{\left(z - x\right) \cdot \frac{x + z}{y}} - \frac{y \cdot y}{y}\right) \cdot \frac{-1}{2} \]
      15. associate-/l*99.9%

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

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

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

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

      \[\leadsto \color{blue}{\left(\left(z - x\right) \cdot \frac{x + z}{y} - y\right) \cdot -0.5} \]
    4. Taylor expanded in x around inf 86.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \leq 10^{-68}:\\ \;\;\;\;-0.5 \cdot \left(\frac{z - x}{\frac{y}{z}} - y\right)\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \left(\left(z - x\right) \cdot \frac{x}{y} - y\right)\\ \end{array} \]

Alternative 10: 51.2% accurate, 1.3× speedup?

\[\begin{array}{l} z = |z|\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -1.22 \cdot 10^{-21}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;y \leq 5.5 \cdot 10^{+121}:\\ \;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \end{array} \]
NOTE: z should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (<= y -1.22e-21)
   (* y 0.5)
   (if (<= y 5.5e+121) (* -0.5 (* z (/ z y))) (* y 0.5))))
z = abs(z);
double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.22e-21) {
		tmp = y * 0.5;
	} else if (y <= 5.5e+121) {
		tmp = -0.5 * (z * (z / y));
	} else {
		tmp = y * 0.5;
	}
	return tmp;
}
NOTE: z should be positive before calling this function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-1.22d-21)) then
        tmp = y * 0.5d0
    else if (y <= 5.5d+121) then
        tmp = (-0.5d0) * (z * (z / y))
    else
        tmp = y * 0.5d0
    end if
    code = tmp
end function
z = Math.abs(z);
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.22e-21) {
		tmp = y * 0.5;
	} else if (y <= 5.5e+121) {
		tmp = -0.5 * (z * (z / y));
	} else {
		tmp = y * 0.5;
	}
	return tmp;
}
z = abs(z)
def code(x, y, z):
	tmp = 0
	if y <= -1.22e-21:
		tmp = y * 0.5
	elif y <= 5.5e+121:
		tmp = -0.5 * (z * (z / y))
	else:
		tmp = y * 0.5
	return tmp
z = abs(z)
function code(x, y, z)
	tmp = 0.0
	if (y <= -1.22e-21)
		tmp = Float64(y * 0.5);
	elseif (y <= 5.5e+121)
		tmp = Float64(-0.5 * Float64(z * Float64(z / y)));
	else
		tmp = Float64(y * 0.5);
	end
	return tmp
end
z = abs(z)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -1.22e-21)
		tmp = y * 0.5;
	elseif (y <= 5.5e+121)
		tmp = -0.5 * (z * (z / y));
	else
		tmp = y * 0.5;
	end
	tmp_2 = tmp;
end
NOTE: z should be positive before calling this function
code[x_, y_, z_] := If[LessEqual[y, -1.22e-21], N[(y * 0.5), $MachinePrecision], If[LessEqual[y, 5.5e+121], N[(-0.5 * N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]]
\begin{array}{l}
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.22 \cdot 10^{-21}:\\
\;\;\;\;y \cdot 0.5\\

\mathbf{elif}\;y \leq 5.5 \cdot 10^{+121}:\\
\;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.21999999999999991e-21 or 5.4999999999999998e121 < y

    1. Initial program 45.8%

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

      \[\leadsto \color{blue}{0.5 \cdot y} \]
    3. Step-by-step derivation
      1. *-commutative68.0%

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

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

    if -1.21999999999999991e-21 < y < 5.4999999999999998e121

    1. Initial program 87.6%

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

      \[\leadsto \frac{\color{blue}{{x}^{2} - {z}^{2}}}{y \cdot 2} \]
    3. Step-by-step derivation
      1. unpow282.0%

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

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

      \[\leadsto \frac{\color{blue}{x \cdot x - z \cdot z}}{y \cdot 2} \]
    5. Taylor expanded in x around 0 47.8%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.22 \cdot 10^{-21}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;y \leq 5.5 \cdot 10^{+121}:\\ \;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]

Alternative 11: 34.0% accurate, 5.0× speedup?

\[\begin{array}{l} z = |z|\\ \\ y \cdot 0.5 \end{array} \]
NOTE: z should be positive before calling this function
(FPCore (x y z) :precision binary64 (* y 0.5))
z = abs(z);
double code(double x, double y, double z) {
	return y * 0.5;
}
NOTE: z should be positive before calling this function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = y * 0.5d0
end function
z = Math.abs(z);
public static double code(double x, double y, double z) {
	return y * 0.5;
}
z = abs(z)
def code(x, y, z):
	return y * 0.5
z = abs(z)
function code(x, y, z)
	return Float64(y * 0.5)
end
z = abs(z)
function tmp = code(x, y, z)
	tmp = y * 0.5;
end
NOTE: z should be positive before calling this function
code[x_, y_, z_] := N[(y * 0.5), $MachinePrecision]
\begin{array}{l}
z = |z|\\
\\
y \cdot 0.5
\end{array}
Derivation
  1. Initial program 70.3%

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

    \[\leadsto \color{blue}{0.5 \cdot y} \]
  3. Step-by-step derivation
    1. *-commutative33.3%

      \[\leadsto \color{blue}{y \cdot 0.5} \]
  4. Simplified33.3%

    \[\leadsto \color{blue}{y \cdot 0.5} \]
  5. Final simplification33.3%

    \[\leadsto y \cdot 0.5 \]

Developer target: 99.9% accurate, 1.0× speedup?

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

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

Reproduce

?
herbie shell --seed 2023240 
(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)))