?

Average Accuracy: 99.8% → 99.8%
Time: 10.3s
Precision: binary64
Cost: 19520

?

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

Error?

Derivation?

  1. Initial program 99.8%

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

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

    [Start]99.8

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

    fma-def [=>]99.8

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

    \[\leadsto \color{blue}{\cos y \cdot z + \sin y \cdot x} \]
  4. Simplified99.8%

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

    [Start]99.8

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

    *-commutative [<=]99.8

    \[ \cos y \cdot z + \color{blue}{x \cdot \sin y} \]

    fma-def [=>]99.8

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

    *-commutative [=>]99.8

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

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

Alternatives

Alternative 1
Accuracy99.8%
Cost19520
\[\mathsf{fma}\left(x, \sin y, \cos y \cdot z\right) \]
Alternative 2
Accuracy99.8%
Cost13248
\[\sin y \cdot x + \cos y \cdot z \]
Alternative 3
Accuracy75.3%
Cost7516
\[\begin{array}{l} t_0 := \sin y \cdot x\\ t_1 := \cos y \cdot z\\ \mathbf{if}\;y \leq -3.5 \cdot 10^{+220}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -6.2 \cdot 10^{+140}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -9.4 \cdot 10^{+73}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.55 \cdot 10^{+50}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -8:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-8}:\\ \;\;\;\;z + y \cdot x\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{+136}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Accuracy85.5%
Cost6985
\[\begin{array}{l} \mathbf{if}\;z \leq -6.5 \cdot 10^{+106} \lor \neg \left(z \leq 9.5 \cdot 10^{+25}\right):\\ \;\;\;\;\cos y \cdot z\\ \mathbf{else}:\\ \;\;\;\;z + \sin y \cdot x\\ \end{array} \]
Alternative 5
Accuracy75.3%
Cost6857
\[\begin{array}{l} \mathbf{if}\;y \leq -0.00026 \lor \neg \left(y \leq 0.0068\right):\\ \;\;\;\;\cos y \cdot z\\ \mathbf{else}:\\ \;\;\;\;z + y \cdot x\\ \end{array} \]
Alternative 6
Accuracy40.2%
Cost588
\[\begin{array}{l} \mathbf{if}\;x \leq -3.2 \cdot 10^{+138}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{+127}:\\ \;\;\;\;z\\ \mathbf{elif}\;x \leq 7 \cdot 10^{+177}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 7
Accuracy51.9%
Cost320
\[z + y \cdot x \]
Alternative 8
Accuracy39.3%
Cost64
\[z \]

Error

Reproduce?

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