expfmod (used to be hard to sample)

Percentage Accurate: 6.7% → 98.7%
Time: 23.6s
Alternatives: 12
Speedup: 5.0×

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 12 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: 98.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{-309}:\\ \;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\log \left({\left(\sqrt[3]{e^{\cos x}}\right)}^{2}\right) + \log \left(\sqrt[3]{e}\right)}\right)\right)}{e^{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \bmod 1\right)}{e^{x}}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -1e-309)
   (/
    (fmod
     (exp x)
     (sqrt (+ (log (pow (cbrt (exp (cos x))) 2.0)) (log (cbrt E)))))
    (exp x))
   (/ (fmod x 1.0) (exp x))))
double code(double x) {
	double tmp;
	if (x <= -1e-309) {
		tmp = fmod(exp(x), sqrt((log(pow(cbrt(exp(cos(x))), 2.0)) + log(cbrt(((double) M_E)))))) / exp(x);
	} else {
		tmp = fmod(x, 1.0) / exp(x);
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (x <= -1e-309)
		tmp = Float64(rem(exp(x), sqrt(Float64(log((cbrt(exp(cos(x))) ^ 2.0)) + log(cbrt(exp(1)))))) / exp(x));
	else
		tmp = Float64(rem(x, 1.0) / exp(x));
	end
	return tmp
end
code[x_] := If[LessEqual[x, -1e-309], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[(N[Log[N[Power[N[Power[N[Exp[N[Cos[x], $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision] + N[Log[N[Power[E, 1/3], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = x, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-309}:\\
\;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\log \left({\left(\sqrt[3]{e^{\cos x}}\right)}^{2}\right) + \log \left(\sqrt[3]{e}\right)}\right)\right)}{e^{x}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(x \bmod 1\right)}{e^{x}}\\


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

    1. Initial program 8.3%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity8.3%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/8.3%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg8.3%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg8.3%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified8.3%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-log-exp8.3%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\color{blue}{\log \left(e^{\cos x}\right)}}\right)\right)}{e^{x}} \]
      2. add-cube-cbrt100.0%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\log \color{blue}{\left(\left(\sqrt[3]{e^{\cos x}} \cdot \sqrt[3]{e^{\cos x}}\right) \cdot \sqrt[3]{e^{\cos x}}\right)}}\right)\right)}{e^{x}} \]
      3. log-prod100.0%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\color{blue}{\log \left(\sqrt[3]{e^{\cos x}} \cdot \sqrt[3]{e^{\cos x}}\right) + \log \left(\sqrt[3]{e^{\cos x}}\right)}}\right)\right)}{e^{x}} \]
      4. pow2100.0%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\log \color{blue}{\left({\left(\sqrt[3]{e^{\cos x}}\right)}^{2}\right)} + \log \left(\sqrt[3]{e^{\cos x}}\right)}\right)\right)}{e^{x}} \]
    6. Applied egg-rr100.0%

      \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\color{blue}{\log \left({\left(\sqrt[3]{e^{\cos x}}\right)}^{2}\right) + \log \left(\sqrt[3]{e^{\cos x}}\right)}}\right)\right)}{e^{x}} \]
    7. Taylor expanded in x around 0 100.0%

      \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\log \left({\left(\sqrt[3]{e^{\cos x}}\right)}^{2}\right) + \log \color{blue}{\left(\sqrt[3]{e^{1}}\right)}}\right)\right)}{e^{x}} \]
    8. Step-by-step derivation
      1. exp-1-e100.0%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\log \left({\left(\sqrt[3]{e^{\cos x}}\right)}^{2}\right) + \log \left(\sqrt[3]{\color{blue}{e}}\right)}\right)\right)}{e^{x}} \]
    9. Simplified100.0%

      \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\log \left({\left(\sqrt[3]{e^{\cos x}}\right)}^{2}\right) + \log \color{blue}{\left(\sqrt[3]{e}\right)}}\right)\right)}{e^{x}} \]

    if -1.000000000000002e-309 < x

    1. Initial program 5.5%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity5.5%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/5.5%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg5.5%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg5.5%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified5.5%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 39.3%

      \[\leadsto \frac{\left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    6. Step-by-step derivation
      1. +-commutative39.3%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    7. Simplified39.3%

      \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    8. Taylor expanded in x around inf 97.8%

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

      \[\leadsto \frac{\left(x \bmod \color{blue}{1}\right)}{e^{x}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 76.6% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\cos x}\\ t_1 := \sqrt[3]{-1 + \frac{1}{x}}\\ \mathbf{if}\;x \leq -7.5 \cdot 10^{-104}:\\ \;\;\;\;\frac{\left(\left(x \cdot \frac{\frac{-1 + {x}^{-2}}{t\_1}}{{t\_1}^{2}}\right) \bmod t\_0\right)}{e^{x}}\\ \mathbf{elif}\;x \leq -5 \cdot 10^{-309}:\\ \;\;\;\;\frac{\left(\left(x \cdot {\left(\sqrt[3]{1 + \frac{1}{x}}\right)}^{3}\right) \bmod t\_0\right)}{e^{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \bmod 1\right)}{e^{x}}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (sqrt (cos x))) (t_1 (cbrt (+ -1.0 (/ 1.0 x)))))
   (if (<= x -7.5e-104)
     (/
      (fmod (* x (/ (/ (+ -1.0 (pow x -2.0)) t_1) (pow t_1 2.0))) t_0)
      (exp x))
     (if (<= x -5e-309)
       (/ (fmod (* x (pow (cbrt (+ 1.0 (/ 1.0 x))) 3.0)) t_0) (exp x))
       (/ (fmod x 1.0) (exp x))))))
double code(double x) {
	double t_0 = sqrt(cos(x));
	double t_1 = cbrt((-1.0 + (1.0 / x)));
	double tmp;
	if (x <= -7.5e-104) {
		tmp = fmod((x * (((-1.0 + pow(x, -2.0)) / t_1) / pow(t_1, 2.0))), t_0) / exp(x);
	} else if (x <= -5e-309) {
		tmp = fmod((x * pow(cbrt((1.0 + (1.0 / x))), 3.0)), t_0) / exp(x);
	} else {
		tmp = fmod(x, 1.0) / exp(x);
	}
	return tmp;
}
function code(x)
	t_0 = sqrt(cos(x))
	t_1 = cbrt(Float64(-1.0 + Float64(1.0 / x)))
	tmp = 0.0
	if (x <= -7.5e-104)
		tmp = Float64(rem(Float64(x * Float64(Float64(Float64(-1.0 + (x ^ -2.0)) / t_1) / (t_1 ^ 2.0))), t_0) / exp(x));
	elseif (x <= -5e-309)
		tmp = Float64(rem(Float64(x * (cbrt(Float64(1.0 + Float64(1.0 / x))) ^ 3.0)), t_0) / exp(x));
	else
		tmp = Float64(rem(x, 1.0) / exp(x));
	end
	return tmp
