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

Percentage Accurate: 68.8% → 99.9%
Time: 10.2s
Alternatives: 10
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 10 alternatives:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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. associate-/l*99.8%

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

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

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

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

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

Alternative 2: 71.9% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 4.4 \cdot 10^{+97} \lor \neg \left(y \leq 9 \cdot 10^{+145}\right) \land y \leq 2.7 \cdot 10^{+206}:\\ \;\;\;\;0.5 \cdot \left(\left(x + z\right) \cdot \frac{x - z}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot y\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y 4.4e+97) (and (not (<= y 9e+145)) (<= y 2.7e+206)))
   (* 0.5 (* (+ x z) (/ (- x z) y)))
   (* 0.5 y)))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= 4.4e+97) || (!(y <= 9e+145) && (y <= 2.7e+206))) {
		tmp = 0.5 * ((x + z) * ((x - z) / y));
	} else {
		tmp = 0.5 * y;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((y <= 4.4d+97) .or. (.not. (y <= 9d+145)) .and. (y <= 2.7d+206)) then
        tmp = 0.5d0 * ((x + z) * ((x - z) / y))
    else
        tmp = 0.5d0 * y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= 4.4e+97) || (!(y <= 9e+145) && (y <= 2.7e+206))) {
		tmp = 0.5 * ((x + z) * ((x - z) / y));
	} else {
		tmp = 0.5 * y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= 4.4e+97) or (not (y <= 9e+145) and (y <= 2.7e+206)):
		tmp = 0.5 * ((x + z) * ((x - z) / y))
	else:
		tmp = 0.5 * y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= 4.4e+97) || (!(y <= 9e+145) && (y <= 2.7e+206)))
		tmp = Float64(0.5 * Float64(Float64(x + z) * Float64(Float64(x - z) / y)));
	else
		tmp = Float64(0.5 * y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= 4.4e+97) || (~((y <= 9e+145)) && (y <= 2.7e+206)))
		tmp = 0.5 * ((x + z) * ((x - z) / y));
	else
		tmp = 0.5 * y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, 4.4e+97], And[N[Not[LessEqual[y, 9e+145]], $MachinePrecision], LessEqual[y, 2.7e+206]]], N[(0.5 * N[(N[(x + z), $MachinePrecision] * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.4 \cdot 10^{+97} \lor \neg \left(y \leq 9 \cdot 10^{+145}\right) \land y \leq 2.7 \cdot 10^{+206}:\\
\;\;\;\;0.5 \cdot \left(\left(x + z\right) \cdot \frac{x - z}{y}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 4.4000000000000002e97 or 8.9999999999999996e145 < y < 2.70000000000000003e206

    1. Initial program 76.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\mathsf{fma}\left(x + z, \frac{x - z}{y}, y\right)} \]
    12. Taylor expanded in y around 0 72.6%

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

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

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

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

        \[\leadsto \frac{0.5 \cdot \left({x}^{2} - \color{blue}{{z}^{2}}\right)}{y} \]
      5. associate-*r/65.9%

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

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

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

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

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

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

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

    if 4.4000000000000002e97 < y < 8.9999999999999996e145 or 2.70000000000000003e206 < y

    1. Initial program 52.5%

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

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

        \[\leadsto \color{blue}{-\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\left(-y\right) \cdot 2}} \]
      4. distribute-frac-neg52.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-152.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-out52.5%

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative52.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-in52.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-frac52.5%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 4.4 \cdot 10^{+97} \lor \neg \left(y \leq 9 \cdot 10^{+145}\right) \land y \leq 2.7 \cdot 10^{+206}:\\ \;\;\;\;0.5 \cdot \left(\left(x + z\right) \cdot \frac{x - z}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot y\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 88.5% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 78.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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. associate-/l*99.8%

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

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

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

    if 5.00000000000000007e121 < (*.f64 x x)

    1. Initial program 68.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(y + \frac{\color{blue}{\left(x + z\right) \cdot \left(x - z\right)}}{y}\right) \]
    9. Applied egg-rr86.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 x around inf 80.7%

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

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

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

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

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

Alternative 4: 86.1% accurate, 0.8× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(x + z\right) \cdot t\_0\right)\\


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

    1. Initial program 77.8%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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. associate-/l*99.8%

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

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

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

    if 4.00000000000000006e116 < (*.f64 x x)

    1. Initial program 68.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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. +-commutative87.1%

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\mathsf{fma}\left(x + z, \frac{x - z}{y}, y\right)} \]
    12. Taylor expanded in y around 0 82.0%

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

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

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

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

        \[\leadsto \frac{0.5 \cdot \left({x}^{2} - \color{blue}{{z}^{2}}\right)}{y} \]
      5. associate-*r/67.7%

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

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

        \[\leadsto 0.5 \cdot \frac{x \cdot x - \color{blue}{z \cdot z}}{y} \]
      8. difference-of-squares82.0%

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

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

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

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

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

Alternative 5: 55.0% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 4000000000:\\
\;\;\;\;z \cdot \frac{1}{\frac{y}{z \cdot -0.5}}\\

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


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

    1. Initial program 76.4%

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

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

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

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative76.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-in76.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-frac76.4%

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

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

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

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

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

      \[\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 z around inf 48.1%

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

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

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

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

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

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

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

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

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

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

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

    if 4e9 < (*.f64 x x)

    1. Initial program 71.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 55.0% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 76.4%

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

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

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

        \[\leadsto \frac{-1 \cdot \left(\left(x \cdot x + y \cdot y\right) - z \cdot z\right)}{\color{blue}{-y \cdot 2}} \]
      7. *-commutative76.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-in76.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-frac76.4%

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

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

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

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

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

      \[\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 z around inf 48.1%

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

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

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

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

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

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

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

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

    if 4e9 < (*.f64 x x)

    1. Initial program 71.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 49.8% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 77.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.00000000000000007e70 < (*.f64 x x)

    1. Initial program 70.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 99.9% accurate, 1.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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. associate-/l*99.8%

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

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

Alternative 9: 43.9% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.75 \cdot 10^{+21}:\\
\;\;\;\;0.5 \cdot y\\

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


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

    1. Initial program 76.3%

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

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

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

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

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

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

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

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

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

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

    if 1.75e21 < z

    1. Initial program 67.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 34.6% 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 74.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Developer Target 1: 99.9% accurate, 1.0× speedup?

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

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

Reproduce

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

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

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