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

Percentage Accurate: 99.8% → 99.8%
Time: 7.0s
Alternatives: 9
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 9 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, 0.7× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\cos y, z, \sin y \cdot x\right) \end{array} \]
(FPCore (x y z) :precision binary64 (fma (cos y) z (* (sin y) x)))
double code(double x, double y, double z) {
	return fma(cos(y), z, (sin(y) * x));
}
function code(x, y, z)
	return fma(cos(y), z, Float64(sin(y) * x))
end
code[x_, y_, z_] := N[(N[Cos[y], $MachinePrecision] * z + N[(N[Sin[y], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\cos y, z, \sin y \cdot x\right)
\end{array}
Derivation
  1. Initial program 99.8%

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

    \[\leadsto \color{blue}{\cos y \cdot z + \sin y \cdot x} \]
  3. Step-by-step derivation
    1. fma-def99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos y, z, \sin y \cdot x\right)} \]
  4. Simplified99.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\cos y, z, \sin y \cdot x\right)} \]
  5. Final simplification99.8%

    \[\leadsto \mathsf{fma}\left(\cos y, z, \sin y \cdot x\right) \]

Alternative 2: 99.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(x, \sin y, \cos y \cdot z\right) \end{array} \]
(FPCore (x y z) :precision binary64 (fma x (sin y) (* (cos y) z)))
double code(double x, double y, double z) {
	return fma(x, sin(y), (cos(y) * z));
}
function code(x, y, z)
	return fma(x, sin(y), Float64(cos(y) * z))
end
code[x_, y_, z_] := N[(x * N[Sin[y], $MachinePrecision] + N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(x, \sin y, \cos y \cdot z\right)
\end{array}
Derivation
  1. Initial program 99.8%

    \[x \cdot \sin y + z \cdot \cos y \]
  2. Step-by-step derivation
    1. fma-def99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, \sin y, z \cdot \cos y\right)} \]
  3. Simplified99.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, \sin y, z \cdot \cos y\right)} \]
  4. Final simplification99.8%

    \[\leadsto \mathsf{fma}\left(x, \sin y, \cos y \cdot z\right) \]

Alternative 3: 87.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -6 \cdot 10^{+57} \lor \neg \left(z \leq 2.7 \cdot 10^{+29}\right):\\ \;\;\;\;\cos y \cdot z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, \sin y, z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -6e+57) (not (<= z 2.7e+29))) (* (cos y) z) (fma x (sin y) z)))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -6e+57) || !(z <= 2.7e+29)) {
		tmp = cos(y) * z;
	} else {
		tmp = fma(x, sin(y), z);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if ((z <= -6e+57) || !(z <= 2.7e+29))
		tmp = Float64(cos(y) * z);
	else
		tmp = fma(x, sin(y), z);
	end
	return tmp
end
code[x_, y_, z_] := If[Or[LessEqual[z, -6e+57], N[Not[LessEqual[z, 2.7e+29]], $MachinePrecision]], N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision], N[(x * N[Sin[y], $MachinePrecision] + z), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -6 \cdot 10^{+57} \lor \neg \left(z \leq 2.7 \cdot 10^{+29}\right):\\
\;\;\;\;\cos y \cdot z\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \sin y, z\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -5.9999999999999999e57 or 2.7e29 < z

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{\cos y \cdot z + \sin y \cdot x} \]
    3. Step-by-step derivation
      1. fma-def99.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\cos y, z, \sin y \cdot x\right)} \]
    4. Simplified99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos y, z, \sin y \cdot x\right)} \]
    5. Taylor expanded in z around inf 89.7%

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

    if -5.9999999999999999e57 < z < 2.7e29

    1. Initial program 99.8%

      \[x \cdot \sin y + z \cdot \cos y \]
    2. Step-by-step derivation
      1. fma-def99.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \sin y, z \cdot \cos y\right)} \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, \sin y, z \cdot \cos y\right)} \]
    4. Taylor expanded in y around 0 87.5%

      \[\leadsto \mathsf{fma}\left(x, \sin y, \color{blue}{z}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification88.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -6 \cdot 10^{+57} \lor \neg \left(z \leq 2.7 \cdot 10^{+29}\right):\\ \;\;\;\;\cos y \cdot z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, \sin y, z\right)\\ \end{array} \]

Alternative 4: 99.8% accurate, 1.0× speedup?

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

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

    \[x \cdot \sin y + z \cdot \cos y \]
  2. Final simplification99.8%

    \[\leadsto \sin y \cdot x + \cos y \cdot z \]

