
(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 9 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: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (* (cos (* x 2.0)) (pow (* s (* x c)) -2.0)))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return cos((x * 2.0)) * pow((s * (x * c)), -2.0);
}
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = cos((x * 2.0d0)) * ((s * (x * c)) ** (-2.0d0))
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return Math.cos((x * 2.0)) * Math.pow((s * (x * c)), -2.0);
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return math.cos((x * 2.0)) * math.pow((s * (x * c)), -2.0)
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(cos(Float64(x * 2.0)) * (Float64(s * Float64(x * c)) ^ -2.0)) end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = cos((x * 2.0)) * ((s * (x * c)) ^ -2.0);
end
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\cos \left(x \cdot 2\right) \cdot {\left(s \cdot \left(x \cdot c\right)\right)}^{-2}
\end{array}
Initial program 65.1%
*-commutative65.1%
associate-*r*57.7%
associate-*r*58.1%
unpow258.1%
unswap-sqr76.8%
unpow276.8%
swap-sqr96.7%
*-commutative96.7%
*-commutative96.7%
*-commutative96.7%
*-commutative96.7%
Simplified96.7%
div-inv96.7%
*-commutative96.7%
pow296.7%
pow-flip97.0%
metadata-eval97.0%
Applied egg-rr97.0%
Final simplification97.0%
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (if (<= x 6e-5) (pow (* c (* x s)) -2.0) (/ (cos (* x 2.0)) (* s (* s (* x (* c (* x c))))))))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double tmp;
if (x <= 6e-5) {
tmp = pow((c * (x * s)), -2.0);
} else {
tmp = cos((x * 2.0)) / (s * (s * (x * (c * (x * c)))));
}
return tmp;
}
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: tmp
if (x <= 6d-5) then
tmp = (c * (x * s)) ** (-2.0d0)
else
tmp = cos((x * 2.0d0)) / (s * (s * (x * (c * (x * c)))))
end if
code = tmp
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double tmp;
if (x <= 6e-5) {
tmp = Math.pow((c * (x * s)), -2.0);
} else {
tmp = Math.cos((x * 2.0)) / (s * (s * (x * (c * (x * c)))));
}
return tmp;
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): tmp = 0 if x <= 6e-5: tmp = math.pow((c * (x * s)), -2.0) else: tmp = math.cos((x * 2.0)) / (s * (s * (x * (c * (x * c))))) return tmp
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) tmp = 0.0 if (x <= 6e-5) tmp = Float64(c * Float64(x * s)) ^ -2.0; else tmp = Float64(cos(Float64(x * 2.0)) / Float64(s * Float64(s * Float64(x * Float64(c * Float64(x * c)))))); end return tmp end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
tmp = 0.0;
if (x <= 6e-5)
tmp = (c * (x * s)) ^ -2.0;
else
tmp = cos((x * 2.0)) / (s * (s * (x * (c * (x * c)))));
end
tmp_2 = tmp;
end
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := If[LessEqual[x, 6e-5], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(s * N[(s * N[(x * N[(c * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6 \cdot 10^{-5}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{s \cdot \left(s \cdot \left(x \cdot \left(c \cdot \left(x \cdot c\right)\right)\right)\right)}\\
\end{array}
\end{array}
if x < 6.00000000000000015e-5Initial program 63.8%
*-commutative63.8%
associate-*r*55.9%
associate-*r*56.4%
unpow256.4%
unswap-sqr75.2%
unpow275.2%
swap-sqr97.3%
*-commutative97.3%
*-commutative97.3%
*-commutative97.3%
*-commutative97.3%
Simplified97.3%
Taylor expanded in x around 0 53.5%
unpow253.5%
unpow253.5%
*-commutative53.5%
unpow253.5%
Simplified53.5%
inv-pow53.5%
unswap-sqr70.3%
unpow270.3%
*-commutative70.3%
pow270.3%
pow-prod-down84.3%
*-commutative84.3%
associate-*r*83.7%
pow283.7%
pow-prod-down83.8%
pow-prod-up83.8%
metadata-eval83.8%
Applied egg-rr83.8%
Taylor expanded in s around 0 84.4%
if 6.00000000000000015e-5 < x Initial program 69.1%
*-commutative69.1%
associate-*l*63.4%
associate-*r*61.8%
*-commutative61.8%
unpow261.8%
associate-*r*63.8%
associate-*r*65.5%
*-commutative65.5%
unpow265.5%
Simplified65.5%
Taylor expanded in x around 0 66.9%
*-commutative66.9%
unpow267.0%
associate-*r*77.3%
unpow277.3%
associate-*r*87.0%
*-commutative87.0%
Simplified87.0%
Final simplification85.0%
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (/ (cos (* x 2.0)) (* (* s (* x c)) (* c (* x s)))))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return cos((x * 2.0)) / ((s * (x * c)) * (c * (x * s)));
}
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = cos((x * 2.0d0)) / ((s * (x * c)) * (c * (x * s)))
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return Math.cos((x * 2.0)) / ((s * (x * c)) * (c * (x * s)));
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return math.cos((x * 2.0)) / ((s * (x * c)) * (c * (x * s)))
c = abs(c) s = abs(s) c, s = sort([c, 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
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = cos((x * 2.0)) / ((s * (x * c)) * (c * (x * s)));
end
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(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}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\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 65.1%
*-commutative65.1%
associate-*r*57.7%
associate-*r*58.1%
unpow258.1%
unswap-sqr76.8%
unpow276.8%
swap-sqr96.7%
*-commutative96.7%
*-commutative96.7%
*-commutative96.7%
*-commutative96.7%
Simplified96.7%
Taylor expanded in s around 0 94.1%
Final simplification94.1%
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (let* ((t_0 (* s (* x c)))) (/ (cos (* x 2.0)) (* t_0 t_0))))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = s * (x * c);
return cos((x * 2.0)) / (t_0 * t_0);
}
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
t_0 = s * (x * c)
code = cos((x * 2.0d0)) / (t_0 * t_0)
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = s * (x * c);
return Math.cos((x * 2.0)) / (t_0 * t_0);
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = s * (x * c) return math.cos((x * 2.0)) / (t_0 * t_0)
c = abs(c) s = abs(s) c, s = sort([c, s]) 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
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
t_0 = s * (x * c);
tmp = cos((x * 2.0)) / (t_0 * t_0);
end
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]}, N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\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 65.1%
*-commutative65.1%
associate-*r*57.7%
associate-*r*58.1%
unpow258.1%
unswap-sqr76.8%
unpow276.8%
swap-sqr96.7%
*-commutative96.7%
*-commutative96.7%
*-commutative96.7%
*-commutative96.7%
Simplified96.7%
Final simplification96.7%
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (let* ((t_0 (* s (* x c)))) (/ (/ (cos (* x 2.0)) t_0) t_0)))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = s * (x * c);
return (cos((x * 2.0)) / t_0) / t_0;
}
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
t_0 = s * (x * c)
code = (cos((x * 2.0d0)) / t_0) / t_0
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = s * (x * c);
return (Math.cos((x * 2.0)) / t_0) / t_0;
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = s * (x * c) return (math.cos((x * 2.0)) / t_0) / t_0
c = abs(c) s = abs(s) c, s = sort([c, s]) 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
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
t_0 = s * (x * c);
tmp = (cos((x * 2.0)) / t_0) / t_0;
end
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\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 65.1%
*-commutative65.1%
associate-*r*57.7%
associate-*r*58.1%
unpow258.1%
unswap-sqr76.8%
unpow276.8%
swap-sqr96.7%
*-commutative96.7%
*-commutative96.7%
*-commutative96.7%
*-commutative96.7%
Simplified96.7%
div-inv96.7%
*-commutative96.7%
pow296.7%
pow-flip97.0%
metadata-eval97.0%
Applied egg-rr97.0%
metadata-eval97.0%
pow-prod-up96.9%
unpow-196.9%
unpow-196.9%
Applied egg-rr96.9%
associate-*r*96.8%
un-div-inv96.9%
un-div-inv96.9%
Applied egg-rr96.9%
Final simplification96.9%
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (pow (* c (* x s)) -2.0))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return pow((c * (x * s)), -2.0);
}
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = (c * (x * s)) ** (-2.0d0)
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return Math.pow((c * (x * s)), -2.0);
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return math.pow((c * (x * s)), -2.0)
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(c * Float64(x * s)) ^ -2.0 end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = (c * (x * s)) ^ -2.0;
end
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}
\end{array}
Initial program 65.1%
*-commutative65.1%
associate-*r*57.7%
associate-*r*58.1%
unpow258.1%
unswap-sqr76.8%
unpow276.8%
swap-sqr96.7%
*-commutative96.7%
*-commutative96.7%
*-commutative96.7%
*-commutative96.7%
Simplified96.7%
Taylor expanded in x around 0 52.0%
unpow252.0%
unpow252.0%
*-commutative52.0%
unpow252.0%
Simplified52.0%
inv-pow52.0%
unswap-sqr65.4%
unpow265.4%
*-commutative65.4%
pow265.4%
pow-prod-down77.3%
*-commutative77.3%
associate-*r*76.8%
pow276.8%
pow-prod-down76.9%
pow-prod-up76.9%
metadata-eval76.9%
Applied egg-rr76.9%
Taylor expanded in s around 0 77.4%
Final simplification77.4%
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (let* ((t_0 (/ (/ 1.0 c) (* x s)))) (* t_0 t_0)))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = (1.0 / c) / (x * s);
return t_0 * t_0;
}
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
t_0 = (1.0d0 / c) / (x * s)
code = t_0 * t_0
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = (1.0 / c) / (x * s);
return t_0 * t_0;
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = (1.0 / c) / (x * s) return t_0 * t_0
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(Float64(1.0 / c) / Float64(x * s)) return Float64(t_0 * t_0) end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
t_0 = (1.0 / c) / (x * s);
tmp = t_0 * t_0;
end
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * t$95$0), $MachinePrecision]]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{1}{c}}{x \cdot s}\\
t_0 \cdot t_0
\end{array}
\end{array}
Initial program 65.1%
associate-/r*64.2%
unpow264.2%
*-commutative64.2%
unpow264.2%
Simplified64.2%
Taylor expanded in x around 0 57.0%
unpow257.0%
Simplified57.0%
add-sqr-sqrt57.0%
sqrt-div57.0%
sqrt-div57.0%
metadata-eval57.0%
sqrt-prod26.5%
add-sqr-sqrt40.9%
associate-*r*35.5%
sqrt-prod35.5%
sqrt-unprod22.0%
add-sqr-sqrt40.7%
sqrt-prod21.7%
add-sqr-sqrt43.3%
*-commutative43.3%
sqrt-div43.3%
sqrt-div44.1%
metadata-eval44.1%
sqrt-prod22.3%
add-sqr-sqrt47.6%
associate-*r*42.1%
sqrt-prod43.2%
Applied egg-rr77.4%
Final simplification77.4%
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (/ 1.0 (* s (* (* x c) (* c (* x s))))))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return 1.0 / (s * ((x * c) * (c * (x * s))));
}
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = 1.0d0 / (s * ((x * c) * (c * (x * s))))
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return 1.0 / (s * ((x * c) * (c * (x * s))));
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return 1.0 / (s * ((x * c) * (c * (x * s))))
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(1.0 / Float64(s * Float64(Float64(x * c) * Float64(c * Float64(x * s))))) end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = 1.0 / (s * ((x * c) * (c * (x * s))));
end
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(1.0 / N[(s * N[(N[(x * c), $MachinePrecision] * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{s \cdot \left(\left(x \cdot c\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)}
\end{array}
Initial program 65.1%
*-commutative65.1%
associate-*r*57.7%
associate-*r*58.1%
unpow258.1%
unswap-sqr76.8%
unpow276.8%
swap-sqr96.7%
*-commutative96.7%
*-commutative96.7%
*-commutative96.7%
*-commutative96.7%
Simplified96.7%
Taylor expanded in x around 0 52.0%
unpow252.0%
unpow252.0%
*-commutative52.0%
unpow252.0%
Simplified52.0%
inv-pow52.0%
unswap-sqr65.4%
unpow265.4%
*-commutative65.4%
pow265.4%
pow-prod-down77.3%
*-commutative77.3%
associate-*r*76.8%
pow276.8%
pow-prod-down76.9%
pow-prod-up76.9%
metadata-eval76.9%
Applied egg-rr76.9%
metadata-eval76.9%
pow-prod-up76.9%
pow-prod-down76.8%
pow276.8%
associate-*r*77.3%
*-commutative77.3%
pow-prod-down65.4%
pow265.4%
*-commutative65.4%
unpow265.4%
unswap-sqr52.0%
inv-pow52.0%
unswap-sqr65.4%
unpow265.4%
*-commutative65.4%
pow265.4%
pow-prod-down77.3%
*-commutative77.3%
associate-*r*76.8%
Applied egg-rr76.8%
unpow276.8%
associate-*r*76.3%
*-commutative76.3%
associate-*l*75.2%
*-commutative75.2%
Applied egg-rr75.2%
Final simplification75.2%
NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (let* ((t_0 (* c (* x s)))) (/ 1.0 (* t_0 t_0))))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = c * (x * s);
return 1.0 / (t_0 * t_0);
}
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
t_0 = c * (x * s)
code = 1.0d0 / (t_0 * t_0)
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = c * (x * s);
return 1.0 / (t_0 * t_0);
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = c * (x * s) return 1.0 / (t_0 * t_0)
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(c * Float64(x * s)) return Float64(1.0 / Float64(t_0 * t_0)) end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
t_0 = c * (x * s);
tmp = 1.0 / (t_0 * t_0);
end
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\frac{1}{t_0 \cdot t_0}
\end{array}
\end{array}
Initial program 65.1%
*-commutative65.1%
associate-*r*57.7%
associate-*r*58.1%
unpow258.1%
unswap-sqr76.8%
unpow276.8%
swap-sqr96.7%
*-commutative96.7%
*-commutative96.7%
*-commutative96.7%
*-commutative96.7%
Simplified96.7%
Taylor expanded in x around 0 52.0%
unpow252.0%
unpow252.0%
*-commutative52.0%
unpow252.0%
Simplified52.0%
inv-pow52.0%
unswap-sqr65.4%
unpow265.4%
*-commutative65.4%
pow265.4%
pow-prod-down77.3%
*-commutative77.3%
associate-*r*76.8%
pow276.8%
pow-prod-down76.9%
pow-prod-up76.9%
metadata-eval76.9%
Applied egg-rr76.9%
metadata-eval76.9%
pow-prod-up76.9%
pow-prod-down76.8%
pow276.8%
associate-*r*77.3%
*-commutative77.3%
pow-prod-down65.4%
pow265.4%
*-commutative65.4%
unpow265.4%
unswap-sqr52.0%
inv-pow52.0%
unswap-sqr65.4%
unpow265.4%
*-commutative65.4%
pow265.4%
pow-prod-down77.3%
*-commutative77.3%
associate-*r*76.8%
Applied egg-rr76.8%
unpow276.8%
associate-*r*76.3%
*-commutative76.3%
*-commutative76.3%
associate-*r*77.3%
*-commutative77.3%
*-commutative77.3%
Applied egg-rr77.3%
Final simplification77.3%
herbie shell --seed 2023229
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))