
(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 8 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 1.75e-29) (pow (* c (* x s)) -2.0) (/ (/ (/ (cos (* x 2.0)) s) (* 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 <= 1.75e-29) {
tmp = pow((c * (x * s)), -2.0);
} else {
tmp = ((cos((x * 2.0)) / s) / (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 <= 1.75d-29) then
tmp = (c * (x * s)) ** (-2.0d0)
else
tmp = ((cos((x * 2.0d0)) / s) / (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 <= 1.75e-29) {
tmp = Math.pow((c * (x * s)), -2.0);
} else {
tmp = ((Math.cos((x * 2.0)) / s) / (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 <= 1.75e-29: tmp = math.pow((c * (x * s)), -2.0) else: tmp = ((math.cos((x * 2.0)) / s) / (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 <= 1.75e-29) tmp = Float64(c * Float64(x * s)) ^ -2.0; else tmp = Float64(Float64(Float64(cos(Float64(x * 2.0)) / s) / 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 <= 1.75e-29)
tmp = (c * (x * s)) ^ -2.0;
else
tmp = ((cos((x * 2.0)) / s) / (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, 1.75e-29], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / s), $MachinePrecision] / N[(x * c), $MachinePrecision]), $MachinePrecision] / N[(s * N[(x * c), $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 1.75 \cdot 10^{-29}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{\cos \left(x \cdot 2\right)}{s}}{x \cdot c}}{s \cdot \left(x \cdot c\right)}\\
\end{array}
\end{array}
if x < 1.7499999999999999e-29Initial program 63.5%
associate-/r*62.8%
remove-double-neg62.8%
distribute-lft-neg-out62.8%
distribute-lft-neg-out62.8%
distribute-rgt-neg-out62.8%
associate-/l/63.5%
distribute-rgt-neg-out63.5%
distribute-lft-neg-out63.5%
associate-*l*65.5%
distribute-lft-neg-in65.5%
distribute-lft-neg-out65.5%
remove-double-neg65.5%
associate-*r*64.7%
*-commutative64.7%
associate-*r*63.8%
Simplified71.3%
Taylor expanded in x around 0 55.1%
unpow255.1%
unpow255.1%
unpow255.1%
swap-sqr74.1%
swap-sqr95.0%
unpow295.0%
associate-*r*96.3%
*-commutative96.3%
associate-*l*96.3%
Simplified96.3%
Taylor expanded in x around 0 50.0%
unpow250.0%
unpow250.0%
associate-*r*50.6%
*-commutative50.6%
swap-sqr62.1%
unpow262.1%
swap-sqr80.7%
associate-*r*79.6%
associate-*r*80.8%
associate-/r*81.1%
*-lft-identity81.1%
associate-*l/81.1%
unpow-181.1%
unpow-181.1%
pow-sqr81.1%
metadata-eval81.1%
associate-*r*80.7%
*-commutative80.7%
associate-*r*80.3%
Simplified80.3%
if 1.7499999999999999e-29 < x Initial program 57.4%
associate-/r*58.0%
remove-double-neg58.0%
distribute-lft-neg-out58.0%
distribute-lft-neg-out58.0%
distribute-rgt-neg-out58.0%
associate-/l/57.4%
distribute-rgt-neg-out57.4%
distribute-lft-neg-out57.4%
associate-*l*58.9%
distribute-lft-neg-in58.9%
distribute-lft-neg-out58.9%
remove-double-neg58.9%
associate-*r*60.1%
*-commutative60.1%
associate-*r*60.0%
Simplified60.0%
associate-/r*60.9%
swap-sqr82.5%
associate-/r*76.6%
associate-/r*75.8%
associate-/r*75.8%
*-un-lft-identity75.8%
add-sqr-sqrt75.7%
times-frac75.7%
Applied egg-rr96.9%
associate-*l/96.9%
*-un-lft-identity96.9%
associate-*r*91.2%
*-commutative91.2%
associate-*r*94.6%
associate-*r*91.2%
*-commutative91.2%
associate-*r*97.1%
Applied egg-rr97.1%
associate-/r*97.1%
div-inv97.1%
*-commutative97.1%
Applied egg-rr97.1%
un-div-inv97.1%
Applied egg-rr97.1%
Final simplification85.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 6500.0) (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 <= 6500.0) {
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 <= 6500.0d0) 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 <= 6500.0) {
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 <= 6500.0: 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 <= 6500.0) 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 <= 6500.0)
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, 6500.0], 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 6500:\\
\;\;\;\;{\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 < 6500Initial program 63.9%
associate-/r*63.3%
remove-double-neg63.3%
distribute-lft-neg-out63.3%
distribute-lft-neg-out63.3%
distribute-rgt-neg-out63.3%
associate-/l/63.9%
distribute-rgt-neg-out63.9%
distribute-lft-neg-out63.9%
associate-*l*65.9%
distribute-lft-neg-in65.9%
distribute-lft-neg-out65.9%
remove-double-neg65.9%
associate-*r*65.1%
*-commutative65.1%
associate-*r*64.3%
Simplified71.5%
Taylor expanded in x around 0 55.7%
unpow255.7%
unpow255.7%
unpow255.7%
swap-sqr74.3%
swap-sqr95.1%
unpow295.1%
associate-*r*96.4%
*-commutative96.4%
associate-*l*96.4%
Simplified96.4%
Taylor expanded in x around 0 50.7%
unpow250.7%
unpow250.7%
associate-*r*51.3%
*-commutative51.3%
swap-sqr62.7%
unpow262.7%
swap-sqr80.8%
associate-*r*79.8%
associate-*r*80.9%
associate-/r*81.2%
*-lft-identity81.2%
associate-*l/81.2%
unpow-181.2%
unpow-181.2%
pow-sqr81.2%
metadata-eval81.2%
associate-*r*80.8%
*-commutative80.8%
associate-*r*80.4%
Simplified80.4%
if 6500 < x Initial program 55.7%
associate-/r*56.4%
remove-double-neg56.4%
distribute-lft-neg-out56.4%
distribute-lft-neg-out56.4%
distribute-rgt-neg-out56.4%
associate-/l/55.7%
distribute-rgt-neg-out55.7%
distribute-lft-neg-out55.7%
associate-*l*57.3%
distribute-lft-neg-in57.3%
distribute-lft-neg-out57.3%
remove-double-neg57.3%
associate-*r*58.6%
*-commutative58.6%
associate-*r*58.5%
Simplified64.7%
Final simplification76.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 (if (<= x 2.9e-8) (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 <= 2.9e-8) {
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 <= 2.9d-8) 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 <= 2.9e-8) {
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 <= 2.9e-8: 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 <= 2.9e-8) tmp = Float64(c * Float64(x * s)) ^ -2.0; else tmp = Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(x * Float64(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 <= 2.9e-8)
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, 2.9e-8], 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[(s * N[(c * 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 2.9 \cdot 10^{-8}:\\
\;\;\;\;{\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(s \cdot \left(c \cdot s\right)\right)\right)\right)}\\
\end{array}
\end{array}
if x < 2.9000000000000002e-8Initial program 64.0%
associate-/r*63.4%
remove-double-neg63.4%
distribute-lft-neg-out63.4%
distribute-lft-neg-out63.4%
distribute-rgt-neg-out63.4%
associate-/l/64.0%
distribute-rgt-neg-out64.0%
distribute-lft-neg-out64.0%
associate-*l*66.0%
distribute-lft-neg-in66.0%
distribute-lft-neg-out66.0%
remove-double-neg66.0%
associate-*r*65.3%
*-commutative65.3%
associate-*r*64.4%
Simplified71.7%
Taylor expanded in x around 0 55.8%
unpow255.8%
unpow255.8%
unpow255.8%
swap-sqr74.5%
swap-sqr95.1%
unpow295.1%
associate-*r*96.4%
*-commutative96.4%
associate-*l*96.4%
Simplified96.4%
Taylor expanded in x around 0 50.8%
unpow250.8%
unpow250.8%
associate-*r*51.4%
*-commutative51.4%
swap-sqr62.7%
unpow262.7%
swap-sqr81.0%
associate-*r*79.9%
associate-*r*81.1%
associate-/r*81.4%
*-lft-identity81.4%
associate-*l/81.4%
unpow-181.4%
unpow-181.4%
pow-sqr81.4%
metadata-eval81.4%
associate-*r*81.0%
*-commutative81.0%
associate-*r*80.6%
Simplified80.6%
if 2.9000000000000002e-8 < x Initial program 55.6%
associate-/r*56.2%
remove-double-neg56.2%
distribute-lft-neg-out56.2%
distribute-lft-neg-out56.2%
distribute-rgt-neg-out56.2%
associate-/l/55.6%
distribute-rgt-neg-out55.6%
distribute-lft-neg-out55.6%
associate-*l*57.1%
distribute-lft-neg-in57.1%
distribute-lft-neg-out57.1%
remove-double-neg57.1%
associate-*r*58.3%
*-commutative58.3%
associate-*r*58.2%
Simplified64.3%
Taylor expanded in c around 0 64.3%
unpow264.3%
associate-*r*79.5%
*-commutative79.5%
Simplified79.5%
Final simplification80.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 (* s (* x c))))
(if (<= x 2.25e-23)
(pow (* c (* x s)) -2.0)
(/ (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 <= 2.25e-23) {
tmp = pow((c * (x * s)), -2.0);
} 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 <= 2.25d-23) then
tmp = (c * (x * s)) ** (-2.0d0)
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 <= 2.25e-23) {
tmp = Math.pow((c * (x * s)), -2.0);
} 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 <= 2.25e-23: tmp = math.pow((c * (x * s)), -2.0) 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 <= 2.25e-23) tmp = Float64(c * Float64(x * s)) ^ -2.0; 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 <= 2.25e-23)
tmp = (c * (x * s)) ^ -2.0;
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, 2.25e-23], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $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 2.25 \cdot 10^{-23}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{t_0 \cdot t_0}\\
\end{array}
\end{array}
if x < 2.24999999999999987e-23Initial program 63.5%
associate-/r*62.8%
remove-double-neg62.8%
distribute-lft-neg-out62.8%
distribute-lft-neg-out62.8%
distribute-rgt-neg-out62.8%
associate-/l/63.5%
distribute-rgt-neg-out63.5%
distribute-lft-neg-out63.5%
associate-*l*65.5%
distribute-lft-neg-in65.5%
distribute-lft-neg-out65.5%
remove-double-neg65.5%
associate-*r*64.7%
*-commutative64.7%
associate-*r*63.8%
Simplified71.3%
Taylor expanded in x around 0 55.1%
unpow255.1%
unpow255.1%
unpow255.1%
swap-sqr74.1%
swap-sqr95.0%
unpow295.0%
associate-*r*96.3%
*-commutative96.3%
associate-*l*96.3%
Simplified96.3%
Taylor expanded in x around 0 50.0%
unpow250.0%
unpow250.0%
associate-*r*50.6%
*-commutative50.6%
swap-sqr62.1%
unpow262.1%
swap-sqr80.7%
associate-*r*79.6%
associate-*r*80.8%
associate-/r*81.1%
*-lft-identity81.1%
associate-*l/81.1%
unpow-181.1%
unpow-181.1%
pow-sqr81.1%
metadata-eval81.1%
associate-*r*80.7%
*-commutative80.7%
associate-*r*80.3%
Simplified80.3%
if 2.24999999999999987e-23 < x Initial program 57.4%
associate-/r*58.0%
remove-double-neg58.0%
distribute-lft-neg-out58.0%
distribute-lft-neg-out58.0%
distribute-rgt-neg-out58.0%
associate-/l/57.4%
distribute-rgt-neg-out57.4%
distribute-lft-neg-out57.4%
associate-*l*58.9%
distribute-lft-neg-in58.9%
distribute-lft-neg-out58.9%
remove-double-neg58.9%
associate-*r*60.1%
*-commutative60.1%
associate-*r*60.0%
Simplified65.8%
Taylor expanded in x around 0 55.2%
unpow255.2%
unpow255.2%
unpow255.2%
swap-sqr67.2%
swap-sqr96.0%
unpow296.0%
associate-*r*92.7%
*-commutative92.7%
associate-*l*96.2%
Simplified96.2%
unpow296.2%
Applied egg-rr96.2%
Final simplification84.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 (* s (* x c)))) (if (<= x 5e-26) (pow (* c (* x s)) -2.0) (/ (/ (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 <= 5e-26) {
tmp = pow((c * (x * s)), -2.0);
} 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 <= 5d-26) then
tmp = (c * (x * s)) ** (-2.0d0)
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 <= 5e-26) {
tmp = Math.pow((c * (x * s)), -2.0);
} 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 <= 5e-26: tmp = math.pow((c * (x * s)), -2.0) 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 <= 5e-26) tmp = Float64(c * Float64(x * s)) ^ -2.0; else tmp = Float64(Float64(cos(Float64(x * 2.0)) / 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 <= 5e-26)
tmp = (c * (x * s)) ^ -2.0;
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, 5e-26], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $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 5 \cdot 10^{-26}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(x \cdot 2\right)}{t_0}}{t_0}\\
\end{array}
\end{array}
if x < 5.00000000000000019e-26Initial program 63.5%
associate-/r*62.8%
remove-double-neg62.8%
distribute-lft-neg-out62.8%
distribute-lft-neg-out62.8%
distribute-rgt-neg-out62.8%
associate-/l/63.5%
distribute-rgt-neg-out63.5%
distribute-lft-neg-out63.5%
associate-*l*65.5%
distribute-lft-neg-in65.5%
distribute-lft-neg-out65.5%
remove-double-neg65.5%
associate-*r*64.7%
*-commutative64.7%
associate-*r*63.8%
Simplified71.3%
Taylor expanded in x around 0 55.1%
unpow255.1%
unpow255.1%
unpow255.1%
swap-sqr74.1%
swap-sqr95.0%
unpow295.0%
associate-*r*96.3%
*-commutative96.3%
associate-*l*96.3%
Simplified96.3%
Taylor expanded in x around 0 50.0%
unpow250.0%
unpow250.0%
associate-*r*50.6%
*-commutative50.6%
swap-sqr62.1%
unpow262.1%
swap-sqr80.7%
associate-*r*79.6%
associate-*r*80.8%
associate-/r*81.1%
*-lft-identity81.1%
associate-*l/81.1%
unpow-181.1%
unpow-181.1%
pow-sqr81.1%
metadata-eval81.1%
associate-*r*80.7%
*-commutative80.7%
associate-*r*80.3%
Simplified80.3%
if 5.00000000000000019e-26 < x Initial program 57.4%
associate-/r*58.0%
remove-double-neg58.0%
distribute-lft-neg-out58.0%
distribute-lft-neg-out58.0%
distribute-rgt-neg-out58.0%
associate-/l/57.4%
distribute-rgt-neg-out57.4%
distribute-lft-neg-out57.4%
associate-*l*58.9%
distribute-lft-neg-in58.9%
distribute-lft-neg-out58.9%
remove-double-neg58.9%
associate-*r*60.1%
*-commutative60.1%
associate-*r*60.0%
Simplified60.0%
associate-/r*60.9%
swap-sqr82.5%
associate-/r*76.6%
associate-/r*75.8%
associate-/r*75.8%
*-un-lft-identity75.8%
add-sqr-sqrt75.7%
times-frac75.7%
Applied egg-rr96.9%
associate-*l/96.9%
*-un-lft-identity96.9%
associate-*r*91.2%
*-commutative91.2%
associate-*r*94.6%
associate-*r*91.2%
*-commutative91.2%
associate-*r*97.1%
Applied egg-rr97.1%
Final simplification85.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 (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 61.8%
associate-/r*61.5%
remove-double-neg61.5%
distribute-lft-neg-out61.5%
distribute-lft-neg-out61.5%
distribute-rgt-neg-out61.5%
associate-/l/61.8%
distribute-rgt-neg-out61.8%
distribute-lft-neg-out61.8%
associate-*l*63.6%
distribute-lft-neg-in63.6%
distribute-lft-neg-out63.6%
remove-double-neg63.6%
associate-*r*63.4%
*-commutative63.4%
associate-*r*62.7%
Simplified69.7%
Taylor expanded in x around 0 55.1%
unpow255.1%
unpow255.1%
unpow255.1%
swap-sqr72.2%
swap-sqr95.3%
unpow295.3%
associate-*r*95.3%
*-commutative95.3%
associate-*l*96.3%
Simplified96.3%
Taylor expanded in x around 0 48.8%
unpow248.8%
unpow248.8%
associate-*r*49.3%
*-commutative49.3%
swap-sqr60.0%
unpow260.0%
swap-sqr74.3%
associate-*r*73.6%
associate-*r*74.5%
associate-/r*74.7%
*-lft-identity74.7%
associate-*l/74.7%
unpow-174.7%
unpow-174.7%
pow-sqr74.7%
metadata-eval74.7%
associate-*r*74.3%
*-commutative74.3%
associate-*r*74.0%
Simplified74.0%
Final simplification74.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 (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 61.8%
associate-/r*61.5%
remove-double-neg61.5%
distribute-lft-neg-out61.5%
distribute-lft-neg-out61.5%
distribute-rgt-neg-out61.5%
associate-/l/61.8%
distribute-rgt-neg-out61.8%
distribute-lft-neg-out61.8%
associate-*l*63.6%
distribute-lft-neg-in63.6%
distribute-lft-neg-out63.6%
remove-double-neg63.6%
associate-*r*63.4%
*-commutative63.4%
associate-*r*62.7%
Simplified62.7%
associate-/r*63.0%
swap-sqr82.8%
associate-/r*71.5%
associate-/r*70.9%
associate-/r*71.3%
*-un-lft-identity71.3%
add-sqr-sqrt71.3%
times-frac71.3%
Applied egg-rr95.8%
Taylor expanded in x around 0 74.0%
Final simplification74.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 (let* ((t_0 (* c (* x 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 = c * (x * 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 = c * (x * 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 = c * (x * 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 = c * (x * 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(c * Float64(x * 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 = c * (x * 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[(c * N[(x * 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 := c \cdot \left(x \cdot s\right)\\
\frac{1}{t_0 \cdot t_0}
\end{array}
\end{array}
Initial program 61.8%
associate-/r*61.5%
remove-double-neg61.5%
distribute-lft-neg-out61.5%
distribute-lft-neg-out61.5%
distribute-rgt-neg-out61.5%
associate-/l/61.8%
distribute-rgt-neg-out61.8%
distribute-lft-neg-out61.8%
associate-*l*63.6%
distribute-lft-neg-in63.6%
distribute-lft-neg-out63.6%
remove-double-neg63.6%
associate-*r*63.4%
*-commutative63.4%
associate-*r*62.7%
Simplified62.7%
associate-/r*63.0%
swap-sqr82.8%
associate-/r*71.5%
associate-/r*70.9%
associate-/r*71.3%
*-un-lft-identity71.3%
add-sqr-sqrt71.3%
times-frac71.3%
Applied egg-rr95.8%
*-commutative95.8%
clear-num95.8%
frac-times95.3%
metadata-eval95.3%
associate-*r*92.0%
*-commutative92.0%
associate-*r*92.9%
associate-*r*92.9%
*-commutative92.9%
associate-*r*96.3%
Applied egg-rr96.3%
Taylor expanded in x around 0 73.0%
Taylor expanded in s around 0 73.7%
Final simplification73.7%
herbie shell --seed 2023278
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))