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

Percentage Accurate: 69.0% → 99.9%
Time: 9.8s
Alternatives: 7
Speedup: 1.2×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 7 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: 99.9% accurate, 1.2× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ z_m = \left|z\right| \\ 0.5 \cdot \left(y + \left(z\_m + x\_m\right) \cdot \frac{x\_m - z\_m}{y}\right) \end{array} \]
x_m = (fabs.f64 x)
z_m = (fabs.f64 z)
(FPCore (x_m y z_m)
 :precision binary64
 (* 0.5 (+ y (* (+ z_m x_m) (/ (- x_m z_m) y)))))
x_m = fabs(x);
z_m = fabs(z);
double code(double x_m, double y, double z_m) {
	return 0.5 * (y + ((z_m + x_m) * ((x_m - z_m) / y)));
}
x_m = abs(x)
z_m = abs(z)
real(8) function code(x_m, y, z_m)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    code = 0.5d0 * (y + ((z_m + x_m) * ((x_m - z_m) / y)))
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
public static double code(double x_m, double y, double z_m) {
	return 0.5 * (y + ((z_m + x_m) * ((x_m - z_m) / y)));
}
x_m = math.fabs(x)
z_m = math.fabs(z)
def code(x_m, y, z_m):
	return 0.5 * (y + ((z_m + x_m) * ((x_m - z_m) / y)))
x_m = abs(x)
z_m = abs(z)
function code(x_m, y, z_m)
	return Float64(0.5 * Float64(y + Float64(Float64(z_m + x_m) * Float64(Float64(x_m - z_m) / y))))
end
x_m = abs(x);
z_m = abs(z);
function tmp = code(x_m, y, z_m)
	tmp = 0.5 * (y + ((z_m + x_m) * ((x_m - z_m) / y)));
