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

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

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 69.6% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\frac{z + x}{y}, z - x, -y\right) \cdot -0.5 \end{array} \]
(FPCore (x y z) :precision binary64 (* (fma (/ (+ z x) y) (- z x) (- y)) -0.5))
double code(double x, double y, double z) {
	return fma(((z + x) / y), (z - x), -y) * -0.5;
}
function code(x, y, z)
	return Float64(fma(Float64(Float64(z + x) / y), Float64(z - x), Float64(-y)) * -0.5)
end
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}

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\left(z \cdot z - x \cdot x\right) - y \cdot y}}{y} \cdot \frac{-1}{2} \]
    10. div-sub63.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-squares68.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. +-commutative68.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-*l/72.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. *-commutative72.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. Step-by-step derivation
    1. *-commutative99.9%

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

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z + x}{y}, z - x, -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: 52.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{y} \cdot \left(x \cdot 0.5\right)\\ \mathbf{if}\;x \leq -7.2 \cdot 10^{+91}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.75 \cdot 10^{-46}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq -1.7 \cdot 10^{-263}:\\ \;\;\;\;z \cdot \frac{z \cdot -0.5}{y}\\ \mathbf{elif}\;x \leq 8.6 \cdot 10^{+114}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (/ x y) (* x 0.5))))
   (if (<= x -7.2e+91)
     t_0
     (if (<= x -1.75e-46)
       (* y 0.5)
       (if (<= x -1.7e-263)
         (* z (/ (* z -0.5) y))
         (if (<= x 8.6e+114) (* y 0.5) t_0))))))
double code(double x, double y, double z) {
	double t_0 = (x / y) * (x * 0.5);
	double tmp;
	if (x <= -7.2e+91) {
		tmp = t_0;
	} else if (x <= -1.75e-46) {
		tmp = y * 0.5;
	} else if (x <= -1.7e-263) {
		tmp = z * ((z * -0.5) / y);
	} else if (x <= 8.6e+114) {
		tmp = y * 0.5;
	} else {
		tmp = t_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) :: t_0
    real(8) :: tmp
    t_0 = (x / y) * (x * 0.5d0)
    if (x <= (-7.2d+91)) then
        tmp = t_0
    else if (x <= (-1.75d-46)) then
        tmp = y * 0.5d0
    else if (x <= (-1.7d-263)) then
        tmp = z * ((z * (-0.5d0)) / y)
    else if (x <= 8.6d+114) then
        tmp = y * 0.5d0
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = (x / y) * (x * 0.5);
	double tmp;
	if (x <= -7.2e+91) {
		tmp = t_0;
	} else if (x <= -1.75e-46) {
		tmp = y * 0.5;
	} else if (x <= -1.7e-263) {
		tmp = z * ((z * -0.5) / y);
	} else if (x <= 8.6e+114) {
		tmp = y * 0.5;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (x / y) * (x * 0.5)
	tmp = 0
	if x <= -7.2e+91:
		tmp = t_0
	elif x <= -1.75e-46:
		tmp = y * 0.5
	elif x <= -1.7e-263:
		tmp = z * ((z * -0.5) / y)
	elif x <= 8.6e+114:
		tmp = y * 0.5
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(x / y) * Float64(x * 0.5))
	tmp = 0.0
	if (x <= -7.2e+91)
		tmp = t_0;
	elseif (x <= -1.75e-46)
		tmp = Float64(y * 0.5);
	elseif (x <= -1.7e-263)
		tmp = Float64(z * Float64(Float64(z * -0.5) / y));
	elseif (x <= 8.6e+114)
		tmp = Float64(y * 0.5);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (x / y) * (x * 0.5);
	tmp = 0.0;
	if (x <= -7.2e+91)
		tmp = t_0;
	elseif (x <= -1.75e-46)
		tmp = y * 0.5;
	elseif (x <= -1.7e-263)
		tmp = z * ((z * -0.5) / y);
	elseif (x <= 8.6e+114)
		tmp = y * 0.5;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x / y), $MachinePrecision] * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -7.2e+91], t$95$0, If[LessEqual[x, -1.75e-46], N[(y * 0.5), $MachinePrecision], If[LessEqual[x, -1.7e-263], N[(z * N[(N[(z * -0.5), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8.6e+114], N[(y * 0.5), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x}{y} \cdot \left(x \cdot 0.5\right)\\
\mathbf{if}\;x \leq -7.2 \cdot 10^{+91}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -1.75 \cdot 10^{-46}:\\
\;\;\;\;y \cdot 0.5\\

\mathbf{elif}\;x \leq -1.7 \cdot 10^{-263}:\\
\;\;\;\;z \cdot \frac{z \cdot -0.5}{y}\\

\mathbf{elif}\;x \leq 8.6 \cdot 10^{+114}:\\
\;\;\;\;y \cdot 0.5\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -7.2e91 or 8.6000000000000001e114 < x

    1. Initial program 59.9%

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

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

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

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

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

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

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

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

    if -7.2e91 < x < -1.7500000000000001e-46 or -1.70000000000000002e-263 < x < 8.6000000000000001e114

    1. Initial program 65.4%

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

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

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

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

    if -1.7500000000000001e-46 < x < -1.70000000000000002e-263

    1. Initial program 67.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-0.5 \cdot {z}^{2}}{1 \cdot y}} \]
      3. *-commutative57.6%

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

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

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

        \[\leadsto \color{blue}{\frac{z}{1} \cdot \frac{z \cdot -0.5}{y}} \]
      7. /-rgt-identity64.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7.2 \cdot 10^{+91}:\\ \;\;\;\;\frac{x}{y} \cdot \left(x \cdot 0.5\right)\\ \mathbf{elif}\;x \leq -1.75 \cdot 10^{-46}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq -1.7 \cdot 10^{-263}:\\ \;\;\;\;z \cdot \frac{z \cdot -0.5}{y}\\ \mathbf{elif}\;x \leq 8.6 \cdot 10^{+114}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \left(x \cdot 0.5\right)\\ \end{array} \]

Alternative 3: 52.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{y} \cdot \left(x \cdot 0.5\right)\\ \mathbf{if}\;x \leq -6.5 \cdot 10^{+91}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -2.9 \cdot 10^{-42}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq -1.2 \cdot 10^{-263}:\\ \;\;\;\;-0.5 \cdot \frac{z}{\frac{y}{z}}\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{+114}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (/ x y) (* x 0.5))))
   (if (<= x -6.5e+91)
     t_0
     (if (<= x -2.9e-42)
       (* y 0.5)
       (if (<= x -1.2e-263)
         (* -0.5 (/ z (/ y z)))
         (if (<= x 4.5e+114) (* y 0.5) t_0))))))