end
code[x_] := Block[{t$95$0 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(-1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[x, -7.5e-104], N[(N[With[{TMP1 = N[(x * N[(N[(N[(-1.0 + N[Power[x, -2.0], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision] / N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], TMP2 = t$95$0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -5e-309], N[(N[With[{TMP1 = N[(x * N[Power[N[Power[N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision], TMP2 = t$95$0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = x, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{\cos x}\\
t_1 := \sqrt[3]{-1 + \frac{1}{x}}\\
\mathbf{if}\;x \leq -7.5 \cdot 10^{-104}:\\
\;\;\;\;\frac{\left(\left(x \cdot \frac{\frac{-1 + {x}^{-2}}{t\_1}}{{t\_1}^{2}}\right) \bmod t\_0\right)}{e^{x}}\\

\mathbf{elif}\;x \leq -5 \cdot 10^{-309}:\\
\;\;\;\;\frac{\left(\left(x \cdot {\left(\sqrt[3]{1 + \frac{1}{x}}\right)}^{3}\right) \bmod t\_0\right)}{e^{x}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(x \bmod 1\right)}{e^{x}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -7.5e-104

    1. Initial program 23.3%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity23.3%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/23.3%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg23.3%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg23.3%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified23.3%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 19.3%

      \[\leadsto \frac{\left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    6. Step-by-step derivation
      1. +-commutative19.3%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    7. Simplified19.3%

      \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    8. Taylor expanded in x around inf 27.3%

      \[\leadsto \frac{\left(\color{blue}{\left(x \cdot \left(1 + \frac{1}{x}\right)\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    9. Step-by-step derivation
      1. +-commutative27.3%

        \[\leadsto \frac{\left(\left(x \cdot \color{blue}{\left(\frac{1}{x} + 1\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      2. flip-+27.3%

        \[\leadsto \frac{\left(\left(x \cdot \color{blue}{\frac{\frac{1}{x} \cdot \frac{1}{x} - 1 \cdot 1}{\frac{1}{x} - 1}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      3. inv-pow27.3%

        \[\leadsto \frac{\left(\left(x \cdot \frac{\color{blue}{{x}^{-1}} \cdot \frac{1}{x} - 1 \cdot 1}{\frac{1}{x} - 1}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      4. inv-pow27.3%

        \[\leadsto \frac{\left(\left(x \cdot \frac{{x}^{-1} \cdot \color{blue}{{x}^{-1}} - 1 \cdot 1}{\frac{1}{x} - 1}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      5. pow-prod-up32.5%

        \[\leadsto \frac{\left(\left(x \cdot \frac{\color{blue}{{x}^{\left(-1 + -1\right)}} - 1 \cdot 1}{\frac{1}{x} - 1}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      6. metadata-eval32.5%

        \[\leadsto \frac{\left(\left(x \cdot \frac{{x}^{\color{blue}{-2}} - 1 \cdot 1}{\frac{1}{x} - 1}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      7. metadata-eval32.5%

        \[\leadsto \frac{\left(\left(x \cdot \frac{{x}^{-2} - \color{blue}{1}}{\frac{1}{x} - 1}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    10. Applied egg-rr32.5%

      \[\leadsto \frac{\left(\left(x \cdot \color{blue}{\frac{{x}^{-2} - 1}{\frac{1}{x} - 1}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    11. Step-by-step derivation
      1. *-un-lft-identity32.5%

        \[\leadsto \frac{\left(\left(x \cdot \frac{\color{blue}{1 \cdot \left({x}^{-2} - 1\right)}}{\frac{1}{x} - 1}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      2. add-cube-cbrt71.1%

        \[\leadsto \frac{\left(\left(x \cdot \frac{1 \cdot \left({x}^{-2} - 1\right)}{\color{blue}{\left(\sqrt[3]{\frac{1}{x} - 1} \cdot \sqrt[3]{\frac{1}{x} - 1}\right) \cdot \sqrt[3]{\frac{1}{x} - 1}}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      3. times-frac70.7%

        \[\leadsto \frac{\left(\left(x \cdot \color{blue}{\left(\frac{1}{\sqrt[3]{\frac{1}{x} - 1} \cdot \sqrt[3]{\frac{1}{x} - 1}} \cdot \frac{{x}^{-2} - 1}{\sqrt[3]{\frac{1}{x} - 1}}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      4. pow270.7%

        \[\leadsto \frac{\left(\left(x \cdot \left(\frac{1}{\color{blue}{{\left(\sqrt[3]{\frac{1}{x} - 1}\right)}^{2}}} \cdot \frac{{x}^{-2} - 1}{\sqrt[3]{\frac{1}{x} - 1}}\right)\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      5. sub-neg70.7%

        \[\leadsto \frac{\left(\left(x \cdot \left(\frac{1}{{\left(\sqrt[3]{\color{blue}{\frac{1}{x} + \left(-1\right)}}\right)}^{2}} \cdot \frac{{x}^{-2} - 1}{\sqrt[3]{\frac{1}{x} - 1}}\right)\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      6. metadata-eval70.7%

        \[\leadsto \frac{\left(\left(x \cdot \left(\frac{1}{{\left(\sqrt[3]{\frac{1}{x} + \color{blue}{-1}}\right)}^{2}} \cdot \frac{{x}^{-2} - 1}{\sqrt[3]{\frac{1}{x} - 1}}\right)\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      7. sub-neg70.7%

        \[\leadsto \frac{\left(\left(x \cdot \left(\frac{1}{{\left(\sqrt[3]{\frac{1}{x} + -1}\right)}^{2}} \cdot \frac{\color{blue}{{x}^{-2} + \left(-1\right)}}{\sqrt[3]{\frac{1}{x} - 1}}\right)\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      8. metadata-eval70.7%

        \[\leadsto \frac{\left(\left(x \cdot \left(\frac{1}{{\left(\sqrt[3]{\frac{1}{x} + -1}\right)}^{2}} \cdot \frac{{x}^{-2} + \color{blue}{-1}}{\sqrt[3]{\frac{1}{x} - 1}}\right)\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      9. sub-neg70.7%

        \[\leadsto \frac{\left(\left(x \cdot \left(\frac{1}{{\left(\sqrt[3]{\frac{1}{x} + -1}\right)}^{2}} \cdot \frac{{x}^{-2} + -1}{\sqrt[3]{\color{blue}{\frac{1}{x} + \left(-1\right)}}}\right)\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      10. metadata-eval70.7%

        \[\leadsto \frac{\left(\left(x \cdot \left(\frac{1}{{\left(\sqrt[3]{\frac{1}{x} + -1}\right)}^{2}} \cdot \frac{{x}^{-2} + -1}{\sqrt[3]{\frac{1}{x} + \color{blue}{-1}}}\right)\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    12. Applied egg-rr70.7%

      \[\leadsto \frac{\left(\left(x \cdot \color{blue}{\left(\frac{1}{{\left(\sqrt[3]{\frac{1}{x} + -1}\right)}^{2}} \cdot \frac{{x}^{-2} + -1}{\sqrt[3]{\frac{1}{x} + -1}}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    13. Step-by-step derivation
      1. associate-*l/71.1%

        \[\leadsto \frac{\left(\left(x \cdot \color{blue}{\frac{1 \cdot \frac{{x}^{-2} + -1}{\sqrt[3]{\frac{1}{x} + -1}}}{{\left(\sqrt[3]{\frac{1}{x} + -1}\right)}^{2}}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      2. *-lft-identity71.1%

        \[\leadsto \frac{\left(\left(x \cdot \frac{\color{blue}{\frac{{x}^{-2} + -1}{\sqrt[3]{\frac{1}{x} + -1}}}}{{\left(\sqrt[3]{\frac{1}{x} + -1}\right)}^{2}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      3. +-commutative71.1%

        \[\leadsto \frac{\left(\left(x \cdot \frac{\frac{\color{blue}{-1 + {x}^{-2}}}{\sqrt[3]{\frac{1}{x} + -1}}}{{\left(\sqrt[3]{\frac{1}{x} + -1}\right)}^{2}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      4. +-commutative71.1%

        \[\leadsto \frac{\left(\left(x \cdot \frac{\frac{-1 + {x}^{-2}}{\sqrt[3]{\color{blue}{-1 + \frac{1}{x}}}}}{{\left(\sqrt[3]{\frac{1}{x} + -1}\right)}^{2}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      5. +-commutative71.1%

        \[\leadsto \frac{\left(\left(x \cdot \frac{\frac{-1 + {x}^{-2}}{\sqrt[3]{-1 + \frac{1}{x}}}}{{\left(\sqrt[3]{\color{blue}{-1 + \frac{1}{x}}}\right)}^{2}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    14. Simplified71.1%

      \[\leadsto \frac{\left(\left(x \cdot \color{blue}{\frac{\frac{-1 + {x}^{-2}}{\sqrt[3]{-1 + \frac{1}{x}}}}{{\left(\sqrt[3]{-1 + \frac{1}{x}}\right)}^{2}}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]

    if -7.5e-104 < x < -4.9999999999999995e-309

    1. Initial program 3.1%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity3.1%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/3.1%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg3.1%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg3.1%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified3.1%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 3.1%

      \[\leadsto \frac{\left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    6. Step-by-step derivation
      1. +-commutative3.1%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    7. Simplified3.1%

      \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    8. Taylor expanded in x around inf 19.7%

      \[\leadsto \frac{\left(\color{blue}{\left(x \cdot \left(1 + \frac{1}{x}\right)\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    9. Step-by-step derivation
      1. add-cube-cbrt40.3%

        \[\leadsto \frac{\left(\left(x \cdot \color{blue}{\left(\left(\sqrt[3]{1 + \frac{1}{x}} \cdot \sqrt[3]{1 + \frac{1}{x}}\right) \cdot \sqrt[3]{1 + \frac{1}{x}}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      2. pow341.7%

        \[\leadsto \frac{\left(\left(x \cdot \color{blue}{{\left(\sqrt[3]{1 + \frac{1}{x}}\right)}^{3}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    10. Applied egg-rr41.7%

      \[\leadsto \frac{\left(\left(x \cdot \color{blue}{{\left(\sqrt[3]{1 + \frac{1}{x}}\right)}^{3}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]

    if -4.9999999999999995e-309 < x

    1. Initial program 5.5%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity5.5%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/5.5%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg5.5%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg5.5%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified5.5%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 39.3%

      \[\leadsto \frac{\left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    6. Step-by-step derivation
      1. +-commutative39.3%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    7. Simplified39.3%

      \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    8. Taylor expanded in x around inf 97.8%

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

      \[\leadsto \frac{\left(x \bmod \color{blue}{1}\right)}{e^{x}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 76.4% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\cos x}\\ \mathbf{if}\;x \leq -7.6 \cdot 10^{-141}:\\ \;\;\;\;\frac{\left(\left(\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(x + {x}^{-2}\right)\right)}{1 + \left({x}^{-2} + \frac{-1}{x}\right)}\right) \bmod t\_0\right)}{e^{x}}\\ \mathbf{elif}\;x \leq -5 \cdot 10^{-309}:\\ \;\;\;\;\frac{\left(\left(x \cdot {\left(\sqrt[3]{1 + \frac{1}{x}}\right)}^{3}\right) \bmod t\_0\right)}{e^{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \bmod 1\right)}{e^{x}}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (sqrt (cos x))))
   (if (<= x -7.6e-141)
     (/
      (fmod
       (/
        (expm1 (log1p (+ x (pow x -2.0))))
        (+ 1.0 (+ (pow x -2.0) (/ -1.0 x))))
       t_0)
      (exp x))
     (if (<= x -5e-309)
       (/ (fmod (* x (pow (cbrt (+ 1.0 (/ 1.0 x))) 3.0)) t_0) (exp x))
       (/ (fmod x 1.0) (exp x))))))
double code(double x) {
	double t_0 = sqrt(cos(x));
	double tmp;
	if (x <= -7.6e-141) {
		tmp = fmod((expm1(log1p((x + pow(x, -2.0)))) / (1.0 + (pow(x, -2.0) + (-1.0 / x)))), t_0) / exp(x);
	} else if (x <= -5e-309) {
		tmp = fmod((x * pow(cbrt((1.0 + (1.0 / x))), 3.0)), t_0) / exp(x);
	} else {
		tmp = fmod(x, 1.0) / exp(x);
	}
	return tmp;
}
function code(x)
	t_0 = sqrt(cos(x))
	tmp = 0.0
	if (x <= -7.6e-141)
		tmp = Float64(rem(Float64(expm1(log1p(Float64(x + (x ^ -2.0)))) / Float64(1.0 + Float64((x ^ -2.0) + Float64(-1.0 / x)))), t_0) / exp(x));
	elseif (x <= -5e-309)
		tmp = Float64(rem(Float64(x * (cbrt(Float64(1.0 + Float64(1.0 / x))) ^ 3.0)), t_0) / exp(x));
	else
		tmp = Float64(rem(x, 1.0) / exp(x));
	end
	return tmp
end
code[x_] := Block[{t$95$0 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -7.6e-141], N[(N[With[{TMP1 = N[(N[(Exp[N[Log[1 + N[(x + N[Power[x, -2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision] / N[(1.0 + N[(N[Power[x, -2.0], $MachinePrecision] + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], TMP2 = t$95$0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -5e-309], N[(N[With[{TMP1 = N[(x * N[Power[N[Power[N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision], TMP2 = t$95$0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = x, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{\cos x}\\
\mathbf{if}\;x \leq -7.6 \cdot 10^{-141}:\\
\;\;\;\;\frac{\left(\left(\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(x + {x}^{-2}\right)\right)}{1 + \left({x}^{-2} + \frac{-1}{x}\right)}\right) \bmod t\_0\right)}{e^{x}}\\

\mathbf{elif}\;x \leq -5 \cdot 10^{-309}:\\
\;\;\;\;\frac{\left(\left(x \cdot {\left(\sqrt[3]{1 + \frac{1}{x}}\right)}^{3}\right) \bmod t\_0\right)}{e^{x}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(x \bmod 1\right)}{e^{x}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -7.59999999999999973e-141

    1. Initial program 15.5%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity15.5%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/15.5%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg15.5%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg15.5%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified15.5%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 13.1%

      \[\leadsto \frac{\left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    6. Step-by-step derivation
      1. +-commutative13.1%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    7. Simplified13.1%

      \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    8. Taylor expanded in x around inf 18.0%

      \[\leadsto \frac{\left(\color{blue}{\left(x \cdot \left(1 + \frac{1}{x}\right)\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    9. Step-by-step derivation
      1. *-commutative18.0%

        \[\leadsto \frac{\left(\color{blue}{\left(\left(1 + \frac{1}{x}\right) \cdot x\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      2. flip3-+15.3%

        \[\leadsto \frac{\left(\left(\color{blue}{\frac{{1}^{3} + {\left(\frac{1}{x}\right)}^{3}}{1 \cdot 1 + \left(\frac{1}{x} \cdot \frac{1}{x} - 1 \cdot \frac{1}{x}\right)}} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      3. associate-*l/17.3%

        \[\leadsto \frac{\left(\color{blue}{\left(\frac{\left({1}^{3} + {\left(\frac{1}{x}\right)}^{3}\right) \cdot x}{1 \cdot 1 + \left(\frac{1}{x} \cdot \frac{1}{x} - 1 \cdot \frac{1}{x}\right)}\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      4. metadata-eval17.3%

        \[\leadsto \frac{\left(\left(\frac{\left(\color{blue}{1} + {\left(\frac{1}{x}\right)}^{3}\right) \cdot x}{1 \cdot 1 + \left(\frac{1}{x} \cdot \frac{1}{x} - 1 \cdot \frac{1}{x}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      5. inv-pow17.3%

        \[\leadsto \frac{\left(\left(\frac{\left(1 + {\color{blue}{\left({x}^{-1}\right)}}^{3}\right) \cdot x}{1 \cdot 1 + \left(\frac{1}{x} \cdot \frac{1}{x} - 1 \cdot \frac{1}{x}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      6. pow-pow20.0%

        \[\leadsto \frac{\left(\left(\frac{\left(1 + \color{blue}{{x}^{\left(-1 \cdot 3\right)}}\right) \cdot x}{1 \cdot 1 + \left(\frac{1}{x} \cdot \frac{1}{x} - 1 \cdot \frac{1}{x}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      7. metadata-eval20.0%

        \[\leadsto \frac{\left(\left(\frac{\left(1 + {x}^{\color{blue}{-3}}\right) \cdot x}{1 \cdot 1 + \left(\frac{1}{x} \cdot \frac{1}{x} - 1 \cdot \frac{1}{x}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      8. metadata-eval20.0%

        \[\leadsto \frac{\left(\left(\frac{\left(1 + {x}^{-3}\right) \cdot x}{\color{blue}{1} + \left(\frac{1}{x} \cdot \frac{1}{x} - 1 \cdot \frac{1}{x}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      9. inv-pow20.0%

        \[\leadsto \frac{\left(\left(\frac{\left(1 + {x}^{-3}\right) \cdot x}{1 + \left(\color{blue}{{x}^{-1}} \cdot \frac{1}{x} - 1 \cdot \frac{1}{x}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      10. inv-pow20.0%

        \[\leadsto \frac{\left(\left(\frac{\left(1 + {x}^{-3}\right) \cdot x}{1 + \left({x}^{-1} \cdot \color{blue}{{x}^{-1}} - 1 \cdot \frac{1}{x}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      11. pow-prod-up22.1%

        \[\leadsto \frac{\left(\left(\frac{\left(1 + {x}^{-3}\right) \cdot x}{1 + \left(\color{blue}{{x}^{\left(-1 + -1\right)}} - 1 \cdot \frac{1}{x}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      12. metadata-eval22.1%

        \[\leadsto \frac{\left(\left(\frac{\left(1 + {x}^{-3}\right) \cdot x}{1 + \left({x}^{\color{blue}{-2}} - 1 \cdot \frac{1}{x}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      13. *-un-lft-identity22.1%

        \[\leadsto \frac{\left(\left(\frac{\left(1 + {x}^{-3}\right) \cdot x}{1 + \left({x}^{-2} - \color{blue}{\frac{1}{x}}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    10. Applied egg-rr22.1%

      \[\leadsto \frac{\left(\color{blue}{\left(\frac{\left(1 + {x}^{-3}\right) \cdot x}{1 + \left({x}^{-2} - \frac{1}{x}\right)}\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    11. Step-by-step derivation
      1. expm1-log1p-u37.1%

        \[\leadsto \frac{\left(\left(\frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(1 + {x}^{-3}\right) \cdot x\right)\right)}}{1 + \left({x}^{-2} - \frac{1}{x}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      2. expm1-undefine37.1%

        \[\leadsto \frac{\left(\left(\frac{\color{blue}{e^{\mathsf{log1p}\left(\left(1 + {x}^{-3}\right) \cdot x\right)} - 1}}{1 + \left({x}^{-2} - \frac{1}{x}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      3. *-commutative37.1%

        \[\leadsto \frac{\left(\left(\frac{e^{\mathsf{log1p}\left(\color{blue}{x \cdot \left(1 + {x}^{-3}\right)}\right)} - 1}{1 + \left({x}^{-2} - \frac{1}{x}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    12. Applied egg-rr37.1%

      \[\leadsto \frac{\left(\left(\frac{\color{blue}{e^{\mathsf{log1p}\left(x \cdot \left(1 + {x}^{-3}\right)\right)} - 1}}{1 + \left({x}^{-2} - \frac{1}{x}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    13. Step-by-step derivation
      1. expm1-define37.1%

        \[\leadsto \frac{\left(\left(\frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x \cdot \left(1 + {x}^{-3}\right)\right)\right)}}{1 + \left({x}^{-2} - \frac{1}{x}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      2. distribute-rgt-in37.1%

        \[\leadsto \frac{\left(\left(\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\color{blue}{1 \cdot x + {x}^{-3} \cdot x}\right)\right)}{1 + \left({x}^{-2} - \frac{1}{x}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      3. *-lft-identity37.1%

        \[\leadsto \frac{\left(\left(\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\color{blue}{x} + {x}^{-3} \cdot x\right)\right)}{1 + \left({x}^{-2} - \frac{1}{x}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      4. pow-plus59.2%

        \[\leadsto \frac{\left(\left(\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(x + \color{blue}{{x}^{\left(-3 + 1\right)}}\right)\right)}{1 + \left({x}^{-2} - \frac{1}{x}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      5. metadata-eval59.2%

        \[\leadsto \frac{\left(\left(\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(x + {x}^{\color{blue}{-2}}\right)\right)}{1 + \left({x}^{-2} - \frac{1}{x}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    14. Simplified59.2%

      \[\leadsto \frac{\left(\left(\frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x + {x}^{-2}\right)\right)}}{1 + \left({x}^{-2} - \frac{1}{x}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]

    if -7.59999999999999973e-141 < x < -4.9999999999999995e-309

    1. Initial program 3.1%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity3.1%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/3.1%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg3.1%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg3.1%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified3.1%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 3.1%

      \[\leadsto \frac{\left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    6. Step-by-step derivation
      1. +-commutative3.1%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    7. Simplified3.1%

      \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    8. Taylor expanded in x around inf 24.3%

      \[\leadsto \frac{\left(\color{blue}{\left(x \cdot \left(1 + \frac{1}{x}\right)\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    9. Step-by-step derivation
      1. add-cube-cbrt38.0%

        \[\leadsto \frac{\left(\left(x \cdot \color{blue}{\left(\left(\sqrt[3]{1 + \frac{1}{x}} \cdot \sqrt[3]{1 + \frac{1}{x}}\right) \cdot \sqrt[3]{1 + \frac{1}{x}}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      2. pow339.8%

        \[\leadsto \frac{\left(\left(x \cdot \color{blue}{{\left(\sqrt[3]{1 + \frac{1}{x}}\right)}^{3}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    10. Applied egg-rr39.8%

      \[\leadsto \frac{\left(\left(x \cdot \color{blue}{{\left(\sqrt[3]{1 + \frac{1}{x}}\right)}^{3}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]

    if -4.9999999999999995e-309 < x

    1. Initial program 5.5%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity5.5%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/5.5%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg5.5%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg5.5%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified5.5%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 39.3%

      \[\leadsto \frac{\left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    6. Step-by-step derivation
      1. +-commutative39.3%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    7. Simplified39.3%

      \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    8. Taylor expanded in x around inf 97.8%

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

      \[\leadsto \frac{\left(x \bmod \color{blue}{1}\right)}{e^{x}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification79.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7.6 \cdot 10^{-141}:\\ \;\;\;\;\frac{\left(\left(\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(x + {x}^{-2}\right)\right)}{1 + \left({x}^{-2} + \frac{-1}{x}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\\ \mathbf{elif}\;x \leq -5 \cdot 10^{-309}:\\ \;\;\;\;\frac{\left(\left(x \cdot {\left(\sqrt[3]{1 + \frac{1}{x}}\right)}^{3}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \bmod 1\right)}{e^{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 68.5% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\cos x}\\ \mathbf{if}\;x \leq -2 \cdot 10^{-135}:\\ \;\;\;\;\frac{\left(\left(\left(1 - {x}^{-2}\right) \cdot \frac{x}{1 + \frac{-1}{x}}\right) \bmod t\_0\right)}{e^{x}}\\ \mathbf{elif}\;x \leq -8.5 \cdot 10^{-296}:\\ \;\;\;\;\frac{\log \left(e^{\left(\left(x \cdot \left(1 + \frac{1}{x}\right)\right) \bmod t\_0\right)}\right)}{e^{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left(x \bmod 1\right)\right|}{e^{x}}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (sqrt (cos x))))
   (if (<= x -2e-135)
     (/ (fmod (* (- 1.0 (pow x -2.0)) (/ x (+ 1.0 (/ -1.0 x)))) t_0) (exp x))
     (if (<= x -8.5e-296)
       (/ (log (exp (fmod (* x (+ 1.0 (/ 1.0 x))) t_0))) (exp x))
       (/ (fabs (fmod x 1.0)) (exp x))))))
double code(double x) {
	double t_0 = sqrt(cos(x));
	double tmp;
	if (x <= -2e-135) {
		tmp = fmod(((1.0 - pow(x, -2.0)) * (x / (1.0 + (-1.0 / x)))), t_0) / exp(x);
	} else if (x <= -8.5e-296) {
		tmp = log(exp(fmod((x * (1.0 + (1.0 / x))), t_0))) / exp(x);
	} else {
		tmp = fabs(fmod(x, 1.0)) / exp(x);
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt(cos(x))
    if (x <= (-2d-135)) then
        tmp = mod(((1.0d0 - (x ** (-2.0d0))) * (x / (1.0d0 + ((-1.0d0) / x)))), t_0) / exp(x)
    else if (x <= (-8.5d-296)) then
        tmp = log(exp(mod((x * (1.0d0 + (1.0d0 / x))), t_0))) / exp(x)
    else
        tmp = abs(mod(x, 1.0d0)) / exp(x)
    end if
    code = tmp
end function
def code(x):
	t_0 = math.sqrt(math.cos(x))
	tmp = 0
	if x <= -2e-135:
		tmp = math.fmod(((1.0 - math.pow(x, -2.0)) * (x / (1.0 + (-1.0 / x)))), t_0) / math.exp(x)
	elif x <= -8.5e-296:
		tmp = math.log(math.exp(math.fmod((x * (1.0 + (1.0 / x))), t_0))) / math.exp(x)
	else:
		tmp = math.fabs(math.fmod(x, 1.0)) / math.exp(x)
	return tmp
function code(x)
	t_0 = sqrt(cos(x))
	tmp = 0.0
	if (x <= -2e-135)
		tmp = Float64(rem(Float64(Float64(1.0 - (x ^ -2.0)) * Float64(x / Float64(1.0 + Float64(-1.0 / x)))), t_0) / exp(x));
	elseif (x <= -8.5e-296)
		tmp = Float64(log(exp(rem(Float64(x * Float64(1.0 + Float64(1.0 / x))), t_0))) / exp(x));
	else
		tmp = Float64(abs(rem(x, 1.0)) / exp(x));
	end
	return tmp
end
code[x_] := Block[{t$95$0 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -2e-135], N[(N[With[{TMP1 = N[(N[(1.0 - N[Power[x, -2.0], $MachinePrecision]), $MachinePrecision] * N[(x / N[(1.0 + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], TMP2 = t$95$0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -8.5e-296], N[(N[Log[N[Exp[N[With[{TMP1 = N[(x * N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], TMP2 = t$95$0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[Abs[N[With[{TMP1 = x, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{\cos x}\\
\mathbf{if}\;x \leq -2 \cdot 10^{-135}:\\
\;\;\;\;\frac{\left(\left(\left(1 - {x}^{-2}\right) \cdot \frac{x}{1 + \frac{-1}{x}}\right) \bmod t\_0\right)}{e^{x}}\\

\mathbf{elif}\;x \leq -8.5 \cdot 10^{-296}:\\
\;\;\;\;\frac{\log \left(e^{\left(\left(x \cdot \left(1 + \frac{1}{x}\right)\right) \bmod t\_0\right)}\right)}{e^{x}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left|\left(x \bmod 1\right)\right|}{e^{x}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.0000000000000001e-135

    1. Initial program 15.9%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity15.9%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/15.9%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg15.9%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg15.9%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified15.9%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 13.4%

      \[\leadsto \frac{\left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    6. Step-by-step derivation
      1. +-commutative13.4%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    7. Simplified13.4%

      \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    8. Taylor expanded in x around inf 18.4%

      \[\leadsto \frac{\left(\color{blue}{\left(x \cdot \left(1 + \frac{1}{x}\right)\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    9. Step-by-step derivation
      1. flip-+18.4%

        \[\leadsto \frac{\left(\left(x \cdot \color{blue}{\frac{1 \cdot 1 - \frac{1}{x} \cdot \frac{1}{x}}{1 - \frac{1}{x}}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      2. associate-*r/18.8%

        \[\leadsto \frac{\left(\color{blue}{\left(\frac{x \cdot \left(1 \cdot 1 - \frac{1}{x} \cdot \frac{1}{x}\right)}{1 - \frac{1}{x}}\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      3. metadata-eval18.8%

        \[\leadsto \frac{\left(\left(\frac{x \cdot \left(\color{blue}{1} - \frac{1}{x} \cdot \frac{1}{x}\right)}{1 - \frac{1}{x}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      4. inv-pow18.8%

        \[\leadsto \frac{\left(\left(\frac{x \cdot \left(1 - \color{blue}{{x}^{-1}} \cdot \frac{1}{x}\right)}{1 - \frac{1}{x}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      5. inv-pow18.8%

        \[\leadsto \frac{\left(\left(\frac{x \cdot \left(1 - {x}^{-1} \cdot \color{blue}{{x}^{-1}}\right)}{1 - \frac{1}{x}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      6. pow-prod-up21.5%

        \[\leadsto \frac{\left(\left(\frac{x \cdot \left(1 - \color{blue}{{x}^{\left(-1 + -1\right)}}\right)}{1 - \frac{1}{x}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      7. metadata-eval21.5%

        \[\leadsto \frac{\left(\left(\frac{x \cdot \left(1 - {x}^{\color{blue}{-2}}\right)}{1 - \frac{1}{x}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    10. Applied egg-rr21.5%

      \[\leadsto \frac{\left(\color{blue}{\left(\frac{x \cdot \left(1 - {x}^{-2}\right)}{1 - \frac{1}{x}}\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    11. Step-by-step derivation
      1. *-commutative21.5%

        \[\leadsto \frac{\left(\left(\frac{\color{blue}{\left(1 - {x}^{-2}\right) \cdot x}}{1 - \frac{1}{x}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      2. associate-/l*39.1%

        \[\leadsto \frac{\left(\color{blue}{\left(\left(1 - {x}^{-2}\right) \cdot \frac{x}{1 - \frac{1}{x}}\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    12. Simplified39.1%

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

    if -2.0000000000000001e-135 < x < -8.50000000000000018e-296

    1. Initial program 3.1%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity3.1%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/3.1%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg3.1%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg3.1%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified3.1%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 3.1%

      \[\leadsto \frac{\left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    6. Step-by-step derivation
      1. +-commutative3.1%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    7. Simplified3.1%

      \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    8. Taylor expanded in x around inf 24.3%

      \[\leadsto \frac{\left(\color{blue}{\left(x \cdot \left(1 + \frac{1}{x}\right)\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    9. Step-by-step derivation
      1. +-commutative24.3%

        \[\leadsto \frac{\left(\left(x \cdot \color{blue}{\left(\frac{1}{x} + 1\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      2. flip-+0.1%

        \[\leadsto \frac{\left(\left(x \cdot \color{blue}{\frac{\frac{1}{x} \cdot \frac{1}{x} - 1 \cdot 1}{\frac{1}{x} - 1}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      3. inv-pow0.1%

        \[\leadsto \frac{\left(\left(x \cdot \frac{\color{blue}{{x}^{-1}} \cdot \frac{1}{x} - 1 \cdot 1}{\frac{1}{x} - 1}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      4. inv-pow0.1%

        \[\leadsto \frac{\left(\left(x \cdot \frac{{x}^{-1} \cdot \color{blue}{{x}^{-1}} - 1 \cdot 1}{\frac{1}{x} - 1}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      5. pow-prod-up1.9%

        \[\leadsto \frac{\left(\left(x \cdot \frac{\color{blue}{{x}^{\left(-1 + -1\right)}} - 1 \cdot 1}{\frac{1}{x} - 1}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      6. metadata-eval1.9%

        \[\leadsto \frac{\left(\left(x \cdot \frac{{x}^{\color{blue}{-2}} - 1 \cdot 1}{\frac{1}{x} - 1}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      7. metadata-eval1.9%

        \[\leadsto \frac{\left(\left(x \cdot \frac{{x}^{-2} - \color{blue}{1}}{\frac{1}{x} - 1}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    10. Applied egg-rr1.9%

      \[\leadsto \frac{\left(\left(x \cdot \color{blue}{\frac{{x}^{-2} - 1}{\frac{1}{x} - 1}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    11. Step-by-step derivation
      1. add-log-exp1.9%

        \[\leadsto \frac{\color{blue}{\log \left(e^{\left(\left(x \cdot \frac{{x}^{-2} - 1}{\frac{1}{x} - 1}\right) \bmod \left(\sqrt{\cos x}\right)\right)}\right)}}{e^{x}} \]
      2. metadata-eval1.9%

        \[\leadsto \frac{\log \left(e^{\left(\left(x \cdot \frac{{x}^{\color{blue}{\left(-1 + -1\right)}} - 1}{\frac{1}{x} - 1}\right) \bmod \left(\sqrt{\cos x}\right)\right)}\right)}{e^{x}} \]
      3. pow-prod-up0.1%

        \[\leadsto \frac{\log \left(e^{\left(\left(x \cdot \frac{\color{blue}{{x}^{-1} \cdot {x}^{-1}} - 1}{\frac{1}{x} - 1}\right) \bmod \left(\sqrt{\cos x}\right)\right)}\right)}{e^{x}} \]
      4. inv-pow0.1%

        \[\leadsto \frac{\log \left(e^{\left(\left(x \cdot \frac{\color{blue}{\frac{1}{x}} \cdot {x}^{-1} - 1}{\frac{1}{x} - 1}\right) \bmod \left(\sqrt{\cos x}\right)\right)}\right)}{e^{x}} \]
      5. inv-pow0.1%

        \[\leadsto \frac{\log \left(e^{\left(\left(x \cdot \frac{\frac{1}{x} \cdot \color{blue}{\frac{1}{x}} - 1}{\frac{1}{x} - 1}\right) \bmod \left(\sqrt{\cos x}\right)\right)}\right)}{e^{x}} \]
      6. metadata-eval0.1%

        \[\leadsto \frac{\log \left(e^{\left(\left(x \cdot \frac{\frac{1}{x} \cdot \frac{1}{x} - \color{blue}{1 \cdot 1}}{\frac{1}{x} - 1}\right) \bmod \left(\sqrt{\cos x}\right)\right)}\right)}{e^{x}} \]
      7. flip-+24.7%

        \[\leadsto \frac{\log \left(e^{\left(\left(x \cdot \color{blue}{\left(\frac{1}{x} + 1\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}\right)}{e^{x}} \]
    12. Applied egg-rr24.7%

      \[\leadsto \frac{\color{blue}{\log \left(e^{\left(\left(x \cdot \left(\frac{1}{x} + 1\right)\right) \bmod \left(\sqrt{\cos x}\right)\right)}\right)}}{e^{x}} \]

    if -8.50000000000000018e-296 < x

    1. Initial program 5.5%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity5.5%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/5.5%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg5.5%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg5.5%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified5.5%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 39.0%

      \[\leadsto \frac{\left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    6. Step-by-step derivation
      1. +-commutative39.0%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    7. Simplified39.0%

      \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    8. Taylor expanded in x around inf 97.2%

      \[\leadsto \frac{\left(\color{blue}{x} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt96.6%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(x \bmod \left(\sqrt{\cos x}\right)\right)} \cdot \sqrt{\left(x \bmod \left(\sqrt{\cos x}\right)\right)}}}{e^{x}} \]
      2. sqrt-unprod65.5%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(x \bmod \left(\sqrt{\cos x}\right)\right) \cdot \left(x \bmod \left(\sqrt{\cos x}\right)\right)}}}{e^{x}} \]
      3. pow265.5%

        \[\leadsto \frac{\sqrt{\color{blue}{{\left(x \bmod \left(\sqrt{\cos x}\right)\right)}^{2}}}}{e^{x}} \]
    10. Applied egg-rr65.5%

      \[\leadsto \frac{\color{blue}{\sqrt{{\left(x \bmod \left(\sqrt{\cos x}\right)\right)}^{2}}}}{e^{x}} \]
    11. Step-by-step derivation
      1. unpow265.5%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(x \bmod \left(\sqrt{\cos x}\right)\right) \cdot \left(x \bmod \left(\sqrt{\cos x}\right)\right)}}}{e^{x}} \]
      2. rem-sqrt-square97.2%

        \[\leadsto \frac{\color{blue}{\left|\left(x \bmod \left(\sqrt{\cos x}\right)\right)\right|}}{e^{x}} \]
    12. Simplified97.2%

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

      \[\leadsto \frac{\left|\left(x \bmod \color{blue}{1}\right)\right|}{e^{x}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification73.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{-135}:\\ \;\;\;\;\frac{\left(\left(\left(1 - {x}^{-2}\right) \cdot \frac{x}{1 + \frac{-1}{x}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\\ \mathbf{elif}\;x \leq -8.5 \cdot 10^{-296}:\\ \;\;\;\;\frac{\log \left(e^{\left(\left(x \cdot \left(1 + \frac{1}{x}\right)\right) \bmod \left(\sqrt{\cos x}\right)\right)}\right)}{e^{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left(x \bmod 1\right)\right|}{e^{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 74.6% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{-309}:\\ \;\;\;\;\frac{\left(\left(x \cdot {\left(\sqrt[3]{1 + \frac{1}{x}}\right)}^{3}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \bmod 1\right)}{e^{x}}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -5e-309)
   (/ (fmod (* x (pow (cbrt (+ 1.0 (/ 1.0 x))) 3.0)) (sqrt (cos x))) (exp x))
   (/ (fmod x 1.0) (exp x))))
double code(double x) {
	double tmp;
	if (x <= -5e-309) {
		tmp = fmod((x * pow(cbrt((1.0 + (1.0 / x))), 3.0)), sqrt(cos(x))) / exp(x);
	} else {
		tmp = fmod(x, 1.0) / exp(x);
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (x <= -5e-309)
		tmp = Float64(rem(Float64(x * (cbrt(Float64(1.0 + Float64(1.0 / x))) ^ 3.0)), sqrt(cos(x))) / exp(x));
	else
		tmp = Float64(rem(x, 1.0) / exp(x));
	end
	return tmp
end
code[x_] := If[LessEqual[x, -5e-309], N[(N[With[{TMP1 = N[(x * N[Power[N[Power[N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = x, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-309}:\\
\;\;\;\;\frac{\left(\left(x \cdot {\left(\sqrt[3]{1 + \frac{1}{x}}\right)}^{3}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(x \bmod 1\right)}{e^{x}}\\


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

    1. Initial program 8.3%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity8.3%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/8.3%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg8.3%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg8.3%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified8.3%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 7.3%

      \[\leadsto \frac{\left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    6. Step-by-step derivation
      1. +-commutative7.3%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    7. Simplified7.3%

      \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    8. Taylor expanded in x around inf 21.7%

      \[\leadsto \frac{\left(\color{blue}{\left(x \cdot \left(1 + \frac{1}{x}\right)\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    9. Step-by-step derivation
      1. add-cube-cbrt39.6%

        \[\leadsto \frac{\left(\left(x \cdot \color{blue}{\left(\left(\sqrt[3]{1 + \frac{1}{x}} \cdot \sqrt[3]{1 + \frac{1}{x}}\right) \cdot \sqrt[3]{1 + \frac{1}{x}}\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      2. pow340.7%

        \[\leadsto \frac{\left(\left(x \cdot \color{blue}{{\left(\sqrt[3]{1 + \frac{1}{x}}\right)}^{3}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    10. Applied egg-rr40.7%

      \[\leadsto \frac{\left(\left(x \cdot \color{blue}{{\left(\sqrt[3]{1 + \frac{1}{x}}\right)}^{3}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]

    if -4.9999999999999995e-309 < x

    1. Initial program 5.5%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity5.5%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/5.5%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg5.5%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg5.5%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified5.5%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 39.3%

      \[\leadsto \frac{\left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    6. Step-by-step derivation
      1. +-commutative39.3%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    7. Simplified39.3%

      \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    8. Taylor expanded in x around inf 97.8%

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

      \[\leadsto \frac{\left(x \bmod \color{blue}{1}\right)}{e^{x}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 68.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{-142}:\\ \;\;\;\;\frac{\left(\left(\left(1 - {x}^{-2}\right) \cdot \frac{x}{1 + \frac{-1}{x}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\\ \mathbf{elif}\;x \leq -8.5 \cdot 10^{-296}:\\ \;\;\;\;\left(\left(x \cdot \left(1 + \frac{1}{x}\right)\right) \bmod 1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left(x \bmod 1\right)\right|}{e^{x}}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -1e-142)
   (/
    (fmod (* (- 1.0 (pow x -2.0)) (/ x (+ 1.0 (/ -1.0 x)))) (sqrt (cos x)))
    (exp x))
   (if (<= x -8.5e-296)
     (fmod (* x (+ 1.0 (/ 1.0 x))) 1.0)
     (/ (fabs (fmod x 1.0)) (exp x)))))
double code(double x) {
	double tmp;
	if (x <= -1e-142) {
		tmp = fmod(((1.0 - pow(x, -2.0)) * (x / (1.0 + (-1.0 / x)))), sqrt(cos(x))) / exp(x);
	} else if (x <= -8.5e-296) {
		tmp = fmod((x * (1.0 + (1.0 / x))), 1.0);
	} else {
		tmp = fabs(fmod(x, 1.0)) / exp(x);
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= (-1d-142)) then
        tmp = mod(((1.0d0 - (x ** (-2.0d0))) * (x / (1.0d0 + ((-1.0d0) / x)))), sqrt(cos(x))) / exp(x)
    else if (x <= (-8.5d-296)) then
        tmp = mod((x * (1.0d0 + (1.0d0 / x))), 1.0d0)
    else
        tmp = abs(mod(x, 1.0d0)) / exp(x)
    end if
    code = tmp
end function
def code(x):
	tmp = 0
	if x <= -1e-142:
		tmp = math.fmod(((1.0 - math.pow(x, -2.0)) * (x / (1.0 + (-1.0 / x)))), math.sqrt(math.cos(x))) / math.exp(x)
	elif x <= -8.5e-296:
		tmp = math.fmod((x * (1.0 + (1.0 / x))), 1.0)
	else:
		tmp = math.fabs(math.fmod(x, 1.0)) / math.exp(x)
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -1e-142)
		tmp = Float64(rem(Float64(Float64(1.0 - (x ^ -2.0)) * Float64(x / Float64(1.0 + Float64(-1.0 / x)))), sqrt(cos(x))) / exp(x));
	elseif (x <= -8.5e-296)
		tmp = rem(Float64(x * Float64(1.0 + Float64(1.0 / x))), 1.0);
	else
		tmp = Float64(abs(rem(x, 1.0)) / exp(x));
	end
	return tmp
end
code[x_] := If[LessEqual[x, -1e-142], N[(N[With[{TMP1 = N[(N[(1.0 - N[Power[x, -2.0], $MachinePrecision]), $MachinePrecision] * N[(x / N[(1.0 + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -8.5e-296], N[With[{TMP1 = N[(x * N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision], N[(N[Abs[N[With[{TMP1 = x, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-142}:\\
\;\;\;\;\frac{\left(\left(\left(1 - {x}^{-2}\right) \cdot \frac{x}{1 + \frac{-1}{x}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\\

\mathbf{elif}\;x \leq -8.5 \cdot 10^{-296}:\\
\;\;\;\;\left(\left(x \cdot \left(1 + \frac{1}{x}\right)\right) \bmod 1\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\left|\left(x \bmod 1\right)\right|}{e^{x}}\\


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

    1. Initial program 15.2%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity15.2%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/15.2%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg15.2%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg15.2%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified15.2%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 12.8%

      \[\leadsto \frac{\left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    6. Step-by-step derivation
      1. +-commutative12.8%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    7. Simplified12.8%

      \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    8. Taylor expanded in x around inf 17.6%

      \[\leadsto \frac{\left(\color{blue}{\left(x \cdot \left(1 + \frac{1}{x}\right)\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    9. Step-by-step derivation
      1. flip-+17.6%

        \[\leadsto \frac{\left(\left(x \cdot \color{blue}{\frac{1 \cdot 1 - \frac{1}{x} \cdot \frac{1}{x}}{1 - \frac{1}{x}}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      2. associate-*r/18.0%

        \[\leadsto \frac{\left(\color{blue}{\left(\frac{x \cdot \left(1 \cdot 1 - \frac{1}{x} \cdot \frac{1}{x}\right)}{1 - \frac{1}{x}}\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      3. metadata-eval18.0%

        \[\leadsto \frac{\left(\left(\frac{x \cdot \left(\color{blue}{1} - \frac{1}{x} \cdot \frac{1}{x}\right)}{1 - \frac{1}{x}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      4. inv-pow18.0%

        \[\leadsto \frac{\left(\left(\frac{x \cdot \left(1 - \color{blue}{{x}^{-1}} \cdot \frac{1}{x}\right)}{1 - \frac{1}{x}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      5. inv-pow18.0%

        \[\leadsto \frac{\left(\left(\frac{x \cdot \left(1 - {x}^{-1} \cdot \color{blue}{{x}^{-1}}\right)}{1 - \frac{1}{x}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      6. pow-prod-up22.9%

        \[\leadsto \frac{\left(\left(\frac{x \cdot \left(1 - \color{blue}{{x}^{\left(-1 + -1\right)}}\right)}{1 - \frac{1}{x}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      7. metadata-eval22.9%

        \[\leadsto \frac{\left(\left(\frac{x \cdot \left(1 - {x}^{\color{blue}{-2}}\right)}{1 - \frac{1}{x}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    10. Applied egg-rr22.9%

      \[\leadsto \frac{\left(\color{blue}{\left(\frac{x \cdot \left(1 - {x}^{-2}\right)}{1 - \frac{1}{x}}\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    11. Step-by-step derivation
      1. *-commutative22.9%

        \[\leadsto \frac{\left(\left(\frac{\color{blue}{\left(1 - {x}^{-2}\right) \cdot x}}{1 - \frac{1}{x}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      2. associate-/l*37.3%

        \[\leadsto \frac{\left(\color{blue}{\left(\left(1 - {x}^{-2}\right) \cdot \frac{x}{1 - \frac{1}{x}}\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    12. Simplified37.3%

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

    if -1e-142 < x < -8.50000000000000018e-296

    1. Initial program 3.1%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity3.1%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/3.1%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg3.1%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg3.1%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified3.1%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 3.1%

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

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

      \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod 1\right) \]
    8. Step-by-step derivation
      1. +-commutative3.1%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    9. Simplified3.1%

      \[\leadsto \left(\color{blue}{\left(x + 1\right)} \bmod 1\right) \]
    10. Taylor expanded in x around inf 25.1%

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

    if -8.50000000000000018e-296 < x

    1. Initial program 5.5%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity5.5%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/5.5%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg5.5%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg5.5%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified5.5%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 39.0%

      \[\leadsto \frac{\left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    6. Step-by-step derivation
      1. +-commutative39.0%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    7. Simplified39.0%

      \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    8. Taylor expanded in x around inf 97.2%

      \[\leadsto \frac{\left(\color{blue}{x} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt96.6%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(x \bmod \left(\sqrt{\cos x}\right)\right)} \cdot \sqrt{\left(x \bmod \left(\sqrt{\cos x}\right)\right)}}}{e^{x}} \]
      2. sqrt-unprod65.5%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(x \bmod \left(\sqrt{\cos x}\right)\right) \cdot \left(x \bmod \left(\sqrt{\cos x}\right)\right)}}}{e^{x}} \]
      3. pow265.5%

        \[\leadsto \frac{\sqrt{\color{blue}{{\left(x \bmod \left(\sqrt{\cos x}\right)\right)}^{2}}}}{e^{x}} \]
    10. Applied egg-rr65.5%

      \[\leadsto \frac{\color{blue}{\sqrt{{\left(x \bmod \left(\sqrt{\cos x}\right)\right)}^{2}}}}{e^{x}} \]
    11. Step-by-step derivation
      1. unpow265.5%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(x \bmod \left(\sqrt{\cos x}\right)\right) \cdot \left(x \bmod \left(\sqrt{\cos x}\right)\right)}}}{e^{x}} \]
      2. rem-sqrt-square97.2%

        \[\leadsto \frac{\color{blue}{\left|\left(x \bmod \left(\sqrt{\cos x}\right)\right)\right|}}{e^{x}} \]
    12. Simplified97.2%

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

      \[\leadsto \frac{\left|\left(x \bmod \color{blue}{1}\right)\right|}{e^{x}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification73.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{-142}:\\ \;\;\;\;\frac{\left(\left(\left(1 - {x}^{-2}\right) \cdot \frac{x}{1 + \frac{-1}{x}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\\ \mathbf{elif}\;x \leq -8.5 \cdot 10^{-296}:\\ \;\;\;\;\left(\left(x \cdot \left(1 + \frac{1}{x}\right)\right) \bmod 1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left(x \bmod 1\right)\right|}{e^{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 69.0% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{-142}:\\ \;\;\;\;\frac{\left(\left(x \cdot \frac{-1 + {x}^{-2}}{-1 + \frac{1}{x}}\right) \bmod 1\right)}{e^{x}}\\ \mathbf{elif}\;x \leq -8.5 \cdot 10^{-296}:\\ \;\;\;\;\left(\left(x \cdot \left(1 + \frac{1}{x}\right)\right) \bmod 1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left(x \bmod 1\right)\right|}{e^{x}}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -1e-142)
   (/ (fmod (* x (/ (+ -1.0 (pow x -2.0)) (+ -1.0 (/ 1.0 x)))) 1.0) (exp x))
   (if (<= x -8.5e-296)
     (fmod (* x (+ 1.0 (/ 1.0 x))) 1.0)
     (/ (fabs (fmod x 1.0)) (exp x)))))
double code(double x) {
	double tmp;
	if (x <= -1e-142) {
		tmp = fmod((x * ((-1.0 + pow(x, -2.0)) / (-1.0 + (1.0 / x)))), 1.0) / exp(x);
	} else if (x <= -8.5e-296) {
		tmp = fmod((x * (1.0 + (1.0 / x))), 1.0);
	} else {
		tmp = fabs(fmod(x, 1.0)) / exp(x);
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= (-1d-142)) then
        tmp = mod((x * (((-1.0d0) + (x ** (-2.0d0))) / ((-1.0d0) + (1.0d0 / x)))), 1.0d0) / exp(x)
    else if (x <= (-8.5d-296)) then
        tmp = mod((x * (1.0d0 + (1.0d0 / x))), 1.0d0)
    else
        tmp = abs(mod(x, 1.0d0)) / exp(x)
    end if
    code = tmp
end function
def code(x):
	tmp = 0
	if x <= -1e-142:
		tmp = math.fmod((x * ((-1.0 + math.pow(x, -2.0)) / (-1.0 + (1.0 / x)))), 1.0) / math.exp(x)
	elif x <= -8.5e-296:
		tmp = math.fmod((x * (1.0 + (1.0 / x))), 1.0)
	else:
		tmp = math.fabs(math.fmod(x, 1.0)) / math.exp(x)
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -1e-142)
		tmp = Float64(rem(Float64(x * Float64(Float64(-1.0 + (x ^ -2.0)) / Float64(-1.0 + Float64(1.0 / x)))), 1.0) / exp(x));
	elseif (x <= -8.5e-296)
		tmp = rem(Float64(x * Float64(1.0 + Float64(1.0 / x))), 1.0);
	else
		tmp = Float64(abs(rem(x, 1.0)) / exp(x));
	end
	return tmp
end
code[x_] := If[LessEqual[x, -1e-142], N[(N[With[{TMP1 = N[(x * N[(N[(-1.0 + N[Power[x, -2.0], $MachinePrecision]), $MachinePrecision] / N[(-1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -8.5e-296], N[With[{TMP1 = N[(x * N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision], N[(N[Abs[N[With[{TMP1 = x, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-142}:\\
\;\;\;\;\frac{\left(\left(x \cdot \frac{-1 + {x}^{-2}}{-1 + \frac{1}{x}}\right) \bmod 1\right)}{e^{x}}\\

\mathbf{elif}\;x \leq -8.5 \cdot 10^{-296}:\\
\;\;\;\;\left(\left(x \cdot \left(1 + \frac{1}{x}\right)\right) \bmod 1\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\left|\left(x \bmod 1\right)\right|}{e^{x}}\\


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

    1. Initial program 15.2%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity15.2%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/15.2%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg15.2%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg15.2%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified15.2%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 12.8%

      \[\leadsto \frac{\left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    6. Step-by-step derivation
      1. +-commutative12.8%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    7. Simplified12.8%

      \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    8. Taylor expanded in x around inf 17.6%

      \[\leadsto \frac{\left(\color{blue}{\left(x \cdot \left(1 + \frac{1}{x}\right)\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    9. Step-by-step derivation
      1. +-commutative17.6%

        \[\leadsto \frac{\left(\left(x \cdot \color{blue}{\left(\frac{1}{x} + 1\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      2. flip-+17.6%

        \[\leadsto \frac{\left(\left(x \cdot \color{blue}{\frac{\frac{1}{x} \cdot \frac{1}{x} - 1 \cdot 1}{\frac{1}{x} - 1}}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      3. inv-pow17.6%

        \[\leadsto \frac{\left(\left(x \cdot \frac{\color{blue}{{x}^{-1}} \cdot \frac{1}{x} - 1 \cdot 1}{\frac{1}{x} - 1}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      4. inv-pow17.6%

        \[\leadsto \frac{\left(\left(x \cdot \frac{{x}^{-1} \cdot \color{blue}{{x}^{-1}} - 1 \cdot 1}{\frac{1}{x} - 1}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      5. pow-prod-up32.8%

        \[\leadsto \frac{\left(\left(x \cdot \frac{\color{blue}{{x}^{\left(-1 + -1\right)}} - 1 \cdot 1}{\frac{1}{x} - 1}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      6. metadata-eval32.8%

        \[\leadsto \frac{\left(\left(x \cdot \frac{{x}^{\color{blue}{-2}} - 1 \cdot 1}{\frac{1}{x} - 1}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
      7. metadata-eval32.8%

        \[\leadsto \frac{\left(\left(x \cdot \frac{{x}^{-2} - \color{blue}{1}}{\frac{1}{x} - 1}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    10. Applied egg-rr32.8%

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

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

    if -1e-142 < x < -8.50000000000000018e-296

    1. Initial program 3.1%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity3.1%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/3.1%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg3.1%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg3.1%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified3.1%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 3.1%

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

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

      \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod 1\right) \]
    8. Step-by-step derivation
      1. +-commutative3.1%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    9. Simplified3.1%

      \[\leadsto \left(\color{blue}{\left(x + 1\right)} \bmod 1\right) \]
    10. Taylor expanded in x around inf 25.1%

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

    if -8.50000000000000018e-296 < x

    1. Initial program 5.5%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity5.5%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/5.5%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg5.5%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg5.5%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified5.5%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 39.0%

      \[\leadsto \frac{\left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    6. Step-by-step derivation
      1. +-commutative39.0%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    7. Simplified39.0%

      \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    8. Taylor expanded in x around inf 97.2%

      \[\leadsto \frac{\left(\color{blue}{x} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt96.6%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(x \bmod \left(\sqrt{\cos x}\right)\right)} \cdot \sqrt{\left(x \bmod \left(\sqrt{\cos x}\right)\right)}}}{e^{x}} \]
      2. sqrt-unprod65.5%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(x \bmod \left(\sqrt{\cos x}\right)\right) \cdot \left(x \bmod \left(\sqrt{\cos x}\right)\right)}}}{e^{x}} \]
      3. pow265.5%

        \[\leadsto \frac{\sqrt{\color{blue}{{\left(x \bmod \left(\sqrt{\cos x}\right)\right)}^{2}}}}{e^{x}} \]
    10. Applied egg-rr65.5%

      \[\leadsto \frac{\color{blue}{\sqrt{{\left(x \bmod \left(\sqrt{\cos x}\right)\right)}^{2}}}}{e^{x}} \]
    11. Step-by-step derivation
      1. unpow265.5%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(x \bmod \left(\sqrt{\cos x}\right)\right) \cdot \left(x \bmod \left(\sqrt{\cos x}\right)\right)}}}{e^{x}} \]
      2. rem-sqrt-square97.2%

        \[\leadsto \frac{\color{blue}{\left|\left(x \bmod \left(\sqrt{\cos x}\right)\right)\right|}}{e^{x}} \]
    12. Simplified97.2%

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

      \[\leadsto \frac{\left|\left(x \bmod \color{blue}{1}\right)\right|}{e^{x}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification72.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{-142}:\\ \;\;\;\;\frac{\left(\left(x \cdot \frac{-1 + {x}^{-2}}{-1 + \frac{1}{x}}\right) \bmod 1\right)}{e^{x}}\\ \mathbf{elif}\;x \leq -8.5 \cdot 10^{-296}:\\ \;\;\;\;\left(\left(x \cdot \left(1 + \frac{1}{x}\right)\right) \bmod 1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left(x \bmod 1\right)\right|}{e^{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 67.1% accurate, 1.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.5 \cdot 10^{-296}:\\
\;\;\;\;\frac{\left(\left(x \cdot \left(1 + \frac{1}{x}\right)\right) \bmod 1\right)}{e^{x}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left|\left(x \bmod 1\right)\right|}{e^{x}}\\


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

    1. Initial program 8.4%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity8.4%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/8.4%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg8.4%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg8.4%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified8.4%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 7.4%

      \[\leadsto \frac{\left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    6. Step-by-step derivation
      1. +-commutative7.4%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    7. Simplified7.4%

      \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    8. Taylor expanded in x around inf 21.9%

      \[\leadsto \frac{\left(\color{blue}{\left(x \cdot \left(1 + \frac{1}{x}\right)\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    9. Taylor expanded in x around 0 21.9%

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

    if -8.50000000000000018e-296 < x

    1. Initial program 5.5%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity5.5%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/5.5%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg5.5%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg5.5%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified5.5%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 39.0%

      \[\leadsto \frac{\left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    6. Step-by-step derivation
      1. +-commutative39.0%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    7. Simplified39.0%

      \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    8. Taylor expanded in x around inf 97.2%

      \[\leadsto \frac{\left(\color{blue}{x} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt96.6%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(x \bmod \left(\sqrt{\cos x}\right)\right)} \cdot \sqrt{\left(x \bmod \left(\sqrt{\cos x}\right)\right)}}}{e^{x}} \]
      2. sqrt-unprod65.5%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(x \bmod \left(\sqrt{\cos x}\right)\right) \cdot \left(x \bmod \left(\sqrt{\cos x}\right)\right)}}}{e^{x}} \]
      3. pow265.5%

        \[\leadsto \frac{\sqrt{\color{blue}{{\left(x \bmod \left(\sqrt{\cos x}\right)\right)}^{2}}}}{e^{x}} \]
    10. Applied egg-rr65.5%

      \[\leadsto \frac{\color{blue}{\sqrt{{\left(x \bmod \left(\sqrt{\cos x}\right)\right)}^{2}}}}{e^{x}} \]
    11. Step-by-step derivation
      1. unpow265.5%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(x \bmod \left(\sqrt{\cos x}\right)\right) \cdot \left(x \bmod \left(\sqrt{\cos x}\right)\right)}}}{e^{x}} \]
      2. rem-sqrt-square97.2%

        \[\leadsto \frac{\color{blue}{\left|\left(x \bmod \left(\sqrt{\cos x}\right)\right)\right|}}{e^{x}} \]
    12. Simplified97.2%

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

      \[\leadsto \frac{\left|\left(x \bmod \color{blue}{1}\right)\right|}{e^{x}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 67.4% accurate, 2.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-309}:\\
\;\;\;\;\frac{\left(\left(x \cdot \left(1 + \frac{1}{x}\right)\right) \bmod 1\right)}{e^{x}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(x \bmod 1\right)}{e^{x}}\\


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

    1. Initial program 8.3%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity8.3%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/8.3%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg8.3%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg8.3%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified8.3%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 7.3%

      \[\leadsto \frac{\left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    6. Step-by-step derivation
      1. +-commutative7.3%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    7. Simplified7.3%

      \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    8. Taylor expanded in x around inf 21.7%

      \[\leadsto \frac{\left(\color{blue}{\left(x \cdot \left(1 + \frac{1}{x}\right)\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    9. Taylor expanded in x around 0 21.7%

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

    if -4.9999999999999995e-309 < x

    1. Initial program 5.5%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity5.5%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/5.5%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg5.5%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg5.5%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified5.5%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 39.3%

      \[\leadsto \frac{\left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    6. Step-by-step derivation
      1. +-commutative39.3%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    7. Simplified39.3%

      \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    8. Taylor expanded in x around inf 97.8%

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

      \[\leadsto \frac{\left(x \bmod \color{blue}{1}\right)}{e^{x}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 67.0% accurate, 2.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-309}:\\
\;\;\;\;\left(\left(x \cdot \left(1 + \frac{1}{x}\right)\right) \bmod 1\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(x \bmod 1\right)}{e^{x}}\\


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

    1. Initial program 8.3%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity8.3%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/8.3%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg8.3%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg8.3%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified8.3%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 8.3%

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

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

      \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod 1\right) \]
    8. Step-by-step derivation
      1. +-commutative7.3%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    9. Simplified6.0%

      \[\leadsto \left(\color{blue}{\left(x + 1\right)} \bmod 1\right) \]
    10. Taylor expanded in x around inf 20.4%

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

    if -4.9999999999999995e-309 < x

    1. Initial program 5.5%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity5.5%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/5.5%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg5.5%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg5.5%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified5.5%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 39.3%

      \[\leadsto \frac{\left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    6. Step-by-step derivation
      1. +-commutative39.3%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    7. Simplified39.3%

      \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    8. Taylor expanded in x around inf 97.8%

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

      \[\leadsto \frac{\left(x \bmod \color{blue}{1}\right)}{e^{x}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 11: 66.2% accurate, 4.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-309}:\\
\;\;\;\;\left(\left(x \cdot \left(1 + \frac{1}{x}\right)\right) \bmod 1\right)\\

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


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

    1. Initial program 8.3%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity8.3%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/8.3%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg8.3%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg8.3%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified8.3%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 8.3%

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

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

      \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod 1\right) \]
    8. Step-by-step derivation
      1. +-commutative7.3%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    9. Simplified6.0%

      \[\leadsto \left(\color{blue}{\left(x + 1\right)} \bmod 1\right) \]
    10. Taylor expanded in x around inf 20.4%

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

    if -4.9999999999999995e-309 < x

    1. Initial program 5.5%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Step-by-step derivation
      1. /-rgt-identity5.5%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
      2. associate-/r/5.5%

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
      3. exp-neg5.5%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
      4. remove-double-neg5.5%

        \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
    3. Simplified5.5%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 4.8%

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

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

      \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod 1\right) \]
    8. Step-by-step derivation
      1. +-commutative39.3%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
    9. Simplified37.9%

      \[\leadsto \left(\color{blue}{\left(x + 1\right)} \bmod 1\right) \]
    10. Taylor expanded in x around inf 96.5%

      \[\leadsto \left(\color{blue}{x} \bmod 1\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 12: 59.5% accurate, 5.0× 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 6.6%

    \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
  2. Step-by-step derivation
    1. /-rgt-identity6.6%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{1}} \cdot e^{-x} \]
    2. associate-/r/6.6%

      \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\frac{1}{e^{-x}}}} \]
    3. exp-neg6.6%

      \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{\color{blue}{e^{-\left(-x\right)}}} \]
    4. remove-double-neg6.6%

      \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{\color{blue}{x}}} \]
  3. Simplified6.6%

    \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 6.1%

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

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

    \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod 1\right) \]
  8. Step-by-step derivation
    1. +-commutative27.7%

      \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right)} \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]
  9. Simplified26.3%

    \[\leadsto \left(\color{blue}{\left(x + 1\right)} \bmod 1\right) \]
  10. Taylor expanded in x around inf 62.3%

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

Reproduce

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