expfmod (used to be hard to sample)

Percentage Accurate: 6.8% → 12.7%
Time: 18.4s
Alternatives: 16
Speedup: 1.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 16 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.8% 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: 12.7% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\ t_1 := \mathsf{expm1}\left(t_0 - x\right)\\ t_2 := {t_1}^{2}\\ t_3 := 1 - t_1\\ t_4 := {t_3}^{-0.5}\\ \mathbf{if}\;x \leq -2 \cdot 10^{-311}:\\ \;\;\;\;\frac{1}{t_3} - \frac{t_2}{1 - \mathsf{expm1}\left(\left|t_0\right| - x\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t_4, t_4, \frac{-t_2}{t_3}\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (log (fmod (exp x) (sqrt (cos x)))))
        (t_1 (expm1 (- t_0 x)))
        (t_2 (pow t_1 2.0))
        (t_3 (- 1.0 t_1))
        (t_4 (pow t_3 -0.5)))
   (if (<= x -2e-311)
     (- (/ 1.0 t_3) (/ t_2 (- 1.0 (expm1 (- (fabs t_0) x)))))
     (fma t_4 t_4 (/ (- t_2) t_3)))))
double code(double x) {
	double t_0 = log(fmod(exp(x), sqrt(cos(x))));
	double t_1 = expm1((t_0 - x));
	double t_2 = pow(t_1, 2.0);
	double t_3 = 1.0 - t_1;
	double t_4 = pow(t_3, -0.5);
	double tmp;
	if (x <= -2e-311) {
		tmp = (1.0 / t_3) - (t_2 / (1.0 - expm1((fabs(t_0) - x))));
	} else {
		tmp = fma(t_4, t_4, (-t_2 / t_3));
	}
	return tmp;
}
function code(x)
	t_0 = log(rem(exp(x), sqrt(cos(x))))
	t_1 = expm1(Float64(t_0 - x))
	t_2 = t_1 ^ 2.0
	t_3 = Float64(1.0 - t_1)
	t_4 = t_3 ^ -0.5
	tmp = 0.0
	if (x <= -2e-311)
		tmp = Float64(Float64(1.0 / t_3) - Float64(t_2 / Float64(1.0 - expm1(Float64(abs(t_0) - x)))));
	else
		tmp = fma(t_4, t_4, Float64(Float64(-t_2) / t_3));
	end
	return tmp
