
(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}
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 (/ 1.0 (* s_m (* x_m c_m)))) (t_1 (cos (* x_m 2.0))))
(if (<= x_m 9e+36)
(/ (/ (/ t_1 (* x_m s_m)) c_m) (* (* x_m s_m) c_m))
(* t_1 (* 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 = 1.0 / (s_m * (x_m * c_m));
double t_1 = cos((x_m * 2.0));
double tmp;
if (x_m <= 9e+36) {
tmp = ((t_1 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m);
} else {
tmp = t_1 * (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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 / (s_m * (x_m * c_m))
t_1 = cos((x_m * 2.0d0))
if (x_m <= 9d+36) then
tmp = ((t_1 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m)
else
tmp = t_1 * (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 = 1.0 / (s_m * (x_m * c_m));
double t_1 = Math.cos((x_m * 2.0));
double tmp;
if (x_m <= 9e+36) {
tmp = ((t_1 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m);
} else {
tmp = t_1 * (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 = 1.0 / (s_m * (x_m * c_m)) t_1 = math.cos((x_m * 2.0)) tmp = 0 if x_m <= 9e+36: tmp = ((t_1 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m) else: tmp = t_1 * (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(1.0 / Float64(s_m * Float64(x_m * c_m))) t_1 = cos(Float64(x_m * 2.0)) tmp = 0.0 if (x_m <= 9e+36) tmp = Float64(Float64(Float64(t_1 / Float64(x_m * s_m)) / c_m) / Float64(Float64(x_m * s_m) * c_m)); else tmp = Float64(t_1 * Float64(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 = 1.0 / (s_m * (x_m * c_m));
t_1 = cos((x_m * 2.0));
tmp = 0.0;
if (x_m <= 9e+36)
tmp = ((t_1 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m);
else
tmp = t_1 * (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[(1.0 / N[(s$95$m * N[(x$95$m * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x$95$m, 9e+36], N[(N[(N[(t$95$1 / N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision] / c$95$m), $MachinePrecision] / N[(N[(x$95$m * s$95$m), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * 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 := \frac{1}{s\_m \cdot \left(x\_m \cdot c\_m\right)}\\
t_1 := \cos \left(x\_m \cdot 2\right)\\
\mathbf{if}\;x\_m \leq 9 \cdot 10^{+36}:\\
\;\;\;\;\frac{\frac{\frac{t\_1}{x\_m \cdot s\_m}}{c\_m}}{\left(x\_m \cdot s\_m\right) \cdot c\_m}\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(t\_0 \cdot t\_0\right)\\
\end{array}
\end{array}
if x < 8.99999999999999994e36Initial program 67.8%
*-un-lft-identity67.8%
add-sqr-sqrt67.8%
times-frac67.8%
sqrt-prod67.8%
sqrt-pow144.6%
metadata-eval44.6%
pow144.6%
*-commutative44.6%
associate-*r*40.4%
unpow240.4%
pow-prod-down44.6%
sqrt-pow144.5%
metadata-eval44.5%
pow144.5%
*-commutative44.5%
Applied egg-rr97.4%
associate-*l/97.5%
*-un-lft-identity97.5%
*-commutative97.5%
Applied egg-rr97.5%
*-un-lft-identity97.5%
times-frac97.0%
Applied egg-rr97.0%
associate-*l/97.0%
*-lft-identity97.0%
*-commutative97.0%
Simplified97.0%
if 8.99999999999999994e36 < x Initial program 61.9%
*-un-lft-identity61.9%
add-sqr-sqrt62.0%
times-frac61.9%
sqrt-prod61.9%
sqrt-pow149.8%
metadata-eval49.8%
pow149.8%
*-commutative49.8%
associate-*r*47.9%
unpow247.9%
pow-prod-down49.8%
sqrt-pow149.1%
metadata-eval49.1%
pow149.1%
*-commutative49.1%
Applied egg-rr96.3%
*-commutative96.3%
clear-num96.3%
associate-/r*96.4%
frac-times93.1%
*-un-lft-identity93.1%
*-commutative93.1%
Applied egg-rr93.1%
*-commutative93.1%
associate-*r/93.1%
associate-/r/93.2%
associate-/r*93.2%
associate-*l*96.4%
pow296.4%
pow-flip96.4%
associate-*r*96.5%
*-commutative96.5%
associate-*l*96.2%
metadata-eval96.2%
Applied egg-rr96.2%
metadata-eval96.2%
pow-prod-up96.2%
unpow-196.2%
*-commutative96.2%
associate-*r*93.1%
*-commutative93.1%
associate-*l*93.2%
unpow-193.2%
*-commutative93.2%
associate-*r*93.3%
*-commutative93.3%
associate-*l*96.6%
Applied egg-rr96.6%
Final simplification96.9%
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))) (t_1 (cos (* x_m 2.0))))
(if (<= x_m 3.3e+35)
(/ (/ (/ t_1 (* x_m s_m)) c_m) (* (* x_m s_m) c_m))
(* t_1 (/ (/ 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);
double t_1 = cos((x_m * 2.0));
double tmp;
if (x_m <= 3.3e+35) {
tmp = ((t_1 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m);
} else {
tmp = t_1 * ((1.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) :: t_1
real(8) :: tmp
t_0 = s_m * (x_m * c_m)
t_1 = cos((x_m * 2.0d0))
if (x_m <= 3.3d+35) then
tmp = ((t_1 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m)
else
tmp = t_1 * ((1.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 t_1 = Math.cos((x_m * 2.0));
double tmp;
if (x_m <= 3.3e+35) {
tmp = ((t_1 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m);
} else {
tmp = t_1 * ((1.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) t_1 = math.cos((x_m * 2.0)) tmp = 0 if x_m <= 3.3e+35: tmp = ((t_1 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m) else: tmp = t_1 * ((1.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)) t_1 = cos(Float64(x_m * 2.0)) tmp = 0.0 if (x_m <= 3.3e+35) tmp = Float64(Float64(Float64(t_1 / Float64(x_m * s_m)) / c_m) / Float64(Float64(x_m * s_m) * c_m)); else tmp = Float64(t_1 * Float64(Float64(1.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);
t_1 = cos((x_m * 2.0));
tmp = 0.0;
if (x_m <= 3.3e+35)
tmp = ((t_1 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m);
else
tmp = t_1 * ((1.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]}, Block[{t$95$1 = N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x$95$m, 3.3e+35], N[(N[(N[(t$95$1 / N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision] / c$95$m), $MachinePrecision] / N[(N[(x$95$m * s$95$m), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(N[(1.0 / t$95$0), $MachinePrecision] / 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)\\
t_1 := \cos \left(x\_m \cdot 2\right)\\
\mathbf{if}\;x\_m \leq 3.3 \cdot 10^{+35}:\\
\;\;\;\;\frac{\frac{\frac{t\_1}{x\_m \cdot s\_m}}{c\_m}}{\left(x\_m \cdot s\_m\right) \cdot c\_m}\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \frac{\frac{1}{t\_0}}{t\_0}\\
\end{array}
\end{array}
if x < 3.3000000000000002e35Initial program 67.7%
*-un-lft-identity67.7%
add-sqr-sqrt67.7%
times-frac67.6%
sqrt-prod67.6%
sqrt-pow144.4%
metadata-eval44.4%
pow144.4%
*-commutative44.4%
associate-*r*40.1%
unpow240.1%
pow-prod-down44.4%
sqrt-pow144.7%
metadata-eval44.7%
pow144.7%
*-commutative44.7%
Applied egg-rr97.4%
associate-*l/97.5%
*-un-lft-identity97.5%
*-commutative97.5%
Applied egg-rr97.5%
*-un-lft-identity97.5%
times-frac97.0%
Applied egg-rr97.0%
associate-*l/97.0%
*-lft-identity97.0%
*-commutative97.0%
Simplified97.0%
if 3.3000000000000002e35 < x Initial program 62.6%
*-un-lft-identity62.6%
add-sqr-sqrt62.6%
times-frac62.5%
sqrt-prod62.5%
sqrt-pow150.6%
metadata-eval50.6%
pow150.6%
*-commutative50.6%
associate-*r*48.7%
unpow248.7%
pow-prod-down50.6%
sqrt-pow148.3%
metadata-eval48.3%
pow148.3%
*-commutative48.3%
Applied egg-rr96.4%
*-commutative96.4%
clear-num96.4%
associate-/r*96.4%
frac-times93.2%
*-un-lft-identity93.2%
*-commutative93.2%
Applied egg-rr93.2%
*-commutative93.2%
associate-*r/93.2%
associate-/r/93.3%
associate-/r*93.3%
associate-*l*96.5%
pow296.5%
pow-flip96.5%
associate-*r*96.5%
*-commutative96.5%
associate-*l*96.2%
metadata-eval96.2%
Applied egg-rr96.2%
sqr-pow96.3%
pow296.3%
metadata-eval96.3%
unpow-196.3%
*-commutative96.3%
associate-*r*96.5%
*-commutative96.5%
metadata-eval96.5%
*-commutative96.5%
frac-times96.3%
associate-/l/96.3%
div-inv96.4%
pow296.4%
clear-num96.4%
un-div-inv96.3%
div-inv96.2%
clear-num96.4%
div-inv96.3%
clear-num96.4%
/-rgt-identity96.4%
Applied egg-rr96.5%
Final simplification96.9%
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))) (t_1 (cos (* x_m 2.0))))
(if (<= x_m 1e+29)
(/ (/ (/ t_1 (* x_m s_m)) c_m) (* (* x_m s_m) c_m))
(/ (/ t_1 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 t_1 = cos((x_m * 2.0));
double tmp;
if (x_m <= 1e+29) {
tmp = ((t_1 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m);
} else {
tmp = (t_1 / 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) :: t_1
real(8) :: tmp
t_0 = s_m * (x_m * c_m)
t_1 = cos((x_m * 2.0d0))
if (x_m <= 1d+29) then
tmp = ((t_1 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m)
else
tmp = (t_1 / 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 t_1 = Math.cos((x_m * 2.0));
double tmp;
if (x_m <= 1e+29) {
tmp = ((t_1 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m);
} else {
tmp = (t_1 / 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) t_1 = math.cos((x_m * 2.0)) tmp = 0 if x_m <= 1e+29: tmp = ((t_1 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m) else: tmp = (t_1 / 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)) t_1 = cos(Float64(x_m * 2.0)) tmp = 0.0 if (x_m <= 1e+29) tmp = Float64(Float64(Float64(t_1 / Float64(x_m * s_m)) / c_m) / Float64(Float64(x_m * s_m) * c_m)); else tmp = Float64(Float64(t_1 / 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);
t_1 = cos((x_m * 2.0));
tmp = 0.0;
if (x_m <= 1e+29)
tmp = ((t_1 / (x_m * s_m)) / c_m) / ((x_m * s_m) * c_m);
else
tmp = (t_1 / 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]}, Block[{t$95$1 = N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x$95$m, 1e+29], N[(N[(N[(t$95$1 / N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision] / c$95$m), $MachinePrecision] / N[(N[(x$95$m * s$95$m), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 / 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)\\
t_1 := \cos \left(x\_m \cdot 2\right)\\
\mathbf{if}\;x\_m \leq 10^{+29}:\\
\;\;\;\;\frac{\frac{\frac{t\_1}{x\_m \cdot s\_m}}{c\_m}}{\left(x\_m \cdot s\_m\right) \cdot c\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_1}{t\_0}}{t\_0}\\
\end{array}
\end{array}
if x < 9.99999999999999914e28Initial program 68.0%
*-un-lft-identity68.0%
add-sqr-sqrt68.0%
times-frac68.0%
sqrt-prod68.0%
sqrt-pow144.6%
metadata-eval44.6%
pow144.6%
*-commutative44.6%
associate-*r*40.3%
unpow240.3%
pow-prod-down44.6%
sqrt-pow144.9%
metadata-eval44.9%
pow144.9%
*-commutative44.9%
Applied egg-rr97.4%
associate-*l/97.5%
*-un-lft-identity97.5%
*-commutative97.5%
Applied egg-rr97.5%
*-un-lft-identity97.5%
times-frac97.0%
Applied egg-rr97.0%
associate-*l/97.0%
*-lft-identity97.0%
*-commutative97.0%
Simplified97.0%
if 9.99999999999999914e28 < x Initial program 61.5%
*-un-lft-identity61.5%
add-sqr-sqrt61.5%
times-frac61.5%
sqrt-prod61.5%
sqrt-pow149.7%
metadata-eval49.7%
pow149.7%
*-commutative49.7%
associate-*r*47.9%
unpow247.9%
pow-prod-down49.8%
sqrt-pow147.5%
metadata-eval47.5%
pow147.5%
*-commutative47.5%
Applied egg-rr96.5%
*-commutative96.5%
clear-num96.4%
associate-/r*96.4%
frac-times91.7%
*-un-lft-identity91.7%
*-commutative91.7%
Applied egg-rr91.7%
*-commutative91.7%
associate-*r/91.8%
associate-/r/91.8%
associate-/r*91.8%
associate-*l*96.5%
pow296.5%
pow-flip96.5%
associate-*r*96.6%
*-commutative96.6%
associate-*l*96.3%
metadata-eval96.3%
Applied egg-rr96.3%
*-commutative96.3%
sqr-pow96.3%
associate-*r*96.2%
metadata-eval96.2%
unpow-196.2%
*-commutative96.2%
associate-*r*93.3%
*-commutative93.3%
div-inv93.3%
metadata-eval93.3%
unpow-193.3%
*-commutative93.3%
associate-*r*96.5%
*-commutative96.5%
div-inv96.5%
Applied egg-rr96.6%
Final simplification96.9%
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 2.4e-9)
(* (/ 1.0 (* (* x_m s_m) c_m)) (/ (/ 1.0 c_m) (* x_m s_m)))
(/ (/ (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 <= 2.4e-9) {
tmp = (1.0 / ((x_m * s_m) * c_m)) * ((1.0 / c_m) / (x_m * s_m));
} 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 <= 2.4d-9) then
tmp = (1.0d0 / ((x_m * s_m) * c_m)) * ((1.0d0 / c_m) / (x_m * s_m))
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 <= 2.4e-9) {
tmp = (1.0 / ((x_m * s_m) * c_m)) * ((1.0 / c_m) / (x_m * s_m));
} 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 <= 2.4e-9: tmp = (1.0 / ((x_m * s_m) * c_m)) * ((1.0 / c_m) / (x_m * s_m)) 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 <= 2.4e-9) tmp = Float64(Float64(1.0 / Float64(Float64(x_m * s_m) * c_m)) * Float64(Float64(1.0 / c_m) / Float64(x_m * s_m))); 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 <= 2.4e-9)
tmp = (1.0 / ((x_m * s_m) * c_m)) * ((1.0 / c_m) / (x_m * s_m));
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, 2.4e-9], N[(N[(1.0 / N[(N[(x$95$m * s$95$m), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / c$95$m), $MachinePrecision] / N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $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 2.4 \cdot 10^{-9}:\\
\;\;\;\;\frac{1}{\left(x\_m \cdot s\_m\right) \cdot c\_m} \cdot \frac{\frac{1}{c\_m}}{x\_m \cdot s\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(x\_m \cdot 2\right)}{t\_0}}{t\_0}\\
\end{array}
\end{array}
if x < 2.4e-9Initial program 68.4%
*-un-lft-identity68.4%
add-sqr-sqrt68.4%
times-frac68.3%
sqrt-prod68.3%
sqrt-pow145.6%
metadata-eval45.6%
pow145.6%
*-commutative45.6%
associate-*r*41.2%
unpow241.2%
pow-prod-down45.6%
sqrt-pow145.5%
metadata-eval45.5%
pow145.5%
*-commutative45.5%
Applied egg-rr97.3%
Taylor expanded in x around 0 86.1%
associate-/r*86.1%
Simplified86.1%
if 2.4e-9 < x Initial program 61.2%
*-un-lft-identity61.2%
add-sqr-sqrt61.2%
times-frac61.2%
sqrt-prod61.2%
sqrt-pow146.2%
metadata-eval46.2%
pow146.2%
*-commutative46.2%
associate-*r*44.6%
unpow244.6%
pow-prod-down46.2%
sqrt-pow145.7%
metadata-eval45.7%
pow145.7%
*-commutative45.7%
Applied egg-rr96.8%
*-commutative96.8%
clear-num96.7%
associate-/r*96.7%
frac-times92.5%
*-un-lft-identity92.5%
*-commutative92.5%
Applied egg-rr92.5%
*-commutative92.5%
associate-*r/92.6%
associate-/r/92.7%
associate-/r*92.6%
associate-*l*96.8%
pow296.8%
pow-flip96.8%
associate-*r*96.9%
*-commutative96.9%
associate-*l*96.6%
metadata-eval96.6%
Applied egg-rr96.6%
*-commutative96.6%
sqr-pow96.6%
associate-*r*96.5%
metadata-eval96.5%
unpow-196.5%
*-commutative96.5%
associate-*r*93.9%
*-commutative93.9%
div-inv94.0%
metadata-eval94.0%
unpow-194.0%
*-commutative94.0%
associate-*r*96.8%
*-commutative96.8%
div-inv96.9%
Applied egg-rr96.9%
Final simplification88.9%
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 (* (* x_m s_m) c_m))) (/ (/ (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 = (x_m * s_m) * c_m;
return (cos((x_m * 2.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 = (x_m * s_m) * c_m
code = (cos((x_m * 2.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 = (x_m * s_m) * c_m;
return (Math.cos((x_m * 2.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 = (x_m * s_m) * c_m return (math.cos((x_m * 2.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(Float64(x_m * s_m) * c_m) return Float64(Float64(cos(Float64(x_m * 2.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 = (x_m * s_m) * c_m;
tmp = (cos((x_m * 2.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[(N[(x$95$m * s$95$m), $MachinePrecision] * c$95$m), $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 := \left(x\_m \cdot s\_m\right) \cdot c\_m\\
\frac{\frac{\cos \left(x\_m \cdot 2\right)}{t\_0}}{t\_0}
\end{array}
\end{array}
Initial program 66.5%
*-un-lft-identity66.5%
add-sqr-sqrt66.5%
times-frac66.5%
sqrt-prod66.5%
sqrt-pow145.8%
metadata-eval45.8%
pow145.8%
*-commutative45.8%
associate-*r*42.1%
unpow242.1%
pow-prod-down45.8%
sqrt-pow145.5%
metadata-eval45.5%
pow145.5%
*-commutative45.5%
Applied egg-rr97.2%
associate-*l/97.2%
*-un-lft-identity97.2%
*-commutative97.2%
Applied egg-rr97.2%
Final simplification97.2%
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 (/ (/ (cos (* x_m 2.0)) c_m) (* (* x_m s_m) (* (* x_m s_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 (cos((x_m * 2.0)) / c_m) / ((x_m * s_m) * ((x_m * s_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 = (cos((x_m * 2.0d0)) / c_m) / ((x_m * s_m) * ((x_m * s_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 (Math.cos((x_m * 2.0)) / c_m) / ((x_m * s_m) * ((x_m * s_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 (math.cos((x_m * 2.0)) / c_m) / ((x_m * s_m) * ((x_m * s_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(Float64(cos(Float64(x_m * 2.0)) / c_m) / Float64(Float64(x_m * s_m) * Float64(Float64(x_m * s_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 = (cos((x_m * 2.0)) / c_m) / ((x_m * s_m) * ((x_m * s_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[(N[(N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision] / c$95$m), $MachinePrecision] / N[(N[(x$95$m * s$95$m), $MachinePrecision] * N[(N[(x$95$m * s$95$m), $MachinePrecision] * c$95$m), $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{\frac{\cos \left(x\_m \cdot 2\right)}{c\_m}}{\left(x\_m \cdot s\_m\right) \cdot \left(\left(x\_m \cdot s\_m\right) \cdot c\_m\right)}
\end{array}
Initial program 66.5%
*-un-lft-identity66.5%
add-sqr-sqrt66.5%
times-frac66.5%
sqrt-prod66.5%
sqrt-pow145.8%
metadata-eval45.8%
pow145.8%
*-commutative45.8%
associate-*r*42.1%
unpow242.1%
pow-prod-down45.8%
sqrt-pow145.5%
metadata-eval45.5%
pow145.5%
*-commutative45.5%
Applied egg-rr97.2%
associate-/r*97.2%
frac-times94.6%
metadata-eval94.6%
times-frac94.6%
*-un-lft-identity94.6%
*-un-lft-identity94.6%
*-commutative94.6%
Applied egg-rr94.6%
Final simplification94.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 (* (/ 1.0 (* (* x_m s_m) c_m)) (/ (/ 1.0 c_m) (* x_m s_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 * s_m) * c_m)) * ((1.0 / c_m) / (x_m * s_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 * s_m) * c_m)) * ((1.0d0 / c_m) / (x_m * s_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 * s_m) * c_m)) * ((1.0 / c_m) / (x_m * s_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 * s_m) * c_m)) * ((1.0 / c_m) / (x_m * s_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(Float64(1.0 / Float64(Float64(x_m * s_m) * c_m)) * Float64(Float64(1.0 / c_m) / Float64(x_m * s_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 * s_m) * c_m)) * ((1.0 / c_m) / (x_m * s_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[(N[(1.0 / N[(N[(x$95$m * s$95$m), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / c$95$m), $MachinePrecision] / N[(x$95$m * s$95$m), $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 s\_m\right) \cdot c\_m} \cdot \frac{\frac{1}{c\_m}}{x\_m \cdot s\_m}
\end{array}
Initial program 66.5%
*-un-lft-identity66.5%
add-sqr-sqrt66.5%
times-frac66.5%
sqrt-prod66.5%
sqrt-pow145.8%
metadata-eval45.8%
pow145.8%
*-commutative45.8%
associate-*r*42.1%
unpow242.1%
pow-prod-down45.8%
sqrt-pow145.5%
metadata-eval45.5%
pow145.5%
*-commutative45.5%
Applied egg-rr97.2%
Taylor expanded in x around 0 76.0%
associate-/r*76.1%
Simplified76.1%
Final simplification76.1%
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 (/ 1.0 (* (* x_m s_m) c_m)))) (* 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 = 1.0 / ((x_m * s_m) * c_m);
return 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 = 1.0d0 / ((x_m * s_m) * c_m)
code = 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 = 1.0 / ((x_m * s_m) * c_m);
return 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 = 1.0 / ((x_m * s_m) * c_m) return 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(1.0 / Float64(Float64(x_m * s_m) * c_m)) return 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 = 1.0 / ((x_m * s_m) * c_m);
tmp = 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[(1.0 / N[(N[(x$95$m * s$95$m), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * 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 := \frac{1}{\left(x\_m \cdot s\_m\right) \cdot c\_m}\\
t\_0 \cdot t\_0
\end{array}
\end{array}
Initial program 66.5%
*-un-lft-identity66.5%
add-sqr-sqrt66.5%
times-frac66.5%
sqrt-prod66.5%
sqrt-pow145.8%
metadata-eval45.8%
pow145.8%
*-commutative45.8%
associate-*r*42.1%
unpow242.1%
pow-prod-down45.8%
sqrt-pow145.5%
metadata-eval45.5%
pow145.5%
*-commutative45.5%
Applied egg-rr97.2%
Taylor expanded in x around 0 76.0%
Final simplification76.0%
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 (* (* x_m s_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 = (x_m * s_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 = (x_m * s_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 = (x_m * s_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 = (x_m * s_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(Float64(x_m * s_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 = (x_m * s_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[(N[(x$95$m * s$95$m), $MachinePrecision] * c$95$m), $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 := \left(x\_m \cdot s\_m\right) \cdot c\_m\\
\frac{1}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 66.5%
Taylor expanded in x around 0 53.2%
associate-/r*53.2%
*-commutative53.2%
unpow253.2%
unpow253.2%
swap-sqr62.6%
unpow262.6%
associate-/r*62.6%
unpow262.6%
unpow262.6%
swap-sqr76.0%
unpow276.0%
*-commutative76.0%
Simplified76.0%
*-commutative76.0%
pow276.0%
Applied egg-rr76.0%
Final simplification76.0%
herbie shell --seed 2024108
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))