Diagrams.Solve.Polynomial:quadForm from diagrams-solve-0.1, B

Percentage Accurate: 99.8% → 99.8%
Time: 6.4s
Alternatives: 5
Speedup: 1.0×

Specification

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

\\
\frac{1}{2} \cdot \left(x + y \cdot \sqrt{z}\right)
\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 5 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: 99.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 1.0× speedup?

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

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

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

      \[\leadsto \color{blue}{0.5} \cdot \left(x + y \cdot \sqrt{z}\right) \]
  3. Simplified99.8%

    \[\leadsto \color{blue}{0.5 \cdot \left(x + y \cdot \sqrt{z}\right)} \]
  4. Final simplification99.8%

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

Alternative 2: 70.5% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \left(y \cdot \sqrt{z}\right)\\ t_1 := 0.5 \cdot \left(x - z \cdot \left(y \cdot \frac{y}{-x}\right)\right)\\ t_2 := 0.5 \cdot \left(x - z \cdot \left(y \cdot \frac{y}{x}\right)\right)\\ \mathbf{if}\;x \leq -1.4 \cdot 10^{-150}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3.5 \cdot 10^{-124}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 7.8 \cdot 10^{-92}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 3500000000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{+28}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.05 \cdot 10^{+90}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* 0.5 (* y (sqrt z))))
        (t_1 (* 0.5 (- x (* z (* y (/ y (- x)))))))
        (t_2 (* 0.5 (- x (* z (* y (/ y x)))))))
   (if (<= x -1.4e-150)
     t_1
     (if (<= x 3.5e-124)
       t_0
       (if (<= x 7.8e-92)
         t_2
         (if (<= x 3500000000000.0)
           t_0
           (if (<= x 8.5e+28) t_1 (if (<= x 2.05e+90) t_0 t_2))))))))
