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

Percentage Accurate: 68.9% → 99.8%
Time: 5.8s
Alternatives: 8
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 8 alternatives:

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

Initial Program: 68.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 1.2× speedup?

\[\begin{array}{l} \\ 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 69.6%

    \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
  2. Taylor expanded in y around 0 84.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-out84.7%

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

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

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

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

      \[\leadsto 0.5 \cdot \left(y + \color{blue}{\frac{x + z}{\frac{y}{x - z}}}\right) \]
    6. +-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. Final simplification99.9%

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

Alternative 2: 42.8% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;x \leq 7.2 \cdot 10^{-219}:\\
\;\;\;\;0.5 \cdot y\\

\mathbf{elif}\;x \leq 4 \cdot 10^{-176}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 7.2 \cdot 10^{+41}:\\
\;\;\;\;0.5 \cdot y\\

\mathbf{elif}\;x \leq 1.9 \cdot 10^{+109}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 5.0000000000000003e-293 or 7.19999999999999947e-219 < x < 4e-176 or 7.20000000000000051e41 < x < 1.90000000000000019e109

    1. Initial program 70.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.0000000000000003e-293 < x < 7.19999999999999947e-219 or 4e-176 < x < 7.20000000000000051e41

    1. Initial program 68.2%

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

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

    if 1.90000000000000019e109 < x

    1. Initial program 68.1%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 5 \cdot 10^{-293}:\\ \;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{-219}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-176}:\\ \;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{+41}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{+109}:\\ \;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{y}{x}}\\ \end{array} \]

Alternative 3: 51.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+82}:\\
\;\;\;\;0.5 \cdot y\\

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

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


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

    1. Initial program 68.9%

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

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

    if 1.9999999999999999e82 < (*.f64 x x) < 4.99999999999999983e218

    1. Initial program 80.2%

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

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

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

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

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

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

    if 4.99999999999999983e218 < (*.f64 x x)

    1. Initial program 68.5%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+82}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+218}:\\ \;\;\;\;\frac{z}{\frac{y}{z}} \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{y}{x}}\\ \end{array} \]

Alternative 4: 79.3% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 74.3%

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

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

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

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

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

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

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

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

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

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

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

    if 9.9999999999999992e249 < (*.f64 z z)

    1. Initial program 58.9%

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

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

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

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

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

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

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

Alternative 5: 85.5% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 73.7%

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

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

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

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

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

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

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

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

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

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

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

    if 3.99999999999999993e67 < (*.f64 z z)

    1. Initial program 63.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 85.5% accurate, 1.1× speedup?

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

    1. Initial program 73.7%

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

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

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

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

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

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

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

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

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

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

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

    if 3.99999999999999993e67 < (*.f64 z z)

    1. Initial program 63.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y - z \cdot \color{blue}{\frac{1}{\frac{y}{z}}}\right) \]
      2. un-div-inv82.3%

        \[\leadsto 0.5 \cdot \left(y - \color{blue}{\frac{z}{\frac{y}{z}}}\right) \]
    9. Applied egg-rr82.3%

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

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

Alternative 7: 42.9% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 6.8 \cdot 10^{+99}:\\ \;\;\;\;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 6.8e+99) (* 0.5 y) (* 0.5 (/ x (/ y x)))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= 6.8e+99) {
		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 <= 6.8d+99) 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 <= 6.8e+99) {
		tmp = 0.5 * y;
	} else {
		tmp = 0.5 * (x / (y / x));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= 6.8e+99:
		tmp = 0.5 * y
	else:
		tmp = 0.5 * (x / (y / x))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= 6.8e+99)
		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 <= 6.8e+99)
		tmp = 0.5 * y;
	else
		tmp = 0.5 * (x / (y / x));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, 6.8e+99], 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 6.8 \cdot 10^{+99}:\\
\;\;\;\;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 < 6.79999999999999968e99

    1. Initial program 69.5%

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

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

    if 6.79999999999999968e99 < x

    1. Initial program 70.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 6.8 \cdot 10^{+99}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{y}{x}}\\ \end{array} \]

Alternative 8: 34.3% 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 69.6%

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

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

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