end
x_m = N[Abs[x], $MachinePrecision]
z_m = N[Abs[z], $MachinePrecision]
code[x$95$m_, y_, z$95$m_] := N[(0.5 * N[(y + N[(N[(z$95$m + x$95$m), $MachinePrecision] * N[(N[(x$95$m - z$95$m), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|

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

    \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
  2. Step-by-step derivation
    1. remove-double-neg74.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-out74.6%

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

      \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
    4. distribute-frac-neg74.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-174.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-out74.6%

      \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
    7. *-commutative74.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-in74.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-frac74.6%

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

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

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

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

      \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
  3. Simplified76.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 83.0%

    \[\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+83.0%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 0.5 \cdot \color{blue}{\mathsf{fma}\left(1, y, \left(x + z\right) \cdot \frac{x - z}{y}\right)} \]
  12. Step-by-step derivation
    1. fma-undefine99.9%

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

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

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

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

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

Alternative 2: 85.4% accurate, 0.7× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;z\_m \leq 3400:\\ \;\;\;\;0.5 \cdot \left(y + \left(z\_m + x\_m\right) \cdot \frac{x\_m}{y}\right)\\ \mathbf{elif}\;z\_m \leq 7.2 \cdot 10^{+94}:\\ \;\;\;\;0.5 \cdot \left(\left(z\_m + x\_m\right) \cdot \frac{x\_m - z\_m}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(y - z\_m \cdot \frac{z\_m}{y}\right)\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
z_m = (fabs.f64 z)
(FPCore (x_m y z_m)
 :precision binary64
 (if (<= z_m 3400.0)
   (* 0.5 (+ y (* (+ z_m x_m) (/ x_m y))))
   (if (<= z_m 7.2e+94)
     (* 0.5 (* (+ z_m x_m) (/ (- x_m z_m) y)))
     (* 0.5 (- y (* z_m (/ z_m y)))))))
x_m = fabs(x);
z_m = fabs(z);
double code(double x_m, double y, double z_m) {
	double tmp;
	if (z_m <= 3400.0) {
		tmp = 0.5 * (y + ((z_m + x_m) * (x_m / y)));
	} else if (z_m <= 7.2e+94) {
		tmp = 0.5 * ((z_m + x_m) * ((x_m - z_m) / y));
	} else {
		tmp = 0.5 * (y - (z_m * (z_m / y)));
	}
	return tmp;
}
x_m = abs(x)
z_m = abs(z)
real(8) function code(x_m, y, z_m)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if (z_m <= 3400.0d0) then
        tmp = 0.5d0 * (y + ((z_m + x_m) * (x_m / y)))
    else if (z_m <= 7.2d+94) then
        tmp = 0.5d0 * ((z_m + x_m) * ((x_m - z_m) / y))
    else
        tmp = 0.5d0 * (y - (z_m * (z_m / y)))
    end if
    code = tmp
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
public static double code(double x_m, double y, double z_m) {
	double tmp;
	if (z_m <= 3400.0) {
		tmp = 0.5 * (y + ((z_m + x_m) * (x_m / y)));
	} else if (z_m <= 7.2e+94) {
		tmp = 0.5 * ((z_m + x_m) * ((x_m - z_m) / y));
	} else {
		tmp = 0.5 * (y - (z_m * (z_m / y)));
	}
	return tmp;
}
x_m = math.fabs(x)
z_m = math.fabs(z)
def code(x_m, y, z_m):
	tmp = 0
	if z_m <= 3400.0:
		tmp = 0.5 * (y + ((z_m + x_m) * (x_m / y)))
	elif z_m <= 7.2e+94:
		tmp = 0.5 * ((z_m + x_m) * ((x_m - z_m) / y))
	else:
		tmp = 0.5 * (y - (z_m * (z_m / y)))
	return tmp
x_m = abs(x)
z_m = abs(z)
function code(x_m, y, z_m)
	tmp = 0.0
	if (z_m <= 3400.0)
		tmp = Float64(0.5 * Float64(y + Float64(Float64(z_m + x_m) * Float64(x_m / y))));
	elseif (z_m <= 7.2e+94)
		tmp = Float64(0.5 * Float64(Float64(z_m + x_m) * Float64(Float64(x_m - z_m) / y)));
	else
		tmp = Float64(0.5 * Float64(y - Float64(z_m * Float64(z_m / y))));
	end
	return tmp
end
x_m = abs(x);
z_m = abs(z);
function tmp_2 = code(x_m, y, z_m)
	tmp = 0.0;
	if (z_m <= 3400.0)
		tmp = 0.5 * (y + ((z_m + x_m) * (x_m / y)));
	elseif (z_m <= 7.2e+94)
		tmp = 0.5 * ((z_m + x_m) * ((x_m - z_m) / y));
	else
		tmp = 0.5 * (y - (z_m * (z_m / y)));
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
z_m = N[Abs[z], $MachinePrecision]
code[x$95$m_, y_, z$95$m_] := If[LessEqual[z$95$m, 3400.0], N[(0.5 * N[(y + N[(N[(z$95$m + x$95$m), $MachinePrecision] * N[(x$95$m / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z$95$m, 7.2e+94], N[(0.5 * N[(N[(z$95$m + x$95$m), $MachinePrecision] * N[(N[(x$95$m - z$95$m), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y - N[(z$95$m * N[(z$95$m / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|

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

\mathbf{elif}\;z\_m \leq 7.2 \cdot 10^{+94}:\\
\;\;\;\;0.5 \cdot \left(\left(z\_m + x\_m\right) \cdot \frac{x\_m - z\_m}{y}\right)\\

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


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

    1. Initial program 73.4%

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

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

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

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

        \[\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-173.4%

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified74.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 86.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\mathsf{fma}\left(1, y, \left(x + z\right) \cdot \frac{x - z}{y}\right)} \]
    12. Step-by-step derivation
      1. fma-undefine99.9%

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

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

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

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

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

    if 3400 < z < 7.19999999999999985e94

    1. Initial program 94.8%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg94.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-out94.8%

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

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg94.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-194.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-out94.8%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative94.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-in94.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-frac94.8%

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified94.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 88.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+88.8%

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

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

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

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

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

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

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

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

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

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

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

    if 7.19999999999999985e94 < z

    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-define79.8%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified79.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 73.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 76.3% accurate, 0.9× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;y \leq 3.2 \cdot 10^{+58}:\\ \;\;\;\;0.5 \cdot \left(\left(z\_m + x\_m\right) \cdot \frac{x\_m - z\_m}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(y - z\_m \cdot \frac{z\_m}{y}\right)\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
z_m = (fabs.f64 z)
(FPCore (x_m y z_m)
 :precision binary64
 (if (<= y 3.2e+58)
   (* 0.5 (* (+ z_m x_m) (/ (- x_m z_m) y)))
   (* 0.5 (- y (* z_m (/ z_m y))))))
x_m = fabs(x);
z_m = fabs(z);
double code(double x_m, double y, double z_m) {
	double tmp;
	if (y <= 3.2e+58) {
		tmp = 0.5 * ((z_m + x_m) * ((x_m - z_m) / y));
	} else {
		tmp = 0.5 * (y - (z_m * (z_m / y)));
	}
	return tmp;
}
x_m = abs(x)
z_m = abs(z)
real(8) function code(x_m, y, z_m)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if (y <= 3.2d+58) then
        tmp = 0.5d0 * ((z_m + x_m) * ((x_m - z_m) / y))
    else
        tmp = 0.5d0 * (y - (z_m * (z_m / y)))
    end if
    code = tmp
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
public static double code(double x_m, double y, double z_m) {
	double tmp;
	if (y <= 3.2e+58) {
		tmp = 0.5 * ((z_m + x_m) * ((x_m - z_m) / y));
	} else {
		tmp = 0.5 * (y - (z_m * (z_m / y)));
	}
	return tmp;
}
x_m = math.fabs(x)
z_m = math.fabs(z)
def code(x_m, y, z_m):
	tmp = 0
	if y <= 3.2e+58:
		tmp = 0.5 * ((z_m + x_m) * ((x_m - z_m) / y))
	else:
		tmp = 0.5 * (y - (z_m * (z_m / y)))
	return tmp
x_m = abs(x)
z_m = abs(z)
function code(x_m, y, z_m)
	tmp = 0.0
	if (y <= 3.2e+58)
		tmp = Float64(0.5 * Float64(Float64(z_m + x_m) * Float64(Float64(x_m - z_m) / y)));
	else
		tmp = Float64(0.5 * Float64(y - Float64(z_m * Float64(z_m / y))));
	end
	return tmp
end
x_m = abs(x);
z_m = abs(z);
function tmp_2 = code(x_m, y, z_m)
	tmp = 0.0;
	if (y <= 3.2e+58)
		tmp = 0.5 * ((z_m + x_m) * ((x_m - z_m) / y));
	else
		tmp = 0.5 * (y - (z_m * (z_m / y)));
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
z_m = N[Abs[z], $MachinePrecision]
code[x$95$m_, y_, z$95$m_] := If[LessEqual[y, 3.2e+58], N[(0.5 * N[(N[(z$95$m + x$95$m), $MachinePrecision] * N[(N[(x$95$m - z$95$m), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y - N[(z$95$m * N[(z$95$m / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|

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

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


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

    1. Initial program 81.4%

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

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

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

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

        \[\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-181.4%

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified84.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 83.6%

      \[\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+83.6%

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

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

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

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

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

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

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

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

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

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

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

    if 3.20000000000000015e58 < y

    1. Initial program 40.6%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg40.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-out40.6%

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

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg40.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-140.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-out40.6%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative40.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-in40.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-frac40.6%

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified40.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 32.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 43.9% accurate, 1.1× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;y \leq 2.6 \cdot 10^{+70}:\\ \;\;\;\;0.5 \cdot \left(\left(z\_m + x\_m\right) \cdot \frac{x\_m}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot y\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
z_m = (fabs.f64 z)
(FPCore (x_m y z_m)
 :precision binary64
 (if (<= y 2.6e+70) (* 0.5 (* (+ z_m x_m) (/ x_m y))) (* 0.5 y)))
x_m = fabs(x);
z_m = fabs(z);
double code(double x_m, double y, double z_m) {
	double tmp;
	if (y <= 2.6e+70) {
		tmp = 0.5 * ((z_m + x_m) * (x_m / y));
	} else {
		tmp = 0.5 * y;
	}
	return tmp;
}
x_m = abs(x)
z_m = abs(z)
real(8) function code(x_m, y, z_m)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if (y <= 2.6d+70) then
        tmp = 0.5d0 * ((z_m + x_m) * (x_m / y))
    else
        tmp = 0.5d0 * y
    end if
    code = tmp
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
public static double code(double x_m, double y, double z_m) {
	double tmp;
	if (y <= 2.6e+70) {
		tmp = 0.5 * ((z_m + x_m) * (x_m / y));
	} else {
		tmp = 0.5 * y;
	}
	return tmp;
}
x_m = math.fabs(x)
z_m = math.fabs(z)
def code(x_m, y, z_m):
	tmp = 0
	if y <= 2.6e+70:
		tmp = 0.5 * ((z_m + x_m) * (x_m / y))
	else:
		tmp = 0.5 * y
	return tmp
x_m = abs(x)
z_m = abs(z)
function code(x_m, y, z_m)
	tmp = 0.0
	if (y <= 2.6e+70)
		tmp = Float64(0.5 * Float64(Float64(z_m + x_m) * Float64(x_m / y)));
	else
		tmp = Float64(0.5 * y);
	end
	return tmp
end
x_m = abs(x);
z_m = abs(z);
function tmp_2 = code(x_m, y, z_m)
	tmp = 0.0;
	if (y <= 2.6e+70)
		tmp = 0.5 * ((z_m + x_m) * (x_m / y));
	else
		tmp = 0.5 * y;
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
z_m = N[Abs[z], $MachinePrecision]
code[x$95$m_, y_, z$95$m_] := If[LessEqual[y, 2.6e+70], N[(0.5 * N[(N[(z$95$m + x$95$m), $MachinePrecision] * N[(x$95$m / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|

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

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


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

    1. Initial program 81.5%

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

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

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

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

        \[\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-181.5%

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified84.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 83.7%

      \[\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+83.7%

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.6e70 < y

    1. Initial program 39.2%

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

      \[\leadsto \color{blue}{0.5 \cdot y} \]
    4. Step-by-step derivation
      1. *-commutative74.1%

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified74.1%

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

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

Alternative 5: 80.4% accurate, 1.1× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;x\_m \leq 3.2 \cdot 10^{+150}:\\ \;\;\;\;0.5 \cdot \left(y - z\_m \cdot \frac{z\_m}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\left(z\_m + x\_m\right) \cdot \frac{x\_m}{y}\right)\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
z_m = (fabs.f64 z)
(FPCore (x_m y z_m)
 :precision binary64
 (if (<= x_m 3.2e+150)
   (* 0.5 (- y (* z_m (/ z_m y))))
   (* 0.5 (* (+ z_m x_m) (/ x_m y)))))
x_m = fabs(x);
z_m = fabs(z);
double code(double x_m, double y, double z_m) {
	double tmp;
	if (x_m <= 3.2e+150) {
		tmp = 0.5 * (y - (z_m * (z_m / y)));
	} else {
		tmp = 0.5 * ((z_m + x_m) * (x_m / y));
	}
	return tmp;
}
x_m = abs(x)
z_m = abs(z)
real(8) function code(x_m, y, z_m)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if (x_m <= 3.2d+150) then
        tmp = 0.5d0 * (y - (z_m * (z_m / y)))
    else
        tmp = 0.5d0 * ((z_m + x_m) * (x_m / y))
    end if
    code = tmp
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
public static double code(double x_m, double y, double z_m) {
	double tmp;
	if (x_m <= 3.2e+150) {
		tmp = 0.5 * (y - (z_m * (z_m / y)));
	} else {
		tmp = 0.5 * ((z_m + x_m) * (x_m / y));
	}
	return tmp;
}
x_m = math.fabs(x)
z_m = math.fabs(z)
def code(x_m, y, z_m):
	tmp = 0
	if x_m <= 3.2e+150:
		tmp = 0.5 * (y - (z_m * (z_m / y)))
	else:
		tmp = 0.5 * ((z_m + x_m) * (x_m / y))
	return tmp
x_m = abs(x)
z_m = abs(z)
function code(x_m, y, z_m)
	tmp = 0.0
	if (x_m <= 3.2e+150)
		tmp = Float64(0.5 * Float64(y - Float64(z_m * Float64(z_m / y))));
	else
		tmp = Float64(0.5 * Float64(Float64(z_m + x_m) * Float64(x_m / y)));
	end
	return tmp
end
x_m = abs(x);
z_m = abs(z);
function tmp_2 = code(x_m, y, z_m)
	tmp = 0.0;
	if (x_m <= 3.2e+150)
		tmp = 0.5 * (y - (z_m * (z_m / y)));
	else
		tmp = 0.5 * ((z_m + x_m) * (x_m / y));
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
z_m = N[Abs[z], $MachinePrecision]
code[x$95$m_, y_, z$95$m_] := If[LessEqual[x$95$m, 3.2e+150], N[(0.5 * N[(y - N[(z$95$m * N[(z$95$m / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(z$95$m + x$95$m), $MachinePrecision] * N[(x$95$m / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 3.20000000000000016e150

    1. Initial program 78.4%

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

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

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

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

        \[\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-178.4%

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified78.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 51.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.20000000000000016e150 < x

    1. Initial program 49.3%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg49.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-out49.3%

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

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg49.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-149.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-out49.3%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative49.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-in49.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-frac49.3%

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified64.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 46.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+46.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 80.4% accurate, 1.1× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;x\_m \leq 1.7 \cdot 10^{+150}:\\ \;\;\;\;0.5 \cdot \left(y - \frac{z\_m}{\frac{y}{z\_m}}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\left(z\_m + x\_m\right) \cdot \frac{x\_m}{y}\right)\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
z_m = (fabs.f64 z)
(FPCore (x_m y z_m)
 :precision binary64
 (if (<= x_m 1.7e+150)
   (* 0.5 (- y (/ z_m (/ y z_m))))
   (* 0.5 (* (+ z_m x_m) (/ x_m y)))))
x_m = fabs(x);
z_m = fabs(z);
double code(double x_m, double y, double z_m) {
	double tmp;
	if (x_m <= 1.7e+150) {
		tmp = 0.5 * (y - (z_m / (y / z_m)));
	} else {
		tmp = 0.5 * ((z_m + x_m) * (x_m / y));
	}
	return tmp;
}
x_m = abs(x)
z_m = abs(z)
real(8) function code(x_m, y, z_m)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if (x_m <= 1.7d+150) then
        tmp = 0.5d0 * (y - (z_m / (y / z_m)))
    else
        tmp = 0.5d0 * ((z_m + x_m) * (x_m / y))
    end if
    code = tmp
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
public static double code(double x_m, double y, double z_m) {
	double tmp;
	if (x_m <= 1.7e+150) {
		tmp = 0.5 * (y - (z_m / (y / z_m)));
	} else {
		tmp = 0.5 * ((z_m + x_m) * (x_m / y));
	}
	return tmp;
}
x_m = math.fabs(x)
z_m = math.fabs(z)
def code(x_m, y, z_m):
	tmp = 0
	if x_m <= 1.7e+150:
		tmp = 0.5 * (y - (z_m / (y / z_m)))
	else:
		tmp = 0.5 * ((z_m + x_m) * (x_m / y))
	return tmp
x_m = abs(x)
z_m = abs(z)
function code(x_m, y, z_m)
	tmp = 0.0
	if (x_m <= 1.7e+150)
		tmp = Float64(0.5 * Float64(y - Float64(z_m / Float64(y / z_m))));
	else
		tmp = Float64(0.5 * Float64(Float64(z_m + x_m) * Float64(x_m / y)));
	end
	return tmp
end
x_m = abs(x);
z_m = abs(z);
function tmp_2 = code(x_m, y, z_m)
	tmp = 0.0;
	if (x_m <= 1.7e+150)
		tmp = 0.5 * (y - (z_m / (y / z_m)));
	else
		tmp = 0.5 * ((z_m + x_m) * (x_m / y));
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
z_m = N[Abs[z], $MachinePrecision]
code[x$95$m_, y_, z$95$m_] := If[LessEqual[x$95$m, 1.7e+150], N[(0.5 * N[(y - N[(z$95$m / N[(y / z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(z$95$m + x$95$m), $MachinePrecision] * N[(x$95$m / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.69999999999999991e150

    1. Initial program 78.4%

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

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

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

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

        \[\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-178.4%

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified78.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 51.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.69999999999999991e150 < x

    1. Initial program 49.3%

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Step-by-step derivation
      1. remove-double-neg49.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-out49.3%

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

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg49.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-149.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-out49.3%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative49.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-in49.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-frac49.3%

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}}{y} \]
    3. Simplified64.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 46.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+46.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 34.8% accurate, 5.0× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ z_m = \left|z\right| \\ 0.5 \cdot y \end{array} \]
x_m = (fabs.f64 x)
z_m = (fabs.f64 z)
(FPCore (x_m y z_m) :precision binary64 (* 0.5 y))
x_m = fabs(x);
z_m = fabs(z);
double code(double x_m, double y, double z_m) {
	return 0.5 * y;
}
x_m = abs(x)
z_m = abs(z)
real(8) function code(x_m, y, z_m)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    code = 0.5d0 * y
end function
x_m = Math.abs(x);
z_m = Math.abs(z);
public static double code(double x_m, double y, double z_m) {
	return 0.5 * y;
}
x_m = math.fabs(x)
z_m = math.fabs(z)
def code(x_m, y, z_m):
	return 0.5 * y
x_m = abs(x)
z_m = abs(z)
function code(x_m, y, z_m)
	return Float64(0.5 * y)
end
x_m = abs(x);
z_m = abs(z);
function tmp = code(x_m, y, z_m)
	tmp = 0.5 * y;
end
x_m = N[Abs[x], $MachinePrecision]
z_m = N[Abs[z], $MachinePrecision]
code[x$95$m_, y_, z$95$m_] := N[(0.5 * y), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
z_m = \left|z\right|

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

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

    \[\leadsto \color{blue}{0.5 \cdot y} \]
  4. Step-by-step derivation
    1. *-commutative33.4%

      \[\leadsto \color{blue}{y \cdot 0.5} \]
  5. Simplified33.4%

    \[\leadsto \color{blue}{y \cdot 0.5} \]
  6. Final simplification33.4%

    \[\leadsto 0.5 \cdot y \]
  7. Add Preprocessing

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

  :alt
  (- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x)))

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