Diagrams.Solve.Polynomial:quartForm from diagrams-solve-0.1, D

Percentage Accurate: 100.0% → 100.0%
Time: 2.5s
Alternatives: 5
Speedup: 1.0×

Specification

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

\\
\frac{x \cdot y}{2} - \frac{z}{8}
\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: 100.0% accurate, 1.0× speedup?

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

\\
\frac{x \cdot y}{2} - \frac{z}{8}
\end{array}

Alternative 1: 100.0% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\frac{y}{2}, x, -0.125 \cdot z\right) \end{array} \]
(FPCore (x y z) :precision binary64 (fma (/ y 2.0) x (* -0.125 z)))
double code(double x, double y, double z) {
	return fma((y / 2.0), x, (-0.125 * z));
}
function code(x, y, z)
	return fma(Float64(y / 2.0), x, Float64(-0.125 * z))
end
code[x_, y_, z_] := N[(N[(y / 2.0), $MachinePrecision] * x + N[(-0.125 * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\frac{y}{2}, x, -0.125 \cdot z\right)
\end{array}
Derivation
  1. Initial program 99.7%

    \[\frac{x \cdot y}{2} - \frac{z}{8} \]
  2. Step-by-step derivation
    1. *-commutative99.7%

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

      \[\leadsto \color{blue}{\frac{y}{2} \cdot x} - \frac{z}{8} \]
    3. fma-neg100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{2}, x, -\frac{z}{8}\right)} \]
    4. distribute-frac-neg100.0%

      \[\leadsto \mathsf{fma}\left(\frac{y}{2}, x, \color{blue}{\frac{-z}{8}}\right) \]
    5. neg-mul-1100.0%

      \[\leadsto \mathsf{fma}\left(\frac{y}{2}, x, \frac{\color{blue}{-1 \cdot z}}{8}\right) \]
    6. associate-/l*99.9%

      \[\leadsto \mathsf{fma}\left(\frac{y}{2}, x, \color{blue}{\frac{-1}{\frac{8}{z}}}\right) \]
    7. associate-/r/100.0%

      \[\leadsto \mathsf{fma}\left(\frac{y}{2}, x, \color{blue}{\frac{-1}{8} \cdot z}\right) \]
    8. metadata-eval100.0%

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{2}, x, -0.125 \cdot z\right)} \]
  4. Final simplification100.0%

    \[\leadsto \mathsf{fma}\left(\frac{y}{2}, x, -0.125 \cdot z\right) \]

Alternative 2: 78.2% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \cdot x \leq -1.65 \cdot 10^{+43} \lor \neg \left(y \cdot x \leq 3 \cdot 10^{-45}\right) \land \left(y \cdot x \leq 8600000 \lor \neg \left(y \cdot x \leq 5 \cdot 10^{+75}\right)\right):\\
\;\;\;\;\left(y \cdot x\right) \cdot 0.5\\

\mathbf{else}:\\
\;\;\;\;-0.125 \cdot z\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -1.6500000000000001e43 or 3.00000000000000011e-45 < (*.f64 x y) < 8.6e6 or 5.0000000000000002e75 < (*.f64 x y)

    1. Initial program 99.3%

      \[\frac{x \cdot y}{2} - \frac{z}{8} \]
    2. Step-by-step derivation
      1. associate-*l/100.0%

        \[\leadsto \color{blue}{\frac{x}{2} \cdot y} - \frac{z}{8} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{x}{2} \cdot y - \frac{z}{8}} \]
    4. Taylor expanded in x around inf 83.2%

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

    if -1.6500000000000001e43 < (*.f64 x y) < 3.00000000000000011e-45 or 8.6e6 < (*.f64 x y) < 5.0000000000000002e75

    1. Initial program 100.0%

      \[\frac{x \cdot y}{2} - \frac{z}{8} \]
    2. Step-by-step derivation
      1. associate-*l/100.0%

        \[\leadsto \color{blue}{\frac{x}{2} \cdot y} - \frac{z}{8} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{x}{2} \cdot y - \frac{z}{8}} \]
    4. Taylor expanded in x around 0 77.6%

      \[\leadsto \color{blue}{-0.125 \cdot z} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification80.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot x \leq -1.65 \cdot 10^{+43} \lor \neg \left(y \cdot x \leq 3 \cdot 10^{-45}\right) \land \left(y \cdot x \leq 8600000 \lor \neg \left(y \cdot x \leq 5 \cdot 10^{+75}\right)\right):\\ \;\;\;\;\left(y \cdot x\right) \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;-0.125 \cdot z\\ \end{array} \]

Alternative 3: 78.0% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_0 := \left(y \cdot x\right) \cdot 0.5\\
\mathbf{if}\;y \cdot x \leq -2 \cdot 10^{+48}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \cdot x \leq 2 \cdot 10^{-45}:\\
\;\;\;\;-0.125 \cdot z\\