end
code[x_] := Block[{t$95$0 = N[Log[N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(Exp[N[(t$95$0 - x), $MachinePrecision]] - 1), $MachinePrecision]}, Block[{t$95$2 = N[Power[t$95$1, 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(1.0 - t$95$1), $MachinePrecision]}, Block[{t$95$4 = N[Power[t$95$3, -0.5], $MachinePrecision]}, If[LessEqual[x, -2e-311], N[(N[(1.0 / t$95$3), $MachinePrecision] - N[(t$95$2 / N[(1.0 - N[(Exp[N[(N[Abs[t$95$0], $MachinePrecision] - x), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$4 * t$95$4 + N[((-t$95$2) / t$95$3), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\
t_1 := \mathsf{expm1}\left(t_0 - x\right)\\
t_2 := {t_1}^{2}\\
t_3 := 1 - t_1\\
t_4 := {t_3}^{-0.5}\\
\mathbf{if}\;x \leq -2 \cdot 10^{-311}:\\
\;\;\;\;\frac{1}{t_3} - \frac{t_2}{1 - \mathsf{expm1}\left(\left|t_0\right| - x\right)}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_4, t_4, \frac{-t_2}{t_3}\right)\\


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

    1. Initial program 12.3%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(1 + \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\right)} - 1 \]
    5. Applied egg-rr12.4%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt0.0%

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

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

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\sqrt{\color{blue}{{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}^{2}}} - x\right)} \]
    11. Applied egg-rr26.6%

      \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\color{blue}{\sqrt{{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}^{2}}} - x\right)} \]
    12. Step-by-step derivation
      1. unpow226.6%

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\sqrt{\color{blue}{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}} - x\right)} \]
      2. rem-sqrt-square26.6%

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\color{blue}{\left|\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\right|} - x\right)} \]
    13. Simplified26.6%

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

    if -1.9999999999999e-311 < x

    1. Initial program 6.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt6.8%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}}, \sqrt{\frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}}, -\frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}\right)} \]
    11. Applied egg-rr6.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left({\left(1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{-0.5}, {\left(1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{-0.5}, -\frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification14.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{-311}:\\ \;\;\;\;\frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\left|\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\right| - x\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left({\left(1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{-0.5}, {\left(1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{-0.5}, \frac{-{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}\right)\\ \end{array} \]

Alternative 2: 12.6% accurate, 0.2× speedup?

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

\\
\begin{array}{l}
t_0 := \log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\
t_1 := \mathsf{expm1}\left(t_0 - x\right)\\
t_2 := {t_1}^{2}\\
t_3 := 1 - t_1\\
t_4 := \frac{1}{t_3}\\
\mathbf{if}\;x \leq -2 \cdot 10^{-311}:\\
\;\;\;\;t_4 - \frac{t_2}{1 - \mathsf{expm1}\left(\left|t_0\right| - x\right)}\\

\mathbf{else}:\\
\;\;\;\;t_4 - \sqrt[3]{{\left(\frac{t_2}{t_3}\right)}^{3}}\\


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

    1. Initial program 12.3%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(1 + \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\right)} - 1 \]
    5. Applied egg-rr12.4%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt0.0%

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

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

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\sqrt{\color{blue}{{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}^{2}}} - x\right)} \]
    11. Applied egg-rr26.6%

      \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\color{blue}{\sqrt{{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}^{2}}} - x\right)} \]
    12. Step-by-step derivation
      1. unpow226.6%

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\sqrt{\color{blue}{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}} - x\right)} \]
      2. rem-sqrt-square26.6%

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\color{blue}{\left|\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\right|} - x\right)} \]
    13. Simplified26.6%

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

    if -1.9999999999999e-311 < x

    1. Initial program 6.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt0.0%

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

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

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\sqrt{\color{blue}{{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}^{2}}} - x\right)} \]
    11. Applied egg-rr3.9%

      \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\color{blue}{\sqrt{{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}^{2}}} - x\right)} \]
    12. Step-by-step derivation
      1. unpow23.9%

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

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\color{blue}{\left|\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\right|} - x\right)} \]
    13. Simplified3.9%

      \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\color{blue}{\left|\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\right|} - x\right)} \]
    14. Step-by-step derivation
      1. add-cbrt-cube3.9%

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

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \sqrt[3]{\color{blue}{{\left(\frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\left|\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\right| - x\right)}\right)}^{3}}} \]
    15. Applied egg-rr6.9%

      \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \color{blue}{\sqrt[3]{{\left(\frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}\right)}^{3}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification14.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{-311}:\\ \;\;\;\;\frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\left|\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\right| - x\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \sqrt[3]{{\left(\frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}\right)}^{3}}\\ \end{array} \]

Alternative 3: 12.6% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\ t_1 := \log t_0\\ t_2 := \mathsf{expm1}\left(t_1 - x\right)\\ t_3 := \frac{1}{1 - t_2}\\ \mathbf{if}\;x \leq -2 \cdot 10^{-311}:\\ \;\;\;\;t_3 - \frac{{t_2}^{2}}{1 - \mathsf{expm1}\left(\left|t_1\right| - x\right)}\\ \mathbf{else}:\\ \;\;\;\;t_3 - {\left(\frac{t_2}{\sqrt{2 - \frac{t_0}{e^{x}}}}\right)}^{2}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (fmod (exp x) (sqrt (cos x))))
        (t_1 (log t_0))
        (t_2 (expm1 (- t_1 x)))
        (t_3 (/ 1.0 (- 1.0 t_2))))
   (if (<= x -2e-311)
     (- t_3 (/ (pow t_2 2.0) (- 1.0 (expm1 (- (fabs t_1) x)))))
     (- t_3 (pow (/ t_2 (sqrt (- 2.0 (/ t_0 (exp x))))) 2.0)))))
