
(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
(let* ((t_0 (expm1 (- (log (fmod (exp x) (sqrt (cos x)))) x))))
(/
(/
(pow (cbrt (- -1.0 (pow t_0 9.0))) 3.0)
(+ -1.0 (- (pow t_0 3.0) (pow t_0 6.0))))
(fma t_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(cbrt((-1.0 - pow(t_0, 9.0))), 3.0) / (-1.0 + (pow(t_0, 3.0) - pow(t_0, 6.0)))) / fma(t_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((cbrt(Float64(-1.0 - (t_0 ^ 9.0))) ^ 3.0) / Float64(-1.0 + Float64((t_0 ^ 3.0) - (t_0 ^ 6.0)))) / fma(t_0, Float64(-1.0 + 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[N[Power[N[(-1.0 - N[Power[t$95$0, 9.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision] / N[(-1.0 + N[(N[Power[t$95$0, 3.0], $MachinePrecision] - N[Power[t$95$0, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * N[(-1.0 + t$95$0), $MachinePrecision] + 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{\frac{{\left(\sqrt[3]{-1 - {t_0}^{9}}\right)}^{3}}{-1 + \left({t_0}^{3} - {t_0}^{6}\right)}}{\mathsf{fma}\left(t_0, -1 + t_0, 1\right)}
\end{array}
\end{array}
Initial program 6.1%
exp-neg6.1%
associate-*r/6.1%
*-rgt-identity6.1%
Simplified6.1%
expm1-log1p-u6.1%
expm1-udef6.1%
log1p-udef6.1%
add-exp-log6.1%
Applied egg-rr6.1%
associate--l+6.1%
Simplified6.1%
flip3-+6.2%
metadata-eval6.2%
add-exp-log6.2%
expm1-def6.2%
log-div6.2%
add-log-exp6.2%
Applied egg-rr6.2%
flip3-+6.2%
frac-2neg6.2%
metadata-eval6.2%
pow-pow6.2%
metadata-eval6.2%
Applied egg-rr6.2%
distribute-neg-in6.2%
metadata-eval6.2%
unsub-neg6.2%
distribute-neg-in6.2%
metadata-eval6.2%
unsub-neg6.2%
Simplified6.2%
add-cube-cbrt6.2%
pow36.2%
Applied egg-rr6.2%
Final simplification6.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (expm1 (- (log (fmod (exp x) (sqrt (cos x)))) x))))
(/
(/ (- -1.0 (pow t_0 9.0)) (+ -1.0 (- (pow t_0 3.0) (pow t_0 6.0))))
(fma t_0 (+ -1.0 t_0) 1.0))))
double code(double x) {
double t_0 = expm1((log(fmod(exp(x), sqrt(cos(x)))) - x));
return ((-1.0 - pow(t_0, 9.0)) / (-1.0 + (pow(t_0, 3.0) - pow(t_0, 6.0)))) / fma(t_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(Float64(-1.0 - (t_0 ^ 9.0)) / Float64(-1.0 + Float64((t_0 ^ 3.0) - (t_0 ^ 6.0)))) / fma(t_0, Float64(-1.0 + 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[(-1.0 - N[Power[t$95$0, 9.0], $MachinePrecision]), $MachinePrecision] / N[(-1.0 + N[(N[Power[t$95$0, 3.0], $MachinePrecision] - N[Power[t$95$0, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * N[(-1.0 + t$95$0), $MachinePrecision] + 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{\frac{-1 - {t_0}^{9}}{-1 + \left({t_0}^{3} - {t_0}^{6}\right)}}{\mathsf{fma}\left(t_0, -1 + t_0, 1\right)}
\end{array}
\end{array}
Initial program 6.1%
exp-neg6.1%
associate-*r/6.1%
*-rgt-identity6.1%
Simplified6.1%
expm1-log1p-u6.1%
expm1-udef6.1%
log1p-udef6.1%
add-exp-log6.1%
Applied egg-rr6.1%
associate--l+6.1%
Simplified6.1%
flip3-+6.2%
metadata-eval6.2%
add-exp-log6.2%
expm1-def6.2%
log-div6.2%
add-log-exp6.2%
Applied egg-rr6.2%
flip3-+6.2%
frac-2neg6.2%
metadata-eval6.2%
pow-pow6.2%
metadata-eval6.2%
Applied egg-rr6.2%
distribute-neg-in6.2%
metadata-eval6.2%
unsub-neg6.2%
distribute-neg-in6.2%
metadata-eval6.2%
unsub-neg6.2%
Simplified6.2%
Final simplification6.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (expm1 (- (log (fmod (exp x) (sqrt (cos x)))) x))))
(/
(pow (+ -1.0 (exp (log1p (cbrt (+ (pow t_0 3.0) 1.0))))) 3.0)
(fma t_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((-1.0 + exp(log1p(cbrt((pow(t_0, 3.0) + 1.0))))), 3.0) / fma(t_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(-1.0 + exp(log1p(cbrt(Float64((t_0 ^ 3.0) + 1.0))))) ^ 3.0) / fma(t_0, Float64(-1.0 + 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[Power[N[(-1.0 + N[Exp[N[Log[1 + N[Power[N[(N[Power[t$95$0, 3.0], $MachinePrecision] + 1.0), $MachinePrecision], 1/3], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision] / N[(t$95$0 * N[(-1.0 + t$95$0), $MachinePrecision] + 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{{\left(-1 + e^{\mathsf{log1p}\left(\sqrt[3]{{t_0}^{3} + 1}\right)}\right)}^{3}}{\mathsf{fma}\left(t_0, -1 + t_0, 1\right)}
\end{array}
\end{array}
Initial program 6.1%
exp-neg6.1%
associate-*r/6.1%
*-rgt-identity6.1%
Simplified6.1%
expm1-log1p-u6.1%
expm1-udef6.1%
log1p-udef6.1%
add-exp-log6.1%
Applied egg-rr6.1%
associate--l+6.1%
Simplified6.1%
flip3-+6.2%
metadata-eval6.2%
add-exp-log6.2%
expm1-def6.2%
log-div6.2%
add-log-exp6.2%
Applied egg-rr6.2%
add-cube-cbrt6.2%
pow36.2%
Applied egg-rr6.2%
expm1-log1p-u6.2%
expm1-udef6.2%
+-commutative6.2%
Applied egg-rr6.2%
Final simplification6.2%
(FPCore (x) :precision binary64 (let* ((t_0 (expm1 (- (log (fmod (exp x) (sqrt (cos x)))) x)))) (/ (pow (cbrt (+ (pow t_0 3.0) 1.0)) 3.0) (fma t_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(cbrt((pow(t_0, 3.0) + 1.0)), 3.0) / fma(t_0, (-1.0 + t_0), 1.0);
}
function code(x) t_0 = expm1(Float64(log(rem(exp(x), sqrt(cos(x)))) - x)) return Float64((cbrt(Float64((t_0 ^ 3.0) + 1.0)) ^ 3.0) / fma(t_0, Float64(-1.0 + 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[Power[N[Power[N[(N[Power[t$95$0, 3.0], $MachinePrecision] + 1.0), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision] / N[(t$95$0 * N[(-1.0 + t$95$0), $MachinePrecision] + 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{{\left(\sqrt[3]{{t_0}^{3} + 1}\right)}^{3}}{\mathsf{fma}\left(t_0, -1 + t_0, 1\right)}
\end{array}
\end{array}
Initial program 6.1%
exp-neg6.1%
associate-*r/6.1%
*-rgt-identity6.1%
Simplified6.1%
expm1-log1p-u6.1%
expm1-udef6.1%
log1p-udef6.1%
add-exp-log6.1%
Applied egg-rr6.1%
associate--l+6.1%
Simplified6.1%
flip3-+6.2%
metadata-eval6.2%
add-exp-log6.2%
expm1-def6.2%
log-div6.2%
add-log-exp6.2%
Applied egg-rr6.2%
add-cube-cbrt6.2%
pow36.2%
Applied egg-rr6.2%
Final simplification6.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (expm1 (- (log (fmod (exp x) (sqrt (cos x)))) x))))
(/
(+ (pow t_0 3.0) 1.0)
(fma
(expm1 (- (log (fmod (exp x) (+ 1.0 (* (* x x) -0.25)))) x))
(+ -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, 3.0) + 1.0) / fma(expm1((log(fmod(exp(x), (1.0 + ((x * x) * -0.25)))) - x)), (-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 ^ 3.0) + 1.0) / fma(expm1(Float64(log(rem(exp(x), Float64(1.0 + Float64(Float64(x * x) * -0.25)))) - x)), Float64(-1.0 + 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, 3.0], $MachinePrecision] + 1.0), $MachinePrecision] / N[(N[(Exp[N[(N[Log[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]], $MachinePrecision] - x), $MachinePrecision]] - 1), $MachinePrecision] * N[(-1.0 + t$95$0), $MachinePrecision] + 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}^{3} + 1}{\mathsf{fma}\left(\mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(1 + \left(x \cdot x\right) \cdot -0.25\right)\right) - x\right), -1 + t_0, 1\right)}
\end{array}
\end{array}
Initial program 6.1%
exp-neg6.1%
associate-*r/6.1%
*-rgt-identity6.1%
Simplified6.1%
expm1-log1p-u6.1%
expm1-udef6.1%
log1p-udef6.1%
add-exp-log6.1%
Applied egg-rr6.1%
associate--l+6.1%
Simplified6.1%
flip3-+6.2%
metadata-eval6.2%
add-exp-log6.2%
expm1-def6.2%
log-div6.2%
add-log-exp6.2%
Applied egg-rr6.2%
Taylor expanded in x around 0 6.2%
*-commutative6.1%
unpow26.1%
Simplified6.2%
Final simplification6.2%
(FPCore (x) :precision binary64 (let* ((t_0 (expm1 (- (log (fmod (exp x) (fma x (* x -0.25) 1.0))) x)))) (/ (- 1.0 (pow t_0 2.0)) (- 1.0 t_0))))
double code(double x) {
double t_0 = expm1((log(fmod(exp(x), fma(x, (x * -0.25), 1.0))) - x));
return (1.0 - pow(t_0, 2.0)) / (1.0 - t_0);
}
function code(x) t_0 = expm1(Float64(log(rem(exp(x), fma(x, Float64(x * -0.25), 1.0))) - x)) return Float64(Float64(1.0 - (t_0 ^ 2.0)) / Float64(1.0 - t_0)) end
code[x_] := Block[{t$95$0 = N[(Exp[N[(N[Log[N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(x * N[(x * -0.25), $MachinePrecision] + 1.0), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]], $MachinePrecision] - x), $MachinePrecision]] - 1), $MachinePrecision]}, N[(N[(1.0 - N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision] / N[(1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{expm1}\left(\log \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(x, x \cdot -0.25, 1\right)\right)\right) - x\right)\\
\frac{1 - {t_0}^{2}}{1 - t_0}
\end{array}
\end{array}
Initial program 6.1%
exp-neg6.1%
associate-*r/6.1%
*-rgt-identity6.1%
Simplified6.1%
expm1-log1p-u6.1%
expm1-udef6.1%
log1p-udef6.1%
add-exp-log6.1%
Applied egg-rr6.1%
associate--l+6.1%
Simplified6.1%
Taylor expanded in x around 0 6.1%
*-commutative6.1%
unpow26.1%
Simplified6.1%
flip-+6.1%
metadata-eval6.1%
div-sub6.1%
Applied egg-rr6.2%
div-sub6.2%
Simplified6.2%
Final simplification6.2%
(FPCore (x) :precision binary64 (+ 1.0 (+ -1.0 (/ (fmod (exp x) (+ 1.0 (* (* x x) -0.25))) (exp x)))))
double code(double x) {
return 1.0 + (-1.0 + (fmod(exp(x), (1.0 + ((x * x) * -0.25))) / exp(x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 + ((-1.0d0) + (mod(exp(x), (1.0d0 + ((x * x) * (-0.25d0)))) / exp(x)))
end function
def code(x): return 1.0 + (-1.0 + (math.fmod(math.exp(x), (1.0 + ((x * x) * -0.25))) / math.exp(x)))
function code(x) return Float64(1.0 + Float64(-1.0 + Float64(rem(exp(x), Float64(1.0 + Float64(Float64(x * x) * -0.25))) / exp(x)))) end
code[x_] := N[(1.0 + N[(-1.0 + 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]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(-1 + \frac{\left(\left(e^{x}\right) \bmod \left(1 + \left(x \cdot x\right) \cdot -0.25\right)\right)}{e^{x}}\right)
\end{array}
Initial program 6.1%
exp-neg6.1%
associate-*r/6.1%
*-rgt-identity6.1%
Simplified6.1%
expm1-log1p-u6.1%
expm1-udef6.1%
log1p-udef6.1%
add-exp-log6.1%
Applied egg-rr6.1%
associate--l+6.1%
Simplified6.1%
Taylor expanded in x around 0 6.1%
*-commutative6.1%
unpow26.1%
Simplified6.1%
Final simplification6.1%
(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 6.1%
exp-neg6.1%
associate-*r/6.1%
*-rgt-identity6.1%
Simplified6.1%
Taylor expanded in x around 0 6.1%
*-commutative6.1%
unpow26.1%
Simplified6.1%
Final simplification6.1%
(FPCore (x) :precision binary64 (+ 1.0 (+ -1.0 (/ (fmod (exp x) 1.0) (exp x)))))
double code(double x) {
return 1.0 + (-1.0 + (fmod(exp(x), 1.0) / exp(x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 + ((-1.0d0) + (mod(exp(x), 1.0d0) / exp(x)))
end function
def code(x): return 1.0 + (-1.0 + (math.fmod(math.exp(x), 1.0) / math.exp(x)))
function code(x) return Float64(1.0 + Float64(-1.0 + Float64(rem(exp(x), 1.0) / exp(x)))) end
code[x_] := N[(1.0 + N[(-1.0 + N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(-1 + \frac{\left(\left(e^{x}\right) \bmod 1\right)}{e^{x}}\right)
\end{array}
Initial program 6.1%
exp-neg6.1%
associate-*r/6.1%
*-rgt-identity6.1%
Simplified6.1%
expm1-log1p-u6.1%
expm1-udef6.1%
log1p-udef6.1%
add-exp-log6.1%
Applied egg-rr6.1%
associate--l+6.1%
Simplified6.1%
Taylor expanded in x around 0 5.8%
Final simplification5.8%
(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 6.1%
exp-neg6.1%
associate-*r/6.1%
*-rgt-identity6.1%
Simplified6.1%
Taylor expanded in x around 0 5.8%
Final simplification5.8%
(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 6.1%
exp-neg6.1%
associate-*r/6.1%
*-rgt-identity6.1%
Simplified6.1%
Taylor expanded in x around 0 5.8%
Taylor expanded in x around 0 4.7%
Final simplification4.7%
herbie shell --seed 2023230
(FPCore (x)
:name "expfmod (used to be hard to sample)"
:precision binary64
(* (fmod (exp x) (sqrt (cos x))) (exp (- x))))