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

Percentage Accurate: 69.4% → 99.9%
Time: 7.3s
Alternatives: 10
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 10 alternatives:

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

Initial Program: 69.4% 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, 0.1× speedup?

\[\begin{array}{l} x = |x|\\ z = |z|\\ \\ \mathsf{fma}\left(\frac{z - x}{y}, z + x, -y\right) \cdot -0.5 \end{array} \]
NOTE: x should be positive before calling this function
NOTE: z should be positive before calling this function
(FPCore (x y z) :precision binary64 (* (fma (/ (- z x) y) (+ z x) (- y)) -0.5))
x = abs(x);
z = abs(z);
double code(double x, double y, double z) {
	return fma(((z - x) / y), (z + x), -y) * -0.5;
}
x = abs(x)
z = abs(z)
function code(x, y, z)
	return Float64(fma(Float64(Float64(z - x) / y), Float64(z + x), Float64(-y)) * -0.5)
end
NOTE: x should be positive before calling this function
NOTE: z should be positive before calling this function
code[x_, y_, z_] := N[(N[(N[(N[(z - x), $MachinePrecision] / y), $MachinePrecision] * N[(z + x), $MachinePrecision] + (-y)), $MachinePrecision] * -0.5), $MachinePrecision]
\begin{array}{l}
x = |x|\\
z = |z|\\
\\
\mathsf{fma}\left(\frac{z - x}{y}, z + x, -y\right) \cdot -0.5
\end{array}
Derivation
  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-squares74.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. +-commutative74.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-*r/80.1%

      \[\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. Step-by-step derivation
    1. *-commutative99.9%

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

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

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

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

Alternative 2: 84.6% accurate, 0.8× speedup?

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

\mathbf{elif}\;z \cdot z \leq 5 \cdot 10^{+266}:\\
\;\;\;\;-0.5 \cdot \left(\frac{z - x}{y} \cdot \left(z + x\right)\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 z z) < 1.99999999999999999e-73

    1. Initial program 72.9%

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

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

        \[\leadsto \frac{\color{blue}{\left(-z \cdot z\right) + \left(x \cdot x + y \cdot y\right)}}{y \cdot 2} \]
      3. neg-sub072.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-72.9%

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z \cdot z - x \cdot x\right) - y \cdot y}}{y} \cdot \frac{-1}{2} \]
      10. div-sub72.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-squares72.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. +-commutative72.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-*r/78.4%

        \[\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. Taylor expanded in x around inf 87.3%

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

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

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

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

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

      \[\leadsto \left(\color{blue}{\frac{x \cdot \left(-x\right)}{y}} - y\right) \cdot -0.5 \]
    7. Step-by-step derivation
      1. distribute-rgt-neg-out87.3%

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

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

        \[\leadsto \left(\left(-\color{blue}{\left(x \cdot x\right) \cdot \frac{1}{y}}\right) - y\right) \cdot -0.5 \]
      4. add-sqr-sqrt87.3%

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

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

        \[\leadsto \left(\left(-\sqrt{\left(x \cdot x\right) \cdot \color{blue}{\left(\left(-x\right) \cdot \left(-x\right)\right)}} \cdot \frac{1}{y}\right) - y\right) \cdot -0.5 \]
      7. swap-sqr78.6%

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

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

        \[\leadsto \left(\left(-\color{blue}{\left(x \cdot \left(-x\right)\right)} \cdot \frac{1}{y}\right) - y\right) \cdot -0.5 \]
      10. associate-*l*46.4%

        \[\leadsto \left(\left(-\color{blue}{x \cdot \left(\left(-x\right) \cdot \frac{1}{y}\right)}\right) - y\right) \cdot -0.5 \]
      11. add-sqr-sqrt25.7%

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

        \[\leadsto \left(\left(-x \cdot \left(\left(-x\right) \cdot \frac{1}{\color{blue}{\sqrt{y \cdot y}}}\right)\right) - y\right) \cdot -0.5 \]
      13. sqr-neg60.6%

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

        \[\leadsto \left(\left(-x \cdot \left(\left(-x\right) \cdot \frac{1}{\color{blue}{\sqrt{-y} \cdot \sqrt{-y}}}\right)\right) - y\right) \cdot -0.5 \]
      15. add-sqr-sqrt98.2%

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

        \[\leadsto \left(\left(-x \cdot \color{blue}{\frac{-x}{-y}}\right) - y\right) \cdot -0.5 \]
      17. frac-2neg98.3%

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

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

    if 1.99999999999999999e-73 < (*.f64 z z) < 4.9999999999999999e266

    1. Initial program 79.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z \cdot z - x \cdot x\right) - y \cdot y}}{y} \cdot \frac{-1}{2} \]
      10. div-sub79.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-squares79.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. +-commutative79.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/84.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. Step-by-step derivation
      1. *-commutative99.8%

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

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

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

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

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

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

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

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

    if 4.9999999999999999e266 < (*.f64 z z)

    1. Initial program 59.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z \cdot z - x \cdot x\right) - y \cdot y}}{y} \cdot \frac{-1}{2} \]
      10. div-sub59.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-squares71.8%

        \[\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. +-commutative71.8%

        \[\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/79.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.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. Step-by-step derivation
      1. *-commutative99.9%

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

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

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

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

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

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

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

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

Alternative 3: 91.6% accurate, 1.0× speedup?

\[\begin{array}{l} x = |x|\\ z = |z|\\ \\ \begin{array}{l} \mathbf{if}\;x \cdot x \leq 2 \cdot 10^{-48}:\\ \;\;\;\;-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: x should be positive before calling this function
NOTE: z should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (<= (* x x) 2e-48)
   (* -0.5 (- (* z (/ z y)) y))
   (* -0.5 (- (* (- z x) (/ x y)) y))))
x = abs(x);
z = abs(z);
double code(double x, double y, double z) {
	double tmp;
	if ((x * x) <= 2e-48) {
		tmp = -0.5 * ((z * (z / y)) - y);
	} else {
		tmp = -0.5 * (((z - x) * (x / y)) - y);
	}
	return tmp;
}
NOTE: x should be positive before calling this function
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-48) then
        tmp = (-0.5d0) * ((z * (z / y)) - y)
    else
        tmp = (-0.5d0) * (((z - x) * (x / y)) - y)
    end if
    code = tmp
