expfmod (used to be hard to sample)

Percentage Accurate: 6.7% → 65.5%
Time: 14.4s
Alternatives: 6
Speedup: 4.1×

Specification

?
\[\begin{array}{l} \\ \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \end{array} \]
(FPCore (x) :precision binary64 (* (fmod (exp x) (sqrt (cos x))) (exp (- x))))
double code(double x) {
	return fmod(exp(x), sqrt(cos(x))) * exp(-x);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = mod(exp(x), sqrt(cos(x))) * exp(-x)
end function
def code(x):
	return math.fmod(math.exp(x), math.sqrt(math.cos(x))) * math.exp(-x)
function code(x)
	return Float64(rem(exp(x), sqrt(cos(x))) * exp(Float64(-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]
\begin{array}{l}

\\
\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x}
\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 6 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: 6.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \end{array} \]
(FPCore (x) :precision binary64 (* (fmod (exp x) (sqrt (cos x))) (exp (- x))))
double code(double x) {
	return fmod(exp(x), sqrt(cos(x))) * exp(-x);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = mod(exp(x), sqrt(cos(x))) * exp(-x)
end function
def code(x):
	return math.fmod(math.exp(x), math.sqrt(math.cos(x))) * math.exp(-x)
function code(x)
	return Float64(rem(exp(x), sqrt(cos(x))) * exp(Float64(-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]
\begin{array}{l}

\\
\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x}
\end{array}

Alternative 1: 65.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{0 - x}\\ t_1 := x \cdot \mathsf{fma}\left(x, x, 0\right)\\ \mathbf{if}\;x \leq -1.35 \cdot 10^{-108}:\\ \;\;\;\;\left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(t\_1 \cdot \frac{t\_1}{\mathsf{fma}\left(x, t\_1, 0\right)}, -0.003298611111111111, -0.010416666666666666\right), -0.25\right), 1\right)\right)\right) \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot \left(x \bmod 1\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (exp (- 0.0 x))) (t_1 (* x (fma x x 0.0))))
   (if (<= x -1.35e-108)
     (*
      (fmod
       (exp x)
       (fma
        (fma x x 0.0)
        (fma
         x
         (*
          x
          (fma
           (* t_1 (/ t_1 (fma x t_1 0.0)))
           -0.003298611111111111
           -0.010416666666666666))
         -0.25)
        1.0))
      t_0)
     (* t_0 (fmod x 1.0)))))
double code(double x) {
	double t_0 = exp((0.0 - x));
	double t_1 = x * fma(x, x, 0.0);
	double tmp;
	if (x <= -1.35e-108) {
		tmp = fmod(exp(x), fma(fma(x, x, 0.0), fma(x, (x * fma((t_1 * (t_1 / fma(x, t_1, 0.0))), -0.003298611111111111, -0.010416666666666666)), -0.25), 1.0)) * t_0;
	} else {
		tmp = t_0 * fmod(x, 1.0);
	}
	return tmp;
}
function code(x)
	t_0 = exp(Float64(0.0 - x))
	t_1 = Float64(x * fma(x, x, 0.0))
	tmp = 0.0
	if (x <= -1.35e-108)
		tmp = Float64(rem(exp(x), fma(fma(x, x, 0.0), fma(x, Float64(x * fma(Float64(t_1 * Float64(t_1 / fma(x, t_1, 0.0))), -0.003298611111111111, -0.010416666666666666)), -0.25), 1.0)) * t_0);
	else
		tmp = Float64(t_0 * rem(x, 1.0));
	end
	return tmp
