
(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 (* (pow (* s (* x c)) -2.0) (cos (* x 2.0))))
double code(double x, double c, double s) {
return pow((s * (x * c)), -2.0) * cos((x * 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 = ((s * (x * c)) ** (-2.0d0)) * cos((x * 2.0d0))
end function
public static double code(double x, double c, double s) {
return Math.pow((s * (x * c)), -2.0) * Math.cos((x * 2.0));
}
def code(x, c, s): return math.pow((s * (x * c)), -2.0) * math.cos((x * 2.0))
function code(x, c, s) return Float64((Float64(s * Float64(x * c)) ^ -2.0) * cos(Float64(x * 2.0))) end
function tmp = code(x, c, s) tmp = ((s * (x * c)) ^ -2.0) * cos((x * 2.0)); end
code[x_, c_, s_] := N[(N[Power[N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision] * N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(s \cdot \left(x \cdot c\right)\right)}^{-2} \cdot \cos \left(x \cdot 2\right)
\end{array}
Initial program 69.0%
*-commutative69.0%
associate-*r*63.7%
associate-*r*64.8%
unpow264.8%
unswap-sqr81.4%
unpow281.4%
swap-sqr98.7%
*-commutative98.7%
*-commutative98.7%
*-commutative98.7%
*-commutative98.7%
Simplified98.7%
div-inv98.7%
*-commutative98.7%
pow298.7%
pow-flip98.9%
metadata-eval98.9%
Applied egg-rr98.9%
Final simplification98.9%
(FPCore (x c s)
:precision binary64
(if (<= x 0.42)
(pow (* c (* x s)) -2.0)
(if (<= x 2.75e+143)
(/ (cos (* x 2.0)) (* s (* (* x x) (* s (* c c)))))
(/ 1.0 (* (* s s) (pow (* x c) 2.0))))))
double code(double x, double c, double s) {
double tmp;
if (x <= 0.42) {
tmp = pow((c * (x * s)), -2.0);
} else if (x <= 2.75e+143) {
tmp = cos((x * 2.0)) / (s * ((x * x) * (s * (c * c))));
} else {
tmp = 1.0 / ((s * s) * pow((x * c), 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 <= 0.42d0) then
tmp = (c * (x * s)) ** (-2.0d0)
else if (x <= 2.75d+143) then
tmp = cos((x * 2.0d0)) / (s * ((x * x) * (s * (c * c))))
else
tmp = 1.0d0 / ((s * s) * ((x * c) ** 2.0d0))
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double tmp;
if (x <= 0.42) {
tmp = Math.pow((c * (x * s)), -2.0);
} else if (x <= 2.75e+143) {
tmp = Math.cos((x * 2.0)) / (s * ((x * x) * (s * (c * c))));
} else {
tmp = 1.0 / ((s * s) * Math.pow((x * c), 2.0));
}
return tmp;
}
def code(x, c, s): tmp = 0 if x <= 0.42: tmp = math.pow((c * (x * s)), -2.0) elif x <= 2.75e+143: tmp = math.cos((x * 2.0)) / (s * ((x * x) * (s * (c * c)))) else: tmp = 1.0 / ((s * s) * math.pow((x * c), 2.0)) return tmp
function code(x, c, s) tmp = 0.0 if (x <= 0.42) tmp = Float64(c * Float64(x * s)) ^ -2.0; elseif (x <= 2.75e+143) tmp = Float64(cos(Float64(x * 2.0)) / Float64(s * Float64(Float64(x * x) * Float64(s * Float64(c * c))))); else tmp = Float64(1.0 / Float64(Float64(s * s) * (Float64(x * c) ^ 2.0))); end return tmp end
function tmp_2 = code(x, c, s) tmp = 0.0; if (x <= 0.42) tmp = (c * (x * s)) ^ -2.0; elseif (x <= 2.75e+143) tmp = cos((x * 2.0)) / (s * ((x * x) * (s * (c * c)))); else tmp = 1.0 / ((s * s) * ((x * c) ^ 2.0)); end tmp_2 = tmp; end
code[x_, c_, s_] := If[LessEqual[x, 0.42], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], If[LessEqual[x, 2.75e+143], 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[(1.0 / N[(N[(s * s), $MachinePrecision] * N[Power[N[(x * c), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.42:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\
\mathbf{elif}\;x \leq 2.75 \cdot 10^{+143}:\\
\;\;\;\;\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}:\\
\;\;\;\;\frac{1}{\left(s \cdot s\right) \cdot {\left(x \cdot c\right)}^{2}}\\
\end{array}
\end{array}
if x < 0.419999999999999984Initial program 68.0%
*-commutative68.0%
associate-*r*62.7%
associate-*r*63.2%
unpow263.2%
unswap-sqr82.6%
unpow282.6%
swap-sqr99.6%
*-commutative99.6%
*-commutative99.6%
*-commutative99.6%
*-commutative99.6%
Simplified99.6%
div-inv99.6%
*-commutative99.6%
pow299.6%
pow-flip99.6%
metadata-eval99.6%
Applied egg-rr99.6%
*-commutative99.6%
metadata-eval99.6%
pow-prod-up99.6%
pow-prod-down99.6%
pow299.6%
associate-*r*97.5%
add-sqr-sqrt50.0%
sqrt-prod84.5%
*-commutative84.5%
associate-*r*84.0%
add-sqr-sqrt40.4%
sqrt-prod73.1%
sqrt-prod73.0%
*-commutative73.0%
pow273.0%
add-sqr-sqrt73.1%
inv-pow73.1%
Applied egg-rr99.6%
Taylor expanded in x around 0 59.8%
unpow259.8%
associate-/r*59.8%
*-commutative59.8%
unpow259.8%
unpow259.8%
swap-sqr69.9%
unpow269.9%
associate-/l/69.9%
*-commutative69.9%
unpow269.9%
swap-sqr87.9%
*-commutative87.9%
associate-*l*86.1%
*-commutative86.1%
associate-*l*87.7%
associate-/l/87.7%
*-lft-identity87.7%
associate-*l/87.7%
unpow-187.7%
unpow-187.7%
Simplified87.9%
if 0.419999999999999984 < x < 2.74999999999999985e143Initial program 83.7%
*-commutative83.7%
associate-*l*83.7%
associate-*r*86.9%
*-commutative86.9%
unpow286.9%
associate-*r*87.3%
associate-*r*90.4%
*-commutative90.4%
unpow290.4%
Simplified90.4%
if 2.74999999999999985e143 < x Initial program 61.3%
*-commutative61.3%
associate-*r*51.8%
associate-*r*51.8%
unpow251.8%
unswap-sqr66.6%
unpow266.6%
swap-sqr95.4%
*-commutative95.4%
*-commutative95.4%
*-commutative95.4%
*-commutative95.4%
Simplified95.4%
Taylor expanded in x around 0 51.8%
associate-/r*51.8%
unpow251.8%
unpow251.8%
swap-sqr60.0%
unpow260.0%
associate-/l/60.0%
unpow260.0%
unpow260.0%
swap-sqr64.3%
associate-*r*64.4%
associate-*r*64.4%
unpow264.4%
associate-*r*64.3%
*-commutative64.3%
Simplified64.3%
*-commutative64.3%
associate-*r*64.4%
*-commutative64.4%
unpow-prod-down56.1%
pow256.1%
Applied egg-rr56.1%
Final simplification84.0%
(FPCore (x c s) :precision binary64 (if (<= s 2.75e+82) (/ (cos (* x 2.0)) (* x (* x (* (* s s) (* c c))))) (pow (* c (* x s)) -2.0)))
double code(double x, double c, double s) {
double tmp;
if (s <= 2.75e+82) {
tmp = cos((x * 2.0)) / (x * (x * ((s * s) * (c * c))));
} 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) :: tmp
if (s <= 2.75d+82) then
tmp = cos((x * 2.0d0)) / (x * (x * ((s * s) * (c * c))))
else
tmp = (c * (x * s)) ** (-2.0d0)
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double tmp;
if (s <= 2.75e+82) {
tmp = Math.cos((x * 2.0)) / (x * (x * ((s * s) * (c * c))));
} else {
tmp = Math.pow((c * (x * s)), -2.0);
}
return tmp;
}
def code(x, c, s): tmp = 0 if s <= 2.75e+82: tmp = math.cos((x * 2.0)) / (x * (x * ((s * s) * (c * c)))) else: tmp = math.pow((c * (x * s)), -2.0) return tmp
function code(x, c, s) tmp = 0.0 if (s <= 2.75e+82) tmp = Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(x * Float64(Float64(s * s) * Float64(c * c))))); else tmp = Float64(c * Float64(x * s)) ^ -2.0; end return tmp end
function tmp_2 = code(x, c, s) tmp = 0.0; if (s <= 2.75e+82) tmp = cos((x * 2.0)) / (x * (x * ((s * s) * (c * c)))); else tmp = (c * (x * s)) ^ -2.0; end tmp_2 = tmp; end
code[x_, c_, s_] := If[LessEqual[s, 2.75e+82], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * N[(x * N[(N[(s * s), $MachinePrecision] * N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;s \leq 2.75 \cdot 10^{+82}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(x \cdot \left(\left(s \cdot s\right) \cdot \left(c \cdot c\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\
\end{array}
\end{array}
if s < 2.74999999999999998e82Initial program 68.2%
associate-*r*70.3%
*-commutative70.3%
*-commutative70.3%
associate-*r*69.4%
*-commutative69.4%
unpow269.4%
unpow269.4%
Simplified69.4%
if 2.74999999999999998e82 < s Initial program 72.4%
*-commutative72.4%
associate-*r*59.9%
associate-*r*61.7%
unpow261.7%
unswap-sqr74.3%
unpow274.3%
swap-sqr99.7%
*-commutative99.7%
*-commutative99.7%
*-commutative99.7%
*-commutative99.7%
Simplified99.7%
div-inv99.7%
*-commutative99.7%
pow299.7%
pow-flip99.8%
metadata-eval99.8%
Applied egg-rr99.8%
*-commutative99.8%
metadata-eval99.8%
pow-prod-up99.6%
pow-prod-down99.7%
pow299.7%
associate-*r*97.9%
add-sqr-sqrt38.6%
sqrt-prod88.3%
*-commutative88.3%
associate-*r*86.3%
add-sqr-sqrt41.0%
sqrt-prod80.2%
sqrt-prod80.2%
*-commutative80.2%
pow280.2%
add-sqr-sqrt80.2%
inv-pow80.2%
Applied egg-rr99.7%
Taylor expanded in x around 0 59.9%
unpow259.9%
associate-/r*59.9%
*-commutative59.9%
unpow259.9%
unpow259.9%
swap-sqr82.2%
unpow282.2%
associate-/l/82.2%
*-commutative82.2%
unpow282.2%
swap-sqr91.8%
*-commutative91.8%
associate-*l*90.0%
*-commutative90.0%
associate-*l*90.3%
associate-/l/90.2%
*-lft-identity90.2%
associate-*l/90.2%
unpow-190.2%
unpow-190.2%
Simplified91.8%
Final simplification73.7%
(FPCore (x c s) :precision binary64 (if (<= s 8.6e+121) (/ (cos (* x 2.0)) (* x (* (* c (* x c)) (* s s)))) (pow (* c (* x s)) -2.0)))
double code(double x, double c, double s) {
double tmp;
if (s <= 8.6e+121) {
tmp = cos((x * 2.0)) / (x * ((c * (x * c)) * (s * s)));
} 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) :: tmp
if (s <= 8.6d+121) then
tmp = cos((x * 2.0d0)) / (x * ((c * (x * c)) * (s * s)))
else
tmp = (c * (x * s)) ** (-2.0d0)
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double tmp;
if (s <= 8.6e+121) {
tmp = Math.cos((x * 2.0)) / (x * ((c * (x * c)) * (s * s)));
} else {
tmp = Math.pow((c * (x * s)), -2.0);
}
return tmp;
}
def code(x, c, s): tmp = 0 if s <= 8.6e+121: tmp = math.cos((x * 2.0)) / (x * ((c * (x * c)) * (s * s))) else: tmp = math.pow((c * (x * s)), -2.0) return tmp
function code(x, c, s) tmp = 0.0 if (s <= 8.6e+121) tmp = Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(Float64(c * Float64(x * c)) * Float64(s * s)))); else tmp = Float64(c * Float64(x * s)) ^ -2.0; end return tmp end
function tmp_2 = code(x, c, s) tmp = 0.0; if (s <= 8.6e+121) tmp = cos((x * 2.0)) / (x * ((c * (x * c)) * (s * s))); else tmp = (c * (x * s)) ^ -2.0; end tmp_2 = tmp; end
code[x_, c_, s_] := If[LessEqual[s, 8.6e+121], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * N[(N[(c * N[(x * c), $MachinePrecision]), $MachinePrecision] * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;s \leq 8.6 \cdot 10^{+121}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(\left(c \cdot \left(x \cdot c\right)\right) \cdot \left(s \cdot s\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\
\end{array}
\end{array}
if s < 8.5999999999999994e121Initial program 68.2%
associate-*r*71.0%
*-commutative71.0%
associate-*r*71.5%
unpow271.5%
unpow271.5%
Simplified71.5%
Taylor expanded in c around 0 71.5%
unpow271.5%
associate-*l*80.4%
Simplified80.4%
if 8.5999999999999994e121 < s Initial program 73.8%
*-commutative73.8%
associate-*r*57.3%
associate-*r*57.1%
unpow257.1%
unswap-sqr71.2%
unpow271.2%
swap-sqr99.7%
*-commutative99.7%
*-commutative99.7%
*-commutative99.7%
*-commutative99.7%
Simplified99.7%
div-inv99.7%
*-commutative99.7%
pow299.7%
pow-flip99.8%
metadata-eval99.8%
Applied egg-rr99.8%
*-commutative99.8%
metadata-eval99.8%
pow-prod-up99.7%
pow-prod-down99.7%
pow299.7%
associate-*r*99.8%
add-sqr-sqrt37.8%
sqrt-prod92.1%
*-commutative92.1%
associate-*r*89.5%
add-sqr-sqrt46.0%
sqrt-prod84.1%
sqrt-prod84.1%
*-commutative84.1%
pow284.1%
add-sqr-sqrt84.2%
inv-pow84.2%
Applied egg-rr99.7%
Taylor expanded in x around 0 57.3%
unpow257.3%
associate-/r*57.3%
*-commutative57.3%
unpow257.3%
unpow257.3%
swap-sqr86.7%
unpow286.7%
associate-/l/86.7%
*-commutative86.7%
unpow286.7%
swap-sqr96.1%
*-commutative96.1%
associate-*l*93.6%
*-commutative93.6%
associate-*l*93.6%
associate-/l/93.5%
*-lft-identity93.5%
associate-*l/93.5%
unpow-193.5%
unpow-193.5%
Simplified96.1%
Final simplification82.7%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* s (* x c)))) (* (/ (cos (* x 2.0)) t_0) (/ 1.0 t_0))))
double code(double x, double c, double s) {
double t_0 = s * (x * c);
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 = s * (x * c)
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 = s * (x * c);
return (Math.cos((x * 2.0)) / t_0) * (1.0 / t_0);
}
def code(x, c, s): t_0 = s * (x * c) return (math.cos((x * 2.0)) / t_0) * (1.0 / t_0)
function code(x, c, s) t_0 = Float64(s * Float64(x * c)) return Float64(Float64(cos(Float64(x * 2.0)) / t_0) * Float64(1.0 / t_0)) end
function tmp = code(x, c, s) t_0 = s * (x * c); tmp = (cos((x * 2.0)) / t_0) * (1.0 / t_0); end
code[x_, c_, s_] := Block[{t$95$0 = N[(s * N[(x * c), $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 := s \cdot \left(x \cdot c\right)\\
\frac{\cos \left(x \cdot 2\right)}{t_0} \cdot \frac{1}{t_0}
\end{array}
\end{array}
Initial program 69.0%
*-commutative69.0%
associate-*r*63.7%
associate-*r*64.8%
unpow264.8%
unswap-sqr81.4%
unpow281.4%
swap-sqr98.7%
*-commutative98.7%
*-commutative98.7%
*-commutative98.7%
*-commutative98.7%
Simplified98.7%
associate-/r*98.9%
div-inv98.9%
*-commutative98.9%
Applied egg-rr98.9%
Final simplification98.9%
(FPCore (x c s) :precision binary64 (/ (cos (* x 2.0)) (* (* s (* x c)) (* c (* x s)))))
double code(double x, double c, double s) {
return cos((x * 2.0)) / ((s * (x * c)) * (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 = cos((x * 2.0d0)) / ((s * (x * c)) * (c * (x * s)))
end function
public static double code(double x, double c, double s) {
return Math.cos((x * 2.0)) / ((s * (x * c)) * (c * (x * s)));
}
def code(x, c, s): return math.cos((x * 2.0)) / ((s * (x * c)) * (c * (x * s)))
function code(x, c, s) return Float64(cos(Float64(x * 2.0)) / Float64(Float64(s * Float64(x * c)) * Float64(c * Float64(x * s)))) end
function tmp = code(x, c, s) tmp = cos((x * 2.0)) / ((s * (x * c)) * (c * (x * s))); end
code[x_, c_, s_] := N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision] * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos \left(x \cdot 2\right)}{\left(s \cdot \left(x \cdot c\right)\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}
\end{array}
Initial program 69.0%
*-commutative69.0%
associate-*r*63.7%
associate-*r*64.8%
unpow264.8%
unswap-sqr81.4%
unpow281.4%
swap-sqr98.7%
*-commutative98.7%
*-commutative98.7%
*-commutative98.7%
*-commutative98.7%
Simplified98.7%
Taylor expanded in s around 0 97.2%
Final simplification97.2%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* s (* x c)))) (/ (cos (* x 2.0)) (* t_0 t_0))))
double code(double x, double c, double s) {
double t_0 = s * (x * c);
return cos((x * 2.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 = s * (x * c)
code = cos((x * 2.0d0)) / (t_0 * t_0)
end function
public static double code(double x, double c, double s) {
double t_0 = s * (x * c);
return Math.cos((x * 2.0)) / (t_0 * t_0);
}
def code(x, c, s): t_0 = s * (x * c) return math.cos((x * 2.0)) / (t_0 * t_0)
function code(x, c, s) t_0 = Float64(s * Float64(x * c)) return Float64(cos(Float64(x * 2.0)) / Float64(t_0 * t_0)) end
function tmp = code(x, c, s) t_0 = s * (x * c); tmp = cos((x * 2.0)) / (t_0 * t_0); end
code[x_, c_, s_] := Block[{t$95$0 = N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]}, N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := s \cdot \left(x \cdot c\right)\\
\frac{\cos \left(x \cdot 2\right)}{t_0 \cdot t_0}
\end{array}
\end{array}
Initial program 69.0%
*-commutative69.0%
associate-*r*63.7%
associate-*r*64.8%
unpow264.8%
unswap-sqr81.4%
unpow281.4%
swap-sqr98.7%
*-commutative98.7%
*-commutative98.7%
*-commutative98.7%
*-commutative98.7%
Simplified98.7%
Final simplification98.7%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* s (* x c)))) (/ (/ (cos (* x 2.0)) t_0) t_0)))
double code(double x, double c, double s) {
double t_0 = s * (x * c);
return (cos((x * 2.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 = s * (x * c)
code = (cos((x * 2.0d0)) / t_0) / t_0
end function
public static double code(double x, double c, double s) {
double t_0 = s * (x * c);
return (Math.cos((x * 2.0)) / t_0) / t_0;
}
def code(x, c, s): t_0 = s * (x * c) return (math.cos((x * 2.0)) / t_0) / t_0
function code(x, c, s) t_0 = Float64(s * Float64(x * c)) return Float64(Float64(cos(Float64(x * 2.0)) / t_0) / t_0) end
function tmp = code(x, c, s) t_0 = s * (x * c); tmp = (cos((x * 2.0)) / t_0) / t_0; end
code[x_, c_, s_] := Block[{t$95$0 = N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := s \cdot \left(x \cdot c\right)\\
\frac{\frac{\cos \left(x \cdot 2\right)}{t_0}}{t_0}
\end{array}
\end{array}
Initial program 69.0%
*-commutative69.0%
associate-*r*63.7%
associate-*r*64.8%
unpow264.8%
unswap-sqr81.4%
unpow281.4%
swap-sqr98.7%
*-commutative98.7%
*-commutative98.7%
*-commutative98.7%
*-commutative98.7%
Simplified98.7%
div-inv98.7%
*-commutative98.7%
pow298.7%
pow-flip98.9%
metadata-eval98.9%
Applied egg-rr98.9%
*-commutative98.9%
metadata-eval98.9%
pow-prod-up98.8%
pow-prod-down98.7%
pow298.7%
associate-*r*97.9%
add-sqr-sqrt51.3%
sqrt-prod86.3%
*-commutative86.3%
associate-*r*84.6%
add-sqr-sqrt41.2%
sqrt-prod75.2%
sqrt-prod75.1%
*-commutative75.1%
pow275.1%
add-sqr-sqrt75.2%
inv-pow75.2%
Applied egg-rr98.9%
Final simplification98.9%
(FPCore (x c s) :precision binary64 (/ 1.0 (pow (* c (* x s)) 2.0)))
double code(double x, double c, double s) {
return 1.0 / pow((c * (x * 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 = 1.0d0 / ((c * (x * s)) ** 2.0d0)
end function
public static double code(double x, double c, double s) {
return 1.0 / Math.pow((c * (x * s)), 2.0);
}
def code(x, c, s): return 1.0 / math.pow((c * (x * s)), 2.0)
function code(x, c, s) return Float64(1.0 / (Float64(c * Float64(x * s)) ^ 2.0)) end
function tmp = code(x, c, s) tmp = 1.0 / ((c * (x * s)) ^ 2.0); end
code[x_, c_, s_] := N[(1.0 / N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}
\end{array}
Initial program 69.0%
*-commutative69.0%
associate-*r*63.7%
associate-*r*64.8%
unpow264.8%
unswap-sqr81.4%
unpow281.4%
swap-sqr98.7%
*-commutative98.7%
*-commutative98.7%
*-commutative98.7%
*-commutative98.7%
Simplified98.7%
Taylor expanded in x around 0 58.6%
associate-/r*58.6%
unpow258.6%
unpow258.6%
swap-sqr67.3%
unpow267.3%
associate-/l/67.3%
unpow267.3%
unpow267.3%
swap-sqr81.5%
associate-*r*81.6%
associate-*r*82.8%
unpow282.8%
associate-*r*81.5%
*-commutative81.5%
Simplified81.5%
Final simplification81.5%
(FPCore (x c s) :precision binary64 (pow (* c (* x s)) -2.0))
double code(double x, double c, double s) {
return pow((c * (x * 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 = (c * (x * s)) ** (-2.0d0)
end function
public static double code(double x, double c, double s) {
return Math.pow((c * (x * s)), -2.0);
}
def code(x, c, s): return math.pow((c * (x * s)), -2.0)
function code(x, c, s) return Float64(c * Float64(x * s)) ^ -2.0 end
function tmp = code(x, c, s) tmp = (c * (x * s)) ^ -2.0; end
code[x_, c_, s_] := N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]
\begin{array}{l}
\\
{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}
\end{array}
Initial program 69.0%
*-commutative69.0%
associate-*r*63.7%
associate-*r*64.8%
unpow264.8%
unswap-sqr81.4%
unpow281.4%
swap-sqr98.7%
*-commutative98.7%
*-commutative98.7%
*-commutative98.7%
*-commutative98.7%
Simplified98.7%
div-inv98.7%
*-commutative98.7%
pow298.7%
pow-flip98.9%
metadata-eval98.9%
Applied egg-rr98.9%
*-commutative98.9%
metadata-eval98.9%
pow-prod-up98.8%
pow-prod-down98.7%
pow298.7%
associate-*r*97.9%
add-sqr-sqrt51.3%
sqrt-prod86.3%
*-commutative86.3%
associate-*r*84.6%
add-sqr-sqrt41.2%
sqrt-prod75.2%
sqrt-prod75.1%
*-commutative75.1%
pow275.1%
add-sqr-sqrt75.2%
inv-pow75.2%
Applied egg-rr98.9%
Taylor expanded in x around 0 58.6%
unpow258.6%
associate-/r*58.6%
*-commutative58.6%
unpow258.6%
unpow258.6%
swap-sqr67.3%
unpow267.3%
associate-/l/67.3%
*-commutative67.3%
unpow267.3%
swap-sqr81.5%
*-commutative81.5%
associate-*l*80.2%
*-commutative80.2%
associate-*l*81.4%
associate-/l/81.4%
*-lft-identity81.4%
associate-*l/81.4%
unpow-181.4%
unpow-181.4%
Simplified81.6%
Final simplification81.6%
(FPCore (x c s) :precision binary64 (if (<= s 1.35e+154) (/ 1.0 (* (* s s) (* (* c c) (* x x)))) (/ -2.0 (* (* s s) (* c c)))))
double code(double x, double c, double s) {
double tmp;
if (s <= 1.35e+154) {
tmp = 1.0 / ((s * s) * ((c * c) * (x * x)));
} else {
tmp = -2.0 / ((s * s) * (c * c));
}
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 / ((s * s) * ((c * c) * (x * x)))
else
tmp = (-2.0d0) / ((s * s) * (c * c))
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 / ((s * s) * ((c * c) * (x * x)));
} else {
tmp = -2.0 / ((s * s) * (c * c));
}
return tmp;
}
def code(x, c, s): tmp = 0 if s <= 1.35e+154: tmp = 1.0 / ((s * s) * ((c * c) * (x * x))) else: tmp = -2.0 / ((s * s) * (c * c)) return tmp
function code(x, c, s) tmp = 0.0 if (s <= 1.35e+154) tmp = Float64(1.0 / Float64(Float64(s * s) * Float64(Float64(c * c) * Float64(x * x)))); else tmp = Float64(-2.0 / Float64(Float64(s * s) * Float64(c * c))); end return tmp end
function tmp_2 = code(x, c, s) tmp = 0.0; if (s <= 1.35e+154) tmp = 1.0 / ((s * s) * ((c * c) * (x * x))); else tmp = -2.0 / ((s * s) * (c * c)); end tmp_2 = tmp; end
code[x_, c_, s_] := If[LessEqual[s, 1.35e+154], N[(1.0 / N[(N[(s * s), $MachinePrecision] * N[(N[(c * c), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 / N[(N[(s * s), $MachinePrecision] * N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;s \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{\left(s \cdot s\right) \cdot \left(\left(c \cdot c\right) \cdot \left(x \cdot x\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2}{\left(s \cdot s\right) \cdot \left(c \cdot c\right)}\\
\end{array}
\end{array}
if s < 1.35000000000000003e154Initial program 68.3%
*-commutative68.3%
associate-*r*64.1%
associate-*r*65.5%
unpow265.5%
unswap-sqr82.1%
unpow282.1%
swap-sqr98.6%
*-commutative98.6%
*-commutative98.6%
*-commutative98.6%
*-commutative98.6%
Simplified98.6%
div-inv98.6%
*-commutative98.6%
pow298.6%
pow-flip98.8%
metadata-eval98.8%
Applied egg-rr98.8%
*-commutative98.8%
metadata-eval98.8%
pow-prod-up98.7%
pow-prod-down98.6%
pow298.6%
associate-*r*97.6%
add-sqr-sqrt53.1%
sqrt-prod85.1%
*-commutative85.1%
associate-*r*83.6%
add-sqr-sqrt40.6%
sqrt-prod73.7%
sqrt-prod73.6%
*-commutative73.6%
pow273.6%
add-sqr-sqrt73.7%
inv-pow73.7%
Applied egg-rr98.7%
Taylor expanded in x around 0 58.2%
unpow258.2%
associate-*r*58.2%
*-commutative58.2%
associate-*r*58.8%
unpow258.8%
*-commutative58.8%
unpow258.8%
Simplified58.8%
if 1.35000000000000003e154 < s Initial program 73.6%
*-commutative73.6%
associate-*r*60.9%
associate-*r*60.6%
unpow260.6%
unswap-sqr76.4%
unpow276.4%
swap-sqr99.8%
*-commutative99.8%
*-commutative99.8%
*-commutative99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in x around 0 60.6%
associate-/r*60.6%
unpow260.6%
unpow260.6%
unpow260.6%
associate-*r/60.6%
metadata-eval60.6%
unpow260.6%
unpow260.6%
Simplified60.6%
Taylor expanded in x around inf 73.6%
unpow273.6%
*-commutative73.6%
unpow273.6%
Simplified73.6%
Final simplification60.7%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* x (* s c)))) (/ 1.0 (* t_0 t_0))))
double code(double x, double c, double s) {
double t_0 = x * (s * c);
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 * (s * c)
code = 1.0d0 / (t_0 * t_0)
end function
public static double code(double x, double c, double s) {
double t_0 = x * (s * c);
return 1.0 / (t_0 * t_0);
}
def code(x, c, s): t_0 = x * (s * c) return 1.0 / (t_0 * t_0)
function code(x, c, s) t_0 = Float64(x * Float64(s * c)) return Float64(1.0 / Float64(t_0 * t_0)) end
function tmp = code(x, c, s) t_0 = x * (s * c); tmp = 1.0 / (t_0 * t_0); end
code[x_, c_, s_] := Block[{t$95$0 = N[(x * N[(s * c), $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(s \cdot c\right)\\
\frac{1}{t_0 \cdot t_0}
\end{array}
\end{array}
Initial program 69.0%
*-commutative69.0%
associate-*r*63.7%
associate-*r*64.8%
unpow264.8%
unswap-sqr81.4%
unpow281.4%
swap-sqr98.7%
*-commutative98.7%
*-commutative98.7%
*-commutative98.7%
*-commutative98.7%
Simplified98.7%
Taylor expanded in x around 0 58.6%
associate-/r*58.6%
unpow258.6%
unpow258.6%
swap-sqr67.3%
unpow267.3%
associate-/l/67.3%
unpow267.3%
unpow267.3%
swap-sqr81.5%
associate-*r*81.6%
associate-*r*82.8%
unpow282.8%
associate-*r*81.5%
*-commutative81.5%
Simplified81.5%
unpow281.5%
associate-*r*80.2%
associate-*r*81.4%
Applied egg-rr81.4%
Final simplification81.4%
(FPCore (x c s) :precision binary64 (/ -2.0 (* (* s s) (* c c))))
double code(double x, double c, double s) {
return -2.0 / ((s * s) * (c * c));
}
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
public static double code(double x, double c, double s) {
return -2.0 / ((s * s) * (c * c));
}
def code(x, c, s): return -2.0 / ((s * s) * (c * c))
function code(x, c, s) return Float64(-2.0 / Float64(Float64(s * s) * Float64(c * c))) end
function tmp = code(x, c, s) tmp = -2.0 / ((s * s) * (c * c)); end
code[x_, c_, s_] := N[(-2.0 / N[(N[(s * s), $MachinePrecision] * N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-2}{\left(s \cdot s\right) \cdot \left(c \cdot c\right)}
\end{array}
Initial program 69.0%
*-commutative69.0%
associate-*r*63.7%
associate-*r*64.8%
unpow264.8%
unswap-sqr81.4%
unpow281.4%
swap-sqr98.7%
*-commutative98.7%
*-commutative98.7%
*-commutative98.7%
*-commutative98.7%
Simplified98.7%
Taylor expanded in x around 0 32.0%
associate-/r*32.0%
unpow232.0%
unpow232.0%
unpow232.0%
associate-*r/32.0%
metadata-eval32.0%
unpow232.0%
unpow232.0%
Simplified32.0%
Taylor expanded in x around inf 27.0%
unpow227.0%
*-commutative27.0%
unpow227.0%
Simplified27.0%
Final simplification27.0%
herbie shell --seed 2023238
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))