Alternative 5: 87.0% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -6 \cdot 10^{+57} \lor \neg \left(z \leq 2.2 \cdot 10^{+27}\right):\\
\;\;\;\;\cos y \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -5.9999999999999999e57 or 2.1999999999999999e27 < z

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{\cos y \cdot z + \sin y \cdot x} \]
    3. Step-by-step derivation
      1. fma-def99.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\cos y, z, \sin y \cdot x\right)} \]
    4. Simplified99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos y, z, \sin y \cdot x\right)} \]
    5. Taylor expanded in z around inf 89.7%

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

    if -5.9999999999999999e57 < z < 2.1999999999999999e27

    1. Initial program 99.8%

      \[x \cdot \sin y + z \cdot \cos y \]
    2. Taylor expanded in y around 0 87.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -6 \cdot 10^{+57} \lor \neg \left(z \leq 2.2 \cdot 10^{+27}\right):\\ \;\;\;\;\cos y \cdot z\\ \mathbf{else}:\\ \;\;\;\;z + \sin y \cdot x\\ \end{array} \]

Alternative 6: 74.9% accurate, 1.9× speedup?

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

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

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


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

    1. Initial program 99.6%

      \[x \cdot \sin y + z \cdot \cos y \]
    2. Taylor expanded in x around 0 99.6%

      \[\leadsto \color{blue}{\cos y \cdot z + \sin y \cdot x} \]
    3. Step-by-step derivation
      1. fma-def99.6%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\cos y, z, \sin y \cdot x\right)} \]
    4. Simplified99.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos y, z, \sin y \cdot x\right)} \]
    5. Taylor expanded in z around inf 53.0%

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

    if -0.0040000000000000001 < y < 0.429999999999999993

    1. Initial program 100.0%

      \[x \cdot \sin y + z \cdot \cos y \]
    2. Taylor expanded in y around 0 99.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -0.004 \lor \neg \left(y \leq 0.43\right):\\ \;\;\;\;\cos y \cdot z\\ \mathbf{else}:\\ \;\;\;\;z + y \cdot x\\ \end{array} \]

Alternative 7: 74.6% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -7 \cdot 10^{-99} \lor \neg \left(z \leq 5 \cdot 10^{-144}\right):\\
\;\;\;\;\cos y \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -6.9999999999999997e-99 or 4.9999999999999998e-144 < z

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{\cos y \cdot z + \sin y \cdot x} \]
    3. Step-by-step derivation
      1. fma-def99.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\cos y, z, \sin y \cdot x\right)} \]
    4. Simplified99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos y, z, \sin y \cdot x\right)} \]
    5. Taylor expanded in z around inf 82.6%

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

    if -6.9999999999999997e-99 < z < 4.9999999999999998e-144

    1. Initial program 99.7%

      \[x \cdot \sin y + z \cdot \cos y \]
    2. Taylor expanded in x around 0 99.7%

      \[\leadsto \color{blue}{\cos y \cdot z + \sin y \cdot x} \]
    3. Step-by-step derivation
      1. fma-def99.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\cos y, z, \sin y \cdot x\right)} \]
    4. Simplified99.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos y, z, \sin y \cdot x\right)} \]
    5. Taylor expanded in z around 0 70.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7 \cdot 10^{-99} \lor \neg \left(z \leq 5 \cdot 10^{-144}\right):\\ \;\;\;\;\cos y \cdot z\\ \mathbf{else}:\\ \;\;\;\;\sin y \cdot x\\ \end{array} \]

Alternative 8: 53.1% accurate, 41.4× speedup?

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

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

    \[x \cdot \sin y + z \cdot \cos y \]
  2. Taylor expanded in y around 0 51.5%

    \[\leadsto \color{blue}{y \cdot x + z} \]
  3. Final simplification51.5%

    \[\leadsto z + y \cdot x \]

Alternative 9: 38.8% accurate, 207.0× speedup?

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

\\
z
\end{array}
Derivation
  1. Initial program 99.8%

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

    \[\leadsto \color{blue}{\cos y \cdot z + \sin y \cdot x} \]
  3. Step-by-step derivation
    1. fma-def99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos y, z, \sin y \cdot x\right)} \]
  4. Simplified99.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\cos y, z, \sin y \cdot x\right)} \]
  5. Taylor expanded in y around 0 43.1%

    \[\leadsto \color{blue}{z} \]
  6. Final simplification43.1%

    \[\leadsto z \]

Reproduce

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