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

Percentage Accurate: 69.8% → 99.8%
Time: 7.3s
Alternatives: 13
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 13 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.8% 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.8% accurate, 1.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 54.0% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 500000:\\
\;\;\;\;y \cdot 0.5\\

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

\mathbf{elif}\;x \cdot x \leq 10^{+180} \lor \neg \left(x \cdot x \leq 5 \cdot 10^{+222}\right):\\
\;\;\;\;0.5 \cdot \frac{z + x}{\frac{y}{x}}\\

\mathbf{else}:\\
\;\;\;\;z \cdot \frac{z \cdot -0.5}{y}\\


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

    1. Initial program 68.9%

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

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

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

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

    if 5e5 < (*.f64 x x) < 4.99999999999999995e131

    1. Initial program 88.0%

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

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

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

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

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

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

    if 4.99999999999999995e131 < (*.f64 x x) < 1e180 or 5.00000000000000023e222 < (*.f64 x x)

    1. Initial program 68.8%

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

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

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

        \[\leadsto 0.5 \cdot \frac{x \cdot x - \color{blue}{z \cdot z}}{y} \]
      3. difference-of-squares78.0%

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\frac{z + x}{\frac{y}{x - z}}} \]
      6. +-commutative84.1%

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

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

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

    if 1e180 < (*.f64 x x) < 5.00000000000000023e222

    1. Initial program 57.6%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \leq 500000:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+131}:\\ \;\;\;\;\frac{z \cdot \left(z \cdot -0.5\right)}{y}\\ \mathbf{elif}\;x \cdot x \leq 10^{+180} \lor \neg \left(x \cdot x \leq 5 \cdot 10^{+222}\right):\\ \;\;\;\;0.5 \cdot \frac{z + x}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{z \cdot -0.5}{y}\\ \end{array} \]

Alternative 3: 52.0% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_0 := z \cdot \frac{z \cdot -0.5}{y}\\
\mathbf{if}\;x \cdot x \leq 500000:\\
\;\;\;\;y \cdot 0.5\\

\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+131}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \cdot x \leq 10^{+180}:\\
\;\;\;\;\frac{x \cdot x}{y \cdot 2}\\

\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+222}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 68.9%

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

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

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

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

    if 5e5 < (*.f64 x x) < 4.99999999999999995e131 or 1e180 < (*.f64 x x) < 5.00000000000000023e222

    1. Initial program 79.7%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{z \cdot -0.5}}{y} \cdot z \]
    6. Applied egg-rr55.8%

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

    if 4.99999999999999995e131 < (*.f64 x x) < 1e180

    1. Initial program 72.6%

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

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

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

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

    if 5.00000000000000023e222 < (*.f64 x x)

    1. Initial program 68.0%

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

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

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

        \[\leadsto 0.5 \cdot \frac{x \cdot x - \color{blue}{z \cdot z}}{y} \]
      3. difference-of-squares81.2%

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\frac{z + x}{\frac{y}{x - z}}} \]
      6. +-commutative86.5%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x + z}}{\frac{y}{x - z}} \]
    4. Simplified86.5%

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

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

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

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

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

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

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

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

Alternative 4: 51.7% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;x \cdot x \leq 10^{+180}:\\
\;\;\;\;\frac{x \cdot x}{y \cdot 2}\\

\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+222}:\\
\;\;\;\;z \cdot \frac{z \cdot -0.5}{y}\\

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


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

    1. Initial program 68.9%

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

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

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

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

    if 5e5 < (*.f64 x x) < 4.99999999999999995e131

    1. Initial program 88.0%

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

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

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

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

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

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

    if 4.99999999999999995e131 < (*.f64 x x) < 1e180

    1. Initial program 72.6%

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

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

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

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

    if 1e180 < (*.f64 x x) < 5.00000000000000023e222

    1. Initial program 57.6%

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

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

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

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

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

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

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

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

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

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

    if 5.00000000000000023e222 < (*.f64 x x)

    1. Initial program 68.0%

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

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

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

        \[\leadsto 0.5 \cdot \frac{x \cdot x - \color{blue}{z \cdot z}}{y} \]
      3. difference-of-squares81.2%

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\frac{z + x}{\frac{y}{x - z}}} \]
      6. +-commutative86.5%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x + z}}{\frac{y}{x - z}} \]
    4. Simplified86.5%

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

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

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

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

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

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

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

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