end function
x = Math.abs(x);
z = Math.abs(z);
public static double code(double x, double y, double z) {
	double tmp;
	if ((x * x) <= 2e-48) {
		tmp = -0.5 * ((z * (z / y)) - y);
	} else {
		tmp = -0.5 * (((z - x) * (x / y)) - y);
	}
	return tmp;
}
x = abs(x)
z = abs(z)
def code(x, y, z):
	tmp = 0
	if (x * x) <= 2e-48:
		tmp = -0.5 * ((z * (z / y)) - y)
	else:
		tmp = -0.5 * (((z - x) * (x / y)) - y)
	return tmp
x = abs(x)
z = abs(z)
function code(x, y, z)
	tmp = 0.0
	if (Float64(x * x) <= 2e-48)
		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
x = abs(x)
z = abs(z)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x * x) <= 2e-48)
		tmp = -0.5 * ((z * (z / y)) - y);
	else
		tmp = -0.5 * (((z - x) * (x / y)) - y);
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: z should be positive before calling this function
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e-48], 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}
x = |x|\\
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{-48}:\\
\;\;\;\;-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.9999999999999999e-48

    1. Initial program 75.5%

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

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

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

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

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

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

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

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

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

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

        \[\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-squares75.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. +-commutative75.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-*r/80.8%

        \[\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. Step-by-step derivation
      1. *-commutative99.9%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\frac{z}{\frac{y}{z}} - y\right)} \cdot -0.5 \]
    9. Step-by-step derivation
      1. associate-/r/91.3%

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

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

    if 1.9999999999999999e-48 < (*.f64 x x)

    1. Initial program 64.7%

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

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

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

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

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

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

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

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

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

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

        \[\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.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. +-commutative72.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/79.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. *-commutative79.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 87.0%

      \[\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 simplification89.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \leq 2 \cdot 10^{-48}:\\ \;\;\;\;-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 4: 85.9% accurate, 1.1× speedup?

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

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


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

    1. Initial program 75.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z \cdot z - x \cdot x\right) - y \cdot y}}{y} \cdot \frac{-1}{2} \]
      10. div-sub75.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-squares75.0%

        \[\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. +-commutative75.0%

        \[\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/79.5%

        \[\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. Step-by-step derivation
      1. *-commutative99.9%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\frac{z}{\frac{y}{z}} - y\right)} \cdot -0.5 \]
    9. Step-by-step derivation
      1. associate-/r/89.4%

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

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

    if 4.99999999999999983e117 < (*.f64 x x)

    1. Initial program 62.9%

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

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

        \[\leadsto \frac{\color{blue}{\left(-z \cdot z\right) + \left(x \cdot x + y \cdot y\right)}}{y \cdot 2} \]
      3. neg-sub062.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-62.9%

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z \cdot z - x \cdot x\right) - y \cdot y}}{y} \cdot \frac{-1}{2} \]
      10. div-sub62.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-squares72.8%

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

        \[\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/81.0%

        \[\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. Taylor expanded in x around inf 75.3%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(-\sqrt{\left(x \cdot x\right) \cdot \color{blue}{\left(\left(-x\right) \cdot \left(-x\right)\right)}} \cdot \frac{1}{y}\right) - y\right) \cdot -0.5 \]
      7. swap-sqr60.8%

        \[\leadsto \left(\left(-\sqrt{\color{blue}{\left(x \cdot \left(-x\right)\right) \cdot \left(x \cdot \left(-x\right)\right)}} \cdot \frac{1}{y}\right) - y\right) \cdot -0.5 \]
      8. sqrt-unprod0.0%

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

        \[\leadsto \left(\left(-\color{blue}{\left(x \cdot \left(-x\right)\right)} \cdot \frac{1}{y}\right) - y\right) \cdot -0.5 \]
      10. associate-*l*20.7%

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

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

        \[\leadsto \left(\left(-x \cdot \left(\left(-x\right) \cdot \frac{1}{\color{blue}{\sqrt{y \cdot y}}}\right)\right) - y\right) \cdot -0.5 \]
      13. sqr-neg51.9%

        \[\leadsto \left(\left(-x \cdot \left(\left(-x\right) \cdot \frac{1}{\sqrt{\color{blue}{\left(-y\right) \cdot \left(-y\right)}}}\right)\right) - y\right) \cdot -0.5 \]
      14. sqrt-unprod44.1%

        \[\leadsto \left(\left(-x \cdot \left(\left(-x\right) \cdot \frac{1}{\color{blue}{\sqrt{-y} \cdot \sqrt{-y}}}\right)\right) - y\right) \cdot -0.5 \]
      15. add-sqr-sqrt89.7%

        \[\leadsto \left(\left(-x \cdot \left(\left(-x\right) \cdot \frac{1}{\color{blue}{-y}}\right)\right) - y\right) \cdot -0.5 \]
      16. div-inv89.8%

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

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

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

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

