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

Percentage Accurate: 69.8% → 99.8%
Time: 12.0s
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: 69.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.8% 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 69.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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. Final simplification99.9%

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

Alternative 2: 73.1% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 3.8 \cdot 10^{+62} \lor \neg \left(y \leq 2.2 \cdot 10^{+82}\right) \land y \leq 1.75 \cdot 10^{+183}:\\ \;\;\;\;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 3.8e+62) (and (not (<= y 2.2e+82)) (<= y 1.75e+183)))
   (* 0.5 (* (+ x z) (/ (- x z) y)))
   (* 0.5 y)))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= 3.8e+62) || (!(y <= 2.2e+82) && (y <= 1.75e+183))) {
		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 <= 3.8d+62) .or. (.not. (y <= 2.2d+82)) .and. (y <= 1.75d+183)) 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 <= 3.8e+62) || (!(y <= 2.2e+82) && (y <= 1.75e+183))) {
		tmp = 0.5 * ((x + z) * ((x - z) / y));
	} else {
		tmp = 0.5 * y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= 3.8e+62) or (not (y <= 2.2e+82) and (y <= 1.75e+183)):
		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 <= 3.8e+62) || (!(y <= 2.2e+82) && (y <= 1.75e+183)))
		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 <= 3.8e+62) || (~((y <= 2.2e+82)) && (y <= 1.75e+183)))
		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, 3.8e+62], And[N[Not[LessEqual[y, 2.2e+82]], $MachinePrecision], LessEqual[y, 1.75e+183]]], 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 3.8 \cdot 10^{+62} \lor \neg \left(y \leq 2.2 \cdot 10^{+82}\right) \land y \leq 1.75 \cdot 10^{+183}:\\
\;\;\;\;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 < 3.79999999999999984e62 or 2.2000000000000001e82 < y < 1.74999999999999994e183

    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-define80.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.79999999999999984e62 < y < 2.2000000000000001e82 or 1.74999999999999994e183 < y

    1. Initial program 27.3%

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

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

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified75.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 3.8 \cdot 10^{+62} \lor \neg \left(y \leq 2.2 \cdot 10^{+82}\right) \land y \leq 1.75 \cdot 10^{+183}:\\ \;\;\;\;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: 73.1% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;y \leq 1.46 \cdot 10^{+82} \lor \neg \left(y \leq 2.1 \cdot 10^{+183}\right):\\
\;\;\;\;0.5 \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 3.49999999999999984e62

    1. Initial program 79.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.49999999999999984e62 < y < 1.4599999999999999e82 or 2.1e183 < y

    1. Initial program 27.3%

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

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

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified75.6%

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

    if 1.4599999999999999e82 < y < 2.1e183

    1. Initial program 54.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 3.5 \cdot 10^{+62}:\\ \;\;\;\;0.5 \cdot \left(\left(x - z\right) \cdot \frac{x + z}{y}\right)\\ \mathbf{elif}\;y \leq 1.46 \cdot 10^{+82} \lor \neg \left(y \leq 2.1 \cdot 10^{+183}\right):\\ \;\;\;\;0.5 \cdot y\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\left(x + z\right) \cdot \frac{x - z}{y}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 42.1% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.0045 \lor \neg \left(x \leq 7.8 \cdot 10^{+77}\right) \land x \leq 1.75 \cdot 10^{+110}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= x 0.0045) (and (not (<= x 7.8e+77)) (<= x 1.75e+110)))
   (* 0.5 y)
   (* x (* x (/ 0.5 y)))))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= 0.0045) || (!(x <= 7.8e+77) && (x <= 1.75e+110))) {
		tmp = 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 <= 0.0045d0) .or. (.not. (x <= 7.8d+77)) .and. (x <= 1.75d+110)) then
        tmp = 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 <= 0.0045) || (!(x <= 7.8e+77) && (x <= 1.75e+110))) {
		tmp = 0.5 * y;
	} else {
		tmp = x * (x * (0.5 / y));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x <= 0.0045) or (not (x <= 7.8e+77) and (x <= 1.75e+110)):
		tmp = 0.5 * y
	else:
		tmp = x * (x * (0.5 / y))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((x <= 0.0045) || (!(x <= 7.8e+77) && (x <= 1.75e+110)))
		tmp = Float64(0.5 * y);
	else
		tmp = Float64(x * Float64(x * Float64(0.5 / y)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= 0.0045) || (~((x <= 7.8e+77)) && (x <= 1.75e+110)))
		tmp = 0.5 * y;
	else
		tmp = x * (x * (0.5 / y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[x, 0.0045], And[N[Not[LessEqual[x, 7.8e+77]], $MachinePrecision], LessEqual[x, 1.75e+110]]], N[(0.5 * y), $MachinePrecision], N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.0045 \lor \neg \left(x \leq 7.8 \cdot 10^{+77}\right) \land x \leq 1.75 \cdot 10^{+110}:\\
\;\;\;\;0.5 \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 0.00449999999999999966 or 7.7999999999999995e77 < x < 1.75e110

    1. Initial program 69.3%

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

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

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified38.8%

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

    if 0.00449999999999999966 < x < 7.7999999999999995e77 or 1.75e110 < x

    1. Initial program 69.2%

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

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

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

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

        \[\leadsto \color{blue}{{x}^{2} \cdot \frac{0.5}{y}} \]
    5. Simplified63.9%

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

        \[\leadsto \color{blue}{\sqrt{{x}^{2} \cdot \frac{0.5}{y}} \cdot \sqrt{{x}^{2} \cdot \frac{0.5}{y}}} \]
      2. pow235.6%

        \[\leadsto \color{blue}{{\left(\sqrt{{x}^{2} \cdot \frac{0.5}{y}}\right)}^{2}} \]
      3. sqrt-prod35.6%

        \[\leadsto {\color{blue}{\left(\sqrt{{x}^{2}} \cdot \sqrt{\frac{0.5}{y}}\right)}}^{2} \]
      4. sqrt-pow138.8%

        \[\leadsto {\left(\color{blue}{{x}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{0.5}{y}}\right)}^{2} \]
      5. metadata-eval38.8%

        \[\leadsto {\left({x}^{\color{blue}{1}} \cdot \sqrt{\frac{0.5}{y}}\right)}^{2} \]
      6. pow138.8%

        \[\leadsto {\left(\color{blue}{x} \cdot \sqrt{\frac{0.5}{y}}\right)}^{2} \]
    7. Applied egg-rr38.8%

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

        \[\leadsto \color{blue}{\left(x \cdot \sqrt{\frac{0.5}{y}}\right) \cdot \left(x \cdot \sqrt{\frac{0.5}{y}}\right)} \]
      2. swap-sqr35.6%

        \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot \left(\sqrt{\frac{0.5}{y}} \cdot \sqrt{\frac{0.5}{y}}\right)} \]
      3. add-sqr-sqrt63.9%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.0045 \lor \neg \left(x \leq 7.8 \cdot 10^{+77}\right) \land x \leq 1.75 \cdot 10^{+110}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 42.2% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.6 \cdot 10^{-5}:\\
