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

Percentage Accurate: 91.3% → 99.9%
Time: 25.6s
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: 91.3% 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} \\ \left(\frac{z - x}{\frac{y}{z + x}} - y\right) \cdot -0.5 \end{array} \]
(FPCore (x y z) :precision binary64 (* (- (/ (- z x) (/ y (+ z x))) y) -0.5))
double code(double x, double y, double z) {
	return (((z - x) / (y / (z + x))) - y) * -0.5;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (((z - x) / (y / (z + x))) - y) * (-0.5d0)
end function
public static double code(double x, double y, double z) {
	return (((z - x) / (y / (z + x))) - y) * -0.5;
}
def code(x, y, z):
	return (((z - x) / (y / (z + x))) - y) * -0.5
function code(x, y, z)
	return Float64(Float64(Float64(Float64(z - x) / Float64(y / Float64(z + x))) - y) * -0.5)
end
function tmp = code(x, y, z)
	tmp = (((z - x) / (y / (z + x))) - y) * -0.5;
end
code[x_, y_, z_] := N[(N[(N[(N[(z - x), $MachinePrecision] / N[(y / N[(z + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision] * -0.5), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\left(z \cdot z - x \cdot x\right) - y \cdot y}}{y} \cdot \frac{-1}{2} \]
    10. div-sub87.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-squares98.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. +-commutative98.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/99.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. associate-*r/98.7%

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

      \[\leadsto \left(\frac{\color{blue}{\left(z - x\right) \cdot \left(x + z\right)}}{y} - y\right) \cdot -0.5 \]
    3. associate-/l*99.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. Final simplification99.9%

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

Alternative 2: 78.7% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 96.6%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z \cdot z - x \cdot x\right) - y \cdot y}}{y} \cdot \frac{-1}{2} \]
      10. div-sub96.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-squares96.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. +-commutative96.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/99.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 z around inf 85.7%

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

    if 4.9999999999999997e32 < (*.f64 x x)

    1. Initial program 79.0%

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

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

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

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

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

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

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

Alternative 3: 83.4% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 4 \cdot 10^{-92}:\\
\;\;\;\;-0.5 \cdot \left(\left(z + x\right) \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) < 3.99999999999999995e-92

    1. Initial program 96.0%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z \cdot z - x \cdot x\right) - y \cdot y}}{y} \cdot \frac{-1}{2} \]
      10. div-sub96.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-squares96.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. +-commutative96.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/98.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. Taylor expanded in z around inf 91.5%

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

    if 3.99999999999999995e-92 < (*.f64 x x)

    1. Initial program 81.7%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z \cdot z - x \cdot x\right) - y \cdot y}}{y} \cdot \frac{-1}{2} \]
      10. div-sub81.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-squares99.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. +-commutative99.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-*l/99.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. *-commutative99.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. Taylor expanded in x around inf 85.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \leq 4 \cdot 10^{-92}:\\ \;\;\;\;-0.5 \cdot \left(\left(z + x\right) \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: 96.0% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{z + x}{y} \cdot \frac{x - z}{2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z z) < 1.0000000000000001e-239

    1. Initial program 94.7%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z \cdot z - x \cdot x\right) - y \cdot y}}{y} \cdot \frac{-1}{2} \]
      10. div-sub94.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-squares94.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. +-commutative94.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/98.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. *-commutative98.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. Taylor expanded in x around inf 95.0%

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

    if 1.0000000000000001e-239 < (*.f64 z z)

    1. Initial program 84.2%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x + z}{y} \cdot \frac{x - z}{2}} \]
      3. +-commutative98.5%

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

      \[\leadsto \color{blue}{\frac{z + x}{y} \cdot \frac{x - z}{2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.5%

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

Alternative 5: 78.1% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 96.6%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z \cdot z - x \cdot x\right) - y \cdot y}}{y} \cdot \frac{-1}{2} \]
      10. div-sub96.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-squares96.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. +-commutative96.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/99.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 0 84.1%

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

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

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

    if 4.9999999999999997e32 < (*.f64 x x)

    1. Initial program 79.0%

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

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

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

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

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

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

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

