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

Percentage Accurate: 69.0% → 90.5%
Time: 11.3s
Alternatives: 8
Speedup: 1.4×

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: 69.0% 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: 90.5% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -6.2 \cdot 10^{+161}:\\ \;\;\;\;0.5 \cdot \left(y - \frac{z}{\frac{y}{z}}\right)\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{+150}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, x, \left(y + z\right) \cdot \left(y - z\right)\right)}{y \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\left(y - z\right) \cdot \frac{y + z}{y}\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -6.2e+161)
   (* 0.5 (- y (/ z (/ y z))))
   (if (<= y 3.2e+150)
     (/ (fma x x (* (+ y z) (- y z))) (* y 2.0))
     (* 0.5 (* (- y z) (/ (+ y z) y))))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -6.2e+161) {
		tmp = 0.5 * (y - (z / (y / z)));
	} else if (y <= 3.2e+150) {
		tmp = fma(x, x, ((y + z) * (y - z))) / (y * 2.0);
	} else {
		tmp = 0.5 * ((y - z) * ((y + z) / y));
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (y <= -6.2e+161)
		tmp = Float64(0.5 * Float64(y - Float64(z / Float64(y / z))));
	elseif (y <= 3.2e+150)
		tmp = Float64(fma(x, x, Float64(Float64(y + z) * Float64(y - z))) / Float64(y * 2.0));
	else
		tmp = Float64(0.5 * Float64(Float64(y - z) * Float64(Float64(y + z) / y)));
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[y, -6.2e+161], N[(0.5 * N[(y - N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.2e+150], N[(N[(x * x + N[(N[(y + z), $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(y - z), $MachinePrecision] * N[(N[(y + z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 3.2 \cdot 10^{+150}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, \left(y + z\right) \cdot \left(y - z\right)\right)}{y \cdot 2}\\

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


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

    1. Initial program 8.8%

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

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

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

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

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

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

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

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

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

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

    if -6.20000000000000013e161 < y < 3.20000000000000016e150

    1. Initial program 91.1%

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y \cdot 2} \]
      3. difference-of-squares93.6%

        \[\leadsto \frac{\mathsf{fma}\left(x, x, \color{blue}{\left(y + z\right) \cdot \left(y - z\right)}\right)}{y \cdot 2} \]
    3. Simplified93.6%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, x, \left(y + z\right) \cdot \left(y - z\right)\right)}{y \cdot 2}} \]

    if 3.20000000000000016e150 < y

    1. Initial program 11.7%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\frac{y + z}{\frac{y}{y - z}}} \]
      5. associate-/r/96.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6.2 \cdot 10^{+161}:\\ \;\;\;\;0.5 \cdot \left(y - \frac{z}{\frac{y}{z}}\right)\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{+150}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, x, \left(y + z\right) \cdot \left(y - z\right)\right)}{y \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\left(y - z\right) \cdot \frac{y + z}{y}\right)\\ \end{array} \]

Alternative 2: 88.1% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -6.20000000000000013e161 or 3.19999999999999999e99 < y

    1. Initial program 20.8%

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

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

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

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

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

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

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

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

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

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

    if -6.20000000000000013e161 < y < 3.19999999999999999e99

    1. Initial program 92.1%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification92.4%

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

Alternative 3: 52.6% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \frac{x}{\frac{y}{x}}\\ t_1 := -0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\ \mathbf{if}\;y \leq -2.35 \cdot 10^{+14}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;y \leq -1.8 \cdot 10^{-48}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -6 \cdot 10^{-179}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.65 \cdot 10^{-206}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{+28}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* 0.5 (/ x (/ y x)))) (t_1 (* -0.5 (* z (/ z y)))))
   (if (<= y -2.35e+14)
     (* y 0.5)
     (if (<= y -1.8e-48)
       t_1
       (if (<= y -6e-179)
         t_0
         (if (<= y -1.65e-206) t_1 (if (<= y 1.25e+28) t_0 (* y 0.5))))))))
