
(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 9 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}
s_m = (fabs.f64 s) NOTE: x, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x c s_m) :precision binary64 (let* ((t_0 (* (* c x) s_m))) (/ (cos (+ x x)) (* t_0 t_0))))
s_m = fabs(s);
assert(x < c && c < s_m);
double code(double x, double c, double s_m) {
double t_0 = (c * x) * s_m;
return cos((x + x)) / (t_0 * t_0);
}
s_m = abs(s)
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s_m
real(8) :: t_0
t_0 = (c * x) * s_m
code = cos((x + x)) / (t_0 * t_0)
end function
s_m = Math.abs(s);
assert x < c && c < s_m;
public static double code(double x, double c, double s_m) {
double t_0 = (c * x) * s_m;
return Math.cos((x + x)) / (t_0 * t_0);
}
s_m = math.fabs(s) [x, c, s_m] = sort([x, c, s_m]) def code(x, c, s_m): t_0 = (c * x) * s_m return math.cos((x + x)) / (t_0 * t_0)
s_m = abs(s) x, c, s_m = sort([x, c, s_m]) function code(x, c, s_m) t_0 = Float64(Float64(c * x) * s_m) return Float64(cos(Float64(x + x)) / Float64(t_0 * t_0)) end
s_m = abs(s);
x, c, s_m = num2cell(sort([x, c, s_m])){:}
function tmp = code(x, c, s_m)
t_0 = (c * x) * s_m;
tmp = cos((x + x)) / (t_0 * t_0);
end
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
code[x_, c_, s$95$m_] := Block[{t$95$0 = N[(N[(c * x), $MachinePrecision] * s$95$m), $MachinePrecision]}, N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
s_m = \left|s\right|
\\
[x, c, s_m] = \mathsf{sort}([x, c, s_m])\\
\\
\begin{array}{l}
t_0 := \left(c \cdot x\right) \cdot s\_m\\
\frac{\cos \left(x + x\right)}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 69.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.6
Applied rewrites98.6%
lift-*.f64N/A
count-2N/A
lift-+.f6498.6
Applied rewrites98.6%
Final simplification98.6%
s_m = (fabs.f64 s)
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c s_m)
:precision binary64
(let* ((t_0 (* (* c x) s_m)))
(if (<=
(/ (cos (* 2.0 x)) (* (* (* (pow s_m 2.0) x) x) (pow c 2.0)))
-4e-232)
(/ (* (* x x) -2.0) (* t_0 t_0))
(/ (/ 1.0 t_0) t_0))))s_m = fabs(s);
assert(x < c && c < s_m);
double code(double x, double c, double s_m) {
double t_0 = (c * x) * s_m;
double tmp;
if ((cos((2.0 * x)) / (((pow(s_m, 2.0) * x) * x) * pow(c, 2.0))) <= -4e-232) {
tmp = ((x * x) * -2.0) / (t_0 * t_0);
} else {
tmp = (1.0 / t_0) / t_0;
}
return tmp;
}
s_m = abs(s)
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s_m
real(8) :: t_0
real(8) :: tmp
t_0 = (c * x) * s_m
if ((cos((2.0d0 * x)) / ((((s_m ** 2.0d0) * x) * x) * (c ** 2.0d0))) <= (-4d-232)) then
tmp = ((x * x) * (-2.0d0)) / (t_0 * t_0)
else
tmp = (1.0d0 / t_0) / t_0
end if
code = tmp
end function
s_m = Math.abs(s);
assert x < c && c < s_m;
public static double code(double x, double c, double s_m) {
double t_0 = (c * x) * s_m;
double tmp;
if ((Math.cos((2.0 * x)) / (((Math.pow(s_m, 2.0) * x) * x) * Math.pow(c, 2.0))) <= -4e-232) {
tmp = ((x * x) * -2.0) / (t_0 * t_0);
} else {
tmp = (1.0 / t_0) / t_0;
}
return tmp;
}
s_m = math.fabs(s) [x, c, s_m] = sort([x, c, s_m]) def code(x, c, s_m): t_0 = (c * x) * s_m tmp = 0 if (math.cos((2.0 * x)) / (((math.pow(s_m, 2.0) * x) * x) * math.pow(c, 2.0))) <= -4e-232: tmp = ((x * x) * -2.0) / (t_0 * t_0) else: tmp = (1.0 / t_0) / t_0 return tmp
s_m = abs(s) x, c, s_m = sort([x, c, s_m]) function code(x, c, s_m) t_0 = Float64(Float64(c * x) * s_m) tmp = 0.0 if (Float64(cos(Float64(2.0 * x)) / Float64(Float64(Float64((s_m ^ 2.0) * x) * x) * (c ^ 2.0))) <= -4e-232) tmp = Float64(Float64(Float64(x * x) * -2.0) / Float64(t_0 * t_0)); else tmp = Float64(Float64(1.0 / t_0) / t_0); end return tmp end
s_m = abs(s);
x, c, s_m = num2cell(sort([x, c, s_m])){:}
function tmp_2 = code(x, c, s_m)
t_0 = (c * x) * s_m;
tmp = 0.0;
if ((cos((2.0 * x)) / ((((s_m ^ 2.0) * x) * x) * (c ^ 2.0))) <= -4e-232)
tmp = ((x * x) * -2.0) / (t_0 * t_0);
else
tmp = (1.0 / t_0) / t_0;
end
tmp_2 = tmp;
end
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
code[x_, c_, s$95$m_] := Block[{t$95$0 = N[(N[(c * x), $MachinePrecision] * s$95$m), $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[(N[(N[Power[s$95$m, 2.0], $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -4e-232], N[(N[(N[(x * x), $MachinePrecision] * -2.0), $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}
s_m = \left|s\right|
\\
[x, c, s_m] = \mathsf{sort}([x, c, s_m])\\
\\
\begin{array}{l}
t_0 := \left(c \cdot x\right) \cdot s\_m\\
\mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{\left(\left({s\_m}^{2} \cdot x\right) \cdot x\right) \cdot {c}^{2}} \leq -4 \cdot 10^{-232}:\\
\;\;\;\;\frac{\left(x \cdot x\right) \cdot -2}{t\_0 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{t\_0}}{t\_0}\\
\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))) < -4.0000000000000001e-232Initial program 70.2%
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.4
Applied rewrites99.4%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6447.4
Applied rewrites47.4%
Taylor expanded in x around inf
Applied rewrites47.4%
if -4.0000000000000001e-232 < (/.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 69.6%
Taylor expanded in x around 0
lower-/.f64N/A
*-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-*.f6487.7
Applied rewrites87.7%
Applied rewrites87.9%
Final simplification85.4%
s_m = (fabs.f64 s)
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c s_m)
:precision binary64
(let* ((t_0 (* (* c x) s_m)))
(if (<= (pow s_m 2.0) 2e+250)
(/ (cos (+ x x)) (* (* (* c c) x) (* (* s_m s_m) x)))
(/ (/ 1.0 t_0) t_0))))s_m = fabs(s);
assert(x < c && c < s_m);
double code(double x, double c, double s_m) {
double t_0 = (c * x) * s_m;
double tmp;
if (pow(s_m, 2.0) <= 2e+250) {
tmp = cos((x + x)) / (((c * c) * x) * ((s_m * s_m) * x));
} else {
tmp = (1.0 / t_0) / t_0;
}
return tmp;
}
s_m = abs(s)
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s_m
real(8) :: t_0
real(8) :: tmp
t_0 = (c * x) * s_m
if ((s_m ** 2.0d0) <= 2d+250) then
tmp = cos((x + x)) / (((c * c) * x) * ((s_m * s_m) * x))
else
tmp = (1.0d0 / t_0) / t_0
end if
code = tmp
end function
s_m = Math.abs(s);
assert x < c && c < s_m;
public static double code(double x, double c, double s_m) {
double t_0 = (c * x) * s_m;
double tmp;
if (Math.pow(s_m, 2.0) <= 2e+250) {
tmp = Math.cos((x + x)) / (((c * c) * x) * ((s_m * s_m) * x));
} else {
tmp = (1.0 / t_0) / t_0;
}
return tmp;
}
s_m = math.fabs(s) [x, c, s_m] = sort([x, c, s_m]) def code(x, c, s_m): t_0 = (c * x) * s_m tmp = 0 if math.pow(s_m, 2.0) <= 2e+250: tmp = math.cos((x + x)) / (((c * c) * x) * ((s_m * s_m) * x)) else: tmp = (1.0 / t_0) / t_0 return tmp
s_m = abs(s) x, c, s_m = sort([x, c, s_m]) function code(x, c, s_m) t_0 = Float64(Float64(c * x) * s_m) tmp = 0.0 if ((s_m ^ 2.0) <= 2e+250) tmp = Float64(cos(Float64(x + x)) / Float64(Float64(Float64(c * c) * x) * Float64(Float64(s_m * s_m) * x))); else tmp = Float64(Float64(1.0 / t_0) / t_0); end return tmp end
s_m = abs(s);
x, c, s_m = num2cell(sort([x, c, s_m])){:}
function tmp_2 = code(x, c, s_m)
t_0 = (c * x) * s_m;
tmp = 0.0;
if ((s_m ^ 2.0) <= 2e+250)
tmp = cos((x + x)) / (((c * c) * x) * ((s_m * s_m) * x));
else
tmp = (1.0 / t_0) / t_0;
end
tmp_2 = tmp;
end
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
code[x_, c_, s$95$m_] := Block[{t$95$0 = N[(N[(c * x), $MachinePrecision] * s$95$m), $MachinePrecision]}, If[LessEqual[N[Power[s$95$m, 2.0], $MachinePrecision], 2e+250], N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[(N[(N[(c * c), $MachinePrecision] * x), $MachinePrecision] * N[(N[(s$95$m * s$95$m), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}
s_m = \left|s\right|
\\
[x, c, s_m] = \mathsf{sort}([x, c, s_m])\\
\\
\begin{array}{l}
t_0 := \left(c \cdot x\right) \cdot s\_m\\
\mathbf{if}\;{s\_m}^{2} \leq 2 \cdot 10^{+250}:\\
\;\;\;\;\frac{\cos \left(x + x\right)}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \left(\left(s\_m \cdot s\_m\right) \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{t\_0}}{t\_0}\\
\end{array}
\end{array}
if (pow.f64 s #s(literal 2 binary64)) < 1.9999999999999998e250Initial program 73.2%
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.6
Applied rewrites98.6%
lift-*.f64N/A
count-2N/A
lift-+.f6498.6
Applied rewrites98.6%
Applied rewrites76.1%
if 1.9999999999999998e250 < (pow.f64 s #s(literal 2 binary64)) Initial program 61.0%
Taylor expanded in x around 0
lower-/.f64N/A
*-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-*.f6491.0
Applied rewrites91.0%
Applied rewrites91.8%
Final simplification80.7%
s_m = (fabs.f64 s) NOTE: x, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x c s_m) :precision binary64 (if (<= x 6.9e-155) (/ (/ 1.0 (* (* (* s_m x) c) c)) (* s_m x)) (/ (cos (+ x x)) (* (* (* s_m c) x) (* (* c x) s_m)))))
s_m = fabs(s);
assert(x < c && c < s_m);
double code(double x, double c, double s_m) {
double tmp;
if (x <= 6.9e-155) {
tmp = (1.0 / (((s_m * x) * c) * c)) / (s_m * x);
} else {
tmp = cos((x + x)) / (((s_m * c) * x) * ((c * x) * s_m));
}
return tmp;
}
s_m = abs(s)
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s_m
real(8) :: tmp
if (x <= 6.9d-155) then
tmp = (1.0d0 / (((s_m * x) * c) * c)) / (s_m * x)
else
tmp = cos((x + x)) / (((s_m * c) * x) * ((c * x) * s_m))
end if
code = tmp
end function
s_m = Math.abs(s);
assert x < c && c < s_m;
public static double code(double x, double c, double s_m) {
double tmp;
if (x <= 6.9e-155) {
tmp = (1.0 / (((s_m * x) * c) * c)) / (s_m * x);
} else {
tmp = Math.cos((x + x)) / (((s_m * c) * x) * ((c * x) * s_m));
}
return tmp;
}
s_m = math.fabs(s) [x, c, s_m] = sort([x, c, s_m]) def code(x, c, s_m): tmp = 0 if x <= 6.9e-155: tmp = (1.0 / (((s_m * x) * c) * c)) / (s_m * x) else: tmp = math.cos((x + x)) / (((s_m * c) * x) * ((c * x) * s_m)) return tmp
s_m = abs(s) x, c, s_m = sort([x, c, s_m]) function code(x, c, s_m) tmp = 0.0 if (x <= 6.9e-155) tmp = Float64(Float64(1.0 / Float64(Float64(Float64(s_m * x) * c) * c)) / Float64(s_m * x)); else tmp = Float64(cos(Float64(x + x)) / Float64(Float64(Float64(s_m * c) * x) * Float64(Float64(c * x) * s_m))); end return tmp end
s_m = abs(s);
x, c, s_m = num2cell(sort([x, c, s_m])){:}
function tmp_2 = code(x, c, s_m)
tmp = 0.0;
if (x <= 6.9e-155)
tmp = (1.0 / (((s_m * x) * c) * c)) / (s_m * x);
else
tmp = cos((x + x)) / (((s_m * c) * x) * ((c * x) * s_m));
end
tmp_2 = tmp;
end
s_m = N[Abs[s], $MachinePrecision] NOTE: x, c, and s_m should be sorted in increasing order before calling this function. code[x_, c_, s$95$m_] := If[LessEqual[x, 6.9e-155], N[(N[(1.0 / N[(N[(N[(s$95$m * x), $MachinePrecision] * c), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision] / N[(s$95$m * x), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[(N[(N[(s$95$m * c), $MachinePrecision] * x), $MachinePrecision] * N[(N[(c * x), $MachinePrecision] * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
s_m = \left|s\right|
\\
[x, c, s_m] = \mathsf{sort}([x, c, s_m])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.9 \cdot 10^{-155}:\\
\;\;\;\;\frac{\frac{1}{\left(\left(s\_m \cdot x\right) \cdot c\right) \cdot c}}{s\_m \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x + x\right)}{\left(\left(s\_m \cdot c\right) \cdot x\right) \cdot \left(\left(c \cdot x\right) \cdot s\_m\right)}\\
\end{array}
\end{array}
if x < 6.89999999999999975e-155Initial program 70.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-*.f64N/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites80.4%
Taylor expanded in x around 0
lower-/.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6483.7
Applied rewrites83.7%
if 6.89999999999999975e-155 < x Initial 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-*.f6497.2
Applied rewrites97.2%
lift-*.f64N/A
count-2N/A
lift-+.f6497.2
Applied rewrites97.2%
Applied rewrites96.4%
Final simplification88.6%
s_m = (fabs.f64 s) NOTE: x, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x c s_m) :precision binary64 (let* ((t_0 (* (* c x) s_m))) (/ (/ 1.0 t_0) t_0)))
s_m = fabs(s);
assert(x < c && c < s_m);
double code(double x, double c, double s_m) {
double t_0 = (c * x) * s_m;
return (1.0 / t_0) / t_0;
}
s_m = abs(s)
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s_m
real(8) :: t_0
t_0 = (c * x) * s_m
code = (1.0d0 / t_0) / t_0
end function
s_m = Math.abs(s);
assert x < c && c < s_m;
public static double code(double x, double c, double s_m) {
double t_0 = (c * x) * s_m;
return (1.0 / t_0) / t_0;
}
s_m = math.fabs(s) [x, c, s_m] = sort([x, c, s_m]) def code(x, c, s_m): t_0 = (c * x) * s_m return (1.0 / t_0) / t_0
s_m = abs(s) x, c, s_m = sort([x, c, s_m]) function code(x, c, s_m) t_0 = Float64(Float64(c * x) * s_m) return Float64(Float64(1.0 / t_0) / t_0) end
s_m = abs(s);
x, c, s_m = num2cell(sort([x, c, s_m])){:}
function tmp = code(x, c, s_m)
t_0 = (c * x) * s_m;
tmp = (1.0 / t_0) / t_0;
end
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
code[x_, c_, s$95$m_] := Block[{t$95$0 = N[(N[(c * x), $MachinePrecision] * s$95$m), $MachinePrecision]}, N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
s_m = \left|s\right|
\\
[x, c, s_m] = \mathsf{sort}([x, c, s_m])\\
\\
\begin{array}{l}
t_0 := \left(c \cdot x\right) \cdot s\_m\\
\frac{\frac{1}{t\_0}}{t\_0}
\end{array}
\end{array}
Initial program 69.6%
Taylor expanded in x around 0
lower-/.f64N/A
*-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-*.f6482.2
Applied rewrites82.2%
Applied rewrites82.4%
s_m = (fabs.f64 s) NOTE: x, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x c s_m) :precision binary64 (let* ((t_0 (* (* c x) s_m))) (/ 1.0 (* t_0 t_0))))
s_m = fabs(s);
assert(x < c && c < s_m);
double code(double x, double c, double s_m) {
double t_0 = (c * x) * s_m;
return 1.0 / (t_0 * t_0);
}
s_m = abs(s)
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s_m
real(8) :: t_0
t_0 = (c * x) * s_m
code = 1.0d0 / (t_0 * t_0)
end function
s_m = Math.abs(s);
assert x < c && c < s_m;
public static double code(double x, double c, double s_m) {
double t_0 = (c * x) * s_m;
return 1.0 / (t_0 * t_0);
}
s_m = math.fabs(s) [x, c, s_m] = sort([x, c, s_m]) def code(x, c, s_m): t_0 = (c * x) * s_m return 1.0 / (t_0 * t_0)
s_m = abs(s) x, c, s_m = sort([x, c, s_m]) function code(x, c, s_m) t_0 = Float64(Float64(c * x) * s_m) return Float64(1.0 / Float64(t_0 * t_0)) end
s_m = abs(s);
x, c, s_m = num2cell(sort([x, c, s_m])){:}
function tmp = code(x, c, s_m)
t_0 = (c * x) * s_m;
tmp = 1.0 / (t_0 * t_0);
end
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
code[x_, c_, s$95$m_] := Block[{t$95$0 = N[(N[(c * x), $MachinePrecision] * s$95$m), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
s_m = \left|s\right|
\\
[x, c, s_m] = \mathsf{sort}([x, c, s_m])\\
\\
\begin{array}{l}
t_0 := \left(c \cdot x\right) \cdot s\_m\\
\frac{1}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 69.6%
Taylor expanded in x around 0
lower-/.f64N/A
*-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-*.f6482.2
Applied rewrites82.2%
Final simplification82.2%
s_m = (fabs.f64 s) NOTE: x, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x c s_m) :precision binary64 (/ 1.0 (* (* (* s_m c) x) (* (* c x) s_m))))
s_m = fabs(s);
assert(x < c && c < s_m);
double code(double x, double c, double s_m) {
return 1.0 / (((s_m * c) * x) * ((c * x) * s_m));
}
s_m = abs(s)
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s_m
code = 1.0d0 / (((s_m * c) * x) * ((c * x) * s_m))
end function
s_m = Math.abs(s);
assert x < c && c < s_m;
public static double code(double x, double c, double s_m) {
return 1.0 / (((s_m * c) * x) * ((c * x) * s_m));
}
s_m = math.fabs(s) [x, c, s_m] = sort([x, c, s_m]) def code(x, c, s_m): return 1.0 / (((s_m * c) * x) * ((c * x) * s_m))
s_m = abs(s) x, c, s_m = sort([x, c, s_m]) function code(x, c, s_m) return Float64(1.0 / Float64(Float64(Float64(s_m * c) * x) * Float64(Float64(c * x) * s_m))) end
s_m = abs(s);
x, c, s_m = num2cell(sort([x, c, s_m])){:}
function tmp = code(x, c, s_m)
tmp = 1.0 / (((s_m * c) * x) * ((c * x) * s_m));
end
s_m = N[Abs[s], $MachinePrecision] NOTE: x, c, and s_m should be sorted in increasing order before calling this function. code[x_, c_, s$95$m_] := N[(1.0 / N[(N[(N[(s$95$m * c), $MachinePrecision] * x), $MachinePrecision] * N[(N[(c * x), $MachinePrecision] * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
s_m = \left|s\right|
\\
[x, c, s_m] = \mathsf{sort}([x, c, s_m])\\
\\
\frac{1}{\left(\left(s\_m \cdot c\right) \cdot x\right) \cdot \left(\left(c \cdot x\right) \cdot s\_m\right)}
\end{array}
Initial program 69.6%
Taylor expanded in x around 0
lower-/.f64N/A
*-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-*.f6482.2
Applied rewrites82.2%
Applied rewrites80.8%
Final simplification80.8%
s_m = (fabs.f64 s) NOTE: x, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x c s_m) :precision binary64 (/ 1.0 (* (* (* (* s_m c) (* s_m x)) c) x)))
s_m = fabs(s);
assert(x < c && c < s_m);
double code(double x, double c, double s_m) {
return 1.0 / ((((s_m * c) * (s_m * x)) * c) * x);
}
s_m = abs(s)
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s_m
code = 1.0d0 / ((((s_m * c) * (s_m * x)) * c) * x)
end function
s_m = Math.abs(s);
assert x < c && c < s_m;
public static double code(double x, double c, double s_m) {
return 1.0 / ((((s_m * c) * (s_m * x)) * c) * x);
}
s_m = math.fabs(s) [x, c, s_m] = sort([x, c, s_m]) def code(x, c, s_m): return 1.0 / ((((s_m * c) * (s_m * x)) * c) * x)
s_m = abs(s) x, c, s_m = sort([x, c, s_m]) function code(x, c, s_m) return Float64(1.0 / Float64(Float64(Float64(Float64(s_m * c) * Float64(s_m * x)) * c) * x)) end
s_m = abs(s);
x, c, s_m = num2cell(sort([x, c, s_m])){:}
function tmp = code(x, c, s_m)
tmp = 1.0 / ((((s_m * c) * (s_m * x)) * c) * x);
end
s_m = N[Abs[s], $MachinePrecision] NOTE: x, c, and s_m should be sorted in increasing order before calling this function. code[x_, c_, s$95$m_] := N[(1.0 / N[(N[(N[(N[(s$95$m * c), $MachinePrecision] * N[(s$95$m * x), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
s_m = \left|s\right|
\\
[x, c, s_m] = \mathsf{sort}([x, c, s_m])\\
\\
\frac{1}{\left(\left(\left(s\_m \cdot c\right) \cdot \left(s\_m \cdot x\right)\right) \cdot c\right) \cdot x}
\end{array}
Initial program 69.6%
Taylor expanded in x around 0
lower-/.f64N/A
*-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-*.f6482.2
Applied rewrites82.2%
Applied rewrites79.0%
Applied rewrites78.6%
Final simplification78.6%
s_m = (fabs.f64 s) NOTE: x, c, and s_m should be sorted in increasing order before calling this function. (FPCore (x c s_m) :precision binary64 (/ 1.0 (* (* (* (* (* s_m s_m) c) x) c) x)))
s_m = fabs(s);
assert(x < c && c < s_m);
double code(double x, double c, double s_m) {
return 1.0 / (((((s_m * s_m) * c) * x) * c) * x);
}
s_m = abs(s)
NOTE: x, c, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s_m
code = 1.0d0 / (((((s_m * s_m) * c) * x) * c) * x)
end function
s_m = Math.abs(s);
assert x < c && c < s_m;
public static double code(double x, double c, double s_m) {
return 1.0 / (((((s_m * s_m) * c) * x) * c) * x);
}
s_m = math.fabs(s) [x, c, s_m] = sort([x, c, s_m]) def code(x, c, s_m): return 1.0 / (((((s_m * s_m) * c) * x) * c) * x)
s_m = abs(s) x, c, s_m = sort([x, c, s_m]) function code(x, c, s_m) return Float64(1.0 / Float64(Float64(Float64(Float64(Float64(s_m * s_m) * c) * x) * c) * x)) end
s_m = abs(s);
x, c, s_m = num2cell(sort([x, c, s_m])){:}
function tmp = code(x, c, s_m)
tmp = 1.0 / (((((s_m * s_m) * c) * x) * c) * x);
end
s_m = N[Abs[s], $MachinePrecision] NOTE: x, c, and s_m should be sorted in increasing order before calling this function. code[x_, c_, s$95$m_] := N[(1.0 / N[(N[(N[(N[(N[(s$95$m * s$95$m), $MachinePrecision] * c), $MachinePrecision] * x), $MachinePrecision] * c), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
s_m = \left|s\right|
\\
[x, c, s_m] = \mathsf{sort}([x, c, s_m])\\
\\
\frac{1}{\left(\left(\left(\left(s\_m \cdot s\_m\right) \cdot c\right) \cdot x\right) \cdot c\right) \cdot x}
\end{array}
Initial program 69.6%
Taylor expanded in x around 0
lower-/.f64N/A
*-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-*.f6482.2
Applied rewrites82.2%
Applied rewrites79.0%
Applied rewrites71.4%
Final simplification71.4%
herbie shell --seed 2024236
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))