Diagrams.ThreeD.Transform:aboutX from diagrams-lib-1.3.0.3, B

Percentage Accurate: 99.8% → 99.8%
Time: 8.6s
Alternatives: 7
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ x \cdot \sin y + z \cdot \cos y \end{array} \]
(FPCore (x y z) :precision binary64 (+ (* x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
	return (x * sin(y)) + (z * cos(y));
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
	return (x * Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z):
	return (x * math.sin(y)) + (z * math.cos(y))
function code(x, y, z)
	return Float64(Float64(x * sin(y)) + Float64(z * cos(y)))
end
function tmp = code(x, y, z)
	tmp = (x * sin(y)) + (z * cos(y));
end
code[x_, y_, z_] := N[(N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \sin y + z \cdot \cos y
\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 7 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} \\ x \cdot \sin y + z \cdot \cos y \end{array} \]
(FPCore (x y z) :precision binary64 (+ (* x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
	return (x * sin(y)) + (z * cos(y));
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
	return (x * Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z):
	return (x * math.sin(y)) + (z * math.cos(y))
function code(x, y, z)
	return Float64(Float64(x * sin(y)) + Float64(z * cos(y)))
end
function tmp = code(x, y, z)
	tmp = (x * sin(y)) + (z * cos(y));
end
code[x_, y_, z_] := N[(N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \sin y + z \cdot \cos y
\end{array}

Alternative 1: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x \cdot \sin y + z \cdot \cos y \end{array} \]
(FPCore (x y z) :precision binary64 (+ (* x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
	return (x * sin(y)) + (z * cos(y));
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
	return (x * Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z):
	return (x * math.sin(y)) + (z * math.cos(y))
function code(x, y, z)
	return Float64(Float64(x * sin(y)) + Float64(z * cos(y)))
end
function tmp = code(x, y, z)
	tmp = (x * sin(y)) + (z * cos(y));
end
code[x_, y_, z_] := N[(N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \sin y + z \cdot \cos y
\end{array}
Derivation
  1. Initial program 99.8%

    \[x \cdot \sin y + z \cdot \cos y \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 85.2% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.66 \cdot 10^{+44} \lor \neg \left(z \leq 2.5 \cdot 10^{-22}\right):\\ \;\;\;\;z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;x \cdot \sin y + z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -1.66e+44) (not (<= z 2.5e-22)))
   (* z (cos y))
   (+ (* x (sin y)) z)))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.66e+44) || !(z <= 2.5e-22)) {
		tmp = z * cos(y);
	} else {
		tmp = (x * sin(y)) + 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 ((z <= (-1.66d+44)) .or. (.not. (z <= 2.5d-22))) then
        tmp = z * cos(y)
    else
        tmp = (x * sin(y)) + z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.66e+44) || !(z <= 2.5e-22)) {
		tmp = z * Math.cos(y);
	} else {
		tmp = (x * Math.sin(y)) + z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -1.66e+44) or not (z <= 2.5e-22):
		tmp = z * math.cos(y)
	else:
		tmp = (x * math.sin(y)) + z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -1.66e+44) || !(z <= 2.5e-22))
		tmp = Float64(z * cos(y));
	else
		tmp = Float64(Float64(x * sin(y)) + z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -1.66e+44) || ~((z <= 2.5e-22)))
		tmp = z * cos(y);
	else
		tmp = (x * sin(y)) + z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.66e+44], N[Not[LessEqual[z, 2.5e-22]], $MachinePrecision]], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.66 \cdot 10^{+44} \lor \neg \left(z \leq 2.5 \cdot 10^{-22}\right):\\
\;\;\;\;z \cdot \cos y\\

\mathbf{else}:\\
\;\;\;\;x \cdot \sin y + z\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.65999999999999992e44 or 2.49999999999999977e-22 < z

    1. Initial program 99.8%

      \[x \cdot \sin y + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 86.5%

      \[\leadsto \color{blue}{z \cdot \cos y} \]

    if -1.65999999999999992e44 < z < 2.49999999999999977e-22

    1. Initial program 99.8%

      \[x \cdot \sin y + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 92.3%

      \[\leadsto x \cdot \sin y + \color{blue}{z} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification89.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.66 \cdot 10^{+44} \lor \neg \left(z \leq 2.5 \cdot 10^{-22}\right):\\ \;\;\;\;z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;x \cdot \sin y + z\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 75.5% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -0.041 \lor \neg \left(y \leq 0.017\right):\\ \;\;\;\;z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;z + y \cdot \left(x + y \cdot \left(z \cdot -0.5 + -0.16666666666666666 \cdot \left(x \cdot y\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -0.041) (not (<= y 0.017)))
   (* z (cos y))
   (+ z (* y (+ x (* y (+ (* z -0.5) (* -0.16666666666666666 (* x y)))))))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -0.041) || !(y <= 0.017)) {
		tmp = z * cos(y);
	} else {
		tmp = z + (y * (x + (y * ((z * -0.5) + (-0.16666666666666666 * (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 <= (-0.041d0)) .or. (.not. (y <= 0.017d0))) then
        tmp = z * cos(y)
    else
        tmp = z + (y * (x + (y * ((z * (-0.5d0)) + ((-0.16666666666666666d0) * (x * y))))))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= -0.041) || !(y <= 0.017)) {
		tmp = z * Math.cos(y);
	} else {
		tmp = z + (y * (x + (y * ((z * -0.5) + (-0.16666666666666666 * (x * y))))));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -0.041) or not (y <= 0.017):
		tmp = z * math.cos(y)
	else:
		tmp = z + (y * (x + (y * ((z * -0.5) + (-0.16666666666666666 * (x * y))))))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -0.041) || !(y <= 0.017))
		tmp = Float64(z * cos(y));
	else
		tmp = Float64(z + Float64(y * Float64(x + Float64(y * Float64(Float64(z * -0.5) + Float64(-0.16666666666666666 * Float64(x * y)))))));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -0.041) || ~((y <= 0.017)))
		tmp = z * cos(y);
	else
		tmp = z + (y * (x + (y * ((z * -0.5) + (-0.16666666666666666 * (x * y))))));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -0.041], N[Not[LessEqual[y, 0.017]], $MachinePrecision]], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(z + N[(y * N[(x + N[(y * N[(N[(z * -0.5), $MachinePrecision] + N[(-0.16666666666666666 * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.041 \lor \neg \left(y \leq 0.017\right):\\
\;\;\;\;z \cdot \cos y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -0.0410000000000000017 or 0.017000000000000001 < y

    1. Initial program 99.6%

      \[x \cdot \sin y + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 56.1%

      \[\leadsto \color{blue}{z \cdot \cos y} \]

    if -0.0410000000000000017 < y < 0.017000000000000001

    1. Initial program 100.0%

      \[x \cdot \sin y + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 99.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -0.041 \lor \neg \left(y \leq 0.017\right):\\ \;\;\;\;z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;z + y \cdot \left(x + y \cdot \left(z \cdot -0.5 + -0.16666666666666666 \cdot \left(x \cdot y\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 73.8% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -0.0076 \lor \neg \left(y \leq 950000000000\right):\\ \;\;\;\;x \cdot \sin y\\ \mathbf{else}:\\ \;\;\;\;z + y \cdot \left(x + y \cdot \left(z \cdot -0.5 + -0.16666666666666666 \cdot \left(x \cdot y\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -0.0076) (not (<= y 950000000000.0)))
   (* x (sin y))
   (+ z (* y (+ x (* y (+ (* z -0.5) (* -0.16666666666666666 (* x y)))))))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -0.0076) || !(y <= 950000000000.0)) {
		tmp = x * sin(y);
	} else {
		tmp = z + (y * (x + (y * ((z * -0.5) + (-0.16666666666666666 * (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 <= (-0.0076d0)) .or. (.not. (y <= 950000000000.0d0))) then
        tmp = x * sin(y)
    else
        tmp = z + (y * (x + (y * ((z * (-0.5d0)) + ((-0.16666666666666666d0) * (x * y))))))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= -0.0076) || !(y <= 950000000000.0)) {
		tmp = x * Math.sin(y);
	} else {
		tmp = z + (y * (x + (y * ((z * -0.5) + (-0.16666666666666666 * (x * y))))));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -0.0076) or not (y <= 950000000000.0):
		tmp = x * math.sin(y)
	else:
		tmp = z + (y * (x + (y * ((z * -0.5) + (-0.16666666666666666 * (x * y))))))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -0.0076) || !(y <= 950000000000.0))
		tmp = Float64(x * sin(y));
	else
		tmp = Float64(z + Float64(y * Float64(x + Float64(y * Float64(Float64(z * -0.5) + Float64(-0.16666666666666666 * Float64(x * y)))))));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -0.0076) || ~((y <= 950000000000.0)))
		tmp = x * sin(y);
	else
		tmp = z + (y * (x + (y * ((z * -0.5) + (-0.16666666666666666 * (x * y))))));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -0.0076], N[Not[LessEqual[y, 950000000000.0]], $MachinePrecision]], N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision], N[(z + N[(y * N[(x + N[(y * N[(N[(z * -0.5), $MachinePrecision] + N[(-0.16666666666666666 * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.0076 \lor \neg \left(y \leq 950000000000\right):\\
\;\;\;\;x \cdot \sin y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -0.00759999999999999998 or 9.5e11 < y

    1. Initial program 99.6%

      \[x \cdot \sin y + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 45.3%

      \[\leadsto \color{blue}{x \cdot \sin y} \]

    if -0.00759999999999999998 < y < 9.5e11

    1. Initial program 100.0%

      \[x \cdot \sin y + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 98.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -0.0076 \lor \neg \left(y \leq 950000000000\right):\\ \;\;\;\;x \cdot \sin y\\ \mathbf{else}:\\ \;\;\;\;z + y \cdot \left(x + y \cdot \left(z \cdot -0.5 + -0.16666666666666666 \cdot \left(x \cdot y\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 33.9% accurate, 13.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.6 \cdot 10^{+118} \lor \neg \left(x \leq 2.5 \cdot 10^{+80}\right):\\
\;\;\;\;x \cdot y\\

\mathbf{else}:\\
\;\;\;\;y \cdot \frac{z}{y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -5.59999999999999972e118 or 2.4999999999999998e80 < x

    1. Initial program 99.8%

      \[x \cdot \sin y + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 52.9%

      \[\leadsto \color{blue}{z + x \cdot y} \]
    4. Step-by-step derivation
      1. +-commutative52.9%

        \[\leadsto \color{blue}{x \cdot y + z} \]
    5. Simplified52.9%

      \[\leadsto \color{blue}{x \cdot y + z} \]
    6. Taylor expanded in x around inf 32.3%

      \[\leadsto \color{blue}{x \cdot y} \]
    7. Step-by-step derivation
      1. *-commutative32.3%

        \[\leadsto \color{blue}{y \cdot x} \]
    8. Simplified32.3%

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

    if -5.59999999999999972e118 < x < 2.4999999999999998e80

    1. Initial program 99.8%

      \[x \cdot \sin y + z \cdot \cos y \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 54.7%

      \[\leadsto \color{blue}{z + x \cdot y} \]
    4. Step-by-step derivation
      1. +-commutative54.7%

        \[\leadsto \color{blue}{x \cdot y + z} \]
    5. Simplified54.7%

      \[\leadsto \color{blue}{x \cdot y + z} \]
    6. Taylor expanded in y around inf 44.2%

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

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

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

Alternative 6: 52.4% accurate, 41.4× speedup?

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

\\
z + x \cdot y
\end{array}
Derivation
  1. Initial program 99.8%

    \[x \cdot \sin y + z \cdot \cos y \]
  2. Add Preprocessing
  3. Taylor expanded in y around 0 54.2%

    \[\leadsto \color{blue}{z + x \cdot y} \]
  4. Step-by-step derivation
    1. +-commutative54.2%

      \[\leadsto \color{blue}{x \cdot y + z} \]
  5. Simplified54.2%

    \[\leadsto \color{blue}{x \cdot y + z} \]
  6. Final simplification54.2%

    \[\leadsto z + x \cdot y \]
  7. Add Preprocessing

Alternative 7: 16.5% accurate, 69.0× speedup?

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

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

    \[x \cdot \sin y + z \cdot \cos y \]
  2. Add Preprocessing
  3. Taylor expanded in y around 0 54.2%

    \[\leadsto \color{blue}{z + x \cdot y} \]
  4. Step-by-step derivation
    1. +-commutative54.2%

      \[\leadsto \color{blue}{x \cdot y + z} \]
  5. Simplified54.2%

    \[\leadsto \color{blue}{x \cdot y + z} \]
  6. Taylor expanded in x around inf 15.7%

    \[\leadsto \color{blue}{x \cdot y} \]
  7. Step-by-step derivation
    1. *-commutative15.7%

      \[\leadsto \color{blue}{y \cdot x} \]
  8. Simplified15.7%

    \[\leadsto \color{blue}{y \cdot x} \]
  9. Final simplification15.7%

    \[\leadsto x \cdot y \]
  10. Add Preprocessing

Reproduce

?
herbie shell --seed 2024132 
(FPCore (x y z)
  :name "Diagrams.ThreeD.Transform:aboutX from diagrams-lib-1.3.0.3, B"
  :precision binary64
  (+ (* x (sin y)) (* z (cos y))))