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

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

\\
y \cdot \left(\sqrt{z} \cdot 0.5\right) + 0.5 \cdot x
\end{array}
Derivation
  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. Step-by-step derivation
    1. +-commutative99.5%

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

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

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

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

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

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

Alternative 2: 76.1% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \sqrt{z}\\ \mathbf{if}\;t_0 \leq -0.05 \lor \neg \left(t_0 \leq 10^{+49}\right):\\ \;\;\;\;0.5 \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (sqrt z))))
   (if (or (<= t_0 -0.05) (not (<= t_0 1e+49))) (* 0.5 t_0) (* 0.5 x))))
double code(double x, double y, double z) {
	double t_0 = y * sqrt(z);
	double tmp;
	if ((t_0 <= -0.05) || !(t_0 <= 1e+49)) {
		tmp = 0.5 * t_0;
	} else {
		tmp = 0.5 * 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) :: t_0
    real(8) :: tmp
    t_0 = y * sqrt(z)
    if ((t_0 <= (-0.05d0)) .or. (.not. (t_0 <= 1d+49))) then
        tmp = 0.5d0 * t_0
    else
        tmp = 0.5d0 * x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = y * Math.sqrt(z);
	double tmp;
	if ((t_0 <= -0.05) || !(t_0 <= 1e+49)) {
		tmp = 0.5 * t_0;
	} else {
		tmp = 0.5 * x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * math.sqrt(z)
	tmp = 0
	if (t_0 <= -0.05) or not (t_0 <= 1e+49):
		tmp = 0.5 * t_0
	else:
		tmp = 0.5 * x
	return tmp
function code(x, y, z)
	t_0 = Float64(y * sqrt(z))
	tmp = 0.0
	if ((t_0 <= -0.05) || !(t_0 <= 1e+49))
		tmp = Float64(0.5 * t_0);
	else
		tmp = Float64(0.5 * x);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y * sqrt(z);
	tmp = 0.0;
	if ((t_0 <= -0.05) || ~((t_0 <= 1e+49)))
		tmp = 0.5 * t_0;
	else
		tmp = 0.5 * x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[Sqrt[z], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.05], N[Not[LessEqual[t$95$0, 1e+49]], $MachinePrecision]], N[(0.5 * t$95$0), $MachinePrecision], N[(0.5 * x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y \cdot \sqrt{z}\\
\mathbf{if}\;t_0 \leq -0.05 \lor \neg \left(t_0 \leq 10^{+49}\right):\\
\;\;\;\;0.5 \cdot t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 y (sqrt.f64 z)) < -0.050000000000000003 or 9.99999999999999946e48 < (*.f64 y (sqrt.f64 z))

    1. Initial program 99.0%

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

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

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

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

    if -0.050000000000000003 < (*.f64 y (sqrt.f64 z)) < 9.99999999999999946e48

    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. Taylor expanded in x around inf 83.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \sqrt{z} \leq -0.05 \lor \neg \left(y \cdot \sqrt{z} \leq 10^{+49}\right):\\ \;\;\;\;0.5 \cdot \left(y \cdot \sqrt{z}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot x\\ \end{array} \]

Alternative 3: 76.2% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := y \cdot \sqrt{z}\\
\mathbf{if}\;t_0 \leq -0.05:\\
\;\;\;\;\sqrt{z} \cdot \left(y \cdot 0.5\right)\\

\mathbf{elif}\;t_0 \leq 10^{+49}:\\
\;\;\;\;0.5 \cdot x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 y (sqrt.f64 z)) < -0.050000000000000003

    1. Initial program 98.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot y\right) \cdot \sqrt{z}} \]
      2. *-commutative84.3%

        \[\leadsto \color{blue}{\left(y \cdot 0.5\right)} \cdot \sqrt{z} \]
    11. Simplified84.3%

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

    if -0.050000000000000003 < (*.f64 y (sqrt.f64 z)) < 9.99999999999999946e48

    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. Taylor expanded in x around inf 83.1%

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

    if 9.99999999999999946e48 < (*.f64 y (sqrt.f64 z))

    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. Taylor expanded in x around 0 87.9%

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

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

Alternative 4: 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.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. Final simplification99.5%

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

Alternative 5: 50.4% 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.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 inf 52.5%

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

    \[\leadsto 0.5 \cdot x \]

Reproduce

?
herbie shell --seed 2023215 
(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)))))