\mathbf{elif}\;y \cdot x \leq 1:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \cdot x \leq 5 \cdot 10^{+75}:\\
\;\;\;\;-0.125 \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x y) < -2.00000000000000009e48 or 1.99999999999999997e-45 < (*.f64 x y) < 1

    1. Initial program 100.0%

      \[\frac{x \cdot y}{2} - \frac{z}{8} \]
    2. Step-by-step derivation
      1. associate-*l/100.0%

        \[\leadsto \color{blue}{\frac{x}{2} \cdot y} - \frac{z}{8} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{x}{2} \cdot y - \frac{z}{8}} \]
    4. Taylor expanded in x around inf 82.5%

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

    if -2.00000000000000009e48 < (*.f64 x y) < 1.99999999999999997e-45 or 1 < (*.f64 x y) < 5.0000000000000002e75

    1. Initial program 100.0%

      \[\frac{x \cdot y}{2} - \frac{z}{8} \]
    2. Step-by-step derivation
      1. associate-*l/100.0%

        \[\leadsto \color{blue}{\frac{x}{2} \cdot y} - \frac{z}{8} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{x}{2} \cdot y - \frac{z}{8}} \]
    4. Taylor expanded in x around 0 77.6%

      \[\leadsto \color{blue}{-0.125 \cdot z} \]

    if 5.0000000000000002e75 < (*.f64 x y)

    1. Initial program 98.3%

      \[\frac{x \cdot y}{2} - \frac{z}{8} \]
    2. Step-by-step derivation
      1. associate-*l/100.0%

        \[\leadsto \color{blue}{\frac{x}{2} \cdot y} - \frac{z}{8} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{x}{2} \cdot y - \frac{z}{8}} \]
    4. Taylor expanded in x around inf 84.2%

      \[\leadsto \color{blue}{0.5 \cdot \left(x \cdot y\right)} \]
    5. Step-by-step derivation
      1. expm1-log1p-u79.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.5 \cdot \left(x \cdot y\right)\right)\right)} \]
      2. expm1-udef79.0%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.5 \cdot \left(x \cdot y\right)\right)} - 1} \]
      3. log1p-udef79.0%

        \[\leadsto e^{\color{blue}{\log \left(1 + 0.5 \cdot \left(x \cdot y\right)\right)}} - 1 \]
      4. add-exp-log84.2%

        \[\leadsto \color{blue}{\left(1 + 0.5 \cdot \left(x \cdot y\right)\right)} - 1 \]
    6. Applied egg-rr84.2%

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

        \[\leadsto \color{blue}{\left(0.5 \cdot \left(x \cdot y\right) + 1\right)} - 1 \]
      2. associate--l+84.2%

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

        \[\leadsto 0.5 \cdot \left(x \cdot y\right) + \color{blue}{0} \]
      4. *-commutative84.2%

        \[\leadsto 0.5 \cdot \color{blue}{\left(y \cdot x\right)} + 0 \]
      5. associate-*r*85.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot x \leq -2 \cdot 10^{+48}:\\ \;\;\;\;\left(y \cdot x\right) \cdot 0.5\\ \mathbf{elif}\;y \cdot x \leq 2 \cdot 10^{-45}:\\ \;\;\;\;-0.125 \cdot z\\ \mathbf{elif}\;y \cdot x \leq 1:\\ \;\;\;\;\left(y \cdot x\right) \cdot 0.5\\ \mathbf{elif}\;y \cdot x \leq 5 \cdot 10^{+75}:\\ \;\;\;\;-0.125 \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot 0.5\right)\\ \end{array} \]

Alternative 4: 100.0% accurate, 1.0× speedup?

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

\\
y \cdot \frac{x}{2} - \frac{z}{8}
\end{array}
Derivation
  1. Initial program 99.7%

    \[\frac{x \cdot y}{2} - \frac{z}{8} \]
  2. Step-by-step derivation
    1. associate-*l/100.0%

      \[\leadsto \color{blue}{\frac{x}{2} \cdot y} - \frac{z}{8} \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\frac{x}{2} \cdot y - \frac{z}{8}} \]
  4. Final simplification100.0%

    \[\leadsto y \cdot \frac{x}{2} - \frac{z}{8} \]

Alternative 5: 50.4% accurate, 3.0× speedup?

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

\\
-0.125 \cdot z
\end{array}
Derivation
  1. Initial program 99.7%

    \[\frac{x \cdot y}{2} - \frac{z}{8} \]
  2. Step-by-step derivation
    1. associate-*l/100.0%

      \[\leadsto \color{blue}{\frac{x}{2} \cdot y} - \frac{z}{8} \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\frac{x}{2} \cdot y - \frac{z}{8}} \]
  4. Taylor expanded in x around 0 50.2%

    \[\leadsto \color{blue}{-0.125 \cdot z} \]
  5. Final simplification50.2%

    \[\leadsto -0.125 \cdot z \]

Reproduce

?
herbie shell --seed 2023293 
(FPCore (x y z)
  :name "Diagrams.Solve.Polynomial:quartForm  from diagrams-solve-0.1, D"
  :precision binary64
  (- (/ (* x y) 2.0) (/ z 8.0)))