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

Percentage Accurate: 68.5% → 91.0%
Time: 9.4s
Alternatives: 10
Speedup: 0.9×

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

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \cdot z \leq 10^{+271}:\\ \;\;\;\;0.5 \cdot \left(y + \frac{1}{y \cdot \frac{1}{{x}^{2} - {z}^{2}}}\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) 1e+271)
   (* 0.5 (+ y (/ 1.0 (* y (/ 1.0 (- (pow x 2.0) (pow z 2.0)))))))
   (* 0.5 (- y (* z (/ z y))))))
double code(double x, double y, double z) {
	double tmp;
	if ((z * z) <= 1e+271) {
		tmp = 0.5 * (y + (1.0 / (y * (1.0 / (pow(x, 2.0) - pow(z, 2.0))))));
	} 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) <= 1d+271) then
        tmp = 0.5d0 * (y + (1.0d0 / (y * (1.0d0 / ((x ** 2.0d0) - (z ** 2.0d0))))))
    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) <= 1e+271) {
		tmp = 0.5 * (y + (1.0 / (y * (1.0 / (Math.pow(x, 2.0) - Math.pow(z, 2.0))))));
	} else {
		tmp = 0.5 * (y - (z * (z / y)));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z * z) <= 1e+271:
		tmp = 0.5 * (y + (1.0 / (y * (1.0 / (math.pow(x, 2.0) - math.pow(z, 2.0))))))
	else:
		tmp = 0.5 * (y - (z * (z / y)))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (Float64(z * z) <= 1e+271)
		tmp = Float64(0.5 * Float64(y + Float64(1.0 / Float64(y * Float64(1.0 / Float64((x ^ 2.0) - (z ^ 2.0)))))));
	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) <= 1e+271)
		tmp = 0.5 * (y + (1.0 / (y * (1.0 / ((x ^ 2.0) - (z ^ 2.0))))));
	else
		tmp = 0.5 * (y - (z * (z / y)));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 1e+271], N[(0.5 * N[(y + N[(1.0 / N[(y * N[(1.0 / N[(N[Power[x, 2.0], $MachinePrecision] - N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 10^{+271}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{1}{y \cdot \frac{1}{{x}^{2} - {z}^{2}}}\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) < 9.99999999999999953e270

    1. Initial program 71.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified71.8%

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 89.2%

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

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

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

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

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

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

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

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

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

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

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

    if 9.99999999999999953e270 < (*.f64 z z)

    1. Initial program 51.9%

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

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out51.9%

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

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

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

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

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

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in51.9%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified61.9%

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 57.8%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y - \frac{\color{blue}{z \cdot z}}{y}\right) \]
      2. *-un-lft-identity74.9%

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

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

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

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

Alternative 2: 91.1% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \cdot z \leq 10^{+271}:\\ \;\;\;\;0.5 \cdot \left(y + \frac{1}{\frac{y}{{x}^{2} - {z}^{2}}}\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) 1e+271)
   (* 0.5 (+ y (/ 1.0 (/ y (- (pow x 2.0) (pow z 2.0))))))
   (* 0.5 (- y (* z (/ z y))))))
double code(double x, double y, double z) {
	double tmp;
	if ((z * z) <= 1e+271) {
		tmp = 0.5 * (y + (1.0 / (y / (pow(x, 2.0) - pow(z, 2.0)))));
	} 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) <= 1d+271) then
        tmp = 0.5d0 * (y + (1.0d0 / (y / ((x ** 2.0d0) - (z ** 2.0d0)))))
    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) <= 1e+271) {
		tmp = 0.5 * (y + (1.0 / (y / (Math.pow(x, 2.0) - Math.pow(z, 2.0)))));
	} else {
		tmp = 0.5 * (y - (z * (z / y)));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z * z) <= 1e+271:
		tmp = 0.5 * (y + (1.0 / (y / (math.pow(x, 2.0) - math.pow(z, 2.0)))))
	else:
		tmp = 0.5 * (y - (z * (z / y)))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (Float64(z * z) <= 1e+271)
		tmp = Float64(0.5 * Float64(y + Float64(1.0 / Float64(y / Float64((x ^ 2.0) - (z ^ 2.0))))));
	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) <= 1e+271)
		tmp = 0.5 * (y + (1.0 / (y / ((x ^ 2.0) - (z ^ 2.0)))));
	else
		tmp = 0.5 * (y - (z * (z / y)));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 1e+271], N[(0.5 * N[(y + N[(1.0 / N[(y / N[(N[Power[x, 2.0], $MachinePrecision] - N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision]), $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 10^{+271}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{1}{\frac{y}{{x}^{2} - {z}^{2}}}\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) < 9.99999999999999953e270

    1. Initial program 71.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified71.8%

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 89.2%

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

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

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

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

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

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

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

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

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

    if 9.99999999999999953e270 < (*.f64 z z)

    1. Initial program 51.9%

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

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out51.9%

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

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

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

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

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

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in51.9%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified61.9%

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 57.8%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y - \frac{\color{blue}{z \cdot z}}{y}\right) \]
      2. *-un-lft-identity74.9%

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

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

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

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

Alternative 3: 91.2% accurate, 0.1× speedup?

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

    1. Initial program 71.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified71.8%

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 89.2%

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

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

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

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

    if 9.99999999999999953e270 < (*.f64 z z)

    1. Initial program 51.9%

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

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out51.9%

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

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

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

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

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

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in51.9%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified61.9%

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 57.8%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y - \frac{\color{blue}{z \cdot z}}{y}\right) \]
      2. *-un-lft-identity74.9%

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

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

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

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

Alternative 4: 66.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\left(y \cdot y + x \cdot x\right) - z \cdot z}{y \cdot 2}\\ \mathbf{if}\;t\_0 \leq 0:\\ \;\;\;\;0.5 \cdot \left(y - \frac{z}{\frac{y}{z}}\right)\\ \mathbf{elif}\;t\_0 \leq \infty:\\ \;\;\;\;0.5 \cdot \left(y + \frac{{x}^{2}}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(y - z \cdot \frac{z}{y}\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (- (+ (* y y) (* x x)) (* z z)) (* y 2.0))))
   (if (<= t_0 0.0)
     (* 0.5 (- y (/ z (/ y z))))
     (if (<= t_0 INFINITY)
       (* 0.5 (+ y (/ (pow x 2.0) y)))
       (* 0.5 (- y (* z (/ z y))))))))
