
(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 9 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 (exp (- x))))
(if (<= x -1e-154)
(*
(fmod
(exp x)
(*
(* x x)
(+
(sqrt 0.041666666666666664)
(/ -0.25 (* (* x x) (sqrt 0.041666666666666664))))))
t_0)
(if (<= x -2e-310)
(*
t_0
(fmod
(exp x)
(* x (* x (* x (* x (+ -0.010416666666666666 (/ -0.25 (* x x)))))))))
(fmod (+ x 1.0) 1.0)))))
double code(double x) {
double t_0 = exp(-x);
double tmp;
if (x <= -1e-154) {
tmp = fmod(exp(x), ((x * x) * (sqrt(0.041666666666666664) + (-0.25 / ((x * x) * sqrt(0.041666666666666664)))))) * t_0;
} else if (x <= -2e-310) {
tmp = t_0 * fmod(exp(x), (x * (x * (x * (x * (-0.010416666666666666 + (-0.25 / (x * x))))))));
} else {
tmp = fmod((x + 1.0), 1.0);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = exp(-x)
if (x <= (-1d-154)) then
tmp = mod(exp(x), ((x * x) * (sqrt(0.041666666666666664d0) + ((-0.25d0) / ((x * x) * sqrt(0.041666666666666664d0)))))) * t_0
else if (x <= (-2d-310)) then
tmp = t_0 * mod(exp(x), (x * (x * (x * (x * ((-0.010416666666666666d0) + ((-0.25d0) / (x * x))))))))
else
tmp = mod((x + 1.0d0), 1.0d0)
end if
code = tmp
end function
def code(x): t_0 = math.exp(-x) tmp = 0 if x <= -1e-154: tmp = math.fmod(math.exp(x), ((x * x) * (math.sqrt(0.041666666666666664) + (-0.25 / ((x * x) * math.sqrt(0.041666666666666664)))))) * t_0 elif x <= -2e-310: tmp = t_0 * math.fmod(math.exp(x), (x * (x * (x * (x * (-0.010416666666666666 + (-0.25 / (x * x)))))))) else: tmp = math.fmod((x + 1.0), 1.0) return tmp
function code(x) t_0 = exp(Float64(-x)) tmp = 0.0 if (x <= -1e-154) tmp = Float64(rem(exp(x), Float64(Float64(x * x) * Float64(sqrt(0.041666666666666664) + Float64(-0.25 / Float64(Float64(x * x) * sqrt(0.041666666666666664)))))) * t_0); elseif (x <= -2e-310) tmp = Float64(t_0 * rem(exp(x), Float64(x * Float64(x * Float64(x * Float64(x * Float64(-0.010416666666666666 + Float64(-0.25 / Float64(x * x))))))))); else tmp = rem(Float64(x + 1.0), 1.0); end return tmp end
code[x_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, -1e-154], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(N[(x * x), $MachinePrecision] * N[(N[Sqrt[0.041666666666666664], $MachinePrecision] + N[(-0.25 / N[(N[(x * x), $MachinePrecision] * N[Sqrt[0.041666666666666664], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[x, -2e-310], N[(t$95$0 * N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(x * N[(x * N[(x * N[(x * N[(-0.010416666666666666 + N[(-0.25 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]), $MachinePrecision], N[With[{TMP1 = N[(x + 1.0), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq -1 \cdot 10^{-154}:\\
\;\;\;\;\left(\left(e^{x}\right) \bmod \left(\left(x \cdot x\right) \cdot \left(\sqrt{0.041666666666666664} + \frac{-0.25}{\left(x \cdot x\right) \cdot \sqrt{0.041666666666666664}}\right)\right)\right) \cdot t\_0\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-310}:\\
\;\;\;\;t\_0 \cdot \left(\left(e^{x}\right) \bmod \left(x \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(-0.010416666666666666 + \frac{-0.25}{x \cdot x}\right)\right)\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(x + 1\right) \bmod 1\right)\\
\end{array}
\end{array}
if x < -9.9999999999999997e-155Initial program 14.2%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f6414.2
Applied rewrites14.2%
Taylor expanded in x around inf
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
sub-negN/A
associate-*r/N/A
metadata-evalN/A
lower-+.f64N/A
lower-sqrt.f64N/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sqrt.f6499.9
Applied rewrites99.9%
if -9.9999999999999997e-155 < x < -1.999999999999994e-310Initial program 3.1%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f643.1
Applied rewrites3.1%
Taylor expanded in x around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
metadata-evalN/A
pow-sqrN/A
unpow2N/A
associate-*l*N/A
unpow2N/A
cube-multN/A
lower-*.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
distribute-neg-inN/A
metadata-evalN/A
lower-+.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f64N/A
unpow2N/A
lower-*.f640.0
Applied rewrites0.0%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64100.0
Applied rewrites100.0%
if -1.999999999999994e-310 < x Initial program 6.1%
Taylor expanded in x around 0
Applied rewrites5.6%
Taylor expanded in x around 0
lower-fmod.f64N/A
lower-exp.f645.5
Applied rewrites5.5%
Taylor expanded in x around 0
lower-+.f6439.4
Applied rewrites39.4%
Final simplification62.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (exp (- x))) (t_1 (* t_0 (fmod (exp x) (sqrt (cos x))))))
(if (<= t_1 0.0)
(*
t_0
(fmod
(exp x)
(* x (* x (* x (* x (+ -0.010416666666666666 (/ -0.25 (* x x)))))))))
(if (<= t_1 2.0)
(*
t_0
(fmod
(exp x)
(sqrt
(fma
(* x x)
(fma
(* x x)
(fma x (* x -0.001388888888888889) 0.041666666666666664)
-0.5)
1.0))))
(fmod 1.0 1.0)))))
double code(double x) {
double t_0 = exp(-x);
double t_1 = t_0 * fmod(exp(x), sqrt(cos(x)));
double tmp;
if (t_1 <= 0.0) {
tmp = t_0 * fmod(exp(x), (x * (x * (x * (x * (-0.010416666666666666 + (-0.25 / (x * x))))))));
} else if (t_1 <= 2.0) {
tmp = t_0 * fmod(exp(x), sqrt(fma((x * x), fma((x * x), fma(x, (x * -0.001388888888888889), 0.041666666666666664), -0.5), 1.0)));
} else {
tmp = fmod(1.0, 1.0);
}
return tmp;
}
function code(x) t_0 = exp(Float64(-x)) t_1 = Float64(t_0 * rem(exp(x), sqrt(cos(x)))) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(t_0 * rem(exp(x), Float64(x * Float64(x * Float64(x * Float64(x * Float64(-0.010416666666666666 + Float64(-0.25 / Float64(x * x))))))))); elseif (t_1 <= 2.0) tmp = Float64(t_0 * rem(exp(x), sqrt(fma(Float64(x * x), fma(Float64(x * x), fma(x, Float64(x * -0.001388888888888889), 0.041666666666666664), -0.5), 1.0)))); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, Block[{t$95$1 = N[(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]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(t$95$0 * N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(x * N[(x * N[(x * N[(x * N[(-0.010416666666666666 + N[(-0.25 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2.0], N[(t$95$0 * N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(x * N[(x * -0.001388888888888889), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] + -0.5), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]), $MachinePrecision], N[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-x}\\
t_1 := t\_0 \cdot \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;t\_0 \cdot \left(\left(e^{x}\right) \bmod \left(x \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(-0.010416666666666666 + \frac{-0.25}{x \cdot x}\right)\right)\right)\right)\right)\right)\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;t\_0 \cdot \left(\left(e^{x}\right) \bmod \left(\sqrt{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot -0.001388888888888889, 0.041666666666666664\right), -0.5\right), 1\right)}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 0.0Initial program 4.3%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f644.3
Applied rewrites4.3%
Taylor expanded in x around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
metadata-evalN/A
pow-sqrN/A
unpow2N/A
associate-*l*N/A
unpow2N/A
cube-multN/A
lower-*.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
distribute-neg-inN/A
metadata-evalN/A
lower-+.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f64N/A
unpow2N/A
lower-*.f641.3
Applied rewrites1.3%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6428.4
Applied rewrites28.4%
if 0.0 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2Initial program 79.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6477.0
Applied rewrites77.0%
if 2 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 0.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
lower-fmod.f64100.0
Applied rewrites100.0%
Final simplification45.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (exp (- x))) (t_1 (* t_0 (fmod (exp x) (sqrt (cos x))))))
(if (<= t_1 0.0)
(*
t_0
(fmod
(exp x)
(* x (* x (* x (* x (+ -0.010416666666666666 (/ -0.25 (* x x)))))))))
(if (<= t_1 2.0)
(/
(fmod
(exp x)
(fma
x
(*
x
(fma
(* x x)
(fma (* x x) -0.003298611111111111 -0.010416666666666666)
-0.25))
1.0))
(exp x))
(fmod 1.0 1.0)))))
double code(double x) {
double t_0 = exp(-x);
double t_1 = t_0 * fmod(exp(x), sqrt(cos(x)));
double tmp;
if (t_1 <= 0.0) {
tmp = t_0 * fmod(exp(x), (x * (x * (x * (x * (-0.010416666666666666 + (-0.25 / (x * x))))))));
} else if (t_1 <= 2.0) {
tmp = fmod(exp(x), fma(x, (x * fma((x * x), fma((x * x), -0.003298611111111111, -0.010416666666666666), -0.25)), 1.0)) / exp(x);
} else {
tmp = fmod(1.0, 1.0);
}
return tmp;
}
function code(x) t_0 = exp(Float64(-x)) t_1 = Float64(t_0 * rem(exp(x), sqrt(cos(x)))) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(t_0 * rem(exp(x), Float64(x * Float64(x * Float64(x * Float64(x * Float64(-0.010416666666666666 + Float64(-0.25 / Float64(x * x))))))))); elseif (t_1 <= 2.0) tmp = Float64(rem(exp(x), fma(x, Float64(x * fma(Float64(x * x), fma(Float64(x * x), -0.003298611111111111, -0.010416666666666666), -0.25)), 1.0)) / exp(x)); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, Block[{t$95$1 = N[(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]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(t$95$0 * N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(x * N[(x * N[(x * N[(x * N[(-0.010416666666666666 + N[(-0.25 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2.0], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(x * N[(x * N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * -0.003298611111111111 + -0.010416666666666666), $MachinePrecision] + -0.25), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-x}\\
t_1 := t\_0 \cdot \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;t\_0 \cdot \left(\left(e^{x}\right) \bmod \left(x \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(-0.010416666666666666 + \frac{-0.25}{x \cdot x}\right)\right)\right)\right)\right)\right)\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, -0.003298611111111111, -0.010416666666666666\right), -0.25\right), 1\right)\right)\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 0.0Initial program 4.3%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f644.3
Applied rewrites4.3%
Taylor expanded in x around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
metadata-evalN/A
pow-sqrN/A
unpow2N/A
associate-*l*N/A
unpow2N/A
cube-multN/A
lower-*.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
distribute-neg-inN/A
metadata-evalN/A
lower-+.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f64N/A
unpow2N/A
lower-*.f641.3
Applied rewrites1.3%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6428.4
Applied rewrites28.4%
if 0.0 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2Initial program 79.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
sub-negN/A
unpow2N/A
associate-*l*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.4
Applied rewrites76.4%
lift-exp.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-fma.f64N/A
lift-fmod.f64N/A
exp-negN/A
lift-exp.f64N/A
Applied rewrites76.6%
if 2 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 0.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
lower-fmod.f64100.0
Applied rewrites100.0%
Final simplification45.7%
(FPCore (x)
:precision binary64
(if (<= (* (exp (- x)) (fmod (exp x) (sqrt (cos x)))) 2.0)
(/
(fmod
(exp x)
(fma
x
(*
x
(fma
(* x x)
(fma (* x x) -0.003298611111111111 -0.010416666666666666)
-0.25))
1.0))
(exp x))
(fmod 1.0 1.0)))
double code(double x) {
double tmp;
if ((exp(-x) * fmod(exp(x), sqrt(cos(x)))) <= 2.0) {
tmp = fmod(exp(x), fma(x, (x * fma((x * x), fma((x * x), -0.003298611111111111, -0.010416666666666666), -0.25)), 1.0)) / exp(x);
} else {
tmp = fmod(1.0, 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(exp(Float64(-x)) * rem(exp(x), sqrt(cos(x)))) <= 2.0) tmp = Float64(rem(exp(x), fma(x, Float64(x * fma(Float64(x * x), fma(Float64(x * x), -0.003298611111111111, -0.010416666666666666), -0.25)), 1.0)) / exp(x)); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := If[LessEqual[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], 2.0], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(x * N[(x * N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * -0.003298611111111111 + -0.010416666666666666), $MachinePrecision] + -0.25), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{-x} \cdot \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \leq 2:\\
\;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, -0.003298611111111111, -0.010416666666666666\right), -0.25\right), 1\right)\right)\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2Initial program 9.1%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
sub-negN/A
unpow2N/A
associate-*l*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f648.9
Applied rewrites8.9%
lift-exp.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-fma.f64N/A
lift-fmod.f64N/A
exp-negN/A
lift-exp.f64N/A
Applied rewrites8.9%
if 2 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 0.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
lower-fmod.f64100.0
Applied rewrites100.0%
Final simplification27.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= (* t_0 (fmod (exp x) (sqrt (cos x)))) 2.0)
(*
t_0
(fmod
(exp x)
(fma
(* x x)
(fma
x
(* x (fma (* x x) -0.003298611111111111 -0.010416666666666666))
-0.25)
1.0)))
(fmod 1.0 1.0))))
double code(double x) {
double t_0 = exp(-x);
double tmp;
if ((t_0 * fmod(exp(x), sqrt(cos(x)))) <= 2.0) {
tmp = t_0 * fmod(exp(x), fma((x * x), fma(x, (x * fma((x * x), -0.003298611111111111, -0.010416666666666666)), -0.25), 1.0));
} else {
tmp = fmod(1.0, 1.0);
}
return tmp;
}
function code(x) t_0 = exp(Float64(-x)) tmp = 0.0 if (Float64(t_0 * rem(exp(x), sqrt(cos(x)))) <= 2.0) tmp = Float64(t_0 * rem(exp(x), fma(Float64(x * x), fma(x, Float64(x * fma(Float64(x * x), -0.003298611111111111, -0.010416666666666666)), -0.25), 1.0))); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[N[(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]), $MachinePrecision], 2.0], N[(t$95$0 * N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(N[(x * x), $MachinePrecision] * N[(x * N[(x * N[(N[(x * x), $MachinePrecision] * -0.003298611111111111 + -0.010416666666666666), $MachinePrecision]), $MachinePrecision] + -0.25), $MachinePrecision] + 1.0), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]), $MachinePrecision], N[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;t\_0 \cdot \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \leq 2:\\
\;\;\;\;t\_0 \cdot \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot x, -0.003298611111111111, -0.010416666666666666\right), -0.25\right), 1\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2Initial program 9.1%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
sub-negN/A
unpow2N/A
associate-*l*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f648.9
Applied rewrites8.9%
if 2 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 0.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
lower-fmod.f64100.0
Applied rewrites100.0%
Final simplification27.8%
(FPCore (x)
:precision binary64
(if (<= (* (exp (- x)) (fmod (exp x) (sqrt (cos x)))) 2.0)
(/
(fmod (exp x) (fma x (* x (fma (* x x) -0.010416666666666666 -0.25)) 1.0))
(exp x))
(fmod 1.0 1.0)))
double code(double x) {
double tmp;
if ((exp(-x) * fmod(exp(x), sqrt(cos(x)))) <= 2.0) {
tmp = fmod(exp(x), fma(x, (x * fma((x * x), -0.010416666666666666, -0.25)), 1.0)) / exp(x);
} else {
tmp = fmod(1.0, 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(exp(Float64(-x)) * rem(exp(x), sqrt(cos(x)))) <= 2.0) tmp = Float64(rem(exp(x), fma(x, Float64(x * fma(Float64(x * x), -0.010416666666666666, -0.25)), 1.0)) / exp(x)); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := If[LessEqual[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], 2.0], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(x * N[(x * N[(N[(x * x), $MachinePrecision] * -0.010416666666666666 + -0.25), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{-x} \cdot \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \leq 2:\\
\;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot x, -0.010416666666666666, -0.25\right), 1\right)\right)\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2Initial program 9.1%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f648.9
Applied rewrites8.9%
lift-exp.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-fma.f64N/A
lift-fmod.f64N/A
exp-negN/A
lift-exp.f64N/A
un-div-invN/A
lower-/.f648.9
Applied rewrites8.9%
if 2 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 0.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
lower-fmod.f64100.0
Applied rewrites100.0%
Final simplification27.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= (* t_0 (fmod (exp x) (sqrt (cos x)))) 2.0)
(*
t_0
(fmod
(exp x)
(fma (* x x) (fma (* x x) -0.010416666666666666 -0.25) 1.0)))
(fmod 1.0 1.0))))
double code(double x) {
double t_0 = exp(-x);
double tmp;
if ((t_0 * fmod(exp(x), sqrt(cos(x)))) <= 2.0) {
tmp = t_0 * fmod(exp(x), fma((x * x), fma((x * x), -0.010416666666666666, -0.25), 1.0));
} else {
tmp = fmod(1.0, 1.0);
}
return tmp;
}
function code(x) t_0 = exp(Float64(-x)) tmp = 0.0 if (Float64(t_0 * rem(exp(x), sqrt(cos(x)))) <= 2.0) tmp = Float64(t_0 * rem(exp(x), fma(Float64(x * x), fma(Float64(x * x), -0.010416666666666666, -0.25), 1.0))); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[N[(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]), $MachinePrecision], 2.0], N[(t$95$0 * N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * -0.010416666666666666 + -0.25), $MachinePrecision] + 1.0), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]), $MachinePrecision], N[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;t\_0 \cdot \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \leq 2:\\
\;\;\;\;t\_0 \cdot \left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, -0.010416666666666666, -0.25\right), 1\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2Initial program 9.1%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f648.9
Applied rewrites8.9%
if 2 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 0.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
lower-fmod.f64100.0
Applied rewrites100.0%
Final simplification27.7%
(FPCore (x) :precision binary64 (fmod (+ x 1.0) 1.0))
double code(double x) {
return fmod((x + 1.0), 1.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = mod((x + 1.0d0), 1.0d0)
end function
def code(x): return math.fmod((x + 1.0), 1.0)
function code(x) return rem(Float64(x + 1.0), 1.0) end
code[x_] := N[With[{TMP1 = N[(x + 1.0), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x + 1\right) \bmod 1\right)
\end{array}
Initial program 7.2%
Taylor expanded in x around 0
Applied rewrites6.9%
Taylor expanded in x around 0
lower-fmod.f64N/A
lower-exp.f645.4
Applied rewrites5.4%
Taylor expanded in x around 0
lower-+.f6426.1
Applied rewrites26.1%
Final simplification26.1%
(FPCore (x) :precision binary64 (fmod 1.0 1.0))
double code(double x) {
return fmod(1.0, 1.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = mod(1.0d0, 1.0d0)
end function
def code(x): return math.fmod(1.0, 1.0)
function code(x) return rem(1.0, 1.0) end
code[x_] := N[With[{TMP1 = 1.0, TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]
\begin{array}{l}
\\
\left(1 \bmod 1\right)
\end{array}
Initial program 7.2%
Taylor expanded in x around 0
Applied rewrites24.4%
Taylor expanded in x around 0
Applied rewrites24.1%
Taylor expanded in x around 0
lower-fmod.f6424.1
Applied rewrites24.1%
herbie shell --seed 2024216
(FPCore (x)
:name "expfmod (used to be hard to sample)"
:precision binary64
(* (fmod (exp x) (sqrt (cos x))) (exp (- x))))