
(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 8 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 (fma (* x x) -0.25 1.0)) (t_1 (exp (- x))))
(if (<= x -5e-99)
(*
(fmod
(*
(pow (- x) 3.0)
(-
(/ (fma (/ (+ (pow x -1.0) 1.0) x) -1.0 -0.5) x)
0.16666666666666666))
t_0)
t_1)
(if (<= x 1e-116)
(fmod (exp x) (* (* (- (pow (* x x) -1.0) 0.25) x) x))
(if (<= x 0.0001)
(*
(fmod
(* (+ (/ (+ (pow x -1.0) 0.5) x) 0.16666666666666666) (pow x 3.0))
t_0)
t_1)
(* (fmod 1.0 (* (* x x) -0.25)) t_1))))))
double code(double x) {
double t_0 = fma((x * x), -0.25, 1.0);
double t_1 = exp(-x);
double tmp;
if (x <= -5e-99) {
tmp = fmod((pow(-x, 3.0) * ((fma(((pow(x, -1.0) + 1.0) / x), -1.0, -0.5) / x) - 0.16666666666666666)), t_0) * t_1;
} else if (x <= 1e-116) {
tmp = fmod(exp(x), (((pow((x * x), -1.0) - 0.25) * x) * x));
} else if (x <= 0.0001) {
tmp = fmod(((((pow(x, -1.0) + 0.5) / x) + 0.16666666666666666) * pow(x, 3.0)), t_0) * t_1;
} else {
tmp = fmod(1.0, ((x * x) * -0.25)) * t_1;
}
return tmp;
}
function code(x) t_0 = fma(Float64(x * x), -0.25, 1.0) t_1 = exp(Float64(-x)) tmp = 0.0 if (x <= -5e-99) tmp = Float64(rem(Float64((Float64(-x) ^ 3.0) * Float64(Float64(fma(Float64(Float64((x ^ -1.0) + 1.0) / x), -1.0, -0.5) / x) - 0.16666666666666666)), t_0) * t_1); elseif (x <= 1e-116) tmp = rem(exp(x), Float64(Float64(Float64((Float64(x * x) ^ -1.0) - 0.25) * x) * x)); elseif (x <= 0.0001) tmp = Float64(rem(Float64(Float64(Float64(Float64((x ^ -1.0) + 0.5) / x) + 0.16666666666666666) * (x ^ 3.0)), t_0) * t_1); else tmp = Float64(rem(1.0, Float64(Float64(x * x) * -0.25)) * t_1); end return tmp end
code[x_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] * -0.25 + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, -5e-99], N[(N[With[{TMP1 = N[(N[Power[(-x), 3.0], $MachinePrecision] * N[(N[(N[(N[(N[(N[Power[x, -1.0], $MachinePrecision] + 1.0), $MachinePrecision] / x), $MachinePrecision] * -1.0 + -0.5), $MachinePrecision] / x), $MachinePrecision] - 0.16666666666666666), $MachinePrecision]), $MachinePrecision], TMP2 = t$95$0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[x, 1e-116], N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(N[(N[(N[Power[N[(x * x), $MachinePrecision], -1.0], $MachinePrecision] - 0.25), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision], If[LessEqual[x, 0.0001], N[(N[With[{TMP1 = N[(N[(N[(N[(N[Power[x, -1.0], $MachinePrecision] + 0.5), $MachinePrecision] / x), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision], TMP2 = t$95$0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[With[{TMP1 = 1.0, TMP2 = N[(N[(x * x), $MachinePrecision] * -0.25), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$1), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(x \cdot x, -0.25, 1\right)\\
t_1 := e^{-x}\\
\mathbf{if}\;x \leq -5 \cdot 10^{-99}:\\
\;\;\;\;\left(\left({\left(-x\right)}^{3} \cdot \left(\frac{\mathsf{fma}\left(\frac{{x}^{-1} + 1}{x}, -1, -0.5\right)}{x} - 0.16666666666666666\right)\right) \bmod t\_0\right) \cdot t\_1\\
\mathbf{elif}\;x \leq 10^{-116}:\\
\;\;\;\;\left(\left(e^{x}\right) \bmod \left(\left(\left({\left(x \cdot x\right)}^{-1} - 0.25\right) \cdot x\right) \cdot x\right)\right)\\
\mathbf{elif}\;x \leq 0.0001:\\
\;\;\;\;\left(\left(\left(\frac{{x}^{-1} + 0.5}{x} + 0.16666666666666666\right) \cdot {x}^{3}\right) \bmod t\_0\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod \left(\left(x \cdot x\right) \cdot -0.25\right)\right) \cdot t\_1\\
\end{array}
\end{array}
if x < -4.99999999999999969e-99Initial program 27.9%
Taylor expanded in x around 0
Applied rewrites4.1%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f644.1
Applied rewrites4.1%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6422.3
Applied rewrites22.3%
Taylor expanded in x around -inf
Applied rewrites49.7%
if -4.99999999999999969e-99 < x < 9.9999999999999999e-117Initial program 4.8%
Taylor expanded in x around 0
lower-fmod.f64N/A
lower-exp.f64N/A
lower-sqrt.f64N/A
lower-cos.f644.8
Applied rewrites4.8%
Taylor expanded in x around 0
Applied rewrites4.8%
Taylor expanded in x around inf
Applied rewrites38.7%
if 9.9999999999999999e-117 < x < 1.00000000000000005e-4Initial program 8.9%
Taylor expanded in x around 0
Applied rewrites3.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f643.9
Applied rewrites3.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f648.8
Applied rewrites8.8%
Taylor expanded in x around inf
Applied rewrites95.8%
if 1.00000000000000005e-4 < x Initial program 0.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites100.0%
Final simplification63.9%
(FPCore (x) :precision binary64 (if (<= (* (fmod (exp x) (sqrt (cos x))) (exp (- x))) 0.0) (fmod (exp x) (* (* (- (pow (* x x) -1.0) 0.25) x) x)) (/ (fmod (+ 1.0 x) (fma -0.25 (* x x) 1.0)) (exp x))))
double code(double x) {
double tmp;
if ((fmod(exp(x), sqrt(cos(x))) * exp(-x)) <= 0.0) {
tmp = fmod(exp(x), (((pow((x * x), -1.0) - 0.25) * x) * x));
} else {
tmp = fmod((1.0 + x), fma(-0.25, (x * x), 1.0)) / exp(x);
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(rem(exp(x), sqrt(cos(x))) * exp(Float64(-x))) <= 0.0) tmp = rem(exp(x), Float64(Float64(Float64((Float64(x * x) ^ -1.0) - 0.25) * x) * x)); else tmp = Float64(rem(Float64(1.0 + x), fma(-0.25, Float64(x * x), 1.0)) / exp(x)); end return tmp end
code[x_] := If[LessEqual[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], 0.0], N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(N[(N[(N[Power[N[(x * x), $MachinePrecision], -1.0], $MachinePrecision] - 0.25), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision], N[(N[With[{TMP1 = N[(1.0 + x), $MachinePrecision], TMP2 = N[(-0.25 * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \leq 0:\\
\;\;\;\;\left(\left(e^{x}\right) \bmod \left(\left(\left({\left(x \cdot x\right)}^{-1} - 0.25\right) \cdot x\right) \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(1 + x\right) \bmod \left(\mathsf{fma}\left(-0.25, x \cdot x, 1\right)\right)\right)}{e^{x}}\\
\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
lower-fmod.f64N/A
lower-exp.f64N/A
lower-sqrt.f64N/A
lower-cos.f644.3
Applied rewrites4.3%
Taylor expanded in x around 0
Applied rewrites4.3%
Taylor expanded in x around inf
Applied rewrites28.2%
if 0.0 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 15.2%
Taylor expanded in x around 0
Applied rewrites81.2%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6481.2
Applied rewrites81.2%
Taylor expanded in x around 0
lower-+.f6491.3
Applied rewrites91.3%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-exp.f64N/A
Applied rewrites91.3%
Final simplification46.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= (* (fmod (exp x) (sqrt (cos x))) t_0) 0.0)
(fmod (exp x) (* (* (- (pow (* x x) -1.0) 0.25) x) x))
(* (fmod (+ 1.0 x) (fma (* x x) -0.25 1.0)) t_0))))
double code(double x) {
double t_0 = exp(-x);
double tmp;
if ((fmod(exp(x), sqrt(cos(x))) * t_0) <= 0.0) {
tmp = fmod(exp(x), (((pow((x * x), -1.0) - 0.25) * x) * x));
} else {
tmp = fmod((1.0 + x), fma((x * x), -0.25, 1.0)) * t_0;
}
return tmp;
}
function code(x) t_0 = exp(Float64(-x)) tmp = 0.0 if (Float64(rem(exp(x), sqrt(cos(x))) * t_0) <= 0.0) tmp = rem(exp(x), Float64(Float64(Float64((Float64(x * x) ^ -1.0) - 0.25) * x) * x)); else tmp = Float64(rem(Float64(1.0 + x), fma(Float64(x * x), -0.25, 1.0)) * t_0); end return tmp end
code[x_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$0), $MachinePrecision], 0.0], N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(N[(N[(N[Power[N[(x * x), $MachinePrecision], -1.0], $MachinePrecision] - 0.25), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision], N[(N[With[{TMP1 = N[(1.0 + x), $MachinePrecision], TMP2 = N[(N[(x * x), $MachinePrecision] * -0.25 + 1.0), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot t\_0 \leq 0:\\
\;\;\;\;\left(\left(e^{x}\right) \bmod \left(\left(\left({\left(x \cdot x\right)}^{-1} - 0.25\right) \cdot x\right) \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(1 + x\right) \bmod \left(\mathsf{fma}\left(x \cdot x, -0.25, 1\right)\right)\right) \cdot t\_0\\
\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
lower-fmod.f64N/A
lower-exp.f64N/A
lower-sqrt.f64N/A
lower-cos.f644.3
Applied rewrites4.3%
Taylor expanded in x around 0
Applied rewrites4.3%
Taylor expanded in x around inf
Applied rewrites28.2%
if 0.0 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 15.2%
Taylor expanded in x around 0
Applied rewrites81.2%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6481.2
Applied rewrites81.2%
Taylor expanded in x around 0
lower-+.f6491.3
Applied rewrites91.3%
Final simplification46.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= (* (fmod (exp x) (sqrt (cos x))) t_0) 2.0)
(fmod (exp x) (fma (* x x) -0.25 1.0))
(* (fmod 1.0 (* (* x x) -0.25)) t_0))))
double code(double x) {
double t_0 = exp(-x);
double tmp;
if ((fmod(exp(x), sqrt(cos(x))) * t_0) <= 2.0) {
tmp = fmod(exp(x), fma((x * x), -0.25, 1.0));
} else {
tmp = fmod(1.0, ((x * x) * -0.25)) * t_0;
}
return tmp;
}
function code(x) t_0 = exp(Float64(-x)) tmp = 0.0 if (Float64(rem(exp(x), sqrt(cos(x))) * t_0) <= 2.0) tmp = rem(exp(x), fma(Float64(x * x), -0.25, 1.0)); else tmp = Float64(rem(1.0, Float64(Float64(x * x) * -0.25)) * t_0); end return tmp end
code[x_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$0), $MachinePrecision], 2.0], N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(N[(x * x), $MachinePrecision] * -0.25 + 1.0), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision], N[(N[With[{TMP1 = 1.0, TMP2 = N[(N[(x * x), $MachinePrecision] * -0.25), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot t\_0 \leq 2:\\
\;\;\;\;\left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(x \cdot x, -0.25, 1\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod \left(\left(x \cdot x\right) \cdot -0.25\right)\right) \cdot t\_0\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2Initial program 9.8%
Taylor expanded in x around 0
lower-fmod.f64N/A
lower-exp.f64N/A
lower-sqrt.f64N/A
lower-cos.f647.6
Applied rewrites7.6%
Taylor expanded in x around 0
Applied rewrites7.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
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= x 1e-116)
(fmod (exp x) (* (* (- (pow (* x x) -1.0) 0.25) x) x))
(if (<= x 0.0001)
(*
(fmod
(* (+ (/ (+ (pow x -1.0) 0.5) x) 0.16666666666666666) (pow x 3.0))
(fma (* x x) -0.25 1.0))
t_0)
(* (fmod 1.0 (* (* x x) -0.25)) t_0)))))
double code(double x) {
double t_0 = exp(-x);
double tmp;
if (x <= 1e-116) {
tmp = fmod(exp(x), (((pow((x * x), -1.0) - 0.25) * x) * x));
} else if (x <= 0.0001) {
tmp = fmod(((((pow(x, -1.0) + 0.5) / x) + 0.16666666666666666) * pow(x, 3.0)), fma((x * x), -0.25, 1.0)) * t_0;
} else {
tmp = fmod(1.0, ((x * x) * -0.25)) * t_0;
}
return tmp;
}
function code(x) t_0 = exp(Float64(-x)) tmp = 0.0 if (x <= 1e-116) tmp = rem(exp(x), Float64(Float64(Float64((Float64(x * x) ^ -1.0) - 0.25) * x) * x)); elseif (x <= 0.0001) tmp = Float64(rem(Float64(Float64(Float64(Float64((x ^ -1.0) + 0.5) / x) + 0.16666666666666666) * (x ^ 3.0)), fma(Float64(x * x), -0.25, 1.0)) * t_0); else tmp = Float64(rem(1.0, Float64(Float64(x * x) * -0.25)) * t_0); end return tmp end
code[x_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, 1e-116], N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(N[(N[(N[Power[N[(x * x), $MachinePrecision], -1.0], $MachinePrecision] - 0.25), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision], If[LessEqual[x, 0.0001], N[(N[With[{TMP1 = N[(N[(N[(N[(N[Power[x, -1.0], $MachinePrecision] + 0.5), $MachinePrecision] / x), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision], TMP2 = N[(N[(x * x), $MachinePrecision] * -0.25 + 1.0), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[With[{TMP1 = 1.0, TMP2 = N[(N[(x * x), $MachinePrecision] * -0.25), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq 10^{-116}:\\
\;\;\;\;\left(\left(e^{x}\right) \bmod \left(\left(\left({\left(x \cdot x\right)}^{-1} - 0.25\right) \cdot x\right) \cdot x\right)\right)\\
\mathbf{elif}\;x \leq 0.0001:\\
\;\;\;\;\left(\left(\left(\frac{{x}^{-1} + 0.5}{x} + 0.16666666666666666\right) \cdot {x}^{3}\right) \bmod \left(\mathsf{fma}\left(x \cdot x, -0.25, 1\right)\right)\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod \left(\left(x \cdot x\right) \cdot -0.25\right)\right) \cdot t\_0\\
\end{array}
\end{array}
if x < 9.9999999999999999e-117Initial program 10.0%
Taylor expanded in x around 0
lower-fmod.f64N/A
lower-exp.f64N/A
lower-sqrt.f64N/A
lower-cos.f647.6
Applied rewrites7.6%
Taylor expanded in x around 0
Applied rewrites7.6%
Taylor expanded in x around inf
Applied rewrites35.4%
if 9.9999999999999999e-117 < x < 1.00000000000000005e-4Initial program 8.9%
Taylor expanded in x around 0
Applied rewrites3.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f643.9
Applied rewrites3.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f648.8
Applied rewrites8.8%
Taylor expanded in x around inf
Applied rewrites95.8%
if 1.00000000000000005e-4 < x Initial program 0.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites100.0%
Final simplification60.4%
(FPCore (x) :precision binary64 (* (fmod (+ 1.0 x) (fma (* x x) -0.25 1.0)) (exp (- x))))
double code(double x) {
return fmod((1.0 + x), fma((x * x), -0.25, 1.0)) * exp(-x);
}
function code(x) return Float64(rem(Float64(1.0 + x), fma(Float64(x * x), -0.25, 1.0)) * exp(Float64(-x))) end
code[x_] := N[(N[With[{TMP1 = N[(1.0 + x), $MachinePrecision], TMP2 = N[(N[(x * x), $MachinePrecision] * -0.25 + 1.0), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(1 + x\right) \bmod \left(\mathsf{fma}\left(x \cdot x, -0.25, 1\right)\right)\right) \cdot e^{-x}
\end{array}
Initial program 7.5%
Taylor expanded in x around 0
Applied rewrites26.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6426.9
Applied rewrites26.9%
Taylor expanded in x around 0
lower-+.f6429.8
Applied rewrites29.8%
(FPCore (x) :precision binary64 (fmod (exp x) (fma (* x x) -0.25 1.0)))
double code(double x) {
return fmod(exp(x), fma((x * x), -0.25, 1.0));
}
function code(x) return rem(exp(x), fma(Float64(x * x), -0.25, 1.0)) end
code[x_] := N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(N[(x * x), $MachinePrecision] * -0.25 + 1.0), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]
\begin{array}{l}
\\
\left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(x \cdot x, -0.25, 1\right)\right)\right)
\end{array}
Initial program 7.5%
Taylor expanded in x around 0
lower-fmod.f64N/A
lower-exp.f64N/A
lower-sqrt.f64N/A
lower-cos.f645.9
Applied rewrites5.9%
Taylor expanded in x around 0
Applied rewrites5.9%
(FPCore (x) :precision binary64 (fmod (exp x) (* (* x x) -0.25)))
double code(double x) {
return fmod(exp(x), ((x * x) * -0.25));
}
real(8) function code(x)
real(8), intent (in) :: x
code = mod(exp(x), ((x * x) * (-0.25d0)))
end function
def code(x): return math.fmod(math.exp(x), ((x * x) * -0.25))
function code(x) return rem(exp(x), Float64(Float64(x * x) * -0.25)) end
code[x_] := N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(N[(x * x), $MachinePrecision] * -0.25), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]
\begin{array}{l}
\\
\left(\left(e^{x}\right) \bmod \left(\left(x \cdot x\right) \cdot -0.25\right)\right)
\end{array}
Initial program 7.5%
Taylor expanded in x around 0
lower-fmod.f64N/A
lower-exp.f64N/A
lower-sqrt.f64N/A
lower-cos.f645.9
Applied rewrites5.9%
Taylor expanded in x around 0
Applied rewrites5.9%
Taylor expanded in x around inf
Applied rewrites2.7%
herbie shell --seed 2024343
(FPCore (x)
:name "expfmod (used to be hard to sample)"
:precision binary64
(* (fmod (exp x) (sqrt (cos x))) (exp (- x))))