double code(double x, double y, double z) {
	double t_0 = (x / y) * (x * 0.5);
	double tmp;
	if (x <= -6.5e+91) {
		tmp = t_0;
	} else if (x <= -2.9e-42) {
		tmp = y * 0.5;
	} else if (x <= -1.2e-263) {
		tmp = -0.5 * (z / (y / z));
	} else if (x <= 4.5e+114) {
		tmp = y * 0.5;
	} else {
		tmp = t_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) :: t_0
    real(8) :: tmp
    t_0 = (x / y) * (x * 0.5d0)
    if (x <= (-6.5d+91)) then
        tmp = t_0
    else if (x <= (-2.9d-42)) then
        tmp = y * 0.5d0
    else if (x <= (-1.2d-263)) then
        tmp = (-0.5d0) * (z / (y / z))
    else if (x <= 4.5d+114) then
        tmp = y * 0.5d0
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = (x / y) * (x * 0.5);
	double tmp;
	if (x <= -6.5e+91) {
		tmp = t_0;
	} else if (x <= -2.9e-42) {
		tmp = y * 0.5;
	} else if (x <= -1.2e-263) {
		tmp = -0.5 * (z / (y / z));
	} else if (x <= 4.5e+114) {
		tmp = y * 0.5;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (x / y) * (x * 0.5)
	tmp = 0
	if x <= -6.5e+91:
		tmp = t_0
	elif x <= -2.9e-42:
		tmp = y * 0.5
	elif x <= -1.2e-263:
		tmp = -0.5 * (z / (y / z))
	elif x <= 4.5e+114:
		tmp = y * 0.5
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(x / y) * Float64(x * 0.5))
	tmp = 0.0
	if (x <= -6.5e+91)
		tmp = t_0;
	elseif (x <= -2.9e-42)
		tmp = Float64(y * 0.5);
	elseif (x <= -1.2e-263)
		tmp = Float64(-0.5 * Float64(z / Float64(y / z)));
	elseif (x <= 4.5e+114)
		tmp = Float64(y * 0.5);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (x / y) * (x * 0.5);
	tmp = 0.0;
	if (x <= -6.5e+91)
		tmp = t_0;
	elseif (x <= -2.9e-42)
		tmp = y * 0.5;
	elseif (x <= -1.2e-263)
		tmp = -0.5 * (z / (y / z));
	elseif (x <= 4.5e+114)
		tmp = y * 0.5;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x / y), $MachinePrecision] * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -6.5e+91], t$95$0, If[LessEqual[x, -2.9e-42], N[(y * 0.5), $MachinePrecision], If[LessEqual[x, -1.2e-263], N[(-0.5 * N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.5e+114], N[(y * 0.5), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x}{y} \cdot \left(x \cdot 0.5\right)\\
\mathbf{if}\;x \leq -6.5 \cdot 10^{+91}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -2.9 \cdot 10^{-42}:\\
\;\;\;\;y \cdot 0.5\\

\mathbf{elif}\;x \leq -1.2 \cdot 10^{-263}:\\
\;\;\;\;-0.5 \cdot \frac{z}{\frac{y}{z}}\\

\mathbf{elif}\;x \leq 4.5 \cdot 10^{+114}:\\
\;\;\;\;y \cdot 0.5\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -6.4999999999999997e91 or 4.5000000000000001e114 < x

    1. Initial program 59.9%

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

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

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

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

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

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

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

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

    if -6.4999999999999997e91 < x < -2.9000000000000003e-42 or -1.2e-263 < x < 4.5000000000000001e114

    1. Initial program 65.4%

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

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

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

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

    if -2.9000000000000003e-42 < x < -1.2e-263

    1. Initial program 67.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.5 \cdot 10^{+91}:\\ \;\;\;\;\frac{x}{y} \cdot \left(x \cdot 0.5\right)\\ \mathbf{elif}\;x \leq -2.9 \cdot 10^{-42}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq -1.2 \cdot 10^{-263}:\\ \;\;\;\;-0.5 \cdot \frac{z}{\frac{y}{z}}\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{+114}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \left(x \cdot 0.5\right)\\ \end{array} \]

Alternative 4: 85.8% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 65.7%

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

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

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

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

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

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

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

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

        \[\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-squares65.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. +-commutative65.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/68.5%

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

        \[\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 z around inf 80.1%

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

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

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

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

    if 2.0000000000000001e190 < (*.f64 x x)

    1. Initial program 60.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\left(z - x\right) \cdot \frac{x + z}{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^{+190}:\\ \;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \left(\left(z - x\right) \cdot \frac{z + x}{y}\right)\\ \end{array} \]

Alternative 5: 87.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot x \leq 4 \cdot 10^{+193}:\\ \;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \left(\left(z - x\right) \cdot \frac{x}{y} - y\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= (* x x) 4e+193)
   (* -0.5 (- (/ z (/ y z)) y))
   (* -0.5 (- (* (- z x) (/ x y)) y))))
double code(double x, double y, double z) {
	double tmp;
	if ((x * x) <= 4e+193) {
		tmp = -0.5 * ((z / (y / z)) - 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+193) then
        tmp = (-0.5d0) * ((z / (y / z)) - 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+193) {
		tmp = -0.5 * ((z / (y / z)) - y);
	} else {
		tmp = -0.5 * (((z - x) * (x / y)) - y);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x * x) <= 4e+193:
		tmp = -0.5 * ((z / (y / z)) - 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+193)
		tmp = Float64(-0.5 * Float64(Float64(z / Float64(y / z)) - 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+193)
		tmp = -0.5 * ((z / (y / z)) - 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+193], N[(-0.5 * N[(N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[(N[(z - x), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 65.9%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z \cdot z - x \cdot x\right) - y \cdot y}}{y} \cdot \frac{-1}{2} \]
      10. div-sub66.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-squares66.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. +-commutative66.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-*l/68.7%

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

        \[\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 z around inf 80.2%

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

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

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

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

    if 4.00000000000000026e193 < (*.f64 x x)

    1. Initial program 59.5%

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

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

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

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

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

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

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

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

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

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

Alternative 6: 88.0% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 71.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2e4 < (*.f64 z z)

    1. Initial program 56.5%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z \cdot z - x \cdot x\right) - y \cdot y}}{y} \cdot \frac{-1}{2} \]
      10. div-sub56.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-squares64.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. +-commutative64.9%

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

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

        \[\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 0 89.4%

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

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

Alternative 7: 85.1% accurate, 1.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z z) < 4.9999999999999998e34

    1. Initial program 71.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.9999999999999998e34 < (*.f64 z z)

    1. Initial program 55.9%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z \cdot z - x \cdot x\right) - y \cdot y}}{y} \cdot \frac{-1}{2} \]
      10. div-sub55.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-squares64.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. +-commutative64.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/68.5%

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

        \[\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 z around inf 69.4%

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

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

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

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

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

Alternative 8: 81.0% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 4 \cdot 10^{+193}:\\
\;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - 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) < 4.00000000000000026e193

    1. Initial program 65.9%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z \cdot z - x \cdot x\right) - y \cdot y}}{y} \cdot \frac{-1}{2} \]
      10. div-sub66.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-squares66.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. +-commutative66.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-*l/68.7%

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

        \[\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 z around inf 80.2%

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

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

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

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

    if 4.00000000000000026e193 < (*.f64 x x)

    1. Initial program 59.5%

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

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

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

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

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

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

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

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

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

Alternative 9: 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 63.7%

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\left(z \cdot z - x \cdot x\right) - y \cdot y}}{y} \cdot \frac{-1}{2} \]
    10. div-sub63.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-squares68.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. +-commutative68.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-*l/72.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. *-commutative72.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. Final simplification99.9%

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