double code(double x) {
	double t_0 = fmod(exp(x), sqrt(cos(x)));
	double t_1 = log(t_0);
	double t_2 = expm1((t_1 - x));
	double t_3 = 1.0 / (1.0 - t_2);
	double tmp;
	if (x <= -2e-311) {
		tmp = t_3 - (pow(t_2, 2.0) / (1.0 - expm1((fabs(t_1) - x))));
	} else {
		tmp = t_3 - pow((t_2 / sqrt((2.0 - (t_0 / exp(x))))), 2.0);
	}
	return tmp;
}
def code(x):
	t_0 = math.fmod(math.exp(x), math.sqrt(math.cos(x)))
	t_1 = math.log(t_0)
	t_2 = math.expm1((t_1 - x))
	t_3 = 1.0 / (1.0 - t_2)
	tmp = 0
	if x <= -2e-311:
		tmp = t_3 - (math.pow(t_2, 2.0) / (1.0 - math.expm1((math.fabs(t_1) - x))))
	else:
		tmp = t_3 - math.pow((t_2 / math.sqrt((2.0 - (t_0 / math.exp(x))))), 2.0)
	return tmp
function code(x)
	t_0 = rem(exp(x), sqrt(cos(x)))
	t_1 = log(t_0)
	t_2 = expm1(Float64(t_1 - x))
	t_3 = Float64(1.0 / Float64(1.0 - t_2))
	tmp = 0.0
	if (x <= -2e-311)
		tmp = Float64(t_3 - Float64((t_2 ^ 2.0) / Float64(1.0 - expm1(Float64(abs(t_1) - x)))));
	else
		tmp = Float64(t_3 - (Float64(t_2 / sqrt(Float64(2.0 - Float64(t_0 / exp(x))))) ^ 2.0));
	end
	return tmp
end
code[x_] := Block[{t$95$0 = N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]}, Block[{t$95$1 = N[Log[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[(Exp[N[(t$95$1 - x), $MachinePrecision]] - 1), $MachinePrecision]}, Block[{t$95$3 = N[(1.0 / N[(1.0 - t$95$2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2e-311], N[(t$95$3 - N[(N[Power[t$95$2, 2.0], $MachinePrecision] / N[(1.0 - N[(Exp[N[(N[Abs[t$95$1], $MachinePrecision] - x), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$3 - N[Power[N[(t$95$2 / N[Sqrt[N[(2.0 - N[(t$95$0 / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\
t_1 := \log t_0\\
t_2 := \mathsf{expm1}\left(t_1 - x\right)\\
t_3 := \frac{1}{1 - t_2}\\
\mathbf{if}\;x \leq -2 \cdot 10^{-311}:\\
\;\;\;\;t_3 - \frac{{t_2}^{2}}{1 - \mathsf{expm1}\left(\left|t_1\right| - x\right)}\\

\mathbf{else}:\\
\;\;\;\;t_3 - {\left(\frac{t_2}{\sqrt{2 - \frac{t_0}{e^{x}}}}\right)}^{2}\\


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

    1. Initial program 12.3%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(1 + \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\right)} - 1 \]
    5. Applied egg-rr12.4%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt0.0%

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

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

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\sqrt{\color{blue}{{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}^{2}}} - x\right)} \]
    11. Applied egg-rr26.6%

      \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\color{blue}{\sqrt{{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}^{2}}} - x\right)} \]
    12. Step-by-step derivation
      1. unpow226.6%

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\sqrt{\color{blue}{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}} - x\right)} \]
      2. rem-sqrt-square26.6%

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\color{blue}{\left|\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\right|} - x\right)} \]
    13. Simplified26.6%

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

    if -1.9999999999999e-311 < x

    1. Initial program 6.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt0.0%

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

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

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\sqrt{\color{blue}{{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}^{2}}} - x\right)} \]
    11. Applied egg-rr3.9%

      \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\color{blue}{\sqrt{{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}^{2}}} - x\right)} \]
    12. Step-by-step derivation
      1. unpow23.9%

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

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\color{blue}{\left|\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\right|} - x\right)} \]
    13. Simplified3.9%

      \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\color{blue}{\left|\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\right|} - x\right)} \]
    14. Step-by-step derivation
      1. add-sqr-sqrt3.4%

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \color{blue}{\sqrt{\frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\left|\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\right| - x\right)}} \cdot \sqrt{\frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\left|\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\right| - x\right)}}} \]
    15. Applied egg-rr6.9%

      \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \color{blue}{\frac{\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}{\sqrt{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}} \cdot \frac{\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}{\sqrt{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}}} \]
    16. Step-by-step derivation
      1. unpow26.9%

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \color{blue}{{\left(\frac{\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}{\sqrt{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}}\right)}^{2}} \]
    17. Simplified6.9%

      \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \color{blue}{{\left(\frac{\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}{\sqrt{2 - \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}}}\right)}^{2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification14.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{-311}:\\ \;\;\;\;\frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\left|\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\right| - x\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - {\left(\frac{\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}{\sqrt{2 - \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}}}\right)}^{2}\\ \end{array} \]