\;\;\;\;0.5 \cdot y\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 8.6000000000000003e-5 or 2.0999999999999999e77 < x < 1.35000000000000005e110

    1. Initial program 69.3%

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

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

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified38.8%

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

    if 8.6000000000000003e-5 < x < 2.0999999999999999e77

    1. Initial program 84.4%

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

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

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

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

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

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

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

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

        \[\leadsto {\color{blue}{\left(\sqrt{{x}^{2}} \cdot \sqrt{\frac{0.5}{y}}\right)}}^{2} \]
      4. sqrt-pow126.3%

        \[\leadsto {\left(\color{blue}{{x}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{0.5}{y}}\right)}^{2} \]
      5. metadata-eval26.3%

        \[\leadsto {\left({x}^{\color{blue}{1}} \cdot \sqrt{\frac{0.5}{y}}\right)}^{2} \]
      6. pow126.3%

        \[\leadsto {\left(\color{blue}{x} \cdot \sqrt{\frac{0.5}{y}}\right)}^{2} \]
    7. Applied egg-rr26.3%

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

        \[\leadsto \color{blue}{\left(x \cdot \sqrt{\frac{0.5}{y}}\right) \cdot \left(x \cdot \sqrt{\frac{0.5}{y}}\right)} \]
      2. swap-sqr26.2%

        \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot \left(\sqrt{\frac{0.5}{y}} \cdot \sqrt{\frac{0.5}{y}}\right)} \]
      3. add-sqr-sqrt47.7%

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\frac{0.5 \cdot x}{y}} \]
      2. *-commutative47.6%

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

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

    if 1.35000000000000005e110 < x

    1. Initial program 61.6%

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

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

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

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

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

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

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

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

        \[\leadsto {\color{blue}{\left(\sqrt{{x}^{2}} \cdot \sqrt{\frac{0.5}{y}}\right)}}^{2} \]
      4. sqrt-pow145.1%

        \[\leadsto {\left(\color{blue}{{x}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{0.5}{y}}\right)}^{2} \]
      5. metadata-eval45.1%

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

        \[\leadsto {\left(\color{blue}{x} \cdot \sqrt{\frac{0.5}{y}}\right)}^{2} \]
    7. Applied egg-rr45.1%

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

        \[\leadsto \color{blue}{\left(x \cdot \sqrt{\frac{0.5}{y}}\right) \cdot \left(x \cdot \sqrt{\frac{0.5}{y}}\right)} \]
      2. swap-sqr40.2%

        \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot \left(\sqrt{\frac{0.5}{y}} \cdot \sqrt{\frac{0.5}{y}}\right)} \]
      3. add-sqr-sqrt72.0%

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

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

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

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