double code(double x, double y, double z) {
	double t_0 = 0.5 * (y * sqrt(z));
	double t_1 = 0.5 * (x - (z * (y * (y / -x))));
	double t_2 = 0.5 * (x - (z * (y * (y / x))));
	double tmp;
	if (x <= -1.4e-150) {
		tmp = t_1;
	} else if (x <= 3.5e-124) {
		tmp = t_0;
	} else if (x <= 7.8e-92) {
		tmp = t_2;
	} else if (x <= 3500000000000.0) {
		tmp = t_0;
	} else if (x <= 8.5e+28) {
		tmp = t_1;
	} else if (x <= 2.05e+90) {
		tmp = t_0;
	} else {
		tmp = t_2;
	}
	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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = 0.5d0 * (y * sqrt(z))
    t_1 = 0.5d0 * (x - (z * (y * (y / -x))))
    t_2 = 0.5d0 * (x - (z * (y * (y / x))))
    if (x <= (-1.4d-150)) then
        tmp = t_1
    else if (x <= 3.5d-124) then
        tmp = t_0
    else if (x <= 7.8d-92) then
        tmp = t_2
    else if (x <= 3500000000000.0d0) then
        tmp = t_0
    else if (x <= 8.5d+28) then
        tmp = t_1
    else if (x <= 2.05d+90) then
        tmp = t_0
    else
        tmp = t_2
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = 0.5 * (y * Math.sqrt(z));
	double t_1 = 0.5 * (x - (z * (y * (y / -x))));
	double t_2 = 0.5 * (x - (z * (y * (y / x))));
	double tmp;
	if (x <= -1.4e-150) {
		tmp = t_1;
	} else if (x <= 3.5e-124) {
		tmp = t_0;
	} else if (x <= 7.8e-92) {
		tmp = t_2;
	} else if (x <= 3500000000000.0) {
		tmp = t_0;
	} else if (x <= 8.5e+28) {
		tmp = t_1;
	} else if (x <= 2.05e+90) {
		tmp = t_0;
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 0.5 * (y * math.sqrt(z))
	t_1 = 0.5 * (x - (z * (y * (y / -x))))
	t_2 = 0.5 * (x - (z * (y * (y / x))))
	tmp = 0
	if x <= -1.4e-150:
		tmp = t_1
	elif x <= 3.5e-124:
		tmp = t_0
	elif x <= 7.8e-92:
		tmp = t_2
	elif x <= 3500000000000.0:
		tmp = t_0
	elif x <= 8.5e+28:
		tmp = t_1
	elif x <= 2.05e+90:
		tmp = t_0
	else:
		tmp = t_2
	return tmp
function code(x, y, z)
	t_0 = Float64(0.5 * Float64(y * sqrt(z)))
	t_1 = Float64(0.5 * Float64(x - Float64(z * Float64(y * Float64(y / Float64(-x))))))
	t_2 = Float64(0.5 * Float64(x - Float64(z * Float64(y * Float64(y / x)))))
	tmp = 0.0
	if (x <= -1.4e-150)
		tmp = t_1;
	elseif (x <= 3.5e-124)
		tmp = t_0;
	elseif (x <= 7.8e-92)
		tmp = t_2;
	elseif (x <= 3500000000000.0)
		tmp = t_0;
	elseif (x <= 8.5e+28)
		tmp = t_1;
	elseif (x <= 2.05e+90)
		tmp = t_0;
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 0.5 * (y * sqrt(z));
	t_1 = 0.5 * (x - (z * (y * (y / -x))));
	t_2 = 0.5 * (x - (z * (y * (y / x))));
	tmp = 0.0;
	if (x <= -1.4e-150)
		tmp = t_1;
	elseif (x <= 3.5e-124)
		tmp = t_0;
	elseif (x <= 7.8e-92)
		tmp = t_2;
	elseif (x <= 3500000000000.0)
		tmp = t_0;
	elseif (x <= 8.5e+28)
		tmp = t_1;
	elseif (x <= 2.05e+90)
		tmp = t_0;
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(0.5 * N[(y * N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[(x - N[(z * N[(y * N[(y / (-x)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(0.5 * N[(x - N[(z * N[(y * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.4e-150], t$95$1, If[LessEqual[x, 3.5e-124], t$95$0, If[LessEqual[x, 7.8e-92], t$95$2, If[LessEqual[x, 3500000000000.0], t$95$0, If[LessEqual[x, 8.5e+28], t$95$1, If[LessEqual[x, 2.05e+90], t$95$0, t$95$2]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(y \cdot \sqrt{z}\right)\\
t_1 := 0.5 \cdot \left(x - z \cdot \left(y \cdot \frac{y}{-x}\right)\right)\\
t_2 := 0.5 \cdot \left(x - z \cdot \left(y \cdot \frac{y}{x}\right)\right)\\
\mathbf{if}\;x \leq -1.4 \cdot 10^{-150}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 3.5 \cdot 10^{-124}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 7.8 \cdot 10^{-92}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;x \leq 3500000000000:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 8.5 \cdot 10^{+28}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 2.05 \cdot 10^{+90}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.39999999999999998e-150 or 3.5e12 < x < 8.49999999999999954e28

    1. Initial program 99.9%

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(x + y \cdot \sqrt{z}\right)} \]
    4. Step-by-step derivation
      1. flip-+51.1%

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

        \[\leadsto 0.5 \cdot \color{blue}{\left(\left(x \cdot x - \left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)\right) \cdot \frac{1}{x - y \cdot \sqrt{z}}\right)} \]
      3. *-commutative51.0%

        \[\leadsto 0.5 \cdot \left(\left(x \cdot x - \color{blue}{\left(\sqrt{z} \cdot y\right)} \cdot \left(y \cdot \sqrt{z}\right)\right) \cdot \frac{1}{x - y \cdot \sqrt{z}}\right) \]
      4. *-commutative51.0%

        \[\leadsto 0.5 \cdot \left(\left(x \cdot x - \left(\sqrt{z} \cdot y\right) \cdot \color{blue}{\left(\sqrt{z} \cdot y\right)}\right) \cdot \frac{1}{x - y \cdot \sqrt{z}}\right) \]
      5. swap-sqr48.6%

        \[\leadsto 0.5 \cdot \left(\left(x \cdot x - \color{blue}{\left(\sqrt{z} \cdot \sqrt{z}\right) \cdot \left(y \cdot y\right)}\right) \cdot \frac{1}{x - y \cdot \sqrt{z}}\right) \]
      6. add-sqr-sqrt48.6%

        \[\leadsto 0.5 \cdot \left(\left(x \cdot x - \color{blue}{z} \cdot \left(y \cdot y\right)\right) \cdot \frac{1}{x - y \cdot \sqrt{z}}\right) \]
    5. Applied egg-rr48.6%

      \[\leadsto 0.5 \cdot \color{blue}{\left(\left(x \cdot x - z \cdot \left(y \cdot y\right)\right) \cdot \frac{1}{x - y \cdot \sqrt{z}}\right)} \]
    6. Taylor expanded in x around inf 42.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(x - \left(\frac{\color{blue}{0}}{-x} - \frac{y \cdot y}{-x}\right) \cdot z\right) \]
      6. add-sqr-sqrt70.2%

        \[\leadsto 0.5 \cdot \left(x - \left(\frac{0}{-x} - \frac{\color{blue}{\sqrt{y \cdot y} \cdot \sqrt{y \cdot y}}}{-x}\right) \cdot z\right) \]
      7. sqrt-unprod64.5%

        \[\leadsto 0.5 \cdot \left(x - \left(\frac{0}{-x} - \frac{\color{blue}{\sqrt{\left(y \cdot y\right) \cdot \left(y \cdot y\right)}}}{-x}\right) \cdot z\right) \]
      8. sqr-neg64.5%

        \[\leadsto 0.5 \cdot \left(x - \left(\frac{0}{-x} - \frac{\sqrt{\color{blue}{\left(-y \cdot y\right) \cdot \left(-y \cdot y\right)}}}{-x}\right) \cdot z\right) \]
      9. sqrt-unprod21.7%

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

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

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

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

      \[\leadsto 0.5 \cdot \left(x - \color{blue}{\left(\frac{0}{-x} - \frac{y}{\frac{x}{y}}\right)} \cdot z\right) \]
    12. Step-by-step derivation
      1. div085.4%

        \[\leadsto 0.5 \cdot \left(x - \left(\color{blue}{0} - \frac{y}{\frac{x}{y}}\right) \cdot z\right) \]
      2. neg-sub085.4%

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(x - \left(\color{blue}{\frac{1}{-1 \cdot x}} \cdot \left(y \cdot y\right)\right) \cdot z\right) \]
      9. neg-mul-178.3%

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

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

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

        \[\leadsto 0.5 \cdot \left(x - \left(y \cdot \color{blue}{\frac{y \cdot 1}{-x}}\right) \cdot z\right) \]
      13. *-rgt-identity85.4%

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

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

    if -1.39999999999999998e-150 < x < 3.4999999999999999e-124 or 7.7999999999999993e-92 < x < 3.5e12 or 8.49999999999999954e28 < x < 2.05000000000000021e90

    1. Initial program 99.5%

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

        \[\leadsto \color{blue}{0.5} \cdot \left(x + y \cdot \sqrt{z}\right) \]
    3. Simplified99.5%

      \[\leadsto \color{blue}{0.5 \cdot \left(x + y \cdot \sqrt{z}\right)} \]
    4. Taylor expanded in x around 0 87.3%

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

    if 3.4999999999999999e-124 < x < 7.7999999999999993e-92 or 2.05000000000000021e90 < x

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{0.5} \cdot \left(x + y \cdot \sqrt{z}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{0.5 \cdot \left(x + y \cdot \sqrt{z}\right)} \]
    4. Step-by-step derivation
      1. flip-+31.1%

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

        \[\leadsto 0.5 \cdot \color{blue}{\left(\left(x \cdot x - \left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)\right) \cdot \frac{1}{x - y \cdot \sqrt{z}}\right)} \]
      3. *-commutative31.1%

        \[\leadsto 0.5 \cdot \left(\left(x \cdot x - \color{blue}{\left(\sqrt{z} \cdot y\right)} \cdot \left(y \cdot \sqrt{z}\right)\right) \cdot \frac{1}{x - y \cdot \sqrt{z}}\right) \]
      4. *-commutative31.1%

        \[\leadsto 0.5 \cdot \left(\left(x \cdot x - \left(\sqrt{z} \cdot y\right) \cdot \color{blue}{\left(\sqrt{z} \cdot y\right)}\right) \cdot \frac{1}{x - y \cdot \sqrt{z}}\right) \]
      5. swap-sqr27.6%

        \[\leadsto 0.5 \cdot \left(\left(x \cdot x - \color{blue}{\left(\sqrt{z} \cdot \sqrt{z}\right) \cdot \left(y \cdot y\right)}\right) \cdot \frac{1}{x - y \cdot \sqrt{z}}\right) \]
      6. add-sqr-sqrt27.6%

        \[\leadsto 0.5 \cdot \left(\left(x \cdot x - \color{blue}{z} \cdot \left(y \cdot y\right)\right) \cdot \frac{1}{x - y \cdot \sqrt{z}}\right) \]
    5. Applied egg-rr27.6%

      \[\leadsto 0.5 \cdot \color{blue}{\left(\left(x \cdot x - z \cdot \left(y \cdot y\right)\right) \cdot \frac{1}{x - y \cdot \sqrt{z}}\right)} \]
    6. Taylor expanded in x around inf 30.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.4 \cdot 10^{-150}:\\ \;\;\;\;0.5 \cdot \left(x - z \cdot \left(y \cdot \frac{y}{-x}\right)\right)\\ \mathbf{elif}\;x \leq 3.5 \cdot 10^{-124}:\\ \;\;\;\;0.5 \cdot \left(y \cdot \sqrt{z}\right)\\ \mathbf{elif}\;x \leq 7.8 \cdot 10^{-92}:\\ \;\;\;\;0.5 \cdot \left(x - z \cdot \left(y \cdot \frac{y}{x}\right)\right)\\ \mathbf{elif}\;x \leq 3500000000000:\\ \;\;\;\;0.5 \cdot \left(y \cdot \sqrt{z}\right)\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{+28}:\\ \;\;\;\;0.5 \cdot \left(x - z \cdot \left(y \cdot \frac{y}{-x}\right)\right)\\ \mathbf{elif}\;x \leq 2.05 \cdot 10^{+90}:\\ \;\;\;\;0.5 \cdot \left(y \cdot \sqrt{z}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x - z \cdot \left(y \cdot \frac{y}{x}\right)\right)\\ \end{array} \]

Alternative 3: 53.2% accurate, 7.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -6.2e-202

    1. Initial program 99.9%

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(x + y \cdot \sqrt{z}\right)} \]
    4. Step-by-step derivation
      1. flip-+50.7%

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

        \[\leadsto 0.5 \cdot \color{blue}{\left(\left(x \cdot x - \left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)\right) \cdot \frac{1}{x - y \cdot \sqrt{z}}\right)} \]
      3. *-commutative50.6%

        \[\leadsto 0.5 \cdot \left(\left(x \cdot x - \color{blue}{\left(\sqrt{z} \cdot y\right)} \cdot \left(y \cdot \sqrt{z}\right)\right) \cdot \frac{1}{x - y \cdot \sqrt{z}}\right) \]
      4. *-commutative50.6%

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(\left(x \cdot x - z \cdot \left(y \cdot y\right)\right) \cdot \frac{1}{x - y \cdot \sqrt{z}}\right)} \]
    6. Taylor expanded in x around inf 37.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(x - \left(\frac{\color{blue}{0}}{-x} - \frac{y \cdot y}{-x}\right) \cdot z\right) \]
      6. add-sqr-sqrt65.2%

        \[\leadsto 0.5 \cdot \left(x - \left(\frac{0}{-x} - \frac{\color{blue}{\sqrt{y \cdot y} \cdot \sqrt{y \cdot y}}}{-x}\right) \cdot z\right) \]
      7. sqrt-unprod59.6%

        \[\leadsto 0.5 \cdot \left(x - \left(\frac{0}{-x} - \frac{\color{blue}{\sqrt{\left(y \cdot y\right) \cdot \left(y \cdot y\right)}}}{-x}\right) \cdot z\right) \]
      8. sqr-neg59.6%

        \[\leadsto 0.5 \cdot \left(x - \left(\frac{0}{-x} - \frac{\sqrt{\color{blue}{\left(-y \cdot y\right) \cdot \left(-y \cdot y\right)}}}{-x}\right) \cdot z\right) \]
      9. sqrt-unprod21.5%

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

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

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

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

      \[\leadsto 0.5 \cdot \left(x - \color{blue}{\left(\frac{0}{-x} - \frac{y}{\frac{x}{y}}\right)} \cdot z\right) \]
    12. Step-by-step derivation
      1. div079.3%

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(x - \left(\color{blue}{\frac{1}{-1 \cdot x}} \cdot \left(y \cdot y\right)\right) \cdot z\right) \]
      9. neg-mul-172.2%

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

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

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

        \[\leadsto 0.5 \cdot \left(x - \left(y \cdot \color{blue}{\frac{y \cdot 1}{-x}}\right) \cdot z\right) \]
      13. *-rgt-identity79.3%

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

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

    if -6.2e-202 < x

    1. Initial program 99.7%

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

        \[\leadsto \color{blue}{0.5} \cdot \left(x + y \cdot \sqrt{z}\right) \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{0.5 \cdot \left(x + y \cdot \sqrt{z}\right)} \]
    4. Step-by-step derivation
      1. flip-+47.9%

        \[\leadsto 0.5 \cdot \color{blue}{\frac{x \cdot x - \left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)}{x - y \cdot \sqrt{z}}} \]
      2. div-inv47.8%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\left(x \cdot x - \left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)\right) \cdot \frac{1}{x - y \cdot \sqrt{z}}\right)} \]
      3. *-commutative47.8%

        \[\leadsto 0.5 \cdot \left(\left(x \cdot x - \color{blue}{\left(\sqrt{z} \cdot y\right)} \cdot \left(y \cdot \sqrt{z}\right)\right) \cdot \frac{1}{x - y \cdot \sqrt{z}}\right) \]
      4. *-commutative47.8%

        \[\leadsto 0.5 \cdot \left(\left(x \cdot x - \left(\sqrt{z} \cdot y\right) \cdot \color{blue}{\left(\sqrt{z} \cdot y\right)}\right) \cdot \frac{1}{x - y \cdot \sqrt{z}}\right) \]
      5. swap-sqr38.7%

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(\left(x \cdot x - z \cdot \left(y \cdot y\right)\right) \cdot \frac{1}{x - y \cdot \sqrt{z}}\right)} \]
    6. Taylor expanded in x around inf 22.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 53.2% accurate, 9.9× speedup?

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

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

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

      \[\leadsto \color{blue}{0.5} \cdot \left(x + y \cdot \sqrt{z}\right) \]
  3. Simplified99.8%

    \[\leadsto \color{blue}{0.5 \cdot \left(x + y \cdot \sqrt{z}\right)} \]
  4. Step-by-step derivation
    1. flip-+48.9%

      \[\leadsto 0.5 \cdot \color{blue}{\frac{x \cdot x - \left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)}{x - y \cdot \sqrt{z}}} \]
    2. div-inv48.8%

      \[\leadsto 0.5 \cdot \color{blue}{\left(\left(x \cdot x - \left(y \cdot \sqrt{z}\right) \cdot \left(y \cdot \sqrt{z}\right)\right) \cdot \frac{1}{x - y \cdot \sqrt{z}}\right)} \]
    3. *-commutative48.8%

      \[\leadsto 0.5 \cdot \left(\left(x \cdot x - \color{blue}{\left(\sqrt{z} \cdot y\right)} \cdot \left(y \cdot \sqrt{z}\right)\right) \cdot \frac{1}{x - y \cdot \sqrt{z}}\right) \]
    4. *-commutative48.8%

      \[\leadsto 0.5 \cdot \left(\left(x \cdot x - \left(\sqrt{z} \cdot y\right) \cdot \color{blue}{\left(\sqrt{z} \cdot y\right)}\right) \cdot \frac{1}{x - y \cdot \sqrt{z}}\right) \]
    5. swap-sqr41.7%

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

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

    \[\leadsto 0.5 \cdot \color{blue}{\left(\left(x \cdot x - z \cdot \left(y \cdot y\right)\right) \cdot \frac{1}{x - y \cdot \sqrt{z}}\right)} \]
  6. Taylor expanded in x around inf 27.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 50.7% accurate, 36.3× speedup?

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

\\
0.5 \cdot x
\end{array}
Derivation
  1. Initial program 99.8%

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

      \[\leadsto \color{blue}{0.5} \cdot \left(x + y \cdot \sqrt{z}\right) \]
  3. Simplified99.8%

    \[\leadsto \color{blue}{0.5 \cdot \left(x + y \cdot \sqrt{z}\right)} \]
  4. Taylor expanded in x around inf 52.6%

    \[\leadsto 0.5 \cdot \color{blue}{x} \]
  5. Final simplification52.6%

    \[\leadsto 0.5 \cdot x \]

Reproduce

?
herbie shell --seed 2023182 
(FPCore (x y z)
  :name "Diagrams.Solve.Polynomial:quadForm from diagrams-solve-0.1, B"
  :precision binary64
  (* (/ 1.0 2.0) (+ x (* y (sqrt z)))))