Alternative 4: 12.2% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\ t_1 := \log t_0\\ t_2 := \mathsf{expm1}\left(t_1 - x\right)\\ t_3 := \frac{1}{1 - t_2}\\ \mathbf{if}\;x \leq -2 \cdot 10^{-311}:\\ \;\;\;\;t_3 - \frac{{\left(t_0 + -1\right)}^{2}}{2 - e^{\left|t_1\right|}}\\ \mathbf{else}:\\ \;\;\;\;t_3 - {\left(\frac{t_2}{\sqrt{2 - \frac{t_0}{e^{x}}}}\right)}^{2}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (fmod (exp x) (sqrt (cos x))))
        (t_1 (log t_0))
        (t_2 (expm1 (- t_1 x)))
        (t_3 (/ 1.0 (- 1.0 t_2))))
   (if (<= x -2e-311)
     (- t_3 (/ (pow (+ t_0 -1.0) 2.0) (- 2.0 (exp (fabs t_1)))))
     (- t_3 (pow (/ t_2 (sqrt (- 2.0 (/ t_0 (exp x))))) 2.0)))))
double code(double x) {
	double t_0 = fmod(exp(x), sqrt(cos(x)));
	double t_1 = log(t_0);
	double t_2 = expm1((t_1 - x));
	double t_3 = 1.0 / (1.0 - t_2);
	double tmp;
	if (x <= -2e-311) {
		tmp = t_3 - (pow((t_0 + -1.0), 2.0) / (2.0 - exp(fabs(t_1))));
	} else {
		tmp = t_3 - pow((t_2 / sqrt((2.0 - (t_0 / exp(x))))), 2.0);
	}
	return tmp;
}
def code(x):
	t_0 = math.fmod(math.exp(x), math.sqrt(math.cos(x)))
	t_1 = math.log(t_0)
	t_2 = math.expm1((t_1 - x))
	t_3 = 1.0 / (1.0 - t_2)
	tmp = 0
	if x <= -2e-311:
		tmp = t_3 - (math.pow((t_0 + -1.0), 2.0) / (2.0 - math.exp(math.fabs(t_1))))
	else:
		tmp = t_3 - math.pow((t_2 / math.sqrt((2.0 - (t_0 / math.exp(x))))), 2.0)
	return tmp
function code(x)
	t_0 = rem(exp(x), sqrt(cos(x)))
	t_1 = log(t_0)
	t_2 = expm1(Float64(t_1 - x))
	t_3 = Float64(1.0 / Float64(1.0 - t_2))
	tmp = 0.0
	if (x <= -2e-311)
		tmp = Float64(t_3 - Float64((Float64(t_0 + -1.0) ^ 2.0) / Float64(2.0 - exp(abs(t_1)))));
	else
		tmp = Float64(t_3 - (Float64(t_2 / sqrt(Float64(2.0 - Float64(t_0 / exp(x))))) ^ 2.0));
	end
	return tmp
