
(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 12 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}
NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (* (pow (* c (* x s)) -2.0) (cos (* x 2.0))))
assert(c < s);
double code(double x, double c, double s) {
return pow((c * (x * s)), -2.0) * cos((x * 2.0));
}
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = ((c * (x * s)) ** (-2.0d0)) * cos((x * 2.0d0))
end function
assert c < s;
public static double code(double x, double c, double s) {
return Math.pow((c * (x * s)), -2.0) * Math.cos((x * 2.0));
}
[c, s] = sort([c, s]) def code(x, c, s): return math.pow((c * (x * s)), -2.0) * math.cos((x * 2.0))
c, s = sort([c, s]) function code(x, c, s) return Float64((Float64(c * Float64(x * s)) ^ -2.0) * cos(Float64(x * 2.0))) end
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = ((c * (x * s)) ^ -2.0) * cos((x * 2.0));
end
NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision] * N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
{\left(c \cdot \left(x \cdot s\right)\right)}^{-2} \cdot \cos \left(x \cdot 2\right)
\end{array}
Initial program 67.6%
*-commutative67.6%
associate-*r*63.4%
associate-*r*62.9%
unpow262.9%
unswap-sqr75.1%
unpow275.1%
swap-sqr95.8%
*-commutative95.8%
*-commutative95.8%
*-commutative95.8%
*-commutative95.8%
Simplified95.8%
Taylor expanded in x around inf 63.4%
unpow263.4%
associate-*r*63.2%
*-commutative63.2%
associate-*r*62.9%
*-commutative62.9%
*-commutative62.9%
unpow262.9%
unpow262.9%
swap-sqr75.1%
swap-sqr95.8%
unpow295.8%
associate-*r*95.7%
*-commutative95.7%
*-commutative95.7%
rem-exp-log83.2%
log-div69.8%
Simplified96.1%
Final simplification96.1%
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
:precision binary64
(let* ((t_0 (cos (* x 2.0))))
(if (<= x -3.7e+148)
(/ t_0 (* x (* c (* c (* s (* x s))))))
(if (<= x -2.8e-33)
(/ t_0 (* s (* (* x x) (* c (* c s)))))
(if (<= x 8e-10)
(pow (* c (* x s)) -2.0)
(/ t_0 (* s (* s (* x (* c (* x c)))))))))))assert(c < s);
double code(double x, double c, double s) {
double t_0 = cos((x * 2.0));
double tmp;
if (x <= -3.7e+148) {
tmp = t_0 / (x * (c * (c * (s * (x * s)))));
} else if (x <= -2.8e-33) {
tmp = t_0 / (s * ((x * x) * (c * (c * s))));
} else if (x <= 8e-10) {
tmp = pow((c * (x * s)), -2.0);
} else {
tmp = t_0 / (s * (s * (x * (c * (x * c)))));
}
return tmp;
}
NOTE: c and s should be sorted in increasing order before calling this function.
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 = cos((x * 2.0d0))
if (x <= (-3.7d+148)) then
tmp = t_0 / (x * (c * (c * (s * (x * s)))))
else if (x <= (-2.8d-33)) then
tmp = t_0 / (s * ((x * x) * (c * (c * s))))
else if (x <= 8d-10) then
tmp = (c * (x * s)) ** (-2.0d0)
else
tmp = t_0 / (s * (s * (x * (c * (x * c)))))
end if
code = tmp
end function
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = Math.cos((x * 2.0));
double tmp;
if (x <= -3.7e+148) {
tmp = t_0 / (x * (c * (c * (s * (x * s)))));
} else if (x <= -2.8e-33) {
tmp = t_0 / (s * ((x * x) * (c * (c * s))));
} else if (x <= 8e-10) {
tmp = Math.pow((c * (x * s)), -2.0);
} else {
tmp = t_0 / (s * (s * (x * (c * (x * c)))));
}
return tmp;
}
[c, s] = sort([c, s]) def code(x, c, s): t_0 = math.cos((x * 2.0)) tmp = 0 if x <= -3.7e+148: tmp = t_0 / (x * (c * (c * (s * (x * s))))) elif x <= -2.8e-33: tmp = t_0 / (s * ((x * x) * (c * (c * s)))) elif x <= 8e-10: tmp = math.pow((c * (x * s)), -2.0) else: tmp = t_0 / (s * (s * (x * (c * (x * c))))) return tmp
c, s = sort([c, s]) function code(x, c, s) t_0 = cos(Float64(x * 2.0)) tmp = 0.0 if (x <= -3.7e+148) tmp = Float64(t_0 / Float64(x * Float64(c * Float64(c * Float64(s * Float64(x * s)))))); elseif (x <= -2.8e-33) tmp = Float64(t_0 / Float64(s * Float64(Float64(x * x) * Float64(c * Float64(c * s))))); elseif (x <= 8e-10) tmp = Float64(c * Float64(x * s)) ^ -2.0; else tmp = Float64(t_0 / Float64(s * Float64(s * Float64(x * Float64(c * Float64(x * c)))))); end return tmp end
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = cos((x * 2.0));
tmp = 0.0;
if (x <= -3.7e+148)
tmp = t_0 / (x * (c * (c * (s * (x * s)))));
elseif (x <= -2.8e-33)
tmp = t_0 / (s * ((x * x) * (c * (c * s))));
elseif (x <= 8e-10)
tmp = (c * (x * s)) ^ -2.0;
else
tmp = t_0 / (s * (s * (x * (c * (x * c)))));
end
tmp_2 = tmp;
end
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -3.7e+148], N[(t$95$0 / N[(x * N[(c * N[(c * N[(s * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2.8e-33], N[(t$95$0 / N[(s * N[(N[(x * x), $MachinePrecision] * N[(c * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8e-10], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(t$95$0 / N[(s * N[(s * N[(x * N[(c * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \cos \left(x \cdot 2\right)\\
\mathbf{if}\;x \leq -3.7 \cdot 10^{+148}:\\
\;\;\;\;\frac{t_0}{x \cdot \left(c \cdot \left(c \cdot \left(s \cdot \left(x \cdot s\right)\right)\right)\right)}\\
\mathbf{elif}\;x \leq -2.8 \cdot 10^{-33}:\\
\;\;\;\;\frac{t_0}{s \cdot \left(\left(x \cdot x\right) \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)}\\
\mathbf{elif}\;x \leq 8 \cdot 10^{-10}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{s \cdot \left(s \cdot \left(x \cdot \left(c \cdot \left(x \cdot c\right)\right)\right)\right)}\\
\end{array}
\end{array}
if x < -3.7000000000000002e148Initial program 62.3%
associate-*r*65.0%
*-commutative65.0%
associate-*r*62.5%
unpow262.5%
unpow262.5%
Simplified62.5%
Taylor expanded in c around 0 62.5%
unpow262.5%
*-commutative62.5%
*-commutative62.5%
*-commutative62.5%
associate-*r*65.0%
unpow265.0%
associate-*l*77.4%
*-commutative77.4%
associate-*l*80.3%
Simplified80.3%
if -3.7000000000000002e148 < x < -2.8e-33Initial program 80.3%
*-commutative80.3%
associate-*l*80.3%
associate-*r*80.4%
*-commutative80.4%
unpow280.4%
associate-*r*82.9%
associate-*r*82.9%
*-commutative82.9%
unpow282.9%
Simplified82.9%
Taylor expanded in c around 0 82.9%
*-commutative82.9%
unpow282.9%
associate-*l*91.3%
Simplified91.3%
if -2.8e-33 < x < 8.00000000000000029e-10Initial program 63.4%
*-commutative63.4%
associate-*r*58.2%
associate-*r*56.8%
unpow256.8%
unswap-sqr71.2%
unpow271.2%
swap-sqr95.5%
*-commutative95.5%
*-commutative95.5%
*-commutative95.5%
*-commutative95.5%
Simplified95.5%
Taylor expanded in x around 0 58.2%
unpow258.2%
unpow258.2%
*-commutative58.2%
unpow258.2%
Simplified58.2%
add-sqr-sqrt58.2%
pow258.2%
sqrt-div58.2%
metadata-eval58.2%
*-commutative58.2%
sqrt-prod58.2%
unswap-sqr74.8%
*-commutative74.8%
*-commutative74.8%
sqrt-prod42.5%
add-sqr-sqrt78.7%
sqrt-prod45.5%
add-sqr-sqrt96.4%
associate-*r*95.8%
pow295.8%
inv-pow95.8%
inv-pow95.8%
Applied egg-rr96.4%
if 8.00000000000000029e-10 < x Initial program 68.3%
*-commutative68.3%
associate-*l*64.0%
associate-*r*65.3%
*-commutative65.3%
unpow265.3%
associate-*r*75.6%
associate-*r*76.9%
*-commutative76.9%
unpow276.9%
Simplified76.9%
Taylor expanded in x around 0 75.6%
*-commutative75.6%
unpow275.6%
associate-*r*79.8%
unpow279.8%
associate-*r*88.0%
*-commutative88.0%
Simplified88.0%
Final simplification91.0%
NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (if (or (<= x -0.46) (not (<= x 8e-10))) (/ (cos (* x 2.0)) (* s (* s (* x (* c (* x c)))))) (pow (* c (* x s)) -2.0)))
assert(c < s);
double code(double x, double c, double s) {
double tmp;
if ((x <= -0.46) || !(x <= 8e-10)) {
tmp = cos((x * 2.0)) / (s * (s * (x * (c * (x * c)))));
} else {
tmp = pow((c * (x * s)), -2.0);
}
return tmp;
}
NOTE: c and s should be sorted in increasing order before calling this function.
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 <= (-0.46d0)) .or. (.not. (x <= 8d-10))) then
tmp = cos((x * 2.0d0)) / (s * (s * (x * (c * (x * c)))))
else
tmp = (c * (x * s)) ** (-2.0d0)
end if
code = tmp
end function
assert c < s;
public static double code(double x, double c, double s) {
double tmp;
if ((x <= -0.46) || !(x <= 8e-10)) {
tmp = Math.cos((x * 2.0)) / (s * (s * (x * (c * (x * c)))));
} else {
tmp = Math.pow((c * (x * s)), -2.0);
}
return tmp;
}
[c, s] = sort([c, s]) def code(x, c, s): tmp = 0 if (x <= -0.46) or not (x <= 8e-10): tmp = math.cos((x * 2.0)) / (s * (s * (x * (c * (x * c))))) else: tmp = math.pow((c * (x * s)), -2.0) return tmp
c, s = sort([c, s]) function code(x, c, s) tmp = 0.0 if ((x <= -0.46) || !(x <= 8e-10)) tmp = Float64(cos(Float64(x * 2.0)) / Float64(s * Float64(s * Float64(x * Float64(c * Float64(x * c)))))); else tmp = Float64(c * Float64(x * s)) ^ -2.0; end return tmp end
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
tmp = 0.0;
if ((x <= -0.46) || ~((x <= 8e-10)))
tmp = cos((x * 2.0)) / (s * (s * (x * (c * (x * c)))));
else
tmp = (c * (x * s)) ^ -2.0;
end
tmp_2 = tmp;
end
NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := If[Or[LessEqual[x, -0.46], N[Not[LessEqual[x, 8e-10]], $MachinePrecision]], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(s * N[(s * N[(x * N[(c * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.46 \lor \neg \left(x \leq 8 \cdot 10^{-10}\right):\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{s \cdot \left(s \cdot \left(x \cdot \left(c \cdot \left(x \cdot c\right)\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\
\end{array}
\end{array}
if x < -0.46000000000000002 or 8.00000000000000029e-10 < x Initial program 70.4%
*-commutative70.4%
associate-*l*66.8%
associate-*r*67.5%
*-commutative67.5%
unpow267.5%
associate-*r*72.8%
associate-*r*72.8%
*-commutative72.8%
unpow272.8%
Simplified72.8%
Taylor expanded in x around 0 72.9%
*-commutative72.9%
unpow272.9%
associate-*r*77.1%
unpow277.1%
associate-*r*85.9%
*-commutative85.9%
Simplified85.9%
if -0.46000000000000002 < x < 8.00000000000000029e-10Initial program 64.0%
*-commutative64.0%
associate-*r*59.1%
associate-*r*57.8%
unpow257.8%
unswap-sqr71.3%
unpow271.3%
swap-sqr95.7%
*-commutative95.7%
*-commutative95.7%
*-commutative95.7%
*-commutative95.7%
Simplified95.7%
Taylor expanded in x around 0 59.1%
unpow259.1%
unpow259.1%
*-commutative59.1%
unpow259.1%
Simplified59.1%
add-sqr-sqrt59.1%
pow259.1%
sqrt-div59.1%
metadata-eval59.1%
*-commutative59.1%
sqrt-prod59.1%
unswap-sqr74.7%
*-commutative74.7%
*-commutative74.7%
sqrt-prod43.4%
add-sqr-sqrt79.1%
sqrt-prod45.1%
add-sqr-sqrt96.5%
associate-*r*95.9%
pow295.9%
inv-pow95.9%
inv-pow95.9%
Applied egg-rr96.5%
Final simplification90.6%
NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (/ (cos (* x 2.0)) (* (* c (* x s)) (* s (* x c)))))
assert(c < s);
double code(double x, double c, double s) {
return cos((x * 2.0)) / ((c * (x * s)) * (s * (x * c)));
}
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = cos((x * 2.0d0)) / ((c * (x * s)) * (s * (x * c)))
end function
assert c < s;
public static double code(double x, double c, double s) {
return Math.cos((x * 2.0)) / ((c * (x * s)) * (s * (x * c)));
}
[c, s] = sort([c, s]) def code(x, c, s): return math.cos((x * 2.0)) / ((c * (x * s)) * (s * (x * c)))
c, s = sort([c, s]) function code(x, c, s) return Float64(cos(Float64(x * 2.0)) / Float64(Float64(c * Float64(x * s)) * Float64(s * Float64(x * c)))) end
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = cos((x * 2.0)) / ((c * (x * s)) * (s * (x * c)));
end
NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision] * N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)}
\end{array}
Initial program 67.6%
*-commutative67.6%
associate-*r*63.4%
associate-*r*62.9%
unpow262.9%
unswap-sqr75.1%
unpow275.1%
swap-sqr95.8%
*-commutative95.8%
*-commutative95.8%
*-commutative95.8%
*-commutative95.8%
Simplified95.8%
Taylor expanded in s around 0 92.4%
Final simplification92.4%
NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (let* ((t_0 (* s (* x c)))) (/ (cos (* x 2.0)) (* t_0 t_0))))
assert(c < s);
double code(double x, double c, double s) {
double t_0 = s * (x * c);
return cos((x * 2.0)) / (t_0 * t_0);
}
NOTE: c and s should be sorted in increasing order before calling this function.
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 = s * (x * c)
code = cos((x * 2.0d0)) / (t_0 * t_0)
end function
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = s * (x * c);
return Math.cos((x * 2.0)) / (t_0 * t_0);
}
[c, s] = sort([c, s]) def code(x, c, s): t_0 = s * (x * c) return math.cos((x * 2.0)) / (t_0 * t_0)
c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(s * Float64(x * c)) return Float64(cos(Float64(x * 2.0)) / Float64(t_0 * t_0)) end
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
t_0 = s * (x * c);
tmp = cos((x * 2.0)) / (t_0 * t_0);
end
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]}, N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := s \cdot \left(x \cdot c\right)\\
\frac{\cos \left(x \cdot 2\right)}{t_0 \cdot t_0}
\end{array}
\end{array}
Initial program 67.6%
*-commutative67.6%
associate-*r*63.4%
associate-*r*62.9%
unpow262.9%
unswap-sqr75.1%
unpow275.1%
swap-sqr95.8%
*-commutative95.8%
*-commutative95.8%
*-commutative95.8%
*-commutative95.8%
Simplified95.8%
Final simplification95.8%
NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (let* ((t_0 (* c (* x s)))) (/ (/ (cos (* x 2.0)) t_0) t_0)))
assert(c < s);
double code(double x, double c, double s) {
double t_0 = c * (x * s);
return (cos((x * 2.0)) / t_0) / t_0;
}
NOTE: c and s should be sorted in increasing order before calling this function.
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 = c * (x * s)
code = (cos((x * 2.0d0)) / t_0) / t_0
end function
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = c * (x * s);
return (Math.cos((x * 2.0)) / t_0) / t_0;
}
[c, s] = sort([c, s]) def code(x, c, s): t_0 = c * (x * s) return (math.cos((x * 2.0)) / t_0) / t_0
c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(c * Float64(x * s)) return Float64(Float64(cos(Float64(x * 2.0)) / t_0) / t_0) end
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
t_0 = c * (x * s);
tmp = (cos((x * 2.0)) / t_0) / t_0;
end
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\frac{\frac{\cos \left(x \cdot 2\right)}{t_0}}{t_0}
\end{array}
\end{array}
Initial program 67.6%
*-commutative67.6%
associate-*r*63.4%
associate-*r*62.9%
unpow262.9%
unswap-sqr75.1%
unpow275.1%
swap-sqr95.8%
*-commutative95.8%
*-commutative95.8%
*-commutative95.8%
*-commutative95.8%
Simplified95.8%
associate-/r*96.0%
div-inv96.0%
*-commutative96.0%
Applied egg-rr96.0%
un-div-inv96.0%
associate-*r*92.5%
*-commutative92.5%
associate-*r*96.1%
*-commutative96.1%
Applied egg-rr96.1%
Final simplification96.1%
NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (pow (* c (* x s)) -2.0))
assert(c < s);
double code(double x, double c, double s) {
return pow((c * (x * s)), -2.0);
}
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = (c * (x * s)) ** (-2.0d0)
end function
assert c < s;
public static double code(double x, double c, double s) {
return Math.pow((c * (x * s)), -2.0);
}
[c, s] = sort([c, s]) def code(x, c, s): return math.pow((c * (x * s)), -2.0)
c, s = sort([c, s]) function code(x, c, s) return Float64(c * Float64(x * s)) ^ -2.0 end
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = (c * (x * s)) ^ -2.0;
end
NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}
\end{array}
Initial program 67.6%
*-commutative67.6%
associate-*r*63.4%
associate-*r*62.9%
unpow262.9%
unswap-sqr75.1%
unpow275.1%
swap-sqr95.8%
*-commutative95.8%
*-commutative95.8%
*-commutative95.8%
*-commutative95.8%
Simplified95.8%
Taylor expanded in x around 0 55.8%
unpow255.8%
unpow255.8%
*-commutative55.8%
unpow255.8%
Simplified55.8%
add-sqr-sqrt55.8%
pow255.8%
sqrt-div55.8%
metadata-eval55.8%
*-commutative55.8%
sqrt-prod55.8%
unswap-sqr65.3%
*-commutative65.3%
*-commutative65.3%
sqrt-prod33.9%
add-sqr-sqrt67.5%
sqrt-prod39.3%
add-sqr-sqrt78.3%
associate-*r*77.9%
pow277.9%
inv-pow77.9%
inv-pow77.9%
Applied egg-rr78.3%
Final simplification78.3%
NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (/ 1.0 (* (* c c) (* (* x x) (* s s)))))
assert(c < s);
double code(double x, double c, double s) {
return 1.0 / ((c * c) * ((x * x) * (s * s)));
}
NOTE: c and s should be sorted in increasing order before calling this function.
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 / ((c * c) * ((x * x) * (s * s)))
end function
assert c < s;
public static double code(double x, double c, double s) {
return 1.0 / ((c * c) * ((x * x) * (s * s)));
}
[c, s] = sort([c, s]) def code(x, c, s): return 1.0 / ((c * c) * ((x * x) * (s * s)))
c, s = sort([c, s]) function code(x, c, s) return Float64(1.0 / Float64(Float64(c * c) * Float64(Float64(x * x) * Float64(s * s)))) end
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = 1.0 / ((c * c) * ((x * x) * (s * s)));
end
NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(1.0 / N[(N[(c * c), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{\left(c \cdot c\right) \cdot \left(\left(x \cdot x\right) \cdot \left(s \cdot s\right)\right)}
\end{array}
Initial program 67.6%
*-commutative67.6%
associate-*r*63.4%
associate-*r*62.9%
unpow262.9%
unswap-sqr75.1%
unpow275.1%
swap-sqr95.8%
*-commutative95.8%
*-commutative95.8%
*-commutative95.8%
*-commutative95.8%
Simplified95.8%
Taylor expanded in x around 0 55.8%
unpow255.8%
unpow255.8%
*-commutative55.8%
unpow255.8%
Simplified55.8%
Final simplification55.8%
NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (/ (/ 1.0 c) (* (* x s) (* s (* x c)))))
assert(c < s);
double code(double x, double c, double s) {
return (1.0 / c) / ((x * s) * (s * (x * c)));
}
NOTE: c and s should be sorted in increasing order before calling this function.
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 / c) / ((x * s) * (s * (x * c)))
end function
assert c < s;
public static double code(double x, double c, double s) {
return (1.0 / c) / ((x * s) * (s * (x * c)));
}
[c, s] = sort([c, s]) def code(x, c, s): return (1.0 / c) / ((x * s) * (s * (x * c)))
c, s = sort([c, s]) function code(x, c, s) return Float64(Float64(1.0 / c) / Float64(Float64(x * s) * Float64(s * Float64(x * c)))) end
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = (1.0 / c) / ((x * s) * (s * (x * c)));
end
NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(N[(1.0 / c), $MachinePrecision] / N[(N[(x * s), $MachinePrecision] * N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\frac{1}{c}}{\left(x \cdot s\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)}
\end{array}
Initial program 67.6%
*-commutative67.6%
associate-*r*63.4%
associate-*r*62.9%
unpow262.9%
unswap-sqr75.1%
unpow275.1%
swap-sqr95.8%
*-commutative95.8%
*-commutative95.8%
*-commutative95.8%
*-commutative95.8%
Simplified95.8%
Taylor expanded in x around 0 55.8%
unpow255.8%
unpow255.8%
*-commutative55.8%
unpow255.8%
Simplified55.8%
add-sqr-sqrt55.8%
pow255.8%
sqrt-div55.8%
metadata-eval55.8%
sqrt-prod55.8%
sqrt-prod28.5%
add-sqr-sqrt60.4%
unswap-sqr71.5%
*-commutative71.5%
*-commutative71.5%
sqrt-prod40.2%
add-sqr-sqrt78.3%
Applied egg-rr78.3%
unpow278.3%
*-commutative78.3%
associate-*r*76.5%
associate-/r*76.5%
frac-times73.7%
*-un-lft-identity73.7%
*-commutative73.7%
Applied egg-rr73.7%
Final simplification73.7%
NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (/ (/ 1.0 s) (* (* x c) (* s (* x c)))))
assert(c < s);
double code(double x, double c, double s) {
return (1.0 / s) / ((x * c) * (s * (x * c)));
}
NOTE: c and s should be sorted in increasing order before calling this function.
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 / s) / ((x * c) * (s * (x * c)))
end function
assert c < s;
public static double code(double x, double c, double s) {
return (1.0 / s) / ((x * c) * (s * (x * c)));
}
[c, s] = sort([c, s]) def code(x, c, s): return (1.0 / s) / ((x * c) * (s * (x * c)))
c, s = sort([c, s]) function code(x, c, s) return Float64(Float64(1.0 / s) / Float64(Float64(x * c) * Float64(s * Float64(x * c)))) end
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = (1.0 / s) / ((x * c) * (s * (x * c)));
end
NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(N[(1.0 / s), $MachinePrecision] / N[(N[(x * c), $MachinePrecision] * N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\frac{1}{s}}{\left(x \cdot c\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)}
\end{array}
Initial program 67.6%
*-commutative67.6%
associate-*r*63.4%
associate-*r*62.9%
unpow262.9%
unswap-sqr75.1%
unpow275.1%
swap-sqr95.8%
*-commutative95.8%
*-commutative95.8%
*-commutative95.8%
*-commutative95.8%
Simplified95.8%
Taylor expanded in x around 0 55.8%
unpow255.8%
unpow255.8%
*-commutative55.8%
unpow255.8%
Simplified55.8%
add-sqr-sqrt55.8%
pow255.8%
sqrt-div55.8%
metadata-eval55.8%
sqrt-prod55.8%
sqrt-prod28.5%
add-sqr-sqrt60.4%
unswap-sqr71.5%
*-commutative71.5%
*-commutative71.5%
sqrt-prod40.2%
add-sqr-sqrt78.3%
Applied egg-rr78.3%
unpow278.3%
*-commutative78.3%
associate-*r*76.5%
*-commutative76.5%
associate-*r*77.9%
associate-/r*77.9%
frac-times75.6%
*-un-lft-identity75.6%
*-commutative75.6%
Applied egg-rr75.6%
Final simplification75.6%
NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (let* ((t_0 (* c (* x s)))) (/ (/ 1.0 t_0) t_0)))
assert(c < s);
double code(double x, double c, double s) {
double t_0 = c * (x * s);
return (1.0 / t_0) / t_0;
}
NOTE: c and s should be sorted in increasing order before calling this function.
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 = c * (x * s)
code = (1.0d0 / t_0) / t_0
end function
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = c * (x * s);
return (1.0 / t_0) / t_0;
}
[c, s] = sort([c, s]) def code(x, c, s): t_0 = c * (x * s) return (1.0 / t_0) / t_0
c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(c * Float64(x * s)) return Float64(Float64(1.0 / t_0) / t_0) end
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
t_0 = c * (x * s);
tmp = (1.0 / t_0) / t_0;
end
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\frac{\frac{1}{t_0}}{t_0}
\end{array}
\end{array}
Initial program 67.6%
*-commutative67.6%
associate-*r*63.4%
associate-*r*62.9%
unpow262.9%
unswap-sqr75.1%
unpow275.1%
swap-sqr95.8%
*-commutative95.8%
*-commutative95.8%
*-commutative95.8%
*-commutative95.8%
Simplified95.8%
associate-/r*96.0%
div-inv96.0%
*-commutative96.0%
Applied egg-rr96.0%
un-div-inv96.0%
associate-*r*92.5%
*-commutative92.5%
associate-*r*96.1%
*-commutative96.1%
Applied egg-rr96.1%
Taylor expanded in x around 0 78.3%
Final simplification78.3%
NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (/ -2.0 (* (* c c) (* s s))))
assert(c < s);
double code(double x, double c, double s) {
return -2.0 / ((c * c) * (s * s));
}
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = (-2.0d0) / ((c * c) * (s * s))
end function
assert c < s;
public static double code(double x, double c, double s) {
return -2.0 / ((c * c) * (s * s));
}
[c, s] = sort([c, s]) def code(x, c, s): return -2.0 / ((c * c) * (s * s))
c, s = sort([c, s]) function code(x, c, s) return Float64(-2.0 / Float64(Float64(c * c) * Float64(s * s))) end
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = -2.0 / ((c * c) * (s * s));
end
NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(-2.0 / N[(N[(c * c), $MachinePrecision] * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{-2}{\left(c \cdot c\right) \cdot \left(s \cdot s\right)}
\end{array}
Initial program 67.6%
*-commutative67.6%
associate-*r*63.4%
associate-*r*62.9%
unpow262.9%
unswap-sqr75.1%
unpow275.1%
swap-sqr95.8%
*-commutative95.8%
*-commutative95.8%
*-commutative95.8%
*-commutative95.8%
Simplified95.8%
associate-/r*96.0%
div-inv96.0%
*-commutative96.0%
Applied egg-rr96.0%
Taylor expanded in x around 0 63.2%
Taylor expanded in x around inf 31.0%
*-commutative31.0%
associate-/r*30.6%
unpow230.6%
unpow230.6%
Simplified30.6%
Taylor expanded in s around 0 31.0%
*-commutative31.0%
unpow231.0%
unpow231.0%
Simplified31.0%
Final simplification31.0%
herbie shell --seed 2023192
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))