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

Percentage Accurate: 69.2% → 99.9%
Time: 11.8s
Alternatives: 10
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 10 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} z = |z|\\ \\ 0.5 \cdot \left(y + \frac{z + x}{y} \cdot \left(x - z\right)\right) \end{array} \]
NOTE: z should be positive before calling this function
(FPCore (x y z) :precision binary64 (* 0.5 (+ y (* (/ (+ z x) y) (- x z)))))
z = abs(z);
double code(double x, double y, double z) {
	return 0.5 * (y + (((z + x) / y) * (x - z)));
}
NOTE: z should be positive before calling this function
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
z = Math.abs(z);
public static double code(double x, double y, double z) {
	return 0.5 * (y + (((z + x) / y) * (x - z)));
}
z = abs(z)
def code(x, y, z):
	return 0.5 * (y + (((z + x) / y) * (x - z)))
z = abs(z)
function code(x, y, z)
	return Float64(0.5 * Float64(y + Float64(Float64(Float64(z + x) / y) * Float64(x - z))))
end
z = abs(z)
function tmp = code(x, y, z)
	tmp = 0.5 * (y + (((z + x) / y) * (x - z)));
end
NOTE: z should be positive before calling this function
code[x_, y_, z_] := N[(0.5 * N[(y + N[(N[(N[(z + x), $MachinePrecision] / y), $MachinePrecision] * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z = |z|\\
\\
0.5 \cdot \left(y + \frac{z + x}{y} \cdot \left(x - z\right)\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. +-lft-identity85.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \left(y + \frac{\color{blue}{z + x}}{\frac{y}{x - z}}\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. associate-/r/99.9%

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

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

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

Alternative 2: 52.2% accurate, 0.5× speedup?

\[\begin{array}{l} z = |z|\\ \\ \begin{array}{l} \mathbf{if}\;z \cdot z \leq 4 \cdot 10^{-62}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{x}{y}\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}:\\ \;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\ \end{array} \end{array} \]
NOTE: z should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (<= (* z z) 4e-62)
   (* 0.5 (* x (/ x y)))
   (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)))))))
z = abs(z);
double code(double x, double y, double z) {
	double tmp;
	if ((z * z) <= 4e-62) {
		tmp = 0.5 * (x * (x / y));
	} 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;
}
NOTE: z should be positive before calling this function
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 = 0.5d0 * (x * (x / y))
    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
z = Math.abs(z);
public static double code(double x, double y, double z) {
	double tmp;
	if ((z * z) <= 4e-62) {
		tmp = 0.5 * (x * (x / y));
	} 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;
}
z = abs(z)
def code(x, y, z):
	tmp = 0
	if (z * z) <= 4e-62:
		tmp = 0.5 * (x * (x / y))
	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
z = abs(z)
function code(x, y, z)
	tmp = 0.0
	if (Float64(z * z) <= 4e-62)
		tmp = Float64(0.5 * Float64(x * Float64(x / y)));
	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(Float64(z * Float64(z / y)) * -0.5);
	end
	return tmp
end
z = abs(z)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z * z) <= 4e-62)
		tmp = 0.5 * (x * (x / y));
	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
NOTE: z should be positive before calling this function
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 4e-62], N[(0.5 * N[(x * N[(x / y), $MachinePrecision]), $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[(N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]]]]]]
\begin{array}{l}
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 4 \cdot 10^{-62}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{x}{y}\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}:\\
\;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -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 \color{blue}{0.5 \cdot \frac{{x}^{2}}{y}} \]
    3. Step-by-step derivation
      1. unpow255.4%

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{x}{y} \cdot x\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. *-commutative66.5%

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

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

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

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

        \[\leadsto \color{blue}{-0.5 \cdot \frac{z}{\frac{y}{z}}} \]
      2. clear-num66.7%

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

        \[\leadsto \color{blue}{\frac{-0.5}{\frac{\frac{y}{z}}{z}}} \]
      4. associate-/l/66.5%

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

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

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

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

    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. *-commutative66.9%

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

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

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

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

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

Alternative 3: 52.2% accurate, 0.5× speedup?

\[\begin{array}{l} z = |z|\\ \\ \begin{array}{l} \mathbf{if}\;z \cdot z \leq 4 \cdot 10^{-62}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{x}{y}\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}{z}} \cdot -0.5\\ \end{array} \end{array} \]
NOTE: z should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (<= (* z z) 4e-62)
   (* 0.5 (* x (/ x y)))
   (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 z)) -0.5)))))))
