
(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 12 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}
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (if (<= x 3.5e-51) (pow (/ (pow s -0.5) (* c (* x (sqrt s)))) 2.0) (* (pow (* s (* x c)) -2.0) (cos (* x 2.0)))))
x = abs(x);
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
double tmp;
if (x <= 3.5e-51) {
tmp = pow((pow(s, -0.5) / (c * (x * sqrt(s)))), 2.0);
} else {
tmp = pow((s * (x * c)), -2.0) * cos((x * 2.0));
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: tmp
if (x <= 3.5d-51) then
tmp = ((s ** (-0.5d0)) / (c * (x * sqrt(s)))) ** 2.0d0
else
tmp = ((s * (x * c)) ** (-2.0d0)) * cos((x * 2.0d0))
end if
code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
double tmp;
if (x <= 3.5e-51) {
tmp = Math.pow((Math.pow(s, -0.5) / (c * (x * Math.sqrt(s)))), 2.0);
} else {
tmp = Math.pow((s * (x * c)), -2.0) * Math.cos((x * 2.0));
}
return tmp;
}
x = abs(x) c = abs(c) [c, s] = sort([c, s]) def code(x, c, s): tmp = 0 if x <= 3.5e-51: tmp = math.pow((math.pow(s, -0.5) / (c * (x * math.sqrt(s)))), 2.0) else: tmp = math.pow((s * (x * c)), -2.0) * math.cos((x * 2.0)) return tmp
x = abs(x) c = abs(c) c, s = sort([c, s]) function code(x, c, s) tmp = 0.0 if (x <= 3.5e-51) tmp = Float64((s ^ -0.5) / Float64(c * Float64(x * sqrt(s)))) ^ 2.0; else tmp = Float64((Float64(s * Float64(x * c)) ^ -2.0) * cos(Float64(x * 2.0))); end return tmp end
x = abs(x)
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
tmp = 0.0;
if (x <= 3.5e-51)
tmp = ((s ^ -0.5) / (c * (x * sqrt(s)))) ^ 2.0;
else
tmp = ((s * (x * c)) ^ -2.0) * cos((x * 2.0));
end
tmp_2 = tmp;
end
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := If[LessEqual[x, 3.5e-51], N[Power[N[(N[Power[s, -0.5], $MachinePrecision] / N[(c * N[(x * N[Sqrt[s], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(N[Power[N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision] * N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.5 \cdot 10^{-51}:\\
\;\;\;\;{\left(\frac{{s}^{-0.5}}{c \cdot \left(x \cdot \sqrt{s}\right)}\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;{\left(s \cdot \left(x \cdot c\right)\right)}^{-2} \cdot \cos \left(x \cdot 2\right)\\
\end{array}
\end{array}
if x < 3.4999999999999997e-51Initial program 63.8%
*-commutative63.8%
associate-*l*56.8%
associate-*r*56.7%
*-commutative56.7%
unpow256.7%
associate-*r*61.1%
associate-*r*62.7%
*-commutative62.7%
unpow262.7%
Simplified62.7%
Taylor expanded in x around 0 58.2%
Taylor expanded in x around 0 58.3%
associate-*r*58.2%
*-commutative58.2%
associate-*r*58.8%
unpow258.8%
unpow258.8%
Simplified58.8%
metadata-eval58.8%
associate-*r*58.2%
frac-times58.6%
*-commutative58.6%
add-sqr-sqrt58.6%
Applied egg-rr44.5%
unpow244.5%
associate-/r*44.5%
Simplified44.5%
if 3.4999999999999997e-51 < x Initial program 77.5%
*-commutative77.5%
associate-*l*71.2%
associate-*r*72.2%
*-commutative72.2%
unpow272.2%
associate-*r*79.5%
associate-*r*78.6%
*-commutative78.6%
unpow278.6%
Simplified78.6%
*-un-lft-identity78.6%
times-frac78.7%
associate-*r*76.6%
swap-sqr84.8%
associate-*r*95.2%
*-commutative95.2%
times-frac95.2%
associate-*l*96.1%
*-un-lft-identity96.1%
div-inv96.0%
*-commutative96.0%
pow296.0%
pow-flip96.2%
metadata-eval96.2%
Applied egg-rr96.2%
Final simplification61.2%
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
:precision binary64
(let* ((t_0 (* c (* x s))) (t_1 (* s (* x c))))
(if (<= x 9.2e-15)
(/ 1.0 (* t_0 t_0))
(if (<= x 4.6e+139)
(/ (cos (* x 2.0)) (* s (* (* x x) (* s (* c c)))))
(/ 1.0 (* t_1 t_1))))))x = abs(x);
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = c * (x * s);
double t_1 = s * (x * c);
double tmp;
if (x <= 9.2e-15) {
tmp = 1.0 / (t_0 * t_0);
} else if (x <= 4.6e+139) {
tmp = cos((x * 2.0)) / (s * ((x * x) * (s * (c * c))));
} else {
tmp = 1.0 / (t_1 * t_1);
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = c * (x * s)
t_1 = s * (x * c)
if (x <= 9.2d-15) then
tmp = 1.0d0 / (t_0 * t_0)
else if (x <= 4.6d+139) then
tmp = cos((x * 2.0d0)) / (s * ((x * x) * (s * (c * c))))
else
tmp = 1.0d0 / (t_1 * t_1)
end if
code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = c * (x * s);
double t_1 = s * (x * c);
double tmp;
if (x <= 9.2e-15) {
tmp = 1.0 / (t_0 * t_0);
} else if (x <= 4.6e+139) {
tmp = Math.cos((x * 2.0)) / (s * ((x * x) * (s * (c * c))));
} else {
tmp = 1.0 / (t_1 * t_1);
}
return tmp;
}
x = abs(x) c = abs(c) [c, s] = sort([c, s]) def code(x, c, s): t_0 = c * (x * s) t_1 = s * (x * c) tmp = 0 if x <= 9.2e-15: tmp = 1.0 / (t_0 * t_0) elif x <= 4.6e+139: tmp = math.cos((x * 2.0)) / (s * ((x * x) * (s * (c * c)))) else: tmp = 1.0 / (t_1 * t_1) return tmp
x = abs(x) c = abs(c) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(c * Float64(x * s)) t_1 = Float64(s * Float64(x * c)) tmp = 0.0 if (x <= 9.2e-15) tmp = Float64(1.0 / Float64(t_0 * t_0)); elseif (x <= 4.6e+139) tmp = Float64(cos(Float64(x * 2.0)) / Float64(s * Float64(Float64(x * x) * Float64(s * Float64(c * c))))); else tmp = Float64(1.0 / Float64(t_1 * t_1)); end return tmp end
x = abs(x)
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = c * (x * s);
t_1 = s * (x * c);
tmp = 0.0;
if (x <= 9.2e-15)
tmp = 1.0 / (t_0 * t_0);
elseif (x <= 4.6e+139)
tmp = cos((x * 2.0)) / (s * ((x * x) * (s * (c * c))));
else
tmp = 1.0 / (t_1 * t_1);
end
tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 9.2e-15], N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.6e+139], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(s * N[(N[(x * x), $MachinePrecision] * N[(s * N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
x = |x|\\
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
t_1 := s \cdot \left(x \cdot c\right)\\
\mathbf{if}\;x \leq 9.2 \cdot 10^{-15}:\\
\;\;\;\;\frac{1}{t_0 \cdot t_0}\\
\mathbf{elif}\;x \leq 4.6 \cdot 10^{+139}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{s \cdot \left(\left(x \cdot x\right) \cdot \left(s \cdot \left(c \cdot c\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t_1 \cdot t_1}\\
\end{array}
\end{array}
if x < 9.19999999999999961e-15Initial program 64.9%
*-commutative64.9%
associate-*r*58.3%
associate-*r*58.8%
unpow258.8%
unswap-sqr77.3%
unpow277.3%
swap-sqr94.5%
*-commutative94.5%
*-commutative94.5%
*-commutative94.5%
*-commutative94.5%
Simplified94.5%
Taylor expanded in s around 0 92.0%
Taylor expanded in s around 0 95.4%
Taylor expanded in x around 0 82.6%
if 9.19999999999999961e-15 < x < 4.6e139Initial program 81.7%
*-commutative81.7%
associate-*l*81.7%
associate-*r*85.8%
*-commutative85.8%
unpow285.8%
associate-*r*95.0%
associate-*r*91.1%
*-commutative91.1%
unpow291.1%
Simplified91.1%
if 4.6e139 < x Initial program 74.6%
*-commutative74.6%
associate-*r*64.2%
associate-*r*64.2%
unpow264.2%
unswap-sqr76.3%
unpow276.3%
swap-sqr94.0%
*-commutative94.0%
*-commutative94.0%
*-commutative94.0%
*-commutative94.0%
Simplified94.0%
Taylor expanded in x around 0 77.2%
Final simplification82.3%
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
:precision binary64
(let* ((t_0 (cos (* x 2.0))) (t_1 (* c (* x s))))
(if (<= x 2.2e+23)
(/ t_0 (* t_1 t_1))
(* (/ t_0 s) (/ (/ (/ 1.0 s) (* x c)) (* x c))))))x = abs(x);
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = cos((x * 2.0));
double t_1 = c * (x * s);
double tmp;
if (x <= 2.2e+23) {
tmp = t_0 / (t_1 * t_1);
} else {
tmp = (t_0 / s) * (((1.0 / s) / (x * c)) / (x * c));
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((x * 2.0d0))
t_1 = c * (x * s)
if (x <= 2.2d+23) then
tmp = t_0 / (t_1 * t_1)
else
tmp = (t_0 / s) * (((1.0d0 / s) / (x * c)) / (x * c))
end if
code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = Math.cos((x * 2.0));
double t_1 = c * (x * s);
double tmp;
if (x <= 2.2e+23) {
tmp = t_0 / (t_1 * t_1);
} else {
tmp = (t_0 / s) * (((1.0 / s) / (x * c)) / (x * c));
}
return tmp;
}
x = abs(x) c = abs(c) [c, s] = sort([c, s]) def code(x, c, s): t_0 = math.cos((x * 2.0)) t_1 = c * (x * s) tmp = 0 if x <= 2.2e+23: tmp = t_0 / (t_1 * t_1) else: tmp = (t_0 / s) * (((1.0 / s) / (x * c)) / (x * c)) return tmp
x = abs(x) c = abs(c) c, s = sort([c, s]) function code(x, c, s) t_0 = cos(Float64(x * 2.0)) t_1 = Float64(c * Float64(x * s)) tmp = 0.0 if (x <= 2.2e+23) tmp = Float64(t_0 / Float64(t_1 * t_1)); else tmp = Float64(Float64(t_0 / s) * Float64(Float64(Float64(1.0 / s) / Float64(x * c)) / Float64(x * c))); end return tmp end
x = abs(x)
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = cos((x * 2.0));
t_1 = c * (x * s);
tmp = 0.0;
if (x <= 2.2e+23)
tmp = t_0 / (t_1 * t_1);
else
tmp = (t_0 / s) * (((1.0 / s) / (x * c)) / (x * c));
end
tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 2.2e+23], N[(t$95$0 / N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / s), $MachinePrecision] * N[(N[(N[(1.0 / s), $MachinePrecision] / N[(x * c), $MachinePrecision]), $MachinePrecision] / N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \cos \left(x \cdot 2\right)\\
t_1 := c \cdot \left(x \cdot s\right)\\
\mathbf{if}\;x \leq 2.2 \cdot 10^{+23}:\\
\;\;\;\;\frac{t_0}{t_1 \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{s} \cdot \frac{\frac{\frac{1}{s}}{x \cdot c}}{x \cdot c}\\
\end{array}
\end{array}
if x < 2.20000000000000008e23Initial program 65.9%
*-commutative65.9%
associate-*r*59.6%
associate-*r*60.0%
unpow260.0%
unswap-sqr78.0%
unpow278.0%
swap-sqr94.6%
*-commutative94.6%
*-commutative94.6%
*-commutative94.6%
*-commutative94.6%
Simplified94.6%
Taylor expanded in s around 0 92.2%
Taylor expanded in s around 0 95.5%
if 2.20000000000000008e23 < x Initial program 74.8%
*-commutative74.8%
associate-*r*67.0%
associate-*r*65.5%
unpow265.5%
unswap-sqr74.7%
unpow274.7%
swap-sqr95.2%
*-commutative95.2%
*-commutative95.2%
*-commutative95.2%
*-commutative95.2%
Simplified95.2%
Taylor expanded in s around 0 95.4%
associate-/r*95.4%
*-commutative95.4%
div-inv95.4%
*-commutative95.4%
associate-*r*95.3%
times-frac94.0%
associate-/r*94.1%
*-commutative94.1%
*-commutative94.1%
Applied egg-rr94.1%
Final simplification95.1%
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
:precision binary64
(let* ((t_0 (* c (* x s))))
(if (<= s 1.55e+99)
(/ (cos (* x 2.0)) (* x (* (* x (* c c)) (* s s))))
(/ 1.0 (* t_0 t_0)))))x = abs(x);
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = c * (x * s);
double tmp;
if (s <= 1.55e+99) {
tmp = cos((x * 2.0)) / (x * ((x * (c * c)) * (s * s)));
} else {
tmp = 1.0 / (t_0 * t_0);
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: tmp
t_0 = c * (x * s)
if (s <= 1.55d+99) then
tmp = cos((x * 2.0d0)) / (x * ((x * (c * c)) * (s * s)))
else
tmp = 1.0d0 / (t_0 * t_0)
end if
code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = c * (x * s);
double tmp;
if (s <= 1.55e+99) {
tmp = Math.cos((x * 2.0)) / (x * ((x * (c * c)) * (s * s)));
} else {
tmp = 1.0 / (t_0 * t_0);
}
return tmp;
}
x = abs(x) c = abs(c) [c, s] = sort([c, s]) def code(x, c, s): t_0 = c * (x * s) tmp = 0 if s <= 1.55e+99: tmp = math.cos((x * 2.0)) / (x * ((x * (c * c)) * (s * s))) else: tmp = 1.0 / (t_0 * t_0) return tmp
x = abs(x) c = abs(c) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(c * Float64(x * s)) tmp = 0.0 if (s <= 1.55e+99) tmp = Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(Float64(x * Float64(c * c)) * Float64(s * s)))); else tmp = Float64(1.0 / Float64(t_0 * t_0)); end return tmp end
x = abs(x)
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = c * (x * s);
tmp = 0.0;
if (s <= 1.55e+99)
tmp = cos((x * 2.0)) / (x * ((x * (c * c)) * (s * s)));
else
tmp = 1.0 / (t_0 * t_0);
end
tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[s, 1.55e+99], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * N[(N[(x * N[(c * c), $MachinePrecision]), $MachinePrecision] * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\mathbf{if}\;s \leq 1.55 \cdot 10^{+99}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(\left(x \cdot \left(c \cdot c\right)\right) \cdot \left(s \cdot s\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t_0 \cdot t_0}\\
\end{array}
\end{array}
if s < 1.55e99Initial program 67.7%
associate-*r*69.6%
*-commutative69.6%
associate-*r*71.4%
unpow271.4%
unpow271.4%
Simplified71.4%
if 1.55e99 < s Initial program 70.0%
*-commutative70.0%
associate-*r*62.5%
associate-*r*60.7%
unpow260.7%
unswap-sqr67.7%
unpow267.7%
swap-sqr87.9%
*-commutative87.9%
*-commutative87.9%
*-commutative87.9%
*-commutative87.9%
Simplified87.9%
Taylor expanded in s around 0 84.6%
Taylor expanded in s around 0 89.6%
Taylor expanded in x around 0 91.9%
Final simplification75.7%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (let* ((t_0 (* s (* x c))) (t_1 (cos (* x 2.0))) (t_2 (* c (* x s)))) (if (<= x 1.1e+44) (/ t_1 (* t_2 t_2)) (/ t_1 (* t_0 t_0)))))
x = abs(x);
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = s * (x * c);
double t_1 = cos((x * 2.0));
double t_2 = c * (x * s);
double tmp;
if (x <= 1.1e+44) {
tmp = t_1 / (t_2 * t_2);
} else {
tmp = t_1 / (t_0 * t_0);
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = s * (x * c)
t_1 = cos((x * 2.0d0))
t_2 = c * (x * s)
if (x <= 1.1d+44) then
tmp = t_1 / (t_2 * t_2)
else
tmp = t_1 / (t_0 * t_0)
end if
code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = s * (x * c);
double t_1 = Math.cos((x * 2.0));
double t_2 = c * (x * s);
double tmp;
if (x <= 1.1e+44) {
tmp = t_1 / (t_2 * t_2);
} else {
tmp = t_1 / (t_0 * t_0);
}
return tmp;
}
x = abs(x) c = abs(c) [c, s] = sort([c, s]) def code(x, c, s): t_0 = s * (x * c) t_1 = math.cos((x * 2.0)) t_2 = c * (x * s) tmp = 0 if x <= 1.1e+44: tmp = t_1 / (t_2 * t_2) else: tmp = t_1 / (t_0 * t_0) return tmp
x = abs(x) c = abs(c) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(s * Float64(x * c)) t_1 = cos(Float64(x * 2.0)) t_2 = Float64(c * Float64(x * s)) tmp = 0.0 if (x <= 1.1e+44) tmp = Float64(t_1 / Float64(t_2 * t_2)); else tmp = Float64(t_1 / Float64(t_0 * t_0)); end return tmp end
x = abs(x)
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = s * (x * c);
t_1 = cos((x * 2.0));
t_2 = c * (x * s);
tmp = 0.0;
if (x <= 1.1e+44)
tmp = t_1 / (t_2 * t_2);
else
tmp = t_1 / (t_0 * t_0);
end
tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.1e+44], N[(t$95$1 / N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
x = |x|\\
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := s \cdot \left(x \cdot c\right)\\
t_1 := \cos \left(x \cdot 2\right)\\
t_2 := c \cdot \left(x \cdot s\right)\\
\mathbf{if}\;x \leq 1.1 \cdot 10^{+44}:\\
\;\;\;\;\frac{t_1}{t_2 \cdot t_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{t_0 \cdot t_0}\\
\end{array}
\end{array}
if x < 1.09999999999999998e44Initial program 67.0%
*-commutative67.0%
associate-*r*60.8%
associate-*r*60.8%
unpow260.8%
unswap-sqr78.1%
unpow278.1%
swap-sqr94.7%
*-commutative94.7%
*-commutative94.7%
*-commutative94.7%
*-commutative94.7%
Simplified94.7%
Taylor expanded in s around 0 92.5%
Taylor expanded in s around 0 95.6%
if 1.09999999999999998e44 < x Initial program 72.3%
*-commutative72.3%
associate-*r*63.7%
associate-*r*63.7%
unpow263.7%
unswap-sqr73.7%
unpow273.7%
swap-sqr94.8%
*-commutative94.8%
*-commutative94.8%
*-commutative94.8%
*-commutative94.8%
Simplified94.8%
Final simplification95.4%
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
:precision binary64
(let* ((t_0 (cos (* x 2.0))) (t_1 (* c (* x s))))
(if (<= x 4e+43)
(/ t_0 (* t_1 t_1))
(/ (/ t_0 s) (* (* s (* x c)) (* x c))))))x = abs(x);
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = cos((x * 2.0));
double t_1 = c * (x * s);
double tmp;
if (x <= 4e+43) {
tmp = t_0 / (t_1 * t_1);
} else {
tmp = (t_0 / s) / ((s * (x * c)) * (x * c));
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((x * 2.0d0))
t_1 = c * (x * s)
if (x <= 4d+43) then
tmp = t_0 / (t_1 * t_1)
else
tmp = (t_0 / s) / ((s * (x * c)) * (x * c))
end if
code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = Math.cos((x * 2.0));
double t_1 = c * (x * s);
double tmp;
if (x <= 4e+43) {
tmp = t_0 / (t_1 * t_1);
} else {
tmp = (t_0 / s) / ((s * (x * c)) * (x * c));
}
return tmp;
}
x = abs(x) c = abs(c) [c, s] = sort([c, s]) def code(x, c, s): t_0 = math.cos((x * 2.0)) t_1 = c * (x * s) tmp = 0 if x <= 4e+43: tmp = t_0 / (t_1 * t_1) else: tmp = (t_0 / s) / ((s * (x * c)) * (x * c)) return tmp
x = abs(x) c = abs(c) c, s = sort([c, s]) function code(x, c, s) t_0 = cos(Float64(x * 2.0)) t_1 = Float64(c * Float64(x * s)) tmp = 0.0 if (x <= 4e+43) tmp = Float64(t_0 / Float64(t_1 * t_1)); else tmp = Float64(Float64(t_0 / s) / Float64(Float64(s * Float64(x * c)) * Float64(x * c))); end return tmp end
x = abs(x)
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = cos((x * 2.0));
t_1 = c * (x * s);
tmp = 0.0;
if (x <= 4e+43)
tmp = t_0 / (t_1 * t_1);
else
tmp = (t_0 / s) / ((s * (x * c)) * (x * c));
end
tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 4e+43], N[(t$95$0 / N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / s), $MachinePrecision] / N[(N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision] * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \cos \left(x \cdot 2\right)\\
t_1 := c \cdot \left(x \cdot s\right)\\
\mathbf{if}\;x \leq 4 \cdot 10^{+43}:\\
\;\;\;\;\frac{t_0}{t_1 \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t_0}{s}}{\left(s \cdot \left(x \cdot c\right)\right) \cdot \left(x \cdot c\right)}\\
\end{array}
\end{array}
if x < 4.00000000000000006e43Initial program 67.0%
*-commutative67.0%
associate-*r*60.8%
associate-*r*60.8%
unpow260.8%
unswap-sqr78.1%
unpow278.1%
swap-sqr94.7%
*-commutative94.7%
*-commutative94.7%
*-commutative94.7%
*-commutative94.7%
Simplified94.7%
Taylor expanded in s around 0 92.5%
Taylor expanded in s around 0 95.6%
if 4.00000000000000006e43 < x Initial program 72.3%
*-commutative72.3%
associate-*r*63.7%
associate-*r*63.7%
unpow263.7%
unswap-sqr73.7%
unpow273.7%
swap-sqr94.8%
*-commutative94.8%
*-commutative94.8%
*-commutative94.8%
*-commutative94.8%
Simplified94.8%
Taylor expanded in s around 0 95.0%
associate-/r*95.0%
*-commutative95.0%
div-inv95.0%
*-commutative95.0%
associate-*r*94.9%
times-frac93.5%
associate-/r*93.5%
*-commutative93.5%
*-commutative93.5%
Applied egg-rr93.5%
frac-times94.9%
associate-/l/94.9%
*-commutative94.9%
div-inv94.9%
div-inv94.9%
*-commutative94.9%
associate-/l/94.9%
frac-times93.5%
div-inv93.5%
Applied egg-rr93.5%
Final simplification95.1%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (let* ((t_0 (* c (* x s)))) (/ (cos (* x 2.0)) (* t_0 t_0))))
x = abs(x);
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = c * (x * s);
return cos((x * 2.0)) / (t_0 * t_0);
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
t_0 = c * (x * s)
code = cos((x * 2.0d0)) / (t_0 * t_0)
end function
x = Math.abs(x);
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = c * (x * s);
return Math.cos((x * 2.0)) / (t_0 * t_0);
}
x = abs(x) c = abs(c) [c, s] = sort([c, s]) def code(x, c, s): t_0 = c * (x * s) return math.cos((x * 2.0)) / (t_0 * t_0)
x = abs(x) c = abs(c) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(c * Float64(x * s)) return Float64(cos(Float64(x * 2.0)) / Float64(t_0 * t_0)) end
x = abs(x)
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
t_0 = c * (x * s);
tmp = cos((x * 2.0)) / (t_0 * t_0);
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\frac{\cos \left(x \cdot 2\right)}{t_0 \cdot t_0}
\end{array}
\end{array}
Initial program 68.2%
*-commutative68.2%
associate-*r*61.5%
associate-*r*61.5%
unpow261.5%
unswap-sqr77.1%
unpow277.1%
swap-sqr94.8%
*-commutative94.8%
*-commutative94.8%
*-commutative94.8%
*-commutative94.8%
Simplified94.8%
Taylor expanded in s around 0 93.1%
Taylor expanded in s around 0 96.2%
Final simplification96.2%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (if (<= c 2900000000000.0) (/ 1.0 (* s (* (* x x) (* s (* c c))))) (/ 1.0 (* x (* (* x (* c c)) (* s s))))))
x = abs(x);
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
double tmp;
if (c <= 2900000000000.0) {
tmp = 1.0 / (s * ((x * x) * (s * (c * c))));
} else {
tmp = 1.0 / (x * ((x * (c * c)) * (s * s)));
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: tmp
if (c <= 2900000000000.0d0) then
tmp = 1.0d0 / (s * ((x * x) * (s * (c * c))))
else
tmp = 1.0d0 / (x * ((x * (c * c)) * (s * s)))
end if
code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
double tmp;
if (c <= 2900000000000.0) {
tmp = 1.0 / (s * ((x * x) * (s * (c * c))));
} else {
tmp = 1.0 / (x * ((x * (c * c)) * (s * s)));
}
return tmp;
}
x = abs(x) c = abs(c) [c, s] = sort([c, s]) def code(x, c, s): tmp = 0 if c <= 2900000000000.0: tmp = 1.0 / (s * ((x * x) * (s * (c * c)))) else: tmp = 1.0 / (x * ((x * (c * c)) * (s * s))) return tmp
x = abs(x) c = abs(c) c, s = sort([c, s]) function code(x, c, s) tmp = 0.0 if (c <= 2900000000000.0) tmp = Float64(1.0 / Float64(s * Float64(Float64(x * x) * Float64(s * Float64(c * c))))); else tmp = Float64(1.0 / Float64(x * Float64(Float64(x * Float64(c * c)) * Float64(s * s)))); end return tmp end
x = abs(x)
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
tmp = 0.0;
if (c <= 2900000000000.0)
tmp = 1.0 / (s * ((x * x) * (s * (c * c))));
else
tmp = 1.0 / (x * ((x * (c * c)) * (s * s)));
end
tmp_2 = tmp;
end
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := If[LessEqual[c, 2900000000000.0], N[(1.0 / N[(s * N[(N[(x * x), $MachinePrecision] * N[(s * N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(x * N[(N[(x * N[(c * c), $MachinePrecision]), $MachinePrecision] * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;c \leq 2900000000000:\\
\;\;\;\;\frac{1}{s \cdot \left(\left(x \cdot x\right) \cdot \left(s \cdot \left(c \cdot c\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \left(\left(x \cdot \left(c \cdot c\right)\right) \cdot \left(s \cdot s\right)\right)}\\
\end{array}
\end{array}
if c < 2.9e12Initial program 69.4%
*-commutative69.4%
associate-*l*61.5%
associate-*r*61.9%
*-commutative61.9%
unpow261.9%
associate-*r*67.2%
associate-*r*68.8%
*-commutative68.8%
unpow268.8%
Simplified68.8%
Taylor expanded in x around 0 61.9%
if 2.9e12 < c Initial program 64.6%
associate-*r*63.1%
*-commutative63.1%
associate-*r*64.4%
unpow264.4%
unpow264.4%
Simplified64.4%
Taylor expanded in x around 0 62.9%
Final simplification62.1%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (/ 1.0 (* s (* (* c c) (* s (* x x))))))
x = abs(x);
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
return 1.0 / (s * ((c * c) * (s * (x * x))));
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = 1.0d0 / (s * ((c * c) * (s * (x * x))))
end function
x = Math.abs(x);
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
return 1.0 / (s * ((c * c) * (s * (x * x))));
}
x = abs(x) c = abs(c) [c, s] = sort([c, s]) def code(x, c, s): return 1.0 / (s * ((c * c) * (s * (x * x))))
x = abs(x) c = abs(c) c, s = sort([c, s]) function code(x, c, s) return Float64(1.0 / Float64(s * Float64(Float64(c * c) * Float64(s * Float64(x * x))))) end
x = abs(x)
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = 1.0 / (s * ((c * c) * (s * (x * x))));
end
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(1.0 / N[(s * N[(N[(c * c), $MachinePrecision] * N[(s * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{s \cdot \left(\left(c \cdot c\right) \cdot \left(s \cdot \left(x \cdot x\right)\right)\right)}
\end{array}
Initial program 68.2%
*-commutative68.2%
associate-*l*61.5%
associate-*r*61.7%
*-commutative61.7%
unpow261.7%
associate-*r*67.0%
associate-*r*67.9%
*-commutative67.9%
unpow267.9%
Simplified67.9%
Taylor expanded in x around 0 62.7%
Taylor expanded in x around 0 62.7%
associate-*r*62.7%
*-commutative62.7%
associate-*r*63.1%
unpow263.1%
unpow263.1%
Simplified63.1%
Final simplification63.1%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (let* ((t_0 (* c (* x s)))) (/ 1.0 (* t_0 t_0))))
x = abs(x);
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = c * (x * s);
return 1.0 / (t_0 * t_0);
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
t_0 = c * (x * s)
code = 1.0d0 / (t_0 * t_0)
end function
x = Math.abs(x);
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = c * (x * s);
return 1.0 / (t_0 * t_0);
}
x = abs(x) c = abs(c) [c, s] = sort([c, s]) def code(x, c, s): t_0 = c * (x * s) return 1.0 / (t_0 * t_0)
x = abs(x) c = abs(c) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(c * Float64(x * s)) return Float64(1.0 / Float64(t_0 * t_0)) end
x = abs(x)
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
t_0 = c * (x * s);
tmp = 1.0 / (t_0 * t_0);
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\frac{1}{t_0 \cdot t_0}
\end{array}
\end{array}
Initial program 68.2%
*-commutative68.2%
associate-*r*61.5%
associate-*r*61.5%
unpow261.5%
unswap-sqr77.1%
unpow277.1%
swap-sqr94.8%
*-commutative94.8%
*-commutative94.8%
*-commutative94.8%
*-commutative94.8%
Simplified94.8%
Taylor expanded in s around 0 93.1%
Taylor expanded in s around 0 96.2%
Taylor expanded in x around 0 79.8%
Final simplification79.8%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (/ -2.0 (* s (* c (* s c)))))
x = abs(x);
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
return -2.0 / (s * (c * (s * c)));
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = (-2.0d0) / (s * (c * (s * c)))
end function
x = Math.abs(x);
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
return -2.0 / (s * (c * (s * c)));
}
x = abs(x) c = abs(c) [c, s] = sort([c, s]) def code(x, c, s): return -2.0 / (s * (c * (s * c)))
x = abs(x) c = abs(c) c, s = sort([c, s]) function code(x, c, s) return Float64(-2.0 / Float64(s * Float64(c * Float64(s * c)))) end
x = abs(x)
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = -2.0 / (s * (c * (s * c)));
end
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(-2.0 / N[(s * N[(c * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{-2}{s \cdot \left(c \cdot \left(s \cdot c\right)\right)}
\end{array}
Initial program 68.2%
*-commutative68.2%
associate-*l*61.5%
associate-*r*61.7%
*-commutative61.7%
unpow261.7%
associate-*r*67.0%
associate-*r*67.9%
*-commutative67.9%
unpow267.9%
Simplified67.9%
add-cube-cbrt67.8%
times-frac68.4%
associate-*r*67.5%
swap-sqr84.5%
associate-*r*92.5%
*-commutative92.5%
times-frac91.7%
associate-*l*94.6%
add-cube-cbrt94.8%
associate-/r*95.6%
Applied egg-rr95.6%
Taylor expanded in x around 0 65.4%
Taylor expanded in x around inf 31.5%
*-commutative31.5%
unpow231.5%
associate-*l*31.9%
unpow231.9%
associate-*r*30.3%
*-commutative30.3%
*-commutative30.3%
Simplified30.3%
Final simplification30.3%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (/ (/ -2.0 (* s s)) (* c c)))
x = abs(x);
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
return (-2.0 / (s * s)) / (c * c);
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = ((-2.0d0) / (s * s)) / (c * c)
end function
x = Math.abs(x);
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
return (-2.0 / (s * s)) / (c * c);
}
x = abs(x) c = abs(c) [c, s] = sort([c, s]) def code(x, c, s): return (-2.0 / (s * s)) / (c * c)
x = abs(x) c = abs(c) c, s = sort([c, s]) function code(x, c, s) return Float64(Float64(-2.0 / Float64(s * s)) / Float64(c * c)) end
x = abs(x)
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = (-2.0 / (s * s)) / (c * c);
end
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(N[(-2.0 / N[(s * s), $MachinePrecision]), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\frac{-2}{s \cdot s}}{c \cdot c}
\end{array}
Initial program 68.2%
*-commutative68.2%
associate-*l*61.5%
associate-*r*61.7%
*-commutative61.7%
unpow261.7%
associate-*r*67.0%
associate-*r*67.9%
*-commutative67.9%
unpow267.9%
Simplified67.9%
add-cube-cbrt67.8%
times-frac68.4%
associate-*r*67.5%
swap-sqr84.5%
associate-*r*92.5%
*-commutative92.5%
times-frac91.7%
associate-*l*94.6%
add-cube-cbrt94.8%
associate-/r*95.6%
Applied egg-rr95.6%
Taylor expanded in x around 0 65.4%
Taylor expanded in x around inf 31.5%
associate-/l/31.5%
unpow231.5%
unpow231.5%
Simplified31.5%
Final simplification31.5%
herbie shell --seed 2023228
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))