Alternative 5: 58.8% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 4 \cdot 10^{+99} \lor \neg \left(x \cdot x \leq 5 \cdot 10^{+165}\right) \land x \cdot x \leq 5 \cdot 10^{+233}:\\
\;\;\;\;-0.5 \cdot \left(x \cdot \frac{z}{y} - y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x x) < 3.9999999999999999e99 or 4.9999999999999997e165 < (*.f64 x x) < 5.00000000000000009e233

    1. Initial program 70.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\frac{z \cdot z - x \cdot x}{y} - \frac{y \cdot y}{y}\right)} \cdot \frac{-1}{2} \]
      11. difference-of-squares70.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. +-commutative70.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/73.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. *-commutative73.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. Taylor expanded in x around inf 68.4%

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

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

        \[\leadsto \left(\frac{\color{blue}{x \cdot z}}{y} - y\right) \cdot -0.5 \]
      2. *-lft-identity57.3%

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

        \[\leadsto \left(\color{blue}{\frac{x}{1} \cdot \frac{z}{y}} - y\right) \cdot -0.5 \]
      4. /-rgt-identity59.7%

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

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

    if 3.9999999999999999e99 < (*.f64 x x) < 4.9999999999999997e165 or 5.00000000000000009e233 < (*.f64 x 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 y around 0 68.1%

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

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

        \[\leadsto 0.5 \cdot \frac{x \cdot x - \color{blue}{z \cdot z}}{y} \]
      3. difference-of-squares80.8%

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\frac{z + x}{\frac{y}{x - z}}} \]
      6. +-commutative86.9%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x + z}}{\frac{y}{x - z}} \]
    4. Simplified86.9%

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

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

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

Alternative 6: 84.9% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 74.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.00000000000000048e220 < (*.f64 z z)

    1. Initial program 59.7%

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

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

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

        \[\leadsto 0.5 \cdot \frac{x \cdot x - \color{blue}{z \cdot z}}{y} \]
      3. difference-of-squares80.6%

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\frac{z + x}{\frac{y}{x - z}}} \]
      6. +-commutative88.9%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x + z}}{\frac{y}{x - z}} \]
    4. Simplified88.9%

      \[\leadsto \color{blue}{0.5 \cdot \frac{x + z}{\frac{y}{x - z}}} \]
    5. Step-by-step derivation
      1. div-inv88.9%

        \[\leadsto 0.5 \cdot \frac{x + z}{\color{blue}{y \cdot \frac{1}{x - z}}} \]
    6. Applied egg-rr88.9%

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

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

Alternative 7: 85.4% accurate, 1.0× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.04e102

    1. Initial program 22.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.04e102 < y < 3700

    1. Initial program 87.2%

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

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

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

        \[\leadsto 0.5 \cdot \frac{x \cdot x - \color{blue}{z \cdot z}}{y} \]
      3. difference-of-squares85.4%

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\frac{z + x}{\frac{y}{x - z}}} \]
      6. +-commutative88.1%

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

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

    if 3700 < y

    1. Initial program 62.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 84.9% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 74.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.00000000000000048e220 < (*.f64 z z)

    1. Initial program 59.7%

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

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

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

        \[\leadsto 0.5 \cdot \frac{x \cdot x - \color{blue}{z \cdot z}}{y} \]
      3. difference-of-squares80.6%

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\frac{z + x}{\frac{y}{x - z}}} \]
      6. +-commutative88.9%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x + z}}{\frac{y}{x - z}} \]
    4. Simplified88.9%

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

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

Alternative 9: 85.5% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -6.6 \cdot 10^{+45} \lor \neg \left(z \leq 7.2 \cdot 10^{+93}\right):\\ \;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \left(x \cdot \frac{-x}{y} - y\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -6.6e+45) (not (<= z 7.2e+93)))
   (* -0.5 (- (/ z (/ y z)) y))
   (* -0.5 (- (* x (/ (- x) y)) y))))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -6.6e+45) || !(z <= 7.2e+93)) {
		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 ((z <= (-6.6d+45)) .or. (.not. (z <= 7.2d+93))) 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 ((z <= -6.6e+45) || !(z <= 7.2e+93)) {
		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 (z <= -6.6e+45) or not (z <= 7.2e+93):
		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 ((z <= -6.6e+45) || !(z <= 7.2e+93))
		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 ((z <= -6.6e+45) || ~((z <= 7.2e+93)))
		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[Or[LessEqual[z, -6.6e+45], N[Not[LessEqual[z, 7.2e+93]], $MachinePrecision]], 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}\;z \leq -6.6 \cdot 10^{+45} \lor \neg \left(z \leq 7.2 \cdot 10^{+93}\right):\\
\;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -6.6000000000000001e45 or 7.1999999999999998e93 < z

    1. Initial program 59.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.6000000000000001e45 < z < 7.1999999999999998e93

    1. Initial program 76.1%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z \cdot z - x \cdot x\right) - y \cdot y}}{y} \cdot \frac{-1}{2} \]
      10. div-sub76.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-squares76.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. +-commutative76.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/78.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. *-commutative78.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. add-cube-cbrt99.5%

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 52.0% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{y} \cdot \left(x \cdot 0.5\right)\\ \mathbf{if}\;x \leq -1.45 \cdot 10^{-28}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 9.2 \cdot 10^{-36}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 8.4 \cdot 10^{+65}:\\ \;\;\;\;z \cdot \frac{z \cdot -0.5}{y}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (/ x y) (* x 0.5))))
   (if (<= x -1.45e-28)
     t_0
     (if (<= x 9.2e-36)
       (* y 0.5)
       (if (<= x 8.4e+65) (* z (/ (* z -0.5) y)) t_0)))))