Alternative 6: 42.2% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.0225:\\
\;\;\;\;0.5 \cdot y\\

\mathbf{elif}\;x \leq 4.1 \cdot 10^{+77}:\\
\;\;\;\;\frac{x \cdot \left(0.5 \cdot x\right)}{y}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 0.022499999999999999 or 4.1000000000000001e77 < x < 8e113

    1. Initial program 69.3%

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

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

        \[\leadsto \color{blue}{y \cdot 0.5} \]
    5. Simplified38.8%

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

    if 0.022499999999999999 < x < 4.1000000000000001e77

    1. Initial program 84.4%

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

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

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

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

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

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

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

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

        \[\leadsto {\color{blue}{\left(\sqrt{{x}^{2}} \cdot \sqrt{\frac{0.5}{y}}\right)}}^{2} \]
      4. sqrt-pow126.3%

        \[\leadsto {\left(\color{blue}{{x}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{0.5}{y}}\right)}^{2} \]
      5. metadata-eval26.3%

        \[\leadsto {\left({x}^{\color{blue}{1}} \cdot \sqrt{\frac{0.5}{y}}\right)}^{2} \]
      6. pow126.3%

        \[\leadsto {\left(\color{blue}{x} \cdot \sqrt{\frac{0.5}{y}}\right)}^{2} \]
    7. Applied egg-rr26.3%

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

        \[\leadsto \color{blue}{\left(x \cdot \sqrt{\frac{0.5}{y}}\right) \cdot \left(x \cdot \sqrt{\frac{0.5}{y}}\right)} \]
      2. swap-sqr26.2%

        \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot \left(\sqrt{\frac{0.5}{y}} \cdot \sqrt{\frac{0.5}{y}}\right)} \]
      3. add-sqr-sqrt47.7%

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

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

      \[\leadsto \color{blue}{x \cdot \left(x \cdot \frac{0.5}{y}\right)} \]
    10. Step-by-step derivation
      1. *-commutative47.5%

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

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

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

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

    if 8e113 < x

    1. Initial program 61.6%

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

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

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

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

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

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

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

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

        \[\leadsto {\color{blue}{\left(\sqrt{{x}^{2}} \cdot \sqrt{\frac{0.5}{y}}\right)}}^{2} \]
      4. sqrt-pow145.1%

        \[\leadsto {\left(\color{blue}{{x}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{0.5}{y}}\right)}^{2} \]
      5. metadata-eval45.1%

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

        \[\leadsto {\left(\color{blue}{x} \cdot \sqrt{\frac{0.5}{y}}\right)}^{2} \]
    7. Applied egg-rr45.1%

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

        \[\leadsto \color{blue}{\left(x \cdot \sqrt{\frac{0.5}{y}}\right) \cdot \left(x \cdot \sqrt{\frac{0.5}{y}}\right)} \]
      2. swap-sqr40.2%

        \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot \left(\sqrt{\frac{0.5}{y}} \cdot \sqrt{\frac{0.5}{y}}\right)} \]
      3. add-sqr-sqrt72.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.0225:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;x \leq 4.1 \cdot 10^{+77}:\\ \;\;\;\;\frac{x \cdot \left(0.5 \cdot x\right)}{y}\\ \mathbf{elif}\;x \leq 8 \cdot 10^{+113}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 78.6% accurate, 0.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 3.6999999999999999e-4

    1. Initial program 69.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 78.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+78.6%

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

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

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

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

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

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

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

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

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

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

    if 3.6999999999999999e-4 < x < 1.06000000000000003e77

    1. Initial program 84.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.06000000000000003e77 < x

    1. Initial program 63.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 65.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+65.3%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 75.8% accurate, 0.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1.20000000000000011e-38

    1. Initial program 76.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.20000000000000011e-38 < y

    1. Initial program 53.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 70.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+70.4%

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

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

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

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

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

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

      \[\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. *-commutative74.3%

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

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

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

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

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

Alternative 9: 99.8% 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 69.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 33.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 69.3%

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

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

      \[\leadsto \color{blue}{y \cdot 0.5} \]
  5. Simplified32.6%

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

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

Developer target: 99.9% accurate, 1.0× speedup?

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

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

Reproduce

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

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

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