
(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 13 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: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (if (<= x 3.6e-31) (/ (/ (/ 1.0 c) (* x s)) (* c (* x s))) (* (pow (* s (* x c)) -2.0) (cos (* x 2.0)))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double tmp;
if (x <= 3.6e-31) {
tmp = ((1.0 / c) / (x * s)) / (c * (x * s));
} else {
tmp = pow((s * (x * c)), -2.0) * cos((x * 2.0));
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
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 <= 3.6d-31) then
tmp = ((1.0d0 / c) / (x * s)) / (c * (x * s))
else
tmp = ((s * (x * c)) ** (-2.0d0)) * cos((x * 2.0d0))
end if
code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double tmp;
if (x <= 3.6e-31) {
tmp = ((1.0 / c) / (x * s)) / (c * (x * s));
} else {
tmp = Math.pow((s * (x * c)), -2.0) * Math.cos((x * 2.0));
}
return tmp;
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): tmp = 0 if x <= 3.6e-31: tmp = ((1.0 / c) / (x * s)) / (c * (x * s)) else: tmp = math.pow((s * (x * c)), -2.0) * math.cos((x * 2.0)) return tmp
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) tmp = 0.0 if (x <= 3.6e-31) tmp = Float64(Float64(Float64(1.0 / c) / Float64(x * s)) / Float64(c * Float64(x * s))); else tmp = Float64((Float64(s * Float64(x * c)) ^ -2.0) * cos(Float64(x * 2.0))); end return tmp end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
tmp = 0.0;
if (x <= 3.6e-31)
tmp = ((1.0 / c) / (x * s)) / (c * (x * s));
else
tmp = ((s * (x * c)) ^ -2.0) * cos((x * 2.0));
end
tmp_2 = tmp;
end
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := If[LessEqual[x, 3.6e-31], N[(N[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision] / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision] * N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.6 \cdot 10^{-31}:\\
\;\;\;\;\frac{\frac{\frac{1}{c}}{x \cdot s}}{c \cdot \left(x \cdot s\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left(s \cdot \left(x \cdot c\right)\right)}^{-2} \cdot \cos \left(x \cdot 2\right)\\
\end{array}
\end{array}
if x < 3.60000000000000004e-31Initial program 69.8%
associate-/r*69.9%
unpow269.9%
*-commutative69.9%
unpow269.9%
Simplified69.9%
Taylor expanded in x around 0 62.9%
unpow262.9%
Simplified62.9%
add-sqr-sqrt62.9%
Applied egg-rr82.3%
un-div-inv82.4%
associate-*l*80.7%
associate-*l*82.1%
associate-/r*82.1%
Applied egg-rr82.1%
if 3.60000000000000004e-31 < x Initial program 62.1%
*-commutative62.1%
associate-*r*60.5%
associate-*r*60.4%
unpow260.4%
unswap-sqr73.7%
unpow273.7%
swap-sqr90.2%
*-commutative90.2%
*-commutative90.2%
*-commutative90.2%
*-commutative90.2%
Simplified90.2%
div-inv90.3%
*-commutative90.3%
pow290.3%
pow-flip91.0%
metadata-eval91.0%
Applied egg-rr91.0%
Final simplification84.6%
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
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 2e-33)
(/ (/ (/ 1.0 c) (* x s)) (* c (* x s)))
(if (<= x 9.5e+109)
(/ t_0 (* s (* (* x x) (* c (* c s)))))
(/ t_0 (* s (* s (* (* x c) (* x c)))))))))x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = cos((x * 2.0));
double tmp;
if (x <= 2e-33) {
tmp = ((1.0 / c) / (x * s)) / (c * (x * s));
} else if (x <= 9.5e+109) {
tmp = t_0 / (s * ((x * x) * (c * (c * s))));
} else {
tmp = t_0 / (s * (s * ((x * c) * (x * c))));
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
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 <= 2d-33) then
tmp = ((1.0d0 / c) / (x * s)) / (c * (x * s))
else if (x <= 9.5d+109) then
tmp = t_0 / (s * ((x * x) * (c * (c * s))))
else
tmp = t_0 / (s * (s * ((x * c) * (x * c))))
end if
code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
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 <= 2e-33) {
tmp = ((1.0 / c) / (x * s)) / (c * (x * s));
} else if (x <= 9.5e+109) {
tmp = t_0 / (s * ((x * x) * (c * (c * s))));
} else {
tmp = t_0 / (s * (s * ((x * c) * (x * c))));
}
return tmp;
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = math.cos((x * 2.0)) tmp = 0 if x <= 2e-33: tmp = ((1.0 / c) / (x * s)) / (c * (x * s)) elif x <= 9.5e+109: tmp = t_0 / (s * ((x * x) * (c * (c * s)))) else: tmp = t_0 / (s * (s * ((x * c) * (x * c)))) return tmp
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = cos(Float64(x * 2.0)) tmp = 0.0 if (x <= 2e-33) tmp = Float64(Float64(Float64(1.0 / c) / Float64(x * s)) / Float64(c * Float64(x * s))); elseif (x <= 9.5e+109) tmp = Float64(t_0 / Float64(s * Float64(Float64(x * x) * Float64(c * Float64(c * s))))); else tmp = Float64(t_0 / Float64(s * Float64(s * Float64(Float64(x * c) * Float64(x * c))))); end return tmp end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = cos((x * 2.0));
tmp = 0.0;
if (x <= 2e-33)
tmp = ((1.0 / c) / (x * s)) / (c * (x * s));
elseif (x <= 9.5e+109)
tmp = t_0 / (s * ((x * x) * (c * (c * s))));
else
tmp = t_0 / (s * (s * ((x * c) * (x * c))));
end
tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
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, 2e-33], N[(N[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision] / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 9.5e+109], N[(t$95$0 / N[(s * N[(N[(x * x), $MachinePrecision] * N[(c * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[(s * N[(s * N[(N[(x * c), $MachinePrecision] * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \cos \left(x \cdot 2\right)\\
\mathbf{if}\;x \leq 2 \cdot 10^{-33}:\\
\;\;\;\;\frac{\frac{\frac{1}{c}}{x \cdot s}}{c \cdot \left(x \cdot s\right)}\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{+109}:\\
\;\;\;\;\frac{t_0}{s \cdot \left(\left(x \cdot x\right) \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{s \cdot \left(s \cdot \left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right)\right)}\\
\end{array}
\end{array}
if x < 2.0000000000000001e-33Initial program 69.6%
associate-/r*69.8%
unpow269.8%
*-commutative69.8%
unpow269.8%
Simplified69.8%
Taylor expanded in x around 0 62.7%
unpow262.7%
Simplified62.7%
add-sqr-sqrt62.7%
Applied egg-rr82.2%
un-div-inv82.3%
associate-*l*80.6%
associate-*l*82.0%
associate-/r*82.0%
Applied egg-rr82.0%
if 2.0000000000000001e-33 < x < 9.49999999999999972e109Initial program 66.4%
*-commutative66.4%
associate-*l*66.4%
associate-*r*69.5%
*-commutative69.5%
unpow269.5%
associate-*r*73.6%
associate-*r*76.6%
*-commutative76.6%
unpow276.6%
Simplified76.6%
Taylor expanded in c around 0 76.6%
*-commutative76.6%
unpow276.6%
associate-*l*81.9%
Simplified81.9%
if 9.49999999999999972e109 < x Initial program 59.8%
*-commutative59.8%
associate-*l*57.2%
associate-*r*57.2%
*-commutative57.2%
unpow257.2%
associate-*r*68.4%
associate-*r*68.4%
*-commutative68.4%
unpow268.4%
Simplified68.4%
Taylor expanded in x around 0 63.9%
*-commutative63.9%
unpow263.9%
unpow263.9%
swap-sqr87.5%
unpow287.5%
*-commutative87.5%
Simplified87.5%
unpow287.5%
*-commutative87.5%
*-commutative87.5%
Applied egg-rr87.5%
Final simplification82.9%
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
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))) (t_1 (* c (* x s))))
(if (<= x 3.1e-34)
(/ (/ (/ 1.0 c) (* x s)) t_1)
(if (<= x 1.5e+110)
(/ t_0 (* t_1 (* s (* x c))))
(/ t_0 (* s (* s (* (* x c) (* x c)))))))))x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = cos((x * 2.0));
double t_1 = c * (x * s);
double tmp;
if (x <= 3.1e-34) {
tmp = ((1.0 / c) / (x * s)) / t_1;
} else if (x <= 1.5e+110) {
tmp = t_0 / (t_1 * (s * (x * c)));
} else {
tmp = t_0 / (s * (s * ((x * c) * (x * c))));
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
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) :: t_1
real(8) :: tmp
t_0 = cos((x * 2.0d0))
t_1 = c * (x * s)
if (x <= 3.1d-34) then
tmp = ((1.0d0 / c) / (x * s)) / t_1
else if (x <= 1.5d+110) then
tmp = t_0 / (t_1 * (s * (x * c)))
else
tmp = t_0 / (s * (s * ((x * c) * (x * c))))
end if
code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = Math.cos((x * 2.0));
double t_1 = c * (x * s);
double tmp;
if (x <= 3.1e-34) {
tmp = ((1.0 / c) / (x * s)) / t_1;
} else if (x <= 1.5e+110) {
tmp = t_0 / (t_1 * (s * (x * c)));
} else {
tmp = t_0 / (s * (s * ((x * c) * (x * c))));
}
return tmp;
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = math.cos((x * 2.0)) t_1 = c * (x * s) tmp = 0 if x <= 3.1e-34: tmp = ((1.0 / c) / (x * s)) / t_1 elif x <= 1.5e+110: tmp = t_0 / (t_1 * (s * (x * c))) else: tmp = t_0 / (s * (s * ((x * c) * (x * c)))) return tmp
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = cos(Float64(x * 2.0)) t_1 = Float64(c * Float64(x * s)) tmp = 0.0 if (x <= 3.1e-34) tmp = Float64(Float64(Float64(1.0 / c) / Float64(x * s)) / t_1); elseif (x <= 1.5e+110) tmp = Float64(t_0 / Float64(t_1 * Float64(s * Float64(x * c)))); else tmp = Float64(t_0 / Float64(s * Float64(s * Float64(Float64(x * c) * Float64(x * c))))); end return tmp end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = cos((x * 2.0));
t_1 = c * (x * s);
tmp = 0.0;
if (x <= 3.1e-34)
tmp = ((1.0 / c) / (x * s)) / t_1;
elseif (x <= 1.5e+110)
tmp = t_0 / (t_1 * (s * (x * c)));
else
tmp = t_0 / (s * (s * ((x * c) * (x * c))));
end
tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
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]}, Block[{t$95$1 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 3.1e-34], N[(N[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[x, 1.5e+110], N[(t$95$0 / N[(t$95$1 * N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[(s * N[(s * N[(N[(x * c), $MachinePrecision] * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \cos \left(x \cdot 2\right)\\
t_1 := c \cdot \left(x \cdot s\right)\\
\mathbf{if}\;x \leq 3.1 \cdot 10^{-34}:\\
\;\;\;\;\frac{\frac{\frac{1}{c}}{x \cdot s}}{t_1}\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{+110}:\\
\;\;\;\;\frac{t_0}{t_1 \cdot \left(s \cdot \left(x \cdot c\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{s \cdot \left(s \cdot \left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right)\right)}\\
\end{array}
\end{array}
if x < 3.0999999999999998e-34Initial program 69.6%
associate-/r*69.8%
unpow269.8%
*-commutative69.8%
unpow269.8%
Simplified69.8%
Taylor expanded in x around 0 62.7%
unpow262.7%
Simplified62.7%
add-sqr-sqrt62.7%
Applied egg-rr82.2%
un-div-inv82.3%
associate-*l*80.6%
associate-*l*82.0%
associate-/r*82.0%
Applied egg-rr82.0%
if 3.0999999999999998e-34 < x < 1.50000000000000004e110Initial program 66.4%
*-commutative66.4%
associate-*r*66.4%
associate-*r*69.4%
unpow269.4%
unswap-sqr70.9%
unpow270.9%
swap-sqr88.0%
*-commutative88.0%
*-commutative88.0%
*-commutative88.0%
*-commutative88.0%
Simplified88.0%
Taylor expanded in s around 0 88.1%
if 1.50000000000000004e110 < x Initial program 59.8%
*-commutative59.8%
associate-*l*57.2%
associate-*r*57.2%
*-commutative57.2%
unpow257.2%
associate-*r*68.4%
associate-*r*68.4%
*-commutative68.4%
unpow268.4%
Simplified68.4%
Taylor expanded in x around 0 63.9%
*-commutative63.9%
unpow263.9%
unpow263.9%
swap-sqr87.5%
unpow287.5%
*-commutative87.5%
Simplified87.5%
unpow287.5%
*-commutative87.5%
*-commutative87.5%
Applied egg-rr87.5%
Final simplification83.6%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (if (<= x 3.4e-21) (/ (/ (/ 1.0 c) (* x s)) (* c (* x s))) (* (/ 1.0 s) (/ (cos (* x 2.0)) (* (* x c) (* s (* x c)))))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double tmp;
if (x <= 3.4e-21) {
tmp = ((1.0 / c) / (x * s)) / (c * (x * s));
} else {
tmp = (1.0 / s) * (cos((x * 2.0)) / ((x * c) * (s * (x * c))));
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
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 <= 3.4d-21) then
tmp = ((1.0d0 / c) / (x * s)) / (c * (x * s))
else
tmp = (1.0d0 / s) * (cos((x * 2.0d0)) / ((x * c) * (s * (x * c))))
end if
code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double tmp;
if (x <= 3.4e-21) {
tmp = ((1.0 / c) / (x * s)) / (c * (x * s));
} else {
tmp = (1.0 / s) * (Math.cos((x * 2.0)) / ((x * c) * (s * (x * c))));
}
return tmp;
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): tmp = 0 if x <= 3.4e-21: tmp = ((1.0 / c) / (x * s)) / (c * (x * s)) else: tmp = (1.0 / s) * (math.cos((x * 2.0)) / ((x * c) * (s * (x * c)))) return tmp
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) tmp = 0.0 if (x <= 3.4e-21) tmp = Float64(Float64(Float64(1.0 / c) / Float64(x * s)) / Float64(c * Float64(x * s))); else tmp = Float64(Float64(1.0 / s) * Float64(cos(Float64(x * 2.0)) / Float64(Float64(x * c) * Float64(s * Float64(x * c))))); end return tmp end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
tmp = 0.0;
if (x <= 3.4e-21)
tmp = ((1.0 / c) / (x * s)) / (c * (x * s));
else
tmp = (1.0 / s) * (cos((x * 2.0)) / ((x * c) * (s * (x * c))));
end
tmp_2 = tmp;
end
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := If[LessEqual[x, 3.4e-21], N[(N[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision] / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / s), $MachinePrecision] * N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(N[(x * c), $MachinePrecision] * N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.4 \cdot 10^{-21}:\\
\;\;\;\;\frac{\frac{\frac{1}{c}}{x \cdot s}}{c \cdot \left(x \cdot s\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{s} \cdot \frac{\cos \left(x \cdot 2\right)}{\left(x \cdot c\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)}\\
\end{array}
\end{array}
if x < 3.4e-21Initial program 69.9%
associate-/r*70.1%
unpow270.1%
*-commutative70.1%
unpow270.1%
Simplified70.1%
Taylor expanded in x around 0 63.1%
unpow263.1%
Simplified63.1%
add-sqr-sqrt63.1%
Applied egg-rr82.4%
un-div-inv82.4%
associate-*l*80.8%
associate-*l*82.2%
associate-/r*82.2%
Applied egg-rr82.2%
if 3.4e-21 < x Initial program 61.5%
*-commutative61.5%
associate-*r*59.9%
associate-*r*59.8%
unpow259.8%
unswap-sqr73.4%
unpow273.4%
swap-sqr90.1%
*-commutative90.1%
*-commutative90.1%
*-commutative90.1%
*-commutative90.1%
Simplified90.1%
*-un-lft-identity90.1%
associate-*l*87.4%
times-frac87.5%
*-commutative87.5%
Applied egg-rr87.5%
Final simplification83.6%
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
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))) (t_1 (cos (* x 2.0))))
(if (<= x 1.6e+29)
(* (/ 1.0 t_0) (/ t_1 t_0))
(* (/ 1.0 s) (/ t_1 (* (* x c) (* s (* x c))))))))x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = c * (x * s);
double t_1 = cos((x * 2.0));
double tmp;
if (x <= 1.6e+29) {
tmp = (1.0 / t_0) * (t_1 / t_0);
} else {
tmp = (1.0 / s) * (t_1 / ((x * c) * (s * (x * c))));
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
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) :: t_1
real(8) :: tmp
t_0 = c * (x * s)
t_1 = cos((x * 2.0d0))
if (x <= 1.6d+29) then
tmp = (1.0d0 / t_0) * (t_1 / t_0)
else
tmp = (1.0d0 / s) * (t_1 / ((x * c) * (s * (x * c))))
end if
code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = c * (x * s);
double t_1 = Math.cos((x * 2.0));
double tmp;
if (x <= 1.6e+29) {
tmp = (1.0 / t_0) * (t_1 / t_0);
} else {
tmp = (1.0 / s) * (t_1 / ((x * c) * (s * (x * c))));
}
return tmp;
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = c * (x * s) t_1 = math.cos((x * 2.0)) tmp = 0 if x <= 1.6e+29: tmp = (1.0 / t_0) * (t_1 / t_0) else: tmp = (1.0 / s) * (t_1 / ((x * c) * (s * (x * c)))) return tmp
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(c * Float64(x * s)) t_1 = cos(Float64(x * 2.0)) tmp = 0.0 if (x <= 1.6e+29) tmp = Float64(Float64(1.0 / t_0) * Float64(t_1 / t_0)); else tmp = Float64(Float64(1.0 / s) * Float64(t_1 / Float64(Float64(x * c) * Float64(s * Float64(x * c))))); end return tmp end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = c * (x * s);
t_1 = cos((x * 2.0));
tmp = 0.0;
if (x <= 1.6e+29)
tmp = (1.0 / t_0) * (t_1 / t_0);
else
tmp = (1.0 / s) * (t_1 / ((x * c) * (s * (x * c))));
end
tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
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]}, Block[{t$95$1 = N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 1.6e+29], N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(t$95$1 / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / s), $MachinePrecision] * N[(t$95$1 / N[(N[(x * c), $MachinePrecision] * N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
t_1 := \cos \left(x \cdot 2\right)\\
\mathbf{if}\;x \leq 1.6 \cdot 10^{+29}:\\
\;\;\;\;\frac{1}{t_0} \cdot \frac{t_1}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{s} \cdot \frac{t_1}{\left(x \cdot c\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)}\\
\end{array}
\end{array}
if x < 1.59999999999999993e29Initial program 69.4%
unpow269.4%
*-commutative69.4%
unpow269.4%
Simplified69.4%
*-un-lft-identity69.4%
add-sqr-sqrt69.3%
times-frac69.3%
sqrt-prod69.3%
sqrt-prod37.5%
add-sqr-sqrt47.9%
associate-*r*46.2%
sqrt-prod46.2%
sqrt-prod15.5%
add-sqr-sqrt47.9%
sqrt-prod29.7%
add-sqr-sqrt50.1%
*-commutative50.1%
Applied egg-rr97.5%
if 1.59999999999999993e29 < x Initial program 61.5%
*-commutative61.5%
associate-*r*59.6%
associate-*r*57.9%
unpow257.9%
unswap-sqr73.4%
unpow273.4%
swap-sqr88.3%
*-commutative88.3%
*-commutative88.3%
*-commutative88.3%
*-commutative88.3%
Simplified88.3%
*-un-lft-identity88.3%
associate-*l*88.3%
times-frac88.4%
*-commutative88.4%
Applied egg-rr88.4%
Final simplification95.5%
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
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))))
(if (<= x 4.2e-58)
(/ (/ (/ 1.0 c) (* x s)) (* c (* x s)))
(* (/ (cos (* x 2.0)) t_0) (/ 1.0 t_0)))))x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = s * (x * c);
double tmp;
if (x <= 4.2e-58) {
tmp = ((1.0 / c) / (x * s)) / (c * (x * s));
} else {
tmp = (cos((x * 2.0)) / t_0) * (1.0 / t_0);
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
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 = s * (x * c)
if (x <= 4.2d-58) then
tmp = ((1.0d0 / c) / (x * s)) / (c * (x * s))
else
tmp = (cos((x * 2.0d0)) / t_0) * (1.0d0 / t_0)
end if
code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = s * (x * c);
double tmp;
if (x <= 4.2e-58) {
tmp = ((1.0 / c) / (x * s)) / (c * (x * s));
} else {
tmp = (Math.cos((x * 2.0)) / t_0) * (1.0 / t_0);
}
return tmp;
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = s * (x * c) tmp = 0 if x <= 4.2e-58: tmp = ((1.0 / c) / (x * s)) / (c * (x * s)) else: tmp = (math.cos((x * 2.0)) / t_0) * (1.0 / t_0) return tmp
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(s * Float64(x * c)) tmp = 0.0 if (x <= 4.2e-58) tmp = Float64(Float64(Float64(1.0 / c) / Float64(x * s)) / Float64(c * Float64(x * s))); else tmp = Float64(Float64(cos(Float64(x * 2.0)) / t_0) * Float64(1.0 / t_0)); end return tmp end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = s * (x * c);
tmp = 0.0;
if (x <= 4.2e-58)
tmp = ((1.0 / c) / (x * s)) / (c * (x * s));
else
tmp = (cos((x * 2.0)) / t_0) * (1.0 / t_0);
end
tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
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]}, If[LessEqual[x, 4.2e-58], N[(N[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision] / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := s \cdot \left(x \cdot c\right)\\
\mathbf{if}\;x \leq 4.2 \cdot 10^{-58}:\\
\;\;\;\;\frac{\frac{\frac{1}{c}}{x \cdot s}}{c \cdot \left(x \cdot s\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{t_0} \cdot \frac{1}{t_0}\\
\end{array}
\end{array}
if x < 4.19999999999999975e-58Initial program 69.2%
associate-/r*69.1%
unpow269.1%
*-commutative69.1%
unpow269.1%
Simplified69.1%
Taylor expanded in x around 0 61.8%
unpow261.8%
Simplified61.8%
add-sqr-sqrt61.8%
Applied egg-rr81.5%
un-div-inv81.6%
associate-*l*79.8%
associate-*l*81.3%
associate-/r*81.3%
Applied egg-rr81.3%
if 4.19999999999999975e-58 < x Initial program 64.2%
*-commutative64.2%
associate-*r*62.8%
associate-*r*62.7%
unpow262.7%
unswap-sqr74.7%
unpow274.7%
swap-sqr90.7%
*-commutative90.7%
*-commutative90.7%
*-commutative90.7%
*-commutative90.7%
Simplified90.7%
associate-/r*91.9%
div-inv91.9%
*-commutative91.9%
Applied egg-rr91.9%
Final simplification84.6%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (if (<= x 0.0145) (/ (/ (/ 1.0 c) (* x s)) (* c (* x s))) (/ (cos (* x 2.0)) (* s (* s (* x (* c (* x c))))))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double tmp;
if (x <= 0.0145) {
tmp = ((1.0 / c) / (x * s)) / (c * (x * s));
} else {
tmp = cos((x * 2.0)) / (s * (s * (x * (c * (x * c)))));
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
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.0145d0) then
tmp = ((1.0d0 / c) / (x * s)) / (c * (x * s))
else
tmp = cos((x * 2.0d0)) / (s * (s * (x * (c * (x * c)))))
end if
code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double tmp;
if (x <= 0.0145) {
tmp = ((1.0 / c) / (x * s)) / (c * (x * s));
} else {
tmp = Math.cos((x * 2.0)) / (s * (s * (x * (c * (x * c)))));
}
return tmp;
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): tmp = 0 if x <= 0.0145: tmp = ((1.0 / c) / (x * s)) / (c * (x * s)) else: tmp = math.cos((x * 2.0)) / (s * (s * (x * (c * (x * c))))) return tmp
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) tmp = 0.0 if (x <= 0.0145) tmp = Float64(Float64(Float64(1.0 / c) / Float64(x * s)) / Float64(c * Float64(x * s))); else tmp = Float64(cos(Float64(x * 2.0)) / Float64(s * Float64(s * Float64(x * Float64(c * Float64(x * c)))))); end return tmp end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
tmp = 0.0;
if (x <= 0.0145)
tmp = ((1.0 / c) / (x * s)) / (c * (x * s));
else
tmp = cos((x * 2.0)) / (s * (s * (x * (c * (x * c)))));
end
tmp_2 = tmp;
end
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := If[LessEqual[x, 0.0145], N[(N[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision] / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $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]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.0145:\\
\;\;\;\;\frac{\frac{\frac{1}{c}}{x \cdot s}}{c \cdot \left(x \cdot s\right)}\\
\mathbf{else}:\\
\;\;\;\;\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)}\\
\end{array}
\end{array}
if x < 0.0145000000000000007Initial program 70.4%
associate-/r*70.6%
unpow270.6%
*-commutative70.6%
unpow270.6%
Simplified70.6%
Taylor expanded in x around 0 63.7%
unpow263.7%
Simplified63.7%
add-sqr-sqrt63.7%
Applied egg-rr82.7%
un-div-inv82.7%
associate-*l*81.1%
associate-*l*82.5%
associate-/r*82.5%
Applied egg-rr82.5%
if 0.0145000000000000007 < x Initial program 59.8%
*-commutative59.8%
associate-*l*58.2%
associate-*r*59.5%
*-commutative59.5%
unpow259.5%
associate-*r*68.4%
associate-*r*69.8%
*-commutative69.8%
unpow269.8%
Simplified69.8%
Taylor expanded in x around 0 65.5%
*-commutative65.5%
unpow265.5%
associate-*r*67.4%
unpow267.4%
associate-*r*78.6%
*-commutative78.6%
Simplified78.6%
Final simplification81.4%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (if (<= x 0.011) (/ (/ (/ 1.0 c) (* x s)) (* c (* x s))) (/ (cos (* x 2.0)) (* s (* s (* (* x c) (* x c)))))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double tmp;
if (x <= 0.011) {
tmp = ((1.0 / c) / (x * s)) / (c * (x * s));
} else {
tmp = cos((x * 2.0)) / (s * (s * ((x * c) * (x * c))));
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
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.011d0) then
tmp = ((1.0d0 / c) / (x * s)) / (c * (x * s))
else
tmp = cos((x * 2.0d0)) / (s * (s * ((x * c) * (x * c))))
end if
code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double tmp;
if (x <= 0.011) {
tmp = ((1.0 / c) / (x * s)) / (c * (x * s));
} else {
tmp = Math.cos((x * 2.0)) / (s * (s * ((x * c) * (x * c))));
}
return tmp;
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): tmp = 0 if x <= 0.011: tmp = ((1.0 / c) / (x * s)) / (c * (x * s)) else: tmp = math.cos((x * 2.0)) / (s * (s * ((x * c) * (x * c)))) return tmp
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) tmp = 0.0 if (x <= 0.011) tmp = Float64(Float64(Float64(1.0 / c) / Float64(x * s)) / Float64(c * Float64(x * s))); else tmp = Float64(cos(Float64(x * 2.0)) / Float64(s * Float64(s * Float64(Float64(x * c) * Float64(x * c))))); end return tmp end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
tmp = 0.0;
if (x <= 0.011)
tmp = ((1.0 / c) / (x * s)) / (c * (x * s));
else
tmp = cos((x * 2.0)) / (s * (s * ((x * c) * (x * c))));
end
tmp_2 = tmp;
end
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := If[LessEqual[x, 0.011], N[(N[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision] / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(s * N[(s * N[(N[(x * c), $MachinePrecision] * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.011:\\
\;\;\;\;\frac{\frac{\frac{1}{c}}{x \cdot s}}{c \cdot \left(x \cdot s\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{s \cdot \left(s \cdot \left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right)\right)}\\
\end{array}
\end{array}
if x < 0.010999999999999999Initial program 70.4%
associate-/r*70.6%
unpow270.6%
*-commutative70.6%
unpow270.6%
Simplified70.6%
Taylor expanded in x around 0 63.7%
unpow263.7%
Simplified63.7%
add-sqr-sqrt63.7%
Applied egg-rr82.7%
un-div-inv82.7%
associate-*l*81.1%
associate-*l*82.5%
associate-/r*82.5%
Applied egg-rr82.5%
if 0.010999999999999999 < x Initial program 59.8%
*-commutative59.8%
associate-*l*58.2%
associate-*r*59.5%
*-commutative59.5%
unpow259.5%
associate-*r*68.4%
associate-*r*69.8%
*-commutative69.8%
unpow269.8%
Simplified69.8%
Taylor expanded in x around 0 65.5%
*-commutative65.5%
unpow265.5%
unpow265.5%
swap-sqr81.0%
unpow281.0%
*-commutative81.0%
Simplified81.0%
unpow281.0%
*-commutative81.0%
*-commutative81.0%
Applied egg-rr81.0%
Final simplification82.1%
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
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))))
(if (<= x 3.5e-31)
(/ (/ (/ 1.0 c) (* x s)) (* c (* x s)))
(/ (cos (* x 2.0)) (* t_0 t_0)))))x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = s * (x * c);
double tmp;
if (x <= 3.5e-31) {
tmp = ((1.0 / c) / (x * s)) / (c * (x * s));
} else {
tmp = cos((x * 2.0)) / (t_0 * t_0);
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
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 = s * (x * c)
if (x <= 3.5d-31) then
tmp = ((1.0d0 / c) / (x * s)) / (c * (x * s))
else
tmp = cos((x * 2.0d0)) / (t_0 * t_0)
end if
code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = s * (x * c);
double tmp;
if (x <= 3.5e-31) {
tmp = ((1.0 / c) / (x * s)) / (c * (x * s));
} else {
tmp = Math.cos((x * 2.0)) / (t_0 * t_0);
}
return tmp;
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = s * (x * c) tmp = 0 if x <= 3.5e-31: tmp = ((1.0 / c) / (x * s)) / (c * (x * s)) else: tmp = math.cos((x * 2.0)) / (t_0 * t_0) return tmp
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(s * Float64(x * c)) tmp = 0.0 if (x <= 3.5e-31) tmp = Float64(Float64(Float64(1.0 / c) / Float64(x * s)) / Float64(c * Float64(x * s))); else tmp = Float64(cos(Float64(x * 2.0)) / Float64(t_0 * t_0)); end return tmp end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = s * (x * c);
tmp = 0.0;
if (x <= 3.5e-31)
tmp = ((1.0 / c) / (x * s)) / (c * (x * s));
else
tmp = cos((x * 2.0)) / (t_0 * t_0);
end
tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
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]}, If[LessEqual[x, 3.5e-31], N[(N[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision] / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := s \cdot \left(x \cdot c\right)\\
\mathbf{if}\;x \leq 3.5 \cdot 10^{-31}:\\
\;\;\;\;\frac{\frac{\frac{1}{c}}{x \cdot s}}{c \cdot \left(x \cdot s\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{t_0 \cdot t_0}\\
\end{array}
\end{array}
if x < 3.49999999999999985e-31Initial program 69.8%
associate-/r*69.9%
unpow269.9%
*-commutative69.9%
unpow269.9%
Simplified69.9%
Taylor expanded in x around 0 62.9%
unpow262.9%
Simplified62.9%
add-sqr-sqrt62.9%
Applied egg-rr82.3%
un-div-inv82.4%
associate-*l*80.7%
associate-*l*82.1%
associate-/r*82.1%
Applied egg-rr82.1%
if 3.49999999999999985e-31 < x Initial program 62.1%
*-commutative62.1%
associate-*r*60.5%
associate-*r*60.4%
unpow260.4%
unswap-sqr73.7%
unpow273.7%
swap-sqr90.2%
*-commutative90.2%
*-commutative90.2%
*-commutative90.2%
*-commutative90.2%
Simplified90.2%
Final simplification84.4%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function 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)))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return 1.0 / ((c * c) * ((x * x) * (s * s)));
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
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
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return 1.0 / ((c * c) * ((x * x) * (s * s)));
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return 1.0 / ((c * c) * ((x * x) * (s * s)))
x = abs(x) c = abs(c) s = abs(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
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = 1.0 / ((c * c) * ((x * x) * (s * s)));
end
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function 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}
x = |x|\\
c = |c|\\
s = |s|\\
[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.9%
associate-*r*63.7%
unpow263.7%
unswap-sqr77.8%
unpow277.8%
swap-sqr95.2%
*-commutative95.2%
*-commutative95.2%
*-commutative95.2%
*-commutative95.2%
Simplified95.2%
Taylor expanded in x around 0 55.9%
unpow255.9%
unpow255.9%
*-commutative55.9%
unpow255.9%
Simplified55.9%
Final simplification55.9%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function 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)) (* x (* c s)))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return 1.0 / ((s * (x * c)) * (x * (c * s)));
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
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)) * (x * (c * s)))
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return 1.0 / ((s * (x * c)) * (x * (c * s)));
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return 1.0 / ((s * (x * c)) * (x * (c * s)))
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(1.0 / Float64(Float64(s * Float64(x * c)) * Float64(x * Float64(c * s)))) end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = 1.0 / ((s * (x * c)) * (x * (c * s)));
end
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(1.0 / N[(N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision] * N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{\left(s \cdot \left(x \cdot c\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)}
\end{array}
Initial program 67.6%
*-commutative67.6%
associate-*r*63.9%
associate-*r*63.7%
unpow263.7%
unswap-sqr77.8%
unpow277.8%
swap-sqr95.2%
*-commutative95.2%
*-commutative95.2%
*-commutative95.2%
*-commutative95.2%
Simplified95.2%
Taylor expanded in x around 0 55.9%
unpow255.9%
associate-*r*55.9%
*-commutative55.9%
associate-*r*55.6%
*-commutative55.6%
unpow255.6%
unpow255.6%
swap-sqr65.1%
swap-sqr75.4%
unpow275.4%
associate-*r*74.9%
*-commutative74.9%
*-commutative74.9%
*-commutative74.9%
Simplified74.9%
unpow274.9%
associate-*r*74.2%
associate-*r*75.5%
Applied egg-rr75.5%
Taylor expanded in c around 0 74.7%
Final simplification74.7%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (let* ((t_0 (* x (* c s)))) (/ 1.0 (* t_0 t_0))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = x * (c * s);
return 1.0 / (t_0 * t_0);
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
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 = x * (c * s)
code = 1.0d0 / (t_0 * t_0)
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = x * (c * s);
return 1.0 / (t_0 * t_0);
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = x * (c * s) return 1.0 / (t_0 * t_0)
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(x * Float64(c * s)) return Float64(1.0 / Float64(t_0 * t_0)) end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
t_0 = x * (c * s);
tmp = 1.0 / (t_0 * t_0);
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := x \cdot \left(c \cdot s\right)\\
\frac{1}{t_0 \cdot t_0}
\end{array}
\end{array}
Initial program 67.6%
*-commutative67.6%
associate-*r*63.9%
associate-*r*63.7%
unpow263.7%
unswap-sqr77.8%
unpow277.8%
swap-sqr95.2%
*-commutative95.2%
*-commutative95.2%
*-commutative95.2%
*-commutative95.2%
Simplified95.2%
Taylor expanded in x around 0 55.9%
unpow255.9%
associate-*r*55.9%
*-commutative55.9%
associate-*r*55.6%
*-commutative55.6%
unpow255.6%
unpow255.6%
swap-sqr65.1%
swap-sqr75.4%
unpow275.4%
associate-*r*74.9%
*-commutative74.9%
*-commutative74.9%
*-commutative74.9%
Simplified74.9%
unpow274.9%
associate-*r*74.2%
associate-*r*75.5%
Applied egg-rr75.5%
Final simplification75.5%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function 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)) (* c (* x s))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return ((1.0 / c) / (x * s)) / (c * (x * s));
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
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)) / (c * (x * s))
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return ((1.0 / c) / (x * s)) / (c * (x * s));
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return ((1.0 / c) / (x * s)) / (c * (x * s))
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(Float64(Float64(1.0 / c) / Float64(x * s)) / Float64(c * Float64(x * s))) end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = ((1.0 / c) / (x * s)) / (c * (x * s));
end
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(N[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision] / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\frac{\frac{1}{c}}{x \cdot s}}{c \cdot \left(x \cdot s\right)}
\end{array}
Initial program 67.6%
associate-/r*67.6%
unpow267.6%
*-commutative67.6%
unpow267.6%
Simplified67.6%
Taylor expanded in x around 0 58.5%
unpow258.5%
Simplified58.5%
add-sqr-sqrt58.5%
Applied egg-rr75.6%
un-div-inv75.6%
associate-*l*74.3%
associate-*l*75.4%
associate-/r*75.4%
Applied egg-rr75.4%
Final simplification75.4%
herbie shell --seed 2023224
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))