double code(double x, double y, double z) {
	double t_0 = (x / y) * (x * 0.5);
	double tmp;
	if (x <= -1.45e-28) {
		tmp = t_0;
	} else if (x <= 9.2e-36) {
		tmp = y * 0.5;
	} else if (x <= 8.4e+65) {
		tmp = z * ((z * -0.5) / 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 / y) * (x * 0.5d0)
    if (x <= (-1.45d-28)) then
        tmp = t_0
    else if (x <= 9.2d-36) then
        tmp = y * 0.5d0
    else if (x <= 8.4d+65) then
        tmp = z * ((z * (-0.5d0)) / 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 / y) * (x * 0.5);
	double tmp;
	if (x <= -1.45e-28) {
		tmp = t_0;
	} else if (x <= 9.2e-36) {
		tmp = y * 0.5;
	} else if (x <= 8.4e+65) {
		tmp = z * ((z * -0.5) / y);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (x / y) * (x * 0.5)
	tmp = 0
	if x <= -1.45e-28:
		tmp = t_0
	elif x <= 9.2e-36:
		tmp = y * 0.5
	elif x <= 8.4e+65:
		tmp = z * ((z * -0.5) / y)
	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 <= -1.45e-28)
		tmp = t_0;
	elseif (x <= 9.2e-36)
		tmp = Float64(y * 0.5);
	elseif (x <= 8.4e+65)
		tmp = Float64(z * Float64(Float64(z * -0.5) / y));
	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 <= -1.45e-28)
		tmp = t_0;
	elseif (x <= 9.2e-36)
		tmp = y * 0.5;
	elseif (x <= 8.4e+65)
		tmp = z * ((z * -0.5) / y);
	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, -1.45e-28], t$95$0, If[LessEqual[x, 9.2e-36], N[(y * 0.5), $MachinePrecision], If[LessEqual[x, 8.4e+65], N[(z * N[(N[(z * -0.5), $MachinePrecision] / y), $MachinePrecision]), $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 -1.45 \cdot 10^{-28}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 9.2 \cdot 10^{-36}:\\
\;\;\;\;y \cdot 0.5\\

\mathbf{elif}\;x \leq 8.4 \cdot 10^{+65}:\\
\;\;\;\;z \cdot \frac{z \cdot -0.5}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.45000000000000006e-28 or 8.39999999999999965e65 < x

    1. Initial program 71.4%

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

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

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

        \[\leadsto 0.5 \cdot \frac{x \cdot x - \color{blue}{z \cdot z}}{y} \]
      3. difference-of-squares77.0%

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\frac{z + x}{\frac{y}{x - z}}} \]
      6. +-commutative82.5%

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

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

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

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

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

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

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

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

    if -1.45000000000000006e-28 < x < 9.19999999999999986e-36

    1. Initial program 67.9%

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

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

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

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

    if 9.19999999999999986e-36 < x < 8.39999999999999965e65

    1. Initial program 75.6%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-0.5 \cdot z}{y} \cdot z} \]
      3. *-commutative61.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.45 \cdot 10^{-28}:\\ \;\;\;\;\frac{x}{y} \cdot \left(x \cdot 0.5\right)\\ \mathbf{elif}\;x \leq 9.2 \cdot 10^{-36}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 8.4 \cdot 10^{+65}:\\ \;\;\;\;z \cdot \frac{z \cdot -0.5}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \left(x \cdot 0.5\right)\\ \end{array} \]

Alternative 11: 82.5% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 71.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\frac{z \cdot z - x \cdot x}{y} - \frac{y \cdot y}{y}\right)} \cdot \frac{-1}{2} \]
      11. difference-of-squares71.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. +-commutative71.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/73.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. *-commutative73.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 79.7%

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

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

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

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

    if 5.00000000000000009e233 < (*.f64 x x)

    1. Initial program 68.7%

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

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

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

        \[\leadsto 0.5 \cdot \frac{x \cdot x - \color{blue}{z \cdot z}}{y} \]
      3. difference-of-squares82.2%

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\frac{z + x}{\frac{y}{x - z}}} \]
      6. +-commutative87.5%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x + z}}{\frac{y}{x - z}} \]
    4. Simplified87.5%

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

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

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

Alternative 12: 51.7% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.5 \cdot 10^{-30} \lor \neg \left(x \leq 1.08 \cdot 10^{+71}\right):\\
\;\;\;\;\frac{x}{y} \cdot \left(x \cdot 0.5\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -6.5000000000000005e-30 or 1.08e71 < x

    1. Initial program 71.4%

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

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

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

        \[\leadsto 0.5 \cdot \frac{x \cdot x - \color{blue}{z \cdot z}}{y} \]
      3. difference-of-squares77.0%

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\frac{z + x}{\frac{y}{x - z}}} \]
      6. +-commutative82.5%

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

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

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

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

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

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

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

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

    if -6.5000000000000005e-30 < x < 1.08e71

    1. Initial program 69.1%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.5 \cdot 10^{-30} \lor \neg \left(x \leq 1.08 \cdot 10^{+71}\right):\\ \;\;\;\;\frac{x}{y} \cdot \left(x \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]

Alternative 13: 33.8% 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 70.2%

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

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

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

    \[\leadsto \color{blue}{y \cdot 0.5} \]
  5. Final simplification36.1%

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