
(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 8 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) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (let* ((t_0 (* c_m (* x s)))) (/ (/ (cos (* x 2.0)) t_0) t_0)))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double t_0 = c_m * (x * s);
return (cos((x * 2.0)) / t_0) / t_0;
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
real(8) :: t_0
t_0 = c_m * (x * s)
code = (cos((x * 2.0d0)) / t_0) / t_0
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double t_0 = c_m * (x * s);
return (Math.cos((x * 2.0)) / t_0) / t_0;
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): t_0 = c_m * (x * s) return (math.cos((x * 2.0)) / t_0) / t_0
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) t_0 = Float64(c_m * Float64(x * s)) return Float64(Float64(cos(Float64(x * 2.0)) / t_0) / t_0) end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
t_0 = c_m * (x * s);
tmp = (cos((x * 2.0)) / t_0) / t_0;
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(c$95$m * N[(x * s), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := c_m \cdot \left(x \cdot s\right)\\
\frac{\frac{\cos \left(x \cdot 2\right)}{t_0}}{t_0}
\end{array}
\end{array}
Initial program 71.8%
*-un-lft-identity71.8%
add-sqr-sqrt71.8%
times-frac71.8%
Applied egg-rr97.9%
associate-*l/98.0%
*-un-lft-identity98.0%
div-inv98.0%
div-inv98.0%
*-commutative98.0%
Applied egg-rr98.0%
Final simplification98.0%
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
:precision binary64
(let* ((t_0 (* c_m (* x s))))
(if (<= (pow s 2.0) 5e-48)
(/ (/ (+ (* -2.0 (/ x c_m)) (/ 1.0 (* x c_m))) s) t_0)
(pow t_0 -2.0))))c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double t_0 = c_m * (x * s);
double tmp;
if (pow(s, 2.0) <= 5e-48) {
tmp = (((-2.0 * (x / c_m)) + (1.0 / (x * c_m))) / s) / t_0;
} else {
tmp = pow(t_0, -2.0);
}
return tmp;
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: tmp
t_0 = c_m * (x * s)
if ((s ** 2.0d0) <= 5d-48) then
tmp = ((((-2.0d0) * (x / c_m)) + (1.0d0 / (x * c_m))) / s) / t_0
else
tmp = t_0 ** (-2.0d0)
end if
code = tmp
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double t_0 = c_m * (x * s);
double tmp;
if (Math.pow(s, 2.0) <= 5e-48) {
tmp = (((-2.0 * (x / c_m)) + (1.0 / (x * c_m))) / s) / t_0;
} else {
tmp = Math.pow(t_0, -2.0);
}
return tmp;
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): t_0 = c_m * (x * s) tmp = 0 if math.pow(s, 2.0) <= 5e-48: tmp = (((-2.0 * (x / c_m)) + (1.0 / (x * c_m))) / s) / t_0 else: tmp = math.pow(t_0, -2.0) return tmp
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) t_0 = Float64(c_m * Float64(x * s)) tmp = 0.0 if ((s ^ 2.0) <= 5e-48) tmp = Float64(Float64(Float64(Float64(-2.0 * Float64(x / c_m)) + Float64(1.0 / Float64(x * c_m))) / s) / t_0); else tmp = t_0 ^ -2.0; end return tmp end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp_2 = code(x, c_m, s)
t_0 = c_m * (x * s);
tmp = 0.0;
if ((s ^ 2.0) <= 5e-48)
tmp = (((-2.0 * (x / c_m)) + (1.0 / (x * c_m))) / s) / t_0;
else
tmp = t_0 ^ -2.0;
end
tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(c$95$m * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[s, 2.0], $MachinePrecision], 5e-48], N[(N[(N[(N[(-2.0 * N[(x / c$95$m), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / s), $MachinePrecision] / t$95$0), $MachinePrecision], N[Power[t$95$0, -2.0], $MachinePrecision]]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := c_m \cdot \left(x \cdot s\right)\\
\mathbf{if}\;{s}^{2} \leq 5 \cdot 10^{-48}:\\
\;\;\;\;\frac{\frac{-2 \cdot \frac{x}{c_m} + \frac{1}{x \cdot c_m}}{s}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;{t_0}^{-2}\\
\end{array}
\end{array}
if (pow.f64 s 2) < 4.9999999999999999e-48Initial program 73.7%
*-un-lft-identity73.7%
add-sqr-sqrt73.6%
times-frac73.6%
Applied egg-rr98.2%
associate-*l/98.2%
*-un-lft-identity98.2%
div-inv98.2%
div-inv98.2%
*-commutative98.2%
Applied egg-rr98.2%
Taylor expanded in x around 0 48.3%
Taylor expanded in s around 0 64.3%
if 4.9999999999999999e-48 < (pow.f64 s 2) Initial program 69.9%
Taylor expanded in x around 0 62.2%
associate-/r*62.1%
*-commutative62.1%
unpow262.1%
unpow262.1%
swap-sqr76.9%
unpow276.9%
associate-/r*77.0%
unpow277.0%
unpow277.0%
swap-sqr86.1%
unpow286.1%
*-commutative86.1%
Simplified86.1%
pow-flip86.4%
*-commutative86.4%
metadata-eval86.4%
Applied egg-rr86.4%
Final simplification75.1%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (/ (/ (cos (* x 2.0)) c_m) (* (* x s) (* c_m (* x s)))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
return (cos((x * 2.0)) / c_m) / ((x * s) * (c_m * (x * s)));
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
code = (cos((x * 2.0d0)) / c_m) / ((x * s) * (c_m * (x * s)))
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
return (Math.cos((x * 2.0)) / c_m) / ((x * s) * (c_m * (x * s)));
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): return (math.cos((x * 2.0)) / c_m) / ((x * s) * (c_m * (x * s)))
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) return Float64(Float64(cos(Float64(x * 2.0)) / c_m) / Float64(Float64(x * s) * Float64(c_m * Float64(x * s)))) end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
tmp = (cos((x * 2.0)) / c_m) / ((x * s) * (c_m * (x * s)));
end
c_m = N[Abs[c], $MachinePrecision] NOTE: x, c_m, and s should be sorted in increasing order before calling this function. code[x_, c$95$m_, s_] := N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / c$95$m), $MachinePrecision] / N[(N[(x * s), $MachinePrecision] * N[(c$95$m * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\frac{\frac{\cos \left(x \cdot 2\right)}{c_m}}{\left(x \cdot s\right) \cdot \left(c_m \cdot \left(x \cdot s\right)\right)}
\end{array}
Initial program 71.8%
*-un-lft-identity71.8%
add-sqr-sqrt71.8%
times-frac71.8%
Applied egg-rr97.9%
*-commutative97.9%
associate-/r*98.0%
frac-times95.3%
div-inv95.3%
*-commutative95.3%
Applied egg-rr95.3%
Final simplification95.3%
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
:precision binary64
(let* ((t_0 (* c_m (* x s))))
(if (<= s 1.8e-24)
(/ (/ (+ (* -2.0 (/ x c_m)) (/ 1.0 (* x c_m))) s) t_0)
(* (/ 1.0 t_0) (/ (/ 1.0 c_m) (* x s))))))c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double t_0 = c_m * (x * s);
double tmp;
if (s <= 1.8e-24) {
tmp = (((-2.0 * (x / c_m)) + (1.0 / (x * c_m))) / s) / t_0;
} else {
tmp = (1.0 / t_0) * ((1.0 / c_m) / (x * s));
}
return tmp;
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: tmp
t_0 = c_m * (x * s)
if (s <= 1.8d-24) then
tmp = ((((-2.0d0) * (x / c_m)) + (1.0d0 / (x * c_m))) / s) / t_0
else
tmp = (1.0d0 / t_0) * ((1.0d0 / c_m) / (x * s))
end if
code = tmp
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double t_0 = c_m * (x * s);
double tmp;
if (s <= 1.8e-24) {
tmp = (((-2.0 * (x / c_m)) + (1.0 / (x * c_m))) / s) / t_0;
} else {
tmp = (1.0 / t_0) * ((1.0 / c_m) / (x * s));
}
return tmp;
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): t_0 = c_m * (x * s) tmp = 0 if s <= 1.8e-24: tmp = (((-2.0 * (x / c_m)) + (1.0 / (x * c_m))) / s) / t_0 else: tmp = (1.0 / t_0) * ((1.0 / c_m) / (x * s)) return tmp
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) t_0 = Float64(c_m * Float64(x * s)) tmp = 0.0 if (s <= 1.8e-24) tmp = Float64(Float64(Float64(Float64(-2.0 * Float64(x / c_m)) + Float64(1.0 / Float64(x * c_m))) / s) / t_0); else tmp = Float64(Float64(1.0 / t_0) * Float64(Float64(1.0 / c_m) / Float64(x * s))); end return tmp end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp_2 = code(x, c_m, s)
t_0 = c_m * (x * s);
tmp = 0.0;
if (s <= 1.8e-24)
tmp = (((-2.0 * (x / c_m)) + (1.0 / (x * c_m))) / s) / t_0;
else
tmp = (1.0 / t_0) * ((1.0 / c_m) / (x * s));
end
tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(c$95$m * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[s, 1.8e-24], N[(N[(N[(N[(-2.0 * N[(x / c$95$m), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / s), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(N[(1.0 / c$95$m), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := c_m \cdot \left(x \cdot s\right)\\
\mathbf{if}\;s \leq 1.8 \cdot 10^{-24}:\\
\;\;\;\;\frac{\frac{-2 \cdot \frac{x}{c_m} + \frac{1}{x \cdot c_m}}{s}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t_0} \cdot \frac{\frac{1}{c_m}}{x \cdot s}\\
\end{array}
\end{array}
if s < 1.8e-24Initial program 70.6%
*-un-lft-identity70.6%
add-sqr-sqrt70.6%
times-frac70.6%
Applied egg-rr97.5%
associate-*l/97.5%
*-un-lft-identity97.5%
div-inv97.6%
div-inv97.5%
*-commutative97.5%
Applied egg-rr97.5%
Taylor expanded in x around 0 56.8%
Taylor expanded in s around 0 65.4%
if 1.8e-24 < s Initial program 75.9%
*-un-lft-identity75.9%
add-sqr-sqrt75.9%
times-frac76.0%
Applied egg-rr99.4%
Taylor expanded in x around 0 94.4%
associate-/r*94.4%
Simplified94.4%
Final simplification72.0%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (let* ((t_0 (/ 1.0 (* c_m (* x s))))) (* t_0 t_0)))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double t_0 = 1.0 / (c_m * (x * s));
return t_0 * t_0;
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
real(8) :: t_0
t_0 = 1.0d0 / (c_m * (x * s))
code = t_0 * t_0
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double t_0 = 1.0 / (c_m * (x * s));
return t_0 * t_0;
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): t_0 = 1.0 / (c_m * (x * s)) return t_0 * t_0
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) t_0 = Float64(1.0 / Float64(c_m * Float64(x * s))) return Float64(t_0 * t_0) end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
t_0 = 1.0 / (c_m * (x * s));
tmp = t_0 * t_0;
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(1.0 / N[(c$95$m * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * t$95$0), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := \frac{1}{c_m \cdot \left(x \cdot s\right)}\\
t_0 \cdot t_0
\end{array}
\end{array}
Initial program 71.8%
*-un-lft-identity71.8%
add-sqr-sqrt71.8%
times-frac71.8%
Applied egg-rr97.9%
Taylor expanded in x around 0 74.3%
Final simplification74.3%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (* (/ 1.0 (* c_m (* x s))) (/ (/ 1.0 c_m) (* x s))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
return (1.0 / (c_m * (x * s))) * ((1.0 / c_m) / (x * s));
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
code = (1.0d0 / (c_m * (x * s))) * ((1.0d0 / c_m) / (x * s))
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
return (1.0 / (c_m * (x * s))) * ((1.0 / c_m) / (x * s));
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): return (1.0 / (c_m * (x * s))) * ((1.0 / c_m) / (x * s))
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) return Float64(Float64(1.0 / Float64(c_m * Float64(x * s))) * Float64(Float64(1.0 / c_m) / Float64(x * s))) end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
tmp = (1.0 / (c_m * (x * s))) * ((1.0 / c_m) / (x * s));
end
c_m = N[Abs[c], $MachinePrecision] NOTE: x, c_m, and s should be sorted in increasing order before calling this function. code[x_, c$95$m_, s_] := N[(N[(1.0 / N[(c$95$m * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / c$95$m), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\frac{1}{c_m \cdot \left(x \cdot s\right)} \cdot \frac{\frac{1}{c_m}}{x \cdot s}
\end{array}
Initial program 71.8%
*-un-lft-identity71.8%
add-sqr-sqrt71.8%
times-frac71.8%
Applied egg-rr97.9%
Taylor expanded in x around 0 74.3%
associate-/r*74.3%
Simplified74.3%
Final simplification74.3%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (/ 1.0 (* (* c_m s) (* x (* c_m (* x s))))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
return 1.0 / ((c_m * s) * (x * (c_m * (x * s))));
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
code = 1.0d0 / ((c_m * s) * (x * (c_m * (x * s))))
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
return 1.0 / ((c_m * s) * (x * (c_m * (x * s))));
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): return 1.0 / ((c_m * s) * (x * (c_m * (x * s))))
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) return Float64(1.0 / Float64(Float64(c_m * s) * Float64(x * Float64(c_m * Float64(x * s))))) end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
tmp = 1.0 / ((c_m * s) * (x * (c_m * (x * s))));
end
c_m = N[Abs[c], $MachinePrecision] NOTE: x, c_m, and s should be sorted in increasing order before calling this function. code[x_, c$95$m_, s_] := N[(1.0 / N[(N[(c$95$m * s), $MachinePrecision] * N[(x * N[(c$95$m * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\frac{1}{\left(c_m \cdot s\right) \cdot \left(x \cdot \left(c_m \cdot \left(x \cdot s\right)\right)\right)}
\end{array}
Initial program 71.8%
Taylor expanded in x around 0 55.4%
associate-/r*55.4%
*-commutative55.4%
unpow255.4%
unpow255.4%
swap-sqr65.3%
unpow265.3%
associate-/r*65.3%
unpow265.3%
unpow265.3%
swap-sqr74.1%
unpow274.1%
*-commutative74.1%
Simplified74.1%
unpow274.1%
associate-*r*72.8%
*-commutative72.8%
associate-*l*71.5%
Applied egg-rr71.5%
Final simplification71.5%
c_m = (fabs.f64 c) NOTE: x, c_m, and s should be sorted in increasing order before calling this function. (FPCore (x c_m s) :precision binary64 (let* ((t_0 (* c_m (* x s)))) (/ 1.0 (* t_0 t_0))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
double t_0 = c_m * (x * s);
return 1.0 / (t_0 * t_0);
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
real(8), intent (in) :: x
real(8), intent (in) :: c_m
real(8), intent (in) :: s
real(8) :: t_0
t_0 = c_m * (x * s)
code = 1.0d0 / (t_0 * t_0)
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
double t_0 = c_m * (x * s);
return 1.0 / (t_0 * t_0);
}
c_m = math.fabs(c) [x, c_m, s] = sort([x, c_m, s]) def code(x, c_m, s): t_0 = c_m * (x * s) return 1.0 / (t_0 * t_0)
c_m = abs(c) x, c_m, s = sort([x, c_m, s]) function code(x, c_m, s) t_0 = Float64(c_m * Float64(x * s)) return Float64(1.0 / Float64(t_0 * t_0)) end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
t_0 = c_m * (x * s);
tmp = 1.0 / (t_0 * t_0);
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(c$95$m * N[(x * s), $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := c_m \cdot \left(x \cdot s\right)\\
\frac{1}{t_0 \cdot t_0}
\end{array}
\end{array}
Initial program 71.8%
Taylor expanded in x around 0 55.4%
associate-/r*55.4%
*-commutative55.4%
unpow255.4%
unpow255.4%
swap-sqr65.3%
unpow265.3%
associate-/r*65.3%
unpow265.3%
unpow265.3%
swap-sqr74.1%
unpow274.1%
*-commutative74.1%
Simplified74.1%
*-commutative74.1%
pow274.1%
Applied egg-rr74.1%
Final simplification74.1%
herbie shell --seed 2024017
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))