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

Percentage Accurate: 69.2% → 99.9%
Time: 11.1s
Alternatives: 11
Speedup: 1.2×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 69.2% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 1.2× speedup?

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \left(\left(\color{blue}{\left(-1 + 1\right)} \cdot z + y\right) + \frac{{x}^{2} - {z}^{2}}{y}\right) \]
    5. distribute-lft1-in85.2%

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \left(\left(\left(-1 \cdot z + z\right) + y\right) + \frac{-1 \cdot {z}^{2} + \color{blue}{{x}^{2}}}{y}\right) \]
    13. distribute-lft1-in85.2%

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

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

      \[\leadsto 0.5 \cdot \left(\left(\color{blue}{0} + y\right) + \frac{-1 \cdot {z}^{2} + {x}^{2}}{y}\right) \]
    16. +-lft-identity85.2%

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

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

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

Alternative 2: 52.2% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;z \cdot z \leq 4 \cdot 10^{-35}:\\
\;\;\;\;0.5 \cdot y\\

\mathbf{elif}\;z \cdot z \leq 2 \cdot 10^{+30}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;z \cdot z \leq 5 \cdot 10^{+190}:\\
\;\;\;\;0.5 \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 z z) < 4.0000000000000002e-62 or 4.00000000000000003e-35 < (*.f64 z z) < 2e30

    1. Initial program 77.6%

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

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

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

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

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

    if 4.0000000000000002e-62 < (*.f64 z z) < 4.00000000000000003e-35 or 2e113 < (*.f64 z z) < 5.00000000000000036e190

    1. Initial program 78.8%

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

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

    if 2e30 < (*.f64 z z) < 2e113

    1. Initial program 89.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z \cdot \left(-1 \cdot 0.5\right)\right)} \cdot z}{y} \]
      11. metadata-eval66.5%

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

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

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

        \[\leadsto \color{blue}{\left(-\left(z \cdot -0.5\right) \cdot z\right) \cdot \frac{1}{-y}} \]
      3. distribute-rgt-neg-in66.7%

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

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

        \[\leadsto \color{blue}{\frac{\left(\left(z \cdot -0.5\right) \cdot \left(-z\right)\right) \cdot 1}{-y}} \]
      2. *-rgt-identity66.5%

        \[\leadsto \frac{\color{blue}{\left(z \cdot -0.5\right) \cdot \left(-z\right)}}{-y} \]
      3. distribute-rgt-neg-out66.5%

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

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

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

        \[\leadsto -\color{blue}{\frac{z}{\frac{-y}{z \cdot -0.5}}} \]
      7. distribute-neg-frac66.5%

        \[\leadsto \color{blue}{\frac{-z}{\frac{-y}{z \cdot -0.5}}} \]
      8. neg-mul-166.5%

        \[\leadsto \frac{-z}{\frac{\color{blue}{-1 \cdot y}}{z \cdot -0.5}} \]
      9. *-commutative66.5%

        \[\leadsto \frac{-z}{\frac{-1 \cdot y}{\color{blue}{-0.5 \cdot z}}} \]
      10. times-frac66.5%

        \[\leadsto \frac{-z}{\color{blue}{\frac{-1}{-0.5} \cdot \frac{y}{z}}} \]
      11. metadata-eval66.5%

        \[\leadsto \frac{-z}{\color{blue}{2} \cdot \frac{y}{z}} \]
    8. Simplified66.5%

      \[\leadsto \color{blue}{\frac{-z}{2 \cdot \frac{y}{z}}} \]
    9. Step-by-step derivation
      1. *-un-lft-identity66.5%

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

        \[\leadsto \frac{1 \cdot \left(-z\right)}{\color{blue}{\frac{y}{z} \cdot 2}} \]
      3. times-frac66.5%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{z}} \cdot \frac{-z}{2}} \]
      4. clear-num66.3%

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

        \[\leadsto \frac{z}{y} \cdot \color{blue}{\frac{-\left(-z\right)}{-2}} \]
      6. remove-double-neg66.3%

        \[\leadsto \frac{z}{y} \cdot \frac{\color{blue}{z}}{-2} \]
      7. times-frac66.5%

        \[\leadsto \color{blue}{\frac{z \cdot z}{y \cdot \left(-2\right)}} \]
      8. metadata-eval66.5%

        \[\leadsto \frac{z \cdot z}{y \cdot \color{blue}{-2}} \]
      9. metadata-eval66.5%

        \[\leadsto \frac{z \cdot z}{y \cdot \color{blue}{\frac{1}{-0.5}}} \]
      10. div-inv66.5%

        \[\leadsto \frac{z \cdot z}{\color{blue}{\frac{y}{-0.5}}} \]
      11. div-inv66.7%

        \[\leadsto \color{blue}{\left(z \cdot z\right) \cdot \frac{1}{\frac{y}{-0.5}}} \]
      12. clear-num66.7%

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

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

    if 5.00000000000000036e190 < (*.f64 z z)

    1. Initial program 61.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z \cdot \left(-1 \cdot 0.5\right)\right)} \cdot z}{y} \]
      11. metadata-eval66.9%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{z \cdot z}}{-2 \cdot y} \]
      5. times-frac70.9%

        \[\leadsto \color{blue}{\frac{z}{-2} \cdot \frac{z}{y}} \]
      6. metadata-eval70.9%

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

        \[\leadsto \color{blue}{\frac{z \cdot -0.5}{1}} \cdot \frac{z}{y} \]
      8. /-rgt-identity70.9%

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

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

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

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

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

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

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

