
(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}
c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x c_m s_m) :precision binary64 (* (pow (* s_m (* x c_m)) -2.0) (cos (* x 2.0))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
return pow((s_m * (x * c_m)), -2.0) * cos((x * 2.0));
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
code = ((s_m * (x * c_m)) ** (-2.0d0)) * cos((x * 2.0d0))
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
return Math.pow((s_m * (x * c_m)), -2.0) * Math.cos((x * 2.0));
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): return math.pow((s_m * (x * c_m)), -2.0) * math.cos((x * 2.0))
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) return Float64((Float64(s_m * Float64(x * c_m)) ^ -2.0) * cos(Float64(x * 2.0))) end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
tmp = ((s_m * (x * c_m)) ^ -2.0) * cos((x * 2.0));
end
c_m = N[Abs[c], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. code[x_, c$95$m_, s$95$m_] := N[(N[Power[N[(s$95$m * N[(x * c$95$m), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision] * N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
{\left(s\_m \cdot \left(x \cdot c\_m\right)\right)}^{-2} \cdot \cos \left(x \cdot 2\right)
\end{array}
Initial program 66.1%
Taylor expanded in c around 0 60.1%
unpow260.1%
rem-square-sqrt60.1%
swap-sqr67.7%
unpow267.7%
unpow267.7%
unpow267.7%
unswap-sqr86.9%
rem-sqrt-square96.6%
Simplified96.6%
pow-prod-down78.1%
associate-/r*78.4%
add-sqr-sqrt44.3%
fabs-sqr44.3%
add-sqr-sqrt78.4%
pow-prod-down60.3%
associate-/r*60.1%
pow160.1%
metadata-eval60.1%
sqrt-pow260.1%
pow-prod-down67.7%
div-inv67.7%
*-commutative67.7%
Applied egg-rr97.7%
Final simplification97.7%
c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x c_m s_m) :precision binary64 (let* ((t_0 (* s_m (* x c_m)))) (/ (cos (* x 2.0)) (* t_0 t_0))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
double t_0 = s_m * (x * c_m);
return cos((x * 2.0)) / (t_0 * t_0);
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
t_0 = s_m * (x * c_m)
code = cos((x * 2.0d0)) / (t_0 * t_0)
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
double t_0 = s_m * (x * c_m);
return Math.cos((x * 2.0)) / (t_0 * t_0);
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): t_0 = s_m * (x * c_m) return math.cos((x * 2.0)) / (t_0 * t_0)
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) t_0 = Float64(s_m * Float64(x * c_m)) return Float64(cos(Float64(x * 2.0)) / Float64(t_0 * t_0)) end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
t_0 = s_m * (x * c_m);
tmp = cos((x * 2.0)) / (t_0 * t_0);
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(s$95$m * N[(x * c$95$m), $MachinePrecision]), $MachinePrecision]}, N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := s\_m \cdot \left(x \cdot c\_m\right)\\
\frac{\cos \left(x \cdot 2\right)}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 66.1%
Taylor expanded in c around 0 60.1%
unpow260.1%
rem-square-sqrt60.1%
swap-sqr67.7%
unpow267.7%
unpow267.7%
unpow267.7%
unswap-sqr86.9%
rem-sqrt-square96.6%
Simplified96.6%
pow-prod-down68.0%
*-commutative68.0%
unpow268.0%
sqr-abs68.0%
unpow268.0%
swap-sqr79.8%
associate-*l*78.8%
associate-*l*79.0%
Applied egg-rr97.1%
Final simplification97.1%
c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x c_m s_m) :precision binary64 (let* ((t_0 (* s_m (* x c_m)))) (/ (/ (cos (* x 2.0)) t_0) t_0)))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
double t_0 = s_m * (x * c_m);
return (cos((x * 2.0)) / t_0) / t_0;
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
t_0 = s_m * (x * c_m)
code = (cos((x * 2.0d0)) / t_0) / t_0
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
double t_0 = s_m * (x * c_m);
return (Math.cos((x * 2.0)) / t_0) / t_0;
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): t_0 = s_m * (x * c_m) return (math.cos((x * 2.0)) / t_0) / t_0
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) t_0 = Float64(s_m * Float64(x * c_m)) return Float64(Float64(cos(Float64(x * 2.0)) / t_0) / t_0) end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
t_0 = s_m * (x * c_m);
tmp = (cos((x * 2.0)) / t_0) / t_0;
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(s$95$m * N[(x * c$95$m), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := s\_m \cdot \left(x \cdot c\_m\right)\\
\frac{\frac{\cos \left(x \cdot 2\right)}{t\_0}}{t\_0}
\end{array}
\end{array}
Initial program 66.1%
Taylor expanded in c around 0 60.1%
unpow260.1%
rem-square-sqrt60.1%
swap-sqr67.7%
unpow267.7%
unpow267.7%
unpow267.7%
unswap-sqr86.9%
rem-sqrt-square96.6%
Simplified96.6%
pow-prod-down78.1%
associate-/r*78.4%
add-sqr-sqrt44.3%
fabs-sqr44.3%
add-sqr-sqrt78.4%
pow-prod-down60.3%
associate-/r*60.1%
pow160.1%
metadata-eval60.1%
sqrt-pow260.1%
pow-prod-down67.7%
div-inv67.7%
*-commutative67.7%
Applied egg-rr97.7%
*-commutative97.7%
metadata-eval97.7%
pow-flip97.1%
pow297.1%
associate-/r/97.1%
clear-num97.1%
associate-/r*97.6%
*-commutative97.6%
Applied egg-rr97.6%
Final simplification97.6%
c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x c_m s_m) :precision binary64 (pow (* c_m (* s_m x)) -2.0))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
return pow((c_m * (s_m * x)), -2.0);
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
code = (c_m * (s_m * x)) ** (-2.0d0)
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
return Math.pow((c_m * (s_m * x)), -2.0);
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): return math.pow((c_m * (s_m * x)), -2.0)
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) return Float64(c_m * Float64(s_m * x)) ^ -2.0 end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
tmp = (c_m * (s_m * x)) ^ -2.0;
end
c_m = N[Abs[c], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. code[x_, c$95$m_, s$95$m_] := N[Power[N[(c$95$m * N[(s$95$m * x), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
{\left(c\_m \cdot \left(s\_m \cdot x\right)\right)}^{-2}
\end{array}
Initial program 66.1%
Taylor expanded in c around 0 60.1%
unpow260.1%
rem-square-sqrt60.1%
swap-sqr67.7%
unpow267.7%
unpow267.7%
unpow267.7%
unswap-sqr86.9%
rem-sqrt-square96.6%
Simplified96.6%
Taylor expanded in x around 0 68.0%
associate-/r*68.0%
unpow268.0%
sqr-abs68.0%
unpow268.0%
associate-/r*68.0%
*-commutative68.0%
unpow268.0%
unpow268.0%
swap-sqr79.8%
associate-*r*78.8%
associate-*r*79.0%
unpow279.0%
/-rgt-identity79.0%
unpow279.0%
associate-/l*78.9%
associate-/l*79.3%
associate-*l/79.3%
unpow-179.3%
unpow-179.3%
Simplified80.2%
Final simplification80.2%
c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x c_m s_m) :precision binary64 (/ 1.0 (* (* s_m c_m) (* x (* c_m (* s_m x))))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
return 1.0 / ((s_m * c_m) * (x * (c_m * (s_m * x))));
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
code = 1.0d0 / ((s_m * c_m) * (x * (c_m * (s_m * x))))
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
return 1.0 / ((s_m * c_m) * (x * (c_m * (s_m * x))));
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): return 1.0 / ((s_m * c_m) * (x * (c_m * (s_m * x))))
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) return Float64(1.0 / Float64(Float64(s_m * c_m) * Float64(x * Float64(c_m * Float64(s_m * x))))) end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
tmp = 1.0 / ((s_m * c_m) * (x * (c_m * (s_m * x))));
end
c_m = N[Abs[c], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. code[x_, c$95$m_, s$95$m_] := N[(1.0 / N[(N[(s$95$m * c$95$m), $MachinePrecision] * N[(x * N[(c$95$m * N[(s$95$m * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\frac{1}{\left(s\_m \cdot c\_m\right) \cdot \left(x \cdot \left(c\_m \cdot \left(s\_m \cdot x\right)\right)\right)}
\end{array}
Initial program 66.1%
Taylor expanded in x around 0 56.4%
unpow256.4%
rem-square-sqrt56.4%
swap-sqr62.4%
unpow262.4%
unpow262.4%
unpow262.4%
unswap-sqr74.5%
rem-sqrt-square79.8%
Simplified79.8%
pow-prod-down68.0%
*-commutative68.0%
unpow268.0%
sqr-abs68.0%
unpow268.0%
swap-sqr79.8%
associate-*l*78.8%
associate-*l*79.0%
Applied egg-rr79.0%
/-rgt-identity79.0%
associate-*l*78.3%
associate-/l*78.3%
*-commutative78.3%
associate-*r*74.6%
pow274.6%
Applied egg-rr74.6%
associate-/r/74.6%
/-rgt-identity74.6%
*-commutative74.6%
associate-*r*69.0%
unpow269.0%
swap-sqr79.0%
associate-*r*78.8%
*-commutative78.8%
associate-*r*77.5%
associate-*l*77.0%
associate-*r*77.6%
*-commutative77.6%
*-commutative77.6%
Applied egg-rr77.6%
Final simplification77.6%
c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x c_m s_m) :precision binary64 (/ 1.0 (* (* s_m (* x c_m)) (* c_m (* s_m x)))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
return 1.0 / ((s_m * (x * c_m)) * (c_m * (s_m * x)));
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
code = 1.0d0 / ((s_m * (x * c_m)) * (c_m * (s_m * x)))
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
return 1.0 / ((s_m * (x * c_m)) * (c_m * (s_m * x)));
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): return 1.0 / ((s_m * (x * c_m)) * (c_m * (s_m * x)))
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) return Float64(1.0 / Float64(Float64(s_m * Float64(x * c_m)) * Float64(c_m * Float64(s_m * x)))) end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
tmp = 1.0 / ((s_m * (x * c_m)) * (c_m * (s_m * x)));
end
c_m = N[Abs[c], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. code[x_, c$95$m_, s$95$m_] := N[(1.0 / N[(N[(s$95$m * N[(x * c$95$m), $MachinePrecision]), $MachinePrecision] * N[(c$95$m * N[(s$95$m * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\frac{1}{\left(s\_m \cdot \left(x \cdot c\_m\right)\right) \cdot \left(c\_m \cdot \left(s\_m \cdot x\right)\right)}
\end{array}
Initial program 66.1%
Taylor expanded in x around 0 56.4%
unpow256.4%
rem-square-sqrt56.4%
swap-sqr62.4%
unpow262.4%
unpow262.4%
unpow262.4%
unswap-sqr74.5%
rem-sqrt-square79.8%
Simplified79.8%
pow-prod-down68.0%
*-commutative68.0%
unpow268.0%
sqr-abs68.0%
unpow268.0%
swap-sqr79.8%
associate-*l*78.8%
associate-*l*79.0%
Applied egg-rr79.0%
Taylor expanded in s around 0 78.8%
Final simplification78.8%
c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x c_m s_m) :precision binary64 (let* ((t_0 (* s_m (* x c_m)))) (/ 1.0 (* t_0 t_0))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
double t_0 = s_m * (x * c_m);
return 1.0 / (t_0 * t_0);
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
t_0 = s_m * (x * c_m)
code = 1.0d0 / (t_0 * t_0)
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
double t_0 = s_m * (x * c_m);
return 1.0 / (t_0 * t_0);
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): t_0 = s_m * (x * c_m) return 1.0 / (t_0 * t_0)
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) t_0 = Float64(s_m * Float64(x * c_m)) return Float64(1.0 / Float64(t_0 * t_0)) end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
t_0 = s_m * (x * c_m);
tmp = 1.0 / (t_0 * t_0);
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(s$95$m * N[(x * c$95$m), $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := s\_m \cdot \left(x \cdot c\_m\right)\\
\frac{1}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 66.1%
Taylor expanded in x around 0 56.4%
unpow256.4%
rem-square-sqrt56.4%
swap-sqr62.4%
unpow262.4%
unpow262.4%
unpow262.4%
unswap-sqr74.5%
rem-sqrt-square79.8%
Simplified79.8%
pow-prod-down68.0%
*-commutative68.0%
unpow268.0%
sqr-abs68.0%
unpow268.0%
swap-sqr79.8%
associate-*l*78.8%
associate-*l*79.0%
Applied egg-rr79.0%
Final simplification79.0%
c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x c_m s_m) :precision binary64 (/ (/ (/ 1.0 (* c_m (* s_m x))) c_m) (* s_m x)))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
return ((1.0 / (c_m * (s_m * x))) / c_m) / (s_m * x);
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
code = ((1.0d0 / (c_m * (s_m * x))) / c_m) / (s_m * x)
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
return ((1.0 / (c_m * (s_m * x))) / c_m) / (s_m * x);
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): return ((1.0 / (c_m * (s_m * x))) / c_m) / (s_m * x)
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) return Float64(Float64(Float64(1.0 / Float64(c_m * Float64(s_m * x))) / c_m) / Float64(s_m * x)) end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
tmp = ((1.0 / (c_m * (s_m * x))) / c_m) / (s_m * x);
end
c_m = N[Abs[c], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. code[x_, c$95$m_, s$95$m_] := N[(N[(N[(1.0 / N[(c$95$m * N[(s$95$m * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c$95$m), $MachinePrecision] / N[(s$95$m * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\frac{\frac{\frac{1}{c\_m \cdot \left(s\_m \cdot x\right)}}{c\_m}}{s\_m \cdot x}
\end{array}
Initial program 66.1%
Taylor expanded in x around 0 56.4%
unpow256.4%
rem-square-sqrt56.4%
swap-sqr62.4%
unpow262.4%
unpow262.4%
unpow262.4%
unswap-sqr74.5%
rem-sqrt-square79.8%
Simplified79.8%
add-sqr-sqrt79.8%
pow279.8%
sqrt-div79.8%
metadata-eval79.8%
sqrt-pow180.1%
metadata-eval80.1%
pow180.1%
add-sqr-sqrt44.0%
fabs-sqr44.0%
add-sqr-sqrt80.1%
*-commutative80.1%
associate-*l*79.3%
Applied egg-rr79.3%
Taylor expanded in s around 0 80.1%
*-commutative80.1%
associate-*r*79.3%
/-rgt-identity79.3%
associate-/l*79.1%
associate-/l*79.1%
*-lft-identity79.1%
*-commutative79.1%
Simplified79.1%
associate-/l/79.3%
*-commutative79.3%
pow279.3%
div-inv79.3%
associate-*r*79.1%
*-commutative79.1%
associate-/r*76.9%
associate-*r*77.5%
*-commutative77.5%
*-commutative77.5%
*-commutative77.5%
Applied egg-rr77.5%
Final simplification77.5%
c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x c_m s_m) :precision binary64 (/ (/ (/ 1.0 (* c_m (* s_m x))) (* s_m x)) c_m))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
return ((1.0 / (c_m * (s_m * x))) / (s_m * x)) / c_m;
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
code = ((1.0d0 / (c_m * (s_m * x))) / (s_m * x)) / c_m
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
return ((1.0 / (c_m * (s_m * x))) / (s_m * x)) / c_m;
}
c_m = math.fabs(c) s_m = math.fabs(s) [x, c_m, s_m] = sort([x, c_m, s_m]) def code(x, c_m, s_m): return ((1.0 / (c_m * (s_m * x))) / (s_m * x)) / c_m
c_m = abs(c) s_m = abs(s) x, c_m, s_m = sort([x, c_m, s_m]) function code(x, c_m, s_m) return Float64(Float64(Float64(1.0 / Float64(c_m * Float64(s_m * x))) / Float64(s_m * x)) / c_m) end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
tmp = ((1.0 / (c_m * (s_m * x))) / (s_m * x)) / c_m;
end
c_m = N[Abs[c], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function. code[x_, c$95$m_, s$95$m_] := N[(N[(N[(1.0 / N[(c$95$m * N[(s$95$m * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(s$95$m * x), $MachinePrecision]), $MachinePrecision] / c$95$m), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\frac{\frac{\frac{1}{c\_m \cdot \left(s\_m \cdot x\right)}}{s\_m \cdot x}}{c\_m}
\end{array}
Initial program 66.1%
Taylor expanded in x around 0 56.4%
unpow256.4%
rem-square-sqrt56.4%
swap-sqr62.4%
unpow262.4%
unpow262.4%
unpow262.4%
unswap-sqr74.5%
rem-sqrt-square79.8%
Simplified79.8%
add-sqr-sqrt79.8%
pow279.8%
sqrt-div79.8%
metadata-eval79.8%
sqrt-pow180.1%
metadata-eval80.1%
pow180.1%
add-sqr-sqrt44.0%
fabs-sqr44.0%
add-sqr-sqrt80.1%
*-commutative80.1%
associate-*l*79.3%
Applied egg-rr79.3%
Taylor expanded in s around 0 80.1%
*-commutative80.1%
associate-*r*79.3%
/-rgt-identity79.3%
associate-/l*79.1%
associate-/l*79.1%
*-lft-identity79.1%
*-commutative79.1%
Simplified79.1%
associate-/l/79.3%
*-commutative79.3%
pow279.3%
div-inv79.3%
associate-*r*79.1%
associate-/r*77.9%
associate-*r*78.9%
*-commutative78.9%
*-commutative78.9%
*-commutative78.9%
Applied egg-rr78.9%
Final simplification78.9%
herbie shell --seed 2024027
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))