end
code[x_] := Block[{t$95$0 = N[Exp[N[(0.0 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(x * x + 0.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.35e-108], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(N[(x * x + 0.0), $MachinePrecision] * N[(x * N[(x * N[(N[(t$95$1 * N[(t$95$1 / N[(x * t$95$1 + 0.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.003298611111111111 + -0.010416666666666666), $MachinePrecision]), $MachinePrecision] + -0.25), $MachinePrecision] + 1.0), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$0), $MachinePrecision], N[(t$95$0 * N[With[{TMP1 = x, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{0 - x}\\
t_1 := x \cdot \mathsf{fma}\left(x, x, 0\right)\\
\mathbf{if}\;x \leq -1.35 \cdot 10^{-108}:\\
\;\;\;\;\left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(t\_1 \cdot \frac{t\_1}{\mathsf{fma}\left(x, t\_1, 0\right)}, -0.003298611111111111, -0.010416666666666666\right), -0.25\right), 1\right)\right)\right) \cdot t\_0\\

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(x \bmod 1\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.35000000000000002e-108

    1. Initial program 15.8%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \left(\left(e^{x}\right) \bmod \color{blue}{\left(1 + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-19}{5760} \cdot {x}^{2} - \frac{1}{96}\right) - \frac{1}{4}\right)\right)}\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \color{blue}{\left({x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-19}{5760} \cdot {x}^{2} - \frac{1}{96}\right) - \frac{1}{4}\right) + 1\right)}\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \color{blue}{\left(\mathsf{fma}\left({x}^{2}, {x}^{2} \cdot \left(\frac{-19}{5760} \cdot {x}^{2} - \frac{1}{96}\right) - \frac{1}{4}, 1\right)\right)}\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      3. +-lft-identityN/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\color{blue}{0 + {x}^{2}}, {x}^{2} \cdot \left(\frac{-19}{5760} \cdot {x}^{2} - \frac{1}{96}\right) - \frac{1}{4}, 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      4. +-commutativeN/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\color{blue}{{x}^{2} + 0}, {x}^{2} \cdot \left(\frac{-19}{5760} \cdot {x}^{2} - \frac{1}{96}\right) - \frac{1}{4}, 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      5. unpow2N/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\color{blue}{x \cdot x} + 0, {x}^{2} \cdot \left(\frac{-19}{5760} \cdot {x}^{2} - \frac{1}{96}\right) - \frac{1}{4}, 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(x, x, 0\right)}, {x}^{2} \cdot \left(\frac{-19}{5760} \cdot {x}^{2} - \frac{1}{96}\right) - \frac{1}{4}, 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      7. sub-negN/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \color{blue}{{x}^{2} \cdot \left(\frac{-19}{5760} \cdot {x}^{2} - \frac{1}{96}\right) + \left(\mathsf{neg}\left(\frac{1}{4}\right)\right)}, 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      8. unpow2N/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{-19}{5760} \cdot {x}^{2} - \frac{1}{96}\right) + \left(\mathsf{neg}\left(\frac{1}{4}\right)\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      9. associate-*l*N/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \color{blue}{x \cdot \left(x \cdot \left(\frac{-19}{5760} \cdot {x}^{2} - \frac{1}{96}\right)\right)} + \left(\mathsf{neg}\left(\frac{1}{4}\right)\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      10. metadata-evalN/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), x \cdot \left(x \cdot \left(\frac{-19}{5760} \cdot {x}^{2} - \frac{1}{96}\right)\right) + \color{blue}{\frac{-1}{4}}, 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      11. accelerator-lowering-fma.f64N/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \color{blue}{\mathsf{fma}\left(x, x \cdot \left(\frac{-19}{5760} \cdot {x}^{2} - \frac{1}{96}\right), \frac{-1}{4}\right)}, 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      12. *-lowering-*.f64N/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, \color{blue}{x \cdot \left(\frac{-19}{5760} \cdot {x}^{2} - \frac{1}{96}\right)}, \frac{-1}{4}\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      13. sub-negN/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \color{blue}{\left(\frac{-19}{5760} \cdot {x}^{2} + \left(\mathsf{neg}\left(\frac{1}{96}\right)\right)\right)}, \frac{-1}{4}\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      14. *-commutativeN/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \left(\color{blue}{{x}^{2} \cdot \frac{-19}{5760}} + \left(\mathsf{neg}\left(\frac{1}{96}\right)\right)\right), \frac{-1}{4}\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      15. metadata-evalN/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \left({x}^{2} \cdot \frac{-19}{5760} + \color{blue}{\frac{-1}{96}}\right), \frac{-1}{4}\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      16. accelerator-lowering-fma.f64N/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \color{blue}{\mathsf{fma}\left({x}^{2}, \frac{-19}{5760}, \frac{-1}{96}\right)}, \frac{-1}{4}\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      17. +-lft-identityN/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\color{blue}{0 + {x}^{2}}, \frac{-19}{5760}, \frac{-1}{96}\right), \frac{-1}{4}\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      18. +-commutativeN/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\color{blue}{{x}^{2} + 0}, \frac{-19}{5760}, \frac{-1}{96}\right), \frac{-1}{4}\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      19. unpow2N/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\color{blue}{x \cdot x} + 0, \frac{-19}{5760}, \frac{-1}{96}\right), \frac{-1}{4}\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      20. accelerator-lowering-fma.f6415.8

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(x, x, 0\right)}, -0.003298611111111111, -0.010416666666666666\right), -0.25\right), 1\right)\right)\right) \cdot e^{-x} \]
    5. Simplified15.8%

      \[\leadsto \left(\left(e^{x}\right) \bmod \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), -0.003298611111111111, -0.010416666666666666\right), -0.25\right), 1\right)\right)}\right) \cdot e^{-x} \]
    6. Step-by-step derivation
      1. flip-+N/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\color{blue}{\frac{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - 0 \cdot 0}{x \cdot x - 0}}, \frac{-19}{5760}, \frac{-1}{96}\right), \frac{-1}{4}\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      2. metadata-evalN/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\frac{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - \color{blue}{0}}{x \cdot x - 0}, \frac{-19}{5760}, \frac{-1}{96}\right), \frac{-1}{4}\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      3. --rgt-identityN/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\frac{\color{blue}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{x \cdot x - 0}, \frac{-19}{5760}, \frac{-1}{96}\right), \frac{-1}{4}\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      4. associate-*r*N/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\frac{\color{blue}{\left(\left(x \cdot x\right) \cdot x\right) \cdot x}}{x \cdot x - 0}, \frac{-19}{5760}, \frac{-1}{96}\right), \frac{-1}{4}\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      5. unpow3N/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\frac{\color{blue}{{x}^{3}} \cdot x}{x \cdot x - 0}, \frac{-19}{5760}, \frac{-1}{96}\right), \frac{-1}{4}\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      6. flip--N/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\frac{{x}^{3} \cdot x}{\color{blue}{\frac{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - 0 \cdot 0}{x \cdot x + 0}}}, \frac{-19}{5760}, \frac{-1}{96}\right), \frac{-1}{4}\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      7. metadata-evalN/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\frac{{x}^{3} \cdot x}{\frac{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - \color{blue}{0}}{x \cdot x + 0}}, \frac{-19}{5760}, \frac{-1}{96}\right), \frac{-1}{4}\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      8. --rgt-identityN/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\frac{{x}^{3} \cdot x}{\frac{\color{blue}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{x \cdot x + 0}}, \frac{-19}{5760}, \frac{-1}{96}\right), \frac{-1}{4}\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      9. +-rgt-identityN/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\frac{{x}^{3} \cdot x}{\frac{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}{\color{blue}{x \cdot x}}}, \frac{-19}{5760}, \frac{-1}{96}\right), \frac{-1}{4}\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      10. div-invN/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\frac{{x}^{3} \cdot x}{\color{blue}{\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{x \cdot x}}}, \frac{-19}{5760}, \frac{-1}{96}\right), \frac{-1}{4}\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      11. +-rgt-identityN/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\frac{{x}^{3} \cdot x}{\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{\color{blue}{x \cdot x + 0}}}, \frac{-19}{5760}, \frac{-1}{96}\right), \frac{-1}{4}\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      12. mul0-lftN/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\frac{{x}^{3} \cdot x}{\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{x \cdot x + \color{blue}{0 \cdot x}}}, \frac{-19}{5760}, \frac{-1}{96}\right), \frac{-1}{4}\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      13. +-lft-identityN/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\frac{{x}^{3} \cdot x}{\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{\color{blue}{0 + \left(x \cdot x + 0 \cdot x\right)}}}, \frac{-19}{5760}, \frac{-1}{96}\right), \frac{-1}{4}\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      14. metadata-evalN/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\frac{{x}^{3} \cdot x}{\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{\color{blue}{0 \cdot 0} + \left(x \cdot x + 0 \cdot x\right)}}, \frac{-19}{5760}, \frac{-1}{96}\right), \frac{-1}{4}\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      15. times-fracN/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\color{blue}{\frac{{x}^{3}}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} \cdot \frac{x}{\frac{1}{0 \cdot 0 + \left(x \cdot x + 0 \cdot x\right)}}}, \frac{-19}{5760}, \frac{-1}{96}\right), \frac{-1}{4}\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      16. un-div-invN/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\frac{{x}^{3}}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} \cdot \color{blue}{\left(x \cdot \frac{1}{\frac{1}{0 \cdot 0 + \left(x \cdot x + 0 \cdot x\right)}}\right)}, \frac{-19}{5760}, \frac{-1}{96}\right), \frac{-1}{4}\right), 1\right)\right)\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
    7. Applied egg-rr38.4%

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

    if -1.35000000000000002e-108 < x

    1. Initial program 6.6%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \left(\left(e^{x}\right) \bmod \color{blue}{1}\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
    4. Step-by-step derivation
      1. Simplified5.6%

        \[\leadsto \left(\left(e^{x}\right) \bmod \color{blue}{1}\right) \cdot e^{-x} \]
      2. Taylor expanded in x around 0

        \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod 1\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      3. Step-by-step derivation
        1. +-lowering-+.f6428.5

          \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod 1\right) \cdot e^{-x} \]
      4. Simplified28.5%

        \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod 1\right) \cdot e^{-x} \]
      5. Taylor expanded in x around inf

        \[\leadsto \left(\color{blue}{x} \bmod 1\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
      6. Step-by-step derivation
        1. Simplified71.3%

          \[\leadsto \left(\color{blue}{x} \bmod 1\right) \cdot e^{-x} \]
      7. Recombined 2 regimes into one program.
      8. Final simplification67.4%

        \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.35 \cdot 10^{-108}:\\ \;\;\;\;\left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(\mathsf{fma}\left(x, x, 0\right), \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\left(x \cdot \mathsf{fma}\left(x, x, 0\right)\right) \cdot \frac{x \cdot \mathsf{fma}\left(x, x, 0\right)}{\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, x, 0\right), 0\right)}, -0.003298611111111111, -0.010416666666666666\right), -0.25\right), 1\right)\right)\right) \cdot e^{0 - x}\\ \mathbf{else}:\\ \;\;\;\;e^{0 - x} \cdot \left(x \bmod 1\right)\\ \end{array} \]
      9. Add Preprocessing

      Alternative 2: 62.0% accurate, 1.3× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{\left(\left(e^{x}\right) \bmod 1\right)}{e^{x}}\\ \mathbf{else}:\\ \;\;\;\;e^{0 - x} \cdot \left(x \bmod 1\right)\\ \end{array} \end{array} \]
      (FPCore (x)
       :precision binary64
       (if (<= x -5e-310)
         (/ (fmod (exp x) 1.0) (exp x))
         (* (exp (- 0.0 x)) (fmod x 1.0))))
      double code(double x) {
      	double tmp;
      	if (x <= -5e-310) {
      		tmp = fmod(exp(x), 1.0) / exp(x);
      	} else {
      		tmp = exp((0.0 - x)) * fmod(x, 1.0);
      	}
      	return tmp;
      }
      
      real(8) function code(x)
          real(8), intent (in) :: x
          real(8) :: tmp
          if (x <= (-5d-310)) then
              tmp = mod(exp(x), 1.0d0) / exp(x)
          else
              tmp = exp((0.0d0 - x)) * mod(x, 1.0d0)
          end if
          code = tmp
      end function
      
      def code(x):
      	tmp = 0
      	if x <= -5e-310:
      		tmp = math.fmod(math.exp(x), 1.0) / math.exp(x)
      	else:
      		tmp = math.exp((0.0 - x)) * math.fmod(x, 1.0)
      	return tmp
      
      function code(x)
      	tmp = 0.0
      	if (x <= -5e-310)
      		tmp = Float64(rem(exp(x), 1.0) / exp(x));
      	else
      		tmp = Float64(exp(Float64(0.0 - x)) * rem(x, 1.0));
      	end
      	return tmp
      end
      
      code[x_] := If[LessEqual[x, -5e-310], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(0.0 - x), $MachinePrecision]], $MachinePrecision] * N[With[{TMP1 = x, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;x \leq -5 \cdot 10^{-310}:\\
      \;\;\;\;\frac{\left(\left(e^{x}\right) \bmod 1\right)}{e^{x}}\\
      
      \mathbf{else}:\\
      \;\;\;\;e^{0 - x} \cdot \left(x \bmod 1\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < -4.999999999999985e-310

        1. Initial program 7.3%

          \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
        2. Add Preprocessing
        3. Taylor expanded in x around 0

          \[\leadsto \left(\left(e^{x}\right) \bmod \color{blue}{1}\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
        4. Step-by-step derivation
          1. Simplified7.3%

            \[\leadsto \left(\left(e^{x}\right) \bmod \color{blue}{1}\right) \cdot e^{-x} \]
          2. Step-by-step derivation
            1. exp-negN/A

              \[\leadsto \left(\left(e^{x}\right) \bmod 1\right) \cdot \color{blue}{\frac{1}{e^{x}}} \]
            2. un-div-invN/A

              \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod 1\right)}{e^{x}}} \]
            3. /-lowering-/.f64N/A

              \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod 1\right)}{e^{x}}} \]
            4. fmod-lowering-fmod.f64N/A

              \[\leadsto \frac{\color{blue}{\left(\left(e^{x}\right) \bmod 1\right)}}{e^{x}} \]
            5. exp-lowering-exp.f64N/A

              \[\leadsto \frac{\left(\color{blue}{\left(e^{x}\right)} \bmod 1\right)}{e^{x}} \]
            6. exp-lowering-exp.f647.3

              \[\leadsto \frac{\left(\left(e^{x}\right) \bmod 1\right)}{\color{blue}{e^{x}}} \]
          3. Applied egg-rr7.3%

            \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod 1\right)}{e^{x}}} \]

          if -4.999999999999985e-310 < x

          1. Initial program 7.9%

            \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
          2. Add Preprocessing
          3. Taylor expanded in x around 0

            \[\leadsto \left(\left(e^{x}\right) \bmod \color{blue}{1}\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
          4. Step-by-step derivation
            1. Simplified6.5%

              \[\leadsto \left(\left(e^{x}\right) \bmod \color{blue}{1}\right) \cdot e^{-x} \]
            2. Taylor expanded in x around 0

              \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod 1\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
            3. Step-by-step derivation
              1. +-lowering-+.f6438.1

                \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod 1\right) \cdot e^{-x} \]
            4. Simplified38.1%

              \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod 1\right) \cdot e^{-x} \]
            5. Taylor expanded in x around inf

              \[\leadsto \left(\color{blue}{x} \bmod 1\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
            6. Step-by-step derivation
              1. Simplified97.3%

                \[\leadsto \left(\color{blue}{x} \bmod 1\right) \cdot e^{-x} \]
            7. Recombined 2 regimes into one program.
            8. Final simplification64.9%

              \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{\left(\left(e^{x}\right) \bmod 1\right)}{e^{x}}\\ \mathbf{else}:\\ \;\;\;\;e^{0 - x} \cdot \left(x \bmod 1\right)\\ \end{array} \]
            9. Add Preprocessing

            Alternative 3: 62.0% accurate, 1.3× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{0 - x}\\ \mathbf{if}\;x \leq -5 \cdot 10^{-310}:\\ \;\;\;\;t\_0 \cdot \left(\left(e^{x}\right) \bmod 1\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot \left(x \bmod 1\right)\\ \end{array} \end{array} \]
            (FPCore (x)
             :precision binary64
             (let* ((t_0 (exp (- 0.0 x))))
               (if (<= x -5e-310) (* t_0 (fmod (exp x) 1.0)) (* t_0 (fmod x 1.0)))))
            double code(double x) {
            	double t_0 = exp((0.0 - x));
            	double tmp;
            	if (x <= -5e-310) {
            		tmp = t_0 * fmod(exp(x), 1.0);
            	} else {
            		tmp = t_0 * fmod(x, 1.0);
            	}
            	return tmp;
            }
            
            real(8) function code(x)
                real(8), intent (in) :: x
                real(8) :: t_0
                real(8) :: tmp
                t_0 = exp((0.0d0 - x))
                if (x <= (-5d-310)) then
                    tmp = t_0 * mod(exp(x), 1.0d0)
                else
                    tmp = t_0 * mod(x, 1.0d0)
                end if
                code = tmp
            end function
            
            def code(x):
            	t_0 = math.exp((0.0 - x))
            	tmp = 0
            	if x <= -5e-310:
            		tmp = t_0 * math.fmod(math.exp(x), 1.0)
            	else:
            		tmp = t_0 * math.fmod(x, 1.0)
            	return tmp
            
            function code(x)
            	t_0 = exp(Float64(0.0 - x))
            	tmp = 0.0
            	if (x <= -5e-310)
            		tmp = Float64(t_0 * rem(exp(x), 1.0));
            	else
            		tmp = Float64(t_0 * rem(x, 1.0));
            	end
            	return tmp
            end
            
            code[x_] := Block[{t$95$0 = N[Exp[N[(0.0 - x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -5e-310], N[(t$95$0 * N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[With[{TMP1 = x, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]), $MachinePrecision]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            t_0 := e^{0 - x}\\
            \mathbf{if}\;x \leq -5 \cdot 10^{-310}:\\
            \;\;\;\;t\_0 \cdot \left(\left(e^{x}\right) \bmod 1\right)\\
            
            \mathbf{else}:\\
            \;\;\;\;t\_0 \cdot \left(x \bmod 1\right)\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if x < -4.999999999999985e-310

              1. Initial program 7.3%

                \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
              2. Add Preprocessing
              3. Taylor expanded in x around 0

                \[\leadsto \left(\left(e^{x}\right) \bmod \color{blue}{1}\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
              4. Step-by-step derivation
                1. Simplified7.3%

                  \[\leadsto \left(\left(e^{x}\right) \bmod \color{blue}{1}\right) \cdot e^{-x} \]

                if -4.999999999999985e-310 < x

                1. Initial program 7.9%

                  \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                2. Add Preprocessing
                3. Taylor expanded in x around 0

                  \[\leadsto \left(\left(e^{x}\right) \bmod \color{blue}{1}\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
                4. Step-by-step derivation
                  1. Simplified6.5%

                    \[\leadsto \left(\left(e^{x}\right) \bmod \color{blue}{1}\right) \cdot e^{-x} \]
                  2. Taylor expanded in x around 0

                    \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod 1\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
                  3. Step-by-step derivation
                    1. +-lowering-+.f6438.1

                      \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod 1\right) \cdot e^{-x} \]
                  4. Simplified38.1%

                    \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod 1\right) \cdot e^{-x} \]
                  5. Taylor expanded in x around inf

                    \[\leadsto \left(\color{blue}{x} \bmod 1\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
                  6. Step-by-step derivation
                    1. Simplified97.3%

                      \[\leadsto \left(\color{blue}{x} \bmod 1\right) \cdot e^{-x} \]
                  7. Recombined 2 regimes into one program.
                  8. Final simplification64.9%

                    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{-310}:\\ \;\;\;\;e^{0 - x} \cdot \left(\left(e^{x}\right) \bmod 1\right)\\ \mathbf{else}:\\ \;\;\;\;e^{0 - x} \cdot \left(x \bmod 1\right)\\ \end{array} \]
                  9. Add Preprocessing

                  Alternative 4: 59.6% accurate, 2.0× speedup?

                  \[\begin{array}{l} \\ e^{0 - x} \cdot \left(x \bmod 1\right) \end{array} \]
                  (FPCore (x) :precision binary64 (* (exp (- 0.0 x)) (fmod x 1.0)))
                  double code(double x) {
                  	return exp((0.0 - x)) * fmod(x, 1.0);
                  }
                  
                  real(8) function code(x)
                      real(8), intent (in) :: x
                      code = exp((0.0d0 - x)) * mod(x, 1.0d0)
                  end function
                  
                  def code(x):
                  	return math.exp((0.0 - x)) * math.fmod(x, 1.0)
                  
                  function code(x)
                  	return Float64(exp(Float64(0.0 - x)) * rem(x, 1.0))
                  end
                  
                  code[x_] := N[(N[Exp[N[(0.0 - x), $MachinePrecision]], $MachinePrecision] * N[With[{TMP1 = x, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]), $MachinePrecision]
                  
                  \begin{array}{l}
                  
                  \\
                  e^{0 - x} \cdot \left(x \bmod 1\right)
                  \end{array}
                  
                  Derivation
                  1. Initial program 7.6%

                    \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                  2. Add Preprocessing
                  3. Taylor expanded in x around 0

                    \[\leadsto \left(\left(e^{x}\right) \bmod \color{blue}{1}\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
                  4. Step-by-step derivation
                    1. Simplified6.8%

                      \[\leadsto \left(\left(e^{x}\right) \bmod \color{blue}{1}\right) \cdot e^{-x} \]
                    2. Taylor expanded in x around 0

                      \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod 1\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
                    3. Step-by-step derivation
                      1. +-lowering-+.f6426.6

                        \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod 1\right) \cdot e^{-x} \]
                    4. Simplified26.6%

                      \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod 1\right) \cdot e^{-x} \]
                    5. Taylor expanded in x around inf

                      \[\leadsto \left(\color{blue}{x} \bmod 1\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
                    6. Step-by-step derivation
                      1. Simplified63.1%

                        \[\leadsto \left(\color{blue}{x} \bmod 1\right) \cdot e^{-x} \]
                      2. Final simplification63.1%

                        \[\leadsto e^{0 - x} \cdot \left(x \bmod 1\right) \]
                      3. Add Preprocessing

                      Alternative 5: 58.8% accurate, 4.1× speedup?

                      \[\begin{array}{l} \\ \left(x \bmod 1\right) \end{array} \]
                      (FPCore (x) :precision binary64 (fmod x 1.0))
                      double code(double x) {
                      	return fmod(x, 1.0);
                      }
                      
                      real(8) function code(x)
                          real(8), intent (in) :: x
                          code = mod(x, 1.0d0)
                      end function
                      
                      def code(x):
                      	return math.fmod(x, 1.0)
                      
                      function code(x)
                      	return rem(x, 1.0)
                      end
                      
                      code[x_] := N[With[{TMP1 = x, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]
                      
                      \begin{array}{l}
                      
                      \\
                      \left(x \bmod 1\right)
                      \end{array}
                      
                      Derivation
                      1. Initial program 7.6%

                        \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                      2. Add Preprocessing
                      3. Taylor expanded in x around 0

                        \[\leadsto \left(\left(e^{x}\right) \bmod \color{blue}{1}\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
                      4. Step-by-step derivation
                        1. Simplified6.8%

                          \[\leadsto \left(\left(e^{x}\right) \bmod \color{blue}{1}\right) \cdot e^{-x} \]
                        2. Taylor expanded in x around 0

                          \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod 1\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
                        3. Step-by-step derivation
                          1. +-lowering-+.f6426.6

                            \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod 1\right) \cdot e^{-x} \]
                        4. Simplified26.6%

                          \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod 1\right) \cdot e^{-x} \]
                        5. Taylor expanded in x around inf

                          \[\leadsto \left(\color{blue}{x} \bmod 1\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
                        6. Step-by-step derivation
                          1. Simplified63.1%

                            \[\leadsto \left(\color{blue}{x} \bmod 1\right) \cdot e^{-x} \]
                          2. Taylor expanded in x around 0

                            \[\leadsto \color{blue}{\left(x \bmod 1\right)} \]
                          3. Step-by-step derivation
                            1. fmod-lowering-fmod.f6462.1

                              \[\leadsto \color{blue}{\left(x \bmod 1\right)} \]
                          4. Simplified62.1%

                            \[\leadsto \color{blue}{\left(x \bmod 1\right)} \]
                          5. Add Preprocessing

                          Alternative 6: 23.6% accurate, 4.1× speedup?

                          \[\begin{array}{l} \\ \left(1 \bmod 1\right) \end{array} \]
                          (FPCore (x) :precision binary64 (fmod 1.0 1.0))
                          double code(double x) {
                          	return fmod(1.0, 1.0);
                          }
                          
                          real(8) function code(x)
                              real(8), intent (in) :: x
                              code = mod(1.0d0, 1.0d0)
                          end function
                          
                          def code(x):
                          	return math.fmod(1.0, 1.0)
                          
                          function code(x)
                          	return rem(1.0, 1.0)
                          end
                          
                          code[x_] := N[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]
                          
                          \begin{array}{l}
                          
                          \\
                          \left(1 \bmod 1\right)
                          \end{array}
                          
                          Derivation
                          1. Initial program 7.6%

                            \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                          2. Add Preprocessing
                          3. Taylor expanded in x around 0

                            \[\leadsto \left(\left(e^{x}\right) \bmod \color{blue}{1}\right) \cdot e^{\mathsf{neg}\left(x\right)} \]
                          4. Step-by-step derivation
                            1. Simplified6.8%

                              \[\leadsto \left(\left(e^{x}\right) \bmod \color{blue}{1}\right) \cdot e^{-x} \]
                            2. Taylor expanded in x around 0

                              \[\leadsto \color{blue}{\left(\left(e^{x}\right) \bmod 1\right)} \]
                            3. Step-by-step derivation
                              1. fmod-lowering-fmod.f64N/A

                                \[\leadsto \color{blue}{\left(\left(e^{x}\right) \bmod 1\right)} \]
                              2. exp-lowering-exp.f645.9

                                \[\leadsto \left(\color{blue}{\left(e^{x}\right)} \bmod 1\right) \]
                            4. Simplified5.9%

                              \[\leadsto \color{blue}{\left(\left(e^{x}\right) \bmod 1\right)} \]
                            5. Taylor expanded in x around 0

                              \[\leadsto \left(\color{blue}{1} \bmod 1\right) \]
                            6. Step-by-step derivation
                              1. Simplified24.0%

                                \[\leadsto \left(\color{blue}{1} \bmod 1\right) \]
                              2. Add Preprocessing

                              Reproduce

                              ?
                              herbie shell --seed 2024195 
                              (FPCore (x)
                                :name "expfmod (used to be hard to sample)"
                                :precision binary64
                                (* (fmod (exp x) (sqrt (cos x))) (exp (- x))))