end
code[x_] := Block[{t$95$0 = N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]}, Block[{t$95$1 = N[Log[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[(Exp[N[(t$95$1 - x), $MachinePrecision]] - 1), $MachinePrecision]}, Block[{t$95$3 = N[(1.0 / N[(1.0 - t$95$2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2e-311], N[(t$95$3 - N[(N[Power[N[(t$95$0 + -1.0), $MachinePrecision], 2.0], $MachinePrecision] / N[(2.0 - N[Exp[N[Abs[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$3 - N[Power[N[(t$95$2 / N[Sqrt[N[(2.0 - N[(t$95$0 / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\
t_1 := \log t_0\\
t_2 := \mathsf{expm1}\left(t_1 - x\right)\\
t_3 := \frac{1}{1 - t_2}\\
\mathbf{if}\;x \leq -2 \cdot 10^{-311}:\\
\;\;\;\;t_3 - \frac{{\left(t_0 + -1\right)}^{2}}{2 - e^{\left|t_1\right|}}\\

\mathbf{else}:\\
\;\;\;\;t_3 - {\left(\frac{t_2}{\sqrt{2 - \frac{t_0}{e^{x}}}}\right)}^{2}\\


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

    1. Initial program 12.3%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(1 + \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\right)} - 1 \]
    5. Applied egg-rr12.4%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt0.0%

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

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

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\sqrt{\color{blue}{{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}^{2}}} - x\right)} \]
    11. Applied egg-rr26.6%

      \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\color{blue}{\sqrt{{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}^{2}}} - x\right)} \]
    12. Step-by-step derivation
      1. unpow226.6%

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\sqrt{\color{blue}{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}} - x\right)} \]
      2. rem-sqrt-square26.6%

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\color{blue}{\left|\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\right|} - x\right)} \]
    13. Simplified26.6%

      \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\color{blue}{\left|\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\right|} - x\right)} \]
    14. Taylor expanded in x around 0 24.8%

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

    if -1.9999999999999e-311 < x

    1. Initial program 6.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt0.0%

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

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

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\sqrt{\color{blue}{{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}^{2}}} - x\right)} \]
    11. Applied egg-rr3.9%

      \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\color{blue}{\sqrt{{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}^{2}}} - x\right)} \]
    12. Step-by-step derivation
      1. unpow23.9%

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

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\color{blue}{\left|\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\right|} - x\right)} \]
    13. Simplified3.9%

      \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\color{blue}{\left|\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\right|} - x\right)} \]
    14. Step-by-step derivation
      1. add-sqr-sqrt3.4%

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \color{blue}{\sqrt{\frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\left|\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\right| - x\right)}} \cdot \sqrt{\frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\left|\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\right| - x\right)}}} \]
    15. Applied egg-rr6.9%

      \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \color{blue}{\frac{\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}{\sqrt{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}} \cdot \frac{\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}{\sqrt{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}}} \]
    16. Step-by-step derivation
      1. unpow26.9%

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \color{blue}{{\left(\frac{\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}{\sqrt{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}}\right)}^{2}} \]
    17. Simplified6.9%

      \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \color{blue}{{\left(\frac{\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}{\sqrt{2 - \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}}}\right)}^{2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification14.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{-311}:\\ \;\;\;\;\frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) + -1\right)}^{2}}{2 - e^{\left|\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\right|}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - {\left(\frac{\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}{\sqrt{2 - \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}}}\right)}^{2}\\ \end{array} \]

Alternative 5: 12.3% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\
t_1 := \log t_0\\
\mathbf{if}\;x \leq -2 \cdot 10^{-311}:\\
\;\;\;\;\frac{1}{1 - \mathsf{expm1}\left(t_1 - x\right)} - \frac{{\left(t_0 + -1\right)}^{2}}{2 - e^{\left|t_1\right|}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\log \left(e^{t_0}\right)}{e^{x}}\\


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

    1. Initial program 12.3%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(1 + \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\right)} - 1 \]
    5. Applied egg-rr12.4%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt0.0%

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

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

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\sqrt{\color{blue}{{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}^{2}}} - x\right)} \]
    11. Applied egg-rr26.6%

      \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\color{blue}{\sqrt{{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}^{2}}} - x\right)} \]
    12. Step-by-step derivation
      1. unpow226.6%

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\sqrt{\color{blue}{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}} - x\right)} \]
      2. rem-sqrt-square26.6%

        \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\color{blue}{\left|\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\right|} - x\right)} \]
    13. Simplified26.6%

      \[\leadsto \frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2}}{1 - \mathsf{expm1}\left(\color{blue}{\left|\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\right|} - x\right)} \]
    14. Taylor expanded in x around 0 24.8%

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

    if -1.9999999999999e-311 < x

    1. Initial program 6.8%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{-311}:\\ \;\;\;\;\frac{1}{1 - \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)} - \frac{{\left(\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) + -1\right)}^{2}}{2 - e^{\left|\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\right|}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(e^{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}\right)}{e^{x}}\\ \end{array} \]

Alternative 6: 6.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\\ \frac{{t_0}^{2} + -1}{t_0 + -1} \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (expm1 (- (log (fmod (exp x) (sqrt (cos x)))) x))))
   (/ (+ (pow t_0 2.0) -1.0) (+ t_0 -1.0))))
double code(double x) {
	double t_0 = expm1((log(fmod(exp(x), sqrt(cos(x)))) - x));
	return (pow(t_0, 2.0) + -1.0) / (t_0 + -1.0);
}
def code(x):
	t_0 = math.expm1((math.log(math.fmod(math.exp(x), math.sqrt(math.cos(x)))) - x))
	return (math.pow(t_0, 2.0) + -1.0) / (t_0 + -1.0)
