
(FPCore (x c s) :precision binary64 (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))
double code(double x, double c, double s) {
return cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x));
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))
end function
public static double code(double x, double c, double s) {
return Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x));
}
def code(x, c, s): return math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))
function code(x, c, s) return Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x))) end
function tmp = code(x, c, s) tmp = cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x)); end
code[x_, c_, s_] := N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x c s) :precision binary64 (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))
double code(double x, double c, double s) {
return cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x));
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))
end function
public static double code(double x, double c, double s) {
return Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x));
}
def code(x, c, s): return math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))
function code(x, c, s) return Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x))) end
function tmp = code(x, c, s) tmp = cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x)); end
code[x_, c_, s_] := N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
\end{array}
(FPCore (x c s) :precision binary64 (let* ((t_0 (* (* x c) s))) (/ (cos (+ x x)) (* t_0 t_0))))
double code(double x, double c, double s) {
double t_0 = (x * c) * s;
return cos((x + x)) / (t_0 * t_0);
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
t_0 = (x * c) * s
code = cos((x + x)) / (t_0 * t_0)
end function
public static double code(double x, double c, double s) {
double t_0 = (x * c) * s;
return Math.cos((x + x)) / (t_0 * t_0);
}
def code(x, c, s): t_0 = (x * c) * s return math.cos((x + x)) / (t_0 * t_0)
function code(x, c, s) t_0 = Float64(Float64(x * c) * s) return Float64(cos(Float64(x + x)) / Float64(t_0 * t_0)) end
function tmp = code(x, c, s) t_0 = (x * c) * s; tmp = cos((x + x)) / (t_0 * t_0); end
code[x_, c_, s_] := Block[{t$95$0 = N[(N[(x * c), $MachinePrecision] * s), $MachinePrecision]}, N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot c\right) \cdot s\\
\frac{\cos \left(x + x\right)}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 70.6%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
unpow2N/A
unswap-sqrN/A
unpow2N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6498.9
Applied rewrites98.9%
lift-*.f64N/A
count-2N/A
lower-+.f6498.9
Applied rewrites98.9%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (cos (+ x x))))
(if (<=
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x)))
INFINITY)
(/ t_0 (* (* (* x c) s) (* (* s x) c)))
(/ t_0 (* x (* (* s c) (* (* c x) s)))))))
double code(double x, double c, double s) {
double t_0 = cos((x + x));
double tmp;
if ((cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x))) <= ((double) INFINITY)) {
tmp = t_0 / (((x * c) * s) * ((s * x) * c));
} else {
tmp = t_0 / (x * ((s * c) * ((c * x) * s)));
}
return tmp;
}
public static double code(double x, double c, double s) {
double t_0 = Math.cos((x + x));
double tmp;
if ((Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x))) <= Double.POSITIVE_INFINITY) {
tmp = t_0 / (((x * c) * s) * ((s * x) * c));
} else {
tmp = t_0 / (x * ((s * c) * ((c * x) * s)));
}
return tmp;
}
def code(x, c, s): t_0 = math.cos((x + x)) tmp = 0 if (math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))) <= math.inf: tmp = t_0 / (((x * c) * s) * ((s * x) * c)) else: tmp = t_0 / (x * ((s * c) * ((c * x) * s))) return tmp
function code(x, c, s) t_0 = cos(Float64(x + x)) tmp = 0.0 if (Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x))) <= Inf) tmp = Float64(t_0 / Float64(Float64(Float64(x * c) * s) * Float64(Float64(s * x) * c))); else tmp = Float64(t_0 / Float64(x * Float64(Float64(s * c) * Float64(Float64(c * x) * s)))); end return tmp end
function tmp_2 = code(x, c, s) t_0 = cos((x + x)); tmp = 0.0; if ((cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x))) <= Inf) tmp = t_0 / (((x * c) * s) * ((s * x) * c)); else tmp = t_0 / (x * ((s * c) * ((c * x) * s))); end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(t$95$0 / N[(N[(N[(x * c), $MachinePrecision] * s), $MachinePrecision] * N[(N[(s * x), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[(x * N[(N[(s * c), $MachinePrecision] * N[(N[(c * x), $MachinePrecision] * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(x + x\right)\\
\mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \leq \infty:\\
\;\;\;\;\frac{t\_0}{\left(\left(x \cdot c\right) \cdot s\right) \cdot \left(\left(s \cdot x\right) \cdot c\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{x \cdot \left(\left(s \cdot c\right) \cdot \left(\left(c \cdot x\right) \cdot s\right)\right)}\\
\end{array}
\end{array}
if (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < +inf.0Initial program 82.9%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
unpow2N/A
unswap-sqrN/A
unpow2N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6499.2
Applied rewrites99.2%
Applied rewrites99.3%
lift-*.f64N/A
count-2N/A
lift-+.f6499.3
Applied rewrites99.3%
if +inf.0 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) Initial program 0.0%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
unpow2N/A
unswap-sqrN/A
unpow2N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6496.8
Applied rewrites96.8%
lift-*.f64N/A
count-2N/A
lower-+.f6496.8
Applied rewrites96.8%
Applied rewrites94.7%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (* (* x c) s)))
(if (<= (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))) -2e-221)
(/ (* -2.0 (* x x)) (* t_0 t_0))
(pow (* (* s x) c) -2.0))))
double code(double x, double c, double s) {
double t_0 = (x * c) * s;
double tmp;
if ((cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x))) <= -2e-221) {
tmp = (-2.0 * (x * x)) / (t_0 * t_0);
} else {
tmp = pow(((s * x) * c), -2.0);
}
return tmp;
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: tmp
t_0 = (x * c) * s
if ((cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))) <= (-2d-221)) then
tmp = ((-2.0d0) * (x * x)) / (t_0 * t_0)
else
tmp = ((s * x) * c) ** (-2.0d0)
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double t_0 = (x * c) * s;
double tmp;
if ((Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x))) <= -2e-221) {
tmp = (-2.0 * (x * x)) / (t_0 * t_0);
} else {
tmp = Math.pow(((s * x) * c), -2.0);
}
return tmp;
}
def code(x, c, s): t_0 = (x * c) * s tmp = 0 if (math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))) <= -2e-221: tmp = (-2.0 * (x * x)) / (t_0 * t_0) else: tmp = math.pow(((s * x) * c), -2.0) return tmp
function code(x, c, s) t_0 = Float64(Float64(x * c) * s) tmp = 0.0 if (Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x))) <= -2e-221) tmp = Float64(Float64(-2.0 * Float64(x * x)) / Float64(t_0 * t_0)); else tmp = Float64(Float64(s * x) * c) ^ -2.0; end return tmp end
function tmp_2 = code(x, c, s) t_0 = (x * c) * s; tmp = 0.0; if ((cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x))) <= -2e-221) tmp = (-2.0 * (x * x)) / (t_0 * t_0); else tmp = ((s * x) * c) ^ -2.0; end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[(N[(x * c), $MachinePrecision] * s), $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-221], N[(N[(-2.0 * N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[Power[N[(N[(s * x), $MachinePrecision] * c), $MachinePrecision], -2.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot c\right) \cdot s\\
\mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \leq -2 \cdot 10^{-221}:\\
\;\;\;\;\frac{-2 \cdot \left(x \cdot x\right)}{t\_0 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;{\left(\left(s \cdot x\right) \cdot c\right)}^{-2}\\
\end{array}
\end{array}
if (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < -2.00000000000000003e-221Initial program 68.7%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
unpow2N/A
unswap-sqrN/A
unpow2N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6499.1
Applied rewrites99.1%
lift-*.f64N/A
count-2N/A
lower-+.f6499.1
Applied rewrites99.1%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6443.9
Applied rewrites43.9%
Taylor expanded in x around inf
Applied rewrites43.9%
if -2.00000000000000003e-221 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) Initial program 70.7%
Taylor expanded in x around 0
associate-*r*N/A
associate-/l/N/A
unpow2N/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6472.4
Applied rewrites72.4%
Applied rewrites86.5%
Applied rewrites85.3%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (* (* x c) s)))
(if (<= (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))) -2e-221)
(/ (* -2.0 (* x x)) (* t_0 t_0))
(pow (* (* c x) s) -2.0))))
double code(double x, double c, double s) {
double t_0 = (x * c) * s;
double tmp;
if ((cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x))) <= -2e-221) {
tmp = (-2.0 * (x * x)) / (t_0 * t_0);
} else {
tmp = pow(((c * x) * s), -2.0);
}
return tmp;
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: tmp
t_0 = (x * c) * s
if ((cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))) <= (-2d-221)) then
tmp = ((-2.0d0) * (x * x)) / (t_0 * t_0)
else
tmp = ((c * x) * s) ** (-2.0d0)
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double t_0 = (x * c) * s;
double tmp;
if ((Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x))) <= -2e-221) {
tmp = (-2.0 * (x * x)) / (t_0 * t_0);
} else {
tmp = Math.pow(((c * x) * s), -2.0);
}
return tmp;
}
def code(x, c, s): t_0 = (x * c) * s tmp = 0 if (math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))) <= -2e-221: tmp = (-2.0 * (x * x)) / (t_0 * t_0) else: tmp = math.pow(((c * x) * s), -2.0) return tmp
function code(x, c, s) t_0 = Float64(Float64(x * c) * s) tmp = 0.0 if (Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x))) <= -2e-221) tmp = Float64(Float64(-2.0 * Float64(x * x)) / Float64(t_0 * t_0)); else tmp = Float64(Float64(c * x) * s) ^ -2.0; end return tmp end
function tmp_2 = code(x, c, s) t_0 = (x * c) * s; tmp = 0.0; if ((cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x))) <= -2e-221) tmp = (-2.0 * (x * x)) / (t_0 * t_0); else tmp = ((c * x) * s) ^ -2.0; end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[(N[(x * c), $MachinePrecision] * s), $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-221], N[(N[(-2.0 * N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[Power[N[(N[(c * x), $MachinePrecision] * s), $MachinePrecision], -2.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot c\right) \cdot s\\
\mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \leq -2 \cdot 10^{-221}:\\
\;\;\;\;\frac{-2 \cdot \left(x \cdot x\right)}{t\_0 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;{\left(\left(c \cdot x\right) \cdot s\right)}^{-2}\\
\end{array}
\end{array}
if (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < -2.00000000000000003e-221Initial program 68.7%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
unpow2N/A
unswap-sqrN/A
unpow2N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6499.1
Applied rewrites99.1%
lift-*.f64N/A
count-2N/A
lower-+.f6499.1
Applied rewrites99.1%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6443.9
Applied rewrites43.9%
Taylor expanded in x around inf
Applied rewrites43.9%
if -2.00000000000000003e-221 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) Initial program 70.7%
Taylor expanded in x around 0
associate-*r*N/A
associate-/l/N/A
unpow2N/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6472.4
Applied rewrites72.4%
Applied rewrites86.5%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (* (* x c) s)) (t_1 (* t_0 t_0)))
(if (<= (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))) -2e-221)
(/ (* -2.0 (* x x)) t_1)
(/ 1.0 t_1))))
double code(double x, double c, double s) {
double t_0 = (x * c) * s;
double t_1 = t_0 * t_0;
double tmp;
if ((cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x))) <= -2e-221) {
tmp = (-2.0 * (x * x)) / t_1;
} else {
tmp = 1.0 / t_1;
}
return tmp;
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (x * c) * s
t_1 = t_0 * t_0
if ((cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))) <= (-2d-221)) then
tmp = ((-2.0d0) * (x * x)) / t_1
else
tmp = 1.0d0 / t_1
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double t_0 = (x * c) * s;
double t_1 = t_0 * t_0;
double tmp;
if ((Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x))) <= -2e-221) {
tmp = (-2.0 * (x * x)) / t_1;
} else {
tmp = 1.0 / t_1;
}
return tmp;
}
def code(x, c, s): t_0 = (x * c) * s t_1 = t_0 * t_0 tmp = 0 if (math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))) <= -2e-221: tmp = (-2.0 * (x * x)) / t_1 else: tmp = 1.0 / t_1 return tmp
function code(x, c, s) t_0 = Float64(Float64(x * c) * s) t_1 = Float64(t_0 * t_0) tmp = 0.0 if (Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x))) <= -2e-221) tmp = Float64(Float64(-2.0 * Float64(x * x)) / t_1); else tmp = Float64(1.0 / t_1); end return tmp end
function tmp_2 = code(x, c, s) t_0 = (x * c) * s; t_1 = t_0 * t_0; tmp = 0.0; if ((cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x))) <= -2e-221) tmp = (-2.0 * (x * x)) / t_1; else tmp = 1.0 / t_1; end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[(N[(x * c), $MachinePrecision] * s), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * t$95$0), $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-221], N[(N[(-2.0 * N[(x * x), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], N[(1.0 / t$95$1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot c\right) \cdot s\\
t_1 := t\_0 \cdot t\_0\\
\mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \leq -2 \cdot 10^{-221}:\\
\;\;\;\;\frac{-2 \cdot \left(x \cdot x\right)}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t\_1}\\
\end{array}
\end{array}
if (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < -2.00000000000000003e-221Initial program 68.7%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
unpow2N/A
unswap-sqrN/A
unpow2N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6499.1
Applied rewrites99.1%
lift-*.f64N/A
count-2N/A
lower-+.f6499.1
Applied rewrites99.1%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6443.9
Applied rewrites43.9%
Taylor expanded in x around inf
Applied rewrites43.9%
if -2.00000000000000003e-221 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) Initial program 70.7%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
unpow2N/A
unswap-sqrN/A
unpow2N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6498.8
Applied rewrites98.8%
Taylor expanded in x around 0
Applied rewrites86.5%
Final simplification84.0%
(FPCore (x c s) :precision binary64 (if (<= x 5e-56) (pow (* (* s x) c) -2.0) (/ (cos (+ x x)) (* (* (* x c) s) (* (* s c) x)))))
double code(double x, double c, double s) {
double tmp;
if (x <= 5e-56) {
tmp = pow(((s * x) * c), -2.0);
} else {
tmp = cos((x + x)) / (((x * c) * s) * ((s * c) * x));
}
return tmp;
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: tmp
if (x <= 5d-56) then
tmp = ((s * x) * c) ** (-2.0d0)
else
tmp = cos((x + x)) / (((x * c) * s) * ((s * c) * x))
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double tmp;
if (x <= 5e-56) {
tmp = Math.pow(((s * x) * c), -2.0);
} else {
tmp = Math.cos((x + x)) / (((x * c) * s) * ((s * c) * x));
}
return tmp;
}
def code(x, c, s): tmp = 0 if x <= 5e-56: tmp = math.pow(((s * x) * c), -2.0) else: tmp = math.cos((x + x)) / (((x * c) * s) * ((s * c) * x)) return tmp
function code(x, c, s) tmp = 0.0 if (x <= 5e-56) tmp = Float64(Float64(s * x) * c) ^ -2.0; else tmp = Float64(cos(Float64(x + x)) / Float64(Float64(Float64(x * c) * s) * Float64(Float64(s * c) * x))); end return tmp end
function tmp_2 = code(x, c, s) tmp = 0.0; if (x <= 5e-56) tmp = ((s * x) * c) ^ -2.0; else tmp = cos((x + x)) / (((x * c) * s) * ((s * c) * x)); end tmp_2 = tmp; end
code[x_, c_, s_] := If[LessEqual[x, 5e-56], N[Power[N[(N[(s * x), $MachinePrecision] * c), $MachinePrecision], -2.0], $MachinePrecision], N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[(N[(N[(x * c), $MachinePrecision] * s), $MachinePrecision] * N[(N[(s * c), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{-56}:\\
\;\;\;\;{\left(\left(s \cdot x\right) \cdot c\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x + x\right)}{\left(\left(x \cdot c\right) \cdot s\right) \cdot \left(\left(s \cdot c\right) \cdot x\right)}\\
\end{array}
\end{array}
if x < 4.99999999999999997e-56Initial program 70.2%
Taylor expanded in x around 0
associate-*r*N/A
associate-/l/N/A
unpow2N/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6468.7
Applied rewrites68.7%
Applied rewrites86.8%
Applied rewrites85.1%
if 4.99999999999999997e-56 < x Initial program 71.3%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
unpow2N/A
unswap-sqrN/A
unpow2N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6497.4
Applied rewrites97.4%
Applied rewrites95.3%
lift-*.f64N/A
count-2N/A
lift-+.f6495.3
Applied rewrites95.3%
Applied rewrites94.3%
(FPCore (x c s) :precision binary64 (if (<= x 1.16e-17) (pow (* (* s x) c) -2.0) (/ (cos (+ x x)) (* x (* (* s c) (* (* c x) s))))))
double code(double x, double c, double s) {
double tmp;
if (x <= 1.16e-17) {
tmp = pow(((s * x) * c), -2.0);
} else {
tmp = cos((x + x)) / (x * ((s * c) * ((c * x) * s)));
}
return tmp;
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: tmp
if (x <= 1.16d-17) then
tmp = ((s * x) * c) ** (-2.0d0)
else
tmp = cos((x + x)) / (x * ((s * c) * ((c * x) * s)))
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double tmp;
if (x <= 1.16e-17) {
tmp = Math.pow(((s * x) * c), -2.0);
} else {
tmp = Math.cos((x + x)) / (x * ((s * c) * ((c * x) * s)));
}
return tmp;
}
def code(x, c, s): tmp = 0 if x <= 1.16e-17: tmp = math.pow(((s * x) * c), -2.0) else: tmp = math.cos((x + x)) / (x * ((s * c) * ((c * x) * s))) return tmp
function code(x, c, s) tmp = 0.0 if (x <= 1.16e-17) tmp = Float64(Float64(s * x) * c) ^ -2.0; else tmp = Float64(cos(Float64(x + x)) / Float64(x * Float64(Float64(s * c) * Float64(Float64(c * x) * s)))); end return tmp end
function tmp_2 = code(x, c, s) tmp = 0.0; if (x <= 1.16e-17) tmp = ((s * x) * c) ^ -2.0; else tmp = cos((x + x)) / (x * ((s * c) * ((c * x) * s))); end tmp_2 = tmp; end
code[x_, c_, s_] := If[LessEqual[x, 1.16e-17], N[Power[N[(N[(s * x), $MachinePrecision] * c), $MachinePrecision], -2.0], $MachinePrecision], N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[(x * N[(N[(s * c), $MachinePrecision] * N[(N[(c * x), $MachinePrecision] * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.16 \cdot 10^{-17}:\\
\;\;\;\;{\left(\left(s \cdot x\right) \cdot c\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x + x\right)}{x \cdot \left(\left(s \cdot c\right) \cdot \left(\left(c \cdot x\right) \cdot s\right)\right)}\\
\end{array}
\end{array}
if x < 1.16e-17Initial program 70.8%
Taylor expanded in x around 0
associate-*r*N/A
associate-/l/N/A
unpow2N/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6469.4
Applied rewrites69.4%
Applied rewrites87.3%
Applied rewrites85.7%
if 1.16e-17 < x Initial program 70.0%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
unpow2N/A
unswap-sqrN/A
unpow2N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6497.2
Applied rewrites97.2%
lift-*.f64N/A
count-2N/A
lower-+.f6497.2
Applied rewrites97.2%
Applied rewrites90.3%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* (* x c) s))) (/ 1.0 (* t_0 t_0))))
double code(double x, double c, double s) {
double t_0 = (x * c) * s;
return 1.0 / (t_0 * t_0);
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
t_0 = (x * c) * s
code = 1.0d0 / (t_0 * t_0)
end function
public static double code(double x, double c, double s) {
double t_0 = (x * c) * s;
return 1.0 / (t_0 * t_0);
}
def code(x, c, s): t_0 = (x * c) * s return 1.0 / (t_0 * t_0)
function code(x, c, s) t_0 = Float64(Float64(x * c) * s) return Float64(1.0 / Float64(t_0 * t_0)) end
function tmp = code(x, c, s) t_0 = (x * c) * s; tmp = 1.0 / (t_0 * t_0); end
code[x_, c_, s_] := Block[{t$95$0 = N[(N[(x * c), $MachinePrecision] * s), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot c\right) \cdot s\\
\frac{1}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 70.6%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
unpow2N/A
unswap-sqrN/A
unpow2N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6498.9
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites81.5%
Final simplification81.5%
(FPCore (x c s) :precision binary64 (/ 1.0 (* x (* (* s c) (* (* c x) s)))))
double code(double x, double c, double s) {
return 1.0 / (x * ((s * c) * ((c * x) * s)));
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = 1.0d0 / (x * ((s * c) * ((c * x) * s)))
end function
public static double code(double x, double c, double s) {
return 1.0 / (x * ((s * c) * ((c * x) * s)));
}
def code(x, c, s): return 1.0 / (x * ((s * c) * ((c * x) * s)))
function code(x, c, s) return Float64(1.0 / Float64(x * Float64(Float64(s * c) * Float64(Float64(c * x) * s)))) end
function tmp = code(x, c, s) tmp = 1.0 / (x * ((s * c) * ((c * x) * s))); end
code[x_, c_, s_] := N[(1.0 / N[(x * N[(N[(s * c), $MachinePrecision] * N[(N[(c * x), $MachinePrecision] * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot \left(\left(s \cdot c\right) \cdot \left(\left(c \cdot x\right) \cdot s\right)\right)}
\end{array}
Initial program 70.6%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
unpow2N/A
unswap-sqrN/A
unpow2N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6498.9
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites81.5%
Applied rewrites78.6%
Final simplification78.6%
(FPCore (x c s) :precision binary64 (/ 1.0 (* x (* c (* (* (* c x) s) s)))))
double code(double x, double c, double s) {
return 1.0 / (x * (c * (((c * x) * s) * s)));
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = 1.0d0 / (x * (c * (((c * x) * s) * s)))
end function
public static double code(double x, double c, double s) {
return 1.0 / (x * (c * (((c * x) * s) * s)));
}
def code(x, c, s): return 1.0 / (x * (c * (((c * x) * s) * s)))
function code(x, c, s) return Float64(1.0 / Float64(x * Float64(c * Float64(Float64(Float64(c * x) * s) * s)))) end
function tmp = code(x, c, s) tmp = 1.0 / (x * (c * (((c * x) * s) * s))); end
code[x_, c_, s_] := N[(1.0 / N[(x * N[(c * N[(N[(N[(c * x), $MachinePrecision] * s), $MachinePrecision] * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot \left(c \cdot \left(\left(\left(c \cdot x\right) \cdot s\right) \cdot s\right)\right)}
\end{array}
Initial program 70.6%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
unpow2N/A
unswap-sqrN/A
unpow2N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6498.9
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites81.5%
Applied rewrites77.0%
Final simplification77.0%
(FPCore (x c s) :precision binary64 (/ 1.0 (* x (* (* (* (* c x) c) s) s))))
double code(double x, double c, double s) {
return 1.0 / (x * ((((c * x) * c) * s) * s));
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = 1.0d0 / (x * ((((c * x) * c) * s) * s))
end function
public static double code(double x, double c, double s) {
return 1.0 / (x * ((((c * x) * c) * s) * s));
}
def code(x, c, s): return 1.0 / (x * ((((c * x) * c) * s) * s))
function code(x, c, s) return Float64(1.0 / Float64(x * Float64(Float64(Float64(Float64(c * x) * c) * s) * s))) end
function tmp = code(x, c, s) tmp = 1.0 / (x * ((((c * x) * c) * s) * s)); end
code[x_, c_, s_] := N[(1.0 / N[(x * N[(N[(N[(N[(c * x), $MachinePrecision] * c), $MachinePrecision] * s), $MachinePrecision] * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot \left(\left(\left(\left(c \cdot x\right) \cdot c\right) \cdot s\right) \cdot s\right)}
\end{array}
Initial program 70.6%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
unpow2N/A
unswap-sqrN/A
unpow2N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6498.9
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites81.5%
Applied rewrites77.0%
Taylor expanded in x around 0
Applied rewrites74.5%
Final simplification74.5%
herbie shell --seed 2024313
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))