Average Error: 0.1 → 0.1
Time: 8.0s
Precision: binary64
Cost: 19520
\[x \cdot \sin y + z \cdot \cos y \]
\[\mathsf{fma}\left(x, \sin y, z \cdot \cos y\right) \]
(FPCore (x y z) :precision binary64 (+ (* x (sin y)) (* z (cos y))))
(FPCore (x y z) :precision binary64 (fma x (sin y) (* z (cos y))))
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(x, sin(y), (z * cos(y)));
}
function code(x, y, z)
	return Float64(Float64(x * sin(y)) + Float64(z * cos(y)))
end
function code(x, y, z)
	return fma(x, sin(y), Float64(z * cos(y)))
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[(x * N[Sin[y], $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x \cdot \sin y + z \cdot \cos y
\mathsf{fma}\left(x, \sin y, z \cdot \cos y\right)

Error

Derivation

  1. Initial program 0.1

    \[x \cdot \sin y + z \cdot \cos y \]
  2. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, \sin y, z \cdot \cos y\right)} \]
    Proof
    (fma.f64 x (sin.f64 y) (*.f64 z (cos.f64 y))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y)))): 1 points increase in error, 0 points decrease in error
  3. Final simplification0.1

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

Alternatives

Alternative 1
Error0.1
Cost13248
\[z \cdot \cos y + x \cdot \sin y \]
Alternative 2
Error16.2
Cost6988
\[\begin{array}{l} t_0 := x \cdot \sin y\\ \mathbf{if}\;y \leq -0.0027:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 0.005:\\ \;\;\;\;z + x \cdot y\\ \mathbf{elif}\;y \leq 6.2 \cdot 10^{+266}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;z \cdot \cos y\\ \end{array} \]
Alternative 3
Error16.2
Cost6988
\[\begin{array}{l} t_0 := x \cdot \sin y\\ \mathbf{if}\;y \leq -0.000105:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 0.0056:\\ \;\;\;\;\mathsf{fma}\left(y, x, z\right)\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{+264}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;z \cdot \cos y\\ \end{array} \]
Alternative 4
Error8.9
Cost6984
\[\begin{array}{l} t_0 := z + x \cdot \sin y\\ \mathbf{if}\;x \leq -2.4 \cdot 10^{-89}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{-49}:\\ \;\;\;\;z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error16.6
Cost6856
\[\begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;y \leq -28:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.75 \cdot 10^{-7}:\\ \;\;\;\;z + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error37.6
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -2.7 \cdot 10^{+189}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 10^{+144}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 7
Error31.2
Cost320
\[z + x \cdot y \]
Alternative 8
Error39.1
Cost64
\[z \]

Error

Reproduce

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