
(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 14 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 -1.8e-103)
(*
(fmod
(*
(* x (* x x))
(- 0.16666666666666666 (/ (+ -0.5 (+ (/ -1.0 x) (/ -1.0 (* x x)))) x)))
1.0)
t_0)
(if (<= x 0.2)
(/ (fmod (fma x (* x 0.5) x) 1.0) (exp x))
(* t_0 (fmod 1.0 (sqrt (cos x))))))))
double code(double x) {
double t_0 = exp(-x);
double tmp;
if (x <= -1.8e-103) {
tmp = fmod(((x * (x * x)) * (0.16666666666666666 - ((-0.5 + ((-1.0 / x) + (-1.0 / (x * x)))) / x))), 1.0) * t_0;
} else if (x <= 0.2) {
tmp = fmod(fma(x, (x * 0.5), x), 1.0) / exp(x);
} else {
tmp = t_0 * fmod(1.0, sqrt(cos(x)));
}
return tmp;
}
function code(x) t_0 = exp(Float64(-x)) tmp = 0.0 if (x <= -1.8e-103) tmp = Float64(rem(Float64(Float64(x * Float64(x * x)) * Float64(0.16666666666666666 - Float64(Float64(-0.5 + Float64(Float64(-1.0 / x) + Float64(-1.0 / Float64(x * x)))) / x))), 1.0) * t_0); elseif (x <= 0.2) tmp = Float64(rem(fma(x, Float64(x * 0.5), x), 1.0) / exp(x)); else tmp = Float64(t_0 * rem(1.0, sqrt(cos(x)))); end return tmp end
code[x_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, -1.8e-103], N[(N[With[{TMP1 = N[(N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(0.16666666666666666 - N[(N[(-0.5 + N[(N[(-1.0 / x), $MachinePrecision] + N[(-1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[x, 0.2], N[(N[With[{TMP1 = N[(x * N[(x * 0.5), $MachinePrecision] + x), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[With[{TMP1 = 1.0, TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq -1.8 \cdot 10^{-103}:\\
\;\;\;\;\left(\left(\left(x \cdot \left(x \cdot x\right)\right) \cdot \left(0.16666666666666666 - \frac{-0.5 + \left(\frac{-1}{x} + \frac{-1}{x \cdot x}\right)}{x}\right)\right) \bmod 1\right) \cdot t\_0\\
\mathbf{elif}\;x \leq 0.2:\\
\;\;\;\;\frac{\left(\left(\mathsf{fma}\left(x, x \cdot 0.5, x\right)\right) \bmod 1\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(1 \bmod \left(\sqrt{\cos x}\right)\right)\\
\end{array}
\end{array}
if x < -1.7999999999999999e-103Initial program 27.0%
Taylor expanded in x around 0
Applied rewrites27.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6425.4
Applied rewrites25.4%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites47.9%
if -1.7999999999999999e-103 < x < 0.20000000000000001Initial program 6.8%
Taylor expanded in x around 0
Applied rewrites6.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f646.0
Applied rewrites6.0%
Taylor expanded in x around inf
distribute-lft-inN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
rgt-mult-inverseN/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6463.3
Applied rewrites63.3%
lift-*.f64N/A
lift-fma.f64N/A
lift-fmod.f64N/A
exp-negN/A
lift-exp.f64N/A
un-div-invN/A
lower-/.f6463.3
Applied rewrites63.3%
if 0.20000000000000001 < x Initial program 1.4%
Taylor expanded in x around 0
Applied rewrites97.3%
Final simplification68.4%
(FPCore (x) :precision binary64 (if (<= (* (exp (- x)) (fmod (exp x) (sqrt (cos x)))) 0.002) (/ (fmod (fma x (* x 0.5) x) 1.0) (exp x)) (/ (fmod (+ x 1.0) 1.0) (exp x))))
double code(double x) {
double tmp;
if ((exp(-x) * fmod(exp(x), sqrt(cos(x)))) <= 0.002) {
tmp = fmod(fma(x, (x * 0.5), x), 1.0) / exp(x);
} else {
tmp = fmod((x + 1.0), 1.0) / exp(x);
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(exp(Float64(-x)) * rem(exp(x), sqrt(cos(x)))) <= 0.002) tmp = Float64(rem(fma(x, Float64(x * 0.5), x), 1.0) / exp(x)); else tmp = Float64(rem(Float64(x + 1.0), 1.0) / exp(x)); 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], 0.002], N[(N[With[{TMP1 = N[(x * N[(x * 0.5), $MachinePrecision] + x), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = N[(x + 1.0), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $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 0.002:\\
\;\;\;\;\frac{\left(\left(\mathsf{fma}\left(x, x \cdot 0.5, x\right)\right) \bmod 1\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(x + 1\right) \bmod 1\right)}{e^{x}}\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2e-3Initial program 6.6%
Taylor expanded in x around 0
Applied rewrites5.7%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f645.7
Applied rewrites5.7%
Taylor expanded in x around inf
distribute-lft-inN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
rgt-mult-inverseN/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6454.0
Applied rewrites54.0%
lift-*.f64N/A
lift-fma.f64N/A
lift-fmod.f64N/A
exp-negN/A
lift-exp.f64N/A
un-div-invN/A
lower-/.f6454.0
Applied rewrites54.0%
if 2e-3 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 14.9%
Taylor expanded in x around 0
Applied rewrites14.9%
Taylor expanded in x around 0
lower-+.f6492.1
Applied rewrites92.1%
lift-+.f64N/A
lift-fmod.f64N/A
exp-negN/A
lift-exp.f64N/A
un-div-invN/A
lower-/.f6492.1
Applied rewrites92.1%
Final simplification64.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= (* t_0 (fmod (exp x) (sqrt (cos x)))) 0.002)
(* t_0 (fmod (fma x (* x 0.5) x) 1.0))
(/ (fmod (+ x 1.0) 1.0) (exp x)))))
double code(double x) {
double t_0 = exp(-x);
double tmp;
if ((t_0 * fmod(exp(x), sqrt(cos(x)))) <= 0.002) {
tmp = t_0 * fmod(fma(x, (x * 0.5), x), 1.0);
} else {
tmp = fmod((x + 1.0), 1.0) / exp(x);
}
return tmp;
}
function code(x) t_0 = exp(Float64(-x)) tmp = 0.0 if (Float64(t_0 * rem(exp(x), sqrt(cos(x)))) <= 0.002) tmp = Float64(t_0 * rem(fma(x, Float64(x * 0.5), x), 1.0)); else tmp = Float64(rem(Float64(x + 1.0), 1.0) / exp(x)); 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], 0.002], N[(t$95$0 * N[With[{TMP1 = N[(x * N[(x * 0.5), $MachinePrecision] + x), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = N[(x + 1.0), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $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 0.002:\\
\;\;\;\;t\_0 \cdot \left(\left(\mathsf{fma}\left(x, x \cdot 0.5, x\right)\right) \bmod 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(x + 1\right) \bmod 1\right)}{e^{x}}\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2e-3Initial program 6.6%
Taylor expanded in x around 0
Applied rewrites5.7%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f645.7
Applied rewrites5.7%
Taylor expanded in x around inf
distribute-lft-inN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
rgt-mult-inverseN/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6454.0
Applied rewrites54.0%
if 2e-3 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 14.9%
Taylor expanded in x around 0
Applied rewrites14.9%
Taylor expanded in x around 0
lower-+.f6492.1
Applied rewrites92.1%
lift-+.f64N/A
lift-fmod.f64N/A
exp-negN/A
lift-exp.f64N/A
un-div-invN/A
lower-/.f6492.1
Applied rewrites92.1%
Final simplification64.0%
(FPCore (x) :precision binary64 (if (<= (* (exp (- x)) (fmod (exp x) (sqrt (cos x)))) 5e-11) (* (fmod (fma x (* x 0.5) x) 1.0) (fma x (fma x 0.5 -1.0) 1.0)) (/ (fmod (+ x 1.0) 1.0) (exp x))))
double code(double x) {
double tmp;
if ((exp(-x) * fmod(exp(x), sqrt(cos(x)))) <= 5e-11) {
tmp = fmod(fma(x, (x * 0.5), x), 1.0) * fma(x, fma(x, 0.5, -1.0), 1.0);
} else {
tmp = fmod((x + 1.0), 1.0) / exp(x);
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(exp(Float64(-x)) * rem(exp(x), sqrt(cos(x)))) <= 5e-11) tmp = Float64(rem(fma(x, Float64(x * 0.5), x), 1.0) * fma(x, fma(x, 0.5, -1.0), 1.0)); else tmp = Float64(rem(Float64(x + 1.0), 1.0) / exp(x)); 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], 5e-11], N[(N[With[{TMP1 = N[(x * N[(x * 0.5), $MachinePrecision] + x), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(x * N[(x * 0.5 + -1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = N[(x + 1.0), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $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 5 \cdot 10^{-11}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(x, x \cdot 0.5, x\right)\right) \bmod 1\right) \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, 0.5, -1\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(x + 1\right) \bmod 1\right)}{e^{x}}\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 5.00000000000000018e-11Initial program 5.1%
Taylor expanded in x around 0
Applied rewrites5.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f645.1
Applied rewrites5.1%
Taylor expanded in x around inf
distribute-lft-inN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
rgt-mult-inverseN/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6454.4
Applied rewrites54.4%
Taylor expanded in x around 0
Applied rewrites54.4%
if 5.00000000000000018e-11 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 18.3%
Taylor expanded in x around 0
Applied rewrites16.1%
Taylor expanded in x around 0
lower-+.f6488.9
Applied rewrites88.9%
lift-+.f64N/A
lift-fmod.f64N/A
exp-negN/A
lift-exp.f64N/A
un-div-invN/A
lower-/.f6488.9
Applied rewrites88.9%
Final simplification63.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= (* t_0 (fmod (exp x) (sqrt (cos x)))) 5e-11)
(* (fmod (fma x (* x 0.5) x) 1.0) (fma x (fma x 0.5 -1.0) 1.0))
(* t_0 (fmod (+ x 1.0) 1.0)))))
double code(double x) {
double t_0 = exp(-x);
double tmp;
if ((t_0 * fmod(exp(x), sqrt(cos(x)))) <= 5e-11) {
tmp = fmod(fma(x, (x * 0.5), x), 1.0) * fma(x, fma(x, 0.5, -1.0), 1.0);
} else {
tmp = t_0 * fmod((x + 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)))) <= 5e-11) tmp = Float64(rem(fma(x, Float64(x * 0.5), x), 1.0) * fma(x, fma(x, 0.5, -1.0), 1.0)); else tmp = Float64(t_0 * rem(Float64(x + 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], 5e-11], N[(N[With[{TMP1 = N[(x * N[(x * 0.5), $MachinePrecision] + x), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(x * N[(x * 0.5 + -1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[With[{TMP1 = N[(x + 1.0), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]), $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 5 \cdot 10^{-11}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(x, x \cdot 0.5, x\right)\right) \bmod 1\right) \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, 0.5, -1\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(\left(x + 1\right) \bmod 1\right)\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 5.00000000000000018e-11Initial program 5.1%
Taylor expanded in x around 0
Applied rewrites5.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f645.1
Applied rewrites5.1%
Taylor expanded in x around inf
distribute-lft-inN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
rgt-mult-inverseN/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6454.4
Applied rewrites54.4%
Taylor expanded in x around 0
Applied rewrites54.4%
if 5.00000000000000018e-11 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 18.3%
Taylor expanded in x around 0
Applied rewrites16.1%
Taylor expanded in x around 0
lower-+.f6488.9
Applied rewrites88.9%
Final simplification63.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= x -1.8e-103)
(*
(fmod
(*
(* x (* x x))
(- 0.16666666666666666 (/ (+ -0.5 (+ (/ -1.0 x) (/ -1.0 (* x x)))) x)))
1.0)
t_0)
(if (<= x 0.2)
(/ (fmod (fma x (* x 0.5) x) 1.0) (exp x))
(* t_0 (fmod (+ x 1.0) 1.0))))))
double code(double x) {
double t_0 = exp(-x);
double tmp;
if (x <= -1.8e-103) {
tmp = fmod(((x * (x * x)) * (0.16666666666666666 - ((-0.5 + ((-1.0 / x) + (-1.0 / (x * x)))) / x))), 1.0) * t_0;
} else if (x <= 0.2) {
tmp = fmod(fma(x, (x * 0.5), x), 1.0) / exp(x);
} else {
tmp = t_0 * fmod((x + 1.0), 1.0);
}
return tmp;
}
function code(x) t_0 = exp(Float64(-x)) tmp = 0.0 if (x <= -1.8e-103) tmp = Float64(rem(Float64(Float64(x * Float64(x * x)) * Float64(0.16666666666666666 - Float64(Float64(-0.5 + Float64(Float64(-1.0 / x) + Float64(-1.0 / Float64(x * x)))) / x))), 1.0) * t_0); elseif (x <= 0.2) tmp = Float64(rem(fma(x, Float64(x * 0.5), x), 1.0) / exp(x)); else tmp = Float64(t_0 * rem(Float64(x + 1.0), 1.0)); end return tmp end
code[x_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, -1.8e-103], N[(N[With[{TMP1 = N[(N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(0.16666666666666666 - N[(N[(-0.5 + N[(N[(-1.0 / x), $MachinePrecision] + N[(-1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[x, 0.2], N[(N[With[{TMP1 = N[(x * N[(x * 0.5), $MachinePrecision] + x), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[With[{TMP1 = N[(x + 1.0), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq -1.8 \cdot 10^{-103}:\\
\;\;\;\;\left(\left(\left(x \cdot \left(x \cdot x\right)\right) \cdot \left(0.16666666666666666 - \frac{-0.5 + \left(\frac{-1}{x} + \frac{-1}{x \cdot x}\right)}{x}\right)\right) \bmod 1\right) \cdot t\_0\\
\mathbf{elif}\;x \leq 0.2:\\
\;\;\;\;\frac{\left(\left(\mathsf{fma}\left(x, x \cdot 0.5, x\right)\right) \bmod 1\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(\left(x + 1\right) \bmod 1\right)\\
\end{array}
\end{array}
if x < -1.7999999999999999e-103Initial program 27.0%
Taylor expanded in x around 0
Applied rewrites27.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6425.4
Applied rewrites25.4%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites47.9%
if -1.7999999999999999e-103 < x < 0.20000000000000001Initial program 6.8%
Taylor expanded in x around 0
Applied rewrites6.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f646.0
Applied rewrites6.0%
Taylor expanded in x around inf
distribute-lft-inN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
rgt-mult-inverseN/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6463.3
Applied rewrites63.3%
lift-*.f64N/A
lift-fma.f64N/A
lift-fmod.f64N/A
exp-negN/A
lift-exp.f64N/A
un-div-invN/A
lower-/.f6463.3
Applied rewrites63.3%
if 0.20000000000000001 < x Initial program 1.4%
Taylor expanded in x around 0
Applied rewrites0.4%
Taylor expanded in x around 0
lower-+.f6497.1
Applied rewrites97.1%
Final simplification68.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (fma x (fma x 0.5 -1.0) 1.0)))
(if (<= x -5e-310)
(* t_0 (fmod (fma x (fma x 0.5 1.0) 1.0) 1.0))
(if (<= x 200.0) (* (fmod (fma x (* x 0.5) x) 1.0) t_0) (fmod 1.0 1.0)))))
double code(double x) {
double t_0 = fma(x, fma(x, 0.5, -1.0), 1.0);
double tmp;
if (x <= -5e-310) {
tmp = t_0 * fmod(fma(x, fma(x, 0.5, 1.0), 1.0), 1.0);
} else if (x <= 200.0) {
tmp = fmod(fma(x, (x * 0.5), x), 1.0) * t_0;
} else {
tmp = fmod(1.0, 1.0);
}
return tmp;
}
function code(x) t_0 = fma(x, fma(x, 0.5, -1.0), 1.0) tmp = 0.0 if (x <= -5e-310) tmp = Float64(t_0 * rem(fma(x, fma(x, 0.5, 1.0), 1.0), 1.0)); elseif (x <= 200.0) tmp = Float64(rem(fma(x, Float64(x * 0.5), x), 1.0) * t_0); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := Block[{t$95$0 = N[(x * N[(x * 0.5 + -1.0), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, -5e-310], N[(t$95$0 * N[With[{TMP1 = N[(x * N[(x * 0.5 + 1.0), $MachinePrecision] + 1.0), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 200.0], N[(N[With[{TMP1 = N[(x * N[(x * 0.5), $MachinePrecision] + x), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$0), $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 := \mathsf{fma}\left(x, \mathsf{fma}\left(x, 0.5, -1\right), 1\right)\\
\mathbf{if}\;x \leq -5 \cdot 10^{-310}:\\
\;\;\;\;t\_0 \cdot \left(\left(\mathsf{fma}\left(x, \mathsf{fma}\left(x, 0.5, 1\right), 1\right)\right) \bmod 1\right)\\
\mathbf{elif}\;x \leq 200:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(x, x \cdot 0.5, x\right)\right) \bmod 1\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if x < -4.999999999999985e-310Initial program 12.9%
Taylor expanded in x around 0
Applied rewrites12.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6411.8
Applied rewrites11.8%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f6412.4
Applied rewrites12.4%
if -4.999999999999985e-310 < x < 200Initial program 9.4%
Taylor expanded in x around 0
Applied rewrites7.8%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f647.9
Applied rewrites7.9%
Taylor expanded in x around inf
distribute-lft-inN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
rgt-mult-inverseN/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6496.3
Applied rewrites96.3%
Taylor expanded in x around 0
Applied rewrites96.1%
if 200 < x Initial program 0.0%
Taylor expanded in x around 0
Applied rewrites0.0%
Taylor expanded in x around 0
lower-fmod.f64N/A
lower-exp.f640.0
Applied rewrites0.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Final simplification64.9%
(FPCore (x)
:precision binary64
(if (<= x -5e-310)
(* (fmod (fma x (fma x 0.5 1.0) 1.0) 1.0) (- 1.0 x))
(if (<= x 200.0)
(* (fmod (fma x (* x 0.5) x) 1.0) (fma x (fma x 0.5 -1.0) 1.0))
(fmod 1.0 1.0))))
double code(double x) {
double tmp;
if (x <= -5e-310) {
tmp = fmod(fma(x, fma(x, 0.5, 1.0), 1.0), 1.0) * (1.0 - x);
} else if (x <= 200.0) {
tmp = fmod(fma(x, (x * 0.5), x), 1.0) * fma(x, fma(x, 0.5, -1.0), 1.0);
} else {
tmp = fmod(1.0, 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= -5e-310) tmp = Float64(rem(fma(x, fma(x, 0.5, 1.0), 1.0), 1.0) * Float64(1.0 - x)); elseif (x <= 200.0) tmp = Float64(rem(fma(x, Float64(x * 0.5), x), 1.0) * fma(x, fma(x, 0.5, -1.0), 1.0)); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := If[LessEqual[x, -5e-310], N[(N[With[{TMP1 = N[(x * N[(x * 0.5 + 1.0), $MachinePrecision] + 1.0), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(1.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 200.0], N[(N[With[{TMP1 = N[(x * N[(x * 0.5), $MachinePrecision] + x), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(x * N[(x * 0.5 + -1.0), $MachinePrecision] + 1.0), $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}\;x \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(x, \mathsf{fma}\left(x, 0.5, 1\right), 1\right)\right) \bmod 1\right) \cdot \left(1 - x\right)\\
\mathbf{elif}\;x \leq 200:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(x, x \cdot 0.5, x\right)\right) \bmod 1\right) \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, 0.5, -1\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if x < -4.999999999999985e-310Initial program 12.9%
Taylor expanded in x around 0
Applied rewrites12.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6411.8
Applied rewrites11.8%
Taylor expanded in x around 0
neg-mul-1N/A
unsub-negN/A
lower--.f6410.9
Applied rewrites10.9%
if -4.999999999999985e-310 < x < 200Initial program 9.4%
Taylor expanded in x around 0
Applied rewrites7.8%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f647.9
Applied rewrites7.9%
Taylor expanded in x around inf
distribute-lft-inN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
rgt-mult-inverseN/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6496.3
Applied rewrites96.3%
Taylor expanded in x around 0
Applied rewrites96.1%
if 200 < x Initial program 0.0%
Taylor expanded in x around 0
Applied rewrites0.0%
Taylor expanded in x around 0
lower-fmod.f64N/A
lower-exp.f640.0
Applied rewrites0.0%
Taylor expanded in x around 0
Applied rewrites100.0%
(FPCore (x)
:precision binary64
(if (<= x -5e-310)
(* (fmod (fma x (fma x 0.5 1.0) 1.0) 1.0) (- 1.0 x))
(if (<= x 0.2)
(* (fmod (fma x (* x 0.5) x) 1.0) (- 1.0 x))
(fmod 1.0 1.0))))
double code(double x) {
double tmp;
if (x <= -5e-310) {
tmp = fmod(fma(x, fma(x, 0.5, 1.0), 1.0), 1.0) * (1.0 - x);
} else if (x <= 0.2) {
tmp = fmod(fma(x, (x * 0.5), x), 1.0) * (1.0 - x);
} else {
tmp = fmod(1.0, 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= -5e-310) tmp = Float64(rem(fma(x, fma(x, 0.5, 1.0), 1.0), 1.0) * Float64(1.0 - x)); elseif (x <= 0.2) tmp = Float64(rem(fma(x, Float64(x * 0.5), x), 1.0) * Float64(1.0 - x)); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := If[LessEqual[x, -5e-310], N[(N[With[{TMP1 = N[(x * N[(x * 0.5 + 1.0), $MachinePrecision] + 1.0), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(1.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.2], N[(N[With[{TMP1 = N[(x * N[(x * 0.5), $MachinePrecision] + x), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(1.0 - 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}\;x \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(x, \mathsf{fma}\left(x, 0.5, 1\right), 1\right)\right) \bmod 1\right) \cdot \left(1 - x\right)\\
\mathbf{elif}\;x \leq 0.2:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(x, x \cdot 0.5, x\right)\right) \bmod 1\right) \cdot \left(1 - x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if x < -4.999999999999985e-310Initial program 12.9%
Taylor expanded in x around 0
Applied rewrites12.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6411.8
Applied rewrites11.8%
Taylor expanded in x around 0
neg-mul-1N/A
unsub-negN/A
lower--.f6410.9
Applied rewrites10.9%
if -4.999999999999985e-310 < x < 0.20000000000000001Initial program 8.8%
Taylor expanded in x around 0
Applied rewrites7.7%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f647.7
Applied rewrites7.7%
Taylor expanded in x around inf
distribute-lft-inN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
rgt-mult-inverseN/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6497.9
Applied rewrites97.9%
Taylor expanded in x around 0
Applied rewrites97.9%
if 0.20000000000000001 < x Initial program 1.4%
Taylor expanded in x around 0
Applied rewrites0.4%
Taylor expanded in x around 0
lower-fmod.f64N/A
lower-exp.f640.3
Applied rewrites0.3%
Taylor expanded in x around 0
Applied rewrites96.6%
(FPCore (x)
:precision binary64
(if (<= x -5e-310)
(* (fmod (+ x 1.0) 1.0) (- 1.0 x))
(if (<= x 0.2)
(* (fmod (fma x (* x 0.5) x) 1.0) (- 1.0 x))
(fmod 1.0 1.0))))
double code(double x) {
double tmp;
if (x <= -5e-310) {
tmp = fmod((x + 1.0), 1.0) * (1.0 - x);
} else if (x <= 0.2) {
tmp = fmod(fma(x, (x * 0.5), x), 1.0) * (1.0 - x);
} else {
tmp = fmod(1.0, 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= -5e-310) tmp = Float64(rem(Float64(x + 1.0), 1.0) * Float64(1.0 - x)); elseif (x <= 0.2) tmp = Float64(rem(fma(x, Float64(x * 0.5), x), 1.0) * Float64(1.0 - x)); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := If[LessEqual[x, -5e-310], N[(N[With[{TMP1 = N[(x + 1.0), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(1.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.2], N[(N[With[{TMP1 = N[(x * N[(x * 0.5), $MachinePrecision] + x), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(1.0 - 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}\;x \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\left(x + 1\right) \bmod 1\right) \cdot \left(1 - x\right)\\
\mathbf{elif}\;x \leq 0.2:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(x, x \cdot 0.5, x\right)\right) \bmod 1\right) \cdot \left(1 - x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if x < -4.999999999999985e-310Initial program 12.9%
Taylor expanded in x around 0
Applied rewrites12.9%
Taylor expanded in x around 0
lower-+.f6410.6
Applied rewrites10.6%
Taylor expanded in x around 0
associate-*r*N/A
distribute-lft1-inN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lower-fmod.f64N/A
lower-+.f64N/A
neg-mul-1N/A
unsub-negN/A
lower--.f6410.5
Applied rewrites10.5%
if -4.999999999999985e-310 < x < 0.20000000000000001Initial program 8.8%
Taylor expanded in x around 0
Applied rewrites7.7%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f647.7
Applied rewrites7.7%
Taylor expanded in x around inf
distribute-lft-inN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
rgt-mult-inverseN/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6497.9
Applied rewrites97.9%
Taylor expanded in x around 0
Applied rewrites97.9%
if 0.20000000000000001 < x Initial program 1.4%
Taylor expanded in x around 0
Applied rewrites0.4%
Taylor expanded in x around 0
lower-fmod.f64N/A
lower-exp.f640.3
Applied rewrites0.3%
Taylor expanded in x around 0
Applied rewrites96.6%
Final simplification64.1%
(FPCore (x) :precision binary64 (if (<= x -5e-310) (* (fmod (+ x 1.0) 1.0) (- 1.0 x)) (if (<= x 200.0) (fmod (fma x (* x 0.5) x) 1.0) (fmod 1.0 1.0))))
double code(double x) {
double tmp;
if (x <= -5e-310) {
tmp = fmod((x + 1.0), 1.0) * (1.0 - x);
} else if (x <= 200.0) {
tmp = fmod(fma(x, (x * 0.5), x), 1.0);
} else {
tmp = fmod(1.0, 1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= -5e-310) tmp = Float64(rem(Float64(x + 1.0), 1.0) * Float64(1.0 - x)); elseif (x <= 200.0) tmp = rem(fma(x, Float64(x * 0.5), x), 1.0); else tmp = rem(1.0, 1.0); end return tmp end
code[x_] := If[LessEqual[x, -5e-310], N[(N[With[{TMP1 = N[(x + 1.0), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(1.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 200.0], N[With[{TMP1 = N[(x * N[(x * 0.5), $MachinePrecision] + x), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $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}\;x \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\left(x + 1\right) \bmod 1\right) \cdot \left(1 - x\right)\\
\mathbf{elif}\;x \leq 200:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(x, x \cdot 0.5, x\right)\right) \bmod 1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod 1\right)\\
\end{array}
\end{array}
if x < -4.999999999999985e-310Initial program 12.9%
Taylor expanded in x around 0
Applied rewrites12.9%
Taylor expanded in x around 0
lower-+.f6410.6
Applied rewrites10.6%
Taylor expanded in x around 0
associate-*r*N/A
distribute-lft1-inN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lower-fmod.f64N/A
lower-+.f64N/A
neg-mul-1N/A
unsub-negN/A
lower--.f6410.5
Applied rewrites10.5%
if -4.999999999999985e-310 < x < 200Initial program 9.4%
Taylor expanded in x around 0
Applied rewrites7.8%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f647.9
Applied rewrites7.9%
Taylor expanded in x around inf
distribute-lft-inN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
rgt-mult-inverseN/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6496.3
Applied rewrites96.3%
Taylor expanded in x around 0
*-rgt-identityN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
distribute-lft-inN/A
*-lft-identityN/A
lft-mult-inverseN/A
associate-*r*N/A
unpow2N/A
associate-*l*N/A
lft-mult-inverseN/A
distribute-rgt-inN/A
+-commutativeN/A
associate-*l*N/A
unpow2N/A
cube-multN/A
Applied rewrites96.0%
if 200 < x Initial program 0.0%
Taylor expanded in x around 0
Applied rewrites0.0%
Taylor expanded in x around 0
lower-fmod.f64N/A
lower-exp.f640.0
Applied rewrites0.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Final simplification64.1%
(FPCore (x) :precision binary64 (* (fmod (+ x 1.0) 1.0) (- 1.0 x)))
double code(double x) {
return fmod((x + 1.0), 1.0) * (1.0 - x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = mod((x + 1.0d0), 1.0d0) * (1.0d0 - x)
end function
def code(x): return math.fmod((x + 1.0), 1.0) * (1.0 - x)
function code(x) return Float64(rem(Float64(x + 1.0), 1.0) * Float64(1.0 - x)) end
code[x_] := N[(N[With[{TMP1 = N[(x + 1.0), $MachinePrecision], TMP2 = 1.0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x + 1\right) \bmod 1\right) \cdot \left(1 - x\right)
\end{array}
Initial program 8.7%
Taylor expanded in x around 0
Applied rewrites8.1%
Taylor expanded in x around 0
lower-+.f6428.3
Applied rewrites28.3%
Taylor expanded in x around 0
associate-*r*N/A
distribute-lft1-inN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lower-fmod.f64N/A
lower-+.f64N/A
neg-mul-1N/A
unsub-negN/A
lower--.f6426.6
Applied rewrites26.6%
Final simplification26.6%
(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 8.7%
Taylor expanded in x around 0
Applied rewrites8.1%
Taylor expanded in x around 0
lower-+.f6428.3
Applied rewrites28.3%
Taylor expanded in x around 0
lower-fmod.f64N/A
lower-+.f6425.8
Applied rewrites25.8%
Final simplification25.8%
(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 8.7%
Taylor expanded in x around 0
Applied rewrites8.1%
Taylor expanded in x around 0
lower-fmod.f64N/A
lower-exp.f646.2
Applied rewrites6.2%
Taylor expanded in x around 0
Applied rewrites24.4%
herbie shell --seed 2024212
(FPCore (x)
:name "expfmod (used to be hard to sample)"
:precision binary64
(* (fmod (exp x) (sqrt (cos x))) (exp (- x))))