double code(double x, double y, double z) {
	double t_0 = 0.5 * (x / (y / x));
	double t_1 = -0.5 * (z * (z / y));
	double tmp;
	if (y <= -2.35e+14) {
		tmp = y * 0.5;
	} else if (y <= -1.8e-48) {
		tmp = t_1;
	} else if (y <= -6e-179) {
		tmp = t_0;
	} else if (y <= -1.65e-206) {
		tmp = t_1;
	} else if (y <= 1.25e+28) {
		tmp = t_0;
	} else {
		tmp = y * 0.5;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 0.5d0 * (x / (y / x))
    t_1 = (-0.5d0) * (z * (z / y))
    if (y <= (-2.35d+14)) then
        tmp = y * 0.5d0
    else if (y <= (-1.8d-48)) then
        tmp = t_1
    else if (y <= (-6d-179)) then
        tmp = t_0
    else if (y <= (-1.65d-206)) then
        tmp = t_1
    else if (y <= 1.25d+28) then
        tmp = t_0
    else
        tmp = y * 0.5d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = 0.5 * (x / (y / x));
	double t_1 = -0.5 * (z * (z / y));
	double tmp;
	if (y <= -2.35e+14) {
		tmp = y * 0.5;
	} else if (y <= -1.8e-48) {
		tmp = t_1;
	} else if (y <= -6e-179) {
		tmp = t_0;
	} else if (y <= -1.65e-206) {
		tmp = t_1;
	} else if (y <= 1.25e+28) {
		tmp = t_0;
	} else {
		tmp = y * 0.5;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 0.5 * (x / (y / x))
	t_1 = -0.5 * (z * (z / y))
	tmp = 0
	if y <= -2.35e+14:
		tmp = y * 0.5
	elif y <= -1.8e-48:
		tmp = t_1
	elif y <= -6e-179:
		tmp = t_0
	elif y <= -1.65e-206:
		tmp = t_1
	elif y <= 1.25e+28:
		tmp = t_0
	else:
		tmp = y * 0.5
	return tmp
function code(x, y, z)
	t_0 = Float64(0.5 * Float64(x / Float64(y / x)))
	t_1 = Float64(-0.5 * Float64(z * Float64(z / y)))
	tmp = 0.0
	if (y <= -2.35e+14)
		tmp = Float64(y * 0.5);
	elseif (y <= -1.8e-48)
		tmp = t_1;
	elseif (y <= -6e-179)
		tmp = t_0;
	elseif (y <= -1.65e-206)
		tmp = t_1;
	elseif (y <= 1.25e+28)
		tmp = t_0;
	else
		tmp = Float64(y * 0.5);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 0.5 * (x / (y / x));
	t_1 = -0.5 * (z * (z / y));
	tmp = 0.0;
	if (y <= -2.35e+14)
		tmp = y * 0.5;
	elseif (y <= -1.8e-48)
		tmp = t_1;
	elseif (y <= -6e-179)
		tmp = t_0;
	elseif (y <= -1.65e-206)
		tmp = t_1;
	elseif (y <= 1.25e+28)
		tmp = t_0;
	else
		tmp = y * 0.5;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(0.5 * N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.5 * N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.35e+14], N[(y * 0.5), $MachinePrecision], If[LessEqual[y, -1.8e-48], t$95$1, If[LessEqual[y, -6e-179], t$95$0, If[LessEqual[y, -1.65e-206], t$95$1, If[LessEqual[y, 1.25e+28], t$95$0, N[(y * 0.5), $MachinePrecision]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -1.8 \cdot 10^{-48}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq -6 \cdot 10^{-179}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq -1.65 \cdot 10^{-206}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 1.25 \cdot 10^{+28}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.35e14 or 1.24999999999999989e28 < y

    1. Initial program 52.2%

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

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

    if -2.35e14 < y < -1.8000000000000001e-48 or -6.00000000000000012e-179 < y < -1.6499999999999999e-206

    1. Initial program 95.0%

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

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

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

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

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

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

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

    if -1.8000000000000001e-48 < y < -6.00000000000000012e-179 or -1.6499999999999999e-206 < y < 1.24999999999999989e28

    1. Initial program 89.5%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.35 \cdot 10^{+14}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;y \leq -1.8 \cdot 10^{-48}:\\ \;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\ \mathbf{elif}\;y \leq -6 \cdot 10^{-179}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{y}{x}}\\ \mathbf{elif}\;y \leq -1.65 \cdot 10^{-206}:\\ \;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{+28}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]

Alternative 4: 52.6% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \frac{x}{\frac{y}{x}}\\ \mathbf{if}\;y \leq -1.26 \cdot 10^{+14}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;y \leq -1.45 \cdot 10^{-48}:\\ \;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\ \mathbf{elif}\;y \leq -1.2 \cdot 10^{-181}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -2 \cdot 10^{-206}:\\ \;\;\;\;-0.5 \cdot \frac{z \cdot z}{y}\\ \mathbf{elif}\;y \leq 4.8 \cdot 10^{+26}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* 0.5 (/ x (/ y x)))))
   (if (<= y -1.26e+14)
     (* y 0.5)
     (if (<= y -1.45e-48)
       (* -0.5 (* z (/ z y)))
       (if (<= y -1.2e-181)
         t_0
         (if (<= y -2e-206)
           (* -0.5 (/ (* z z) y))
           (if (<= y 4.8e+26) t_0 (* y 0.5))))))))