function code(x)
	t_0 = expm1(Float64(log(rem(exp(x), sqrt(cos(x)))) - x))
	return Float64(Float64((t_0 ^ 2.0) + -1.0) / Float64(t_0 + -1.0))
end
code[x_] := Block[{t$95$0 = N[(Exp[N[(N[Log[N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]], $MachinePrecision] - x), $MachinePrecision]] - 1), $MachinePrecision]}, N[(N[(N[Power[t$95$0, 2.0], $MachinePrecision] + -1.0), $MachinePrecision] / N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\\
\frac{{t_0}^{2} + -1}{t_0 + -1}
\end{array}
\end{array}
Derivation
  1. Initial program 9.0%

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

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

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

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

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

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

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

      \[\leadsto e^{\color{blue}{\log \left(1 + \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\right)}} - 1 \]
    4. add-exp-log9.0%

      \[\leadsto \color{blue}{\left(1 + \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\right)} - 1 \]
  5. Applied egg-rr9.0%

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

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

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

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

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

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

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

      \[\leadsto \frac{{\color{blue}{\left(\mathsf{expm1}\left(\log \left(\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\right)\right)\right)}}^{2} - 1 \cdot 1}{\left(\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} - 1\right) - 1} \]
    6. log-div9.0%

      \[\leadsto \frac{{\left(\mathsf{expm1}\left(\color{blue}{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - \log \left(e^{x}\right)}\right)\right)}^{2} - 1 \cdot 1}{\left(\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} - 1\right) - 1} \]
    7. add-log-exp9.0%

      \[\leadsto \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - \color{blue}{x}\right)\right)}^{2} - 1 \cdot 1}{\left(\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} - 1\right) - 1} \]
    8. metadata-eval9.0%

      \[\leadsto \frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2} - \color{blue}{1}}{\left(\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} - 1\right) - 1} \]
  9. Applied egg-rr9.1%

    \[\leadsto \color{blue}{\frac{{\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)\right)}^{2} - 1}{\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right) - 1}} \]
  10. Final simplification9.1%

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

Alternative 7: 6.8% accurate, 1.0× speedup?

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

\\
\left(1 + \left(1 + \left(\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} + -1\right)\right)\right) + -1
\end{array}
Derivation
  1. Initial program 9.0%

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

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

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

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

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

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

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

      \[\leadsto e^{\color{blue}{\log \left(1 + \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\right)}} - 1 \]
    4. add-exp-log9.0%

      \[\leadsto \color{blue}{\left(1 + \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\right)} - 1 \]
  5. Applied egg-rr9.0%

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

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

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

      \[\leadsto e^{\color{blue}{\log \left(1 + \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\right)}} - 1 \]
    4. add-exp-log9.0%

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

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

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

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

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

Alternative 8: 6.8% accurate, 1.0× speedup?

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

\\
1 + \left(\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} + -1\right)
\end{array}
Derivation
  1. Initial program 9.0%

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

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

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

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

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

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

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

      \[\leadsto e^{\color{blue}{\log \left(1 + \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\right)}} - 1 \]
    4. add-exp-log9.0%

      \[\leadsto \color{blue}{\left(1 + \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\right)} - 1 \]
  5. Applied egg-rr9.0%

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

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

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

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

Alternative 9: 6.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{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(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}

\\
\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}
\end{array}
Derivation
  1. Initial program 9.0%

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

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

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

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

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

    \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}} \]

Alternative 10: 6.6% accurate, 1.6× speedup?

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

\\
1 + \left(\frac{\left(\left(e^{x}\right) \bmod \left(1 + \left(x \cdot x\right) \cdot -0.25\right)\right)}{e^{x}} + -1\right)
\end{array}
Derivation
  1. Initial program 9.0%

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

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

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

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

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

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

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

      \[\leadsto e^{\color{blue}{\log \left(1 + \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\right)}} - 1 \]
    4. add-exp-log9.0%

      \[\leadsto \color{blue}{\left(1 + \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\right)} - 1 \]
  5. Applied egg-rr9.0%

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

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

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

    \[\leadsto 1 + \left(\frac{\left(\left(e^{x}\right) \bmod \color{blue}{\left(1 + -0.25 \cdot {x}^{2}\right)}\right)}{e^{x}} - 1\right) \]
  9. Step-by-step derivation
    1. *-commutative8.7%

      \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(1 + \color{blue}{{x}^{2} \cdot -0.25}\right)\right)}{e^{x}} \]
    2. unpow28.7%

      \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(1 + \color{blue}{\left(x \cdot x\right)} \cdot -0.25\right)\right)}{e^{x}} \]
  10. Simplified8.7%

    \[\leadsto 1 + \left(\frac{\left(\left(e^{x}\right) \bmod \color{blue}{\left(1 + \left(x \cdot x\right) \cdot -0.25\right)}\right)}{e^{x}} - 1\right) \]
  11. Final simplification8.7%

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