Alternative 3: 52.2% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;z \cdot z \leq 4 \cdot 10^{-35}:\\
\;\;\;\;0.5 \cdot y\\

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

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

\mathbf{elif}\;z \cdot z \leq 5 \cdot 10^{+190}:\\
\;\;\;\;0.5 \cdot y\\

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


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

    1. Initial program 77.4%

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

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

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

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

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

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

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

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

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

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

    if 4.0000000000000002e-62 < (*.f64 z z) < 4.00000000000000003e-35 or 2e113 < (*.f64 z z) < 5.00000000000000036e190

    1. Initial program 78.8%

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

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

    if 4.00000000000000003e-35 < (*.f64 z z) < 2e30

    1. Initial program 78.9%

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

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

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

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

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

    if 2e30 < (*.f64 z z) < 2e113

    1. Initial program 89.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z \cdot \left(-1 \cdot 0.5\right)\right)} \cdot z}{y} \]
      11. metadata-eval66.5%

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

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

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

        \[\leadsto \color{blue}{\left(-\left(z \cdot -0.5\right) \cdot z\right) \cdot \frac{1}{-y}} \]
      3. distribute-rgt-neg-in66.7%

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

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

        \[\leadsto \color{blue}{\frac{\left(\left(z \cdot -0.5\right) \cdot \left(-z\right)\right) \cdot 1}{-y}} \]
      2. *-rgt-identity66.5%

        \[\leadsto \frac{\color{blue}{\left(z \cdot -0.5\right) \cdot \left(-z\right)}}{-y} \]
      3. distribute-rgt-neg-out66.5%

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

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

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

        \[\leadsto -\color{blue}{\frac{z}{\frac{-y}{z \cdot -0.5}}} \]
      7. distribute-neg-frac66.5%

        \[\leadsto \color{blue}{\frac{-z}{\frac{-y}{z \cdot -0.5}}} \]
      8. neg-mul-166.5%

        \[\leadsto \frac{-z}{\frac{\color{blue}{-1 \cdot y}}{z \cdot -0.5}} \]
      9. *-commutative66.5%

        \[\leadsto \frac{-z}{\frac{-1 \cdot y}{\color{blue}{-0.5 \cdot z}}} \]
      10. times-frac66.5%

        \[\leadsto \frac{-z}{\color{blue}{\frac{-1}{-0.5} \cdot \frac{y}{z}}} \]
      11. metadata-eval66.5%

        \[\leadsto \frac{-z}{\color{blue}{2} \cdot \frac{y}{z}} \]
    8. Simplified66.5%

      \[\leadsto \color{blue}{\frac{-z}{2 \cdot \frac{y}{z}}} \]
    9. Step-by-step derivation
      1. *-un-lft-identity66.5%

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

        \[\leadsto \frac{1 \cdot \left(-z\right)}{\color{blue}{\frac{y}{z} \cdot 2}} \]
      3. times-frac66.5%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{z}} \cdot \frac{-z}{2}} \]
      4. clear-num66.3%

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

        \[\leadsto \frac{z}{y} \cdot \color{blue}{\frac{-\left(-z\right)}{-2}} \]
      6. remove-double-neg66.3%

        \[\leadsto \frac{z}{y} \cdot \frac{\color{blue}{z}}{-2} \]
      7. times-frac66.5%

        \[\leadsto \color{blue}{\frac{z \cdot z}{y \cdot \left(-2\right)}} \]
      8. metadata-eval66.5%

        \[\leadsto \frac{z \cdot z}{y \cdot \color{blue}{-2}} \]
      9. metadata-eval66.5%

        \[\leadsto \frac{z \cdot z}{y \cdot \color{blue}{\frac{1}{-0.5}}} \]
      10. div-inv66.5%

        \[\leadsto \frac{z \cdot z}{\color{blue}{\frac{y}{-0.5}}} \]
      11. div-inv66.7%

        \[\leadsto \color{blue}{\left(z \cdot z\right) \cdot \frac{1}{\frac{y}{-0.5}}} \]
      12. clear-num66.7%

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

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

    if 5.00000000000000036e190 < (*.f64 z z)

    1. Initial program 61.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z \cdot \left(-1 \cdot 0.5\right)\right)} \cdot z}{y} \]
      11. metadata-eval66.9%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{z \cdot z}}{-2 \cdot y} \]
      5. times-frac70.9%

        \[\leadsto \color{blue}{\frac{z}{-2} \cdot \frac{z}{y}} \]
      6. metadata-eval70.9%

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

        \[\leadsto \color{blue}{\frac{z \cdot -0.5}{1}} \cdot \frac{z}{y} \]
      8. /-rgt-identity70.9%

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

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

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

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

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

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

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

