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

Percentage Accurate: 68.2% → 99.9%
Time: 6.4s
Alternatives: 9
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 9 alternatives:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 87.6% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 75.6%

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.00000000000000015e121 < (*.f64 x x)

    1. Initial program 69.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(x + z\right) \cdot \color{blue}{\left(-1 \cdot \frac{x}{y}\right)} - y\right) \cdot -0.5 \]
    5. Step-by-step derivation
      1. neg-mul-192.2%

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

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

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

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

Alternative 3: 87.5% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 74.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e161 < (*.f64 z z)

    1. Initial program 70.7%

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

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

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

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

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

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

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

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

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

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

        \[\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*100.0%

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

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

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

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

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

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

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

Alternative 4: 85.3% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 75.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{\color{blue}{\left(x + z\right)} \cdot \left(z - x\right)}{y} - \frac{y \cdot y}{y}\right) \cdot \frac{-1}{2} \]
      13. associate-*r/77.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 88.1%

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

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

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

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

    if 4.99999999999999962e125 < (*.f64 x x)

    1. Initial program 69.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 52.7% accurate, 1.1× speedup?

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

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

\mathbf{elif}\;x \leq 1.9 \cdot 10^{-112}:\\
\;\;\;\;y \cdot 0.5\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.80000000000000018e46 or 6.99999999999999967e62 < x

    1. Initial program 70.6%

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

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

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

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

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

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

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

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

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

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

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

    if -2.80000000000000018e46 < x < 1.89999999999999997e-112

    1. Initial program 71.5%

      \[\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.89999999999999997e-112 < x < 6.99999999999999967e62

    1. Initial program 88.2%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{z}{\frac{y}{z}} \cdot -0.5} \]
    5. Step-by-step derivation
      1. associate-/r/61.8%

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

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

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

Alternative 6: 52.7% accurate, 1.1× speedup?

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

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

\mathbf{elif}\;x \leq 2 \cdot 10^{-112}:\\
\;\;\;\;y \cdot 0.5\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -3.00000000000000023e46

    1. Initial program 73.5%

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

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

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

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

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

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

    if -3.00000000000000023e46 < x < 1.9999999999999999e-112

    1. Initial program 71.5%

      \[\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.9999999999999999e-112 < x < 4.8999999999999997e63

    1. Initial program 88.2%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{z}{\frac{y}{z}} \cdot -0.5} \]
    5. Step-by-step derivation
      1. associate-/r/61.8%

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

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

    if 4.8999999999999997e63 < x

    1. Initial program 66.7%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 80.0% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{+69} \lor \neg \left(x \leq 1.2 \cdot 10^{+153}\right):\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{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 x < -1.69999999999999993e69 or 1.19999999999999996e153 < x

    1. Initial program 69.0%

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

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

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

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

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

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

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

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

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

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

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

    if -1.69999999999999993e69 < x < 1.19999999999999996e153

    1. Initial program 75.4%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\frac{z \cdot z - x \cdot x}{y} - \frac{y \cdot y}{y}\right)} \cdot \frac{-1}{2} \]
      11. difference-of-squares75.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. +-commutative75.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/76.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. Taylor expanded in x around 0 85.1%

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

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

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

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

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

Alternative 8: 52.1% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9 \cdot 10^{+46} \lor \neg \left(x \leq 1.04 \cdot 10^{+152}\right):\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.9e46 or 1.04000000000000005e152 < x

    1. Initial program 70.3%

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

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

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

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

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

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

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

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

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

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

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

    if -1.9e46 < x < 1.04000000000000005e152

    1. Initial program 74.8%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.9 \cdot 10^{+46} \lor \neg \left(x \leq 1.04 \cdot 10^{+152}\right):\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]

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

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

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

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

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

    \[\leadsto y \cdot 0.5 \]

Developer target: 99.9% accurate, 1.0× speedup?

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

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

Reproduce

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