Alternative 11: 6.6% accurate, 1.6× speedup?

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

\\
\frac{\left(\left(e^{x}\right) \bmod \left(1 + \left(x \cdot x\right) \cdot -0.25\right)\right)}{e^{x}}
\end{array}
Derivation
  1. Initial program 9.0%

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

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

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

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

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

    \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \color{blue}{\left(1 + -0.25 \cdot {x}^{2}\right)}\right)}{e^{x}} \]
  5. Step-by-step derivation
    1. *-commutative8.7%

      \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(1 + \color{blue}{{x}^{2} \cdot -0.25}\right)\right)}{e^{x}} \]
    2. unpow28.7%

      \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(1 + \color{blue}{\left(x \cdot x\right)} \cdot -0.25\right)\right)}{e^{x}} \]
  6. Simplified8.7%

    \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \color{blue}{\left(1 + \left(x \cdot x\right) \cdot -0.25\right)}\right)}{e^{x}} \]
  7. Final simplification8.7%

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

Alternative 12: 6.4% accurate, 1.6× speedup?

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

\\
1 + \left(\frac{\left(\left(e^{x}\right) \bmod 1\right)}{e^{x}} + -1\right)
\end{array}
Derivation
  1. Initial program 9.0%

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

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

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

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

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

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

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

      \[\leadsto e^{\color{blue}{\log \left(1 + \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\right)}} - 1 \]
    4. add-exp-log9.0%

      \[\leadsto \color{blue}{\left(1 + \frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\right)} - 1 \]
  5. Applied egg-rr9.0%

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

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

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

    \[\leadsto 1 + \left(\frac{\left(\left(e^{x}\right) \bmod \color{blue}{1}\right)}{e^{x}} - 1\right) \]
  9. Final simplification8.2%

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

Alternative 13: 6.4% accurate, 1.7× speedup?

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

\\
\frac{\left(\left(e^{x}\right) \bmod 1\right)}{e^{x}}
\end{array}
Derivation
  1. Initial program 9.0%

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

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

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

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

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

    \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \color{blue}{1}\right)}{e^{x}} \]
  5. Final simplification8.2%

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

Alternative 14: 5.8% accurate, 2.4× speedup?

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

\\
\frac{\left(\left(e^{x}\right) \bmod 1\right)}{\frac{x + 1}{1 - x \cdot x}}
\end{array}
Derivation
  1. Initial program 9.0%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 \cdot \left(\left(e^{x}\right) \bmod 1\right)} + -1 \cdot \left(x \cdot \left(\left(e^{x}\right) \bmod 1\right)\right) \]
    3. associate-*r*7.4%

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod 1\right) \cdot \left(1 - x \cdot x\right)}{x + 1}} \]
  10. Step-by-step derivation
    1. associate-/l*7.4%

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

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

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

Alternative 15: 5.8% accurate, 2.5× speedup?

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

\\
\left(\left(e^{x}\right) \bmod 1\right) \cdot \left(1 - x\right)
\end{array}
Derivation
  1. Initial program 9.0%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 \cdot \left(\left(e^{x}\right) \bmod 1\right)} + -1 \cdot \left(x \cdot \left(\left(e^{x}\right) \bmod 1\right)\right) \]
    3. associate-*r*7.4%

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

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

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

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

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

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

Alternative 16: 5.4% accurate, 2.5× speedup?

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

\\
\left(\left(e^{x}\right) \bmod 1\right)
\end{array}
Derivation
  1. Initial program 9.0%

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

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

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

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

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

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

    \[\leadsto \color{blue}{\left(\left(e^{x}\right) \bmod 1\right)} \]
  6. Final simplification6.7%

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

Reproduce

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