Alternative 4: 52.2% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;z \cdot z \leq 4 \cdot 10^{-35}:\\
\;\;\;\;0.5 \cdot y\\

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

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

\mathbf{elif}\;z \cdot z \leq 5 \cdot 10^{+190}:\\
\;\;\;\;0.5 \cdot y\\

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


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

    1. Initial program 77.4%

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

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

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

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

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

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

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

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

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

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

    if 4.0000000000000002e-62 < (*.f64 z z) < 4.00000000000000003e-35 or 2e113 < (*.f64 z z) < 5.00000000000000036e190

    1. Initial program 78.8%

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

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

    if 4.00000000000000003e-35 < (*.f64 z z) < 2e30

    1. Initial program 78.9%

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

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

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

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

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

    if 2e30 < (*.f64 z z) < 2e113

    1. Initial program 89.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z \cdot \left(-1 \cdot 0.5\right)\right)} \cdot z}{y} \]
      11. metadata-eval66.5%

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

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

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

        \[\leadsto \color{blue}{\left(-\left(z \cdot -0.5\right) \cdot z\right) \cdot \frac{1}{-y}} \]
      3. distribute-rgt-neg-in66.7%

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

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

        \[\leadsto \color{blue}{\frac{\left(\left(z \cdot -0.5\right) \cdot \left(-z\right)\right) \cdot 1}{-y}} \]
      2. *-rgt-identity66.5%

        \[\leadsto \frac{\color{blue}{\left(z \cdot -0.5\right) \cdot \left(-z\right)}}{-y} \]
      3. distribute-rgt-neg-out66.5%

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

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

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

        \[\leadsto -\color{blue}{\frac{z}{\frac{-y}{z \cdot -0.5}}} \]
      7. distribute-neg-frac66.5%

        \[\leadsto \color{blue}{\frac{-z}{\frac{-y}{z \cdot -0.5}}} \]
      8. neg-mul-166.5%

        \[\leadsto \frac{-z}{\frac{\color{blue}{-1 \cdot y}}{z \cdot -0.5}} \]
      9. *-commutative66.5%

        \[\leadsto \frac{-z}{\frac{-1 \cdot y}{\color{blue}{-0.5 \cdot z}}} \]
      10. times-frac66.5%

        \[\leadsto \frac{-z}{\color{blue}{\frac{-1}{-0.5} \cdot \frac{y}{z}}} \]
      11. metadata-eval66.5%

        \[\leadsto \frac{-z}{\color{blue}{2} \cdot \frac{y}{z}} \]
    8. Simplified66.5%

      \[\leadsto \color{blue}{\frac{-z}{2 \cdot \frac{y}{z}}} \]
    9. Step-by-step derivation
      1. *-un-lft-identity66.5%

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

        \[\leadsto \frac{1 \cdot \left(-z\right)}{\color{blue}{\frac{y}{z} \cdot 2}} \]
      3. times-frac66.5%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{z}} \cdot \frac{-z}{2}} \]
      4. clear-num66.3%

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

        \[\leadsto \frac{z}{y} \cdot \color{blue}{\frac{-\left(-z\right)}{-2}} \]
      6. remove-double-neg66.3%

        \[\leadsto \frac{z}{y} \cdot \frac{\color{blue}{z}}{-2} \]
      7. times-frac66.5%

        \[\leadsto \color{blue}{\frac{z \cdot z}{y \cdot \left(-2\right)}} \]
      8. metadata-eval66.5%

        \[\leadsto \frac{z \cdot z}{y \cdot \color{blue}{-2}} \]
      9. metadata-eval66.5%

        \[\leadsto \frac{z \cdot z}{y \cdot \color{blue}{\frac{1}{-0.5}}} \]
      10. div-inv66.5%

        \[\leadsto \frac{z \cdot z}{\color{blue}{\frac{y}{-0.5}}} \]
      11. div-inv66.7%

        \[\leadsto \color{blue}{\left(z \cdot z\right) \cdot \frac{1}{\frac{y}{-0.5}}} \]
      12. clear-num66.7%

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

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

    if 5.00000000000000036e190 < (*.f64 z z)

    1. Initial program 61.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z \cdot \left(-1 \cdot 0.5\right)\right)} \cdot z}{y} \]
      11. metadata-eval66.9%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{z \cdot z}}{-2 \cdot y} \]
      5. times-frac70.9%

        \[\leadsto \color{blue}{\frac{z}{-2} \cdot \frac{z}{y}} \]
      6. metadata-eval70.9%

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

        \[\leadsto \color{blue}{\frac{z \cdot -0.5}{1}} \cdot \frac{z}{y} \]
      8. /-rgt-identity70.9%

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

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

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

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

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

      \[\leadsto \color{blue}{z \cdot \frac{z}{\frac{y}{-0.5}}} \]
    8. Step-by-step derivation
      1. clear-num70.9%

        \[\leadsto z \cdot \color{blue}{\frac{1}{\frac{\frac{y}{-0.5}}{z}}} \]
      2. un-div-inv70.9%

        \[\leadsto \color{blue}{\frac{z}{\frac{\frac{y}{-0.5}}{z}}} \]
      3. div-inv70.9%

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

        \[\leadsto \frac{z}{\frac{y \cdot \color{blue}{-2}}{z}} \]
    9. Applied egg-rr70.9%

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

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

