Average Error: 59.8 → 59.9
Time: 13.0s
Precision: binary64
\[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
\[\frac{\left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left({x}^{4}, -0.010416666666666666, \mathsf{fma}\left(x, x \cdot -0.25, 1\right)\right)\right)\right)}{e^{x}} \]
(FPCore (x) :precision binary64 (* (fmod (exp x) (sqrt (cos x))) (exp (- x))))
(FPCore (x)
 :precision binary64
 (/
  (fmod
   (exp x)
   (fma (pow x 4.0) -0.010416666666666666 (fma x (* x -0.25) 1.0)))
  (exp x)))
double code(double x) {
	return fmod(exp(x), sqrt(cos(x))) * exp(-x);
}
double code(double x) {
	return fmod(exp(x), fma(pow(x, 4.0), -0.010416666666666666, fma(x, (x * -0.25), 1.0))) / exp(x);
}
function code(x)
	return Float64(rem(exp(x), sqrt(cos(x))) * exp(Float64(-x)))
end
function code(x)
	return Float64(rem(exp(x), fma((x ^ 4.0), -0.010416666666666666, fma(x, Float64(x * -0.25), 1.0))) / exp(x))
end
code[x_] := N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(N[Power[x, 4.0], $MachinePrecision] * -0.010416666666666666 + N[(x * N[(x * -0.25), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]
\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x}
\frac{\left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left({x}^{4}, -0.010416666666666666, \mathsf{fma}\left(x, x \cdot -0.25, 1\right)\right)\right)\right)}{e^{x}}

Error

Bits error versus x

Derivation

  1. Initial program 59.8

    \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
  2. Simplified59.8

    \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
  3. Taylor expanded in x around 0 59.9

    \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \color{blue}{\left(1 - \left(0.010416666666666666 \cdot {x}^{4} + 0.25 \cdot {x}^{2}\right)\right)}\right)}{e^{x}} \]
  4. Simplified59.9

    \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \color{blue}{\left(\mathsf{fma}\left({x}^{4}, -0.010416666666666666, \mathsf{fma}\left(x, x \cdot -0.25, 1\right)\right)\right)}\right)}{e^{x}} \]
  5. Final simplification59.9

    \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left({x}^{4}, -0.010416666666666666, \mathsf{fma}\left(x, x \cdot -0.25, 1\right)\right)\right)\right)}{e^{x}} \]

Reproduce

herbie shell --seed 2022129 
(FPCore (x)
  :name "expfmod"
  :precision binary64
  (* (fmod (exp x) (sqrt (cos x))) (exp (- x))))