
(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 10 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 (/ 1.0 (exp (- x (cbrt (pow (log (fmod (exp x) (sqrt (cos x)))) 3.0))))))
double code(double x) {
return 1.0 / exp((x - cbrt(pow(log(fmod(exp(x), sqrt(cos(x)))), 3.0))));
}
function code(x) return Float64(1.0 / exp(Float64(x - cbrt((log(rem(exp(x), sqrt(cos(x)))) ^ 3.0))))) end
code[x_] := N[(1.0 / N[Exp[N[(x - N[Power[N[Power[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], 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{e^{x - \sqrt[3]{{\log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}^{3}}}}
\end{array}
Initial program 6.3%
exp-neg6.3%
div-inv6.3%
clear-num6.3%
Applied egg-rr6.3%
add-exp-log6.3%
div-exp6.4%
Applied egg-rr6.4%
add-cbrt-cube6.4%
pow36.4%
Applied egg-rr6.4%
Final simplification6.4%
(FPCore (x) :precision binary64 (/ 1.0 (exp (- x (log (fmod (exp x) (sqrt (cos x))))))))
double code(double x) {
return 1.0 / exp((x - log(fmod(exp(x), sqrt(cos(x))))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / exp((x - log(mod(exp(x), sqrt(cos(x))))))
end function
def code(x): return 1.0 / math.exp((x - math.log(math.fmod(math.exp(x), math.sqrt(math.cos(x))))))
function code(x) return Float64(1.0 / exp(Float64(x - log(rem(exp(x), sqrt(cos(x))))))) end
code[x_] := N[(1.0 / N[Exp[N[(x - 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]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{e^{x - \log \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}}
\end{array}
Initial program 6.3%
exp-neg6.3%
div-inv6.3%
clear-num6.3%
Applied egg-rr6.3%
add-exp-log6.3%
div-exp6.4%
Applied egg-rr6.4%
Final simplification6.4%
(FPCore (x) :precision binary64 (/ 1.0 (/ (exp x) (fmod (exp x) (sqrt (cos x))))))
double code(double x) {
return 1.0 / (exp(x) / fmod(exp(x), sqrt(cos(x))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / (exp(x) / mod(exp(x), sqrt(cos(x))))
end function
def code(x): return 1.0 / (math.exp(x) / math.fmod(math.exp(x), math.sqrt(math.cos(x))))
function code(x) return Float64(1.0 / Float64(exp(x) / rem(exp(x), sqrt(cos(x))))) end
code[x_] := N[(1.0 / N[(N[Exp[x], $MachinePrecision] / N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{e^{x}}{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}}
\end{array}
Initial program 6.3%
exp-neg6.3%
div-inv6.3%
clear-num6.3%
Applied egg-rr6.3%
Final simplification6.3%
(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 6.3%
exp-neg6.3%
associate-*r/6.3%
*-rgt-identity6.3%
Simplified6.3%
Final simplification6.3%
(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.3%
exp-neg6.3%
associate-*r/6.3%
*-rgt-identity6.3%
Simplified6.3%
Taylor expanded in x around 0 5.9%
*-commutative5.4%
unpow25.4%
Simplified5.9%
Final simplification5.9%
(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.3%
exp-neg6.3%
associate-*r/6.3%
*-rgt-identity6.3%
Simplified6.3%
Taylor expanded in x around 0 5.6%
Final simplification5.6%
(FPCore (x) :precision binary64 (* (fmod (exp x) 1.0) (/ (- 1.0 (* x x)) (+ 1.0 x))))
double code(double x) {
return fmod(exp(x), 1.0) * ((1.0 - (x * x)) / (1.0 + x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = mod(exp(x), 1.0d0) * ((1.0d0 - (x * x)) / (1.0d0 + x))
end function
def code(x): return math.fmod(math.exp(x), 1.0) * ((1.0 - (x * x)) / (1.0 + x))
function code(x) return Float64(rem(exp(x), 1.0) * Float64(Float64(1.0 - Float64(x * x)) / 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[(N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(e^{x}\right) \bmod 1\right) \cdot \frac{1 - x \cdot x}{1 + x}
\end{array}
Initial program 6.3%
Taylor expanded in x around 0 5.4%
mul-1-neg5.4%
unsub-neg5.4%
*-rgt-identity5.4%
distribute-lft-out--5.4%
Simplified5.4%
Taylor expanded in x around 0 5.3%
flip--5.3%
associate-*r/5.3%
metadata-eval5.3%
+-commutative5.3%
Applied egg-rr5.3%
*-commutative5.3%
associate-/l*5.3%
associate-/r/5.3%
Simplified5.3%
Final simplification5.3%
(FPCore (x) :precision binary64 (* (fmod (exp x) (+ 1.0 (* (* x x) -0.25))) (- 1.0 x)))
double code(double x) {
return fmod(exp(x), (1.0 + ((x * x) * -0.25))) * (1.0 - x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = mod(exp(x), (1.0d0 + ((x * x) * (-0.25d0)))) * (1.0d0 - x)
end function
def code(x): return math.fmod(math.exp(x), (1.0 + ((x * x) * -0.25))) * (1.0 - x)
function code(x) return Float64(rem(exp(x), Float64(1.0 + Float64(Float64(x * x) * -0.25))) * Float64(1.0 - 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[(1.0 - x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(e^{x}\right) \bmod \left(1 + \left(x \cdot x\right) \cdot -0.25\right)\right) \cdot \left(1 - x\right)
\end{array}
Initial program 6.3%
Taylor expanded in x around 0 5.4%
mul-1-neg5.4%
unsub-neg5.4%
*-rgt-identity5.4%
distribute-lft-out--5.4%
Simplified5.4%
Taylor expanded in x around 0 5.4%
*-commutative5.4%
unpow25.4%
Simplified5.4%
Final simplification5.4%
(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 6.3%
Taylor expanded in x around 0 5.4%
mul-1-neg5.4%
unsub-neg5.4%
*-rgt-identity5.4%
distribute-lft-out--5.4%
Simplified5.4%
Taylor expanded in x around 0 5.3%
Final simplification5.3%
(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.3%
exp-neg6.3%
associate-*r/6.3%
*-rgt-identity6.3%
Simplified6.3%
Taylor expanded in x around 0 5.6%
Taylor expanded in x around 0 4.8%
Final simplification4.8%
herbie shell --seed 2023224
(FPCore (x)
:name "expfmod (used to be hard to sample)"
:precision binary64
(* (fmod (exp x) (sqrt (cos x))) (exp (- x))))