
(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 14 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 5e+47) (* (/ 1.0 (pow (* c (* x s)) 2.0)) (cos (* x 2.0))) (/ (- (pow (cos x) 2.0) (pow (sin x) 2.0)) (pow (* s (* x c)) 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 <= 5e+47) {
tmp = (1.0 / pow((c * (x * s)), 2.0)) * cos((x * 2.0));
} else {
tmp = (pow(cos(x), 2.0) - pow(sin(x), 2.0)) / pow((s * (x * c)), 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 <= 5d+47) then
tmp = (1.0d0 / ((c * (x * s)) ** 2.0d0)) * cos((x * 2.0d0))
else
tmp = ((cos(x) ** 2.0d0) - (sin(x) ** 2.0d0)) / ((s * (x * c)) ** 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 <= 5e+47) {
tmp = (1.0 / Math.pow((c * (x * s)), 2.0)) * Math.cos((x * 2.0));
} else {
tmp = (Math.pow(Math.cos(x), 2.0) - Math.pow(Math.sin(x), 2.0)) / Math.pow((s * (x * c)), 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 <= 5e+47: tmp = (1.0 / math.pow((c * (x * s)), 2.0)) * math.cos((x * 2.0)) else: tmp = (math.pow(math.cos(x), 2.0) - math.pow(math.sin(x), 2.0)) / math.pow((s * (x * c)), 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 <= 5e+47) tmp = Float64(Float64(1.0 / (Float64(c * Float64(x * s)) ^ 2.0)) * cos(Float64(x * 2.0))); else tmp = Float64(Float64((cos(x) ^ 2.0) - (sin(x) ^ 2.0)) / (Float64(s * Float64(x * c)) ^ 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 <= 5e+47)
tmp = (1.0 / ((c * (x * s)) ^ 2.0)) * cos((x * 2.0));
else
tmp = ((cos(x) ^ 2.0) - (sin(x) ^ 2.0)) / ((s * (x * c)) ^ 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, 5e+47], N[(N[(1.0 / N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{+47}:\\
\;\;\;\;\frac{1}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}} \cdot \cos \left(x \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{{\cos x}^{2} - {\sin x}^{2}}{{\left(s \cdot \left(x \cdot c\right)\right)}^{2}}\\
\end{array}
\end{array}
if x < 5.00000000000000022e47Initial program 65.7%
associate-/r*65.8%
*-commutative65.8%
associate-*l*62.5%
unpow262.5%
unpow262.5%
associate-*r*68.7%
associate-/r*71.7%
associate-/l/71.6%
associate-/l/71.7%
*-commutative71.7%
associate-*l*67.7%
unpow267.7%
associate-*l*62.1%
unpow262.1%
unswap-sqr80.6%
*-commutative80.6%
*-commutative80.6%
Simplified80.6%
clear-num80.6%
associate-/r/80.6%
Applied egg-rr97.5%
if 5.00000000000000022e47 < x Initial program 66.3%
associate-/r*66.0%
remove-double-neg66.0%
distribute-lft-neg-out66.0%
distribute-lft-neg-out66.0%
distribute-rgt-neg-out66.0%
associate-/l/66.3%
distribute-rgt-neg-out66.3%
distribute-lft-neg-out66.3%
associate-*l*69.0%
distribute-lft-neg-in69.0%
distribute-lft-neg-out69.0%
remove-double-neg69.0%
associate-*r*69.0%
*-commutative69.0%
associate-*r*67.4%
Simplified72.7%
Taylor expanded in x around 0 55.8%
unpow255.8%
unpow255.8%
unpow255.8%
swap-sqr79.1%
swap-sqr94.9%
unpow294.9%
associate-*r*97.2%
*-commutative97.2%
associate-*l*96.4%
Simplified96.4%
cos-296.2%
sub-neg96.2%
pow296.2%
pow296.2%
Applied egg-rr96.2%
sub-neg96.2%
Simplified96.2%
Final simplification97.2%
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 5e+70)
(* (/ 1.0 t_0) (/ t_1 t_0))
(/ t_1 (* (* x c) (* s (* 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 <= 5e+70) {
tmp = (1.0 / t_0) * (t_1 / t_0);
} else {
tmp = t_1 / ((x * c) * (s * (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 <= 5d+70) then
tmp = (1.0d0 / t_0) * (t_1 / t_0)
else
tmp = t_1 / ((x * c) * (s * (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 <= 5e+70) {
tmp = (1.0 / t_0) * (t_1 / t_0);
} else {
tmp = t_1 / ((x * c) * (s * (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 <= 5e+70: tmp = (1.0 / t_0) * (t_1 / t_0) else: tmp = t_1 / ((x * c) * (s * (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 <= 5e+70) tmp = Float64(Float64(1.0 / t_0) * Float64(t_1 / t_0)); else tmp = Float64(t_1 / Float64(Float64(x * c) * Float64(s * 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 <= 5e+70)
tmp = (1.0 / t_0) * (t_1 / t_0);
else
tmp = t_1 / ((x * c) * (s * (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, 5e+70], N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(t$95$1 / t$95$0), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / N[(N[(x * c), $MachinePrecision] * N[(s * 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 5 \cdot 10^{+70}:\\
\;\;\;\;\frac{1}{t_0} \cdot \frac{t_1}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{\left(x \cdot c\right) \cdot \left(s \cdot \left(s \cdot \left(x \cdot c\right)\right)\right)}\\
\end{array}
\end{array}
if x < 5.0000000000000002e70Initial program 65.3%
associate-/r*65.3%
*-commutative65.3%
associate-*l*62.1%
unpow262.1%
unpow262.1%
associate-*r*68.2%
associate-/r*71.1%
associate-/l/71.1%
associate-/l/71.1%
*-commutative71.1%
associate-*l*67.3%
unpow267.3%
associate-*l*61.6%
unpow261.6%
unswap-sqr80.9%
*-commutative80.9%
*-commutative80.9%
Simplified80.9%
*-un-lft-identity80.9%
add-sqr-sqrt80.9%
times-frac80.9%
Applied egg-rr97.4%
if 5.0000000000000002e70 < x Initial program 68.0%
associate-/r*67.7%
remove-double-neg67.7%
distribute-lft-neg-out67.7%
distribute-lft-neg-out67.7%
distribute-rgt-neg-out67.7%
associate-/l/68.0%
distribute-rgt-neg-out68.0%
distribute-lft-neg-out68.0%
associate-*l*72.5%
distribute-lft-neg-in72.5%
distribute-lft-neg-out72.5%
remove-double-neg72.5%
associate-*r*72.5%
*-commutative72.5%
associate-*r*69.2%
Simplified74.7%
Taylor expanded in x around 0 57.0%
unpow257.0%
unpow257.0%
unpow257.0%
swap-sqr81.5%
swap-sqr94.7%
unpow294.7%
associate-*r*97.2%
*-commutative97.2%
associate-*l*97.9%
Simplified97.9%
unpow297.9%
associate-*r*95.6%
*-commutative95.6%
associate-*r*93.1%
associate-*r*89.9%
associate-*r*93.1%
*-commutative93.1%
associate-*r*94.7%
Applied egg-rr94.7%
Final simplification96.8%
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 1.5e-26)
(pow (* c (* x s)) -2.0)
(* (/ 1.0 t_0) (/ (cos (* x 2.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 <= 1.5e-26) {
tmp = pow((c * (x * s)), -2.0);
} else {
tmp = (1.0 / t_0) * (cos((x * 2.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 <= 1.5d-26) then
tmp = (c * (x * s)) ** (-2.0d0)
else
tmp = (1.0d0 / t_0) * (cos((x * 2.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 <= 1.5e-26) {
tmp = Math.pow((c * (x * s)), -2.0);
} else {
tmp = (1.0 / t_0) * (Math.cos((x * 2.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 <= 1.5e-26: tmp = math.pow((c * (x * s)), -2.0) else: tmp = (1.0 / t_0) * (math.cos((x * 2.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 <= 1.5e-26) tmp = Float64(c * Float64(x * s)) ^ -2.0; else tmp = Float64(Float64(1.0 / t_0) * Float64(cos(Float64(x * 2.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 <= 1.5e-26)
tmp = (c * (x * s)) ^ -2.0;
else
tmp = (1.0 / t_0) * (cos((x * 2.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, 1.5e-26], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / 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 1.5 \cdot 10^{-26}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t_0} \cdot \frac{\cos \left(x \cdot 2\right)}{t_0}\\
\end{array}
\end{array}
if x < 1.50000000000000006e-26Initial program 65.6%
associate-/r*65.6%
remove-double-neg65.6%
distribute-lft-neg-out65.6%
distribute-lft-neg-out65.6%
distribute-rgt-neg-out65.6%
associate-/l/65.6%
distribute-rgt-neg-out65.6%
distribute-lft-neg-out65.6%
associate-*l*67.0%
distribute-lft-neg-in67.0%
distribute-lft-neg-out67.0%
remove-double-neg67.0%
associate-*r*66.7%
*-commutative66.7%
associate-*r*64.7%
Simplified72.5%
Taylor expanded in x around 0 62.2%
unpow262.2%
unpow262.2%
unpow262.2%
swap-sqr74.9%
swap-sqr97.4%
unpow297.4%
associate-*r*98.1%
*-commutative98.1%
associate-*l*97.1%
Simplified97.1%
Taylor expanded in x around 0 56.5%
unpow256.5%
unpow256.5%
unpow256.5%
associate-*r*56.5%
*-commutative56.5%
swap-sqr70.6%
swap-sqr85.2%
associate-*r*83.7%
associate-*r*84.1%
unpow284.1%
/-rgt-identity84.1%
unpow284.1%
associate-/l*84.1%
associate-/l*84.2%
associate-*l/84.1%
unpow-184.1%
unpow-184.1%
pow-sqr84.2%
Simplified84.4%
if 1.50000000000000006e-26 < x Initial program 66.6%
associate-/r*66.3%
remove-double-neg66.3%
distribute-lft-neg-out66.3%
distribute-lft-neg-out66.3%
distribute-rgt-neg-out66.3%
associate-/l/66.6%
distribute-rgt-neg-out66.6%
distribute-lft-neg-out66.6%
associate-*l*68.9%
distribute-lft-neg-in68.9%
distribute-lft-neg-out68.9%
remove-double-neg68.9%
associate-*r*68.9%
*-commutative68.9%
associate-*r*67.5%
Simplified74.9%
Taylor expanded in x around 0 57.4%
unpow257.4%
unpow257.4%
unpow257.4%
swap-sqr77.7%
swap-sqr95.5%
unpow295.5%
associate-*r*97.5%
*-commutative97.5%
associate-*l*96.8%
Simplified96.8%
*-un-lft-identity96.8%
associate-*r*97.5%
*-commutative97.5%
associate-*r*95.5%
unpow295.5%
times-frac95.6%
associate-*r*93.7%
*-commutative93.7%
associate-*r*93.0%
*-commutative93.0%
associate-*r*95.1%
*-commutative95.1%
associate-*r*96.9%
Applied egg-rr96.9%
Final simplification87.8%
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.016) (pow (* c (* x s)) -2.0) (/ (cos (* x 2.0)) (* x (* x (* c (* c (* s s))))))))
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.016) {
tmp = pow((c * (x * s)), -2.0);
} else {
tmp = cos((x * 2.0)) / (x * (x * (c * (c * (s * s)))));
}
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.016d0) then
tmp = (c * (x * s)) ** (-2.0d0)
else
tmp = cos((x * 2.0d0)) / (x * (x * (c * (c * (s * s)))))
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.016) {
tmp = Math.pow((c * (x * s)), -2.0);
} else {
tmp = Math.cos((x * 2.0)) / (x * (x * (c * (c * (s * s)))));
}
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.016: tmp = math.pow((c * (x * s)), -2.0) else: tmp = math.cos((x * 2.0)) / (x * (x * (c * (c * (s * s))))) 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.016) tmp = Float64(c * Float64(x * s)) ^ -2.0; else tmp = Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(x * Float64(c * Float64(c * Float64(s * s)))))); 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.016)
tmp = (c * (x * s)) ^ -2.0;
else
tmp = cos((x * 2.0)) / (x * (x * (c * (c * (s * s)))));
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.016], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * N[(x * N[(c * N[(c * N[(s * s), $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.016:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(x \cdot \left(c \cdot \left(c \cdot \left(s \cdot s\right)\right)\right)\right)}\\
\end{array}
\end{array}
if x < 0.016Initial program 66.2%
associate-/r*66.2%
remove-double-neg66.2%
distribute-lft-neg-out66.2%
distribute-lft-neg-out66.2%
distribute-rgt-neg-out66.2%
associate-/l/66.2%
distribute-rgt-neg-out66.2%
distribute-lft-neg-out66.2%
associate-*l*67.6%
distribute-lft-neg-in67.6%
distribute-lft-neg-out67.6%
remove-double-neg67.6%
associate-*r*67.2%
*-commutative67.2%
associate-*r*65.3%
Simplified72.9%
Taylor expanded in x around 0 62.8%
unpow262.8%
unpow262.8%
unpow262.8%
swap-sqr75.3%
swap-sqr97.4%
unpow297.4%
associate-*r*98.1%
*-commutative98.1%
associate-*l*97.2%
Simplified97.2%
Taylor expanded in x around 0 57.2%
unpow257.2%
unpow257.2%
unpow257.2%
associate-*r*57.2%
*-commutative57.2%
swap-sqr71.0%
swap-sqr85.4%
associate-*r*83.9%
associate-*r*84.4%
unpow284.4%
/-rgt-identity84.4%
unpow284.4%
associate-/l*84.4%
associate-/l*84.4%
associate-*l/84.3%
unpow-184.3%
unpow-184.3%
pow-sqr84.4%
Simplified84.7%
if 0.016 < x Initial program 65.0%
associate-/r*64.8%
remove-double-neg64.8%
distribute-lft-neg-out64.8%
distribute-lft-neg-out64.8%
distribute-rgt-neg-out64.8%
associate-/l/65.0%
distribute-rgt-neg-out65.0%
distribute-lft-neg-out65.0%
associate-*l*67.5%
distribute-lft-neg-in67.5%
distribute-lft-neg-out67.5%
remove-double-neg67.5%
associate-*r*67.5%
*-commutative67.5%
associate-*r*66.1%
Simplified73.7%
Final simplification81.8%
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.0065) (pow (* c (* x s)) -2.0) (/ (cos (* x 2.0)) (* x (* (* x c) (* s (* c s)))))))
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.0065) {
tmp = pow((c * (x * s)), -2.0);
} else {
tmp = cos((x * 2.0)) / (x * ((x * c) * (s * (c * s))));
}
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.0065d0) then
tmp = (c * (x * s)) ** (-2.0d0)
else
tmp = cos((x * 2.0d0)) / (x * ((x * c) * (s * (c * s))))
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.0065) {
tmp = Math.pow((c * (x * s)), -2.0);
} else {
tmp = Math.cos((x * 2.0)) / (x * ((x * c) * (s * (c * s))));
}
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.0065: tmp = math.pow((c * (x * s)), -2.0) else: tmp = math.cos((x * 2.0)) / (x * ((x * c) * (s * (c * s)))) 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.0065) tmp = Float64(c * Float64(x * s)) ^ -2.0; else tmp = Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(Float64(x * c) * Float64(s * Float64(c * s))))); 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.0065)
tmp = (c * (x * s)) ^ -2.0;
else
tmp = cos((x * 2.0)) / (x * ((x * c) * (s * (c * s))));
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.0065], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * N[(N[(x * c), $MachinePrecision] * N[(s * N[(c * s), $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.0065:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(\left(x \cdot c\right) \cdot \left(s \cdot \left(c \cdot s\right)\right)\right)}\\
\end{array}
\end{array}
if x < 0.0064999999999999997Initial program 66.2%
associate-/r*66.2%
remove-double-neg66.2%
distribute-lft-neg-out66.2%
distribute-lft-neg-out66.2%
distribute-rgt-neg-out66.2%
associate-/l/66.2%
distribute-rgt-neg-out66.2%
distribute-lft-neg-out66.2%
associate-*l*67.6%
distribute-lft-neg-in67.6%
distribute-lft-neg-out67.6%
remove-double-neg67.6%
associate-*r*67.2%
*-commutative67.2%
associate-*r*65.3%
Simplified72.9%
Taylor expanded in x around 0 62.8%
unpow262.8%
unpow262.8%
unpow262.8%
swap-sqr75.3%
swap-sqr97.4%
unpow297.4%
associate-*r*98.1%
*-commutative98.1%
associate-*l*97.2%
Simplified97.2%
Taylor expanded in x around 0 57.2%
unpow257.2%
unpow257.2%
unpow257.2%
associate-*r*57.2%
*-commutative57.2%
swap-sqr71.0%
swap-sqr85.4%
associate-*r*83.9%
associate-*r*84.4%
unpow284.4%
/-rgt-identity84.4%
unpow284.4%
associate-/l*84.4%
associate-/l*84.4%
associate-*l/84.3%
unpow-184.3%
unpow-184.3%
pow-sqr84.4%
Simplified84.7%
if 0.0064999999999999997 < x Initial program 65.0%
associate-/r*64.8%
remove-double-neg64.8%
distribute-lft-neg-out64.8%
distribute-lft-neg-out64.8%
distribute-rgt-neg-out64.8%
associate-/l/65.0%
distribute-rgt-neg-out65.0%
distribute-lft-neg-out65.0%
associate-*l*67.5%
distribute-lft-neg-in67.5%
distribute-lft-neg-out67.5%
remove-double-neg67.5%
associate-*r*67.5%
*-commutative67.5%
associate-*r*66.1%
Simplified73.7%
add-sqr-sqrt73.7%
pow273.7%
associate-*r*66.1%
swap-sqr83.9%
*-commutative83.9%
sqrt-prod83.7%
sqrt-prod54.6%
add-sqr-sqrt92.4%
Applied egg-rr92.4%
unpow292.4%
*-commutative92.4%
*-commutative92.4%
swap-sqr83.8%
add-sqr-sqrt83.9%
associate-*l*82.4%
associate-*r*82.5%
*-commutative82.5%
*-commutative82.5%
Applied egg-rr82.5%
Final simplification84.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 (if (<= x 4e-37) (pow (* c (* x s)) -2.0) (/ (cos (* x 2.0)) (* x (* (* s (* x c)) (* c s))))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double tmp;
if (x <= 4e-37) {
tmp = pow((c * (x * s)), -2.0);
} else {
tmp = cos((x * 2.0)) / (x * ((s * (x * c)) * (c * s)));
}
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 <= 4d-37) then
tmp = (c * (x * s)) ** (-2.0d0)
else
tmp = cos((x * 2.0d0)) / (x * ((s * (x * c)) * (c * s)))
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 <= 4e-37) {
tmp = Math.pow((c * (x * s)), -2.0);
} else {
tmp = Math.cos((x * 2.0)) / (x * ((s * (x * c)) * (c * s)));
}
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 <= 4e-37: tmp = math.pow((c * (x * s)), -2.0) else: tmp = math.cos((x * 2.0)) / (x * ((s * (x * c)) * (c * s))) 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 <= 4e-37) tmp = Float64(c * Float64(x * s)) ^ -2.0; else tmp = Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(Float64(s * Float64(x * c)) * Float64(c * s)))); 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 <= 4e-37)
tmp = (c * (x * s)) ^ -2.0;
else
tmp = cos((x * 2.0)) / (x * ((s * (x * c)) * (c * s)));
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, 4e-37], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * N[(N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision] * N[(c * s), $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 4 \cdot 10^{-37}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(\left(s \cdot \left(x \cdot c\right)\right) \cdot \left(c \cdot s\right)\right)}\\
\end{array}
\end{array}
if x < 4.00000000000000027e-37Initial program 65.6%
associate-/r*65.6%
remove-double-neg65.6%
distribute-lft-neg-out65.6%
distribute-lft-neg-out65.6%
distribute-rgt-neg-out65.6%
associate-/l/65.6%
distribute-rgt-neg-out65.6%
distribute-lft-neg-out65.6%
associate-*l*67.0%
distribute-lft-neg-in67.0%
distribute-lft-neg-out67.0%
remove-double-neg67.0%
associate-*r*66.6%
*-commutative66.6%
associate-*r*64.6%
Simplified72.5%
Taylor expanded in x around 0 62.1%
unpow262.1%
unpow262.1%
unpow262.1%
swap-sqr74.9%
swap-sqr97.3%
unpow297.3%
associate-*r*98.0%
*-commutative98.0%
associate-*l*97.1%
Simplified97.1%
Taylor expanded in x around 0 56.3%
unpow256.3%
unpow256.3%
unpow256.3%
associate-*r*56.3%
*-commutative56.3%
swap-sqr70.6%
swap-sqr84.9%
associate-*r*83.4%
associate-*r*83.9%
unpow283.9%
/-rgt-identity83.9%
unpow283.9%
associate-/l*83.8%
associate-/l*83.9%
associate-*l/83.8%
unpow-183.8%
unpow-183.8%
pow-sqr83.9%
Simplified84.2%
if 4.00000000000000027e-37 < x Initial program 66.7%
associate-/r*66.4%
remove-double-neg66.4%
distribute-lft-neg-out66.4%
distribute-lft-neg-out66.4%
distribute-rgt-neg-out66.4%
associate-/l/66.7%
distribute-rgt-neg-out66.7%
distribute-lft-neg-out66.7%
associate-*l*68.9%
distribute-lft-neg-in68.9%
distribute-lft-neg-out68.9%
remove-double-neg68.9%
associate-*r*69.0%
*-commutative69.0%
associate-*r*67.6%
Simplified74.6%
add-sqr-sqrt74.6%
pow274.6%
associate-*r*67.6%
swap-sqr83.9%
*-commutative83.9%
sqrt-prod83.8%
sqrt-prod55.5%
add-sqr-sqrt93.0%
Applied egg-rr93.0%
unpow293.0%
*-commutative93.0%
associate-*r*93.0%
associate-*r*93.1%
add-sqr-sqrt93.1%
*-commutative93.1%
associate-*r*90.6%
*-commutative90.6%
Applied egg-rr90.6%
Final simplification86.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. (FPCore (x c s) :precision binary64 (if (<= x 0.0065) (pow (* c (* x s)) -2.0) (/ (cos (* x 2.0)) (* (* x c) (* s (* 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 <= 0.0065) {
tmp = pow((c * (x * s)), -2.0);
} else {
tmp = cos((x * 2.0)) / ((x * c) * (s * (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 <= 0.0065d0) then
tmp = (c * (x * s)) ** (-2.0d0)
else
tmp = cos((x * 2.0d0)) / ((x * c) * (s * (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 <= 0.0065) {
tmp = Math.pow((c * (x * s)), -2.0);
} else {
tmp = Math.cos((x * 2.0)) / ((x * c) * (s * (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 <= 0.0065: tmp = math.pow((c * (x * s)), -2.0) else: tmp = math.cos((x * 2.0)) / ((x * c) * (s * (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 <= 0.0065) tmp = Float64(c * Float64(x * s)) ^ -2.0; else tmp = Float64(cos(Float64(x * 2.0)) / Float64(Float64(x * c) * Float64(s * 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 <= 0.0065)
tmp = (c * (x * s)) ^ -2.0;
else
tmp = cos((x * 2.0)) / ((x * c) * (s * (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, 0.0065], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(N[(x * c), $MachinePrecision] * N[(s * 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 0.0065:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{\left(x \cdot c\right) \cdot \left(s \cdot \left(s \cdot \left(x \cdot c\right)\right)\right)}\\
\end{array}
\end{array}
if x < 0.0064999999999999997Initial program 66.2%
associate-/r*66.2%
remove-double-neg66.2%
distribute-lft-neg-out66.2%
distribute-lft-neg-out66.2%
distribute-rgt-neg-out66.2%
associate-/l/66.2%
distribute-rgt-neg-out66.2%
distribute-lft-neg-out66.2%
associate-*l*67.6%
distribute-lft-neg-in67.6%
distribute-lft-neg-out67.6%
remove-double-neg67.6%
associate-*r*67.2%
*-commutative67.2%
associate-*r*65.3%
Simplified72.9%
Taylor expanded in x around 0 62.8%
unpow262.8%
unpow262.8%
unpow262.8%
swap-sqr75.3%
swap-sqr97.4%
unpow297.4%
associate-*r*98.1%
*-commutative98.1%
associate-*l*97.2%
Simplified97.2%
Taylor expanded in x around 0 57.2%
unpow257.2%
unpow257.2%
unpow257.2%
associate-*r*57.2%
*-commutative57.2%
swap-sqr71.0%
swap-sqr85.4%
associate-*r*83.9%
associate-*r*84.4%
unpow284.4%
/-rgt-identity84.4%
unpow284.4%
associate-/l*84.4%
associate-/l*84.4%
associate-*l/84.3%
unpow-184.3%
unpow-184.3%
pow-sqr84.4%
Simplified84.7%
if 0.0064999999999999997 < x Initial program 65.0%
associate-/r*64.8%
remove-double-neg64.8%
distribute-lft-neg-out64.8%
distribute-lft-neg-out64.8%
distribute-rgt-neg-out64.8%
associate-/l/65.0%
distribute-rgt-neg-out65.0%
distribute-lft-neg-out65.0%
associate-*l*67.5%
distribute-lft-neg-in67.5%
distribute-lft-neg-out67.5%
remove-double-neg67.5%
associate-*r*67.5%
*-commutative67.5%
associate-*r*66.1%
Simplified73.7%
Taylor expanded in x around 0 55.5%
unpow255.5%
unpow255.5%
unpow255.5%
swap-sqr76.7%
swap-sqr95.3%
unpow295.3%
associate-*r*97.4%
*-commutative97.4%
associate-*l*96.6%
Simplified96.6%
unpow296.6%
associate-*r*94.7%
*-commutative94.7%
associate-*r*92.5%
associate-*r*89.7%
associate-*r*92.5%
*-commutative92.5%
associate-*r*93.9%
Applied egg-rr93.9%
Final simplification87.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. (FPCore (x c s) :precision binary64 (/ 1.0 (pow (* c (* x s)) 2.0)))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return 1.0 / pow((c * (x * s)), 2.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
code = 1.0d0 / ((c * (x * s)) ** 2.0d0)
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 / Math.pow((c * (x * s)), 2.0);
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return 1.0 / math.pow((c * (x * s)), 2.0)
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(1.0 / (Float64(c * Float64(x * s)) ^ 2.0)) 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)) ^ 2.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_] := N[(1.0 / N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}
\end{array}
Initial program 65.9%
associate-/r*65.8%
remove-double-neg65.8%
distribute-lft-neg-out65.8%
distribute-lft-neg-out65.8%
distribute-rgt-neg-out65.8%
associate-/l/65.9%
distribute-rgt-neg-out65.9%
distribute-lft-neg-out65.9%
associate-*l*67.5%
distribute-lft-neg-in67.5%
distribute-lft-neg-out67.5%
remove-double-neg67.5%
associate-*r*67.3%
*-commutative67.3%
associate-*r*65.5%
Simplified73.1%
Taylor expanded in x around 0 63.4%
associate-*r*58.2%
*-commutative58.2%
associate-*r*58.6%
associate-*l*58.2%
*-commutative58.2%
add-sqr-sqrt58.2%
pow258.2%
sqrt-prod58.2%
sqrt-prod31.4%
add-sqr-sqrt62.9%
sqrt-prod35.0%
sqrt-prod35.7%
sqrt-prod24.1%
add-sqr-sqrt41.5%
associate-*l*41.5%
add-sqr-sqrt78.3%
*-commutative78.3%
Applied egg-rr78.3%
Final simplification78.3%
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 (pow (* c (* x s)) -2.0))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return pow((c * (x * s)), -2.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
code = (c * (x * s)) ** (-2.0d0)
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 Math.pow((c * (x * s)), -2.0);
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return math.pow((c * (x * s)), -2.0)
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(c * Float64(x * s)) ^ -2.0 end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = (c * (x * s)) ^ -2.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_] := N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}
\end{array}
Initial program 65.9%
associate-/r*65.8%
remove-double-neg65.8%
distribute-lft-neg-out65.8%
distribute-lft-neg-out65.8%
distribute-rgt-neg-out65.8%
associate-/l/65.9%
distribute-rgt-neg-out65.9%
distribute-lft-neg-out65.9%
associate-*l*67.5%
distribute-lft-neg-in67.5%
distribute-lft-neg-out67.5%
remove-double-neg67.5%
associate-*r*67.3%
*-commutative67.3%
associate-*r*65.5%
Simplified73.1%
Taylor expanded in x around 0 60.9%
unpow260.9%
unpow260.9%
unpow260.9%
swap-sqr75.6%
swap-sqr96.9%
unpow296.9%
associate-*r*97.9%
*-commutative97.9%
associate-*l*97.0%
Simplified97.0%
Taylor expanded in x around 0 55.7%
unpow255.7%
unpow255.7%
unpow255.7%
associate-*r*55.6%
*-commutative55.6%
swap-sqr67.0%
swap-sqr78.8%
associate-*r*77.6%
associate-*r*78.0%
unpow278.0%
/-rgt-identity78.0%
unpow278.0%
associate-/l*78.0%
associate-/l*78.0%
associate-*l/77.9%
unpow-177.9%
unpow-177.9%
pow-sqr78.0%
Simplified78.3%
Final simplification78.3%
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 (/ 1.0 (* c (* x s))))) (* 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 = 1.0 / (c * (x * s));
return 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 = 1.0d0 / (c * (x * s))
code = 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 = 1.0 / (c * (x * s));
return 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 = 1.0 / (c * (x * s)) return 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(1.0 / Float64(c * Float64(x * s))) return 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 = 1.0 / (c * (x * s));
tmp = 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[(1.0 / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * t$95$0), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \frac{1}{c \cdot \left(x \cdot s\right)}\\
t_0 \cdot t_0
\end{array}
\end{array}
Initial program 65.9%
associate-/r*65.8%
remove-double-neg65.8%
distribute-lft-neg-out65.8%
distribute-lft-neg-out65.8%
distribute-rgt-neg-out65.8%
associate-/l/65.9%
distribute-rgt-neg-out65.9%
distribute-lft-neg-out65.9%
associate-*l*67.5%
distribute-lft-neg-in67.5%
distribute-lft-neg-out67.5%
remove-double-neg67.5%
associate-*r*67.3%
*-commutative67.3%
associate-*r*65.5%
Simplified73.1%
Taylor expanded in x around 0 60.9%
unpow260.9%
unpow260.9%
unpow260.9%
swap-sqr75.6%
swap-sqr96.9%
unpow296.9%
associate-*r*97.9%
*-commutative97.9%
associate-*l*97.0%
Simplified97.0%
Taylor expanded in x around 0 55.7%
unpow255.7%
unpow255.7%
unpow255.7%
associate-*r*55.6%
*-commutative55.6%
swap-sqr67.0%
swap-sqr78.8%
associate-*r*77.6%
associate-*r*78.0%
unpow278.0%
/-rgt-identity78.0%
unpow278.0%
associate-/l*78.0%
associate-/l*78.0%
associate-*l/77.9%
unpow-177.9%
unpow-177.9%
pow-sqr78.0%
Simplified78.3%
metadata-eval78.3%
pow-prod-up78.2%
unpow-178.2%
*-commutative78.2%
unpow-178.2%
*-commutative78.2%
Applied egg-rr78.2%
Final simplification78.2%
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 (* x (* x (* c (* c (* 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 / (x * (x * (c * (c * (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 / (x * (x * (c * (c * (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 / (x * (x * (c * (c * (s * s)))));
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return 1.0 / (x * (x * (c * (c * (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(x * Float64(x * Float64(c * Float64(c * 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 / (x * (x * (c * (c * (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[(x * N[(x * N[(c * N[(c * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{x \cdot \left(x \cdot \left(c \cdot \left(c \cdot \left(s \cdot s\right)\right)\right)\right)}
\end{array}
Initial program 65.9%
associate-/r*65.8%
remove-double-neg65.8%
distribute-lft-neg-out65.8%
distribute-lft-neg-out65.8%
distribute-rgt-neg-out65.8%
associate-/l/65.9%
distribute-rgt-neg-out65.9%
distribute-lft-neg-out65.9%
associate-*l*67.5%
distribute-lft-neg-in67.5%
distribute-lft-neg-out67.5%
remove-double-neg67.5%
associate-*r*67.3%
*-commutative67.3%
associate-*r*65.5%
Simplified73.1%
Taylor expanded in x around 0 63.4%
Final simplification63.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 (* x (* (* s (* x c)) (* 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 / (x * ((s * (x * c)) * (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 / (x * ((s * (x * c)) * (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 / (x * ((s * (x * c)) * (c * s)));
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return 1.0 / (x * ((s * (x * c)) * (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(x * Float64(Float64(s * Float64(x * c)) * 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 / (x * ((s * (x * c)) * (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[(x * N[(N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision] * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{x \cdot \left(\left(s \cdot \left(x \cdot c\right)\right) \cdot \left(c \cdot s\right)\right)}
\end{array}
Initial program 65.9%
associate-/r*65.8%
remove-double-neg65.8%
distribute-lft-neg-out65.8%
distribute-lft-neg-out65.8%
distribute-rgt-neg-out65.8%
associate-/l/65.9%
distribute-rgt-neg-out65.9%
distribute-lft-neg-out65.9%
associate-*l*67.5%
distribute-lft-neg-in67.5%
distribute-lft-neg-out67.5%
remove-double-neg67.5%
associate-*r*67.3%
*-commutative67.3%
associate-*r*65.5%
Simplified73.1%
add-sqr-sqrt37.3%
pow237.3%
associate-*r*33.9%
swap-sqr41.9%
*-commutative41.9%
sqrt-prod41.9%
sqrt-prod28.8%
add-sqr-sqrt48.2%
Applied egg-rr48.2%
unpow248.2%
*-commutative48.2%
associate-*r*48.2%
associate-*r*48.2%
add-sqr-sqrt93.8%
*-commutative93.8%
associate-*r*91.7%
*-commutative91.7%
Applied egg-rr91.7%
Taylor expanded in x around 0 74.6%
Final simplification74.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 (/ 1.0 (* (* x c) (* s (* s (* x c))))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return 1.0 / ((x * c) * (s * (s * (x * c))));
}
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 / ((x * c) * (s * (s * (x * c))))
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 / ((x * c) * (s * (s * (x * c))));
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return 1.0 / ((x * c) * (s * (s * (x * c))))
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(x * c) * Float64(s * Float64(s * Float64(x * c))))) 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 / ((x * c) * (s * (s * (x * c))));
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[(x * c), $MachinePrecision] * N[(s * 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])\\
\\
\frac{1}{\left(x \cdot c\right) \cdot \left(s \cdot \left(s \cdot \left(x \cdot c\right)\right)\right)}
\end{array}
Initial program 65.9%
associate-/r*65.8%
remove-double-neg65.8%
distribute-lft-neg-out65.8%
distribute-lft-neg-out65.8%
distribute-rgt-neg-out65.8%
associate-/l/65.9%
distribute-rgt-neg-out65.9%
distribute-lft-neg-out65.9%
associate-*l*67.5%
distribute-lft-neg-in67.5%
distribute-lft-neg-out67.5%
remove-double-neg67.5%
associate-*r*67.3%
*-commutative67.3%
associate-*r*65.5%
Simplified73.1%
Taylor expanded in x around 0 60.9%
unpow260.9%
unpow260.9%
unpow260.9%
swap-sqr75.6%
swap-sqr96.9%
unpow296.9%
associate-*r*97.9%
*-commutative97.9%
associate-*l*97.0%
Simplified97.0%
unpow297.0%
associate-*r*95.8%
*-commutative95.8%
associate-*r*94.7%
associate-*r*89.7%
associate-*r*91.4%
*-commutative91.4%
associate-*r*91.7%
Applied egg-rr91.7%
Taylor expanded in x around 0 74.5%
Final simplification74.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 (/ -2.0 (* (* s s) (* c c))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return -2.0 / ((s * s) * (c * c));
}
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 = (-2.0d0) / ((s * s) * (c * c))
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 -2.0 / ((s * s) * (c * c));
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return -2.0 / ((s * s) * (c * c))
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(-2.0 / Float64(Float64(s * s) * Float64(c * c))) end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = -2.0 / ((s * s) * (c * c));
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[(-2.0 / N[(N[(s * s), $MachinePrecision] * N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{-2}{\left(s \cdot s\right) \cdot \left(c \cdot c\right)}
\end{array}
Initial program 65.9%
associate-/r*65.8%
*-commutative65.8%
associate-*l*60.9%
unpow260.9%
unpow260.9%
associate-*r*66.8%
associate-/r*69.0%
associate-/l/69.1%
associate-/l/69.1%
*-commutative69.1%
associate-*l*66.0%
unpow266.0%
associate-*l*60.8%
unpow260.8%
unswap-sqr77.8%
*-commutative77.8%
*-commutative77.8%
Simplified77.8%
Taylor expanded in x around 0 49.8%
unpow249.8%
Simplified49.8%
Taylor expanded in x around inf 27.2%
unpow227.2%
unpow227.2%
associate-/r*27.2%
Simplified27.2%
Taylor expanded in c around 0 27.2%
unpow227.2%
unpow227.2%
Simplified27.2%
Final simplification27.2%
herbie shell --seed 2023271
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))