
(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 10 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}
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
:precision binary64
(let* ((t_0 (cos (* x 2.0))) (t_1 (* (* s x) c_m)))
(if (<= (/ t_0 (* (* (* (pow s 2.0) x) x) (pow c_m 2.0))) INFINITY)
(/ (/ (cos (+ x x)) t_1) t_1)
(/ 1.0 (/ (pow (* (* s c_m) x) 2.0) t_0)))))c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double t_0 = cos((x * 2.0));
double t_1 = (s * x) * c_m;
double tmp;
if ((t_0 / (((pow(s, 2.0) * x) * x) * pow(c_m, 2.0))) <= ((double) INFINITY)) {
tmp = (cos((x + x)) / t_1) / t_1;
} else {
tmp = 1.0 / (pow(((s * c_m) * x), 2.0) / t_0);
}
return tmp;
}
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double t_0 = Math.cos((x * 2.0));
double t_1 = (s * x) * c_m;
double tmp;
if ((t_0 / (((Math.pow(s, 2.0) * x) * x) * Math.pow(c_m, 2.0))) <= Double.POSITIVE_INFINITY) {
tmp = (Math.cos((x + x)) / t_1) / t_1;
} else {
tmp = 1.0 / (Math.pow(((s * c_m) * x), 2.0) / t_0);
}
return tmp;
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): t_0 = math.cos((x * 2.0)) t_1 = (s * x) * c_m tmp = 0 if (t_0 / (((math.pow(s, 2.0) * x) * x) * math.pow(c_m, 2.0))) <= math.inf: tmp = (math.cos((x + x)) / t_1) / t_1 else: tmp = 1.0 / (math.pow(((s * c_m) * x), 2.0) / t_0) return tmp
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) t_0 = cos(Float64(x * 2.0)) t_1 = Float64(Float64(s * x) * c_m) tmp = 0.0 if (Float64(t_0 / Float64(Float64(Float64((s ^ 2.0) * x) * x) * (c_m ^ 2.0))) <= Inf) tmp = Float64(Float64(cos(Float64(x + x)) / t_1) / t_1); else tmp = Float64(1.0 / Float64((Float64(Float64(s * c_m) * x) ^ 2.0) / t_0)); end return tmp end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp_2 = code(x, c_m, s)
t_0 = cos((x * 2.0));
t_1 = (s * x) * c_m;
tmp = 0.0;
if ((t_0 / ((((s ^ 2.0) * x) * x) * (c_m ^ 2.0))) <= Inf)
tmp = (cos((x + x)) / t_1) / t_1;
else
tmp = 1.0 / ((((s * c_m) * x) ^ 2.0) / t_0);
end
tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(s * x), $MachinePrecision] * c$95$m), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(N[(N[Power[s, 2.0], $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * N[Power[c$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / t$95$1), $MachinePrecision] / t$95$1), $MachinePrecision], N[(1.0 / N[(N[Power[N[(N[(s * c$95$m), $MachinePrecision] * x), $MachinePrecision], 2.0], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := \cos \left(x \cdot 2\right)\\
t_1 := \left(s \cdot x\right) \cdot c\_m\\
\mathbf{if}\;\frac{t\_0}{\left(\left({s}^{2} \cdot x\right) \cdot x\right) \cdot {c\_m}^{2}} \leq \infty:\\
\;\;\;\;\frac{\frac{\cos \left(x + x\right)}{t\_1}}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{{\left(\left(s \cdot c\_m\right) \cdot x\right)}^{2}}{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))) < +inf.0Initial program 82.4%
lift-/.f64N/A
clear-numN/A
frac-2negN/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites97.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-pow.f64N/A
unpow2N/A
mul-1-negN/A
lift-neg.f64N/A
remove-double-negN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.7%
lift-*.f64N/A
count-2N/A
lower-+.f6499.7
Applied rewrites99.7%
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%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f640.0
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
associate-*l*N/A
pow2N/A
*-commutativeN/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f6497.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6497.4
Applied rewrites97.4%
Final simplification99.2%
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
:precision binary64
(let* ((t_0 (cos (* x 2.0))) (t_1 (* (* s x) c_m)))
(if (<= (/ t_0 (* (* (* (pow s 2.0) x) x) (pow c_m 2.0))) INFINITY)
(/ (/ (cos (+ x x)) t_1) t_1)
(/ t_0 (pow (* (* s c_m) x) 2.0)))))c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double t_0 = cos((x * 2.0));
double t_1 = (s * x) * c_m;
double tmp;
if ((t_0 / (((pow(s, 2.0) * x) * x) * pow(c_m, 2.0))) <= ((double) INFINITY)) {
tmp = (cos((x + x)) / t_1) / t_1;
} else {
tmp = t_0 / pow(((s * c_m) * x), 2.0);
}
return tmp;
}
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double t_0 = Math.cos((x * 2.0));
double t_1 = (s * x) * c_m;
double tmp;
if ((t_0 / (((Math.pow(s, 2.0) * x) * x) * Math.pow(c_m, 2.0))) <= Double.POSITIVE_INFINITY) {
tmp = (Math.cos((x + x)) / t_1) / t_1;
} else {
tmp = t_0 / Math.pow(((s * c_m) * x), 2.0);
}
return tmp;
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): t_0 = math.cos((x * 2.0)) t_1 = (s * x) * c_m tmp = 0 if (t_0 / (((math.pow(s, 2.0) * x) * x) * math.pow(c_m, 2.0))) <= math.inf: tmp = (math.cos((x + x)) / t_1) / t_1 else: tmp = t_0 / math.pow(((s * c_m) * x), 2.0) return tmp
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) t_0 = cos(Float64(x * 2.0)) t_1 = Float64(Float64(s * x) * c_m) tmp = 0.0 if (Float64(t_0 / Float64(Float64(Float64((s ^ 2.0) * x) * x) * (c_m ^ 2.0))) <= Inf) tmp = Float64(Float64(cos(Float64(x + x)) / t_1) / t_1); else tmp = Float64(t_0 / (Float64(Float64(s * c_m) * x) ^ 2.0)); end return tmp end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp_2 = code(x, c_m, s)
t_0 = cos((x * 2.0));
t_1 = (s * x) * c_m;
tmp = 0.0;
if ((t_0 / ((((s ^ 2.0) * x) * x) * (c_m ^ 2.0))) <= Inf)
tmp = (cos((x + x)) / t_1) / t_1;
else
tmp = t_0 / (((s * c_m) * x) ^ 2.0);
end
tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(s * x), $MachinePrecision] * c$95$m), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(N[(N[Power[s, 2.0], $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * N[Power[c$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / t$95$1), $MachinePrecision] / t$95$1), $MachinePrecision], N[(t$95$0 / N[Power[N[(N[(s * c$95$m), $MachinePrecision] * x), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := \cos \left(x \cdot 2\right)\\
t_1 := \left(s \cdot x\right) \cdot c\_m\\
\mathbf{if}\;\frac{t\_0}{\left(\left({s}^{2} \cdot x\right) \cdot x\right) \cdot {c\_m}^{2}} \leq \infty:\\
\;\;\;\;\frac{\frac{\cos \left(x + x\right)}{t\_1}}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{{\left(\left(s \cdot c\_m\right) \cdot x\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))) < +inf.0Initial program 82.4%
lift-/.f64N/A
clear-numN/A
frac-2negN/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites97.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-pow.f64N/A
unpow2N/A
mul-1-negN/A
lift-neg.f64N/A
remove-double-negN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.7%
lift-*.f64N/A
count-2N/A
lower-+.f6499.7
Applied rewrites99.7%
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%
lift-*.f64N/A
*-commutativeN/A
lower-*.f640.0
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
associate-*l*N/A
pow2N/A
*-commutativeN/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f6497.4
Applied rewrites97.4%
Final simplification99.2%
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
:precision binary64
(let* ((t_0 (* (* s x) c_m)))
(if (<=
(/ (cos (* x 2.0)) (* (* (* (pow s 2.0) x) x) (pow c_m 2.0)))
-2e-69)
(/ (/ (/ (/ -2.0 s) s) c_m) c_m)
(/ (/ 1.0 t_0) t_0))))c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double t_0 = (s * x) * c_m;
double tmp;
if ((cos((x * 2.0)) / (((pow(s, 2.0) * x) * x) * pow(c_m, 2.0))) <= -2e-69) {
tmp = (((-2.0 / s) / s) / c_m) / c_m;
} else {
tmp = (1.0 / t_0) / t_0;
}
return tmp;
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: tmp
t_0 = (s * x) * c_m
if ((cos((x * 2.0d0)) / ((((s ** 2.0d0) * x) * x) * (c_m ** 2.0d0))) <= (-2d-69)) then
tmp = ((((-2.0d0) / s) / s) / c_m) / c_m
else
tmp = (1.0d0 / t_0) / t_0
end if
code = tmp
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double t_0 = (s * x) * c_m;
double tmp;
if ((Math.cos((x * 2.0)) / (((Math.pow(s, 2.0) * x) * x) * Math.pow(c_m, 2.0))) <= -2e-69) {
tmp = (((-2.0 / s) / s) / c_m) / c_m;
} else {
tmp = (1.0 / t_0) / t_0;
}
return tmp;
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): t_0 = (s * x) * c_m tmp = 0 if (math.cos((x * 2.0)) / (((math.pow(s, 2.0) * x) * x) * math.pow(c_m, 2.0))) <= -2e-69: tmp = (((-2.0 / s) / s) / c_m) / c_m else: tmp = (1.0 / t_0) / t_0 return tmp
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) t_0 = Float64(Float64(s * x) * c_m) tmp = 0.0 if (Float64(cos(Float64(x * 2.0)) / Float64(Float64(Float64((s ^ 2.0) * x) * x) * (c_m ^ 2.0))) <= -2e-69) tmp = Float64(Float64(Float64(Float64(-2.0 / s) / s) / c_m) / c_m); else tmp = Float64(Float64(1.0 / t_0) / t_0); end return tmp end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp_2 = code(x, c_m, s)
t_0 = (s * x) * c_m;
tmp = 0.0;
if ((cos((x * 2.0)) / ((((s ^ 2.0) * x) * x) * (c_m ^ 2.0))) <= -2e-69)
tmp = (((-2.0 / s) / s) / c_m) / c_m;
else
tmp = (1.0 / t_0) / t_0;
end
tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(N[(s * x), $MachinePrecision] * c$95$m), $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(N[(N[(N[Power[s, 2.0], $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * N[Power[c$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-69], N[(N[(N[(N[(-2.0 / s), $MachinePrecision] / s), $MachinePrecision] / c$95$m), $MachinePrecision] / c$95$m), $MachinePrecision], N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := \left(s \cdot x\right) \cdot c\_m\\
\mathbf{if}\;\frac{\cos \left(x \cdot 2\right)}{\left(\left({s}^{2} \cdot x\right) \cdot x\right) \cdot {c\_m}^{2}} \leq -2 \cdot 10^{-69}:\\
\;\;\;\;\frac{\frac{\frac{\frac{-2}{s}}{s}}{c\_m}}{c\_m}\\
\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))) < -1.9999999999999999e-69Initial program 51.5%
lift-/.f64N/A
clear-numN/A
frac-2negN/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites99.1%
Taylor expanded in x around 0
lower-/.f64N/A
Applied rewrites19.9%
Taylor expanded in x around inf
Applied rewrites37.9%
if -1.9999999999999999e-69 < (/.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 67.1%
lift-/.f64N/A
clear-numN/A
frac-2negN/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites97.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-pow.f64N/A
unpow2N/A
mul-1-negN/A
lift-neg.f64N/A
remove-double-negN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites97.3%
Taylor expanded in x around 0
Applied rewrites84.1%
Final simplification80.0%
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
:precision binary64
(let* ((t_0 (* (* s x) c_m)))
(if (<= x 1.1e-26)
(/ (/ 1.0 t_0) t_0)
(if (<= x 1.4e+150)
(/ (cos (+ x x)) (* (* x x) (* (* (* s c_m) s) c_m)))
(/ (/ -1.0 (* (pow (* c_m x) 2.0) s)) (- s))))))c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double t_0 = (s * x) * c_m;
double tmp;
if (x <= 1.1e-26) {
tmp = (1.0 / t_0) / t_0;
} else if (x <= 1.4e+150) {
tmp = cos((x + x)) / ((x * x) * (((s * c_m) * s) * c_m));
} else {
tmp = (-1.0 / (pow((c_m * x), 2.0) * s)) / -s;
}
return tmp;
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: tmp
t_0 = (s * x) * c_m
if (x <= 1.1d-26) then
tmp = (1.0d0 / t_0) / t_0
else if (x <= 1.4d+150) then
tmp = cos((x + x)) / ((x * x) * (((s * c_m) * s) * c_m))
else
tmp = ((-1.0d0) / (((c_m * x) ** 2.0d0) * s)) / -s
end if
code = tmp
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double t_0 = (s * x) * c_m;
double tmp;
if (x <= 1.1e-26) {
tmp = (1.0 / t_0) / t_0;
} else if (x <= 1.4e+150) {
tmp = Math.cos((x + x)) / ((x * x) * (((s * c_m) * s) * c_m));
} else {
tmp = (-1.0 / (Math.pow((c_m * x), 2.0) * s)) / -s;
}
return tmp;
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): t_0 = (s * x) * c_m tmp = 0 if x <= 1.1e-26: tmp = (1.0 / t_0) / t_0 elif x <= 1.4e+150: tmp = math.cos((x + x)) / ((x * x) * (((s * c_m) * s) * c_m)) else: tmp = (-1.0 / (math.pow((c_m * x), 2.0) * s)) / -s return tmp
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) t_0 = Float64(Float64(s * x) * c_m) tmp = 0.0 if (x <= 1.1e-26) tmp = Float64(Float64(1.0 / t_0) / t_0); elseif (x <= 1.4e+150) tmp = Float64(cos(Float64(x + x)) / Float64(Float64(x * x) * Float64(Float64(Float64(s * c_m) * s) * c_m))); else tmp = Float64(Float64(-1.0 / Float64((Float64(c_m * x) ^ 2.0) * s)) / Float64(-s)); end return tmp end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp_2 = code(x, c_m, s)
t_0 = (s * x) * c_m;
tmp = 0.0;
if (x <= 1.1e-26)
tmp = (1.0 / t_0) / t_0;
elseif (x <= 1.4e+150)
tmp = cos((x + x)) / ((x * x) * (((s * c_m) * s) * c_m));
else
tmp = (-1.0 / (((c_m * x) ^ 2.0) * s)) / -s;
end
tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(N[(s * x), $MachinePrecision] * c$95$m), $MachinePrecision]}, If[LessEqual[x, 1.1e-26], N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[x, 1.4e+150], N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[(N[(x * x), $MachinePrecision] * N[(N[(N[(s * c$95$m), $MachinePrecision] * s), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 / N[(N[Power[N[(c$95$m * x), $MachinePrecision], 2.0], $MachinePrecision] * s), $MachinePrecision]), $MachinePrecision] / (-s)), $MachinePrecision]]]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := \left(s \cdot x\right) \cdot c\_m\\
\mathbf{if}\;x \leq 1.1 \cdot 10^{-26}:\\
\;\;\;\;\frac{\frac{1}{t\_0}}{t\_0}\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+150}:\\
\;\;\;\;\frac{\cos \left(x + x\right)}{\left(x \cdot x\right) \cdot \left(\left(\left(s \cdot c\_m\right) \cdot s\right) \cdot c\_m\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-1}{{\left(c\_m \cdot x\right)}^{2} \cdot s}}{-s}\\
\end{array}
\end{array}
if x < 1.1e-26Initial program 62.6%
lift-/.f64N/A
clear-numN/A
frac-2negN/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites96.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-pow.f64N/A
unpow2N/A
mul-1-negN/A
lift-neg.f64N/A
remove-double-negN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites96.6%
Taylor expanded in x around 0
Applied rewrites80.8%
if 1.1e-26 < x < 1.40000000000000005e150Initial program 61.4%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f6495.3
Applied rewrites95.3%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6489.7
Applied rewrites89.7%
lift-*.f64N/A
count-2N/A
lower-+.f6489.7
Applied rewrites89.7%
if 1.40000000000000005e150 < x Initial program 89.1%
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-*.f6475.3
Applied rewrites75.3%
Applied rewrites82.1%
Final simplification82.3%
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
:precision binary64
(let* ((t_0 (* (* c_m x) s)) (t_1 (* (* s x) c_m)))
(if (<= x 3.1e+38)
(/ (/ (cos (+ x x)) t_1) t_1)
(/ (cos (* x 2.0)) (* t_0 t_0)))))c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double t_0 = (c_m * x) * s;
double t_1 = (s * x) * c_m;
double tmp;
if (x <= 3.1e+38) {
tmp = (cos((x + x)) / t_1) / t_1;
} else {
tmp = cos((x * 2.0)) / (t_0 * t_0);
}
return tmp;
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (c_m * x) * s
t_1 = (s * x) * c_m
if (x <= 3.1d+38) then
tmp = (cos((x + x)) / t_1) / t_1
else
tmp = cos((x * 2.0d0)) / (t_0 * t_0)
end if
code = tmp
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double t_0 = (c_m * x) * s;
double t_1 = (s * x) * c_m;
double tmp;
if (x <= 3.1e+38) {
tmp = (Math.cos((x + x)) / t_1) / t_1;
} else {
tmp = Math.cos((x * 2.0)) / (t_0 * t_0);
}
return tmp;
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): t_0 = (c_m * x) * s t_1 = (s * x) * c_m tmp = 0 if x <= 3.1e+38: tmp = (math.cos((x + x)) / t_1) / t_1 else: tmp = math.cos((x * 2.0)) / (t_0 * t_0) return tmp
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) t_0 = Float64(Float64(c_m * x) * s) t_1 = Float64(Float64(s * x) * c_m) tmp = 0.0 if (x <= 3.1e+38) tmp = Float64(Float64(cos(Float64(x + x)) / t_1) / t_1); else tmp = Float64(cos(Float64(x * 2.0)) / Float64(t_0 * t_0)); end return tmp end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp_2 = code(x, c_m, s)
t_0 = (c_m * x) * s;
t_1 = (s * x) * c_m;
tmp = 0.0;
if (x <= 3.1e+38)
tmp = (cos((x + x)) / t_1) / t_1;
else
tmp = cos((x * 2.0)) / (t_0 * t_0);
end
tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(N[(c$95$m * x), $MachinePrecision] * s), $MachinePrecision]}, Block[{t$95$1 = N[(N[(s * x), $MachinePrecision] * c$95$m), $MachinePrecision]}, If[LessEqual[x, 3.1e+38], N[(N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / t$95$1), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := \left(c\_m \cdot x\right) \cdot s\\
t_1 := \left(s \cdot x\right) \cdot c\_m\\
\mathbf{if}\;x \leq 3.1 \cdot 10^{+38}:\\
\;\;\;\;\frac{\frac{\cos \left(x + x\right)}{t\_1}}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{t\_0 \cdot t\_0}\\
\end{array}
\end{array}
if x < 3.10000000000000018e38Initial program 61.7%
lift-/.f64N/A
clear-numN/A
frac-2negN/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites96.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-pow.f64N/A
unpow2N/A
mul-1-negN/A
lift-neg.f64N/A
remove-double-negN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites96.8%
lift-*.f64N/A
count-2N/A
lower-+.f6496.8
Applied rewrites96.8%
if 3.10000000000000018e38 < x Initial program 79.8%
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.8
Applied rewrites99.8%
Final simplification97.5%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (let* ((t_0 (* (* c_m x) s)) (t_1 (* (* s x) c_m))) (if (<= x 5e-14) (/ (/ 1.0 t_1) t_1) (/ (cos (* x 2.0)) (* t_0 t_0)))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double t_0 = (c_m * x) * s;
double t_1 = (s * x) * c_m;
double tmp;
if (x <= 5e-14) {
tmp = (1.0 / t_1) / t_1;
} else {
tmp = cos((x * 2.0)) / (t_0 * t_0);
}
return tmp;
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (c_m * x) * s
t_1 = (s * x) * c_m
if (x <= 5d-14) then
tmp = (1.0d0 / t_1) / t_1
else
tmp = cos((x * 2.0d0)) / (t_0 * t_0)
end if
code = tmp
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double t_0 = (c_m * x) * s;
double t_1 = (s * x) * c_m;
double tmp;
if (x <= 5e-14) {
tmp = (1.0 / t_1) / t_1;
} else {
tmp = Math.cos((x * 2.0)) / (t_0 * t_0);
}
return tmp;
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): t_0 = (c_m * x) * s t_1 = (s * x) * c_m tmp = 0 if x <= 5e-14: tmp = (1.0 / t_1) / t_1 else: tmp = math.cos((x * 2.0)) / (t_0 * t_0) return tmp
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) t_0 = Float64(Float64(c_m * x) * s) t_1 = Float64(Float64(s * x) * c_m) tmp = 0.0 if (x <= 5e-14) tmp = Float64(Float64(1.0 / t_1) / t_1); else tmp = Float64(cos(Float64(x * 2.0)) / Float64(t_0 * t_0)); end return tmp end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp_2 = code(x, c_m, s)
t_0 = (c_m * x) * s;
t_1 = (s * x) * c_m;
tmp = 0.0;
if (x <= 5e-14)
tmp = (1.0 / t_1) / t_1;
else
tmp = cos((x * 2.0)) / (t_0 * t_0);
end
tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(N[(c$95$m * x), $MachinePrecision] * s), $MachinePrecision]}, Block[{t$95$1 = N[(N[(s * x), $MachinePrecision] * c$95$m), $MachinePrecision]}, If[LessEqual[x, 5e-14], N[(N[(1.0 / t$95$1), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := \left(c\_m \cdot x\right) \cdot s\\
t_1 := \left(s \cdot x\right) \cdot c\_m\\
\mathbf{if}\;x \leq 5 \cdot 10^{-14}:\\
\;\;\;\;\frac{\frac{1}{t\_1}}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{t\_0 \cdot t\_0}\\
\end{array}
\end{array}
if x < 5.0000000000000002e-14Initial program 62.1%
lift-/.f64N/A
clear-numN/A
frac-2negN/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites96.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-pow.f64N/A
unpow2N/A
mul-1-negN/A
lift-neg.f64N/A
remove-double-negN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites96.7%
Taylor expanded in x around 0
Applied rewrites81.1%
if 5.0000000000000002e-14 < x Initial program 75.8%
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.6
Applied rewrites99.6%
Final simplification86.0%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (let* ((t_0 (* (* s x) c_m))) (/ (/ 1.0 t_0) t_0)))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double t_0 = (s * x) * c_m;
return (1.0 / t_0) / t_0;
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
real(8) :: t_0
t_0 = (s * x) * c_m
code = (1.0d0 / t_0) / t_0
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double t_0 = (s * x) * c_m;
return (1.0 / t_0) / t_0;
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): t_0 = (s * x) * c_m return (1.0 / t_0) / t_0
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) t_0 = Float64(Float64(s * x) * c_m) return Float64(Float64(1.0 / t_0) / t_0) end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
t_0 = (s * x) * c_m;
tmp = (1.0 / t_0) / t_0;
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(N[(s * x), $MachinePrecision] * c$95$m), $MachinePrecision]}, N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := \left(s \cdot x\right) \cdot c\_m\\
\frac{\frac{1}{t\_0}}{t\_0}
\end{array}
\end{array}
Initial program 65.7%
lift-/.f64N/A
clear-numN/A
frac-2negN/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites97.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-pow.f64N/A
unpow2N/A
mul-1-negN/A
lift-neg.f64N/A
remove-double-negN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites97.4%
Taylor expanded in x around 0
Applied rewrites77.1%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (let* ((t_0 (* (* s x) c_m))) (/ 1.0 (* t_0 t_0))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double t_0 = (s * x) * c_m;
return 1.0 / (t_0 * t_0);
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
real(8) :: t_0
t_0 = (s * x) * c_m
code = 1.0d0 / (t_0 * t_0)
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double t_0 = (s * x) * c_m;
return 1.0 / (t_0 * t_0);
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): t_0 = (s * x) * c_m return 1.0 / (t_0 * t_0)
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) t_0 = Float64(Float64(s * x) * c_m) return Float64(1.0 / Float64(t_0 * t_0)) end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
t_0 = (s * x) * c_m;
tmp = 1.0 / (t_0 * t_0);
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(N[(s * x), $MachinePrecision] * c$95$m), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := \left(s \cdot x\right) \cdot c\_m\\
\frac{1}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 65.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f6479.4
Applied rewrites79.4%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in x around 0
Applied rewrites65.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
pow2N/A
unpow-prod-downN/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lower-*.f6477.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.0
Applied rewrites77.0%
Final simplification77.0%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (/ 1.0 (* (* (* (* (* s c_m) s) x) x) c_m)))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
return 1.0 / (((((s * c_m) * s) * x) * x) * c_m);
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
code = 1.0d0 / (((((s * c_m) * s) * x) * x) * c_m)
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
return 1.0 / (((((s * c_m) * s) * x) * x) * c_m);
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): return 1.0 / (((((s * c_m) * s) * x) * x) * c_m)
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) return Float64(1.0 / Float64(Float64(Float64(Float64(Float64(s * c_m) * s) * x) * x) * c_m)) end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
tmp = 1.0 / (((((s * c_m) * s) * x) * x) * c_m);
end
c_m = N[Abs[c], $MachinePrecision] NOTE: x, c_m, and s should be sorted in increasing order before calling this function. code[x_, c$95$m_, s_] := N[(1.0 / N[(N[(N[(N[(N[(s * c$95$m), $MachinePrecision] * s), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\frac{1}{\left(\left(\left(\left(s \cdot c\_m\right) \cdot s\right) \cdot x\right) \cdot x\right) \cdot c\_m}
\end{array}
Initial program 65.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f6479.4
Applied rewrites79.4%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in x around 0
Applied rewrites65.0%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lower-*.f64N/A
lower-*.f6470.2
Applied rewrites70.2%
Final simplification70.2%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (/ 1.0 (* (* (* (* (* c_m x) x) c_m) s) s)))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
return 1.0 / (((((c_m * x) * x) * c_m) * s) * s);
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
code = 1.0d0 / (((((c_m * x) * x) * c_m) * s) * s)
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
return 1.0 / (((((c_m * x) * x) * c_m) * s) * s);
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): return 1.0 / (((((c_m * x) * x) * c_m) * s) * s)
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) return Float64(1.0 / Float64(Float64(Float64(Float64(Float64(c_m * x) * x) * c_m) * s) * s)) end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
tmp = 1.0 / (((((c_m * x) * x) * c_m) * s) * s);
end
c_m = N[Abs[c], $MachinePrecision] NOTE: x, c_m, and s should be sorted in increasing order before calling this function. code[x_, c$95$m_, s_] := N[(1.0 / N[(N[(N[(N[(N[(c$95$m * x), $MachinePrecision] * x), $MachinePrecision] * c$95$m), $MachinePrecision] * s), $MachinePrecision] * s), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\frac{1}{\left(\left(\left(\left(c\_m \cdot x\right) \cdot x\right) \cdot c\_m\right) \cdot s\right) \cdot s}
\end{array}
Initial program 65.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f6479.4
Applied rewrites79.4%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in x around 0
Applied rewrites65.0%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6469.6
Applied rewrites69.6%
herbie shell --seed 2024332
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))