Alternative 5: 52.4% accurate, 1.1× speedup?

\[\begin{array}{l} x = |x|\\ z = |z|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 3.5 \cdot 10^{-233}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 17500000:\\ \;\;\;\;-0.5 \cdot \frac{z}{\frac{y}{z}}\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{+62}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \left(x \cdot 0.5\right)\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: z should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (<= x 3.5e-233)
   (* y 0.5)
   (if (<= x 17500000.0)
     (* -0.5 (/ z (/ y z)))
     (if (<= x 2.7e+62) (* y 0.5) (* (/ x y) (* x 0.5))))))
x = abs(x);
z = abs(z);
double code(double x, double y, double z) {
	double tmp;
	if (x <= 3.5e-233) {
		tmp = y * 0.5;
	} else if (x <= 17500000.0) {
		tmp = -0.5 * (z / (y / z));
	} else if (x <= 2.7e+62) {
		tmp = y * 0.5;
	} else {
		tmp = (x / y) * (x * 0.5);
	}
	return tmp;
}
NOTE: x should be positive before calling this function
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 <= 3.5d-233) then
        tmp = y * 0.5d0
    else if (x <= 17500000.0d0) then
        tmp = (-0.5d0) * (z / (y / z))
    else if (x <= 2.7d+62) then
        tmp = y * 0.5d0
    else
        tmp = (x / y) * (x * 0.5d0)
    end if
    code = tmp