Alternative 5: 52.2% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;z \cdot z \leq 4 \cdot 10^{-35}:\\
\;\;\;\;0.5 \cdot y\\

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

\mathbf{elif}\;z \cdot z \leq 2 \cdot 10^{+113}:\\
\;\;\;\;\frac{-z}{y \cdot \frac{2}{z}}\\

\mathbf{elif}\;z \cdot z \leq 5 \cdot 10^{+190}:\\
\;\;\;\;0.5 \cdot y\\

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


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

    1. Initial program 77.4%

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

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

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

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

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

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

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

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

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

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

    if 4.0000000000000002e-62 < (*.f64 z z) < 4.00000000000000003e-35 or 2e113 < (*.f64 z z) < 5.00000000000000036e190

    1. Initial program 78.8%

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

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

    if 4.00000000000000003e-35 < (*.f64 z z) < 2e30

    1. Initial program 78.9%

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

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

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

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

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

    if 2e30 < (*.f64 z z) < 2e113

    1. Initial program 89.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z \cdot \left(-1 \cdot 0.5\right)\right)} \cdot z}{y} \]
      11. metadata-eval66.5%

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

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

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

        \[\leadsto \color{blue}{\left(-\left(z \cdot -0.5\right) \cdot z\right) \cdot \frac{1}{-y}} \]
      3. distribute-rgt-neg-in66.7%

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

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

        \[\leadsto \color{blue}{\frac{\left(\left(z \cdot -0.5\right) \cdot \left(-z\right)\right) \cdot 1}{-y}} \]
      2. *-rgt-identity66.5%

        \[\leadsto \frac{\color{blue}{\left(z \cdot -0.5\right) \cdot \left(-z\right)}}{-y} \]
      3. distribute-rgt-neg-out66.5%

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

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

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

        \[\leadsto -\color{blue}{\frac{z}{\frac{-y}{z \cdot -0.5}}} \]
      7. distribute-neg-frac66.5%

        \[\leadsto \color{blue}{\frac{-z}{\frac{-y}{z \cdot -0.5}}} \]
      8. neg-mul-166.5%

        \[\leadsto \frac{-z}{\frac{\color{blue}{-1 \cdot y}}{z \cdot -0.5}} \]
      9. *-commutative66.5%

        \[\leadsto \frac{-z}{\frac{-1 \cdot y}{\color{blue}{-0.5 \cdot z}}} \]
      10. times-frac66.5%

        \[\leadsto \frac{-z}{\color{blue}{\frac{-1}{-0.5} \cdot \frac{y}{z}}} \]
      11. metadata-eval66.5%

        \[\leadsto \frac{-z}{\color{blue}{2} \cdot \frac{y}{z}} \]
    8. Simplified66.5%

      \[\leadsto \color{blue}{\frac{-z}{2 \cdot \frac{y}{z}}} \]
    9. Step-by-step derivation
      1. expm1-log1p-u66.1%

        \[\leadsto \frac{-z}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(2 \cdot \frac{y}{z}\right)\right)}} \]
      2. expm1-udef12.8%

        \[\leadsto \frac{-z}{\color{blue}{e^{\mathsf{log1p}\left(2 \cdot \frac{y}{z}\right)} - 1}} \]
    10. Applied egg-rr12.8%

      \[\leadsto \frac{-z}{\color{blue}{e^{\mathsf{log1p}\left(2 \cdot \frac{y}{z}\right)} - 1}} \]
    11. Step-by-step derivation
      1. expm1-def66.1%

        \[\leadsto \frac{-z}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(2 \cdot \frac{y}{z}\right)\right)}} \]
      2. expm1-log1p66.5%

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

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

        \[\leadsto \frac{-z}{\color{blue}{\frac{2}{z} \cdot y}} \]
      5. metadata-eval66.7%

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

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

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

        \[\leadsto \frac{-z}{y \cdot \color{blue}{\frac{2 \cdot 1}{z}}} \]
      9. metadata-eval66.7%

        \[\leadsto \frac{-z}{y \cdot \frac{\color{blue}{2}}{z}} \]
    12. Simplified66.7%

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

    if 5.00000000000000036e190 < (*.f64 z z)

    1. Initial program 61.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(z \cdot \left(-1 \cdot 0.5\right)\right)} \cdot z}{y} \]
      11. metadata-eval66.9%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{z \cdot z}}{-2 \cdot y} \]
      5. times-frac70.9%

        \[\leadsto \color{blue}{\frac{z}{-2} \cdot \frac{z}{y}} \]
      6. metadata-eval70.9%

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

        \[\leadsto \color{blue}{\frac{z \cdot -0.5}{1}} \cdot \frac{z}{y} \]
      8. /-rgt-identity70.9%

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

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

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

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

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

      \[\leadsto \color{blue}{z \cdot \frac{z}{\frac{y}{-0.5}}} \]
    8. Step-by-step derivation
      1. clear-num70.9%

        \[\leadsto z \cdot \color{blue}{\frac{1}{\frac{\frac{y}{-0.5}}{z}}} \]
      2. un-div-inv70.9%

        \[\leadsto \color{blue}{\frac{z}{\frac{\frac{y}{-0.5}}{z}}} \]
      3. div-inv70.9%

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

        \[\leadsto \frac{z}{\frac{y \cdot \color{blue}{-2}}{z}} \]
    9. Applied egg-rr70.9%

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

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

