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

Percentage Accurate: 70.1% → 99.9%
Time: 7.5s
Alternatives: 8
Speedup: 1.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 alternatives:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 53.0% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-79}:\\
\;\;\;\;0.5 \cdot y\\

\mathbf{elif}\;x \cdot x \leq 0.02:\\
\;\;\;\;t_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x x) < 5.0000000000000002e-154 or 4.99999999999999999e-79 < (*.f64 x x) < 0.0200000000000000004

    1. Initial program 68.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.0000000000000002e-154 < (*.f64 x x) < 4.99999999999999999e-79 or 0.0200000000000000004 < (*.f64 x x) < 1.00000000000000001e155

    1. Initial program 70.4%

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

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

    if 1.00000000000000001e155 < (*.f64 x x)

    1. Initial program 65.3%

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

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

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

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

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

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

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

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

Alternative 3: 85.3% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z z) < 5.0000000000000001e-9

    1. Initial program 73.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.0000000000000001e-9 < (*.f64 z z)

    1. Initial program 61.2%

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

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

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

        \[\leadsto 0.5 \cdot \frac{x \cdot x - \color{blue}{z \cdot z}}{y} \]
      3. sub-neg64.1%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\frac{x + z}{\frac{y}{x - z}}} \]
      15. +-commutative83.8%

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

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

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

Alternative 4: 99.9% accurate, 1.2× speedup?

\[\begin{array}{l} \\ 0.5 \cdot \left(y + \left(x - z\right) \cdot \frac{z + x}{y}\right) \end{array} \]
(FPCore (x y z) :precision binary64 (* 0.5 (+ y (* (- x z) (/ (+ z x) y)))))
double code(double x, double y, double z) {
	return 0.5 * (y + ((x - z) * ((z + x) / 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 + ((x - z) * ((z + x) / y)))
end function
public static double code(double x, double y, double z) {
	return 0.5 * (y + ((x - z) * ((z + x) / y)));
}
def code(x, y, z):
	return 0.5 * (y + ((x - z) * ((z + x) / y)))
function code(x, y, z)
	return Float64(0.5 * Float64(y + Float64(Float64(x - z) * Float64(Float64(z + x) / y))))
end
function tmp = code(x, y, z)
	tmp = 0.5 * (y + ((x - z) * ((z + x) / y)));
end
code[x_, y_, z_] := N[(0.5 * N[(y + N[(N[(x - z), $MachinePrecision] * N[(N[(z + x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 72.8% accurate, 1.4× speedup?

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

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

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


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

    1. Initial program 70.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.2999999999999999e120 < z

    1. Initial program 54.7%

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

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

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

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

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

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

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

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

Alternative 6: 75.2% accurate, 1.4× speedup?

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

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

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


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

    1. Initial program 70.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.06e86 < z

    1. Initial program 56.3%

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 42.6% accurate, 1.7× speedup?

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

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

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


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

    1. Initial program 70.0%

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

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

    if 4.50000000000000024e77 < x

    1. Initial program 57.1%

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

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

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

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

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

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

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

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

Alternative 8: 33.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 67.5%

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

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

    \[\leadsto 0.5 \cdot y \]

Developer target: 99.9% accurate, 1.0× speedup?

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

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

Reproduce

?
herbie shell --seed 2023297 
(FPCore (x y z)
  :name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
  :precision binary64

  :herbie-target
  (- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x)))

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