end function
x = Math.abs(x);
z = Math.abs(z);
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= 3.5e-233) {
		tmp = y * 0.5;
	} else if (x <= 17500000.0) {
		tmp = -0.5 * (z / (y / z));
	} else if (x <= 2.7e+62) {
		tmp = y * 0.5;
	} else {
		tmp = (x / y) * (x * 0.5);
	}
	return tmp;
}
x = abs(x)
z = abs(z)
def code(x, y, z):
	tmp = 0
	if x <= 3.5e-233:
		tmp = y * 0.5
	elif x <= 17500000.0:
		tmp = -0.5 * (z / (y / z))
	elif x <= 2.7e+62:
		tmp = y * 0.5
	else:
		tmp = (x / y) * (x * 0.5)
	return tmp
x = abs(x)
z = abs(z)
function code(x, y, z)
	tmp = 0.0
	if (x <= 3.5e-233)
		tmp = Float64(y * 0.5);
	elseif (x <= 17500000.0)
		tmp = Float64(-0.5 * Float64(z / Float64(y / z)));
	elseif (x <= 2.7e+62)
		tmp = Float64(y * 0.5);
	else
		tmp = Float64(Float64(x / y) * Float64(x * 0.5));
	end
	return tmp
end
x = abs(x)
z = abs(z)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= 3.5e-233)
		tmp = y * 0.5;
	elseif (x <= 17500000.0)
		tmp = -0.5 * (z / (y / z));
	elseif (x <= 2.7e+62)
		tmp = y * 0.5;
	else
		tmp = (x / y) * (x * 0.5);
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: z should be positive before calling this function
code[x_, y_, z_] := If[LessEqual[x, 3.5e-233], N[(y * 0.5), $MachinePrecision], If[LessEqual[x, 17500000.0], N[(-0.5 * N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.7e+62], N[(y * 0.5), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.5 \cdot 10^{-233}:\\
\;\;\;\;y \cdot 0.5\\

\mathbf{elif}\;x \leq 17500000:\\
\;\;\;\;-0.5 \cdot \frac{z}{\frac{y}{z}}\\

\mathbf{elif}\;x \leq 2.7 \cdot 10^{+62}:\\
\;\;\;\;y \cdot 0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 3.49999999999999991e-233 or 1.75e7 < x < 2.7e62

    1. Initial program 73.1%

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

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

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

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

    if 3.49999999999999991e-233 < x < 1.75e7

    1. Initial program 74.9%

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

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

        \[\leadsto \frac{\color{blue}{\left(-z \cdot z\right) + \left(x \cdot x + y \cdot y\right)}}{y \cdot 2} \]
      3. neg-sub074.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-74.9%

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z \cdot z - x \cdot x\right) - y \cdot y}}{y} \cdot \frac{-1}{2} \]
      10. div-sub74.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-squares74.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. +-commutative74.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-*r/83.2%

        \[\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. Step-by-step derivation
      1. *-commutative99.8%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{z}{\frac{y}{z}}} \cdot -0.5 \]
    8. Simplified52.3%

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

    if 2.7e62 < x

    1. Initial program 56.3%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 3.5 \cdot 10^{-233}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 17500000:\\ \;\;\;\;-0.5 \cdot \frac{z}{\frac{y}{z}}\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{+62}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \left(x \cdot 0.5\right)\\ \end{array} \]

Alternative 6: 80.3% accurate, 1.1× speedup?

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

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


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

    1. Initial program 73.6%

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

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

        \[\leadsto \frac{\color{blue}{\left(-z \cdot z\right) + \left(x \cdot x + y \cdot y\right)}}{y \cdot 2} \]
      3. neg-sub073.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-73.6%

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

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

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

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

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

        \[\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-squares73.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. +-commutative73.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-*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. Step-by-step derivation
      1. *-commutative99.9%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\frac{z}{\frac{y}{z}} - y\right)} \cdot -0.5 \]
    9. Step-by-step derivation
      1. associate-/r/87.6%

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

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

    if 1.00000000000000004e192 < (*.f64 x x)

    1. Initial program 64.0%

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

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

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

      \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot 2} \]
    5. Step-by-step derivation
      1. times-frac77.9%

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

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

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

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

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