Alternative 10: 51.1% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.45 \cdot 10^{+141} \lor \neg \left(z \leq 2.8 \cdot 10^{-41}\right):\\ \;\;\;\;z \cdot \frac{z \cdot -0.5}{y}\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -1.45e+141) (not (<= z 2.8e-41)))
   (* z (/ (* z -0.5) y))
   (* y 0.5)))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.45e+141) || !(z <= 2.8e-41)) {
		tmp = z * ((z * -0.5) / y);
	} else {
		tmp = y * 0.5;
	}
	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 <= (-1.45d+141)) .or. (.not. (z <= 2.8d-41))) then
        tmp = z * ((z * (-0.5d0)) / y)
    else
        tmp = y * 0.5d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.45e+141) || !(z <= 2.8e-41)) {
		tmp = z * ((z * -0.5) / y);
	} else {
		tmp = y * 0.5;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -1.45e+141) or not (z <= 2.8e-41):
		tmp = z * ((z * -0.5) / y)
	else:
		tmp = y * 0.5
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -1.45e+141) || !(z <= 2.8e-41))
		tmp = Float64(z * Float64(Float64(z * -0.5) / y));
	else
		tmp = Float64(y * 0.5);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -1.45e+141) || ~((z <= 2.8e-41)))
		tmp = z * ((z * -0.5) / y);
	else
		tmp = y * 0.5;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.45e+141], N[Not[LessEqual[z, 2.8e-41]], $MachinePrecision]], N[(z * N[(N[(z * -0.5), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.45 \cdot 10^{+141} \lor \neg \left(z \leq 2.8 \cdot 10^{-41}\right):\\
\;\;\;\;z \cdot \frac{z \cdot -0.5}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.45000000000000003e141 or 2.8000000000000002e-41 < z

    1. Initial program 55.3%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-0.5}{1}} \cdot \frac{{z}^{2}}{y} \]
      2. times-frac57.1%

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

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

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

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

        \[\leadsto \color{blue}{\frac{z}{1} \cdot \frac{z \cdot -0.5}{y}} \]
      7. /-rgt-identity64.0%

        \[\leadsto \color{blue}{z} \cdot \frac{z \cdot -0.5}{y} \]
    7. Simplified64.0%

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

    if -1.45000000000000003e141 < z < 2.8000000000000002e-41

    1. Initial program 70.3%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.45 \cdot 10^{+141} \lor \neg \left(z \leq 2.8 \cdot 10^{-41}\right):\\ \;\;\;\;z \cdot \frac{z \cdot -0.5}{y}\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]

Alternative 11: 34.0% 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 63.7%

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

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

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

    \[\leadsto \color{blue}{y \cdot 0.5} \]
  5. Final simplification36.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 2023195 
(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)))