
(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:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
(FPCore (x) :precision binary64 (pow E (- (log (fmod (exp x) (sqrt (cos x)))) x)))
double code(double x) {
return pow(((double) M_E), (log(fmod(exp(x), sqrt(cos(x)))) - x));
}
def code(x): return math.pow(math.e, (math.log(math.fmod(math.exp(x), math.sqrt(math.cos(x)))) - x))
function code(x) return exp(1) ^ Float64(log(rem(exp(x), sqrt(cos(x)))) - x) end
code[x_] := N[Power[E, 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]], $MachinePrecision]
\begin{array}{l}
\\
{e}^{\left(\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x\right)}
\end{array}
Initial program 5.5%
exp-neg5.5%
associate-*r/5.5%
*-rgt-identity5.5%
Simplified5.5%
add-exp-log5.5%
div-exp5.5%
Applied egg-rr5.5%
*-un-lft-identity5.5%
exp-prod5.5%
exp-1-e5.5%
Applied egg-rr5.5%
Final simplification5.5%
(FPCore (x) :precision binary64 (exp (- (log (fmod (exp x) (sqrt (cos x)))) x)))
double code(double x) {
return exp((log(fmod(exp(x), sqrt(cos(x)))) - x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = exp((log(mod(exp(x), sqrt(cos(x)))) - x))
end function
def code(x): return math.exp((math.log(math.fmod(math.exp(x), math.sqrt(math.cos(x)))) - x))
function code(x) return exp(Float64(log(rem(exp(x), sqrt(cos(x)))) - x)) end
code[x_] := 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]], $MachinePrecision]
\begin{array}{l}
\\
e^{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) - x}
\end{array}
Initial program 5.5%
exp-neg5.5%
associate-*r/5.5%
*-rgt-identity5.5%
Simplified5.5%
add-exp-log5.5%
div-exp5.5%
Applied egg-rr5.5%
Final simplification5.5%
(FPCore (x) :precision binary64 (* (fmod (exp x) (sqrt (cos x))) (/ -1.0 (- (exp x)))))
double code(double x) {
return fmod(exp(x), sqrt(cos(x))) * (-1.0 / -exp(x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = mod(exp(x), sqrt(cos(x))) * ((-1.0d0) / -exp(x))
end function
def code(x): return math.fmod(math.exp(x), math.sqrt(math.cos(x))) * (-1.0 / -math.exp(x))
function code(x) return Float64(rem(exp(x), sqrt(cos(x))) * Float64(-1.0 / Float64(-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[(-1.0 / (-N[Exp[x], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{-1}{-e^{x}}
\end{array}
Initial program 5.5%
exp-neg5.5%
associate-*r/5.5%
*-rgt-identity5.5%
Simplified5.5%
frac-2neg5.5%
div-inv5.5%
Applied egg-rr5.5%
Final simplification5.5%
(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}
Initial program 5.5%
exp-neg5.5%
associate-*r/5.5%
*-rgt-identity5.5%
Simplified5.5%
Final simplification5.5%
(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}
Initial program 5.5%
exp-neg5.5%
associate-*r/5.5%
*-rgt-identity5.5%
Simplified5.5%
Taylor expanded in x around 0 5.3%
*-commutative5.3%
unpow25.3%
Simplified5.3%
Final simplification5.3%
(FPCore (x) :precision binary64 (* (fmod (exp x) 1.0) (/ (- -1.0) (exp x))))
double code(double x) {
return fmod(exp(x), 1.0) * (-(-1.0) / exp(x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = mod(exp(x), 1.0d0) * (-(-1.0d0) / exp(x))
end function
def code(x): return math.fmod(math.exp(x), 1.0) * (-(-1.0) / math.exp(x))
function code(x) return Float64(rem(exp(x), 1.0) * Float64(Float64(-(-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[((--1.0) / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(e^{x}\right) \bmod 1\right) \cdot \frac{--1}{e^{x}}
\end{array}
Initial program 5.5%
exp-neg5.5%
associate-*r/5.5%
*-rgt-identity5.5%
Simplified5.5%
frac-2neg5.5%
div-inv5.5%
Applied egg-rr5.5%
Taylor expanded in x around 0 5.1%
Taylor expanded in x around inf 5.1%
Final simplification5.1%
(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}
Initial program 5.5%
exp-neg5.5%
associate-*r/5.5%
*-rgt-identity5.5%
Simplified5.5%
Taylor expanded in x around 0 5.1%
Final simplification5.1%
(FPCore (x) :precision binary64 (* (- (fmod (exp x) 1.0)) (+ x (+ -1.0 (* (* x x) -0.5)))))
double code(double x) {
return -fmod(exp(x), 1.0) * (x + (-1.0 + ((x * x) * -0.5)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = -mod(exp(x), 1.0d0) * (x + ((-1.0d0) + ((x * x) * (-0.5d0))))
end function
def code(x): return -math.fmod(math.exp(x), 1.0) * (x + (-1.0 + ((x * x) * -0.5)))
function code(x) return Float64(Float64(-rem(exp(x), 1.0)) * Float64(x + Float64(-1.0 + Float64(Float64(x * x) * -0.5)))) end
code[x_] := N[((-N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]) * N[(x + N[(-1.0 + N[(N[(x * x), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-\left(\left(e^{x}\right) \bmod 1\right)\right) \cdot \left(x + \left(-1 + \left(x \cdot x\right) \cdot -0.5\right)\right)
\end{array}
Initial program 5.5%
exp-neg5.5%
associate-*r/5.5%
*-rgt-identity5.5%
Simplified5.5%
frac-2neg5.5%
div-inv5.5%
Applied egg-rr5.5%
Taylor expanded in x around 0 5.1%
Taylor expanded in x around 0 5.0%
associate--l+5.0%
*-commutative5.0%
unpow25.0%
Simplified5.0%
Final simplification5.0%
(FPCore (x) :precision binary64 (/ (* (fmod (exp x) 1.0) (+ 1.0 (* x x))) (+ x 1.0)))
double code(double x) {
return (fmod(exp(x), 1.0) * (1.0 + (x * x))) / (x + 1.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (mod(exp(x), 1.0d0) * (1.0d0 + (x * x))) / (x + 1.0d0)
end function
def code(x): return (math.fmod(math.exp(x), 1.0) * (1.0 + (x * x))) / (x + 1.0)
function code(x) return Float64(Float64(rem(exp(x), 1.0) * Float64(1.0 + Float64(x * x))) / Float64(x + 1.0)) end
code[x_] := N[(N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(1.0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(\left(e^{x}\right) \bmod 1\right) \cdot \left(1 + x \cdot x\right)}{x + 1}
\end{array}
Initial program 5.5%
exp-neg5.5%
associate-*r/5.5%
*-rgt-identity5.5%
Simplified5.5%
Taylor expanded in x around 0 5.1%
div-inv5.1%
rec-exp5.1%
Applied egg-rr5.1%
Taylor expanded in x around 0 4.9%
+-commutative4.9%
*-lft-identity4.9%
associate-*r*4.9%
neg-mul-14.9%
distribute-rgt-out4.9%
unsub-neg4.9%
Simplified4.9%
flip--4.9%
associate-*r/4.9%
metadata-eval4.9%
sub-neg4.9%
add-sqr-sqrt2.6%
sqrt-prod4.9%
sqr-neg4.9%
sqrt-unprod2.3%
add-sqr-sqrt4.9%
distribute-lft-neg-out4.9%
sqr-neg4.9%
+-commutative4.9%
Applied egg-rr4.9%
Final simplification4.9%
(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}
Initial program 5.5%
exp-neg5.5%
associate-*r/5.5%
*-rgt-identity5.5%
Simplified5.5%
Taylor expanded in x around 0 5.1%
div-inv5.1%
rec-exp5.1%
Applied egg-rr5.1%
Taylor expanded in x around 0 4.9%
+-commutative4.9%
*-lft-identity4.9%
associate-*r*4.9%
neg-mul-14.9%
distribute-rgt-out4.9%
unsub-neg4.9%
Simplified4.9%
Final simplification4.9%
(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}
Initial program 5.5%
exp-neg5.5%
associate-*r/5.5%
*-rgt-identity5.5%
Simplified5.5%
Taylor expanded in x around 0 5.1%
Taylor expanded in x around 0 4.7%
Final simplification4.7%
herbie shell --seed 2023278
(FPCore (x)
:name "expfmod (used to be hard to sample)"
:precision binary64
(* (fmod (exp x) (sqrt (cos x))) (exp (- x))))