z = abs(z);
double code(double x, double y, double z) {
	double tmp;
	if ((z * z) <= 4e-62) {
		tmp = 0.5 * (x * (x / y));
	} 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 / z)) * -0.5;
	}
	return tmp;
}
NOTE: z should be positive before calling this function
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 = 0.5d0 * (x * (x / y))
    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 / z)) * (-0.5d0)
    end if
    code = tmp
end function
z = Math.abs(z);
public static double code(double x, double y, double z) {
	double tmp;
	if ((z * z) <= 4e-62) {
		tmp = 0.5 * (x * (x / y));
	} 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 / z)) * -0.5;
	}
	return tmp;
}
z = abs(z)
def code(x, y, z):
	tmp = 0
	if (z * z) <= 4e-62:
		tmp = 0.5 * (x * (x / y))
	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 / z)) * -0.5
	return tmp
z = abs(z)
function code(x, y, z)
	tmp = 0.0
	if (Float64(z * z) <= 4e-62)
		tmp = Float64(0.5 * Float64(x * Float64(x / y)));
	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(Float64(z / Float64(y / z)) * -0.5);
	end
	return tmp
end
z = abs(z)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z * z) <= 4e-62)
		tmp = 0.5 * (x * (x / y));
	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 / z)) * -0.5;
	end
	tmp_2 = tmp;
end
NOTE: z should be positive before calling this function
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 4e-62], N[(0.5 * N[(x * N[(x / y), $MachinePrecision]), $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[(N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]]]]]]
\begin{array}{l}
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 4 \cdot 10^{-62}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{x}{y}\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}{z}} \cdot -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 \color{blue}{0.5 \cdot \frac{{x}^{2}}{y}} \]
    3. Step-by-step derivation
      1. unpow255.4%

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{x}{y} \cdot x\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. *-commutative66.5%

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

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

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

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

        \[\leadsto \color{blue}{-0.5 \cdot \frac{z}{\frac{y}{z}}} \]
      2. clear-num66.7%

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

        \[\leadsto \color{blue}{\frac{-0.5}{\frac{\frac{y}{z}}{z}}} \]
      4. associate-/l/66.5%

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

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

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

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

    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. *-commutative66.9%

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

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

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

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

Alternative 4: 85.1% accurate, 0.6× speedup?

\[\begin{array}{l} z = |z|\\ \\ \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 \left(\frac{z + x}{y} \cdot \left(x - z\right)\right)\\ \end{array} \end{array} \]
NOTE: z should be positive before calling this function
(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))))))
z = abs(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;
}
NOTE: z should be positive before calling this function
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
z = Math.abs(z);
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;
}
z = abs(z)
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
z = abs(z)
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(Float64(z + x) / y) * Float64(x - z)));
	end
	return tmp
end
z = abs(z)
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
NOTE: z should be positive before calling this function
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[(N[(z + x), $MachinePrecision] / y), $MachinePrecision] * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
z = |z|\\
\\
\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 \left(\frac{z + x}{y} \cdot \left(x - z\right)\right)\\


\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. +-lft-identity93.3%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y + \frac{x \cdot x - \color{blue}{z \cdot z}}{y}\right) \]
      13. difference-of-squares93.3%

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

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

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

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

      \[\leadsto 0.5 \cdot \left(y + \color{blue}{\frac{{x}^{2}}{y}}\right) \]
    6. 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) \]
    7. 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. sub-neg84.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\frac{x + z}{\frac{y}{x - z}}} \]
      15. +-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}}} \]
    5. Step-by-step derivation
      1. associate-/r/100.0%

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

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

Alternative 5: 51.7% accurate, 0.7× speedup?

\[\begin{array}{l} z = |z|\\ \\ \begin{array}{l} t_0 := 0.5 \cdot \left(x \cdot \frac{x}{y}\right)\\ \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}:\\ \;\;\;\;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):\\ \;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot y\\ \end{array} \end{array} \]
NOTE: z should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* 0.5 (* x (/ x y)))))
   (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)
             (* 0.5 (/ x (/ y x)))
             (if (or (<= z 1.22e+57) (not (<= z 1.85e+95)))
               (* (* z (/ z y)) -0.5)
               (* 0.5 y)))))))))
z = abs(z);
double code(double x, double y, double z) {
	double t_0 = 0.5 * (x * (x / y));
	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 = 0.5 * (x / (y / x));
	} else if ((z <= 1.22e+57) || !(z <= 1.85e+95)) {
		tmp = (z * (z / y)) * -0.5;
	} else {
		tmp = 0.5 * y;
	}
	return tmp;
}
NOTE: z should be positive before calling this function
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 * (x / y))
    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 = 0.5d0 * (x / (y / x))
    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
