
(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 7 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 (let* ((t_0 (* (* x c_m) s_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 = (x * c_m) * s_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 = (x * c_m) * s_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 = (x * c_m) * s_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 = (x * c_m) * s_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(Float64(x * c_m) * s_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 = (x * c_m) * s_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[(N[(x * c$95$m), $MachinePrecision] * s$95$m), $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 := \left(x \cdot c\_m\right) \cdot s\_m\\
\frac{\frac{\cos \left(x \cdot 2\right)}{t\_0}}{t\_0}
\end{array}
\end{array}
Initial program 65.7%
*-un-lft-identity65.7%
add-sqr-sqrt65.7%
times-frac65.7%
sqrt-prod65.7%
sqrt-pow146.6%
metadata-eval46.6%
pow146.6%
*-commutative46.6%
associate-*r*41.9%
unpow241.9%
pow-prod-down46.6%
sqrt-pow146.7%
metadata-eval46.7%
pow146.7%
*-commutative46.7%
Applied egg-rr98.1%
associate-*r/98.2%
associate-/r*98.2%
*-commutative98.2%
Applied egg-rr98.2%
*-commutative98.2%
*-un-lft-identity98.2%
times-frac98.2%
associate-/l/98.1%
*-commutative98.1%
associate-/r*97.6%
metadata-eval97.6%
frac-times98.1%
*-commutative98.1%
associate-/l/98.2%
frac-times95.5%
*-un-lft-identity95.5%
times-frac95.5%
div-inv95.5%
*-un-lft-identity95.5%
Applied egg-rr98.2%
associate-*l/98.3%
*-un-lft-identity98.3%
associate-/l/98.2%
*-commutative98.2%
associate-*r*95.9%
*-commutative95.9%
associate-*r*97.2%
*-commutative97.2%
Applied egg-rr97.2%
Final simplification97.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 (/ (/ (cos (* x 2.0)) c_m) (* (* x s_m) (* c_m (* x s_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 (cos((x * 2.0)) / c_m) / ((x * s_m) * (c_m * (x * s_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 = (cos((x * 2.0d0)) / c_m) / ((x * s_m) * (c_m * (x * s_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 (Math.cos((x * 2.0)) / c_m) / ((x * s_m) * (c_m * (x * s_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 (math.cos((x * 2.0)) / c_m) / ((x * s_m) * (c_m * (x * s_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(cos(Float64(x * 2.0)) / c_m) / Float64(Float64(x * s_m) * Float64(c_m * Float64(x * s_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 = (cos((x * 2.0)) / c_m) / ((x * s_m) * (c_m * (x * s_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[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / c$95$m), $MachinePrecision] / N[(N[(x * s$95$m), $MachinePrecision] * N[(c$95$m * N[(x * s$95$m), $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{\frac{\cos \left(x \cdot 2\right)}{c\_m}}{\left(x \cdot s\_m\right) \cdot \left(c\_m \cdot \left(x \cdot s\_m\right)\right)}
\end{array}
Initial program 65.7%
*-un-lft-identity65.7%
add-sqr-sqrt65.7%
times-frac65.7%
sqrt-prod65.7%
sqrt-pow146.6%
metadata-eval46.6%
pow146.6%
*-commutative46.6%
associate-*r*41.9%
unpow241.9%
pow-prod-down46.6%
sqrt-pow146.7%
metadata-eval46.7%
pow146.7%
*-commutative46.7%
Applied egg-rr98.1%
associate-/r*98.2%
frac-times95.5%
*-un-lft-identity95.5%
*-commutative95.5%
Applied egg-rr95.5%
Final simplification95.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 (let* ((t_0 (* c_m (* x s_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 = c_m * (x * s_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 = c_m * (x * s_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 = c_m * (x * s_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 = c_m * (x * s_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(c_m * Float64(x * s_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 = c_m * (x * s_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[(c$95$m * N[(x * s$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 := c\_m \cdot \left(x \cdot s\_m\right)\\
\frac{\frac{\cos \left(x \cdot 2\right)}{t\_0}}{t\_0}
\end{array}
\end{array}
Initial program 65.7%
*-un-lft-identity65.7%
add-sqr-sqrt65.7%
times-frac65.7%
sqrt-prod65.7%
sqrt-pow146.6%
metadata-eval46.6%
pow146.6%
*-commutative46.6%
associate-*r*41.9%
unpow241.9%
pow-prod-down46.6%
sqrt-pow146.7%
metadata-eval46.7%
pow146.7%
*-commutative46.7%
Applied egg-rr98.1%
associate-*l/98.2%
*-un-lft-identity98.2%
*-commutative98.2%
Applied egg-rr98.2%
Final simplification98.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 (let* ((t_0 (/ 1.0 (* c_m (* x s_m))))) (* 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 = 1.0 / (c_m * (x * s_m));
return 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 = 1.0d0 / (c_m * (x * s_m))
code = 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 = 1.0 / (c_m * (x * s_m));
return 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 = 1.0 / (c_m * (x * s_m)) return 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(1.0 / Float64(c_m * Float64(x * s_m))) return 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 = 1.0 / (c_m * (x * s_m));
tmp = 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[(1.0 / N[(c$95$m * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * 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 := \frac{1}{c\_m \cdot \left(x \cdot s\_m\right)}\\
t\_0 \cdot t\_0
\end{array}
\end{array}
Initial program 65.7%
*-un-lft-identity65.7%
add-sqr-sqrt65.7%
times-frac65.7%
sqrt-prod65.7%
sqrt-pow146.6%
metadata-eval46.6%
pow146.6%
*-commutative46.6%
associate-*r*41.9%
unpow241.9%
pow-prod-down46.6%
sqrt-pow146.7%
metadata-eval46.7%
pow146.7%
*-commutative46.7%
Applied egg-rr98.1%
Taylor expanded in x around 0 78.4%
Final simplification78.4%
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 (* x s_m))) (/ (/ 1.0 c_m) (* x s_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 * (x * s_m))) * ((1.0 / c_m) / (x * s_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 * (x * s_m))) * ((1.0d0 / c_m) / (x * s_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 * (x * s_m))) * ((1.0 / c_m) / (x * s_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 * (x * s_m))) * ((1.0 / c_m) / (x * s_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(1.0 / Float64(c_m * Float64(x * s_m))) * Float64(Float64(1.0 / c_m) / Float64(x * s_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 * (x * s_m))) * ((1.0 / c_m) / (x * s_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[(1.0 / N[(c$95$m * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / c$95$m), $MachinePrecision] / N[(x * s$95$m), $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}{c\_m \cdot \left(x \cdot s\_m\right)} \cdot \frac{\frac{1}{c\_m}}{x \cdot s\_m}
\end{array}
Initial program 65.7%
*-un-lft-identity65.7%
add-sqr-sqrt65.7%
times-frac65.7%
sqrt-prod65.7%
sqrt-pow146.6%
metadata-eval46.6%
pow146.6%
*-commutative46.6%
associate-*r*41.9%
unpow241.9%
pow-prod-down46.6%
sqrt-pow146.7%
metadata-eval46.7%
pow146.7%
*-commutative46.7%
Applied egg-rr98.1%
Taylor expanded in x around 0 78.4%
associate-/r*78.4%
Simplified78.4%
Final simplification78.4%
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 (* x s_m)) (/ 1.0 c_m)) (* c_m (* x s_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 / (x * s_m)) * (1.0 / c_m)) / (c_m * (x * s_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 / (x * s_m)) * (1.0d0 / c_m)) / (c_m * (x * s_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 / (x * s_m)) * (1.0 / c_m)) / (c_m * (x * s_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 / (x * s_m)) * (1.0 / c_m)) / (c_m * (x * s_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(x * s_m)) * Float64(1.0 / c_m)) / Float64(c_m * Float64(x * s_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 / (x * s_m)) * (1.0 / c_m)) / (c_m * (x * s_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[(x * s$95$m), $MachinePrecision]), $MachinePrecision] * N[(1.0 / c$95$m), $MachinePrecision]), $MachinePrecision] / N[(c$95$m * N[(x * s$95$m), $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{\frac{1}{x \cdot s\_m} \cdot \frac{1}{c\_m}}{c\_m \cdot \left(x \cdot s\_m\right)}
\end{array}
Initial program 65.7%
Taylor expanded in x around 0 55.0%
associate-/r*55.0%
*-commutative55.0%
unpow255.0%
unpow255.0%
swap-sqr67.1%
unpow267.1%
associate-/r*67.1%
unpow267.1%
unpow267.1%
swap-sqr78.3%
unpow278.3%
*-commutative78.3%
Simplified78.3%
*-commutative78.3%
pow278.3%
Applied egg-rr78.3%
associate-/r*78.4%
*-commutative78.4%
associate-/l/78.5%
div-inv78.4%
inv-pow78.4%
metadata-eval78.4%
sqrt-pow154.6%
*-commutative54.6%
metadata-eval54.6%
pow-flip54.1%
times-frac50.0%
pow-flip50.5%
*-commutative50.5%
metadata-eval50.5%
sqrt-pow168.0%
metadata-eval68.0%
inv-pow68.0%
Applied egg-rr68.0%
associate-/r*67.7%
*-commutative67.7%
frac-2neg67.7%
associate-/r*68.0%
frac-times78.4%
Applied egg-rr78.4%
Final simplification78.4%
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 (* c_m (* x s_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 = c_m * (x * s_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 = c_m * (x * s_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 = c_m * (x * s_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 = c_m * (x * s_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(c_m * Float64(x * s_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 = c_m * (x * s_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[(c$95$m * N[(x * s$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 := c\_m \cdot \left(x \cdot s\_m\right)\\
\frac{1}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 65.7%
Taylor expanded in x around 0 55.0%
associate-/r*55.0%
*-commutative55.0%
unpow255.0%
unpow255.0%
swap-sqr67.1%
unpow267.1%
associate-/r*67.1%
unpow267.1%
unpow267.1%
swap-sqr78.3%
unpow278.3%
*-commutative78.3%
Simplified78.3%
*-commutative78.3%
pow278.3%
Applied egg-rr78.3%
Final simplification78.3%
herbie shell --seed 2024076
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))