
(FPCore (x c s) :precision binary64 (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))
double code(double x, double c, double s) {
return cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x));
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))
end function
public static double code(double x, double c, double s) {
return Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x));
}
def code(x, c, s): return math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))
function code(x, c, s) return Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x))) end
function tmp = code(x, c, s) tmp = cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x)); end
code[x_, c_, s_] := N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x c s) :precision binary64 (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))
double code(double x, double c, double s) {
return cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x));
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))
end function
public static double code(double x, double c, double s) {
return Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x));
}
def code(x, c, s): return math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))
function code(x, c, s) return Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x))) end
function tmp = code(x, c, s) tmp = cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x)); end
code[x_, c_, s_] := N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
\end{array}
NOTE: 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 (cos (* 2.0 x))))
(if (<= s 1.6e+163)
(/ t_0 (* (* c (* x s)) (* s (* x c))))
(* (/ 1.0 x) (/ t_0 (* c (* s (* x (* c s)))))))))c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = cos((2.0 * x));
double tmp;
if (s <= 1.6e+163) {
tmp = t_0 / ((c * (x * s)) * (s * (x * c)));
} else {
tmp = (1.0 / x) * (t_0 / (c * (s * (x * (c * s)))));
}
return tmp;
}
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 = cos((2.0d0 * x))
if (s <= 1.6d+163) then
tmp = t_0 / ((c * (x * s)) * (s * (x * c)))
else
tmp = (1.0d0 / x) * (t_0 / (c * (s * (x * (c * s)))))
end if
code = tmp
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = Math.cos((2.0 * x));
double tmp;
if (s <= 1.6e+163) {
tmp = t_0 / ((c * (x * s)) * (s * (x * c)));
} else {
tmp = (1.0 / x) * (t_0 / (c * (s * (x * (c * s)))));
}
return tmp;
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = math.cos((2.0 * x)) tmp = 0 if s <= 1.6e+163: tmp = t_0 / ((c * (x * s)) * (s * (x * c))) else: tmp = (1.0 / x) * (t_0 / (c * (s * (x * (c * s))))) return tmp
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = cos(Float64(2.0 * x)) tmp = 0.0 if (s <= 1.6e+163) tmp = Float64(t_0 / Float64(Float64(c * Float64(x * s)) * Float64(s * Float64(x * c)))); else tmp = Float64(Float64(1.0 / x) * Float64(t_0 / Float64(c * Float64(s * Float64(x * Float64(c * s)))))); end return tmp end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = cos((2.0 * x));
tmp = 0.0;
if (s <= 1.6e+163)
tmp = t_0 / ((c * (x * s)) * (s * (x * c)));
else
tmp = (1.0 / x) * (t_0 / (c * (s * (x * (c * s)))));
end
tmp_2 = tmp;
end
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[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[s, 1.6e+163], N[(t$95$0 / N[(N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision] * N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / N[(c * N[(s * N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \cos \left(2 \cdot x\right)\\
\mathbf{if}\;s \leq 1.6 \cdot 10^{+163}:\\
\;\;\;\;\frac{t_0}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t_0}{c \cdot \left(s \cdot \left(x \cdot \left(c \cdot s\right)\right)\right)}\\
\end{array}
\end{array}
if s < 1.5999999999999999e163Initial program 68.3%
*-commutative68.3%
associate-*r*63.0%
associate-*r*63.3%
unpow263.3%
unswap-sqr78.5%
unpow278.5%
swap-sqr99.2%
*-commutative99.2%
*-commutative99.2%
*-commutative99.2%
*-commutative99.2%
Simplified99.2%
Taylor expanded in s around 0 96.5%
if 1.5999999999999999e163 < s Initial program 0.9%
associate-*r*0.9%
*-commutative0.9%
associate-*r*0.2%
unpow20.2%
unpow20.2%
Simplified0.2%
Taylor expanded in c around 0 0.2%
unpow20.2%
*-commutative0.2%
associate-*r*0.9%
unpow20.9%
associate-*l*2.1%
*-commutative2.1%
associate-*r*61.9%
associate-*l*99.7%
*-commutative99.7%
Simplified99.7%
*-commutative99.7%
*-un-lft-identity99.7%
times-frac99.4%
associate-*l*99.5%
*-commutative99.5%
Applied egg-rr99.5%
Final simplification96.7%
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 (* (cos (* 2.0 x)) (pow (* c (* x s)) -2.0)))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return cos((2.0 * x)) * pow((c * (x * s)), -2.0);
}
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 = cos((2.0d0 * x)) * ((c * (x * s)) ** (-2.0d0))
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return Math.cos((2.0 * x)) * Math.pow((c * (x * s)), -2.0);
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return math.cos((2.0 * x)) * math.pow((c * (x * s)), -2.0)
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(cos(Float64(2.0 * x)) * (Float64(c * Float64(x * s)) ^ -2.0)) end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = cos((2.0 * x)) * ((c * (x * s)) ^ -2.0);
end
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[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] * N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\cos \left(2 \cdot x\right) \cdot {\left(c \cdot \left(x \cdot s\right)\right)}^{-2}
\end{array}
Initial program 63.5%
*-commutative63.5%
associate-*l*58.6%
associate-*r*59.3%
*-commutative59.3%
unpow259.3%
associate-*r*67.4%
associate-*r*68.7%
*-commutative68.7%
unpow268.7%
Simplified68.7%
Taylor expanded in x around inf 58.8%
unpow258.8%
associate-/r*58.6%
*-commutative58.6%
unpow258.6%
*-commutative58.6%
unpow258.6%
swap-sqr72.7%
unpow272.7%
associate-/r*73.0%
unpow273.0%
swap-sqr98.2%
associate-/r*98.2%
*-rgt-identity98.2%
associate-*r/98.1%
Simplified97.0%
Final simplification97.0%
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.00072)
(pow (/ (/ (- 1.0 (* x x)) c) (* x s)) 2.0)
(if (<= x 8.2e+153)
(/ (cos (* 2.0 x)) (* s (* (* c c) (* s (* x x)))))
(/ 1.0 (pow (* c (* x s)) 2.0)))))c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double tmp;
if (x <= 0.00072) {
tmp = pow((((1.0 - (x * x)) / c) / (x * s)), 2.0);
} else if (x <= 8.2e+153) {
tmp = cos((2.0 * x)) / (s * ((c * c) * (s * (x * x))));
} else {
tmp = 1.0 / pow((c * (x * s)), 2.0);
}
return tmp;
}
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.00072d0) then
tmp = (((1.0d0 - (x * x)) / c) / (x * s)) ** 2.0d0
else if (x <= 8.2d+153) then
tmp = cos((2.0d0 * x)) / (s * ((c * c) * (s * (x * x))))
else
tmp = 1.0d0 / ((c * (x * s)) ** 2.0d0)
end if
code = tmp
end function
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.00072) {
tmp = Math.pow((((1.0 - (x * x)) / c) / (x * s)), 2.0);
} else if (x <= 8.2e+153) {
tmp = Math.cos((2.0 * x)) / (s * ((c * c) * (s * (x * x))));
} else {
tmp = 1.0 / Math.pow((c * (x * s)), 2.0);
}
return tmp;
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): tmp = 0 if x <= 0.00072: tmp = math.pow((((1.0 - (x * x)) / c) / (x * s)), 2.0) elif x <= 8.2e+153: tmp = math.cos((2.0 * x)) / (s * ((c * c) * (s * (x * x)))) else: tmp = 1.0 / math.pow((c * (x * s)), 2.0) return tmp
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) tmp = 0.0 if (x <= 0.00072) tmp = Float64(Float64(Float64(1.0 - Float64(x * x)) / c) / Float64(x * s)) ^ 2.0; elseif (x <= 8.2e+153) tmp = Float64(cos(Float64(2.0 * x)) / Float64(s * Float64(Float64(c * c) * Float64(s * Float64(x * x))))); else tmp = Float64(1.0 / (Float64(c * Float64(x * s)) ^ 2.0)); end return tmp end
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.00072)
tmp = (((1.0 - (x * x)) / c) / (x * s)) ^ 2.0;
elseif (x <= 8.2e+153)
tmp = cos((2.0 * x)) / (s * ((c * c) * (s * (x * x))));
else
tmp = 1.0 / ((c * (x * s)) ^ 2.0);
end
tmp_2 = tmp;
end
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.00072], N[Power[N[(N[(N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], If[LessEqual[x, 8.2e+153], N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(s * N[(N[(c * c), $MachinePrecision] * N[(s * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.00072:\\
\;\;\;\;{\left(\frac{\frac{1 - x \cdot x}{c}}{x \cdot s}\right)}^{2}\\
\mathbf{elif}\;x \leq 8.2 \cdot 10^{+153}:\\
\;\;\;\;\frac{\cos \left(2 \cdot x\right)}{s \cdot \left(\left(c \cdot c\right) \cdot \left(s \cdot \left(x \cdot x\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}\\
\end{array}
\end{array}
if x < 7.20000000000000045e-4Initial program 65.1%
*-commutative65.1%
associate-*l*62.0%
associate-*r*63.2%
*-commutative63.2%
unpow263.2%
associate-*r*72.0%
associate-*r*71.3%
*-commutative71.3%
unpow271.3%
Simplified71.3%
Applied egg-rr87.9%
Taylor expanded in x around 0 81.6%
mul-1-neg81.6%
unsub-neg81.6%
unpow281.6%
Simplified81.6%
if 7.20000000000000045e-4 < x < 8.20000000000000033e153Initial program 61.8%
*-commutative61.8%
associate-*l*61.9%
associate-*r*59.7%
*-commutative59.7%
unpow259.7%
associate-*r*67.2%
associate-*r*81.2%
*-commutative81.2%
unpow281.2%
Simplified81.2%
Taylor expanded in x around 0 73.5%
*-commutative73.5%
unpow273.5%
associate-*r*82.0%
unpow282.0%
*-commutative82.0%
Simplified82.0%
if 8.20000000000000033e153 < x Initial program 44.7%
*-commutative44.7%
associate-*l*0.2%
associate-*r*0.0%
*-commutative0.0%
unpow20.0%
associate-*r*0.0%
associate-*r*0.2%
*-commutative0.2%
unpow20.2%
Simplified0.2%
Taylor expanded in x around 0 0.2%
unpow20.2%
associate-/r*0.2%
unpow20.2%
*-commutative0.2%
unpow20.2%
swap-sqr25.6%
unpow225.6%
associate-/r*25.6%
unpow225.6%
swap-sqr25.8%
unpow225.8%
associate-*r*25.8%
*-commutative25.8%
Simplified25.8%
Final simplification78.6%
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.00072) (pow (/ (/ (- 1.0 (* x x)) c) (* x s)) 2.0) (/ (cos (* 2.0 x)) (* x (* c (* c (* s (* x s))))))))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double tmp;
if (x <= 0.00072) {
tmp = pow((((1.0 - (x * x)) / c) / (x * s)), 2.0);
} else {
tmp = cos((2.0 * x)) / (x * (c * (c * (s * (x * s)))));
}
return tmp;
}
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.00072d0) then
tmp = (((1.0d0 - (x * x)) / c) / (x * s)) ** 2.0d0
else
tmp = cos((2.0d0 * x)) / (x * (c * (c * (s * (x * s)))))
end if
code = tmp
end function
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.00072) {
tmp = Math.pow((((1.0 - (x * x)) / c) / (x * s)), 2.0);
} else {
tmp = Math.cos((2.0 * x)) / (x * (c * (c * (s * (x * s)))));
}
return tmp;
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): tmp = 0 if x <= 0.00072: tmp = math.pow((((1.0 - (x * x)) / c) / (x * s)), 2.0) else: tmp = math.cos((2.0 * x)) / (x * (c * (c * (s * (x * s))))) return tmp
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) tmp = 0.0 if (x <= 0.00072) tmp = Float64(Float64(Float64(1.0 - Float64(x * x)) / c) / Float64(x * s)) ^ 2.0; else tmp = Float64(cos(Float64(2.0 * x)) / Float64(x * Float64(c * Float64(c * Float64(s * Float64(x * s)))))); end return tmp end
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.00072)
tmp = (((1.0 - (x * x)) / c) / (x * s)) ^ 2.0;
else
tmp = cos((2.0 * x)) / (x * (c * (c * (s * (x * s)))));
end
tmp_2 = tmp;
end
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.00072], N[Power[N[(N[(N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(x * N[(c * N[(c * N[(s * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.00072:\\
\;\;\;\;{\left(\frac{\frac{1 - x \cdot x}{c}}{x \cdot s}\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(2 \cdot x\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 < 7.20000000000000045e-4Initial program 65.1%
*-commutative65.1%
associate-*l*62.0%
associate-*r*63.2%
*-commutative63.2%
unpow263.2%
associate-*r*72.0%
associate-*r*71.3%
*-commutative71.3%
unpow271.3%
Simplified71.3%
Applied egg-rr87.9%
Taylor expanded in x around 0 81.6%
mul-1-neg81.6%
unsub-neg81.6%
unpow281.6%
Simplified81.6%
if 7.20000000000000045e-4 < x Initial program 56.7%
associate-*r*55.2%
*-commutative55.2%
associate-*r*55.3%
unpow255.3%
unpow255.3%
Simplified55.3%
Taylor expanded in c around 0 55.3%
unpow255.3%
*-commutative55.3%
associate-*r*55.2%
unpow255.2%
associate-*l*65.6%
*-commutative65.6%
associate-*r*65.6%
associate-*l*72.1%
*-commutative72.1%
Simplified72.1%
Taylor expanded in s around 0 65.6%
unpow265.6%
associate-*r*65.6%
Simplified65.6%
Final simplification78.7%
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 (cos (* 2.0 x))))
(if (<= s 4.7e+181)
(/ t_0 (* (* c (* x s)) (* s (* x c))))
(/ t_0 (* x (* c (* (* x s) (* c s))))))))c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = cos((2.0 * x));
double tmp;
if (s <= 4.7e+181) {
tmp = t_0 / ((c * (x * s)) * (s * (x * c)));
} else {
tmp = t_0 / (x * (c * ((x * s) * (c * s))));
}
return tmp;
}
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 = cos((2.0d0 * x))
if (s <= 4.7d+181) then
tmp = t_0 / ((c * (x * s)) * (s * (x * c)))
else
tmp = t_0 / (x * (c * ((x * s) * (c * s))))
end if
code = tmp
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = Math.cos((2.0 * x));
double tmp;
if (s <= 4.7e+181) {
tmp = t_0 / ((c * (x * s)) * (s * (x * c)));
} else {
tmp = t_0 / (x * (c * ((x * s) * (c * s))));
}
return tmp;
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = math.cos((2.0 * x)) tmp = 0 if s <= 4.7e+181: tmp = t_0 / ((c * (x * s)) * (s * (x * c))) else: tmp = t_0 / (x * (c * ((x * s) * (c * s)))) return tmp
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = cos(Float64(2.0 * x)) tmp = 0.0 if (s <= 4.7e+181) tmp = Float64(t_0 / Float64(Float64(c * Float64(x * s)) * Float64(s * Float64(x * c)))); else tmp = Float64(t_0 / Float64(x * Float64(c * Float64(Float64(x * s) * Float64(c * s))))); end return tmp end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = cos((2.0 * x));
tmp = 0.0;
if (s <= 4.7e+181)
tmp = t_0 / ((c * (x * s)) * (s * (x * c)));
else
tmp = t_0 / (x * (c * ((x * s) * (c * s))));
end
tmp_2 = tmp;
end
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[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[s, 4.7e+181], N[(t$95$0 / N[(N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision] * N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[(x * N[(c * N[(N[(x * s), $MachinePrecision] * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \cos \left(2 \cdot x\right)\\
\mathbf{if}\;s \leq 4.7 \cdot 10^{+181}:\\
\;\;\;\;\frac{t_0}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{x \cdot \left(c \cdot \left(\left(x \cdot s\right) \cdot \left(c \cdot s\right)\right)\right)}\\
\end{array}
\end{array}
if s < 4.70000000000000027e181Initial program 67.2%
*-commutative67.2%
associate-*r*62.0%
associate-*r*62.2%
unpow262.2%
unswap-sqr77.2%
unpow277.2%
swap-sqr99.2%
*-commutative99.2%
*-commutative99.2%
*-commutative99.2%
*-commutative99.2%
Simplified99.2%
Taylor expanded in s around 0 96.6%
if 4.70000000000000027e181 < s Initial program 1.1%
associate-*r*1.1%
*-commutative1.1%
associate-*r*0.3%
unpow20.3%
unpow20.3%
Simplified0.3%
Taylor expanded in c around 0 0.3%
unpow20.3%
*-commutative0.3%
associate-*r*1.1%
unpow21.1%
associate-*l*2.2%
*-commutative2.2%
associate-*r*51.1%
associate-*l*99.6%
*-commutative99.6%
Simplified99.6%
Final simplification96.7%
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))) (t_1 (cos (* 2.0 x))))
(if (<= x 1.95e+39)
(/ t_1 (* x (* c (* (* x s) (* c s)))))
(/ t_1 (* t_0 t_0)))))c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = s * (x * c);
double t_1 = cos((2.0 * x));
double tmp;
if (x <= 1.95e+39) {
tmp = t_1 / (x * (c * ((x * s) * (c * s))));
} else {
tmp = t_1 / (t_0 * t_0);
}
return tmp;
}
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) :: t_1
real(8) :: tmp
t_0 = s * (x * c)
t_1 = cos((2.0d0 * x))
if (x <= 1.95d+39) then
tmp = t_1 / (x * (c * ((x * s) * (c * s))))
else
tmp = t_1 / (t_0 * t_0)
end if
code = tmp
end function
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 t_1 = Math.cos((2.0 * x));
double tmp;
if (x <= 1.95e+39) {
tmp = t_1 / (x * (c * ((x * s) * (c * s))));
} else {
tmp = t_1 / (t_0 * t_0);
}
return tmp;
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = s * (x * c) t_1 = math.cos((2.0 * x)) tmp = 0 if x <= 1.95e+39: tmp = t_1 / (x * (c * ((x * s) * (c * s)))) else: tmp = t_1 / (t_0 * t_0) return tmp
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(s * Float64(x * c)) t_1 = cos(Float64(2.0 * x)) tmp = 0.0 if (x <= 1.95e+39) tmp = Float64(t_1 / Float64(x * Float64(c * Float64(Float64(x * s) * Float64(c * s))))); else tmp = Float64(t_1 / Float64(t_0 * t_0)); end return tmp end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = s * (x * c);
t_1 = cos((2.0 * x));
tmp = 0.0;
if (x <= 1.95e+39)
tmp = t_1 / (x * (c * ((x * s) * (c * s))));
else
tmp = t_1 / (t_0 * t_0);
end
tmp_2 = tmp;
end
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]}, Block[{t$95$1 = N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 1.95e+39], N[(t$95$1 / N[(x * N[(c * N[(N[(x * s), $MachinePrecision] * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := s \cdot \left(x \cdot c\right)\\
t_1 := \cos \left(2 \cdot x\right)\\
\mathbf{if}\;x \leq 1.95 \cdot 10^{+39}:\\
\;\;\;\;\frac{t_1}{x \cdot \left(c \cdot \left(\left(x \cdot s\right) \cdot \left(c \cdot s\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{t_0 \cdot t_0}\\
\end{array}
\end{array}
if x < 1.95e39Initial program 65.3%
associate-*r*67.4%
*-commutative67.4%
associate-*r*67.0%
unpow267.0%
unpow267.0%
Simplified67.0%
Taylor expanded in c around 0 67.0%
unpow267.0%
*-commutative67.0%
associate-*r*67.4%
unpow267.4%
associate-*l*72.6%
*-commutative72.6%
associate-*r*83.7%
associate-*l*91.5%
*-commutative91.5%
Simplified91.5%
if 1.95e39 < x Initial program 52.9%
*-commutative52.9%
associate-*r*36.1%
associate-*r*36.3%
unpow236.3%
unswap-sqr66.0%
unpow266.0%
swap-sqr99.5%
*-commutative99.5%
*-commutative99.5%
*-commutative99.5%
*-commutative99.5%
Simplified99.5%
Final simplification92.7%
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 (/ (cos (* 2.0 x)) (* x (* c (* (* x s) (* c s))))))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return cos((2.0 * x)) / (x * (c * ((x * s) * (c * s))));
}
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 = cos((2.0d0 * x)) / (x * (c * ((x * s) * (c * s))))
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return Math.cos((2.0 * x)) / (x * (c * ((x * s) * (c * s))));
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return math.cos((2.0 * x)) / (x * (c * ((x * s) * (c * s))))
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(cos(Float64(2.0 * x)) / Float64(x * Float64(c * Float64(Float64(x * s) * Float64(c * s))))) end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = cos((2.0 * x)) / (x * (c * ((x * s) * (c * s))));
end
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[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(x * N[(c * N[(N[(x * s), $MachinePrecision] * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(c \cdot \left(\left(x \cdot s\right) \cdot \left(c \cdot s\right)\right)\right)}
\end{array}
Initial program 63.5%
associate-*r*65.0%
*-commutative65.0%
associate-*r*64.7%
unpow264.7%
unpow264.7%
Simplified64.7%
Taylor expanded in c around 0 64.7%
unpow264.7%
*-commutative64.7%
associate-*r*65.0%
unpow265.0%
associate-*l*71.4%
*-commutative71.4%
associate-*r*80.9%
associate-*l*88.3%
*-commutative88.3%
Simplified88.3%
Final simplification88.3%
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 (pow (* c (* x s)) 2.0)))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return 1.0 / pow((c * (x * s)), 2.0);
}
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)) ** 2.0d0)
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return 1.0 / Math.pow((c * (x * s)), 2.0);
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return 1.0 / math.pow((c * (x * s)), 2.0)
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(1.0 / (Float64(c * Float64(x * s)) ^ 2.0)) end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = 1.0 / ((c * (x * s)) ^ 2.0);
end
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[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}
\end{array}
Initial program 63.5%
*-commutative63.5%
associate-*l*58.6%
associate-*r*59.3%
*-commutative59.3%
unpow259.3%
associate-*r*67.4%
associate-*r*68.7%
*-commutative68.7%
unpow268.7%
Simplified68.7%
Taylor expanded in x around 0 49.2%
unpow249.2%
associate-/r*49.0%
unpow249.0%
*-commutative49.0%
unpow249.0%
swap-sqr58.1%
unpow258.1%
associate-/r*58.4%
unpow258.4%
swap-sqr73.9%
unpow273.9%
associate-*r*72.5%
*-commutative72.5%
Simplified72.5%
Final simplification72.5%
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 (/ 1.0 (* s (* x c))))) (* t_0 t_0)))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = 1.0 / (s * (x * c));
return t_0 * t_0;
}
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 = 1.0d0 / (s * (x * c))
code = t_0 * t_0
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = 1.0 / (s * (x * c));
return t_0 * t_0;
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = 1.0 / (s * (x * c)) return t_0 * t_0
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(1.0 / Float64(s * Float64(x * c))) return Float64(t_0 * t_0) end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
t_0 = 1.0 / (s * (x * c));
tmp = t_0 * t_0;
end
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[(1.0 / N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * t$95$0), $MachinePrecision]]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \frac{1}{s \cdot \left(x \cdot c\right)}\\
t_0 \cdot t_0
\end{array}
\end{array}
Initial program 63.5%
*-commutative63.5%
associate-*l*58.6%
associate-*r*59.3%
*-commutative59.3%
unpow259.3%
associate-*r*67.4%
associate-*r*68.7%
*-commutative68.7%
unpow268.7%
Simplified68.7%
add-cube-cbrt68.6%
times-frac68.7%
associate-*r*65.5%
swap-sqr82.6%
associate-*r*94.7%
*-commutative94.7%
times-frac94.7%
associate-*l*97.9%
add-cube-cbrt98.2%
associate-/r*98.2%
Applied egg-rr98.1%
Taylor expanded in x around 0 73.9%
Final simplification73.9%
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 (/ 1.0 (* x (* c s))))) (* t_0 t_0)))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = 1.0 / (x * (c * s));
return t_0 * t_0;
}
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 = 1.0d0 / (x * (c * s))
code = t_0 * t_0
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = 1.0 / (x * (c * s));
return t_0 * t_0;
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = 1.0 / (x * (c * s)) return t_0 * t_0
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(1.0 / Float64(x * Float64(c * s))) return Float64(t_0 * t_0) end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
t_0 = 1.0 / (x * (c * s));
tmp = t_0 * t_0;
end
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[(1.0 / N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * t$95$0), $MachinePrecision]]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \frac{1}{x \cdot \left(c \cdot s\right)}\\
t_0 \cdot t_0
\end{array}
\end{array}
Initial program 63.5%
associate-/r*63.5%
unpow263.5%
*-commutative63.5%
unpow263.5%
Simplified63.5%
Taylor expanded in x around 0 52.0%
unpow252.0%
Simplified52.0%
associate-/r*52.0%
associate-*r*49.3%
add-sqr-sqrt49.3%
Applied egg-rr75.0%
Final simplification75.0%
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 (* 0.6666666666666666 (* (/ x (* c c)) (/ (/ x s) s))))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return 0.6666666666666666 * ((x / (c * c)) * ((x / s) / s));
}
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 = 0.6666666666666666d0 * ((x / (c * c)) * ((x / s) / s))
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return 0.6666666666666666 * ((x / (c * c)) * ((x / s) / s));
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return 0.6666666666666666 * ((x / (c * c)) * ((x / s) / s))
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(0.6666666666666666 * Float64(Float64(x / Float64(c * c)) * Float64(Float64(x / s) / s))) end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = 0.6666666666666666 * ((x / (c * c)) * ((x / s) / s));
end
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[(0.6666666666666666 * N[(N[(x / N[(c * c), $MachinePrecision]), $MachinePrecision] * N[(N[(x / s), $MachinePrecision] / s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
0.6666666666666666 \cdot \left(\frac{x}{c \cdot c} \cdot \frac{\frac{x}{s}}{s}\right)
\end{array}
Initial program 63.5%
*-commutative63.5%
associate-*l*58.6%
associate-*r*59.3%
*-commutative59.3%
unpow259.3%
associate-*r*67.4%
associate-*r*68.7%
*-commutative68.7%
unpow268.7%
Simplified68.7%
Taylor expanded in x around 0 12.1%
Simplified12.1%
Taylor expanded in x around inf 23.5%
unpow223.5%
associate-*r/23.5%
unpow223.5%
unpow223.5%
associate-/r*21.9%
associate-*r/21.9%
associate-*r/21.9%
associate-*l/29.4%
associate-*r/32.9%
associate-/r*29.2%
Simplified29.2%
Final simplification29.2%
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 c) (* (* x s) (* x s)))))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return 1.0 / ((c * c) * ((x * s) * (x * s)));
}
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 * c) * ((x * s) * (x * s)))
end function
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 * c) * ((x * s) * (x * s)));
}
c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return 1.0 / ((c * c) * ((x * s) * (x * s)))
c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(1.0 / Float64(Float64(c * c) * Float64(Float64(x * s) * Float64(x * s)))) end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = 1.0 / ((c * c) * ((x * s) * (x * s)));
end
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[(N[(c * c), $MachinePrecision] * N[(N[(x * s), $MachinePrecision] * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{\left(c \cdot c\right) \cdot \left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}
\end{array}
Initial program 63.5%
*-commutative63.5%
associate-*l*58.6%
associate-*r*59.3%
*-commutative59.3%
unpow259.3%
associate-*r*67.4%
associate-*r*68.7%
*-commutative68.7%
unpow268.7%
Simplified68.7%
Taylor expanded in x around 0 49.2%
unpow249.2%
unpow249.2%
associate-*r*50.3%
*-commutative50.3%
associate-/r*50.3%
associate-/r*50.3%
associate-/r*49.3%
*-commutative49.3%
swap-sqr61.5%
unpow261.5%
associate-/r*61.5%
unpow261.5%
swap-sqr49.3%
*-commutative49.3%
unpow249.3%
*-commutative49.3%
Simplified49.3%
Taylor expanded in x around 0 49.3%
unpow249.3%
unpow249.3%
swap-sqr61.5%
unpow261.5%
Simplified61.5%
unpow261.5%
Applied egg-rr61.5%
Final simplification61.5%
herbie shell --seed 2023278
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))