
(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 13 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: s 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))))
(if (<= x 1.5e-40)
(* (/ 1.0 c) (/ 1.0 (* (* x s) (* c (* x s)))))
(/ (cos (* x 2.0)) (* t_0 t_0)))))x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = s * (x * c);
double tmp;
if (x <= 1.5e-40) {
tmp = (1.0 / c) * (1.0 / ((x * s) * (c * (x * s))));
} else {
tmp = cos((x * 2.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: s 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 = s * (x * c)
if (x <= 1.5d-40) then
tmp = (1.0d0 / c) * (1.0d0 / ((x * s) * (c * (x * s))))
else
tmp = cos((x * 2.0d0)) / (t_0 * t_0)
end if
code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = s * (x * c);
double tmp;
if (x <= 1.5e-40) {
tmp = (1.0 / c) * (1.0 / ((x * s) * (c * (x * s))));
} else {
tmp = Math.cos((x * 2.0)) / (t_0 * t_0);
}
return tmp;
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = s * (x * c) tmp = 0 if x <= 1.5e-40: tmp = (1.0 / c) * (1.0 / ((x * s) * (c * (x * s)))) else: tmp = math.cos((x * 2.0)) / (t_0 * t_0) return tmp
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(s * Float64(x * c)) tmp = 0.0 if (x <= 1.5e-40) tmp = Float64(Float64(1.0 / c) * Float64(1.0 / Float64(Float64(x * s) * Float64(c * Float64(x * s))))); else tmp = Float64(cos(Float64(x * 2.0)) / Float64(t_0 * t_0)); end return tmp end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = s * (x * c);
tmp = 0.0;
if (x <= 1.5e-40)
tmp = (1.0 / c) * (1.0 / ((x * s) * (c * (x * s))));
else
tmp = cos((x * 2.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: s 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]}, If[LessEqual[x, 1.5e-40], N[(N[(1.0 / c), $MachinePrecision] * N[(1.0 / N[(N[(x * s), $MachinePrecision] * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := s \cdot \left(x \cdot c\right)\\
\mathbf{if}\;x \leq 1.5 \cdot 10^{-40}:\\
\;\;\;\;\frac{1}{c} \cdot \frac{1}{\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{t_0 \cdot t_0}\\
\end{array}
\end{array}
if x < 1.5000000000000001e-40Initial program 67.9%
*-commutative67.9%
associate-*r*58.5%
associate-*r*58.7%
unpow258.7%
unswap-sqr82.1%
unpow282.1%
swap-sqr97.6%
*-commutative97.6%
*-commutative97.6%
*-commutative97.6%
*-commutative97.6%
Simplified97.6%
Taylor expanded in x around 0 55.0%
unpow255.0%
unpow255.0%
*-commutative55.0%
unpow255.0%
swap-sqr71.5%
swap-sqr87.0%
unpow287.0%
*-commutative87.0%
Simplified87.0%
unpow287.0%
*-commutative87.0%
associate-*r*85.3%
associate-*l*83.8%
associate-*r*85.6%
*-commutative85.6%
Applied egg-rr85.6%
inv-pow85.6%
unpow-prod-down85.5%
associate-*l*84.6%
associate-*r*81.5%
Applied egg-rr81.5%
unpow-181.5%
unpow-181.5%
associate-*r*82.4%
associate-*r*85.5%
Simplified85.5%
if 1.5000000000000001e-40 < x Initial program 74.8%
*-commutative74.8%
associate-*r*66.9%
associate-*r*69.7%
unpow269.7%
unswap-sqr86.5%
unpow286.5%
swap-sqr98.3%
*-commutative98.3%
*-commutative98.3%
*-commutative98.3%
*-commutative98.3%
Simplified98.3%
Final simplification88.8%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s 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 (* (pow (* c (* x s)) -2.0) (cos (* x 2.0))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return pow((c * (x * s)), -2.0) * cos((x * 2.0));
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s 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 = ((c * (x * s)) ** (-2.0d0)) * cos((x * 2.0d0))
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return Math.pow((c * (x * s)), -2.0) * Math.cos((x * 2.0));
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return math.pow((c * (x * s)), -2.0) * math.cos((x * 2.0))
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64((Float64(c * Float64(x * s)) ^ -2.0) * cos(Float64(x * 2.0))) end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = ((c * (x * s)) ^ -2.0) * cos((x * 2.0));
end
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s 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[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision] * N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
{\left(c \cdot \left(x \cdot s\right)\right)}^{-2} \cdot \cos \left(x \cdot 2\right)
\end{array}
Initial program 69.7%
*-commutative69.7%
associate-*r*60.7%
associate-*r*61.5%
unpow261.5%
unswap-sqr83.2%
unpow283.2%
swap-sqr97.8%
*-commutative97.8%
*-commutative97.8%
*-commutative97.8%
*-commutative97.8%
Simplified97.8%
Taylor expanded in x around inf 60.7%
*-commutative60.7%
unpow260.7%
unpow260.7%
*-commutative60.7%
unpow260.7%
swap-sqr79.4%
swap-sqr97.9%
unpow297.9%
rem-exp-log86.0%
log-div71.5%
log-pow45.2%
*-commutative45.2%
*-commutative45.2%
associate-*r*44.0%
cancel-sign-sub-inv44.0%
Simplified98.0%
Final simplification98.0%
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s 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 (<= x 2.85e-5)
(* (/ 1.0 c) (/ 1.0 (* (* x s) t_0)))
(if (<= x 4.1e+191)
(/ (cos (* x 2.0)) (* s (* (* x x) (* s (* c c)))))
(/ (+ (* -2.0 (/ x (* c s))) (/ 1.0 (* s (* x c)))) t_0)))))x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = c * (x * s);
double tmp;
if (x <= 2.85e-5) {
tmp = (1.0 / c) * (1.0 / ((x * s) * t_0));
} else if (x <= 4.1e+191) {
tmp = cos((x * 2.0)) / (s * ((x * x) * (s * (c * c))));
} else {
tmp = ((-2.0 * (x / (c * s))) + (1.0 / (s * (x * c)))) / t_0;
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s 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 (x <= 2.85d-5) then
tmp = (1.0d0 / c) * (1.0d0 / ((x * s) * t_0))
else if (x <= 4.1d+191) then
tmp = cos((x * 2.0d0)) / (s * ((x * x) * (s * (c * c))))
else
tmp = (((-2.0d0) * (x / (c * s))) + (1.0d0 / (s * (x * c)))) / t_0
end if
code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = c * (x * s);
double tmp;
if (x <= 2.85e-5) {
tmp = (1.0 / c) * (1.0 / ((x * s) * t_0));
} else if (x <= 4.1e+191) {
tmp = Math.cos((x * 2.0)) / (s * ((x * x) * (s * (c * c))));
} else {
tmp = ((-2.0 * (x / (c * s))) + (1.0 / (s * (x * c)))) / t_0;
}
return tmp;
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = c * (x * s) tmp = 0 if x <= 2.85e-5: tmp = (1.0 / c) * (1.0 / ((x * s) * t_0)) elif x <= 4.1e+191: tmp = math.cos((x * 2.0)) / (s * ((x * x) * (s * (c * c)))) else: tmp = ((-2.0 * (x / (c * s))) + (1.0 / (s * (x * c)))) / t_0 return tmp
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(c * Float64(x * s)) tmp = 0.0 if (x <= 2.85e-5) tmp = Float64(Float64(1.0 / c) * Float64(1.0 / Float64(Float64(x * s) * t_0))); elseif (x <= 4.1e+191) tmp = Float64(cos(Float64(x * 2.0)) / Float64(s * Float64(Float64(x * x) * Float64(s * Float64(c * c))))); else tmp = Float64(Float64(Float64(-2.0 * Float64(x / Float64(c * s))) + Float64(1.0 / Float64(s * Float64(x * c)))) / t_0); end return tmp end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = c * (x * s);
tmp = 0.0;
if (x <= 2.85e-5)
tmp = (1.0 / c) * (1.0 / ((x * s) * t_0));
elseif (x <= 4.1e+191)
tmp = cos((x * 2.0)) / (s * ((x * x) * (s * (c * c))));
else
tmp = ((-2.0 * (x / (c * s))) + (1.0 / (s * (x * c)))) / 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: s 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[x, 2.85e-5], N[(N[(1.0 / c), $MachinePrecision] * N[(1.0 / N[(N[(x * s), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.1e+191], 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[(N[(N[(-2.0 * N[(x / N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\mathbf{if}\;x \leq 2.85 \cdot 10^{-5}:\\
\;\;\;\;\frac{1}{c} \cdot \frac{1}{\left(x \cdot s\right) \cdot t_0}\\
\mathbf{elif}\;x \leq 4.1 \cdot 10^{+191}:\\
\;\;\;\;\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{-2 \cdot \frac{x}{c \cdot s} + \frac{1}{s \cdot \left(x \cdot c\right)}}{t_0}\\
\end{array}
\end{array}
if x < 2.8500000000000002e-5Initial program 68.6%
*-commutative68.6%
associate-*r*59.4%
associate-*r*59.5%
unpow259.5%
unswap-sqr82.4%
unpow282.5%
swap-sqr97.7%
*-commutative97.7%
*-commutative97.7%
*-commutative97.7%
*-commutative97.7%
Simplified97.7%
Taylor expanded in x around 0 55.9%
unpow255.9%
unpow255.9%
*-commutative55.9%
unpow255.9%
swap-sqr72.1%
swap-sqr87.3%
unpow287.3%
*-commutative87.3%
Simplified87.3%
unpow287.3%
*-commutative87.3%
associate-*r*85.6%
associate-*l*84.1%
associate-*r*85.9%
*-commutative85.9%
Applied egg-rr85.9%
inv-pow85.9%
unpow-prod-down85.8%
associate-*l*85.0%
associate-*r*81.9%
Applied egg-rr81.9%
unpow-181.9%
unpow-181.9%
associate-*r*82.8%
associate-*r*85.8%
Simplified85.8%
if 2.8500000000000002e-5 < x < 4.0999999999999999e191Initial program 79.5%
*-commutative79.5%
associate-*l*79.3%
associate-*r*85.0%
*-commutative85.0%
unpow285.0%
associate-*r*88.1%
associate-*r*88.1%
*-commutative88.1%
unpow288.1%
Simplified88.1%
if 4.0999999999999999e191 < x Initial program 66.0%
*-commutative66.0%
associate-*r*48.3%
associate-*r*48.3%
unpow248.3%
unswap-sqr83.0%
unpow283.0%
swap-sqr96.5%
*-commutative96.5%
*-commutative96.5%
*-commutative96.5%
*-commutative96.5%
Simplified96.5%
Taylor expanded in x around inf 48.3%
*-commutative48.3%
unpow248.3%
unpow248.3%
*-commutative48.3%
unpow248.3%
swap-sqr82.7%
swap-sqr96.6%
unpow296.6%
rem-exp-log75.0%
log-div40.3%
log-pow20.7%
*-commutative20.7%
*-commutative20.7%
associate-*r*20.7%
cancel-sign-sub-inv20.7%
Simplified96.6%
metadata-eval96.6%
pow-flip96.6%
unpow296.6%
*-commutative96.6%
associate-*r*93.5%
*-commutative93.5%
div-inv93.4%
associate-/r*93.4%
*-commutative93.4%
associate-*r*96.6%
*-commutative96.6%
Applied egg-rr96.6%
Taylor expanded in x around 0 66.2%
Final simplification83.9%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s 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 8e-5) (* (/ 1.0 c) (/ 1.0 (* (* x s) (* c (* x s))))) (/ (cos (* x 2.0)) (* x (* c (* c (* s (* x s))))))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double tmp;
if (x <= 8e-5) {
tmp = (1.0 / c) * (1.0 / ((x * s) * (c * (x * s))));
} else {
tmp = cos((x * 2.0)) / (x * (c * (c * (s * (x * s)))));
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s 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 <= 8d-5) then
tmp = (1.0d0 / c) * (1.0d0 / ((x * s) * (c * (x * s))))
else
tmp = cos((x * 2.0d0)) / (x * (c * (c * (s * (x * s)))))
end if
code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double tmp;
if (x <= 8e-5) {
tmp = (1.0 / c) * (1.0 / ((x * s) * (c * (x * s))));
} else {
tmp = Math.cos((x * 2.0)) / (x * (c * (c * (s * (x * s)))));
}
return tmp;
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): tmp = 0 if x <= 8e-5: tmp = (1.0 / c) * (1.0 / ((x * s) * (c * (x * s)))) else: tmp = math.cos((x * 2.0)) / (x * (c * (c * (s * (x * s))))) return tmp
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) tmp = 0.0 if (x <= 8e-5) tmp = Float64(Float64(1.0 / c) * Float64(1.0 / Float64(Float64(x * s) * Float64(c * Float64(x * s))))); else tmp = Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(c * Float64(c * Float64(s * Float64(x * s)))))); end return tmp end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
tmp = 0.0;
if (x <= 8e-5)
tmp = (1.0 / c) * (1.0 / ((x * s) * (c * (x * s))));
else
tmp = cos((x * 2.0)) / (x * (c * (c * (s * (x * 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: s 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, 8e-5], N[(N[(1.0 / c), $MachinePrecision] * N[(1.0 / N[(N[(x * s), $MachinePrecision] * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * N[(c * N[(c * N[(s * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8 \cdot 10^{-5}:\\
\;\;\;\;\frac{1}{c} \cdot \frac{1}{\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(c \cdot \left(c \cdot \left(s \cdot \left(x \cdot s\right)\right)\right)\right)}\\
\end{array}
\end{array}
if x < 8.00000000000000065e-5Initial program 68.6%
*-commutative68.6%
associate-*r*59.4%
associate-*r*59.5%
unpow259.5%
unswap-sqr82.4%
unpow282.5%
swap-sqr97.7%
*-commutative97.7%
*-commutative97.7%
*-commutative97.7%
*-commutative97.7%
Simplified97.7%
Taylor expanded in x around 0 55.9%
unpow255.9%
unpow255.9%
*-commutative55.9%
unpow255.9%
swap-sqr72.1%
swap-sqr87.3%
unpow287.3%
*-commutative87.3%
Simplified87.3%
unpow287.3%
*-commutative87.3%
associate-*r*85.6%
associate-*l*84.1%
associate-*r*85.9%
*-commutative85.9%
Applied egg-rr85.9%
inv-pow85.9%
unpow-prod-down85.8%
associate-*l*85.0%
associate-*r*81.9%
Applied egg-rr81.9%
unpow-181.9%
unpow-181.9%
associate-*r*82.8%
associate-*r*85.8%
Simplified85.8%
if 8.00000000000000065e-5 < x Initial program 73.2%
associate-*r*74.8%
*-commutative74.8%
associate-*r*76.3%
unpow276.3%
unpow276.3%
Simplified76.3%
Taylor expanded in c around 0 76.3%
unpow276.3%
associate-*r*76.4%
*-commutative76.4%
associate-*r*74.8%
*-commutative74.8%
unpow274.8%
associate-*l*79.3%
*-commutative79.3%
associate-*l*84.1%
Simplified84.1%
Final simplification85.4%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s 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 0.00105) (* (/ 1.0 c) (/ 1.0 (* (* x s) (* c (* x s))))) (/ (cos (* x 2.0)) (* x (* (* c (* x c)) (* s s))))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double tmp;
if (x <= 0.00105) {
tmp = (1.0 / c) * (1.0 / ((x * s) * (c * (x * s))));
} else {
tmp = cos((x * 2.0)) / (x * ((c * (x * c)) * (s * s)));
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s 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 <= 0.00105d0) then
tmp = (1.0d0 / c) * (1.0d0 / ((x * s) * (c * (x * s))))
else
tmp = cos((x * 2.0d0)) / (x * ((c * (x * c)) * (s * s)))
end if
code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double tmp;
if (x <= 0.00105) {
tmp = (1.0 / c) * (1.0 / ((x * s) * (c * (x * s))));
} else {
tmp = Math.cos((x * 2.0)) / (x * ((c * (x * c)) * (s * s)));
}
return tmp;
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): tmp = 0 if x <= 0.00105: tmp = (1.0 / c) * (1.0 / ((x * s) * (c * (x * s)))) else: tmp = math.cos((x * 2.0)) / (x * ((c * (x * c)) * (s * s))) return tmp
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) tmp = 0.0 if (x <= 0.00105) tmp = Float64(Float64(1.0 / c) * Float64(1.0 / Float64(Float64(x * s) * Float64(c * Float64(x * s))))); else tmp = Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(Float64(c * Float64(x * c)) * Float64(s * s)))); end return tmp end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
tmp = 0.0;
if (x <= 0.00105)
tmp = (1.0 / c) * (1.0 / ((x * s) * (c * (x * s))));
else
tmp = cos((x * 2.0)) / (x * ((c * (x * 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: s 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, 0.00105], N[(N[(1.0 / c), $MachinePrecision] * N[(1.0 / N[(N[(x * s), $MachinePrecision] * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * N[(N[(c * N[(x * c), $MachinePrecision]), $MachinePrecision] * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.00105:\\
\;\;\;\;\frac{1}{c} \cdot \frac{1}{\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(\left(c \cdot \left(x \cdot c\right)\right) \cdot \left(s \cdot s\right)\right)}\\
\end{array}
\end{array}
if x < 0.00104999999999999994Initial program 68.6%
*-commutative68.6%
associate-*r*59.4%
associate-*r*59.5%
unpow259.5%
unswap-sqr82.4%
unpow282.5%
swap-sqr97.7%
*-commutative97.7%
*-commutative97.7%
*-commutative97.7%
*-commutative97.7%
Simplified97.7%
Taylor expanded in x around 0 55.9%
unpow255.9%
unpow255.9%
*-commutative55.9%
unpow255.9%
swap-sqr72.1%
swap-sqr87.3%
unpow287.3%
*-commutative87.3%
Simplified87.3%
unpow287.3%
*-commutative87.3%
associate-*r*85.6%
associate-*l*84.1%
associate-*r*85.9%
*-commutative85.9%
Applied egg-rr85.9%
inv-pow85.9%
unpow-prod-down85.8%
associate-*l*85.0%
associate-*r*81.9%
Applied egg-rr81.9%
unpow-181.9%
unpow-181.9%
associate-*r*82.8%
associate-*r*85.8%
Simplified85.8%
if 0.00104999999999999994 < x Initial program 73.2%
associate-*r*74.8%
*-commutative74.8%
associate-*r*76.3%
unpow276.3%
unpow276.3%
Simplified76.3%
Taylor expanded in c around 0 76.3%
*-commutative76.3%
unpow276.3%
associate-*r*79.0%
*-commutative79.0%
Simplified79.0%
Final simplification84.1%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s 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);
s = abs(s);
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: s 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);
s = Math.abs(s);
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) s = abs(s) [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) s = abs(s) 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)
s = abs(s)
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: s 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|\\
s = |s|\\
[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 69.7%
*-commutative69.7%
associate-*r*60.7%
associate-*r*61.5%
unpow261.5%
unswap-sqr83.2%
unpow283.2%
swap-sqr97.8%
*-commutative97.8%
*-commutative97.8%
*-commutative97.8%
*-commutative97.8%
Simplified97.8%
Taylor expanded in s around 0 96.3%
Taylor expanded in s around 0 97.9%
Final simplification97.9%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s 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);
s = abs(s);
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: s 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);
s = Math.abs(s);
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) s = abs(s) [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) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(c * Float64(x * s)) return Float64(Float64(cos(Float64(x * 2.0)) / t_0) / t_0) end
x = abs(x)
c = abs(c)
s = abs(s)
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: s 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[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\frac{\frac{\cos \left(x \cdot 2\right)}{t_0}}{t_0}
\end{array}
\end{array}
Initial program 69.7%
*-commutative69.7%
associate-*r*60.7%
associate-*r*61.5%
unpow261.5%
unswap-sqr83.2%
unpow283.2%
swap-sqr97.8%
*-commutative97.8%
*-commutative97.8%
*-commutative97.8%
*-commutative97.8%
Simplified97.8%
Taylor expanded in x around inf 60.7%
*-commutative60.7%
unpow260.7%
unpow260.7%
*-commutative60.7%
unpow260.7%
swap-sqr79.4%
swap-sqr97.9%
unpow297.9%
rem-exp-log86.0%
log-div71.5%
log-pow45.2%
*-commutative45.2%
*-commutative45.2%
associate-*r*44.0%
cancel-sign-sub-inv44.0%
Simplified98.0%
metadata-eval98.0%
pow-flip97.8%
unpow297.8%
*-commutative97.8%
associate-*r*96.2%
*-commutative96.2%
div-inv96.3%
associate-/r*96.3%
*-commutative96.3%
associate-*r*98.0%
*-commutative98.0%
Applied egg-rr98.0%
Final simplification98.0%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s 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 (<= s 7.5e-199) (* (/ 1.0 (* s (* s (* x c)))) (+ (* -2.0 (/ x c)) (/ 1.0 (* x c)))) (pow (* c (* x s)) -2.0)))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double tmp;
if (s <= 7.5e-199) {
tmp = (1.0 / (s * (s * (x * c)))) * ((-2.0 * (x / c)) + (1.0 / (x * c)));
} else {
tmp = pow((c * (x * s)), -2.0);
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s 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 (s <= 7.5d-199) then
tmp = (1.0d0 / (s * (s * (x * c)))) * (((-2.0d0) * (x / c)) + (1.0d0 / (x * c)))
else
tmp = (c * (x * s)) ** (-2.0d0)
end if
code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double tmp;
if (s <= 7.5e-199) {
tmp = (1.0 / (s * (s * (x * c)))) * ((-2.0 * (x / c)) + (1.0 / (x * c)));
} else {
tmp = Math.pow((c * (x * s)), -2.0);
}
return tmp;
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): tmp = 0 if s <= 7.5e-199: tmp = (1.0 / (s * (s * (x * c)))) * ((-2.0 * (x / c)) + (1.0 / (x * c))) else: tmp = math.pow((c * (x * s)), -2.0) return tmp
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) tmp = 0.0 if (s <= 7.5e-199) tmp = Float64(Float64(1.0 / Float64(s * Float64(s * Float64(x * c)))) * Float64(Float64(-2.0 * Float64(x / c)) + Float64(1.0 / Float64(x * c)))); else tmp = Float64(c * Float64(x * s)) ^ -2.0; end return tmp end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
tmp = 0.0;
if (s <= 7.5e-199)
tmp = (1.0 / (s * (s * (x * c)))) * ((-2.0 * (x / c)) + (1.0 / (x * c)));
else
tmp = (c * (x * s)) ^ -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: s 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[s, 7.5e-199], N[(N[(1.0 / N[(s * N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(-2.0 * N[(x / c), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;s \leq 7.5 \cdot 10^{-199}:\\
\;\;\;\;\frac{1}{s \cdot \left(s \cdot \left(x \cdot c\right)\right)} \cdot \left(-2 \cdot \frac{x}{c} + \frac{1}{x \cdot c}\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\
\end{array}
\end{array}
if s < 7.5000000000000003e-199Initial program 68.3%
*-commutative68.3%
associate-*r*59.4%
associate-*r*59.5%
unpow259.5%
unswap-sqr84.3%
unpow284.3%
swap-sqr98.9%
*-commutative98.9%
*-commutative98.9%
*-commutative98.9%
*-commutative98.9%
Simplified98.9%
*-un-lft-identity98.9%
associate-*r*96.6%
times-frac96.5%
*-commutative96.5%
Applied egg-rr96.5%
Taylor expanded in x around 0 79.7%
if 7.5000000000000003e-199 < s Initial program 71.8%
*-commutative71.8%
associate-*r*62.7%
associate-*r*64.6%
unpow264.6%
unswap-sqr81.5%
unpow281.5%
swap-sqr96.1%
*-commutative96.1%
*-commutative96.1%
*-commutative96.1%
*-commutative96.1%
Simplified96.1%
Taylor expanded in x around 0 55.2%
unpow255.2%
unpow255.2%
*-commutative55.2%
unpow255.2%
Simplified55.2%
*-commutative55.2%
swap-sqr71.0%
swap-sqr79.6%
unpow279.6%
pow-flip79.6%
metadata-eval79.6%
Applied egg-rr79.6%
Final simplification79.7%
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s 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.05e-197)
(* (/ 1.0 (* s (* s (* x c)))) (+ (* -2.0 (/ x c)) (/ 1.0 (* x c))))
(/ (/ 1.0 t_0) t_0))))x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = c * (x * s);
double tmp;
if (s <= 1.05e-197) {
tmp = (1.0 / (s * (s * (x * c)))) * ((-2.0 * (x / c)) + (1.0 / (x * c)));
} 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: s 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.05d-197) then
tmp = (1.0d0 / (s * (s * (x * c)))) * (((-2.0d0) * (x / c)) + (1.0d0 / (x * c)))
else
tmp = (1.0d0 / t_0) / t_0
end if
code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = c * (x * s);
double tmp;
if (s <= 1.05e-197) {
tmp = (1.0 / (s * (s * (x * c)))) * ((-2.0 * (x / c)) + (1.0 / (x * c)));
} else {
tmp = (1.0 / t_0) / t_0;
}
return tmp;
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = c * (x * s) tmp = 0 if s <= 1.05e-197: tmp = (1.0 / (s * (s * (x * c)))) * ((-2.0 * (x / c)) + (1.0 / (x * c))) else: tmp = (1.0 / t_0) / t_0 return tmp
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(c * Float64(x * s)) tmp = 0.0 if (s <= 1.05e-197) tmp = Float64(Float64(1.0 / Float64(s * Float64(s * Float64(x * c)))) * Float64(Float64(-2.0 * Float64(x / c)) + Float64(1.0 / Float64(x * c)))); else tmp = Float64(Float64(1.0 / t_0) / t_0); end return tmp end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = c * (x * s);
tmp = 0.0;
if (s <= 1.05e-197)
tmp = (1.0 / (s * (s * (x * c)))) * ((-2.0 * (x / c)) + (1.0 / (x * c)));
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: s 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.05e-197], N[(N[(1.0 / N[(s * N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(-2.0 * N[(x / c), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\mathbf{if}\;s \leq 1.05 \cdot 10^{-197}:\\
\;\;\;\;\frac{1}{s \cdot \left(s \cdot \left(x \cdot c\right)\right)} \cdot \left(-2 \cdot \frac{x}{c} + \frac{1}{x \cdot c}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{t_0}}{t_0}\\
\end{array}
\end{array}
if s < 1.05e-197Initial program 67.9%
*-commutative67.9%
associate-*r*59.0%
associate-*r*59.1%
unpow259.1%
unswap-sqr83.8%
unpow283.8%
swap-sqr98.4%
*-commutative98.4%
*-commutative98.4%
*-commutative98.4%
*-commutative98.4%
Simplified98.4%
*-un-lft-identity98.4%
associate-*r*96.0%
times-frac96.0%
*-commutative96.0%
Applied egg-rr96.0%
Taylor expanded in x around 0 79.2%
if 1.05e-197 < s Initial program 72.5%
*-commutative72.5%
associate-*r*63.4%
associate-*r*65.2%
unpow265.2%
unswap-sqr82.3%
unpow282.4%
swap-sqr97.0%
*-commutative97.0%
*-commutative97.0%
*-commutative97.0%
*-commutative97.0%
Simplified97.0%
Taylor expanded in x around inf 63.4%
*-commutative63.4%
unpow263.4%
unpow263.4%
*-commutative63.4%
unpow263.4%
swap-sqr83.1%
swap-sqr96.8%
unpow296.8%
rem-exp-log85.0%
log-div65.0%
log-pow38.0%
*-commutative38.0%
*-commutative38.0%
associate-*r*38.2%
cancel-sign-sub-inv38.2%
Simplified96.8%
metadata-eval96.8%
pow-flip96.8%
unpow296.8%
*-commutative96.8%
associate-*r*94.3%
*-commutative94.3%
div-inv94.4%
associate-/r*94.3%
*-commutative94.3%
associate-*r*96.9%
*-commutative96.9%
Applied egg-rr96.9%
Taylor expanded in x around 0 80.4%
Final simplification79.7%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s 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 (* c (* (* x s) (* c (* x s))))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return 1.0 / (c * ((x * s) * (c * (x * s))));
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s 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 / (c * ((x * s) * (c * (x * s))))
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return 1.0 / (c * ((x * s) * (c * (x * s))));
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return 1.0 / (c * ((x * s) * (c * (x * s))))
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(1.0 / Float64(c * Float64(Float64(x * s) * Float64(c * Float64(x * s))))) end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = 1.0 / (c * ((x * s) * (c * (x * s))));
end
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s 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[(c * N[(N[(x * s), $MachinePrecision] * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{c \cdot \left(\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)}
\end{array}
Initial program 69.7%
*-commutative69.7%
associate-*r*60.7%
associate-*r*61.5%
unpow261.5%
unswap-sqr83.2%
unpow283.2%
swap-sqr97.8%
*-commutative97.8%
*-commutative97.8%
*-commutative97.8%
*-commutative97.8%
Simplified97.8%
Taylor expanded in x around 0 56.6%
unpow256.6%
unpow256.6%
*-commutative56.6%
unpow256.6%
swap-sqr70.4%
swap-sqr82.9%
unpow282.9%
*-commutative82.9%
Simplified82.9%
unpow282.9%
*-commutative82.9%
associate-*r*81.6%
associate-*l*80.5%
associate-*r*81.8%
*-commutative81.8%
Applied egg-rr81.8%
Final simplification81.8%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s 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);
s = abs(s);
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: s 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);
s = Math.abs(s);
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) s = abs(s) [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) s = abs(s) 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)
s = abs(s)
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: s 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|\\
s = |s|\\
[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 69.7%
*-commutative69.7%
associate-*r*60.7%
associate-*r*61.5%
unpow261.5%
unswap-sqr83.2%
unpow283.2%
swap-sqr97.8%
*-commutative97.8%
*-commutative97.8%
*-commutative97.8%
*-commutative97.8%
Simplified97.8%
Taylor expanded in x around 0 56.6%
unpow256.6%
unpow256.6%
*-commutative56.6%
unpow256.6%
swap-sqr70.4%
swap-sqr82.9%
unpow282.9%
*-commutative82.9%
Simplified82.9%
unpow282.9%
Applied egg-rr82.9%
Final simplification82.9%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s 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);
s = abs(s);
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: s 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);
s = Math.abs(s);
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) s = abs(s) [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) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(c * Float64(x * s)) return Float64(Float64(1.0 / t_0) / t_0) end
x = abs(x)
c = abs(c)
s = abs(s)
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: s 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[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\frac{\frac{1}{t_0}}{t_0}
\end{array}
\end{array}
Initial program 69.7%
*-commutative69.7%
associate-*r*60.7%
associate-*r*61.5%
unpow261.5%
unswap-sqr83.2%
unpow283.2%
swap-sqr97.8%
*-commutative97.8%
*-commutative97.8%
*-commutative97.8%
*-commutative97.8%
Simplified97.8%
Taylor expanded in x around inf 60.7%
*-commutative60.7%
unpow260.7%
unpow260.7%
*-commutative60.7%
unpow260.7%
swap-sqr79.4%
swap-sqr97.9%
unpow297.9%
rem-exp-log86.0%
log-div71.5%
log-pow45.2%
*-commutative45.2%
*-commutative45.2%
associate-*r*44.0%
cancel-sign-sub-inv44.0%
Simplified98.0%
metadata-eval98.0%
pow-flip97.8%
unpow297.8%
*-commutative97.8%
associate-*r*96.2%
*-commutative96.2%
div-inv96.3%
associate-/r*96.3%
*-commutative96.3%
associate-*r*98.0%
*-commutative98.0%
Applied egg-rr98.0%
Taylor expanded in x around 0 83.0%
Final simplification83.0%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s 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);
s = abs(s);
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: s 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);
s = Math.abs(s);
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) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return -2.0 / ((s * s) * (c * c))
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(-2.0 / Float64(Float64(s * s) * Float64(c * c))) end
x = abs(x)
c = abs(c)
s = abs(s)
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: s 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[(N[(s * s), $MachinePrecision] * N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{-2}{\left(s \cdot s\right) \cdot \left(c \cdot c\right)}
\end{array}
Initial program 69.7%
*-commutative69.7%
associate-*r*60.7%
associate-*r*61.5%
unpow261.5%
unswap-sqr83.2%
unpow283.2%
swap-sqr97.8%
*-commutative97.8%
*-commutative97.8%
*-commutative97.8%
*-commutative97.8%
Simplified97.8%
Taylor expanded in x around 0 35.9%
unpow236.0%
*-commutative36.0%
associate-*r*36.2%
unpow236.2%
unpow236.2%
associate-*r/36.2%
metadata-eval36.2%
unpow236.2%
unpow236.2%
Simplified36.2%
Taylor expanded in x around inf 35.0%
unpow235.0%
unpow235.0%
Simplified35.0%
Final simplification35.0%
herbie shell --seed 2023222
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))