Alternative 7: 99.9% accurate, 1.2× speedup?

\[\begin{array}{l} x = |x|\\ z = |z|\\ \\ -0.5 \cdot \left(\frac{z - x}{y} \cdot \left(z + x\right) - y\right) \end{array} \]
NOTE: x should be positive before calling this function
NOTE: z should be positive before calling this function
(FPCore (x y z) :precision binary64 (* -0.5 (- (* (/ (- z x) y) (+ z x)) y)))
x = abs(x);
z = abs(z);
double code(double x, double y, double z) {
	return -0.5 * ((((z - x) / y) * (z + x)) - y);
}
NOTE: x should be positive before calling this function
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 = (-0.5d0) * ((((z - x) / y) * (z + x)) - y)
end function
x = Math.abs(x);
z = Math.abs(z);
public static double code(double x, double y, double z) {
	return -0.5 * ((((z - x) / y) * (z + x)) - y);
}
x = abs(x)
z = abs(z)
def code(x, y, z):
	return -0.5 * ((((z - x) / y) * (z + x)) - y)
x = abs(x)
z = abs(z)
function code(x, y, z)
	return Float64(-0.5 * Float64(Float64(Float64(Float64(z - x) / y) * Float64(z + x)) - y))
end
x = abs(x)
z = abs(z)
function tmp = code(x, y, z)
	tmp = -0.5 * ((((z - x) / y) * (z + x)) - y);
end
NOTE: x should be positive before calling this function
NOTE: z should be positive before calling this function
code[x_, y_, z_] := N[(-0.5 * N[(N[(N[(N[(z - x), $MachinePrecision] / y), $MachinePrecision] * N[(z + x), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
z = |z|\\
\\
-0.5 \cdot \left(\frac{z - x}{y} \cdot \left(z + x\right) - y\right)
\end{array}
Derivation
  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-squares74.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. +-commutative74.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-*r/80.1%

      \[\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 -0.5 \cdot \left(\frac{z - x}{y} \cdot \left(z + x\right) - y\right) \]

Alternative 8: 52.5% accurate, 1.7× speedup?

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

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


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

    1. Initial program 73.5%

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

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

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

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

    if 2.80000000000000014e62 < x

    1. Initial program 56.3%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{x \cdot x}}{y} \cdot 0.5 \]
      3. metadata-eval56.3%

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

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

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

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

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

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

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

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

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

Alternative 9: 52.5% accurate, 1.7× speedup?

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

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


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

    1. Initial program 73.5%

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

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

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

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

    if 2.89999999999999984e62 < x

    1. Initial program 56.3%

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

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

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

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

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

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

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

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

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

Alternative 10: 35.4% accurate, 5.0× speedup?

\[\begin{array}{l} x = |x|\\ z = |z|\\ \\ y \cdot 0.5 \end{array} \]
NOTE: x should be positive before calling this function
NOTE: z should be positive before calling this function
(FPCore (x y z) :precision binary64 (* y 0.5))
x = abs(x);
z = abs(z);
double code(double x, double y, double z) {
	return y * 0.5;
}
NOTE: x should be positive before calling this function
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
x = Math.abs(x);
z = Math.abs(z);
public static double code(double x, double y, double z) {
	return y * 0.5;
}
x = abs(x)
z = abs(z)
def code(x, y, z):
	return y * 0.5
x = abs(x)
z = abs(z)
function code(x, y, z)
	return Float64(y * 0.5)
end
x = abs(x)
z = abs(z)
function tmp = code(x, y, z)
	tmp = y * 0.5;
end
NOTE: x should be positive before calling this function
NOTE: z should be positive before calling this function
code[x_, y_, z_] := N[(y * 0.5), $MachinePrecision]
\begin{array}{l}
x = |x|\\
z = |z|\\
\\
y \cdot 0.5
\end{array}
Derivation
  1. Initial program 70.2%

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

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

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

    \[\leadsto \color{blue}{y \cdot 0.5} \]
  5. Final simplification32.0%

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