double code(double x, double y, double z) {
	double t_0 = (((y * y) + (x * x)) - (z * z)) / (y * 2.0);
	double tmp;
	if (t_0 <= 0.0) {
		tmp = 0.5 * (y - (z / (y / z)));
	} else if (t_0 <= ((double) INFINITY)) {
		tmp = 0.5 * (y + (pow(x, 2.0) / y));
	} else {
		tmp = 0.5 * (y - (z * (z / y)));
	}
	return tmp;
}
public static double code(double x, double y, double z) {
	double t_0 = (((y * y) + (x * x)) - (z * z)) / (y * 2.0);
	double tmp;
	if (t_0 <= 0.0) {
		tmp = 0.5 * (y - (z / (y / z)));
	} else if (t_0 <= Double.POSITIVE_INFINITY) {
		tmp = 0.5 * (y + (Math.pow(x, 2.0) / y));
	} else {
		tmp = 0.5 * (y - (z * (z / y)));
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (((y * y) + (x * x)) - (z * z)) / (y * 2.0)
	tmp = 0
	if t_0 <= 0.0:
		tmp = 0.5 * (y - (z / (y / z)))
	elif t_0 <= math.inf:
		tmp = 0.5 * (y + (math.pow(x, 2.0) / y))
	else:
		tmp = 0.5 * (y - (z * (z / y)))
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(Float64(Float64(y * y) + Float64(x * x)) - Float64(z * z)) / Float64(y * 2.0))
	tmp = 0.0
	if (t_0 <= 0.0)
		tmp = Float64(0.5 * Float64(y - Float64(z / Float64(y / z))));
	elseif (t_0 <= Inf)
		tmp = Float64(0.5 * Float64(y + Float64((x ^ 2.0) / y)));
	else
		tmp = Float64(0.5 * Float64(y - Float64(z * Float64(z / y))));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (((y * y) + (x * x)) - (z * z)) / (y * 2.0);
	tmp = 0.0;
	if (t_0 <= 0.0)
		tmp = 0.5 * (y - (z / (y / z)));
	elseif (t_0 <= Inf)
		tmp = 0.5 * (y + ((x ^ 2.0) / y));
	else
		tmp = 0.5 * (y - (z * (z / y)));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(y * y), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(0.5 * N[(y - N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(0.5 * N[(y + N[(N[Power[x, 2.0], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y - N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\left(y \cdot y + x \cdot x\right) - z \cdot z}{y \cdot 2}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;0.5 \cdot \left(y - \frac{z}{\frac{y}{z}}\right)\\

\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;0.5 \cdot \left(y + \frac{{x}^{2}}{y}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < 0.0

    1. Initial program 70.7%

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

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

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

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

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

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

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

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in70.7%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified70.7%

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 86.8%

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \left(y - \color{blue}{\frac{z}{1} \cdot \frac{z}{y}}\right) \]
    11. Step-by-step derivation
      1. /-rgt-identity63.7%

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

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

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

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

    if 0.0 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < +inf.0

    1. Initial program 79.0%

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

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

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

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

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

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

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

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in79.0%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified79.0%

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 90.3%

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

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

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

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

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

    if +inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64)))

    1. Initial program 0.0%

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

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

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

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

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

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

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

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in0.0%

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define24.1%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified24.1%

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 18.2%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y - \frac{\color{blue}{z \cdot z}}{y}\right) \]
      2. *-un-lft-identity45.8%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(y \cdot y + x \cdot x\right) - z \cdot z}{y \cdot 2} \leq 0:\\ \;\;\;\;0.5 \cdot \left(y - \frac{z}{\frac{y}{z}}\right)\\ \mathbf{elif}\;\frac{\left(y \cdot y + x \cdot x\right) - z \cdot z}{y \cdot 2} \leq \infty:\\ \;\;\;\;0.5 \cdot \left(y + \frac{{x}^{2}}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(y - z \cdot \frac{z}{y}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 81.6% accurate, 0.1× speedup?

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

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

\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 y < 1.00000000000000004e154

    1. Initial program 75.3%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define78.5%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified78.5%

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing

    if 1.00000000000000004e154 < y

    1. Initial program 7.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 71.3%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y - \frac{\color{blue}{z \cdot z}}{y}\right) \]
      2. *-un-lft-identity74.0%

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

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

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

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

Alternative 6: 79.2% accurate, 0.7× speedup?

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

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

\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 y < 3.2999999999999999e99

    1. Initial program 75.1%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Add Preprocessing

    if 3.2999999999999999e99 < y

    1. Initial program 27.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 73.2%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y - \frac{\color{blue}{z \cdot z}}{y}\right) \]
      2. *-un-lft-identity73.1%

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

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

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

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

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

Alternative 7: 80.2% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 69.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 91.5%

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

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

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

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

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

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

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

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

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

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

    if 9.9999999999999992e248 < (*.f64 x x)

    1. Initial program 60.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified68.7%

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 69.3%

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

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

        \[\leadsto \color{blue}{\frac{{x}^{2} \cdot 0.5}{y}} \]
      3. associate-*r/69.3%

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

      \[\leadsto \color{blue}{{x}^{2} \cdot \frac{0.5}{y}} \]
    8. Step-by-step derivation
      1. associate-*r/69.3%

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

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{{x}^{2} \cdot 0.5}}} \]
    9. Applied egg-rr69.3%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot 0.5}{y}} \cdot x \]
    11. Applied egg-rr74.8%

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

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

