
(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 10 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: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
:precision binary64
(let* ((t_0 (cos (* x 2.0))))
(if (<= x 2.7e+60)
(/ (/ (/ t_0 (* x s)) c) (* c (* x s)))
(* (/ (/ (/ 1.0 x) (* s c)) (* s c)) (/ t_0 x)))))s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = cos((x * 2.0));
double tmp;
if (x <= 2.7e+60) {
tmp = ((t_0 / (x * s)) / c) / (c * (x * s));
} else {
tmp = (((1.0 / x) / (s * c)) / (s * c)) * (t_0 / x);
}
return tmp;
}
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: tmp
t_0 = cos((x * 2.0d0))
if (x <= 2.7d+60) then
tmp = ((t_0 / (x * s)) / c) / (c * (x * s))
else
tmp = (((1.0d0 / x) / (s * c)) / (s * c)) * (t_0 / x)
end if
code = tmp
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = Math.cos((x * 2.0));
double tmp;
if (x <= 2.7e+60) {
tmp = ((t_0 / (x * s)) / c) / (c * (x * s));
} else {
tmp = (((1.0 / x) / (s * c)) / (s * c)) * (t_0 / x);
}
return tmp;
}
s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = math.cos((x * 2.0)) tmp = 0 if x <= 2.7e+60: tmp = ((t_0 / (x * s)) / c) / (c * (x * s)) else: tmp = (((1.0 / x) / (s * c)) / (s * c)) * (t_0 / x) return tmp
s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = cos(Float64(x * 2.0)) tmp = 0.0 if (x <= 2.7e+60) tmp = Float64(Float64(Float64(t_0 / Float64(x * s)) / c) / Float64(c * Float64(x * s))); else tmp = Float64(Float64(Float64(Float64(1.0 / x) / Float64(s * c)) / Float64(s * c)) * Float64(t_0 / x)); end return tmp end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = cos((x * 2.0));
tmp = 0.0;
if (x <= 2.7e+60)
tmp = ((t_0 / (x * s)) / c) / (c * (x * s));
else
tmp = (((1.0 / x) / (s * c)) / (s * c)) * (t_0 / x);
end
tmp_2 = tmp;
end
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 2.7e+60], N[(N[(N[(t$95$0 / N[(x * s), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision] / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(1.0 / x), $MachinePrecision] / N[(s * c), $MachinePrecision]), $MachinePrecision] / N[(s * c), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \cos \left(x \cdot 2\right)\\
\mathbf{if}\;x \leq 2.7 \cdot 10^{+60}:\\
\;\;\;\;\frac{\frac{\frac{t_0}{x \cdot s}}{c}}{c \cdot \left(x \cdot s\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{1}{x}}{s \cdot c}}{s \cdot c} \cdot \frac{t_0}{x}\\
\end{array}
\end{array}
if x < 2.6999999999999999e60Initial program 72.5%
*-un-lft-identity72.5%
add-sqr-sqrt72.5%
times-frac72.5%
sqrt-prod72.5%
unpow272.5%
sqrt-prod41.6%
add-sqr-sqrt51.2%
*-commutative51.2%
associate-*r*46.1%
unpow246.1%
pow-prod-down51.2%
sqrt-prod51.2%
Applied egg-rr89.8%
associate-*l/89.9%
*-lft-identity89.9%
unpow289.9%
rem-sqrt-square89.9%
*-commutative89.9%
unpow289.9%
rem-sqrt-square98.7%
*-commutative98.7%
Simplified98.7%
Taylor expanded in x around inf 80.3%
associate-/r*80.6%
*-commutative80.6%
unpow280.6%
sqr-abs80.6%
unpow280.6%
associate-/l/80.3%
*-commutative80.3%
unpow280.3%
unpow280.3%
swap-sqr98.4%
associate-/l/98.7%
*-rgt-identity98.7%
associate-*r/98.7%
associate-*r/98.7%
*-rgt-identity98.7%
associate-*r/98.7%
Simplified98.3%
metadata-eval98.3%
pow-flip98.0%
unpow298.0%
associate-/r*98.3%
associate-*r/98.3%
div-inv98.3%
associate-*r*97.4%
*-commutative97.4%
associate-/r*97.1%
associate-*r*98.4%
Applied egg-rr98.4%
if 2.6999999999999999e60 < x Initial program 72.4%
*-un-lft-identity72.4%
associate-*r*72.3%
times-frac72.4%
*-commutative72.4%
associate-*r*72.5%
*-commutative72.5%
pow-prod-down92.6%
Applied egg-rr92.6%
unpow292.6%
*-commutative92.6%
*-commutative92.6%
Applied egg-rr92.6%
inv-pow92.6%
associate-*l*97.9%
unpow-prod-down98.0%
inv-pow98.0%
associate-*r*88.3%
Applied egg-rr88.3%
unpow-188.3%
associate-*l/88.4%
*-lft-identity88.4%
associate-*r*98.1%
associate-/l/98.0%
Simplified98.0%
Final simplification98.3%
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 (* (/ (cos (* x 2.0)) (* x (* s c))) (/ (/ -1.0 x) (* s (- c)))))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return (cos((x * 2.0)) / (x * (s * c))) * ((-1.0 / x) / (s * -c));
}
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 = (cos((x * 2.0d0)) / (x * (s * c))) * (((-1.0d0) / x) / (s * -c))
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return (Math.cos((x * 2.0)) / (x * (s * c))) * ((-1.0 / x) / (s * -c));
}
s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return (math.cos((x * 2.0)) / (x * (s * c))) * ((-1.0 / x) / (s * -c))
s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(s * c))) * Float64(Float64(-1.0 / x) / Float64(s * Float64(-c)))) end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = (cos((x * 2.0)) / (x * (s * c))) * ((-1.0 / x) / (s * -c));
end
NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(-1.0 / x), $MachinePrecision] / N[(s * (-c)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(s \cdot c\right)} \cdot \frac{\frac{-1}{x}}{s \cdot \left(-c\right)}
\end{array}
Initial program 72.5%
*-un-lft-identity72.5%
add-sqr-sqrt72.5%
times-frac72.5%
sqrt-prod72.5%
unpow272.5%
sqrt-prod41.8%
add-sqr-sqrt53.4%
*-commutative53.4%
associate-*r*48.5%
unpow248.5%
pow-prod-down53.4%
sqrt-prod53.4%
Applied egg-rr89.5%
associate-*l/89.5%
*-lft-identity89.5%
unpow289.5%
rem-sqrt-square89.5%
*-commutative89.5%
unpow289.5%
rem-sqrt-square96.9%
*-commutative96.9%
Simplified96.9%
frac-2neg96.9%
div-inv96.9%
associate-/r*96.9%
*-commutative96.9%
add-sqr-sqrt55.3%
fabs-sqr55.3%
add-sqr-sqrt67.0%
*-commutative67.0%
distribute-rgt-neg-in67.0%
Applied egg-rr96.9%
*-commutative96.9%
distribute-rgt-neg-out96.9%
*-commutative96.9%
associate-*r*95.5%
associate-/l/95.5%
*-commutative95.5%
associate-*r*98.3%
Simplified98.3%
inv-pow98.3%
distribute-lft-neg-in98.3%
unpow-prod-down98.2%
distribute-rgt-neg-in98.2%
inv-pow98.2%
Applied egg-rr98.2%
*-commutative98.2%
unpow-198.2%
associate-*r/98.3%
*-rgt-identity98.3%
distribute-rgt-neg-out98.3%
*-commutative98.3%
distribute-rgt-neg-in98.3%
Simplified98.3%
Final simplification98.3%
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 (* (/ (cos (* x 2.0)) (* x (* s c))) (/ -1.0 (* x (* s (- c))))))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return (cos((x * 2.0)) / (x * (s * c))) * (-1.0 / (x * (s * -c)));
}
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 = (cos((x * 2.0d0)) / (x * (s * c))) * ((-1.0d0) / (x * (s * -c)))
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return (Math.cos((x * 2.0)) / (x * (s * c))) * (-1.0 / (x * (s * -c)));
}
s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return (math.cos((x * 2.0)) / (x * (s * c))) * (-1.0 / (x * (s * -c)))
s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(s * c))) * Float64(-1.0 / Float64(x * Float64(s * Float64(-c))))) end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = (cos((x * 2.0)) / (x * (s * c))) * (-1.0 / (x * (s * -c)));
end
NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[(x * N[(s * (-c)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(s \cdot c\right)} \cdot \frac{-1}{x \cdot \left(s \cdot \left(-c\right)\right)}
\end{array}
Initial program 72.5%
*-un-lft-identity72.5%
add-sqr-sqrt72.5%
times-frac72.5%
sqrt-prod72.5%
unpow272.5%
sqrt-prod41.8%
add-sqr-sqrt53.4%
*-commutative53.4%
associate-*r*48.5%
unpow248.5%
pow-prod-down53.4%
sqrt-prod53.4%
Applied egg-rr89.5%
associate-*l/89.5%
*-lft-identity89.5%
unpow289.5%
rem-sqrt-square89.5%
*-commutative89.5%
unpow289.5%
rem-sqrt-square96.9%
*-commutative96.9%
Simplified96.9%
frac-2neg96.9%
div-inv96.9%
associate-/r*96.9%
*-commutative96.9%
add-sqr-sqrt55.3%
fabs-sqr55.3%
add-sqr-sqrt67.0%
*-commutative67.0%
distribute-rgt-neg-in67.0%
Applied egg-rr96.9%
*-commutative96.9%
distribute-rgt-neg-out96.9%
*-commutative96.9%
associate-*r*95.5%
associate-/l/95.5%
*-commutative95.5%
associate-*r*98.3%
Simplified98.3%
Final simplification98.3%
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))))
(if (<= x 4e-152)
(/ (/ 1.0 t_0) t_0)
(/ (/ (cos (* x 2.0)) (* s c)) (* x t_0)))))s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = c * (x * s);
double tmp;
if (x <= 4e-152) {
tmp = (1.0 / t_0) / t_0;
} else {
tmp = (cos((x * 2.0)) / (s * c)) / (x * t_0);
}
return tmp;
}
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 = c * (x * s)
if (x <= 4d-152) then
tmp = (1.0d0 / t_0) / t_0
else
tmp = (cos((x * 2.0d0)) / (s * c)) / (x * t_0)
end if
code = tmp
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = c * (x * s);
double tmp;
if (x <= 4e-152) {
tmp = (1.0 / t_0) / t_0;
} else {
tmp = (Math.cos((x * 2.0)) / (s * c)) / (x * t_0);
}
return tmp;
}
s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = c * (x * s) tmp = 0 if x <= 4e-152: tmp = (1.0 / t_0) / t_0 else: tmp = (math.cos((x * 2.0)) / (s * c)) / (x * t_0) return tmp
s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(c * Float64(x * s)) tmp = 0.0 if (x <= 4e-152) tmp = Float64(Float64(1.0 / t_0) / t_0); else tmp = Float64(Float64(cos(Float64(x * 2.0)) / Float64(s * c)) / Float64(x * t_0)); end return tmp end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = c * (x * s);
tmp = 0.0;
if (x <= 4e-152)
tmp = (1.0 / t_0) / t_0;
else
tmp = (cos((x * 2.0)) / (s * c)) / (x * t_0);
end
tmp_2 = tmp;
end
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]}, If[LessEqual[x, 4e-152], N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(s * c), $MachinePrecision]), $MachinePrecision] / N[(x * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\mathbf{if}\;x \leq 4 \cdot 10^{-152}:\\
\;\;\;\;\frac{\frac{1}{t_0}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(x \cdot 2\right)}{s \cdot c}}{x \cdot t_0}\\
\end{array}
\end{array}
if x < 4.00000000000000026e-152Initial program 70.4%
Taylor expanded in x around 0 58.5%
*-commutative58.5%
unpow258.5%
unpow258.5%
swap-sqr73.3%
unpow273.3%
unpow273.3%
rem-square-sqrt73.3%
swap-sqr82.1%
unpow282.1%
unpow282.1%
rem-sqrt-square88.5%
*-commutative88.5%
Simplified88.5%
add-sqr-sqrt66.5%
sqrt-prod88.5%
unpow288.5%
pow288.5%
add-sqr-sqrt88.5%
pow-flip88.5%
add-sqr-sqrt53.3%
fabs-sqr53.3%
add-sqr-sqrt88.5%
metadata-eval88.5%
Applied egg-rr88.5%
metadata-eval88.5%
pow-prod-up88.5%
pow-prod-down88.5%
sqr-neg88.5%
associate-*r*87.3%
associate-*r*87.9%
pow-prod-down87.9%
inv-pow87.9%
inv-pow87.9%
un-div-inv87.9%
Applied egg-rr88.5%
if 4.00000000000000026e-152 < x Initial program 75.6%
*-un-lft-identity75.6%
add-sqr-sqrt75.6%
times-frac75.6%
sqrt-prod75.6%
unpow275.6%
sqrt-prod40.9%
add-sqr-sqrt56.5%
*-commutative56.5%
associate-*r*54.5%
unpow254.5%
pow-prod-down56.5%
sqrt-prod56.5%
Applied egg-rr88.2%
associate-*l/88.2%
*-lft-identity88.2%
unpow288.2%
rem-sqrt-square88.2%
*-commutative88.2%
unpow288.2%
rem-sqrt-square93.6%
*-commutative93.6%
Simplified93.6%
Taylor expanded in x around inf 83.0%
associate-/r*83.0%
*-commutative83.0%
unpow283.0%
sqr-abs83.0%
unpow283.0%
associate-/l/83.0%
*-commutative83.0%
unpow283.0%
unpow283.0%
swap-sqr93.1%
associate-/l/93.6%
*-rgt-identity93.6%
associate-*r/93.7%
associate-*r/93.6%
*-rgt-identity93.6%
associate-*r/93.7%
Simplified98.7%
metadata-eval98.7%
pow-flip97.5%
unpow297.5%
associate-/r*98.7%
associate-*r/98.7%
div-inv98.7%
add-sqr-sqrt68.9%
sqrt-unprod76.6%
sqr-neg76.6%
sqrt-unprod30.7%
add-sqr-sqrt38.0%
remove-double-neg38.0%
distribute-rgt-neg-out38.0%
Applied egg-rr90.1%
Final simplification89.2%
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 (/ (- (/ (cos (* x 2.0)) (* x (* s c)))) (* x (* s (- c)))))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return -(cos((x * 2.0)) / (x * (s * c))) / (x * (s * -c));
}
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 = -(cos((x * 2.0d0)) / (x * (s * c))) / (x * (s * -c))
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return -(Math.cos((x * 2.0)) / (x * (s * c))) / (x * (s * -c));
}
s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return -(math.cos((x * 2.0)) / (x * (s * c))) / (x * (s * -c))
s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(Float64(-Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(s * c)))) / Float64(x * Float64(s * Float64(-c)))) end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = -(cos((x * 2.0)) / (x * (s * c))) / (x * (s * -c));
end
NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[((-N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) / N[(x * N[(s * (-c)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{-\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(s \cdot c\right)}}{x \cdot \left(s \cdot \left(-c\right)\right)}
\end{array}
Initial program 72.5%
*-un-lft-identity72.5%
add-sqr-sqrt72.5%
times-frac72.5%
sqrt-prod72.5%
unpow272.5%
sqrt-prod41.8%
add-sqr-sqrt53.4%
*-commutative53.4%
associate-*r*48.5%
unpow248.5%
pow-prod-down53.4%
sqrt-prod53.4%
Applied egg-rr89.5%
associate-*l/89.5%
*-lft-identity89.5%
unpow289.5%
rem-sqrt-square89.5%
*-commutative89.5%
unpow289.5%
rem-sqrt-square96.9%
*-commutative96.9%
Simplified96.9%
frac-2neg96.9%
div-inv96.9%
associate-/r*96.9%
*-commutative96.9%
add-sqr-sqrt55.3%
fabs-sqr55.3%
add-sqr-sqrt67.0%
*-commutative67.0%
distribute-rgt-neg-in67.0%
Applied egg-rr96.9%
associate-*r/96.9%
*-rgt-identity96.9%
associate-/l/96.9%
*-commutative96.9%
associate-*r*95.5%
distribute-rgt-neg-out95.5%
*-commutative95.5%
associate-*r*98.2%
distribute-rgt-neg-in98.2%
Simplified98.2%
Final simplification98.2%
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)))) (/ (/ (cos (* x 2.0)) t_0) t_0)))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = c * (x * s);
return (cos((x * 2.0)) / t_0) / t_0;
}
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 = (cos((x * 2.0d0)) / t_0) / t_0
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = c * (x * s);
return (Math.cos((x * 2.0)) / t_0) / t_0;
}
s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = c * (x * s) return (math.cos((x * 2.0)) / t_0) / t_0
s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(c * Float64(x * s)) return Float64(Float64(cos(Float64(x * 2.0)) / t_0) / t_0) end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
t_0 = c * (x * s);
tmp = (cos((x * 2.0)) / t_0) / t_0;
end
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[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\frac{\frac{\cos \left(x \cdot 2\right)}{t_0}}{t_0}
\end{array}
\end{array}
Initial program 72.5%
*-un-lft-identity72.5%
add-sqr-sqrt72.5%
times-frac72.5%
sqrt-prod72.5%
unpow272.5%
sqrt-prod41.8%
add-sqr-sqrt53.4%
*-commutative53.4%
associate-*r*48.5%
unpow248.5%
pow-prod-down53.4%
sqrt-prod53.4%
Applied egg-rr89.5%
associate-*l/89.5%
*-lft-identity89.5%
unpow289.5%
rem-sqrt-square89.5%
*-commutative89.5%
unpow289.5%
rem-sqrt-square96.9%
*-commutative96.9%
Simplified96.9%
frac-2neg96.9%
div-inv96.9%
associate-/r*96.9%
*-commutative96.9%
add-sqr-sqrt55.3%
fabs-sqr55.3%
add-sqr-sqrt67.0%
*-commutative67.0%
distribute-rgt-neg-in67.0%
Applied egg-rr96.9%
*-commutative96.9%
distribute-rgt-neg-out96.9%
*-commutative96.9%
associate-*r*95.5%
associate-/l/95.5%
*-commutative95.5%
associate-*r*98.3%
Simplified98.3%
add-sqr-sqrt55.8%
sqrt-unprod63.7%
sqr-neg63.7%
sqrt-unprod27.8%
add-sqr-sqrt33.7%
associate-/r*33.7%
frac-times33.8%
/-rgt-identity33.8%
Applied egg-rr96.9%
Final simplification96.9%
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 (/ (/ (/ (cos (* x 2.0)) (* x s)) c) (* c (* x s))))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return ((cos((x * 2.0)) / (x * s)) / c) / (c * (x * s));
}
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 = ((cos((x * 2.0d0)) / (x * s)) / c) / (c * (x * s))
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return ((Math.cos((x * 2.0)) / (x * s)) / c) / (c * (x * s));
}
s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return ((math.cos((x * 2.0)) / (x * s)) / c) / (c * (x * s))
s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(Float64(Float64(cos(Float64(x * 2.0)) / Float64(x * s)) / c) / Float64(c * Float64(x * s))) end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = ((cos((x * 2.0)) / (x * s)) / c) / (c * (x * s));
end
NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision] / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\frac{\frac{\cos \left(x \cdot 2\right)}{x \cdot s}}{c}}{c \cdot \left(x \cdot s\right)}
\end{array}
Initial program 72.5%
*-un-lft-identity72.5%
add-sqr-sqrt72.5%
times-frac72.5%
sqrt-prod72.5%
unpow272.5%
sqrt-prod41.8%
add-sqr-sqrt53.4%
*-commutative53.4%
associate-*r*48.5%
unpow248.5%
pow-prod-down53.4%
sqrt-prod53.4%
Applied egg-rr89.5%
associate-*l/89.5%
*-lft-identity89.5%
unpow289.5%
rem-sqrt-square89.5%
*-commutative89.5%
unpow289.5%
rem-sqrt-square96.9%
*-commutative96.9%
Simplified96.9%
Taylor expanded in x around inf 81.2%
associate-/r*81.2%
*-commutative81.2%
unpow281.2%
sqr-abs81.2%
unpow281.2%
associate-/l/81.2%
*-commutative81.2%
unpow281.2%
unpow281.2%
swap-sqr96.6%
associate-/l/96.9%
*-rgt-identity96.9%
associate-*r/96.9%
associate-*r/96.9%
*-rgt-identity96.9%
associate-*r/96.9%
Simplified98.3%
metadata-eval98.3%
pow-flip97.7%
unpow297.7%
associate-/r*98.2%
associate-*r/98.2%
div-inv98.2%
associate-*r*95.5%
*-commutative95.5%
associate-/r*95.2%
associate-*r*96.6%
Applied egg-rr96.6%
Final simplification96.6%
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))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return pow((c * (x * s)), -2.0);
}
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
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);
}
s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return math.pow((c * (x * s)), -2.0)
s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(c * Float64(x * s)) ^ -2.0 end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = (c * (x * s)) ^ -2.0;
end
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}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}
\end{array}
Initial program 72.5%
Taylor expanded in x around 0 60.1%
*-commutative60.1%
unpow260.1%
unpow260.1%
swap-sqr72.4%
unpow272.4%
unpow272.4%
rem-square-sqrt72.4%
swap-sqr79.0%
unpow279.0%
unpow279.0%
rem-sqrt-square83.6%
*-commutative83.6%
Simplified83.6%
add-sqr-sqrt57.5%
sqrt-prod83.6%
unpow283.6%
pow283.6%
add-sqr-sqrt83.6%
pow-flip83.9%
add-sqr-sqrt48.3%
fabs-sqr48.3%
add-sqr-sqrt83.9%
metadata-eval83.9%
Applied egg-rr83.9%
Final simplification83.9%
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))))
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: 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
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);
}
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)
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
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: 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}
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 72.5%
Taylor expanded in x around 0 60.1%
*-commutative60.1%
unpow260.1%
unpow260.1%
swap-sqr72.4%
unpow272.4%
unpow272.4%
rem-square-sqrt72.4%
swap-sqr79.0%
unpow279.0%
unpow279.0%
rem-sqrt-square83.6%
*-commutative83.6%
Simplified83.6%
add-sqr-sqrt57.5%
sqrt-prod83.6%
unpow283.6%
pow283.6%
sqrt-pow162.9%
metadata-eval62.9%
pow162.9%
add-sqr-sqrt34.8%
fabs-sqr34.8%
add-sqr-sqrt61.8%
sqrt-pow162.5%
metadata-eval62.5%
pow162.5%
add-sqr-sqrt42.4%
fabs-sqr42.4%
add-sqr-sqrt83.6%
Applied egg-rr83.6%
Final simplification83.6%
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)))
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: 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
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;
}
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
s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(c * Float64(x * s)) return Float64(Float64(1.0 / t_0) / t_0) end
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: 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[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\frac{\frac{1}{t_0}}{t_0}
\end{array}
\end{array}
Initial program 72.5%
Taylor expanded in x around 0 60.1%
*-commutative60.1%
unpow260.1%
unpow260.1%
swap-sqr72.4%
unpow272.4%
unpow272.4%
rem-square-sqrt72.4%
swap-sqr79.0%
unpow279.0%
unpow279.0%
rem-sqrt-square83.6%
*-commutative83.6%
Simplified83.6%
add-sqr-sqrt57.5%
sqrt-prod83.6%
unpow283.6%
pow283.6%
add-sqr-sqrt83.6%
pow-flip83.9%
add-sqr-sqrt48.3%
fabs-sqr48.3%
add-sqr-sqrt83.9%
metadata-eval83.9%
Applied egg-rr83.9%
metadata-eval83.9%
pow-prod-up83.8%
pow-prod-down83.6%
sqr-neg83.6%
associate-*r*82.8%
associate-*r*83.6%
pow-prod-down83.9%
inv-pow83.9%
inv-pow83.9%
un-div-inv83.9%
Applied egg-rr83.9%
Final simplification83.9%
herbie shell --seed 2023300
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))