Alternative 6: 99.9% accurate, 1.2× speedup?

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\left(z \cdot z - x \cdot x\right) - y \cdot y}}{y} \cdot \frac{-1}{2} \]
    10. div-sub87.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-squares98.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. +-commutative98.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/99.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. Final simplification99.9%

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

Alternative 7: 70.3% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{+32}:\\ \;\;\;\;-0.5 \cdot \frac{z}{\frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= (* x x) 5e+32) (* -0.5 (/ z (/ y z))) (* (/ x y) (/ x 2.0))))
double code(double x, double y, double z) {
	double tmp;
	if ((x * x) <= 5e+32) {
		tmp = -0.5 * (z / (y / z));
	} else {
		tmp = (x / y) * (x / 2.0);
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((x * x) <= 5d+32) then
        tmp = (-0.5d0) * (z / (y / z))
    else
        tmp = (x / y) * (x / 2.0d0)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((x * x) <= 5e+32) {
		tmp = -0.5 * (z / (y / z));
	} else {
		tmp = (x / y) * (x / 2.0);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x * x) <= 5e+32:
		tmp = -0.5 * (z / (y / z))
	else:
		tmp = (x / y) * (x / 2.0)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (Float64(x * x) <= 5e+32)
		tmp = Float64(-0.5 * Float64(z / Float64(y / z)));
	else
		tmp = Float64(Float64(x / y) * Float64(x / 2.0));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x * x) <= 5e+32)
		tmp = -0.5 * (z / (y / z));
	else
		tmp = (x / y) * (x / 2.0);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 5e+32], N[(-0.5 * N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{+32}:\\
\;\;\;\;-0.5 \cdot \frac{z}{\frac{y}{z}}\\

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


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

    1. Initial program 96.6%

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

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

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

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

        \[\leadsto \color{blue}{\frac{z}{\frac{y}{z}}} \cdot -0.5 \]
    4. Simplified69.2%

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

    if 4.9999999999999997e32 < (*.f64 x x)

    1. Initial program 79.0%

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

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

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

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

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

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

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

Alternative 8: 30.7% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.8 \cdot 10^{-136}:\\
\;\;\;\;y \cdot 0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 6.8000000000000001e-136

    1. Initial program 88.5%

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

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

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

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

    if 6.8000000000000001e-136 < x

    1. Initial program 85.4%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 30.7% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 6.8 \cdot 10^{-136}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x 6.8e-136) (* y 0.5) (* (/ x y) (/ x 2.0))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= 6.8e-136) {
		tmp = y * 0.5;
	} else {
		tmp = (x / y) * (x / 2.0);
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= 6.8d-136) then
        tmp = y * 0.5d0
    else
        tmp = (x / y) * (x / 2.0d0)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= 6.8e-136) {
		tmp = y * 0.5;
	} else {
		tmp = (x / y) * (x / 2.0);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= 6.8e-136:
		tmp = y * 0.5
	else:
		tmp = (x / y) * (x / 2.0)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= 6.8e-136)
		tmp = Float64(y * 0.5);
	else
		tmp = Float64(Float64(x / y) * Float64(x / 2.0));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= 6.8e-136)
		tmp = y * 0.5;
	else
		tmp = (x / y) * (x / 2.0);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, 6.8e-136], N[(y * 0.5), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.8 \cdot 10^{-136}:\\
\;\;\;\;y \cdot 0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 6.8000000000000001e-136

    1. Initial program 88.5%

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

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

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

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

    if 6.8000000000000001e-136 < x

    1. Initial program 85.4%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 6.8 \cdot 10^{-136}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\ \end{array} \]

Alternative 10: 58.4% accurate, 1.7× speedup?

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

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

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


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

    1. Initial program 90.1%

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

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

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

        \[\leadsto \frac{\color{blue}{z \cdot z}}{y} \cdot -0.5 \]
    4. Simplified49.6%

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

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

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

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

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

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

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

    if 6.2e16 < x

    1. Initial program 78.9%

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

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

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

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

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

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

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

Alternative 11: 10.3% accurate, 5.0× speedup?

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

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

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

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

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

    \[\leadsto \color{blue}{y \cdot 0.5} \]
  5. Final simplification9.4%

    \[\leadsto y \cdot 0.5 \]

Developer target: 99.8% accurate, 1.0× speedup?

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

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

Reproduce

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