Alternative 8: 44.0% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.42 \cdot 10^{+104}:\\
\;\;\;\;x \cdot \frac{0.5 \cdot x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1.42e104

    1. Initial program 74.9%

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

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out74.9%

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

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

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

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

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

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in74.9%

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 36.0%

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

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

        \[\leadsto \color{blue}{\frac{{x}^{2} \cdot 0.5}{y}} \]
      3. associate-*r/36.0%

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

      \[\leadsto \color{blue}{{x}^{2} \cdot \frac{0.5}{y}} \]
    8. Step-by-step derivation
      1. associate-*r/36.0%

        \[\leadsto \color{blue}{\frac{{x}^{2} \cdot 0.5}{y}} \]
      2. clear-num36.0%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{{x}^{2} \cdot 0.5}}} \]
    9. Applied egg-rr36.0%

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

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

        \[\leadsto \color{blue}{{x}^{2} \cdot \frac{0.5}{y}} \]
      3. pow236.0%

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot 0.5}{y}} \cdot x \]
    11. Applied egg-rr38.1%

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

    if 1.42e104 < y

    1. Initial program 26.1%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define26.1%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified26.1%

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 77.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.42 \cdot 10^{+104}:\\ \;\;\;\;x \cdot \frac{0.5 \cdot x}{y}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot y\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 42.3% accurate, 1.2× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1.42e104

    1. Initial program 74.9%

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

        \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{-\left(-y \cdot 2\right)}} \]
      2. distribute-lft-neg-out74.9%

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

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

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

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

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

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{-\color{blue}{2 \cdot y}} \]
      8. distribute-lft-neg-in74.9%

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 36.0%

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

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

        \[\leadsto \color{blue}{\frac{{x}^{2} \cdot 0.5}{y}} \]
      3. associate-*r/36.0%

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

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

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

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

    if 1.42e104 < y

    1. Initial program 26.1%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
      13. fma-define26.1%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified26.1%

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 77.5%

      \[\leadsto \color{blue}{0.5 \cdot y} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 35.1% 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 66.3%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}{y} \]
    13. fma-define69.1%

      \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
  3. Simplified69.1%

    \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
  4. Add Preprocessing
  5. Taylor expanded in y around inf 32.8%

    \[\leadsto \color{blue}{0.5 \cdot y} \]
  6. Add Preprocessing

Developer Target 1: 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 2024137 
(FPCore (x y z)
  :name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
  :precision binary64

  :alt
  (! :herbie-platform default (- (* y 1/2) (* (* (/ 1/2 y) (+ z x)) (- z x))))

  (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))