Alternative 6: 85.1% accurate, 0.6× speedup?

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

\mathbf{elif}\;z \cdot z \leq 5 \cdot 10^{+157} \lor \neg \left(z \cdot z \leq 2 \cdot 10^{+221}\right):\\
\;\;\;\;0.5 \cdot \left(y - \frac{z}{\frac{y}{z}}\right)\\

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


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

    1. Initial program 77.9%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(\left(\color{blue}{\left(-1 + 1\right)} \cdot z + y\right) + \frac{{x}^{2} - {z}^{2}}{y}\right) \]
      5. distribute-lft1-in93.3%

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(\left(\left(-1 \cdot z + z\right) + y\right) + \frac{-1 \cdot {z}^{2} + \color{blue}{{x}^{2}}}{y}\right) \]
      13. distribute-lft1-in93.3%

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

        \[\leadsto 0.5 \cdot \left(\left(\color{blue}{0} \cdot z + y\right) + \frac{-1 \cdot {z}^{2} + {x}^{2}}{y}\right) \]
      15. mul0-lft93.3%

        \[\leadsto 0.5 \cdot \left(\left(\color{blue}{0} + y\right) + \frac{-1 \cdot {z}^{2} + {x}^{2}}{y}\right) \]
      16. +-lft-identity93.3%

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

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

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

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

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

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

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

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

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

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

    if 2e30 < (*.f64 z z) < 4.99999999999999976e157 or 2.0000000000000001e221 < (*.f64 z z)

    1. Initial program 61.6%

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

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

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

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

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

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

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

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

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

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

    if 4.99999999999999976e157 < (*.f64 z z) < 2.0000000000000001e221

    1. Initial program 92.8%

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

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

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

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

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

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

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

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

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

