
(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 10 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.2e-60)
(pow (* c (* x s)) -2.0)
(/ (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.2e-60) {
tmp = pow((c * (x * s)), -2.0);
} 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.2d-60) then
tmp = (c * (x * s)) ** (-2.0d0)
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.2e-60) {
tmp = Math.pow((c * (x * s)), -2.0);
} 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.2e-60: tmp = math.pow((c * (x * s)), -2.0) 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.2e-60) tmp = Float64(c * Float64(x * s)) ^ -2.0; 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.2e-60)
tmp = (c * (x * s)) ^ -2.0;
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.2e-60], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $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.2 \cdot 10^{-60}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{t_0 \cdot t_0}\\
\end{array}
\end{array}
if x < 1.20000000000000005e-60Initial program 65.4%
associate-*r*67.5%
*-commutative67.5%
*-commutative67.5%
associate-*r*65.4%
*-commutative65.4%
unpow265.4%
unpow265.4%
Simplified65.4%
*-un-lft-identity65.4%
associate-*r*66.9%
*-commutative66.9%
add-sqr-sqrt66.9%
times-frac66.9%
Applied egg-rr97.2%
associate-*l/97.3%
*-un-lft-identity97.3%
Applied egg-rr97.3%
Taylor expanded in c around 0 94.9%
Taylor expanded in x around 0 53.8%
associate-/r*53.7%
unpow253.7%
unpow253.7%
swap-sqr66.3%
*-commutative66.3%
associate-*r*64.6%
associate-/r*64.7%
unpow264.7%
associate-*r*71.7%
associate-/r*71.7%
*-rgt-identity71.7%
associate-*r*73.8%
*-commutative73.8%
associate-*r*80.8%
*-commutative80.8%
times-frac83.7%
associate-/r*83.7%
unpow-183.7%
unpow-183.7%
pow-sqr83.8%
Simplified83.8%
if 1.20000000000000005e-60 < x Initial program 70.4%
*-commutative70.4%
associate-*r*63.0%
associate-*r*62.9%
unpow262.9%
unswap-sqr77.3%
unpow277.3%
swap-sqr96.3%
*-commutative96.3%
*-commutative96.3%
*-commutative96.3%
*-commutative96.3%
Simplified96.3%
Final simplification87.2%
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 8.8e-17) (pow (* c (* x s)) -2.0) (/ (cos (* x 2.0)) (* s (* s (* x (* c (* x c))))))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double tmp;
if (x <= 8.8e-17) {
tmp = pow((c * (x * s)), -2.0);
} else {
tmp = cos((x * 2.0)) / (s * (s * (x * (c * (x * c)))));
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: 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 <= 8.8d-17) then
tmp = (c * (x * s)) ** (-2.0d0)
else
tmp = cos((x * 2.0d0)) / (s * (s * (x * (c * (x * c)))))
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 <= 8.8e-17) {
tmp = Math.pow((c * (x * s)), -2.0);
} else {
tmp = Math.cos((x * 2.0)) / (s * (s * (x * (c * (x * c)))));
}
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 <= 8.8e-17: tmp = math.pow((c * (x * s)), -2.0) else: tmp = math.cos((x * 2.0)) / (s * (s * (x * (c * (x * c))))) 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 <= 8.8e-17) tmp = Float64(c * Float64(x * s)) ^ -2.0; else tmp = Float64(cos(Float64(x * 2.0)) / Float64(s * Float64(s * Float64(x * Float64(c * Float64(x * c)))))); 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 <= 8.8e-17)
tmp = (c * (x * s)) ^ -2.0;
else
tmp = cos((x * 2.0)) / (s * (s * (x * (c * (x * c)))));
end
tmp_2 = tmp;
end
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: 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, 8.8e-17], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(s * N[(s * N[(x * N[(c * N[(x * c), $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.8 \cdot 10^{-17}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{s \cdot \left(s \cdot \left(x \cdot \left(c \cdot \left(x \cdot c\right)\right)\right)\right)}\\
\end{array}
\end{array}
if x < 8.8e-17Initial program 66.8%
associate-*r*68.8%
*-commutative68.8%
*-commutative68.8%
associate-*r*66.9%
*-commutative66.9%
unpow266.9%
unpow266.9%
Simplified66.9%
*-un-lft-identity66.9%
associate-*r*68.2%
*-commutative68.2%
add-sqr-sqrt68.2%
times-frac68.2%
Applied egg-rr97.4%
associate-*l/97.4%
*-un-lft-identity97.4%
Applied egg-rr97.4%
Taylor expanded in c around 0 95.2%
Taylor expanded in x around 0 56.0%
associate-/r*56.0%
unpow256.0%
unpow256.0%
swap-sqr67.7%
*-commutative67.7%
associate-*r*66.1%
associate-/r*66.1%
unpow266.1%
associate-*r*73.1%
associate-/r*73.1%
*-rgt-identity73.1%
associate-*r*75.1%
*-commutative75.1%
associate-*r*82.2%
*-commutative82.2%
times-frac84.8%
associate-/r*84.8%
unpow-184.8%
unpow-184.8%
pow-sqr84.9%
Simplified84.9%
if 8.8e-17 < x Initial program 66.4%
*-commutative66.4%
associate-*l*57.2%
associate-*r*55.4%
*-commutative55.4%
unpow255.4%
associate-*r*65.3%
associate-*r*69.0%
*-commutative69.0%
unpow269.0%
Simplified69.0%
Taylor expanded in x around 0 67.3%
unpow255.8%
*-commutative55.8%
associate-*r*58.0%
unpow258.0%
associate-*r*60.4%
*-commutative60.4%
Simplified84.0%
Final simplification84.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 (<= x 5.2e-45)
(pow t_0 -2.0)
(/ (cos (* x 2.0)) (* t_0 (* s (* x c)))))))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 <= 5.2e-45) {
tmp = pow(t_0, -2.0);
} else {
tmp = cos((x * 2.0)) / (t_0 * (s * (x * c)));
}
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 <= 5.2d-45) then
tmp = t_0 ** (-2.0d0)
else
tmp = cos((x * 2.0d0)) / (t_0 * (s * (x * c)))
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 <= 5.2e-45) {
tmp = Math.pow(t_0, -2.0);
} else {
tmp = Math.cos((x * 2.0)) / (t_0 * (s * (x * c)));
}
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 <= 5.2e-45: tmp = math.pow(t_0, -2.0) else: tmp = math.cos((x * 2.0)) / (t_0 * (s * (x * c))) 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 <= 5.2e-45) tmp = t_0 ^ -2.0; else tmp = Float64(cos(Float64(x * 2.0)) / Float64(t_0 * Float64(s * Float64(x * c)))); 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 <= 5.2e-45)
tmp = t_0 ^ -2.0;
else
tmp = cos((x * 2.0)) / (t_0 * (s * (x * c)));
end
tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: 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, 5.2e-45], N[Power[t$95$0, -2.0], $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $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)\\
\mathbf{if}\;x \leq 5.2 \cdot 10^{-45}:\\
\;\;\;\;{t_0}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{t_0 \cdot \left(s \cdot \left(x \cdot c\right)\right)}\\
\end{array}
\end{array}
if x < 5.19999999999999973e-45Initial program 66.1%
associate-*r*68.2%
*-commutative68.2%
*-commutative68.2%
associate-*r*66.2%
*-commutative66.2%
unpow266.2%
unpow266.2%
Simplified66.2%
*-un-lft-identity66.2%
associate-*r*67.6%
*-commutative67.6%
add-sqr-sqrt67.6%
times-frac67.6%
Applied egg-rr97.3%
associate-*l/97.3%
*-un-lft-identity97.3%
Applied egg-rr97.3%
Taylor expanded in c around 0 95.0%
Taylor expanded in x around 0 54.7%
associate-/r*54.7%
unpow254.7%
unpow254.7%
swap-sqr67.0%
*-commutative67.0%
associate-*r*65.4%
associate-/r*65.4%
unpow265.4%
associate-*r*72.2%
associate-/r*72.2%
*-rgt-identity72.2%
associate-*r*74.3%
*-commutative74.3%
associate-*r*81.2%
*-commutative81.2%
times-frac84.0%
associate-/r*84.0%
unpow-184.0%
unpow-184.0%
pow-sqr84.1%
Simplified84.1%
if 5.19999999999999973e-45 < x Initial program 68.5%
*-commutative68.5%
associate-*r*60.8%
associate-*r*60.7%
unpow260.7%
unswap-sqr75.9%
unpow275.9%
swap-sqr96.1%
*-commutative96.1%
*-commutative96.1%
*-commutative96.1%
*-commutative96.1%
Simplified96.1%
Taylor expanded in s around 0 91.8%
Final simplification86.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 (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) {
return pow((c * (x * s)), -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)
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);
}
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)
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(c * Float64(x * s)) ^ -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;
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[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])\\
\\
{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}
\end{array}
Initial program 66.7%
associate-*r*68.6%
*-commutative68.6%
*-commutative68.6%
associate-*r*66.0%
*-commutative66.0%
unpow266.0%
unpow266.0%
Simplified66.0%
*-un-lft-identity66.0%
associate-*r*68.2%
*-commutative68.2%
add-sqr-sqrt68.2%
times-frac68.2%
Applied egg-rr97.2%
associate-*l/97.2%
*-un-lft-identity97.2%
Applied egg-rr97.2%
Taylor expanded in c around 0 94.8%
Taylor expanded in x around 0 54.3%
associate-/r*54.2%
unpow254.2%
unpow254.2%
swap-sqr64.3%
*-commutative64.3%
associate-*r*63.1%
associate-/r*63.2%
unpow263.2%
associate-*r*70.4%
associate-/r*70.4%
*-rgt-identity70.4%
associate-*r*72.0%
*-commutative72.0%
associate-*r*77.7%
*-commutative77.7%
times-frac79.8%
associate-/r*79.8%
unpow-179.8%
unpow-179.8%
pow-sqr79.8%
Simplified80.0%
Final simplification80.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 (<= x 2.3e-201) (/ 1.0 (* s (* s (* x (* c (* x c)))))) (/ 1.0 (* s (* (* x x) (* c (* c 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 <= 2.3e-201) {
tmp = 1.0 / (s * (s * (x * (c * (x * c)))));
} else {
tmp = 1.0 / (s * ((x * x) * (c * (c * 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 <= 2.3d-201) then
tmp = 1.0d0 / (s * (s * (x * (c * (x * c)))))
else
tmp = 1.0d0 / (s * ((x * x) * (c * (c * 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 <= 2.3e-201) {
tmp = 1.0 / (s * (s * (x * (c * (x * c)))));
} else {
tmp = 1.0 / (s * ((x * x) * (c * (c * 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 <= 2.3e-201: tmp = 1.0 / (s * (s * (x * (c * (x * c))))) else: tmp = 1.0 / (s * ((x * x) * (c * (c * 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 <= 2.3e-201) tmp = Float64(1.0 / Float64(s * Float64(s * Float64(x * Float64(c * Float64(x * c)))))); else tmp = Float64(1.0 / Float64(s * Float64(Float64(x * x) * Float64(c * Float64(c * 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 <= 2.3e-201)
tmp = 1.0 / (s * (s * (x * (c * (x * c)))));
else
tmp = 1.0 / (s * ((x * x) * (c * (c * 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, 2.3e-201], N[(1.0 / N[(s * N[(s * N[(x * N[(c * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(s * N[(N[(x * x), $MachinePrecision] * N[(c * N[(c * s), $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 2.3 \cdot 10^{-201}:\\
\;\;\;\;\frac{1}{s \cdot \left(s \cdot \left(x \cdot \left(c \cdot \left(x \cdot c\right)\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{s \cdot \left(\left(x \cdot x\right) \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)}\\
\end{array}
\end{array}
if x < 2.29999999999999986e-201Initial program 66.7%
*-commutative66.7%
associate-*l*61.0%
associate-*r*59.6%
*-commutative59.6%
unpow259.6%
associate-*r*64.8%
associate-*r*68.0%
*-commutative68.0%
unpow268.0%
Simplified68.0%
Taylor expanded in x around 0 60.5%
Taylor expanded in x around 0 60.0%
unpow260.0%
*-commutative60.0%
associate-*r*65.2%
unpow265.2%
associate-*r*71.9%
*-commutative71.9%
Simplified71.9%
if 2.29999999999999986e-201 < x Initial program 66.8%
*-commutative66.8%
associate-*l*61.1%
associate-*r*61.0%
*-commutative61.0%
unpow261.0%
associate-*r*70.3%
associate-*r*72.5%
*-commutative72.5%
unpow272.5%
Simplified72.5%
Taylor expanded in x around 0 64.6%
expm1-log1p-u42.6%
expm1-udef26.3%
associate-*l*26.3%
add-sqr-sqrt14.6%
sqrt-prod26.8%
unswap-sqr24.6%
*-commutative24.6%
sqrt-prod24.6%
sqrt-prod15.7%
add-sqr-sqrt25.8%
sqrt-prod13.5%
add-sqr-sqrt26.3%
Applied egg-rr26.3%
expm1-def43.8%
expm1-log1p66.9%
*-commutative66.9%
Simplified66.9%
Final simplification70.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 (if (<= c 2.06e-17) (/ 1.0 (* s (* (* x x) (* c (* c s))))) (/ 1.0 (* x (* (* x (* c 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 (c <= 2.06e-17) {
tmp = 1.0 / (s * ((x * x) * (c * (c * s))));
} else {
tmp = 1.0 / (x * ((x * (c * c)) * (s * s)));
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: 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 <= 2.06d-17) then
tmp = 1.0d0 / (s * ((x * x) * (c * (c * s))))
else
tmp = 1.0d0 / (x * ((x * (c * 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 (c <= 2.06e-17) {
tmp = 1.0 / (s * ((x * x) * (c * (c * s))));
} else {
tmp = 1.0 / (x * ((x * (c * 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 c <= 2.06e-17: tmp = 1.0 / (s * ((x * x) * (c * (c * s)))) else: tmp = 1.0 / (x * ((x * (c * 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 (c <= 2.06e-17) tmp = Float64(1.0 / Float64(s * Float64(Float64(x * x) * Float64(c * Float64(c * s))))); else tmp = Float64(1.0 / Float64(x * Float64(Float64(x * Float64(c * c)) * Float64(s * s)))); end return tmp end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
tmp = 0.0;
if (c <= 2.06e-17)
tmp = 1.0 / (s * ((x * x) * (c * (c * s))));
else
tmp = 1.0 / (x * ((x * (c * c)) * (s * s)));
end
tmp_2 = tmp;
end
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: 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, 2.06e-17], N[(1.0 / N[(s * N[(N[(x * x), $MachinePrecision] * N[(c * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(x * N[(N[(x * N[(c * c), $MachinePrecision]), $MachinePrecision] * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;c \leq 2.06 \cdot 10^{-17}:\\
\;\;\;\;\frac{1}{s \cdot \left(\left(x \cdot x\right) \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \left(\left(x \cdot \left(c \cdot c\right)\right) \cdot \left(s \cdot s\right)\right)}\\
\end{array}
\end{array}
if c < 2.06000000000000013e-17Initial program 68.1%
*-commutative68.1%
associate-*l*61.9%
associate-*r*60.2%
*-commutative60.2%
unpow260.2%
associate-*r*66.3%
associate-*r*69.5%
*-commutative69.5%
unpow269.5%
Simplified69.5%
Taylor expanded in x around 0 61.1%
expm1-log1p-u46.2%
expm1-udef27.7%
associate-*l*29.3%
add-sqr-sqrt11.8%
sqrt-prod20.2%
unswap-sqr18.4%
*-commutative18.4%
sqrt-prod18.4%
sqrt-prod17.3%
add-sqr-sqrt30.7%
sqrt-prod8.5%
add-sqr-sqrt29.3%
Applied egg-rr29.3%
expm1-def52.3%
expm1-log1p67.8%
*-commutative67.8%
Simplified67.8%
if 2.06000000000000013e-17 < c Initial program 63.4%
associate-*r*67.3%
*-commutative67.3%
associate-*r*65.7%
unpow265.7%
unpow265.7%
Simplified65.7%
Taylor expanded in x around 0 63.2%
Final simplification66.5%
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 (* s (* s (* x (* c (* x c)))))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return 1.0 / (s * (s * (x * (c * (x * 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 = 1.0d0 / (s * (s * (x * (c * (x * 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 1.0 / (s * (s * (x * (c * (x * c)))));
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return 1.0 / (s * (s * (x * (c * (x * c)))))
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(1.0 / Float64(s * Float64(s * Float64(x * Float64(c * Float64(x * c)))))) 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 / (s * (s * (x * (c * (x * 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[(1.0 / N[(s * N[(s * N[(x * N[(c * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{s \cdot \left(s \cdot \left(x \cdot \left(c \cdot \left(x \cdot c\right)\right)\right)\right)}
\end{array}
Initial program 66.7%
*-commutative66.7%
associate-*l*61.0%
associate-*r*60.1%
*-commutative60.1%
unpow260.1%
associate-*r*66.8%
associate-*r*69.6%
*-commutative69.6%
unpow269.6%
Simplified69.6%
Taylor expanded in x around 0 62.0%
Taylor expanded in x around 0 60.6%
unpow260.6%
*-commutative60.6%
associate-*r*64.5%
unpow264.5%
associate-*r*70.4%
*-commutative70.4%
Simplified70.4%
Final simplification70.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 (let* ((t_0 (* s (* 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 = s * (x * c);
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 = s * (x * c)
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 = s * (x * c);
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 = s * (x * c) 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(s * Float64(x * c)) 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 = s * (x * c);
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[(s * N[(x * c), $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 := s \cdot \left(x \cdot c\right)\\
\frac{1}{t_0 \cdot t_0}
\end{array}
\end{array}
Initial program 66.7%
*-commutative66.7%
associate-*r*61.0%
associate-*r*60.4%
unpow260.4%
unswap-sqr74.9%
unpow274.9%
swap-sqr96.9%
*-commutative96.9%
*-commutative96.9%
*-commutative96.9%
*-commutative96.9%
Simplified96.9%
Taylor expanded in x around 0 79.9%
Final simplification79.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 (* x (* c 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 = x * (c * 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 = x * (c * 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 = x * (c * 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 = x * (c * 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(x * Float64(c * 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 = x * (c * 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[(x * N[(c * 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 := x \cdot \left(c \cdot s\right)\\
\frac{1}{t_0 \cdot t_0}
\end{array}
\end{array}
Initial program 66.7%
associate-*r*68.6%
*-commutative68.6%
*-commutative68.6%
associate-*r*66.0%
*-commutative66.0%
unpow266.0%
unpow266.0%
Simplified66.0%
*-un-lft-identity66.0%
associate-*r*68.2%
*-commutative68.2%
add-sqr-sqrt68.2%
times-frac68.2%
Applied egg-rr97.2%
Taylor expanded in x around 0 54.3%
unpow254.3%
unpow254.3%
unpow254.3%
swap-sqr64.4%
swap-sqr79.9%
associate-*r*78.7%
associate-*r*80.4%
*-commutative80.4%
*-commutative80.4%
unpow280.4%
*-commutative80.4%
Simplified80.4%
unpow280.4%
*-commutative80.4%
*-commutative80.4%
Applied egg-rr80.4%
Final simplification80.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 (/ -2.0 (* (* c c) (* s s))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return -2.0 / ((c * c) * (s * 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 = (-2.0d0) / ((c * c) * (s * 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 -2.0 / ((c * c) * (s * s));
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return -2.0 / ((c * c) * (s * s))
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(c * c) * Float64(s * s))) 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 / ((c * c) * (s * 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[(-2.0 / N[(N[(c * c), $MachinePrecision] * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{-2}{\left(c \cdot c\right) \cdot \left(s \cdot s\right)}
\end{array}
Initial program 66.7%
*-commutative66.7%
associate-*r*61.0%
associate-*r*60.4%
unpow260.4%
unswap-sqr74.9%
unpow274.9%
swap-sqr96.9%
*-commutative96.9%
*-commutative96.9%
*-commutative96.9%
*-commutative96.9%
Simplified96.9%
Taylor expanded in x around 0 29.8%
unpow229.8%
unpow229.8%
associate-*r*30.2%
*-commutative30.2%
associate-*r*30.0%
unpow230.0%
associate-*r/30.0%
metadata-eval30.0%
unpow230.0%
unpow230.0%
Simplified30.0%
Taylor expanded in x around inf 26.9%
unpow226.9%
unpow226.9%
Simplified26.9%
Final simplification26.9%
herbie shell --seed 2023257
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))