z = Math.abs(z);
public static double code(double x, double y, double z) {
	double t_0 = 0.5 * (x * (x / y));
	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 = 0.5 * (x / (y / x));
	} else if ((z <= 1.22e+57) || !(z <= 1.85e+95)) {
		tmp = (z * (z / y)) * -0.5;
	} else {
		tmp = 0.5 * y;
	}
	return tmp;
}
z = abs(z)
def code(x, y, z):
	t_0 = 0.5 * (x * (x / y))
	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 = 0.5 * (x / (y / x))
	elif (z <= 1.22e+57) or not (z <= 1.85e+95):
		tmp = (z * (z / y)) * -0.5
	else:
		tmp = 0.5 * y
	return tmp
z = abs(z)
function code(x, y, z)
	t_0 = Float64(0.5 * Float64(x * Float64(x / y)))
	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 = Float64(0.5 * Float64(x / Float64(y / x)));
	elseif ((z <= 1.22e+57) || !(z <= 1.85e+95))
		tmp = Float64(Float64(z * Float64(z / y)) * -0.5);
	else
		tmp = Float64(0.5 * y);
	end
	return tmp
end
z = abs(z)
function tmp_2 = code(x, y, z)
	t_0 = 0.5 * (x * (x / y));
	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 = 0.5 * (x / (y / x));
	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
NOTE: z should be positive before calling this function
code[x_, y_, z_] := Block[{t$95$0 = N[(0.5 * N[(x * N[(x / y), $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], N[(0.5 * N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, 1.22e+57], N[Not[LessEqual[z, 1.85e+95]], $MachinePrecision]], N[(N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]]]]]]]
\begin{array}{l}
z = |z|\\
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(x \cdot \frac{x}{y}\right)\\
\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}:\\
\;\;\;\;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):\\
\;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\

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


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

    1. Initial program 75.5%

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

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

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

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

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

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

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

    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 6.6000000000000003e-18 < z < 7.2e21

    1. Initial program 69.3%

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

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

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

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

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

    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. *-commutative62.7%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 1.75 \cdot 10^{-253}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{x}{y}\right)\\ \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 \left(x \cdot \frac{x}{y}\right)\\ \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):\\ \;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot y\\ \end{array} \]

Alternative 6: 84.3% accurate, 0.7× speedup?

\[\begin{array}{l} z = |z|\\ \\ \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} \]
NOTE: z should be positive before calling this function
(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))))))
z = abs(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;
}
NOTE: z should be positive before calling this function
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
z = Math.abs(z);
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;
}
z = abs(z)
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
z = abs(z)
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
z = abs(z)
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
NOTE: z should be positive before calling this function
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}
z = |z|\\
\\
\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. +-lft-identity93.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \left(y + \color{blue}{\frac{{x}^{2}}{y}}\right) \]
    6. 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) \]
    7. 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 7: 80.2% accurate, 1.1× speedup?

\[\begin{array}{l} z = |z|\\ \\ \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}:\\ \;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\ \end{array} \end{array} \]
NOTE: z should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (<= (* z z) 5e+246) (* 0.5 (+ y (* x (/ x y)))) (* (* z (/ z y)) -0.5)))
z = abs(z);
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;
}
NOTE: z should be positive before calling this function
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
z = Math.abs(z);
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;
}
z = abs(z)
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
z = abs(z)
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(Float64(z * Float64(z / y)) * -0.5);
	end
	return tmp
end
z = abs(z)
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
NOTE: z should be positive before calling this function
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[(N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
z = |z|\\
\\
\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}:\\
\;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -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. +-lft-identity94.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y + \frac{x \cdot x - \color{blue}{z \cdot z}}{y}\right) \]
      13. difference-of-squares94.7%

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

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

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

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

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

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

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

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

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

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

Alternative 8: 43.7% accurate, 1.7× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.94999999999999989e-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.94999999999999989e-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}}} \]
    5. Step-by-step derivation
      1. associate-/r/61.9%

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

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

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

Alternative 9: 43.7% accurate, 1.7× speedup?

\[\begin{array}{l} z = |z|\\ \\ \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} \]
NOTE: z should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (<= x 1.85e-16) (* 0.5 y) (* 0.5 (/ x (/ y x)))))
z = abs(z);
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;
}
NOTE: z should be positive before calling this function
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
z = Math.abs(z);
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;
}
z = abs(z)
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
z = abs(z)
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
z = abs(z)
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
NOTE: z should be positive before calling this function
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}
z = |z|\\
\\
\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 10: 33.7% accurate, 5.0× speedup?

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