
(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}
(FPCore (x c s) :precision binary64 (* (/ (/ 1.0 x) (* c s)) (/ (cos (* x 2.0)) (* x (* c s)))))
double code(double x, double c, double s) {
return ((1.0 / x) / (c * s)) * (cos((x * 2.0)) / (x * (c * s)));
}
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)) * (cos((x * 2.0d0)) / (x * (c * s)))
end function
public static double code(double x, double c, double s) {
return ((1.0 / x) / (c * s)) * (Math.cos((x * 2.0)) / (x * (c * s)));
}
def code(x, c, s): return ((1.0 / x) / (c * s)) * (math.cos((x * 2.0)) / (x * (c * s)))
function code(x, c, s) return Float64(Float64(Float64(1.0 / x) / Float64(c * s)) * Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(c * s)))) end
function tmp = code(x, c, s) tmp = ((1.0 / x) / (c * s)) * (cos((x * 2.0)) / (x * (c * s))); end
code[x_, c_, s_] := N[(N[(N[(1.0 / x), $MachinePrecision] / N[(c * s), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{c \cdot s} \cdot \frac{\cos \left(x \cdot 2\right)}{x \cdot \left(c \cdot s\right)}
\end{array}
Initial program 63.4%
associate-*r*64.5%
*-commutative64.5%
*-commutative64.5%
associate-*r*63.0%
*-commutative63.0%
unpow263.0%
unpow263.0%
Simplified63.0%
*-un-lft-identity63.0%
associate-*r*64.1%
*-commutative64.1%
add-sqr-sqrt64.1%
times-frac64.0%
Applied egg-rr98.2%
Taylor expanded in x around 0 95.4%
*-commutative95.4%
*-commutative95.4%
associate-*r*98.2%
associate-/r*98.2%
*-commutative98.2%
Simplified98.2%
Final simplification98.2%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (* x (* c s))))
(if (<= x -8.8e+154)
(/ 1.0 (* (* s (* x c)) t_0))
(if (or (<= x -0.013) (not (<= x 0.62)))
(/ (cos (* x 2.0)) (* s (* (* x x) (* s (* c c)))))
(pow t_0 -2.0)))))
double code(double x, double c, double s) {
double t_0 = x * (c * s);
double tmp;
if (x <= -8.8e+154) {
tmp = 1.0 / ((s * (x * c)) * t_0);
} else if ((x <= -0.013) || !(x <= 0.62)) {
tmp = cos((x * 2.0)) / (s * ((x * x) * (s * (c * c))));
} else {
tmp = pow(t_0, -2.0);
}
return tmp;
}
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 = x * (c * s)
if (x <= (-8.8d+154)) then
tmp = 1.0d0 / ((s * (x * c)) * t_0)
else if ((x <= (-0.013d0)) .or. (.not. (x <= 0.62d0))) then
tmp = cos((x * 2.0d0)) / (s * ((x * x) * (s * (c * c))))
else
tmp = t_0 ** (-2.0d0)
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double t_0 = x * (c * s);
double tmp;
if (x <= -8.8e+154) {
tmp = 1.0 / ((s * (x * c)) * t_0);
} else if ((x <= -0.013) || !(x <= 0.62)) {
tmp = Math.cos((x * 2.0)) / (s * ((x * x) * (s * (c * c))));
} else {
tmp = Math.pow(t_0, -2.0);
}
return tmp;
}
def code(x, c, s): t_0 = x * (c * s) tmp = 0 if x <= -8.8e+154: tmp = 1.0 / ((s * (x * c)) * t_0) elif (x <= -0.013) or not (x <= 0.62): tmp = math.cos((x * 2.0)) / (s * ((x * x) * (s * (c * c)))) else: tmp = math.pow(t_0, -2.0) return tmp
function code(x, c, s) t_0 = Float64(x * Float64(c * s)) tmp = 0.0 if (x <= -8.8e+154) tmp = Float64(1.0 / Float64(Float64(s * Float64(x * c)) * t_0)); elseif ((x <= -0.013) || !(x <= 0.62)) tmp = Float64(cos(Float64(x * 2.0)) / Float64(s * Float64(Float64(x * x) * Float64(s * Float64(c * c))))); else tmp = t_0 ^ -2.0; end return tmp end
function tmp_2 = code(x, c, s) t_0 = x * (c * s); tmp = 0.0; if (x <= -8.8e+154) tmp = 1.0 / ((s * (x * c)) * t_0); elseif ((x <= -0.013) || ~((x <= 0.62))) tmp = cos((x * 2.0)) / (s * ((x * x) * (s * (c * c)))); else tmp = t_0 ^ -2.0; end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -8.8e+154], N[(1.0 / N[(N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, -0.013], N[Not[LessEqual[x, 0.62]], $MachinePrecision]], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(s * N[(N[(x * x), $MachinePrecision] * N[(s * N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[t$95$0, -2.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(c \cdot s\right)\\
\mathbf{if}\;x \leq -8.8 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{\left(s \cdot \left(x \cdot c\right)\right) \cdot t_0}\\
\mathbf{elif}\;x \leq -0.013 \lor \neg \left(x \leq 0.62\right):\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{s \cdot \left(\left(x \cdot x\right) \cdot \left(s \cdot \left(c \cdot c\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;{t_0}^{-2}\\
\end{array}
\end{array}
if x < -8.8000000000000004e154Initial program 73.5%
*-commutative73.5%
associate-*r*63.4%
associate-*r*63.4%
unpow263.4%
unswap-sqr84.9%
unpow284.9%
swap-sqr94.7%
*-commutative94.7%
*-commutative94.7%
*-commutative94.7%
*-commutative94.7%
Simplified94.7%
Taylor expanded in x around 0 63.4%
unpow263.4%
unpow263.4%
*-commutative63.4%
associate-*r*63.4%
unpow263.4%
unpow263.4%
*-commutative63.4%
unpow263.4%
swap-sqr79.1%
unpow279.1%
associate-*r*79.6%
*-commutative79.6%
*-commutative79.6%
associate-*r*79.1%
unpow279.1%
swap-sqr79.9%
unpow279.9%
Simplified79.9%
associate-*r*79.9%
*-commutative79.9%
*-commutative79.9%
pow279.9%
*-commutative79.9%
*-commutative79.9%
Applied egg-rr79.9%
Taylor expanded in x around 0 79.9%
if -8.8000000000000004e154 < x < -0.0129999999999999994 or 0.619999999999999996 < x Initial program 63.5%
*-commutative63.5%
associate-*l*59.2%
associate-*r*57.2%
*-commutative57.2%
unpow257.2%
associate-*r*62.3%
associate-*r*64.2%
*-commutative64.2%
unpow264.2%
Simplified64.2%
if -0.0129999999999999994 < x < 0.619999999999999996Initial program 61.3%
*-commutative61.3%
associate-*r*56.4%
associate-*r*57.0%
unpow257.0%
unswap-sqr70.3%
unpow270.3%
swap-sqr97.1%
*-commutative97.1%
*-commutative97.1%
*-commutative97.1%
*-commutative97.1%
Simplified97.1%
Taylor expanded in x around 0 56.4%
unpow256.4%
unpow256.4%
unpow256.4%
Simplified56.4%
add-sqr-sqrt56.4%
pow256.4%
sqrt-div56.4%
metadata-eval56.4%
associate-*r*61.3%
associate-*r*69.5%
*-commutative69.5%
*-commutative69.5%
sqrt-prod69.5%
associate-*r*72.5%
*-commutative72.5%
sqrt-prod51.5%
add-sqr-sqrt77.7%
*-commutative77.7%
sqrt-prod53.0%
add-sqr-sqrt94.8%
associate-*r*97.6%
Applied egg-rr97.7%
Final simplification84.7%
(FPCore (x c s) :precision binary64 (if (or (<= x -1.5e+32) (not (<= x 0.64))) (/ (cos (* x 2.0)) (* x (* c (* c (* s (* x s)))))) (pow (* x (* c s)) -2.0)))
double code(double x, double c, double s) {
double tmp;
if ((x <= -1.5e+32) || !(x <= 0.64)) {
tmp = cos((x * 2.0)) / (x * (c * (c * (s * (x * s)))));
} else {
tmp = pow((x * (c * s)), -2.0);
}
return tmp;
}
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.5d+32)) .or. (.not. (x <= 0.64d0))) then
tmp = cos((x * 2.0d0)) / (x * (c * (c * (s * (x * s)))))
else
tmp = (x * (c * s)) ** (-2.0d0)
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double tmp;
if ((x <= -1.5e+32) || !(x <= 0.64)) {
tmp = Math.cos((x * 2.0)) / (x * (c * (c * (s * (x * s)))));
} else {
tmp = Math.pow((x * (c * s)), -2.0);
}
return tmp;
}
def code(x, c, s): tmp = 0 if (x <= -1.5e+32) or not (x <= 0.64): tmp = math.cos((x * 2.0)) / (x * (c * (c * (s * (x * s))))) else: tmp = math.pow((x * (c * s)), -2.0) return tmp
function code(x, c, s) tmp = 0.0 if ((x <= -1.5e+32) || !(x <= 0.64)) tmp = Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(c * Float64(c * Float64(s * Float64(x * s)))))); else tmp = Float64(x * Float64(c * s)) ^ -2.0; end return tmp end
function tmp_2 = code(x, c, s) tmp = 0.0; if ((x <= -1.5e+32) || ~((x <= 0.64))) tmp = cos((x * 2.0)) / (x * (c * (c * (s * (x * s))))); else tmp = (x * (c * s)) ^ -2.0; end tmp_2 = tmp; end
code[x_, c_, s_] := If[Or[LessEqual[x, -1.5e+32], N[Not[LessEqual[x, 0.64]], $MachinePrecision]], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * N[(c * N[(c * N[(s * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \cdot 10^{+32} \lor \neg \left(x \leq 0.64\right):\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(c \cdot \left(c \cdot \left(s \cdot \left(x \cdot s\right)\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left(x \cdot \left(c \cdot s\right)\right)}^{-2}\\
\end{array}
\end{array}
if x < -1.5e32 or 0.640000000000000013 < x Initial program 66.6%
associate-*r*67.9%
*-commutative67.9%
associate-*r*67.0%
unpow267.0%
unpow267.0%
Simplified67.0%
Taylor expanded in c around 0 67.0%
*-commutative67.0%
unpow267.0%
associate-*r*70.7%
*-commutative70.7%
Simplified70.7%
Taylor expanded in c around 0 67.0%
associate-*r*65.9%
*-commutative65.9%
associate-*r*67.9%
unpow267.9%
associate-*l*74.1%
unpow274.1%
associate-*l*81.3%
Simplified81.3%
if -1.5e32 < x < 0.640000000000000013Initial program 61.1%
*-commutative61.1%
associate-*r*56.3%
associate-*r*56.9%
unpow256.9%
unswap-sqr69.8%
unpow269.8%
swap-sqr96.7%
*-commutative96.7%
*-commutative96.7%
*-commutative96.7%
*-commutative96.7%
Simplified96.7%
Taylor expanded in x around 0 56.3%
unpow256.3%
unpow256.3%
unpow256.3%
Simplified56.3%
add-sqr-sqrt56.2%
pow256.2%
sqrt-div56.2%
metadata-eval56.2%
associate-*r*61.0%
associate-*r*69.0%
*-commutative69.0%
*-commutative69.0%
sqrt-prod69.0%
associate-*r*72.0%
*-commutative72.0%
sqrt-prod50.8%
add-sqr-sqrt77.0%
*-commutative77.0%
sqrt-prod52.6%
add-sqr-sqrt94.0%
associate-*r*96.7%
Applied egg-rr96.8%
Final simplification90.1%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (* c (* x s))))
(if (<= s 8.5e+184)
(/ (cos (* x 2.0)) (* t_0 (* s (* x c))))
(pow t_0 -2.0))))
double code(double x, double c, double s) {
double t_0 = c * (x * s);
double tmp;
if (s <= 8.5e+184) {
tmp = cos((x * 2.0)) / (t_0 * (s * (x * c)));
} else {
tmp = pow(t_0, -2.0);
}
return tmp;
}
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 = c * (x * s)
if (s <= 8.5d+184) then
tmp = cos((x * 2.0d0)) / (t_0 * (s * (x * c)))
else
tmp = t_0 ** (-2.0d0)
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double t_0 = c * (x * s);
double tmp;
if (s <= 8.5e+184) {
tmp = Math.cos((x * 2.0)) / (t_0 * (s * (x * c)));
} else {
tmp = Math.pow(t_0, -2.0);
}
return tmp;
}
def code(x, c, s): t_0 = c * (x * s) tmp = 0 if s <= 8.5e+184: tmp = math.cos((x * 2.0)) / (t_0 * (s * (x * c))) else: tmp = math.pow(t_0, -2.0) return tmp
function code(x, c, s) t_0 = Float64(c * Float64(x * s)) tmp = 0.0 if (s <= 8.5e+184) tmp = Float64(cos(Float64(x * 2.0)) / Float64(t_0 * Float64(s * Float64(x * c)))); else tmp = t_0 ^ -2.0; end return tmp end
function tmp_2 = code(x, c, s) t_0 = c * (x * s); tmp = 0.0; if (s <= 8.5e+184) tmp = cos((x * 2.0)) / (t_0 * (s * (x * c))); else tmp = t_0 ^ -2.0; end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[s, 8.5e+184], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[t$95$0, -2.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\mathbf{if}\;s \leq 8.5 \cdot 10^{+184}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{t_0 \cdot \left(s \cdot \left(x \cdot c\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;{t_0}^{-2}\\
\end{array}
\end{array}
if s < 8.50000000000000043e184Initial program 63.4%
*-commutative63.4%
associate-*r*58.0%
associate-*r*57.6%
unpow257.6%
unswap-sqr72.8%
unpow272.8%
swap-sqr96.5%
*-commutative96.5%
*-commutative96.5%
*-commutative96.5%
*-commutative96.5%
Simplified96.5%
Taylor expanded in s around 0 93.6%
if 8.50000000000000043e184 < s Initial program 63.8%
associate-*r*63.8%
*-commutative63.8%
*-commutative63.8%
associate-*r*63.8%
*-commutative63.8%
unpow263.8%
unpow263.8%
Simplified63.8%
*-un-lft-identity63.8%
associate-*r*63.4%
*-commutative63.4%
add-sqr-sqrt63.4%
times-frac63.4%
Applied egg-rr99.8%
Taylor expanded in x around 0 59.6%
associate-*r*59.8%
*-commutative59.8%
*-commutative59.8%
unpow259.8%
*-commutative59.8%
unpow259.8%
unpow259.8%
swap-sqr82.1%
swap-sqr99.9%
associate-/r*99.9%
*-lft-identity99.9%
associate-*l/99.8%
unpow-199.8%
unpow-199.8%
pow-sqr100.0%
metadata-eval100.0%
associate-*r*99.9%
*-commutative99.9%
*-commutative99.9%
Simplified99.9%
Final simplification94.2%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (* s (* x c))))
(if (<= s 1.28e+185)
(/ (cos (* x 2.0)) (* t_0 t_0))
(pow (* c (* x s)) -2.0))))
double code(double x, double c, double s) {
double t_0 = s * (x * c);
double tmp;
if (s <= 1.28e+185) {
tmp = cos((x * 2.0)) / (t_0 * t_0);
} else {
tmp = pow((c * (x * s)), -2.0);
}
return tmp;
}
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 (s <= 1.28d+185) then
tmp = cos((x * 2.0d0)) / (t_0 * t_0)
else
tmp = (c * (x * s)) ** (-2.0d0)
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double t_0 = s * (x * c);
double tmp;
if (s <= 1.28e+185) {
tmp = Math.cos((x * 2.0)) / (t_0 * t_0);
} else {
tmp = Math.pow((c * (x * s)), -2.0);
}
return tmp;
}
def code(x, c, s): t_0 = s * (x * c) tmp = 0 if s <= 1.28e+185: tmp = math.cos((x * 2.0)) / (t_0 * t_0) else: tmp = math.pow((c * (x * s)), -2.0) return tmp
function code(x, c, s) t_0 = Float64(s * Float64(x * c)) tmp = 0.0 if (s <= 1.28e+185) tmp = Float64(cos(Float64(x * 2.0)) / Float64(t_0 * t_0)); else tmp = Float64(c * Float64(x * s)) ^ -2.0; end return tmp end
function tmp_2 = code(x, c, s) t_0 = s * (x * c); tmp = 0.0; if (s <= 1.28e+185) tmp = cos((x * 2.0)) / (t_0 * t_0); else tmp = (c * (x * s)) ^ -2.0; end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[s, 1.28e+185], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := s \cdot \left(x \cdot c\right)\\
\mathbf{if}\;s \leq 1.28 \cdot 10^{+185}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{t_0 \cdot t_0}\\
\mathbf{else}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\
\end{array}
\end{array}
if s < 1.27999999999999993e185Initial program 63.4%
*-commutative63.4%
associate-*r*58.0%
associate-*r*57.6%
unpow257.6%
unswap-sqr72.8%
unpow272.8%
swap-sqr96.5%
*-commutative96.5%
*-commutative96.5%
*-commutative96.5%
*-commutative96.5%
Simplified96.5%
if 1.27999999999999993e185 < s Initial program 63.8%
associate-*r*63.8%
*-commutative63.8%
*-commutative63.8%
associate-*r*63.8%
*-commutative63.8%
unpow263.8%
unpow263.8%
Simplified63.8%
*-un-lft-identity63.8%
associate-*r*63.4%
*-commutative63.4%
add-sqr-sqrt63.4%
times-frac63.4%
Applied egg-rr99.8%
Taylor expanded in x around 0 59.6%
associate-*r*59.8%
*-commutative59.8%
*-commutative59.8%
unpow259.8%
*-commutative59.8%
unpow259.8%
unpow259.8%
swap-sqr82.1%
swap-sqr99.9%
associate-/r*99.9%
*-lft-identity99.9%
associate-*l/99.8%
unpow-199.8%
unpow-199.8%
pow-sqr100.0%
metadata-eval100.0%
associate-*r*99.9%
*-commutative99.9%
*-commutative99.9%
Simplified99.9%
Final simplification96.9%
(FPCore (x c s) :precision binary64 (* (/ 1.0 (* x (* c s))) (/ (cos (* x 2.0)) (* c (* x s)))))
double code(double x, double c, double s) {
return (1.0 / (x * (c * s))) * (cos((x * 2.0)) / (c * (x * s)));
}
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))) * (cos((x * 2.0d0)) / (c * (x * s)))
end function
public static double code(double x, double c, double s) {
return (1.0 / (x * (c * s))) * (Math.cos((x * 2.0)) / (c * (x * s)));
}
def code(x, c, s): return (1.0 / (x * (c * s))) * (math.cos((x * 2.0)) / (c * (x * s)))
function code(x, c, s) return Float64(Float64(1.0 / Float64(x * Float64(c * s))) * Float64(cos(Float64(x * 2.0)) / Float64(c * Float64(x * s)))) end
function tmp = code(x, c, s) tmp = (1.0 / (x * (c * s))) * (cos((x * 2.0)) / (c * (x * s))); end
code[x_, c_, s_] := N[(N[(1.0 / N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot \left(c \cdot s\right)} \cdot \frac{\cos \left(x \cdot 2\right)}{c \cdot \left(x \cdot s\right)}
\end{array}
Initial program 63.4%
associate-*r*64.5%
*-commutative64.5%
*-commutative64.5%
associate-*r*63.0%
*-commutative63.0%
unpow263.0%
unpow263.0%
Simplified63.0%
*-un-lft-identity63.0%
associate-*r*64.1%
*-commutative64.1%
add-sqr-sqrt64.1%
times-frac64.0%
Applied egg-rr98.2%
Taylor expanded in x around 0 95.4%
Final simplification95.4%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* x (* c s)))) (* (/ (cos (* x 2.0)) t_0) (/ 1.0 t_0))))
double code(double x, double c, double s) {
double t_0 = x * (c * s);
return (cos((x * 2.0)) / t_0) * (1.0 / t_0);
}
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 = (cos((x * 2.0d0)) / t_0) * (1.0d0 / t_0)
end function
public static double code(double x, double c, double s) {
double t_0 = x * (c * s);
return (Math.cos((x * 2.0)) / t_0) * (1.0 / t_0);
}
def code(x, c, s): t_0 = x * (c * s) return (math.cos((x * 2.0)) / t_0) * (1.0 / t_0)
function code(x, c, s) t_0 = Float64(x * Float64(c * s)) return Float64(Float64(cos(Float64(x * 2.0)) / t_0) * Float64(1.0 / t_0)) end
function tmp = code(x, c, s) t_0 = x * (c * s); tmp = (cos((x * 2.0)) / t_0) * (1.0 / t_0); end
code[x_, c_, s_] := Block[{t$95$0 = N[(x * N[(c * s), $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}
\\
\begin{array}{l}
t_0 := x \cdot \left(c \cdot s\right)\\
\frac{\cos \left(x \cdot 2\right)}{t_0} \cdot \frac{1}{t_0}
\end{array}
\end{array}
Initial program 63.4%
associate-*r*64.5%
*-commutative64.5%
*-commutative64.5%
associate-*r*63.0%
*-commutative63.0%
unpow263.0%
unpow263.0%
Simplified63.0%
*-un-lft-identity63.0%
associate-*r*64.1%
*-commutative64.1%
add-sqr-sqrt64.1%
times-frac64.0%
Applied egg-rr98.2%
Final simplification98.2%
(FPCore (x c s) :precision binary64 (pow (* x (* c s)) -2.0))
double code(double x, double c, double s) {
return pow((x * (c * s)), -2.0);
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = (x * (c * s)) ** (-2.0d0)
end function
public static double code(double x, double c, double s) {
return Math.pow((x * (c * s)), -2.0);
}
def code(x, c, s): return math.pow((x * (c * s)), -2.0)
function code(x, c, s) return Float64(x * Float64(c * s)) ^ -2.0 end
function tmp = code(x, c, s) tmp = (x * (c * s)) ^ -2.0; end
code[x_, c_, s_] := N[Power[N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]
\begin{array}{l}
\\
{\left(x \cdot \left(c \cdot s\right)\right)}^{-2}
\end{array}
Initial program 63.4%
*-commutative63.4%
associate-*r*58.2%
associate-*r*57.8%
unpow257.8%
unswap-sqr72.2%
unpow272.2%
swap-sqr96.3%
*-commutative96.3%
*-commutative96.3%
*-commutative96.3%
*-commutative96.3%
Simplified96.3%
Taylor expanded in x around 0 52.8%
unpow252.8%
unpow252.8%
unpow252.8%
Simplified52.8%
add-sqr-sqrt52.7%
pow252.7%
sqrt-div52.7%
metadata-eval52.7%
associate-*r*56.7%
associate-*r*62.1%
*-commutative62.1%
*-commutative62.1%
sqrt-prod62.1%
associate-*r*63.8%
*-commutative63.8%
sqrt-prod39.4%
add-sqr-sqrt66.9%
*-commutative66.9%
sqrt-prod39.3%
add-sqr-sqrt77.9%
associate-*r*79.3%
Applied egg-rr79.3%
Final simplification79.3%
(FPCore (x c s) :precision binary64 (if (<= s 1.35e+154) (/ 1.0 (* (* c c) (* (* x x) (* s s)))) (/ -2.0 (* c (* c (* s s))))))
double code(double x, double c, double s) {
double tmp;
if (s <= 1.35e+154) {
tmp = 1.0 / ((c * c) * ((x * x) * (s * s)));
} else {
tmp = -2.0 / (c * (c * (s * s)));
}
return tmp;
}
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 (s <= 1.35d+154) then
tmp = 1.0d0 / ((c * c) * ((x * x) * (s * s)))
else
tmp = (-2.0d0) / (c * (c * (s * s)))
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double tmp;
if (s <= 1.35e+154) {
tmp = 1.0 / ((c * c) * ((x * x) * (s * s)));
} else {
tmp = -2.0 / (c * (c * (s * s)));
}
return tmp;
}
def code(x, c, s): tmp = 0 if s <= 1.35e+154: tmp = 1.0 / ((c * c) * ((x * x) * (s * s))) else: tmp = -2.0 / (c * (c * (s * s))) return tmp
function code(x, c, s) tmp = 0.0 if (s <= 1.35e+154) tmp = Float64(1.0 / Float64(Float64(c * c) * Float64(Float64(x * x) * Float64(s * s)))); else tmp = Float64(-2.0 / Float64(c * Float64(c * Float64(s * s)))); end return tmp end
function tmp_2 = code(x, c, s) tmp = 0.0; if (s <= 1.35e+154) tmp = 1.0 / ((c * c) * ((x * x) * (s * s))); else tmp = -2.0 / (c * (c * (s * s))); end tmp_2 = tmp; end
code[x_, c_, s_] := If[LessEqual[s, 1.35e+154], N[(1.0 / N[(N[(c * c), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 / N[(c * N[(c * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;s \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{\left(c \cdot c\right) \cdot \left(\left(x \cdot x\right) \cdot \left(s \cdot s\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2}{c \cdot \left(c \cdot \left(s \cdot s\right)\right)}\\
\end{array}
\end{array}
if s < 1.35000000000000003e154Initial program 63.8%
*-commutative63.8%
associate-*r*58.2%
associate-*r*57.8%
unpow257.8%
unswap-sqr73.4%
unpow273.4%
swap-sqr96.4%
*-commutative96.4%
*-commutative96.4%
*-commutative96.4%
*-commutative96.4%
Simplified96.4%
Taylor expanded in x around 0 52.0%
unpow252.0%
unpow252.0%
unpow252.0%
Simplified52.0%
if 1.35000000000000003e154 < s Initial program 61.4%
*-commutative61.4%
associate-*r*58.0%
associate-*r*57.7%
unpow257.7%
unswap-sqr63.8%
unpow263.8%
swap-sqr95.3%
*-commutative95.3%
*-commutative95.3%
*-commutative95.3%
*-commutative95.3%
Simplified95.3%
Taylor expanded in x around 0 57.7%
unpow257.7%
unpow257.7%
associate-*r*58.0%
*-commutative58.0%
associate-*r*58.0%
unpow258.0%
unpow258.0%
unpow258.0%
unpow258.0%
unpow258.0%
associate-*r/58.0%
metadata-eval58.0%
unpow258.0%
unpow258.0%
Simplified58.0%
Taylor expanded in x around inf 61.4%
*-commutative61.4%
unpow261.4%
associate-*r*64.6%
unpow264.6%
Simplified64.6%
Final simplification53.6%
(FPCore (x c s) :precision binary64 (/ 1.0 (* (* c (* x s)) (* x (* c s)))))
double code(double x, double c, double s) {
return 1.0 / ((c * (x * s)) * (x * (c * s)));
}
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)) * (x * (c * s)))
end function
public static double code(double x, double c, double s) {
return 1.0 / ((c * (x * s)) * (x * (c * s)));
}
def code(x, c, s): return 1.0 / ((c * (x * s)) * (x * (c * s)))
function code(x, c, s) return Float64(1.0 / Float64(Float64(c * Float64(x * s)) * Float64(x * Float64(c * s)))) end
function tmp = code(x, c, s) tmp = 1.0 / ((c * (x * s)) * (x * (c * s))); end
code[x_, c_, s_] := N[(1.0 / N[(N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision] * N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)}
\end{array}
Initial program 63.4%
*-commutative63.4%
associate-*r*58.2%
associate-*r*57.8%
unpow257.8%
unswap-sqr72.2%
unpow272.2%
swap-sqr96.3%
*-commutative96.3%
*-commutative96.3%
*-commutative96.3%
*-commutative96.3%
Simplified96.3%
Taylor expanded in x around 0 52.8%
unpow252.8%
unpow252.8%
*-commutative52.8%
associate-*r*53.0%
unpow253.0%
unpow253.0%
*-commutative53.0%
unpow253.0%
swap-sqr63.0%
unpow263.0%
associate-*r*70.5%
*-commutative70.5%
*-commutative70.5%
associate-*r*63.0%
unpow263.0%
swap-sqr78.8%
unpow278.8%
Simplified77.8%
associate-*r*79.3%
*-commutative79.3%
*-commutative79.3%
pow279.3%
*-commutative79.3%
*-commutative79.3%
Applied egg-rr79.3%
Taylor expanded in x around 0 78.1%
associate-*r*79.3%
*-commutative79.3%
associate-*r*77.1%
Simplified77.1%
Final simplification77.1%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* x (* c s)))) (/ 1.0 (* t_0 t_0))))
double code(double x, double c, double s) {
double t_0 = x * (c * s);
return 1.0 / (t_0 * t_0);
}
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
public static double code(double x, double c, double s) {
double t_0 = x * (c * s);
return 1.0 / (t_0 * t_0);
}
def code(x, c, s): t_0 = x * (c * s) return 1.0 / (t_0 * t_0)
function code(x, c, s) t_0 = Float64(x * Float64(c * s)) return Float64(1.0 / Float64(t_0 * t_0)) end
function tmp = code(x, c, s) t_0 = x * (c * s); tmp = 1.0 / (t_0 * t_0); end
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}
\\
\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 63.4%
*-commutative63.4%
associate-*r*58.2%
associate-*r*57.8%
unpow257.8%
unswap-sqr72.2%
unpow272.2%
swap-sqr96.3%
*-commutative96.3%
*-commutative96.3%
*-commutative96.3%
*-commutative96.3%
Simplified96.3%
Taylor expanded in x around 0 52.8%
unpow252.8%
unpow252.8%
*-commutative52.8%
associate-*r*53.0%
unpow253.0%
unpow253.0%
*-commutative53.0%
unpow253.0%
swap-sqr63.0%
unpow263.0%
associate-*r*70.5%
*-commutative70.5%
*-commutative70.5%
associate-*r*63.0%
unpow263.0%
swap-sqr78.8%
unpow278.8%
Simplified77.8%
associate-*r*79.3%
*-commutative79.3%
*-commutative79.3%
pow279.3%
*-commutative79.3%
*-commutative79.3%
Applied egg-rr79.3%
Final simplification79.3%
(FPCore (x c s) :precision binary64 (/ -2.0 (* c (* c (* s s)))))
double code(double x, double c, double s) {
return -2.0 / (c * (c * (s * s)));
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = (-2.0d0) / (c * (c * (s * s)))
end function
public static double code(double x, double c, double s) {
return -2.0 / (c * (c * (s * s)));
}
def code(x, c, s): return -2.0 / (c * (c * (s * s)))
function code(x, c, s) return Float64(-2.0 / Float64(c * Float64(c * Float64(s * s)))) end
function tmp = code(x, c, s) tmp = -2.0 / (c * (c * (s * s))); end
code[x_, c_, s_] := N[(-2.0 / N[(c * N[(c * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-2}{c \cdot \left(c \cdot \left(s \cdot s\right)\right)}
\end{array}
Initial program 63.4%
*-commutative63.4%
associate-*r*58.2%
associate-*r*57.8%
unpow257.8%
unswap-sqr72.2%
unpow272.2%
swap-sqr96.3%
*-commutative96.3%
*-commutative96.3%
*-commutative96.3%
*-commutative96.3%
Simplified96.3%
Taylor expanded in x around 0 32.9%
unpow232.9%
unpow232.9%
associate-*r*32.3%
*-commutative32.3%
associate-*r*32.6%
unpow232.6%
unpow232.6%
unpow232.6%
unpow232.6%
unpow232.6%
associate-*r/32.6%
metadata-eval32.6%
unpow232.6%
unpow232.6%
Simplified32.6%
Taylor expanded in x around inf 28.1%
*-commutative28.1%
unpow228.1%
associate-*r*27.2%
unpow227.2%
Simplified27.2%
Final simplification27.2%
(FPCore (x c s) :precision binary64 (/ -2.0 (* (* c c) (* s s))))
double code(double x, double c, double s) {
return -2.0 / ((c * c) * (s * s));
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = (-2.0d0) / ((c * c) * (s * s))
end function
public static double code(double x, double c, double s) {
return -2.0 / ((c * c) * (s * s));
}
def code(x, c, s): return -2.0 / ((c * c) * (s * s))
function code(x, c, s) return Float64(-2.0 / Float64(Float64(c * c) * Float64(s * s))) end
function tmp = code(x, c, s) tmp = -2.0 / ((c * c) * (s * s)); end
code[x_, c_, s_] := N[(-2.0 / N[(N[(c * c), $MachinePrecision] * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-2}{\left(c \cdot c\right) \cdot \left(s \cdot s\right)}
\end{array}
Initial program 63.4%
*-commutative63.4%
associate-*r*58.2%
associate-*r*57.8%
unpow257.8%
unswap-sqr72.2%
unpow272.2%
swap-sqr96.3%
*-commutative96.3%
*-commutative96.3%
*-commutative96.3%
*-commutative96.3%
Simplified96.3%
Taylor expanded in x around 0 32.9%
unpow232.9%
unpow232.9%
associate-*r*32.3%
*-commutative32.3%
associate-*r*32.6%
unpow232.6%
unpow232.6%
unpow232.6%
unpow232.6%
unpow232.6%
associate-*r/32.6%
metadata-eval32.6%
unpow232.6%
unpow232.6%
Simplified32.6%
Taylor expanded in x around inf 28.1%
*-commutative28.1%
unpow228.1%
unpow228.1%
Simplified28.1%
Final simplification28.1%
herbie shell --seed 2023178
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))