
(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}
x_m = (fabs.f64 x)
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x_m c_m s_m)
:precision binary64
(let* ((t_0 (* s_m (* x_m c_m))))
(if (<= x_m 3.4e-9)
(pow (* c_m (* x_m s_m)) -2.0)
(/ (/ (cos (* x_m 2.0)) t_0) t_0))))x_m = fabs(x);
c_m = fabs(c);
s_m = fabs(s);
assert(x_m < c_m && c_m < s_m);
double code(double x_m, double c_m, double s_m) {
double t_0 = s_m * (x_m * c_m);
double tmp;
if (x_m <= 3.4e-9) {
tmp = pow((c_m * (x_m * s_m)), -2.0);
} else {
tmp = (cos((x_m * 2.0)) / t_0) / t_0;
}
return tmp;
}
x_m = abs(x)
c_m = abs(c)
s_m = abs(s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c_m, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
real(8) :: tmp
t_0 = s_m * (x_m * c_m)
if (x_m <= 3.4d-9) then
tmp = (c_m * (x_m * s_m)) ** (-2.0d0)
else
tmp = (cos((x_m * 2.0d0)) / t_0) / t_0
end if
code = tmp
end function
x_m = Math.abs(x);
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x_m < c_m && c_m < s_m;
public static double code(double x_m, double c_m, double s_m) {
double t_0 = s_m * (x_m * c_m);
double tmp;
if (x_m <= 3.4e-9) {
tmp = Math.pow((c_m * (x_m * s_m)), -2.0);
} else {
tmp = (Math.cos((x_m * 2.0)) / t_0) / t_0;
}
return tmp;
}
x_m = math.fabs(x) c_m = math.fabs(c) s_m = math.fabs(s) [x_m, c_m, s_m] = sort([x_m, c_m, s_m]) def code(x_m, c_m, s_m): t_0 = s_m * (x_m * c_m) tmp = 0 if x_m <= 3.4e-9: tmp = math.pow((c_m * (x_m * s_m)), -2.0) else: tmp = (math.cos((x_m * 2.0)) / t_0) / t_0 return tmp
x_m = abs(x) c_m = abs(c) s_m = abs(s) x_m, c_m, s_m = sort([x_m, c_m, s_m]) function code(x_m, c_m, s_m) t_0 = Float64(s_m * Float64(x_m * c_m)) tmp = 0.0 if (x_m <= 3.4e-9) tmp = Float64(c_m * Float64(x_m * s_m)) ^ -2.0; else tmp = Float64(Float64(cos(Float64(x_m * 2.0)) / t_0) / t_0); end return tmp end
x_m = abs(x);
c_m = abs(c);
s_m = abs(s);
x_m, c_m, s_m = num2cell(sort([x_m, c_m, s_m])){:}
function tmp_2 = code(x_m, c_m, s_m)
t_0 = s_m * (x_m * c_m);
tmp = 0.0;
if (x_m <= 3.4e-9)
tmp = (c_m * (x_m * s_m)) ^ -2.0;
else
tmp = (cos((x_m * 2.0)) / t_0) / t_0;
end
tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
code[x$95$m_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(s$95$m * N[(x$95$m * c$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$95$m, 3.4e-9], N[Power[N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[(N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|
\\
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x_m, c_m, s_m] = \mathsf{sort}([x_m, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := s\_m \cdot \left(x\_m \cdot c\_m\right)\\
\mathbf{if}\;x\_m \leq 3.4 \cdot 10^{-9}:\\
\;\;\;\;{\left(c\_m \cdot \left(x\_m \cdot s\_m\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(x\_m \cdot 2\right)}{t\_0}}{t\_0}\\
\end{array}
\end{array}
if x < 3.3999999999999998e-9Initial program 63.8%
associate-/r*63.5%
cos-neg63.5%
distribute-rgt-neg-out63.5%
distribute-rgt-neg-out63.5%
*-commutative63.5%
distribute-rgt-neg-in63.5%
metadata-eval63.5%
*-commutative63.5%
associate-*l*58.4%
unpow258.4%
Simplified58.4%
Taylor expanded in x around 0 52.4%
associate-/r*52.6%
*-commutative52.6%
unpow252.6%
unpow252.6%
swap-sqr65.2%
unpow265.2%
associate-/r*65.1%
unpow265.1%
unpow265.1%
swap-sqr80.0%
unpow280.0%
Simplified80.0%
Taylor expanded in c around 0 52.4%
associate-*r*51.7%
unpow251.7%
unpow251.7%
unswap-sqr67.1%
unpow267.1%
swap-sqr80.3%
*-commutative80.3%
associate-*r*78.9%
*-commutative78.9%
associate-*r*80.4%
associate-/l/80.7%
*-lft-identity80.7%
associate-*l/80.6%
unpow-180.6%
unpow-180.6%
pow-sqr80.7%
associate-*r*80.5%
*-commutative80.5%
associate-*r*80.2%
metadata-eval80.2%
Simplified80.2%
if 3.3999999999999998e-9 < x Initial program 68.5%
associate-/r*68.5%
cos-neg68.5%
distribute-rgt-neg-out68.5%
distribute-rgt-neg-out68.5%
*-commutative68.5%
distribute-rgt-neg-in68.5%
metadata-eval68.5%
*-commutative68.5%
associate-*l*57.9%
unpow257.9%
Simplified57.9%
associate-/l/58.0%
associate-/r*58.0%
associate-/l/58.0%
unpow258.0%
*-un-lft-identity58.0%
times-frac65.5%
Applied egg-rr83.7%
*-commutative83.7%
div-inv83.7%
associate-*r*74.9%
inv-pow74.9%
inv-pow74.9%
pow-sqr74.9%
metadata-eval74.9%
associate-*l*75.0%
unpow-prod-down96.9%
*-commutative96.9%
metadata-eval96.9%
pow-flip96.8%
div-inv96.8%
unpow296.8%
associate-/r*96.7%
associate-*r*97.0%
Applied egg-rr99.5%
Final simplification85.3%
x_m = (fabs.f64 x)
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x_m c_m s_m)
:precision binary64
(let* ((t_0 (* c_m (* x_m s_m))))
(if (<= x_m 1e-32)
(pow t_0 -2.0)
(/ (/ (cos (* x_m 2.0)) (* s_m (* x_m c_m))) t_0))))x_m = fabs(x);
c_m = fabs(c);
s_m = fabs(s);
assert(x_m < c_m && c_m < s_m);
double code(double x_m, double c_m, double s_m) {
double t_0 = c_m * (x_m * s_m);
double tmp;
if (x_m <= 1e-32) {
tmp = pow(t_0, -2.0);
} else {
tmp = (cos((x_m * 2.0)) / (s_m * (x_m * c_m))) / t_0;
}
return tmp;
}
x_m = abs(x)
c_m = abs(c)
s_m = abs(s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c_m, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
real(8) :: tmp
t_0 = c_m * (x_m * s_m)
if (x_m <= 1d-32) then
tmp = t_0 ** (-2.0d0)
else
tmp = (cos((x_m * 2.0d0)) / (s_m * (x_m * c_m))) / t_0
end if
code = tmp
end function
x_m = Math.abs(x);
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x_m < c_m && c_m < s_m;
public static double code(double x_m, double c_m, double s_m) {
double t_0 = c_m * (x_m * s_m);
double tmp;
if (x_m <= 1e-32) {
tmp = Math.pow(t_0, -2.0);
} else {
tmp = (Math.cos((x_m * 2.0)) / (s_m * (x_m * c_m))) / t_0;
}
return tmp;
}
x_m = math.fabs(x) c_m = math.fabs(c) s_m = math.fabs(s) [x_m, c_m, s_m] = sort([x_m, c_m, s_m]) def code(x_m, c_m, s_m): t_0 = c_m * (x_m * s_m) tmp = 0 if x_m <= 1e-32: tmp = math.pow(t_0, -2.0) else: tmp = (math.cos((x_m * 2.0)) / (s_m * (x_m * c_m))) / t_0 return tmp
x_m = abs(x) c_m = abs(c) s_m = abs(s) x_m, c_m, s_m = sort([x_m, c_m, s_m]) function code(x_m, c_m, s_m) t_0 = Float64(c_m * Float64(x_m * s_m)) tmp = 0.0 if (x_m <= 1e-32) tmp = t_0 ^ -2.0; else tmp = Float64(Float64(cos(Float64(x_m * 2.0)) / Float64(s_m * Float64(x_m * c_m))) / t_0); end return tmp end
x_m = abs(x);
c_m = abs(c);
s_m = abs(s);
x_m, c_m, s_m = num2cell(sort([x_m, c_m, s_m])){:}
function tmp_2 = code(x_m, c_m, s_m)
t_0 = c_m * (x_m * s_m);
tmp = 0.0;
if (x_m <= 1e-32)
tmp = t_0 ^ -2.0;
else
tmp = (cos((x_m * 2.0)) / (s_m * (x_m * c_m))) / t_0;
end
tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
code[x$95$m_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$95$m, 1e-32], N[Power[t$95$0, -2.0], $MachinePrecision], N[(N[(N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision] / N[(s$95$m * N[(x$95$m * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|
\\
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x_m, c_m, s_m] = \mathsf{sort}([x_m, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := c\_m \cdot \left(x\_m \cdot s\_m\right)\\
\mathbf{if}\;x\_m \leq 10^{-32}:\\
\;\;\;\;{t\_0}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(x\_m \cdot 2\right)}{s\_m \cdot \left(x\_m \cdot c\_m\right)}}{t\_0}\\
\end{array}
\end{array}
if x < 1.00000000000000006e-32Initial program 63.6%
associate-/r*63.3%
cos-neg63.3%
distribute-rgt-neg-out63.3%
distribute-rgt-neg-out63.3%
*-commutative63.3%
distribute-rgt-neg-in63.3%
metadata-eval63.3%
*-commutative63.3%
associate-*l*58.2%
unpow258.2%
Simplified58.2%
Taylor expanded in x around 0 52.2%
associate-/r*52.4%
*-commutative52.4%
unpow252.4%
unpow252.4%
swap-sqr65.0%
unpow265.0%
associate-/r*64.9%
unpow264.9%
unpow264.9%
swap-sqr79.9%
unpow279.9%
Simplified79.9%
Taylor expanded in c around 0 52.2%
associate-*r*51.4%
unpow251.4%
unpow251.4%
unswap-sqr67.0%
unpow267.0%
swap-sqr80.2%
*-commutative80.2%
associate-*r*78.8%
*-commutative78.8%
associate-*r*80.3%
associate-/l/80.6%
*-lft-identity80.6%
associate-*l/80.5%
unpow-180.5%
unpow-180.5%
pow-sqr80.6%
associate-*r*80.4%
*-commutative80.4%
associate-*r*80.1%
metadata-eval80.1%
Simplified80.1%
if 1.00000000000000006e-32 < x Initial program 68.9%
associate-/r*68.9%
cos-neg68.9%
distribute-rgt-neg-out68.9%
distribute-rgt-neg-out68.9%
*-commutative68.9%
distribute-rgt-neg-in68.9%
metadata-eval68.9%
*-commutative68.9%
associate-*l*58.5%
unpow258.5%
Simplified58.5%
associate-/l/58.6%
associate-/r*58.6%
associate-/l/58.6%
unpow258.6%
*-un-lft-identity58.6%
times-frac66.0%
Applied egg-rr83.9%
*-commutative83.9%
div-inv83.9%
associate-*r*75.3%
inv-pow75.3%
inv-pow75.3%
pow-sqr75.3%
metadata-eval75.3%
associate-*l*75.3%
unpow-prod-down96.9%
*-commutative96.9%
metadata-eval96.9%
pow-flip96.8%
div-inv96.8%
unpow296.8%
associate-/r*96.8%
associate-*r*97.0%
Applied egg-rr99.5%
Taylor expanded in s around 0 96.9%
Final simplification84.6%
x_m = (fabs.f64 x) c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x_m c_m s_m) :precision binary64 (if (<= s_m 5.5e+134) (/ (/ (cos (* x_m 2.0)) c_m) (* (* s_m (* x_m c_m)) (* x_m s_m))) (pow (* c_m (* x_m s_m)) -2.0)))
x_m = fabs(x);
c_m = fabs(c);
s_m = fabs(s);
assert(x_m < c_m && c_m < s_m);
double code(double x_m, double c_m, double s_m) {
double tmp;
if (s_m <= 5.5e+134) {
tmp = (cos((x_m * 2.0)) / c_m) / ((s_m * (x_m * c_m)) * (x_m * s_m));
} else {
tmp = pow((c_m * (x_m * s_m)), -2.0);
}
return tmp;
}
x_m = abs(x)
c_m = abs(c)
s_m = abs(s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c_m, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: tmp
if (s_m <= 5.5d+134) then
tmp = (cos((x_m * 2.0d0)) / c_m) / ((s_m * (x_m * c_m)) * (x_m * s_m))
else
tmp = (c_m * (x_m * s_m)) ** (-2.0d0)
end if
code = tmp
end function
x_m = Math.abs(x);
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x_m < c_m && c_m < s_m;
public static double code(double x_m, double c_m, double s_m) {
double tmp;
if (s_m <= 5.5e+134) {
tmp = (Math.cos((x_m * 2.0)) / c_m) / ((s_m * (x_m * c_m)) * (x_m * s_m));
} else {
tmp = Math.pow((c_m * (x_m * s_m)), -2.0);
}
return tmp;
}
x_m = math.fabs(x) c_m = math.fabs(c) s_m = math.fabs(s) [x_m, c_m, s_m] = sort([x_m, c_m, s_m]) def code(x_m, c_m, s_m): tmp = 0 if s_m <= 5.5e+134: tmp = (math.cos((x_m * 2.0)) / c_m) / ((s_m * (x_m * c_m)) * (x_m * s_m)) else: tmp = math.pow((c_m * (x_m * s_m)), -2.0) return tmp
x_m = abs(x) c_m = abs(c) s_m = abs(s) x_m, c_m, s_m = sort([x_m, c_m, s_m]) function code(x_m, c_m, s_m) tmp = 0.0 if (s_m <= 5.5e+134) tmp = Float64(Float64(cos(Float64(x_m * 2.0)) / c_m) / Float64(Float64(s_m * Float64(x_m * c_m)) * Float64(x_m * s_m))); else tmp = Float64(c_m * Float64(x_m * s_m)) ^ -2.0; end return tmp end
x_m = abs(x);
c_m = abs(c);
s_m = abs(s);
x_m, c_m, s_m = num2cell(sort([x_m, c_m, s_m])){:}
function tmp_2 = code(x_m, c_m, s_m)
tmp = 0.0;
if (s_m <= 5.5e+134)
tmp = (cos((x_m * 2.0)) / c_m) / ((s_m * (x_m * c_m)) * (x_m * s_m));
else
tmp = (c_m * (x_m * s_m)) ^ -2.0;
end
tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision] c_m = N[Abs[c], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function. code[x$95$m_, c$95$m_, s$95$m_] := If[LessEqual[s$95$m, 5.5e+134], N[(N[(N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision] / c$95$m), $MachinePrecision] / N[(N[(s$95$m * N[(x$95$m * c$95$m), $MachinePrecision]), $MachinePrecision] * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x_m, c_m, s_m] = \mathsf{sort}([x_m, c_m, s_m])\\
\\
\begin{array}{l}
\mathbf{if}\;s\_m \leq 5.5 \cdot 10^{+134}:\\
\;\;\;\;\frac{\frac{\cos \left(x\_m \cdot 2\right)}{c\_m}}{\left(s\_m \cdot \left(x\_m \cdot c\_m\right)\right) \cdot \left(x\_m \cdot s\_m\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left(c\_m \cdot \left(x\_m \cdot s\_m\right)\right)}^{-2}\\
\end{array}
\end{array}
if s < 5.4999999999999999e134Initial program 67.5%
associate-/r*67.2%
cos-neg67.2%
distribute-rgt-neg-out67.2%
distribute-rgt-neg-out67.2%
*-commutative67.2%
distribute-rgt-neg-in67.2%
metadata-eval67.2%
*-commutative67.2%
associate-*l*60.4%
unpow260.4%
Simplified60.4%
associate-/l/60.2%
associate-/r*60.3%
associate-/l/60.3%
unpow260.3%
*-un-lft-identity60.3%
times-frac67.1%
Applied egg-rr86.6%
*-commutative86.6%
div-inv86.5%
associate-*r*78.2%
inv-pow78.2%
inv-pow78.2%
pow-sqr78.3%
metadata-eval78.3%
associate-*l*78.3%
unpow-prod-down97.5%
*-commutative97.5%
metadata-eval97.5%
pow-flip97.1%
div-inv97.1%
unpow297.1%
associate-/r*97.4%
associate-/r*97.4%
associate-/l/93.2%
Applied egg-rr91.0%
if 5.4999999999999999e134 < s Initial program 45.9%
associate-/r*45.9%
cos-neg45.9%
distribute-rgt-neg-out45.9%
distribute-rgt-neg-out45.9%
*-commutative45.9%
distribute-rgt-neg-in45.9%
metadata-eval45.9%
*-commutative45.9%
associate-*l*41.9%
unpow241.9%
Simplified41.9%
Taylor expanded in x around 0 41.9%
associate-/r*41.9%
*-commutative41.9%
unpow241.9%
unpow241.9%
swap-sqr62.6%
unpow262.6%
associate-/r*62.7%
unpow262.7%
unpow262.7%
swap-sqr78.0%
unpow278.0%
Simplified78.0%
Taylor expanded in c around 0 41.9%
associate-*r*39.1%
unpow239.1%
unpow239.1%
unswap-sqr61.7%
unpow261.7%
swap-sqr72.7%
*-commutative72.7%
associate-*r*72.7%
*-commutative72.7%
associate-*r*79.0%
associate-/l/79.1%
*-lft-identity79.1%
associate-*l/79.0%
unpow-179.0%
unpow-179.0%
pow-sqr79.1%
associate-*r*72.8%
*-commutative72.8%
associate-*r*78.1%
metadata-eval78.1%
Simplified78.1%
Final simplification89.6%
x_m = (fabs.f64 x) c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x_m c_m s_m) :precision binary64 (pow (* c_m (* x_m s_m)) -2.0))
x_m = fabs(x);
c_m = fabs(c);
s_m = fabs(s);
assert(x_m < c_m && c_m < s_m);
double code(double x_m, double c_m, double s_m) {
return pow((c_m * (x_m * s_m)), -2.0);
}
x_m = abs(x)
c_m = abs(c)
s_m = abs(s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c_m, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
code = (c_m * (x_m * s_m)) ** (-2.0d0)
end function
x_m = Math.abs(x);
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x_m < c_m && c_m < s_m;
public static double code(double x_m, double c_m, double s_m) {
return Math.pow((c_m * (x_m * s_m)), -2.0);
}
x_m = math.fabs(x) c_m = math.fabs(c) s_m = math.fabs(s) [x_m, c_m, s_m] = sort([x_m, c_m, s_m]) def code(x_m, c_m, s_m): return math.pow((c_m * (x_m * s_m)), -2.0)
x_m = abs(x) c_m = abs(c) s_m = abs(s) x_m, c_m, s_m = sort([x_m, c_m, s_m]) function code(x_m, c_m, s_m) return Float64(c_m * Float64(x_m * s_m)) ^ -2.0 end
x_m = abs(x);
c_m = abs(c);
s_m = abs(s);
x_m, c_m, s_m = num2cell(sort([x_m, c_m, s_m])){:}
function tmp = code(x_m, c_m, s_m)
tmp = (c_m * (x_m * s_m)) ^ -2.0;
end
x_m = N[Abs[x], $MachinePrecision] c_m = N[Abs[c], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function. code[x$95$m_, c$95$m_, s$95$m_] := N[Power[N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x_m, c_m, s_m] = \mathsf{sort}([x_m, c_m, s_m])\\
\\
{\left(c\_m \cdot \left(x\_m \cdot s\_m\right)\right)}^{-2}
\end{array}
Initial program 65.0%
associate-/r*64.8%
cos-neg64.8%
distribute-rgt-neg-out64.8%
distribute-rgt-neg-out64.8%
*-commutative64.8%
distribute-rgt-neg-in64.8%
metadata-eval64.8%
*-commutative64.8%
associate-*l*58.3%
unpow258.3%
Simplified58.3%
Taylor expanded in x around 0 50.7%
associate-/r*50.8%
*-commutative50.8%
unpow250.8%
unpow250.8%
swap-sqr60.7%
unpow260.7%
associate-/r*60.6%
unpow260.6%
unpow260.6%
swap-sqr73.4%
unpow273.4%
Simplified73.4%
Taylor expanded in c around 0 50.7%
associate-*r*50.1%
unpow250.1%
unpow250.1%
unswap-sqr62.8%
unpow262.8%
swap-sqr73.6%
*-commutative73.6%
associate-*r*72.5%
*-commutative72.5%
associate-*r*73.7%
associate-/l/73.9%
*-lft-identity73.9%
associate-*l/73.8%
unpow-173.8%
unpow-173.8%
pow-sqr73.9%
associate-*r*73.7%
*-commutative73.7%
associate-*r*73.6%
metadata-eval73.6%
Simplified73.6%
Final simplification73.6%
x_m = (fabs.f64 x) c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x_m c_m s_m) :precision binary64 (let* ((t_0 (* c_m (* x_m s_m)))) (/ (/ 1.0 t_0) t_0)))
x_m = fabs(x);
c_m = fabs(c);
s_m = fabs(s);
assert(x_m < c_m && c_m < s_m);
double code(double x_m, double c_m, double s_m) {
double t_0 = c_m * (x_m * s_m);
return (1.0 / t_0) / t_0;
}
x_m = abs(x)
c_m = abs(c)
s_m = abs(s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c_m, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
t_0 = c_m * (x_m * s_m)
code = (1.0d0 / t_0) / t_0
end function
x_m = Math.abs(x);
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x_m < c_m && c_m < s_m;
public static double code(double x_m, double c_m, double s_m) {
double t_0 = c_m * (x_m * s_m);
return (1.0 / t_0) / t_0;
}
x_m = math.fabs(x) c_m = math.fabs(c) s_m = math.fabs(s) [x_m, c_m, s_m] = sort([x_m, c_m, s_m]) def code(x_m, c_m, s_m): t_0 = c_m * (x_m * s_m) return (1.0 / t_0) / t_0
x_m = abs(x) c_m = abs(c) s_m = abs(s) x_m, c_m, s_m = sort([x_m, c_m, s_m]) function code(x_m, c_m, s_m) t_0 = Float64(c_m * Float64(x_m * s_m)) return Float64(Float64(1.0 / t_0) / t_0) end
x_m = abs(x);
c_m = abs(c);
s_m = abs(s);
x_m, c_m, s_m = num2cell(sort([x_m, c_m, s_m])){:}
function tmp = code(x_m, c_m, s_m)
t_0 = c_m * (x_m * s_m);
tmp = (1.0 / t_0) / t_0;
end
x_m = N[Abs[x], $MachinePrecision]
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
code[x$95$m_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]}, N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x_m, c_m, s_m] = \mathsf{sort}([x_m, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := c\_m \cdot \left(x\_m \cdot s\_m\right)\\
\frac{\frac{1}{t\_0}}{t\_0}
\end{array}
\end{array}
Initial program 65.0%
associate-/r*64.8%
cos-neg64.8%
distribute-rgt-neg-out64.8%
distribute-rgt-neg-out64.8%
*-commutative64.8%
distribute-rgt-neg-in64.8%
metadata-eval64.8%
*-commutative64.8%
associate-*l*58.3%
unpow258.3%
Simplified58.3%
Taylor expanded in x around 0 50.7%
associate-/r*50.8%
*-commutative50.8%
unpow250.8%
unpow250.8%
swap-sqr60.7%
unpow260.7%
associate-/r*60.6%
unpow260.6%
unpow260.6%
swap-sqr73.4%
unpow273.4%
Simplified73.4%
clear-num73.4%
add-sqr-sqrt73.4%
sqrt-div73.4%
metadata-eval73.4%
/-rgt-identity73.4%
sqrt-pow154.7%
metadata-eval54.7%
pow154.7%
associate-*r*54.2%
*-commutative54.2%
sqrt-div54.2%
metadata-eval54.2%
/-rgt-identity54.2%
sqrt-pow172.5%
metadata-eval72.5%
pow172.5%
associate-*r*73.8%
*-commutative73.8%
Applied egg-rr73.8%
un-div-inv73.9%
*-commutative73.9%
associate-*r*72.5%
*-commutative72.5%
associate-*r*73.5%
Applied egg-rr73.5%
x_m = (fabs.f64 x) c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x_m c_m s_m) :precision binary64 (let* ((t_0 (* s_m (* x_m c_m)))) (/ 1.0 (* t_0 t_0))))
x_m = fabs(x);
c_m = fabs(c);
s_m = fabs(s);
assert(x_m < c_m && c_m < s_m);
double code(double x_m, double c_m, double s_m) {
double t_0 = s_m * (x_m * c_m);
return 1.0 / (t_0 * t_0);
}
x_m = abs(x)
c_m = abs(c)
s_m = abs(s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c_m, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
real(8) :: t_0
t_0 = s_m * (x_m * c_m)
code = 1.0d0 / (t_0 * t_0)
end function
x_m = Math.abs(x);
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x_m < c_m && c_m < s_m;
public static double code(double x_m, double c_m, double s_m) {
double t_0 = s_m * (x_m * c_m);
return 1.0 / (t_0 * t_0);
}
x_m = math.fabs(x) c_m = math.fabs(c) s_m = math.fabs(s) [x_m, c_m, s_m] = sort([x_m, c_m, s_m]) def code(x_m, c_m, s_m): t_0 = s_m * (x_m * c_m) return 1.0 / (t_0 * t_0)
x_m = abs(x) c_m = abs(c) s_m = abs(s) x_m, c_m, s_m = sort([x_m, c_m, s_m]) function code(x_m, c_m, s_m) t_0 = Float64(s_m * Float64(x_m * c_m)) return Float64(1.0 / Float64(t_0 * t_0)) end
x_m = abs(x);
c_m = abs(c);
s_m = abs(s);
x_m, c_m, s_m = num2cell(sort([x_m, c_m, s_m])){:}
function tmp = code(x_m, c_m, s_m)
t_0 = s_m * (x_m * c_m);
tmp = 1.0 / (t_0 * t_0);
end
x_m = N[Abs[x], $MachinePrecision]
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
code[x$95$m_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(s$95$m * N[(x$95$m * c$95$m), $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x_m, c_m, s_m] = \mathsf{sort}([x_m, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := s\_m \cdot \left(x\_m \cdot c\_m\right)\\
\frac{1}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 65.0%
associate-/r*64.8%
cos-neg64.8%
distribute-rgt-neg-out64.8%
distribute-rgt-neg-out64.8%
*-commutative64.8%
distribute-rgt-neg-in64.8%
metadata-eval64.8%
*-commutative64.8%
associate-*l*58.3%
unpow258.3%
Simplified58.3%
Taylor expanded in x around 0 50.7%
associate-/r*50.8%
*-commutative50.8%
unpow250.8%
unpow250.8%
swap-sqr60.7%
unpow260.7%
associate-/r*60.6%
unpow260.6%
unpow260.6%
swap-sqr73.4%
unpow273.4%
Simplified73.4%
unpow273.4%
associate-*r*72.3%
*-commutative72.3%
associate-*r*73.7%
*-commutative73.7%
Applied egg-rr73.7%
Final simplification73.7%
x_m = (fabs.f64 x) c_m = (fabs.f64 c) s_m = (fabs.f64 s) NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function. (FPCore (x_m c_m s_m) :precision binary64 (/ 1.0 (* (* x_m c_m) (* s_m (* s_m (* x_m c_m))))))
x_m = fabs(x);
c_m = fabs(c);
s_m = fabs(s);
assert(x_m < c_m && c_m < s_m);
double code(double x_m, double c_m, double s_m) {
return 1.0 / ((x_m * c_m) * (s_m * (s_m * (x_m * c_m))));
}
x_m = abs(x)
c_m = abs(c)
s_m = abs(s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x_m, c_m, s_m)
real(8), intent (in) :: x_m
real(8), intent (in) :: c_m
real(8), intent (in) :: s_m
code = 1.0d0 / ((x_m * c_m) * (s_m * (s_m * (x_m * c_m))))
end function
x_m = Math.abs(x);
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x_m < c_m && c_m < s_m;
public static double code(double x_m, double c_m, double s_m) {
return 1.0 / ((x_m * c_m) * (s_m * (s_m * (x_m * c_m))));
}
x_m = math.fabs(x) c_m = math.fabs(c) s_m = math.fabs(s) [x_m, c_m, s_m] = sort([x_m, c_m, s_m]) def code(x_m, c_m, s_m): return 1.0 / ((x_m * c_m) * (s_m * (s_m * (x_m * c_m))))
x_m = abs(x) c_m = abs(c) s_m = abs(s) x_m, c_m, s_m = sort([x_m, c_m, s_m]) function code(x_m, c_m, s_m) return Float64(1.0 / Float64(Float64(x_m * c_m) * Float64(s_m * Float64(s_m * Float64(x_m * c_m))))) end
x_m = abs(x);
c_m = abs(c);
s_m = abs(s);
x_m, c_m, s_m = num2cell(sort([x_m, c_m, s_m])){:}
function tmp = code(x_m, c_m, s_m)
tmp = 1.0 / ((x_m * c_m) * (s_m * (s_m * (x_m * c_m))));
end
x_m = N[Abs[x], $MachinePrecision] c_m = N[Abs[c], $MachinePrecision] s_m = N[Abs[s], $MachinePrecision] NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function. code[x$95$m_, c$95$m_, s$95$m_] := N[(1.0 / N[(N[(x$95$m * c$95$m), $MachinePrecision] * N[(s$95$m * N[(s$95$m * N[(x$95$m * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x_m, c_m, s_m] = \mathsf{sort}([x_m, c_m, s_m])\\
\\
\frac{1}{\left(x\_m \cdot c\_m\right) \cdot \left(s\_m \cdot \left(s\_m \cdot \left(x\_m \cdot c\_m\right)\right)\right)}
\end{array}
Initial program 65.0%
associate-/r*64.8%
cos-neg64.8%
distribute-rgt-neg-out64.8%
distribute-rgt-neg-out64.8%
*-commutative64.8%
distribute-rgt-neg-in64.8%
metadata-eval64.8%
*-commutative64.8%
associate-*l*58.3%
unpow258.3%
Simplified58.3%
Taylor expanded in x around 0 50.7%
associate-/r*50.8%
*-commutative50.8%
unpow250.8%
unpow250.8%
swap-sqr60.7%
unpow260.7%
associate-/r*60.6%
unpow260.6%
unpow260.6%
swap-sqr73.4%
unpow273.4%
Simplified73.4%
unpow273.4%
associate-*r*72.3%
associate-*l*71.9%
associate-*r*72.9%
*-commutative72.9%
Applied egg-rr72.9%
Final simplification72.9%
herbie shell --seed 2024136
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))