
(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 14 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: 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 (* s x)))) (* (/ 1.0 t_0) (/ (- (pow (cos x) 2.0) (pow (sin x) 2.0)) t_0))))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = c * (s * x);
return (1.0 / t_0) * ((pow(cos(x), 2.0) - pow(sin(x), 2.0)) / t_0);
}
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 * (s * x)
code = (1.0d0 / t_0) * (((cos(x) ** 2.0d0) - (sin(x) ** 2.0d0)) / t_0)
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = c * (s * x);
return (1.0 / t_0) * ((Math.pow(Math.cos(x), 2.0) - Math.pow(Math.sin(x), 2.0)) / t_0);
}
s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = c * (s * x) return (1.0 / t_0) * ((math.pow(math.cos(x), 2.0) - math.pow(math.sin(x), 2.0)) / t_0)
s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(c * Float64(s * x)) return Float64(Float64(1.0 / t_0) * Float64(Float64((cos(x) ^ 2.0) - (sin(x) ^ 2.0)) / t_0)) end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
t_0 = c * (s * x);
tmp = (1.0 / t_0) * (((cos(x) ^ 2.0) - (sin(x) ^ 2.0)) / t_0);
end
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[(s * x), $MachinePrecision]), $MachinePrecision]}, N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(N[(N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(s \cdot x\right)\\
\frac{1}{t_0} \cdot \frac{{\cos x}^{2} - {\sin x}^{2}}{t_0}
\end{array}
\end{array}
Initial program 64.1%
associate-/r*63.8%
remove-double-neg63.8%
distribute-lft-neg-out63.8%
distribute-lft-neg-out63.8%
distribute-rgt-neg-out63.8%
associate-/r*64.1%
unpow264.1%
*-commutative64.1%
associate-*r*58.2%
sqr-neg58.2%
associate-*r*64.1%
unpow264.1%
Simplified64.1%
associate-*r*58.2%
*-commutative58.2%
associate-*l*59.0%
swap-sqr76.3%
*-commutative76.3%
add-sqr-sqrt76.3%
*-un-lft-identity76.3%
times-frac76.3%
Applied egg-rr97.7%
*-commutative97.7%
cos-298.0%
sub-neg98.0%
pow298.0%
pow298.0%
Applied egg-rr98.0%
sub-neg98.0%
Simplified98.0%
Final simplification98.0%
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 (cos (* x 2.0))))
(if (<= x 1.4e-38)
(* (/ 1.0 (* c (* s x))) (/ (/ 1.0 (* s x)) c))
(if (<= x 8.2e+65)
(/ t_0 (* (* x x) (* (* c s) (* c s))))
(/ t_0 (* x (* x (* c (* c (* s s))))))))))s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = cos((x * 2.0));
double tmp;
if (x <= 1.4e-38) {
tmp = (1.0 / (c * (s * x))) * ((1.0 / (s * x)) / c);
} else if (x <= 8.2e+65) {
tmp = t_0 / ((x * x) * ((c * s) * (c * s)));
} else {
tmp = t_0 / (x * (x * (c * (c * (s * s)))));
}
return tmp;
}
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 = cos((x * 2.0d0))
if (x <= 1.4d-38) then
tmp = (1.0d0 / (c * (s * x))) * ((1.0d0 / (s * x)) / c)
else if (x <= 8.2d+65) then
tmp = t_0 / ((x * x) * ((c * s) * (c * s)))
else
tmp = t_0 / (x * (x * (c * (c * (s * s)))))
end if
code = tmp
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = Math.cos((x * 2.0));
double tmp;
if (x <= 1.4e-38) {
tmp = (1.0 / (c * (s * x))) * ((1.0 / (s * x)) / c);
} else if (x <= 8.2e+65) {
tmp = t_0 / ((x * x) * ((c * s) * (c * s)));
} else {
tmp = t_0 / (x * (x * (c * (c * (s * s)))));
}
return tmp;
}
s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = math.cos((x * 2.0)) tmp = 0 if x <= 1.4e-38: tmp = (1.0 / (c * (s * x))) * ((1.0 / (s * x)) / c) elif x <= 8.2e+65: tmp = t_0 / ((x * x) * ((c * s) * (c * s))) else: tmp = t_0 / (x * (x * (c * (c * (s * s))))) return tmp
s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = cos(Float64(x * 2.0)) tmp = 0.0 if (x <= 1.4e-38) tmp = Float64(Float64(1.0 / Float64(c * Float64(s * x))) * Float64(Float64(1.0 / Float64(s * x)) / c)); elseif (x <= 8.2e+65) tmp = Float64(t_0 / Float64(Float64(x * x) * Float64(Float64(c * s) * Float64(c * s)))); else tmp = Float64(t_0 / Float64(x * Float64(x * Float64(c * Float64(c * Float64(s * s)))))); end return tmp end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = cos((x * 2.0));
tmp = 0.0;
if (x <= 1.4e-38)
tmp = (1.0 / (c * (s * x))) * ((1.0 / (s * x)) / c);
elseif (x <= 8.2e+65)
tmp = t_0 / ((x * x) * ((c * s) * (c * s)));
else
tmp = t_0 / (x * (x * (c * (c * (s * s)))));
end
tmp_2 = tmp;
end
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[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 1.4e-38], N[(N[(1.0 / N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / N[(s * x), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8.2e+65], N[(t$95$0 / N[(N[(x * x), $MachinePrecision] * N[(N[(c * s), $MachinePrecision] * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[(x * N[(x * N[(c * N[(c * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \cos \left(x \cdot 2\right)\\
\mathbf{if}\;x \leq 1.4 \cdot 10^{-38}:\\
\;\;\;\;\frac{1}{c \cdot \left(s \cdot x\right)} \cdot \frac{\frac{1}{s \cdot x}}{c}\\
\mathbf{elif}\;x \leq 8.2 \cdot 10^{+65}:\\
\;\;\;\;\frac{t_0}{\left(x \cdot x\right) \cdot \left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{x \cdot \left(x \cdot \left(c \cdot \left(c \cdot \left(s \cdot s\right)\right)\right)\right)}\\
\end{array}
\end{array}
if x < 1.4e-38Initial program 63.5%
associate-/r*63.5%
remove-double-neg63.5%
distribute-lft-neg-out63.5%
distribute-lft-neg-out63.5%
distribute-rgt-neg-out63.5%
associate-/r*63.5%
unpow263.5%
*-commutative63.5%
associate-*r*55.9%
sqr-neg55.9%
associate-*r*63.5%
unpow263.5%
Simplified63.5%
associate-*r*55.9%
*-commutative55.9%
associate-*l*57.0%
swap-sqr74.4%
*-commutative74.4%
add-sqr-sqrt74.4%
*-un-lft-identity74.4%
times-frac74.4%
Applied egg-rr97.0%
Taylor expanded in x around 0 85.4%
*-commutative85.4%
associate-/r*85.5%
Simplified85.5%
if 1.4e-38 < x < 8.2000000000000003e65Initial program 90.7%
associate-/r*90.7%
*-commutative90.7%
associate-*l*90.7%
unpow290.7%
unpow290.7%
associate-*r*90.7%
associate-/r*95.1%
associate-/l/95.0%
associate-/l/95.3%
*-commutative95.3%
associate-*l*91.1%
unpow291.1%
associate-*l*90.8%
unpow290.8%
unswap-sqr95.5%
*-commutative95.5%
*-commutative95.5%
Simplified95.5%
if 8.2000000000000003e65 < x Initial program 55.5%
associate-/r*53.6%
remove-double-neg53.6%
distribute-lft-neg-out53.6%
distribute-lft-neg-out53.6%
distribute-rgt-neg-out53.6%
associate-/l/55.5%
distribute-rgt-neg-out55.5%
distribute-lft-neg-out55.5%
associate-*l*57.3%
distribute-lft-neg-in57.3%
distribute-lft-neg-out57.3%
remove-double-neg57.3%
associate-*r*57.4%
*-commutative57.4%
associate-*r*55.4%
Simplified67.1%
Final simplification82.6%
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 (cos (* x 2.0))))
(if (<= x 1e-42)
(* (/ 1.0 (* c (* s x))) (/ (/ 1.0 (* s x)) c))
(if (<= x 1e+127)
(/ t_0 (* (* x x) (* (* c s) (* c s))))
(/ (/ t_0 (* s (* s x))) (* c (* c x)))))))s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = cos((x * 2.0));
double tmp;
if (x <= 1e-42) {
tmp = (1.0 / (c * (s * x))) * ((1.0 / (s * x)) / c);
} else if (x <= 1e+127) {
tmp = t_0 / ((x * x) * ((c * s) * (c * s)));
} else {
tmp = (t_0 / (s * (s * x))) / (c * (c * x));
}
return tmp;
}
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 = cos((x * 2.0d0))
if (x <= 1d-42) then
tmp = (1.0d0 / (c * (s * x))) * ((1.0d0 / (s * x)) / c)
else if (x <= 1d+127) then
tmp = t_0 / ((x * x) * ((c * s) * (c * s)))
else
tmp = (t_0 / (s * (s * x))) / (c * (c * x))
end if
code = tmp
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = Math.cos((x * 2.0));
double tmp;
if (x <= 1e-42) {
tmp = (1.0 / (c * (s * x))) * ((1.0 / (s * x)) / c);
} else if (x <= 1e+127) {
tmp = t_0 / ((x * x) * ((c * s) * (c * s)));
} else {
tmp = (t_0 / (s * (s * x))) / (c * (c * x));
}
return tmp;
}
s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = math.cos((x * 2.0)) tmp = 0 if x <= 1e-42: tmp = (1.0 / (c * (s * x))) * ((1.0 / (s * x)) / c) elif x <= 1e+127: tmp = t_0 / ((x * x) * ((c * s) * (c * s))) else: tmp = (t_0 / (s * (s * x))) / (c * (c * x)) return tmp
s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = cos(Float64(x * 2.0)) tmp = 0.0 if (x <= 1e-42) tmp = Float64(Float64(1.0 / Float64(c * Float64(s * x))) * Float64(Float64(1.0 / Float64(s * x)) / c)); elseif (x <= 1e+127) tmp = Float64(t_0 / Float64(Float64(x * x) * Float64(Float64(c * s) * Float64(c * s)))); else tmp = Float64(Float64(t_0 / Float64(s * Float64(s * x))) / Float64(c * Float64(c * x))); end return tmp end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = cos((x * 2.0));
tmp = 0.0;
if (x <= 1e-42)
tmp = (1.0 / (c * (s * x))) * ((1.0 / (s * x)) / c);
elseif (x <= 1e+127)
tmp = t_0 / ((x * x) * ((c * s) * (c * s)));
else
tmp = (t_0 / (s * (s * x))) / (c * (c * x));
end
tmp_2 = tmp;
end
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[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 1e-42], N[(N[(1.0 / N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / N[(s * x), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1e+127], N[(t$95$0 / N[(N[(x * x), $MachinePrecision] * N[(N[(c * s), $MachinePrecision] * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / N[(s * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c * N[(c * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \cos \left(x \cdot 2\right)\\
\mathbf{if}\;x \leq 10^{-42}:\\
\;\;\;\;\frac{1}{c \cdot \left(s \cdot x\right)} \cdot \frac{\frac{1}{s \cdot x}}{c}\\
\mathbf{elif}\;x \leq 10^{+127}:\\
\;\;\;\;\frac{t_0}{\left(x \cdot x\right) \cdot \left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t_0}{s \cdot \left(s \cdot x\right)}}{c \cdot \left(c \cdot x\right)}\\
\end{array}
\end{array}
if x < 1.00000000000000004e-42Initial program 63.5%
associate-/r*63.5%
remove-double-neg63.5%
distribute-lft-neg-out63.5%
distribute-lft-neg-out63.5%
distribute-rgt-neg-out63.5%
associate-/r*63.5%
unpow263.5%
*-commutative63.5%
associate-*r*55.9%
sqr-neg55.9%
associate-*r*63.5%
unpow263.5%
Simplified63.5%
associate-*r*55.9%
*-commutative55.9%
associate-*l*57.0%
swap-sqr74.4%
*-commutative74.4%
add-sqr-sqrt74.4%
*-un-lft-identity74.4%
times-frac74.4%
Applied egg-rr97.0%
Taylor expanded in x around 0 85.4%
*-commutative85.4%
associate-/r*85.5%
Simplified85.5%
if 1.00000000000000004e-42 < x < 9.99999999999999955e126Initial program 91.1%
associate-/r*91.1%
*-commutative91.1%
associate-*l*91.1%
unpow291.1%
unpow291.1%
associate-*r*94.0%
associate-/r*96.8%
associate-/l/96.7%
associate-/l/96.9%
*-commutative96.9%
associate-*l*94.2%
unpow294.2%
associate-*l*91.2%
unpow291.2%
unswap-sqr97.1%
*-commutative97.1%
*-commutative97.1%
Simplified97.1%
if 9.99999999999999955e126 < x Initial program 44.4%
associate-/r*41.9%
remove-double-neg41.9%
distribute-lft-neg-out41.9%
distribute-lft-neg-out41.9%
distribute-rgt-neg-out41.9%
associate-/r*44.4%
unpow244.4%
*-commutative44.4%
associate-*r*41.6%
sqr-neg41.6%
associate-*r*44.4%
unpow244.4%
Simplified44.4%
Taylor expanded in x around 0 44.4%
unpow244.4%
associate-*r*74.6%
Simplified74.6%
*-un-lft-identity74.6%
associate-*r*72.2%
times-frac72.2%
*-commutative72.2%
Applied egg-rr72.2%
associate-*l/72.3%
*-lft-identity72.3%
associate-*l*86.5%
Simplified86.5%
Final simplification87.1%
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 30.0) (* (/ 1.0 (* c (* s x))) (/ (+ (/ 1.0 (* s x)) (* -2.0 (/ x s))) c)) (/ (cos (* x 2.0)) (* x (* x (* c (* c (* s s))))))))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double tmp;
if (x <= 30.0) {
tmp = (1.0 / (c * (s * x))) * (((1.0 / (s * x)) + (-2.0 * (x / s))) / c);
} else {
tmp = cos((x * 2.0)) / (x * (x * (c * (c * (s * s)))));
}
return tmp;
}
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 <= 30.0d0) then
tmp = (1.0d0 / (c * (s * x))) * (((1.0d0 / (s * x)) + ((-2.0d0) * (x / s))) / c)
else
tmp = cos((x * 2.0d0)) / (x * (x * (c * (c * (s * s)))))
end if
code = tmp
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double tmp;
if (x <= 30.0) {
tmp = (1.0 / (c * (s * x))) * (((1.0 / (s * x)) + (-2.0 * (x / s))) / c);
} else {
tmp = Math.cos((x * 2.0)) / (x * (x * (c * (c * (s * s)))));
}
return tmp;
}
s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): tmp = 0 if x <= 30.0: tmp = (1.0 / (c * (s * x))) * (((1.0 / (s * x)) + (-2.0 * (x / s))) / c) else: tmp = math.cos((x * 2.0)) / (x * (x * (c * (c * (s * s))))) return tmp
s = abs(s) c, s = sort([c, s]) function code(x, c, s) tmp = 0.0 if (x <= 30.0) tmp = Float64(Float64(1.0 / Float64(c * Float64(s * x))) * Float64(Float64(Float64(1.0 / Float64(s * x)) + Float64(-2.0 * Float64(x / s))) / c)); else tmp = Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(x * Float64(c * Float64(c * Float64(s * s)))))); end return tmp end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
tmp = 0.0;
if (x <= 30.0)
tmp = (1.0 / (c * (s * x))) * (((1.0 / (s * x)) + (-2.0 * (x / s))) / c);
else
tmp = cos((x * 2.0)) / (x * (x * (c * (c * (s * s)))));
end
tmp_2 = tmp;
end
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, 30.0], N[(N[(1.0 / N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(1.0 / N[(s * x), $MachinePrecision]), $MachinePrecision] + N[(-2.0 * N[(x / s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * N[(x * N[(c * N[(c * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 30:\\
\;\;\;\;\frac{1}{c \cdot \left(s \cdot x\right)} \cdot \frac{\frac{1}{s \cdot x} + -2 \cdot \frac{x}{s}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(x \cdot \left(c \cdot \left(c \cdot \left(s \cdot s\right)\right)\right)\right)}\\
\end{array}
\end{array}
if x < 30Initial program 64.1%
associate-/r*64.1%
remove-double-neg64.1%
distribute-lft-neg-out64.1%
distribute-lft-neg-out64.1%
distribute-rgt-neg-out64.1%
associate-/r*64.1%
unpow264.1%
*-commutative64.1%
associate-*r*56.7%
sqr-neg56.7%
associate-*r*64.1%
unpow264.1%
Simplified64.1%
associate-*r*56.7%
*-commutative56.7%
associate-*l*57.8%
swap-sqr75.2%
*-commutative75.2%
add-sqr-sqrt75.2%
*-un-lft-identity75.2%
times-frac75.2%
Applied egg-rr97.1%
Taylor expanded in x around 0 72.6%
Taylor expanded in c around 0 80.0%
if 30 < x Initial program 64.2%
associate-/r*62.7%
remove-double-neg62.7%
distribute-lft-neg-out62.7%
distribute-lft-neg-out62.7%
distribute-rgt-neg-out62.7%
associate-/l/64.2%
distribute-rgt-neg-out64.2%
distribute-lft-neg-out64.2%
associate-*l*65.5%
distribute-lft-neg-in65.5%
distribute-lft-neg-out65.5%
remove-double-neg65.5%
associate-*r*65.6%
*-commutative65.6%
associate-*r*64.1%
Simplified73.1%
Final simplification78.2%
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 (* s x)))) (* (/ 1.0 t_0) (/ (cos (* x 2.0)) t_0))))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = c * (s * x);
return (1.0 / t_0) * (cos((x * 2.0)) / t_0);
}
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 * (s * x)
code = (1.0d0 / t_0) * (cos((x * 2.0d0)) / t_0)
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = c * (s * x);
return (1.0 / t_0) * (Math.cos((x * 2.0)) / t_0);
}
s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = c * (s * x) return (1.0 / t_0) * (math.cos((x * 2.0)) / t_0)
s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(c * Float64(s * x)) return Float64(Float64(1.0 / t_0) * Float64(cos(Float64(x * 2.0)) / t_0)) end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
t_0 = c * (s * x);
tmp = (1.0 / t_0) * (cos((x * 2.0)) / t_0);
end
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[(s * x), $MachinePrecision]), $MachinePrecision]}, N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(s \cdot x\right)\\
\frac{1}{t_0} \cdot \frac{\cos \left(x \cdot 2\right)}{t_0}
\end{array}
\end{array}
Initial program 64.1%
associate-/r*63.8%
remove-double-neg63.8%
distribute-lft-neg-out63.8%
distribute-lft-neg-out63.8%
distribute-rgt-neg-out63.8%
associate-/r*64.1%
unpow264.1%
*-commutative64.1%
associate-*r*58.2%
sqr-neg58.2%
associate-*r*64.1%
unpow264.1%
Simplified64.1%
associate-*r*58.2%
*-commutative58.2%
associate-*l*59.0%
swap-sqr76.3%
*-commutative76.3%
add-sqr-sqrt76.3%
*-un-lft-identity76.3%
times-frac76.3%
Applied egg-rr97.7%
Final simplification97.7%
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 (* s x))) (/ (/ (cos (* x 2.0)) (* s x)) c)))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return (1.0 / (c * (s * x))) * ((cos((x * 2.0)) / (s * x)) / c);
}
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 * (s * x))) * ((cos((x * 2.0d0)) / (s * x)) / c)
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return (1.0 / (c * (s * x))) * ((Math.cos((x * 2.0)) / (s * x)) / c);
}
s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return (1.0 / (c * (s * x))) * ((math.cos((x * 2.0)) / (s * x)) / c)
s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(Float64(1.0 / Float64(c * Float64(s * x))) * Float64(Float64(cos(Float64(x * 2.0)) / Float64(s * x)) / c)) end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = (1.0 / (c * (s * x))) * ((cos((x * 2.0)) / (s * x)) / c);
end
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[(1.0 / N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(s * x), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{c \cdot \left(s \cdot x\right)} \cdot \frac{\frac{\cos \left(x \cdot 2\right)}{s \cdot x}}{c}
\end{array}
Initial program 64.1%
associate-/r*63.8%
remove-double-neg63.8%
distribute-lft-neg-out63.8%
distribute-lft-neg-out63.8%
distribute-rgt-neg-out63.8%
associate-/r*64.1%
unpow264.1%
*-commutative64.1%
associate-*r*58.2%
sqr-neg58.2%
associate-*r*64.1%
unpow264.1%
Simplified64.1%
associate-*r*58.2%
*-commutative58.2%
associate-*l*59.0%
swap-sqr76.3%
*-commutative76.3%
add-sqr-sqrt76.3%
*-un-lft-identity76.3%
times-frac76.3%
Applied egg-rr97.7%
*-commutative97.7%
*-un-lft-identity97.7%
times-frac97.7%
*-commutative97.7%
Applied egg-rr97.7%
associate-*l/97.8%
*-un-lft-identity97.8%
*-commutative97.8%
Applied egg-rr97.8%
Final simplification97.8%
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 (<= c 2e-142) (* (/ 1.0 x) (/ 1.0 (* x (* (* c s) (* c s))))) (/ (/ (- -1.0) (* s x)) (* (* s x) (* c c)))))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double tmp;
if (c <= 2e-142) {
tmp = (1.0 / x) * (1.0 / (x * ((c * s) * (c * s))));
} else {
tmp = (-(-1.0) / (s * x)) / ((s * x) * (c * c));
}
return tmp;
}
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 (c <= 2d-142) then
tmp = (1.0d0 / x) * (1.0d0 / (x * ((c * s) * (c * s))))
else
tmp = (-(-1.0d0) / (s * x)) / ((s * x) * (c * c))
end if
code = tmp
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double tmp;
if (c <= 2e-142) {
tmp = (1.0 / x) * (1.0 / (x * ((c * s) * (c * s))));
} else {
tmp = (-(-1.0) / (s * x)) / ((s * x) * (c * c));
}
return tmp;
}
s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): tmp = 0 if c <= 2e-142: tmp = (1.0 / x) * (1.0 / (x * ((c * s) * (c * s)))) else: tmp = (-(-1.0) / (s * x)) / ((s * x) * (c * c)) return tmp
s = abs(s) c, s = sort([c, s]) function code(x, c, s) tmp = 0.0 if (c <= 2e-142) tmp = Float64(Float64(1.0 / x) * Float64(1.0 / Float64(x * Float64(Float64(c * s) * Float64(c * s))))); else tmp = Float64(Float64(Float64(-(-1.0)) / Float64(s * x)) / Float64(Float64(s * x) * Float64(c * c))); end return tmp end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
tmp = 0.0;
if (c <= 2e-142)
tmp = (1.0 / x) * (1.0 / (x * ((c * s) * (c * s))));
else
tmp = (-(-1.0) / (s * x)) / ((s * x) * (c * c));
end
tmp_2 = tmp;
end
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[c, 2e-142], N[(N[(1.0 / x), $MachinePrecision] * N[(1.0 / N[(x * N[(N[(c * s), $MachinePrecision] * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((--1.0) / N[(s * x), $MachinePrecision]), $MachinePrecision] / N[(N[(s * x), $MachinePrecision] * N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;c \leq 2 \cdot 10^{-142}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{1}{x \cdot \left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{--1}{s \cdot x}}{\left(s \cdot x\right) \cdot \left(c \cdot c\right)}\\
\end{array}
\end{array}
if c < 2.0000000000000001e-142Initial program 66.8%
associate-/r*66.1%
remove-double-neg66.1%
distribute-lft-neg-out66.1%
distribute-lft-neg-out66.1%
distribute-rgt-neg-out66.1%
associate-/r*66.8%
unpow266.8%
*-commutative66.8%
associate-*r*60.1%
sqr-neg60.1%
associate-*r*66.8%
unpow266.8%
Simplified66.8%
Taylor expanded in x around 0 66.8%
unpow266.8%
associate-*r*77.8%
Simplified77.8%
associate-*r*77.8%
*-commutative77.8%
swap-sqr97.4%
pow297.4%
associate-*r*97.0%
add-sqr-sqrt41.9%
associate-*r*41.9%
add-sqr-sqrt27.0%
sqrt-prod38.4%
unpow238.4%
sqrt-prod38.4%
*-commutative38.4%
sqrt-prod88.9%
*-commutative88.9%
pow288.9%
add-sqr-sqrt88.9%
Applied egg-rr88.9%
Taylor expanded in x around 0 76.7%
unpow276.7%
Applied egg-rr76.7%
if 2.0000000000000001e-142 < c Initial program 59.1%
associate-/r*59.2%
remove-double-neg59.2%
distribute-lft-neg-out59.2%
distribute-lft-neg-out59.2%
distribute-rgt-neg-out59.2%
associate-/r*59.1%
unpow259.1%
*-commutative59.1%
associate-*r*54.6%
sqr-neg54.6%
associate-*r*59.1%
unpow259.1%
Simplified59.1%
associate-*r*54.6%
*-commutative54.6%
associate-*l*55.9%
swap-sqr77.5%
*-commutative77.5%
add-sqr-sqrt77.5%
*-un-lft-identity77.5%
times-frac77.4%
Applied egg-rr97.2%
Taylor expanded in x around 0 73.2%
Taylor expanded in c around -inf 54.0%
mul-1-neg54.0%
associate-*r/54.0%
*-commutative54.0%
*-commutative54.0%
unpow254.0%
Simplified54.0%
Taylor expanded in x around 0 64.6%
Final simplification72.6%
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 (<= c 1.1e-142) (/ 1.0 (* (* x x) (* (* c s) (* c s)))) (/ (/ (- -1.0) (* s x)) (* (* s x) (* c c)))))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double tmp;
if (c <= 1.1e-142) {
tmp = 1.0 / ((x * x) * ((c * s) * (c * s)));
} else {
tmp = (-(-1.0) / (s * x)) / ((s * x) * (c * c));
}
return tmp;
}
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 (c <= 1.1d-142) then
tmp = 1.0d0 / ((x * x) * ((c * s) * (c * s)))
else
tmp = (-(-1.0d0) / (s * x)) / ((s * x) * (c * c))
end if
code = tmp
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double tmp;
if (c <= 1.1e-142) {
tmp = 1.0 / ((x * x) * ((c * s) * (c * s)));
} else {
tmp = (-(-1.0) / (s * x)) / ((s * x) * (c * c));
}
return tmp;
}
s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): tmp = 0 if c <= 1.1e-142: tmp = 1.0 / ((x * x) * ((c * s) * (c * s))) else: tmp = (-(-1.0) / (s * x)) / ((s * x) * (c * c)) return tmp
s = abs(s) c, s = sort([c, s]) function code(x, c, s) tmp = 0.0 if (c <= 1.1e-142) tmp = Float64(1.0 / Float64(Float64(x * x) * Float64(Float64(c * s) * Float64(c * s)))); else tmp = Float64(Float64(Float64(-(-1.0)) / Float64(s * x)) / Float64(Float64(s * x) * Float64(c * c))); end return tmp end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
tmp = 0.0;
if (c <= 1.1e-142)
tmp = 1.0 / ((x * x) * ((c * s) * (c * s)));
else
tmp = (-(-1.0) / (s * x)) / ((s * x) * (c * c));
end
tmp_2 = tmp;
end
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[c, 1.1e-142], N[(1.0 / N[(N[(x * x), $MachinePrecision] * N[(N[(c * s), $MachinePrecision] * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((--1.0) / N[(s * x), $MachinePrecision]), $MachinePrecision] / N[(N[(s * x), $MachinePrecision] * N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;c \leq 1.1 \cdot 10^{-142}:\\
\;\;\;\;\frac{1}{\left(x \cdot x\right) \cdot \left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{--1}{s \cdot x}}{\left(s \cdot x\right) \cdot \left(c \cdot c\right)}\\
\end{array}
\end{array}
if c < 1.10000000000000008e-142Initial program 66.8%
associate-/r*66.1%
*-commutative66.1%
associate-*l*59.4%
unpow259.4%
unpow259.4%
associate-*r*65.0%
associate-/r*65.7%
associate-/l/66.8%
associate-/l/66.8%
*-commutative66.8%
associate-*l*66.2%
unpow266.2%
associate-*l*60.7%
unpow260.7%
unswap-sqr75.7%
*-commutative75.7%
*-commutative75.7%
Simplified75.7%
Taylor expanded in x around 0 67.9%
if 1.10000000000000008e-142 < c Initial program 59.1%
associate-/r*59.2%
remove-double-neg59.2%
distribute-lft-neg-out59.2%
distribute-lft-neg-out59.2%
distribute-rgt-neg-out59.2%
associate-/r*59.1%
unpow259.1%
*-commutative59.1%
associate-*r*54.6%
sqr-neg54.6%
associate-*r*59.1%
unpow259.1%
Simplified59.1%
associate-*r*54.6%
*-commutative54.6%
associate-*l*55.9%
swap-sqr77.5%
*-commutative77.5%
add-sqr-sqrt77.5%
*-un-lft-identity77.5%
times-frac77.4%
Applied egg-rr97.2%
Taylor expanded in x around 0 73.2%
Taylor expanded in c around -inf 54.0%
mul-1-neg54.0%
associate-*r/54.0%
*-commutative54.0%
*-commutative54.0%
unpow254.0%
Simplified54.0%
Taylor expanded in x around 0 64.6%
Final simplification66.8%
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 4.6e-60) (/ 1.0 (* (* c c) (* x (* s (* s x))))) (/ 1.0 (* x (* x (* c (* c (* s s))))))))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double tmp;
if (x <= 4.6e-60) {
tmp = 1.0 / ((c * c) * (x * (s * (s * x))));
} else {
tmp = 1.0 / (x * (x * (c * (c * (s * s)))));
}
return tmp;
}
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 <= 4.6d-60) then
tmp = 1.0d0 / ((c * c) * (x * (s * (s * x))))
else
tmp = 1.0d0 / (x * (x * (c * (c * (s * s)))))
end if
code = tmp
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double tmp;
if (x <= 4.6e-60) {
tmp = 1.0 / ((c * c) * (x * (s * (s * x))));
} else {
tmp = 1.0 / (x * (x * (c * (c * (s * s)))));
}
return tmp;
}
s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): tmp = 0 if x <= 4.6e-60: tmp = 1.0 / ((c * c) * (x * (s * (s * x)))) else: tmp = 1.0 / (x * (x * (c * (c * (s * s))))) return tmp
s = abs(s) c, s = sort([c, s]) function code(x, c, s) tmp = 0.0 if (x <= 4.6e-60) tmp = Float64(1.0 / Float64(Float64(c * c) * Float64(x * Float64(s * Float64(s * x))))); else tmp = Float64(1.0 / Float64(x * Float64(x * Float64(c * Float64(c * Float64(s * s)))))); end return tmp end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
tmp = 0.0;
if (x <= 4.6e-60)
tmp = 1.0 / ((c * c) * (x * (s * (s * x))));
else
tmp = 1.0 / (x * (x * (c * (c * (s * s)))));
end
tmp_2 = tmp;
end
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, 4.6e-60], N[(1.0 / N[(N[(c * c), $MachinePrecision] * N[(x * N[(s * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(x * N[(x * N[(c * N[(c * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.6 \cdot 10^{-60}:\\
\;\;\;\;\frac{1}{\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot \left(s \cdot x\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \left(x \cdot \left(c \cdot \left(c \cdot \left(s \cdot s\right)\right)\right)\right)}\\
\end{array}
\end{array}
if x < 4.6000000000000003e-60Initial program 63.6%
associate-/r*63.6%
remove-double-neg63.6%
distribute-lft-neg-out63.6%
distribute-lft-neg-out63.6%
distribute-rgt-neg-out63.6%
associate-/r*63.6%
unpow263.6%
*-commutative63.6%
associate-*r*55.7%
sqr-neg55.7%
associate-*r*63.6%
unpow263.6%
Simplified63.6%
Taylor expanded in x around 0 63.6%
unpow263.6%
associate-*r*73.4%
Simplified73.4%
Taylor expanded in x around 0 67.4%
if 4.6000000000000003e-60 < x Initial program 65.5%
associate-/r*64.2%
remove-double-neg64.2%
distribute-lft-neg-out64.2%
distribute-lft-neg-out64.2%
distribute-rgt-neg-out64.2%
associate-/l/65.5%
distribute-rgt-neg-out65.5%
distribute-lft-neg-out65.5%
associate-*l*66.6%
distribute-lft-neg-in66.6%
distribute-lft-neg-out66.6%
remove-double-neg66.6%
associate-*r*66.7%
*-commutative66.7%
associate-*r*65.4%
Simplified74.4%
Taylor expanded in x around 0 57.8%
Final simplification64.5%
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 4e-148) (/ 1.0 (* (* c c) (* x (* s (* s x))))) (/ 1.0 (* (* x x) (* (* c s) (* c s))))))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double tmp;
if (x <= 4e-148) {
tmp = 1.0 / ((c * c) * (x * (s * (s * x))));
} else {
tmp = 1.0 / ((x * x) * ((c * s) * (c * s)));
}
return tmp;
}
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 <= 4d-148) then
tmp = 1.0d0 / ((c * c) * (x * (s * (s * x))))
else
tmp = 1.0d0 / ((x * x) * ((c * s) * (c * s)))
end if
code = tmp
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double tmp;
if (x <= 4e-148) {
tmp = 1.0 / ((c * c) * (x * (s * (s * x))));
} else {
tmp = 1.0 / ((x * x) * ((c * s) * (c * s)));
}
return tmp;
}
s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): tmp = 0 if x <= 4e-148: tmp = 1.0 / ((c * c) * (x * (s * (s * x)))) else: tmp = 1.0 / ((x * x) * ((c * s) * (c * s))) return tmp
s = abs(s) c, s = sort([c, s]) function code(x, c, s) tmp = 0.0 if (x <= 4e-148) tmp = Float64(1.0 / Float64(Float64(c * c) * Float64(x * Float64(s * Float64(s * x))))); else tmp = Float64(1.0 / Float64(Float64(x * x) * Float64(Float64(c * s) * Float64(c * s)))); end return tmp end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
tmp = 0.0;
if (x <= 4e-148)
tmp = 1.0 / ((c * c) * (x * (s * (s * x))));
else
tmp = 1.0 / ((x * x) * ((c * s) * (c * s)));
end
tmp_2 = tmp;
end
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, 4e-148], N[(1.0 / N[(N[(c * c), $MachinePrecision] * N[(x * N[(s * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(x * x), $MachinePrecision] * N[(N[(c * s), $MachinePrecision] * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4 \cdot 10^{-148}:\\
\;\;\;\;\frac{1}{\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot \left(s \cdot x\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(x \cdot x\right) \cdot \left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right)}\\
\end{array}
\end{array}
if x < 3.99999999999999974e-148Initial program 63.8%
associate-/r*63.8%
remove-double-neg63.8%
distribute-lft-neg-out63.8%
distribute-lft-neg-out63.8%
distribute-rgt-neg-out63.8%
associate-/r*63.8%
unpow263.8%
*-commutative63.8%
associate-*r*55.5%
sqr-neg55.5%
associate-*r*63.8%
unpow263.8%
Simplified63.8%
Taylor expanded in x around 0 63.8%
unpow263.8%
associate-*r*74.1%
Simplified74.1%
Taylor expanded in x around 0 67.9%
if 3.99999999999999974e-148 < x Initial program 64.9%
associate-/r*63.8%
*-commutative63.8%
associate-*l*62.4%
unpow262.4%
unpow262.4%
associate-*r*72.9%
associate-/r*74.0%
associate-/l/75.2%
associate-/l/75.2%
*-commutative75.2%
associate-*l*73.1%
unpow273.1%
associate-*l*63.7%
unpow263.7%
unswap-sqr82.1%
*-commutative82.1%
*-commutative82.1%
Simplified82.1%
Taylor expanded in x around 0 68.3%
Final simplification68.0%
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 (/ 1.0 (* c (* s x))))) (* t_0 t_0)))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = 1.0 / (c * (s * x));
return t_0 * t_0;
}
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 = 1.0d0 / (c * (s * x))
code = t_0 * t_0
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = 1.0 / (c * (s * x));
return t_0 * t_0;
}
s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = 1.0 / (c * (s * x)) return t_0 * t_0
s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(1.0 / Float64(c * Float64(s * x))) return Float64(t_0 * t_0) end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
t_0 = 1.0 / (c * (s * x));
tmp = t_0 * t_0;
end
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[(1.0 / N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * t$95$0), $MachinePrecision]]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \frac{1}{c \cdot \left(s \cdot x\right)}\\
t_0 \cdot t_0
\end{array}
\end{array}
Initial program 64.1%
associate-/r*63.8%
remove-double-neg63.8%
distribute-lft-neg-out63.8%
distribute-lft-neg-out63.8%
distribute-rgt-neg-out63.8%
associate-/r*64.1%
unpow264.1%
*-commutative64.1%
associate-*r*58.2%
sqr-neg58.2%
associate-*r*64.1%
unpow264.1%
Simplified64.1%
associate-*r*58.2%
*-commutative58.2%
associate-*l*59.0%
swap-sqr76.3%
*-commutative76.3%
add-sqr-sqrt76.3%
*-un-lft-identity76.3%
times-frac76.3%
Applied egg-rr97.7%
Taylor expanded in x around 0 80.0%
Final simplification80.0%
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 (* s x))) (/ (/ 1.0 (* s x)) c)))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return (1.0 / (c * (s * x))) * ((1.0 / (s * x)) / c);
}
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 * (s * x))) * ((1.0d0 / (s * x)) / c)
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return (1.0 / (c * (s * x))) * ((1.0 / (s * x)) / c);
}
s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return (1.0 / (c * (s * x))) * ((1.0 / (s * x)) / c)
s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(Float64(1.0 / Float64(c * Float64(s * x))) * Float64(Float64(1.0 / Float64(s * x)) / c)) end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = (1.0 / (c * (s * x))) * ((1.0 / (s * x)) / c);
end
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[(1.0 / N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / N[(s * x), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{c \cdot \left(s \cdot x\right)} \cdot \frac{\frac{1}{s \cdot x}}{c}
\end{array}
Initial program 64.1%
associate-/r*63.8%
remove-double-neg63.8%
distribute-lft-neg-out63.8%
distribute-lft-neg-out63.8%
distribute-rgt-neg-out63.8%
associate-/r*64.1%
unpow264.1%
*-commutative64.1%
associate-*r*58.2%
sqr-neg58.2%
associate-*r*64.1%
unpow264.1%
Simplified64.1%
associate-*r*58.2%
*-commutative58.2%
associate-*l*59.0%
swap-sqr76.3%
*-commutative76.3%
add-sqr-sqrt76.3%
*-un-lft-identity76.3%
times-frac76.3%
Applied egg-rr97.7%
Taylor expanded in x around 0 80.0%
*-commutative80.0%
associate-/r*80.0%
Simplified80.0%
Final simplification80.0%
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 (* x (* x (* c (* c (* s s)))))))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return 1.0 / (x * (x * (c * (c * (s * s)))));
}
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 / (x * (x * (c * (c * (s * s)))))
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return 1.0 / (x * (x * (c * (c * (s * s)))));
}
s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return 1.0 / (x * (x * (c * (c * (s * s)))))
s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(1.0 / Float64(x * Float64(x * Float64(c * Float64(c * Float64(s * s)))))) end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = 1.0 / (x * (x * (c * (c * (s * s)))));
end
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[(x * N[(x * N[(c * N[(c * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{x \cdot \left(x \cdot \left(c \cdot \left(c \cdot \left(s \cdot s\right)\right)\right)\right)}
\end{array}
Initial program 64.1%
associate-/r*63.8%
remove-double-neg63.8%
distribute-lft-neg-out63.8%
distribute-lft-neg-out63.8%
distribute-rgt-neg-out63.8%
associate-/l/64.1%
distribute-rgt-neg-out64.1%
distribute-lft-neg-out64.1%
associate-*l*65.4%
distribute-lft-neg-in65.4%
distribute-lft-neg-out65.4%
remove-double-neg65.4%
associate-*r*66.3%
*-commutative66.3%
associate-*r*65.2%
Simplified74.2%
Taylor expanded in x around 0 65.7%
Final simplification65.7%
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))))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return -2.0 / ((s * s) * (c * c));
}
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
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return -2.0 / ((s * s) * (c * c));
}
s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return -2.0 / ((s * s) * (c * c))
s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(Float64(-2.0) / Float64(Float64(s * s) * Float64(c * c))) end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = -2.0 / ((s * s) * (c * c));
end
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}
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 64.1%
associate-/r*63.8%
remove-double-neg63.8%
distribute-lft-neg-out63.8%
distribute-lft-neg-out63.8%
distribute-rgt-neg-out63.8%
associate-/r*64.1%
unpow264.1%
*-commutative64.1%
associate-*r*58.2%
sqr-neg58.2%
associate-*r*64.1%
unpow264.1%
Simplified64.1%
associate-*r*58.2%
*-commutative58.2%
associate-*l*59.0%
swap-sqr76.3%
*-commutative76.3%
add-sqr-sqrt76.3%
*-un-lft-identity76.3%
times-frac76.3%
Applied egg-rr97.7%
Taylor expanded in x around 0 65.2%
Taylor expanded in c around -inf 60.2%
mul-1-neg60.2%
associate-*r/60.2%
*-commutative60.2%
*-commutative60.2%
unpow260.2%
Simplified60.2%
Taylor expanded in x around inf 26.6%
unpow226.6%
unpow226.6%
Simplified26.6%
Final simplification26.6%
herbie shell --seed 2023279
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))