Average Error: 0.1 → 0.1
Time: 5.7s
Precision: binary64
\[x \cdot \sin y + z \cdot \cos y \]
\[\begin{array}{l} t_0 := \mathsf{expm1}\left(\mathsf{log1p}\left(\cos y\right) \cdot 2\right)\\ \mathsf{fma}\left(x, \sin y, z \cdot \left(\cos y \cdot \frac{t_0}{t_0}\right)\right) \end{array} \]
(FPCore (x y z) :precision binary64 (+ (* x (sin y)) (* z (cos y))))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (expm1 (* (log1p (cos y)) 2.0))))
   (fma x (sin y) (* z (* (cos y) (/ t_0 t_0))))))
double code(double x, double y, double z) {
	return (x * sin(y)) + (z * cos(y));
}
double code(double x, double y, double z) {
	double t_0 = expm1((log1p(cos(y)) * 2.0));
	return fma(x, sin(y), (z * (cos(y) * (t_0 / t_0))));
}
function code(x, y, z)
	return Float64(Float64(x * sin(y)) + Float64(z * cos(y)))
end
function code(x, y, z)
	t_0 = expm1(Float64(log1p(cos(y)) * 2.0))
	return fma(x, sin(y), Float64(z * Float64(cos(y) * Float64(t_0 / t_0))))
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_] := Block[{t$95$0 = N[(Exp[N[(N[Log[1 + N[Cos[y], $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision]] - 1), $MachinePrecision]}, N[(x * N[Sin[y], $MachinePrecision] + N[(z * N[(N[Cos[y], $MachinePrecision] * N[(t$95$0 / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
x \cdot \sin y + z \cdot \cos y
\begin{array}{l}
t_0 := \mathsf{expm1}\left(\mathsf{log1p}\left(\cos y\right) \cdot 2\right)\\
\mathsf{fma}\left(x, \sin y, z \cdot \left(\cos y \cdot \frac{t_0}{t_0}\right)\right)
\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

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)} \]
  3. Applied egg-rr0.1

    \[\leadsto \mathsf{fma}\left(x, \sin y, z \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\cos y\right)\right)}\right) \]
  4. Applied egg-rr0.3

    \[\leadsto \mathsf{fma}\left(x, \sin y, z \cdot \color{blue}{\frac{\left(\cos y + 1\right) \cdot \left(\cos y + 1\right) - 1}{\left(\cos y + 1\right) + 1}}\right) \]
  5. Applied egg-rr0.1

    \[\leadsto \mathsf{fma}\left(x, \sin y, z \cdot \color{blue}{\left(\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\cos y\right) \cdot 2\right)}{\mathsf{expm1}\left(\mathsf{log1p}\left(\cos y\right) \cdot 2\right)} \cdot \cos y\right)}\right) \]
  6. Final simplification0.1

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

Reproduce

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