?

Average Accuracy: 6.8% → 62.9%
Time: 16.3s
Precision: binary64
Cost: 103560

?

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

\mathbf{elif}\;t_1 \leq 2:\\
\;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left({\left({\cos x}^{1.5}\right)}^{0.3333333333333333}\right)\right)}{e^{x}}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}

Error?

Derivation?

  1. Split input into 2 regimes
  2. if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 0.0 or 2 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x)))

    1. Initial program 3.4%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Simplified3.4%

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

      [Start]3.4

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

      exp-neg [=>]3.4

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

      associate-*r/ [=>]3.4

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

      *-rgt-identity [=>]3.4

      \[ \frac{\color{blue}{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}}{e^{x}} \]
    3. Applied egg-rr3.4%

      \[\leadsto \color{blue}{e^{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x}} \]
      Proof

      [Start]3.4

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

      add-exp-log [=>]3.4

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

      div-exp [=>]3.4

      \[ \color{blue}{e^{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x}} \]
    4. Taylor expanded in x around inf 62.0%

      \[\leadsto e^{\color{blue}{-1 \cdot x}} \]
    5. Simplified62.0%

      \[\leadsto e^{\color{blue}{-x}} \]
      Proof

      [Start]62.0

      \[ e^{-1 \cdot x} \]

      mul-1-neg [=>]62.0

      \[ e^{\color{blue}{-x}} \]

    if 0.0 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2

    1. Initial program 81.7%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Simplified82.0%

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

      [Start]81.7

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

      exp-neg [=>]81.8

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

      associate-*r/ [=>]82.0

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

      *-rgt-identity [=>]82.0

      \[ \frac{\color{blue}{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}}{e^{x}} \]
    3. Applied egg-rr82.0%

      \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \color{blue}{\left({\left({\cos x}^{1.5}\right)}^{0.3333333333333333}\right)}\right)}{e^{x}} \]
      Proof

      [Start]82.0

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

      add-cbrt-cube [=>]81.8

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

      pow1/3 [=>]82.0

      \[ \frac{\left(\left(e^{x}\right) \bmod \color{blue}{\left({\left(\left(\sqrt{\cos x} \cdot \sqrt{\cos x}\right) \cdot \sqrt{\cos x}\right)}^{0.3333333333333333}\right)}\right)}{e^{x}} \]

      add-sqr-sqrt [<=]82.0

      \[ \frac{\left(\left(e^{x}\right) \bmod \left({\left(\color{blue}{\cos x} \cdot \sqrt{\cos x}\right)}^{0.3333333333333333}\right)\right)}{e^{x}} \]

      pow1 [=>]82.0

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

      pow1/2 [=>]82.0

      \[ \frac{\left(\left(e^{x}\right) \bmod \left({\left({\cos x}^{1} \cdot \color{blue}{{\cos x}^{0.5}}\right)}^{0.3333333333333333}\right)\right)}{e^{x}} \]

      pow-prod-up [=>]82.0

      \[ \frac{\left(\left(e^{x}\right) \bmod \left({\color{blue}{\left({\cos x}^{\left(1 + 0.5\right)}\right)}}^{0.3333333333333333}\right)\right)}{e^{x}} \]

      metadata-eval [=>]82.0

      \[ \frac{\left(\left(e^{x}\right) \bmod \left({\left({\cos x}^{\color{blue}{1.5}}\right)}^{0.3333333333333333}\right)\right)}{e^{x}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification62.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \leq 0:\\ \;\;\;\;e^{-x}\\ \mathbf{elif}\;\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \leq 2:\\ \;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left({\left({\cos x}^{1.5}\right)}^{0.3333333333333333}\right)\right)}{e^{x}}\\ \mathbf{else}:\\ \;\;\;\;e^{-x}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy62.8%
Cost103497
\[\begin{array}{l} t_0 := e^{-x}\\ t_1 := \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot t_0\\ \mathbf{if}\;t_1 \leq 0 \lor \neg \left(t_1 \leq 2\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt[3]{{\cos x}^{1.5}}\right)\right)}{e^{x}}\\ \end{array} \]
Alternative 2
Accuracy62.9%
Cost97033
\[\begin{array}{l} t_0 := \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\ t_1 := e^{-x}\\ t_2 := t_0 \cdot t_1\\ \mathbf{if}\;t_2 \leq 0 \lor \neg \left(t_2 \leq 2\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{e^{x}}\\ \end{array} \]
Alternative 3
Accuracy61.8%
Cost20105
\[\begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{-310} \lor \neg \left(x \leq 0.05\right):\\ \;\;\;\;e^{-x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(1 + \left(x \cdot x\right) \cdot -0.25\right)\right)}{e^{x}}\\ \end{array} \]
Alternative 4
Accuracy60.8%
Cost6528
\[e^{-x} \]

Error

Reproduce?

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