Alternative 7: 43.4% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \frac{x}{\frac{y}{x}}\\ \mathbf{if}\;z \leq 1.75 \cdot 10^{-253}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 3.1 \cdot 10^{-220}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{-31}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 6.6 \cdot 10^{-18}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{+21}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.22 \cdot 10^{+57} \lor \neg \left(z \leq 1.85 \cdot 10^{+95}\right):\\ \;\;\;\;z \cdot \frac{z}{\frac{y}{-0.5}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot y\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* 0.5 (/ x (/ y x)))))
   (if (<= z 1.75e-253)
     t_0
     (if (<= z 3.1e-220)
       (* 0.5 y)
       (if (<= z 3.2e-31)
         t_0
         (if (<= z 6.6e-18)
           (* 0.5 y)
           (if (<= z 7.2e+21)
             t_0
             (if (or (<= z 1.22e+57) (not (<= z 1.85e+95)))
               (* z (/ z (/ y -0.5)))
               (* 0.5 y)))))))))
double code(double x, double y, double z) {
	double t_0 = 0.5 * (x / (y / x));
	double tmp;
	if (z <= 1.75e-253) {
		tmp = t_0;
	} else if (z <= 3.1e-220) {
		tmp = 0.5 * y;
	} else if (z <= 3.2e-31) {
		tmp = t_0;
	} else if (z <= 6.6e-18) {
		tmp = 0.5 * y;
	} else if (z <= 7.2e+21) {
		tmp = t_0;
	} else if ((z <= 1.22e+57) || !(z <= 1.85e+95)) {
		tmp = z * (z / (y / -0.5));
	} else {
		tmp = 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) :: t_0
    real(8) :: tmp
    t_0 = 0.5d0 * (x / (y / x))
    if (z <= 1.75d-253) then
        tmp = t_0
    else if (z <= 3.1d-220) then
        tmp = 0.5d0 * y
    else if (z <= 3.2d-31) then
        tmp = t_0
    else if (z <= 6.6d-18) then
        tmp = 0.5d0 * y
    else if (z <= 7.2d+21) then
        tmp = t_0
    else if ((z <= 1.22d+57) .or. (.not. (z <= 1.85d+95))) then
        tmp = z * (z / (y / (-0.5d0)))
    else
        tmp = 0.5d0 * y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = 0.5 * (x / (y / x));
	double tmp;
	if (z <= 1.75e-253) {
		tmp = t_0;
	} else if (z <= 3.1e-220) {
		tmp = 0.5 * y;
	} else if (z <= 3.2e-31) {
		tmp = t_0;
	} else if (z <= 6.6e-18) {
		tmp = 0.5 * y;
	} else if (z <= 7.2e+21) {
		tmp = t_0;
	} else if ((z <= 1.22e+57) || !(z <= 1.85e+95)) {
		tmp = z * (z / (y / -0.5));
	} else {
		tmp = 0.5 * y;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 0.5 * (x / (y / x))
	tmp = 0
	if z <= 1.75e-253:
		tmp = t_0
	elif z <= 3.1e-220:
		tmp = 0.5 * y
	elif z <= 3.2e-31:
		tmp = t_0
	elif z <= 6.6e-18:
		tmp = 0.5 * y
	elif z <= 7.2e+21:
		tmp = t_0
	elif (z <= 1.22e+57) or not (z <= 1.85e+95):
		tmp = z * (z / (y / -0.5))
	else:
		tmp = 0.5 * y
	return tmp
function code(x, y, z)
	t_0 = Float64(0.5 * Float64(x / Float64(y / x)))
	tmp = 0.0
	if (z <= 1.75e-253)
		tmp = t_0;
	elseif (z <= 3.1e-220)
		tmp = Float64(0.5 * y);
	elseif (z <= 3.2e-31)
		tmp = t_0;
	elseif (z <= 6.6e-18)
		tmp = Float64(0.5 * y);
	elseif (z <= 7.2e+21)
		tmp = t_0;
	elseif ((z <= 1.22e+57) || !(z <= 1.85e+95))
		tmp = Float64(z * Float64(z / Float64(y / -0.5)));
	else
		tmp = Float64(0.5 * y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 0.5 * (x / (y / x));
	tmp = 0.0;
	if (z <= 1.75e-253)
		tmp = t_0;
	elseif (z <= 3.1e-220)
		tmp = 0.5 * y;
	elseif (z <= 3.2e-31)
		tmp = t_0;
	elseif (z <= 6.6e-18)
		tmp = 0.5 * y;
	elseif (z <= 7.2e+21)
		tmp = t_0;
	elseif ((z <= 1.22e+57) || ~((z <= 1.85e+95)))
		tmp = z * (z / (y / -0.5));
	else
		tmp = 0.5 * y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(0.5 * N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 1.75e-253], t$95$0, If[LessEqual[z, 3.1e-220], N[(0.5 * y), $MachinePrecision], If[LessEqual[z, 3.2e-31], t$95$0, If[LessEqual[z, 6.6e-18], N[(0.5 * y), $MachinePrecision], If[LessEqual[z, 7.2e+21], t$95$0, If[Or[LessEqual[z, 1.22e+57], N[Not[LessEqual[z, 1.85e+95]], $MachinePrecision]], N[(z * N[(z / N[(y / -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq 3.1 \cdot 10^{-220}:\\
\;\;\;\;0.5 \cdot y\\

\mathbf{elif}\;z \leq 3.2 \cdot 10^{-31}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq 6.6 \cdot 10^{-18}:\\
\;\;\;\;0.5 \cdot y\\

\mathbf{elif}\;z \leq 7.2 \cdot 10^{+21}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq 1.22 \cdot 10^{+57} \lor \neg \left(z \leq 1.85 \cdot 10^{+95}\right):\\
\;\;\;\;z \cdot \frac{z}{\frac{y}{-0.5}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 1.75000000000000011e-253 or 3.10000000000000011e-220 < z < 3.20000000000000018e-31 or 6.6000000000000003e-18 < z < 7.2e21

    1. Initial program 75.3%

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

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

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

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

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

    if 1.75000000000000011e-253 < z < 3.10000000000000011e-220 or 3.20000000000000018e-31 < z < 6.6000000000000003e-18 or 1.22e57 < z < 1.8500000000000001e95

    1. Initial program 64.2%

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

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

    if 7.2e21 < z < 1.22e57 or 1.8500000000000001e95 < z

    1. Initial program 62.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(\color{blue}{\left(-1 \cdot z\right)} \cdot 0.5\right) \cdot z}{y} \]
      9. *-commutative62.7%

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

        \[\leadsto \frac{\color{blue}{\left(z \cdot \left(-1 \cdot 0.5\right)\right)} \cdot z}{y} \]
      11. metadata-eval62.7%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{{z}^{2}}}{-2 \cdot y} \]
      4. unpow262.7%

        \[\leadsto \frac{\color{blue}{z \cdot z}}{-2 \cdot y} \]
      5. times-frac64.3%

        \[\leadsto \color{blue}{\frac{z}{-2} \cdot \frac{z}{y}} \]
      6. metadata-eval64.3%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 1.75 \cdot 10^{-253}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{y}{x}}\\ \mathbf{elif}\;z \leq 3.1 \cdot 10^{-220}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{-31}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{y}{x}}\\ \mathbf{elif}\;z \leq 6.6 \cdot 10^{-18}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{+21}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{y}{x}}\\ \mathbf{elif}\;z \leq 1.22 \cdot 10^{+57} \lor \neg \left(z \leq 1.85 \cdot 10^{+95}\right):\\ \;\;\;\;z \cdot \frac{z}{\frac{y}{-0.5}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot y\\ \end{array} \]

Alternative 8: 84.3% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+30} \lor \neg \left(z \cdot z \leq 2 \cdot 10^{+113}\right) \land z \cdot z \leq 5 \cdot 10^{+190}:\\
\;\;\;\;0.5 \cdot \left(y + x \cdot \frac{x}{y}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z z) < 2e30 or 2e113 < (*.f64 z z) < 5.00000000000000036e190

    1. Initial program 77.7%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(\left(\color{blue}{\left(-1 + 1\right)} \cdot z + y\right) + \frac{{x}^{2} - {z}^{2}}{y}\right) \]
      5. distribute-lft1-in93.8%

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(\left(\left(-1 \cdot z + z\right) + y\right) + \frac{-1 \cdot {z}^{2} + \color{blue}{{x}^{2}}}{y}\right) \]
      13. distribute-lft1-in93.8%

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

        \[\leadsto 0.5 \cdot \left(\left(\color{blue}{0} \cdot z + y\right) + \frac{-1 \cdot {z}^{2} + {x}^{2}}{y}\right) \]
      15. mul0-lft93.8%

        \[\leadsto 0.5 \cdot \left(\left(\color{blue}{0} + y\right) + \frac{-1 \cdot {z}^{2} + {x}^{2}}{y}\right) \]
      16. +-lft-identity93.8%

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

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

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

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

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

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

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

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

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

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

    if 2e30 < (*.f64 z z) < 2e113 or 5.00000000000000036e190 < (*.f64 z z)

    1. Initial program 63.9%

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 80.2% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 78.4%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(\left(\color{blue}{\left(-1 + 1\right)} \cdot z + y\right) + \frac{{x}^{2} - {z}^{2}}{y}\right) \]
      5. distribute-lft1-in94.7%

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

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

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

        \[\leadsto 0.5 \cdot \left(\left(\left(-1 \cdot z + z\right) + y\right) + \frac{\color{blue}{x \cdot x + \left(-z \cdot z\right)}}{y}\right) \]
      9. mul-1-neg94.7%

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

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

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

        \[\leadsto 0.5 \cdot \left(\left(\left(-1 \cdot z + z\right) + y\right) + \frac{-1 \cdot {z}^{2} + \color{blue}{{x}^{2}}}{y}\right) \]
      13. distribute-lft1-in94.7%

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

        \[\leadsto 0.5 \cdot \left(\left(\color{blue}{0} \cdot z + y\right) + \frac{-1 \cdot {z}^{2} + {x}^{2}}{y}\right) \]
      15. mul0-lft94.7%

        \[\leadsto 0.5 \cdot \left(\left(\color{blue}{0} + y\right) + \frac{-1 \cdot {z}^{2} + {x}^{2}}{y}\right) \]
      16. +-lft-identity94.7%

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

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

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

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

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

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

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

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

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

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

    if 4.99999999999999976e246 < (*.f64 z z)

    1. Initial program 57.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{{z}^{2}}}{-2 \cdot y} \]
      4. unpow271.8%

        \[\leadsto \frac{\color{blue}{z \cdot z}}{-2 \cdot y} \]
      5. times-frac76.6%

        \[\leadsto \color{blue}{\frac{z}{-2} \cdot \frac{z}{y}} \]
      6. metadata-eval76.6%

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

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

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

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

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

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

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

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

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

Alternative 10: 43.7% accurate, 1.7× speedup?

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

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

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


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

    1. Initial program 70.4%

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

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

    if 1.85e-16 < x

    1. Initial program 74.9%

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

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

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

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

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

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

Alternative 11: 33.7% accurate, 5.0× speedup?

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

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

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

    \[\leadsto \color{blue}{0.5 \cdot y} \]
  3. Final simplification30.7%

    \[\leadsto 0.5 \cdot y \]

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 2023279 
(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)))