double code(double x, double y, double z) {
	double t_0 = 0.5 * (x / (y / x));
	double tmp;
	if (y <= -1.26e+14) {
		tmp = y * 0.5;
	} else if (y <= -1.45e-48) {
		tmp = -0.5 * (z * (z / y));
	} else if (y <= -1.2e-181) {
		tmp = t_0;
	} else if (y <= -2e-206) {
		tmp = -0.5 * ((z * z) / y);
	} else if (y <= 4.8e+26) {
		tmp = t_0;
	} else {
		tmp = y * 0.5;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 0.5d0 * (x / (y / x))
    if (y <= (-1.26d+14)) then
        tmp = y * 0.5d0
    else if (y <= (-1.45d-48)) then
        tmp = (-0.5d0) * (z * (z / y))
    else if (y <= (-1.2d-181)) then
        tmp = t_0
    else if (y <= (-2d-206)) then
        tmp = (-0.5d0) * ((z * z) / y)
    else if (y <= 4.8d+26) then
        tmp = t_0
    else
        tmp = y * 0.5d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = 0.5 * (x / (y / x));
	double tmp;
	if (y <= -1.26e+14) {
		tmp = y * 0.5;
	} else if (y <= -1.45e-48) {
		tmp = -0.5 * (z * (z / y));
	} else if (y <= -1.2e-181) {
		tmp = t_0;
	} else if (y <= -2e-206) {
		tmp = -0.5 * ((z * z) / y);
	} else if (y <= 4.8e+26) {
		tmp = t_0;
	} else {
		tmp = y * 0.5;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 0.5 * (x / (y / x))
	tmp = 0
	if y <= -1.26e+14:
		tmp = y * 0.5
	elif y <= -1.45e-48:
		tmp = -0.5 * (z * (z / y))
	elif y <= -1.2e-181:
		tmp = t_0
	elif y <= -2e-206:
		tmp = -0.5 * ((z * z) / y)
	elif y <= 4.8e+26:
		tmp = t_0
	else:
		tmp = y * 0.5
	return tmp
function code(x, y, z)
	t_0 = Float64(0.5 * Float64(x / Float64(y / x)))
	tmp = 0.0
	if (y <= -1.26e+14)
		tmp = Float64(y * 0.5);
	elseif (y <= -1.45e-48)
		tmp = Float64(-0.5 * Float64(z * Float64(z / y)));
	elseif (y <= -1.2e-181)
		tmp = t_0;
	elseif (y <= -2e-206)
		tmp = Float64(-0.5 * Float64(Float64(z * z) / y));
	elseif (y <= 4.8e+26)
		tmp = t_0;
	else
		tmp = Float64(y * 0.5);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 0.5 * (x / (y / x));
	tmp = 0.0;
	if (y <= -1.26e+14)
		tmp = y * 0.5;
	elseif (y <= -1.45e-48)
		tmp = -0.5 * (z * (z / y));
	elseif (y <= -1.2e-181)
		tmp = t_0;
	elseif (y <= -2e-206)
		tmp = -0.5 * ((z * z) / y);
	elseif (y <= 4.8e+26)
		tmp = t_0;
	else
		tmp = y * 0.5;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(0.5 * N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.26e+14], N[(y * 0.5), $MachinePrecision], If[LessEqual[y, -1.45e-48], N[(-0.5 * N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -1.2e-181], t$95$0, If[LessEqual[y, -2e-206], N[(-0.5 * N[(N[(z * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.8e+26], t$95$0, N[(y * 0.5), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.5 \cdot \frac{x}{\frac{y}{x}}\\
\mathbf{if}\;y \leq -1.26 \cdot 10^{+14}:\\
\;\;\;\;y \cdot 0.5\\

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

\mathbf{elif}\;y \leq -1.2 \cdot 10^{-181}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;y \leq 4.8 \cdot 10^{+26}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -1.26e14 or 4.80000000000000009e26 < y

    1. Initial program 52.2%

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

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

    if -1.26e14 < y < -1.4500000000000001e-48

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if -1.4500000000000001e-48 < y < -1.2000000000000001e-181 or -2.00000000000000006e-206 < y < 4.80000000000000009e26

    1. Initial program 89.5%

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

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

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

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

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

    if -1.2000000000000001e-181 < y < -2.00000000000000006e-206

    1. Initial program 88.1%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.26 \cdot 10^{+14}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;y \leq -1.45 \cdot 10^{-48}:\\ \;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\ \mathbf{elif}\;y \leq -1.2 \cdot 10^{-181}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{y}{x}}\\ \mathbf{elif}\;y \leq -2 \cdot 10^{-206}:\\ \;\;\;\;-0.5 \cdot \frac{z \cdot z}{y}\\ \mathbf{elif}\;y \leq 4.8 \cdot 10^{+26}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]

Alternative 5: 86.2% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 75.7%

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

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

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

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

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

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

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

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

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

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

    if 2e113 < (*.f64 x x)

    1. Initial program 70.1%

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

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

        \[\leadsto \frac{\color{blue}{x \cdot x} + {y}^{2}}{y \cdot 2} \]
      2. unpow271.1%

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

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

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

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

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

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

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

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

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

Alternative 6: 52.2% accurate, 1.3× speedup?

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

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

\mathbf{elif}\;y \leq 2.2 \cdot 10^{+27}:\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{y}{x}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -7.60000000000000024e-16 or 2.1999999999999999e27 < y

    1. Initial program 55.0%

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

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

    if -7.60000000000000024e-16 < y < 2.1999999999999999e27

    1. Initial program 89.7%

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

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

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

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

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

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

Alternative 7: 72.7% accurate, 1.4× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 8.2000000000000006e169

    1. Initial program 74.7%

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

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

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

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

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

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

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

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

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

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

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

    if 8.2000000000000006e169 < z

    1. Initial program 61.1%

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

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

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

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

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

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

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

Alternative 8: 34.9% accurate, 5.0× speedup?

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

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

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

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

    \[\leadsto y \cdot 0.5 \]

Developer target: 99.9% accurate, 1.0× speedup?

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

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

Reproduce

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