
(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: 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 (* 2.0 x)) (* t_0 t_0))))
assert(c < s);
double code(double x, double c, double s) {
double t_0 = s * (x * c);
return cos((2.0 * x)) / (t_0 * t_0);
}
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((2.0d0 * x)) / (t_0 * t_0)
end function
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = s * (x * c);
return Math.cos((2.0 * x)) / (t_0 * t_0);
}
[c, s] = sort([c, s]) def code(x, c, s): t_0 = s * (x * c) return math.cos((2.0 * x)) / (t_0 * t_0)
c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(s * Float64(x * c)) return Float64(cos(Float64(2.0 * x)) / Float64(t_0 * t_0)) end
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
t_0 = s * (x * c);
tmp = cos((2.0 * x)) / (t_0 * t_0);
end
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[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := s \cdot \left(x \cdot c\right)\\
\frac{\cos \left(2 \cdot x\right)}{t_0 \cdot t_0}
\end{array}
\end{array}
Initial program 64.8%
associate-/r*64.9%
remove-double-neg64.9%
distribute-lft-neg-out64.9%
distribute-lft-neg-out64.9%
distribute-rgt-neg-out64.9%
associate-/l/64.8%
distribute-rgt-neg-out64.8%
distribute-lft-neg-out64.8%
associate-*l*66.6%
distribute-lft-neg-in66.6%
distribute-lft-neg-out66.6%
remove-double-neg66.6%
associate-*r*66.5%
*-commutative66.5%
associate-*r*65.6%
Simplified71.7%
Taylor expanded in x around 0 57.9%
unpow257.9%
associate-*r*57.9%
unpow257.9%
unpow257.9%
swap-sqr71.6%
swap-sqr95.2%
*-commutative95.2%
*-commutative95.2%
unpow295.2%
*-commutative95.2%
*-commutative95.2%
associate-*l*97.0%
Simplified97.0%
unpow297.0%
Applied egg-rr97.0%
Final simplification97.0%
NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (if (<= x 1.05e-13) (pow (* c (* x s)) -2.0) (/ (cos (* 2.0 x)) (* x (* s (* (* x c) (* s c)))))))
assert(c < s);
double code(double x, double c, double s) {
double tmp;
if (x <= 1.05e-13) {
tmp = pow((c * (x * s)), -2.0);
} else {
tmp = cos((2.0 * x)) / (x * (s * ((x * c) * (s * c))));
}
return tmp;
}
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: tmp
if (x <= 1.05d-13) then
tmp = (c * (x * s)) ** (-2.0d0)
else
tmp = cos((2.0d0 * x)) / (x * (s * ((x * c) * (s * c))))
end if
code = tmp
end function
assert c < s;
public static double code(double x, double c, double s) {
double tmp;
if (x <= 1.05e-13) {
tmp = Math.pow((c * (x * s)), -2.0);
} else {
tmp = Math.cos((2.0 * x)) / (x * (s * ((x * c) * (s * c))));
}
return tmp;
}
[c, s] = sort([c, s]) def code(x, c, s): tmp = 0 if x <= 1.05e-13: tmp = math.pow((c * (x * s)), -2.0) else: tmp = math.cos((2.0 * x)) / (x * (s * ((x * c) * (s * c)))) return tmp
c, s = sort([c, s]) function code(x, c, s) tmp = 0.0 if (x <= 1.05e-13) tmp = Float64(c * Float64(x * s)) ^ -2.0; else tmp = Float64(cos(Float64(2.0 * x)) / Float64(x * Float64(s * Float64(Float64(x * c) * Float64(s * c))))); end return tmp end
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
tmp = 0.0;
if (x <= 1.05e-13)
tmp = (c * (x * s)) ^ -2.0;
else
tmp = cos((2.0 * x)) / (x * (s * ((x * c) * (s * c))));
end
tmp_2 = tmp;
end
NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := If[LessEqual[x, 1.05e-13], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(x * N[(s * N[(N[(x * c), $MachinePrecision] * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.05 \cdot 10^{-13}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(s \cdot \left(\left(x \cdot c\right) \cdot \left(s \cdot c\right)\right)\right)}\\
\end{array}
\end{array}
if x < 1.04999999999999994e-13Initial program 64.2%
associate-/r*64.2%
remove-double-neg64.2%
distribute-lft-neg-out64.2%
distribute-lft-neg-out64.2%
distribute-rgt-neg-out64.2%
associate-/l/64.2%
distribute-rgt-neg-out64.2%
distribute-lft-neg-out64.2%
associate-*l*66.2%
distribute-lft-neg-in66.2%
distribute-lft-neg-out66.2%
remove-double-neg66.2%
associate-*r*65.9%
*-commutative65.9%
associate-*r*64.3%
Simplified69.9%
Taylor expanded in x around 0 57.3%
unpow257.3%
associate-*r*56.9%
unpow256.9%
unpow256.9%
swap-sqr70.0%
swap-sqr94.6%
*-commutative94.6%
*-commutative94.6%
unpow294.6%
*-commutative94.6%
*-commutative94.6%
associate-*l*96.8%
Simplified96.8%
Taylor expanded in x around 0 54.2%
unpow254.2%
unpow254.2%
unpow254.2%
associate-*r*54.1%
*-commutative54.1%
swap-sqr66.2%
swap-sqr86.3%
associate-*r*85.0%
associate-*r*88.3%
associate-/r*88.2%
*-lft-identity88.2%
associate-*l/88.2%
unpow-188.2%
unpow-188.2%
pow-sqr88.3%
associate-*r*86.3%
*-commutative86.3%
associate-*r*89.1%
metadata-eval89.1%
Simplified89.1%
if 1.04999999999999994e-13 < x Initial program 66.7%
associate-/r*67.1%
remove-double-neg67.1%
distribute-lft-neg-out67.1%
distribute-lft-neg-out67.1%
distribute-rgt-neg-out67.1%
associate-/l/66.7%
distribute-rgt-neg-out66.7%
distribute-lft-neg-out66.7%
associate-*l*68.1%
distribute-lft-neg-in68.1%
distribute-lft-neg-out68.1%
remove-double-neg68.1%
associate-*r*68.1%
*-commutative68.1%
associate-*r*69.7%
Simplified77.6%
add-sqr-sqrt77.6%
pow277.6%
associate-*r*69.7%
swap-sqr85.4%
*-commutative85.4%
sqrt-prod85.3%
sqrt-prod48.5%
add-sqr-sqrt90.7%
Applied egg-rr90.7%
unpow290.7%
*-commutative90.7%
associate-*r*90.7%
associate-*r*90.7%
*-commutative90.7%
add-sqr-sqrt90.7%
associate-*r*89.3%
*-commutative89.3%
Applied egg-rr89.3%
associate-*l*86.4%
*-commutative86.4%
Simplified86.4%
Final simplification88.4%
NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (if (<= x 1e-59) (pow (* c (* x s)) -2.0) (/ (cos (* 2.0 x)) (* (* x (* s (* x c))) (* s c)))))
assert(c < s);
double code(double x, double c, double s) {
double tmp;
if (x <= 1e-59) {
tmp = pow((c * (x * s)), -2.0);
} else {
tmp = cos((2.0 * x)) / ((x * (s * (x * c))) * (s * c));
}
return tmp;
}
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 <= 1d-59) then
tmp = (c * (x * s)) ** (-2.0d0)
else
tmp = cos((2.0d0 * x)) / ((x * (s * (x * c))) * (s * c))
end if
code = tmp
end function
assert c < s;
public static double code(double x, double c, double s) {
double tmp;
if (x <= 1e-59) {
tmp = Math.pow((c * (x * s)), -2.0);
} else {
tmp = Math.cos((2.0 * x)) / ((x * (s * (x * c))) * (s * c));
}
return tmp;
}
[c, s] = sort([c, s]) def code(x, c, s): tmp = 0 if x <= 1e-59: tmp = math.pow((c * (x * s)), -2.0) else: tmp = math.cos((2.0 * x)) / ((x * (s * (x * c))) * (s * c)) return tmp
c, s = sort([c, s]) function code(x, c, s) tmp = 0.0 if (x <= 1e-59) tmp = Float64(c * Float64(x * s)) ^ -2.0; else tmp = Float64(cos(Float64(2.0 * x)) / Float64(Float64(x * Float64(s * Float64(x * c))) * Float64(s * c))); end return tmp end
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
tmp = 0.0;
if (x <= 1e-59)
tmp = (c * (x * s)) ^ -2.0;
else
tmp = cos((2.0 * x)) / ((x * (s * (x * c))) * (s * c));
end
tmp_2 = tmp;
end
NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := If[LessEqual[x, 1e-59], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[(x * N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{-59}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(2 \cdot x\right)}{\left(x \cdot \left(s \cdot \left(x \cdot c\right)\right)\right) \cdot \left(s \cdot c\right)}\\
\end{array}
\end{array}
if x < 1e-59Initial program 64.6%
associate-/r*64.6%
remove-double-neg64.6%
distribute-lft-neg-out64.6%
distribute-lft-neg-out64.6%
distribute-rgt-neg-out64.6%
associate-/l/64.6%
distribute-rgt-neg-out64.6%
distribute-lft-neg-out64.6%
associate-*l*66.6%
distribute-lft-neg-in66.6%
distribute-lft-neg-out66.6%
remove-double-neg66.6%
associate-*r*66.4%
*-commutative66.4%
associate-*r*64.7%
Simplified70.0%
Taylor expanded in x around 0 57.5%
unpow257.5%
associate-*r*57.0%
unpow257.0%
unpow257.0%
swap-sqr69.0%
swap-sqr94.4%
*-commutative94.4%
*-commutative94.4%
unpow294.4%
*-commutative94.4%
*-commutative94.4%
associate-*l*96.7%
Simplified96.7%
Taylor expanded in x around 0 54.2%
unpow254.2%
unpow254.2%
unpow254.2%
associate-*r*54.2%
*-commutative54.2%
swap-sqr65.1%
swap-sqr85.9%
associate-*r*84.6%
associate-*r*87.9%
associate-/r*87.9%
*-lft-identity87.9%
associate-*l/87.8%
unpow-187.8%
unpow-187.8%
pow-sqr88.0%
associate-*r*85.9%
*-commutative85.9%
associate-*r*88.8%
metadata-eval88.8%
Simplified88.8%
if 1e-59 < x Initial program 65.4%
associate-/r*65.8%
remove-double-neg65.8%
distribute-lft-neg-out65.8%
distribute-lft-neg-out65.8%
distribute-rgt-neg-out65.8%
associate-/l/65.4%
distribute-rgt-neg-out65.4%
distribute-lft-neg-out65.4%
associate-*l*66.7%
distribute-lft-neg-in66.7%
distribute-lft-neg-out66.7%
remove-double-neg66.7%
associate-*r*66.7%
*-commutative66.7%
associate-*r*68.2%
Simplified76.8%
Taylor expanded in x around 0 59.0%
unpow259.0%
associate-*r*60.4%
unpow260.4%
unpow260.4%
swap-sqr78.8%
swap-sqr97.5%
*-commutative97.5%
*-commutative97.5%
unpow297.5%
*-commutative97.5%
*-commutative97.5%
associate-*l*97.9%
Simplified97.9%
unpow268.1%
associate-*r*68.0%
*-commutative68.0%
associate-*l*67.3%
*-commutative67.3%
Applied egg-rr93.5%
Final simplification90.0%
NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (/ (cos (* 2.0 x)) (* (* s (* x c)) (* c (* x s)))))
assert(c < s);
double code(double x, double c, double s) {
return cos((2.0 * x)) / ((s * (x * c)) * (c * (x * s)));
}
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((2.0d0 * x)) / ((s * (x * c)) * (c * (x * s)))
end function
assert c < s;
public static double code(double x, double c, double s) {
return Math.cos((2.0 * x)) / ((s * (x * c)) * (c * (x * s)));
}
[c, s] = sort([c, s]) def code(x, c, s): return math.cos((2.0 * x)) / ((s * (x * c)) * (c * (x * s)))
c, s = sort([c, s]) function code(x, c, s) return Float64(cos(Float64(2.0 * x)) / Float64(Float64(s * Float64(x * c)) * Float64(c * Float64(x * s)))) end
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = cos((2.0 * x)) / ((s * (x * c)) * (c * (x * s)));
end
NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision] * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\cos \left(2 \cdot x\right)}{\left(s \cdot \left(x \cdot c\right)\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}
\end{array}
Initial program 64.8%
associate-/r*64.9%
remove-double-neg64.9%
distribute-lft-neg-out64.9%
distribute-lft-neg-out64.9%
distribute-rgt-neg-out64.9%
associate-/l/64.8%
distribute-rgt-neg-out64.8%
distribute-lft-neg-out64.8%
associate-*l*66.6%
distribute-lft-neg-in66.6%
distribute-lft-neg-out66.6%
remove-double-neg66.6%
associate-*r*66.5%
*-commutative66.5%
associate-*r*65.6%
Simplified71.7%
Taylor expanded in x around 0 57.9%
unpow257.9%
associate-*r*57.9%
unpow257.9%
unpow257.9%
swap-sqr71.6%
swap-sqr95.2%
*-commutative95.2%
*-commutative95.2%
unpow295.2%
*-commutative95.2%
*-commutative95.2%
associate-*l*97.0%
Simplified97.0%
unpow297.0%
Applied egg-rr97.0%
Taylor expanded in s around 0 96.0%
Final simplification96.0%
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))
assert(c < s);
double code(double x, double c, double s) {
return pow((c * (x * s)), -2.0);
}
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
assert c < s;
public static double code(double x, double c, double s) {
return Math.pow((c * (x * s)), -2.0);
}
[c, s] = sort([c, s]) def code(x, c, s): return math.pow((c * (x * s)), -2.0)
c, s = sort([c, s]) function code(x, c, s) return Float64(c * Float64(x * s)) ^ -2.0 end
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = (c * (x * s)) ^ -2.0;
end
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, s] = \mathsf{sort}([c, s])\\
\\
{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}
\end{array}
Initial program 64.8%
associate-/r*64.9%
remove-double-neg64.9%
distribute-lft-neg-out64.9%
distribute-lft-neg-out64.9%
distribute-rgt-neg-out64.9%
associate-/l/64.8%
distribute-rgt-neg-out64.8%
distribute-lft-neg-out64.8%
associate-*l*66.6%
distribute-lft-neg-in66.6%
distribute-lft-neg-out66.6%
remove-double-neg66.6%
associate-*r*66.5%
*-commutative66.5%
associate-*r*65.6%
Simplified71.7%
Taylor expanded in x around 0 57.9%
unpow257.9%
associate-*r*57.9%
unpow257.9%
unpow257.9%
swap-sqr71.6%
swap-sqr95.2%
*-commutative95.2%
*-commutative95.2%
unpow295.2%
*-commutative95.2%
*-commutative95.2%
associate-*l*97.0%
Simplified97.0%
Taylor expanded in x around 0 53.5%
unpow253.5%
unpow253.5%
unpow253.5%
associate-*r*53.5%
*-commutative53.5%
swap-sqr64.2%
swap-sqr81.2%
associate-*r*80.2%
associate-*r*82.7%
associate-/r*82.7%
*-lft-identity82.7%
associate-*l/82.7%
unpow-182.7%
unpow-182.7%
pow-sqr82.8%
associate-*r*81.3%
*-commutative81.3%
associate-*r*83.4%
metadata-eval83.4%
Simplified83.4%
Final simplification83.4%
NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (/ 1.0 (* x (* s (* (* x c) (* s c))))))
assert(c < s);
double code(double x, double c, double s) {
return 1.0 / (x * (s * ((x * c) * (s * c))));
}
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 / (x * (s * ((x * c) * (s * c))))
end function
assert c < s;
public static double code(double x, double c, double s) {
return 1.0 / (x * (s * ((x * c) * (s * c))));
}
[c, s] = sort([c, s]) def code(x, c, s): return 1.0 / (x * (s * ((x * c) * (s * c))))
c, s = sort([c, s]) function code(x, c, s) return Float64(1.0 / Float64(x * Float64(s * Float64(Float64(x * c) * Float64(s * c))))) end
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = 1.0 / (x * (s * ((x * c) * (s * c))));
end
NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(1.0 / N[(x * N[(s * N[(N[(x * c), $MachinePrecision] * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{x \cdot \left(s \cdot \left(\left(x \cdot c\right) \cdot \left(s \cdot c\right)\right)\right)}
\end{array}
Initial program 64.8%
associate-/r*64.9%
remove-double-neg64.9%
distribute-lft-neg-out64.9%
distribute-lft-neg-out64.9%
distribute-rgt-neg-out64.9%
associate-/l/64.8%
distribute-rgt-neg-out64.8%
distribute-lft-neg-out64.8%
associate-*l*66.6%
distribute-lft-neg-in66.6%
distribute-lft-neg-out66.6%
remove-double-neg66.6%
associate-*r*66.5%
*-commutative66.5%
associate-*r*65.6%
Simplified71.7%
add-sqr-sqrt40.0%
pow240.0%
associate-*r*36.5%
swap-sqr46.3%
*-commutative46.3%
sqrt-prod46.3%
sqrt-prod26.4%
add-sqr-sqrt50.2%
Applied egg-rr50.2%
unpow250.2%
*-commutative50.2%
associate-*r*50.2%
associate-*r*50.2%
*-commutative50.2%
add-sqr-sqrt90.0%
associate-*r*88.4%
*-commutative88.4%
Applied egg-rr88.4%
associate-*l*86.4%
*-commutative86.4%
Simplified86.4%
Taylor expanded in x around 0 76.3%
Final simplification76.3%
NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (/ 1.0 (* (* x (* s (* x c))) (* s c))))
assert(c < s);
double code(double x, double c, double s) {
return 1.0 / ((x * (s * (x * c))) * (s * c));
}
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 / ((x * (s * (x * c))) * (s * c))
end function
assert c < s;
public static double code(double x, double c, double s) {
return 1.0 / ((x * (s * (x * c))) * (s * c));
}
[c, s] = sort([c, s]) def code(x, c, s): return 1.0 / ((x * (s * (x * c))) * (s * c))
c, s = sort([c, s]) function code(x, c, s) return Float64(1.0 / Float64(Float64(x * Float64(s * Float64(x * c))) * Float64(s * c))) end
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = 1.0 / ((x * (s * (x * c))) * (s * c));
end
NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(1.0 / N[(N[(x * N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{\left(x \cdot \left(s \cdot \left(x \cdot c\right)\right)\right) \cdot \left(s \cdot c\right)}
\end{array}
Initial program 64.8%
associate-/r*64.9%
*-commutative64.9%
associate-*l*58.0%
unpow258.0%
unpow258.0%
associate-*r*63.3%
associate-/r*65.8%
associate-/l/66.1%
associate-/l/65.9%
*-commutative65.9%
associate-*l*63.3%
unpow263.3%
associate-*l*57.9%
unpow257.9%
unswap-sqr71.6%
*-commutative71.6%
*-commutative71.6%
Simplified71.6%
Taylor expanded in x around 0 53.5%
associate-/r*53.5%
unpow253.5%
associate-/r*53.5%
associate-/r*53.5%
unpow253.5%
unpow253.5%
swap-sqr64.2%
unpow264.2%
associate-/r*64.2%
*-commutative64.2%
unpow264.2%
swap-sqr81.2%
unpow281.2%
*-commutative81.2%
*-commutative81.2%
associate-*l*82.7%
Simplified82.7%
unpow282.7%
associate-*r*80.2%
*-commutative80.2%
associate-*l*77.8%
*-commutative77.8%
Applied egg-rr77.8%
Final simplification77.8%
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)))) (/ 1.0 (* t_0 t_0))))
assert(c < s);
double code(double x, double c, double s) {
double t_0 = s * (x * c);
return 1.0 / (t_0 * t_0);
}
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 = 1.0d0 / (t_0 * t_0)
end function
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = s * (x * c);
return 1.0 / (t_0 * t_0);
}
[c, s] = sort([c, s]) def code(x, c, s): t_0 = s * (x * c) return 1.0 / (t_0 * t_0)
c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(s * Float64(x * c)) return Float64(1.0 / Float64(t_0 * t_0)) end
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
t_0 = s * (x * c);
tmp = 1.0 / (t_0 * t_0);
end
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[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := s \cdot \left(x \cdot c\right)\\
\frac{1}{t_0 \cdot t_0}
\end{array}
\end{array}
Initial program 64.8%
associate-/r*64.9%
*-commutative64.9%
associate-*l*58.0%
unpow258.0%
unpow258.0%
associate-*r*63.3%
associate-/r*65.8%
associate-/l/66.1%
associate-/l/65.9%
*-commutative65.9%
associate-*l*63.3%
unpow263.3%
associate-*l*57.9%
unpow257.9%
unswap-sqr71.6%
*-commutative71.6%
*-commutative71.6%
Simplified71.6%
Taylor expanded in x around 0 53.5%
associate-/r*53.5%
unpow253.5%
associate-/r*53.5%
associate-/r*53.5%
unpow253.5%
unpow253.5%
swap-sqr64.2%
unpow264.2%
associate-/r*64.2%
*-commutative64.2%
unpow264.2%
swap-sqr81.2%
unpow281.2%
*-commutative81.2%
*-commutative81.2%
associate-*l*82.7%
Simplified82.7%
unpow297.0%
Applied egg-rr82.7%
Final simplification82.7%
NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (/ (/ 1.0 (* c (* x s))) (* s (* x c))))
assert(c < s);
double code(double x, double c, double s) {
return (1.0 / (c * (x * s))) / (s * (x * c));
}
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 / (c * (x * s))) / (s * (x * c))
end function
assert c < s;
public static double code(double x, double c, double s) {
return (1.0 / (c * (x * s))) / (s * (x * c));
}
[c, s] = sort([c, s]) def code(x, c, s): return (1.0 / (c * (x * s))) / (s * (x * c))
c, s = sort([c, s]) function code(x, c, s) return Float64(Float64(1.0 / Float64(c * Float64(x * s))) / Float64(s * Float64(x * c))) end
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = (1.0 / (c * (x * s))) / (s * (x * c));
end
NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(N[(1.0 / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\frac{1}{c \cdot \left(x \cdot s\right)}}{s \cdot \left(x \cdot c\right)}
\end{array}
Initial program 64.8%
associate-/r*64.9%
*-commutative64.9%
associate-*l*58.0%
unpow258.0%
unpow258.0%
associate-*r*63.3%
associate-/r*65.8%
associate-/l/66.1%
associate-/l/65.9%
*-commutative65.9%
associate-*l*63.3%
unpow263.3%
associate-*l*57.9%
unpow257.9%
unswap-sqr71.6%
*-commutative71.6%
*-commutative71.6%
Simplified71.6%
Taylor expanded in x around 0 53.5%
associate-/r*53.5%
unpow253.5%
associate-/r*53.5%
associate-/r*53.5%
unpow253.5%
unpow253.5%
swap-sqr64.2%
unpow264.2%
associate-/r*64.2%
*-commutative64.2%
unpow264.2%
swap-sqr81.2%
unpow281.2%
*-commutative81.2%
*-commutative81.2%
associate-*l*82.7%
Simplified82.7%
pow-flip82.8%
add-sqr-sqrt50.5%
unpow-prod-down50.5%
metadata-eval50.5%
metadata-eval50.5%
Applied egg-rr50.5%
pow-sqr50.6%
metadata-eval50.6%
Simplified50.6%
sqrt-pow282.8%
metadata-eval82.8%
metadata-eval82.8%
pow-div82.7%
inv-pow82.7%
pow182.7%
Applied egg-rr82.7%
Taylor expanded in s around 0 82.5%
Final simplification82.5%
NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (/ (/ -2.0 (* c c)) (* s s)))
assert(c < s);
double code(double x, double c, double s) {
return (-2.0 / (c * c)) / (s * s);
}
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 = ((-2.0d0) / (c * c)) / (s * s)
end function
assert c < s;
public static double code(double x, double c, double s) {
return (-2.0 / (c * c)) / (s * s);
}
[c, s] = sort([c, s]) def code(x, c, s): return (-2.0 / (c * c)) / (s * s)
c, s = sort([c, s]) function code(x, c, s) return Float64(Float64(-2.0 / Float64(c * c)) / Float64(s * s)) end
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = (-2.0 / (c * c)) / (s * s);
end
NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(N[(-2.0 / N[(c * c), $MachinePrecision]), $MachinePrecision] / N[(s * s), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\frac{-2}{c \cdot c}}{s \cdot s}
\end{array}
Initial program 64.8%
associate-/r*64.9%
*-commutative64.9%
associate-*l*58.0%
unpow258.0%
unpow258.0%
associate-*r*63.3%
associate-/r*65.8%
associate-/l/66.1%
associate-/l/65.9%
*-commutative65.9%
associate-*l*63.3%
unpow263.3%
associate-*l*57.9%
unpow257.9%
unswap-sqr71.6%
*-commutative71.6%
*-commutative71.6%
Simplified71.6%
Taylor expanded in x around 0 52.2%
unpow252.2%
Simplified52.2%
Taylor expanded in x around inf 25.4%
associate-/r*25.1%
unpow225.1%
unpow225.1%
Simplified25.1%
Final simplification25.1%
herbie shell --seed 2023275
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))