
(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 8 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))) (t_1 (* c (* x s)))) (if (<= x 5e-64) (/ 1.0 (* t_1 t_1)) (/ (/ (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 t_1 = c * (x * s);
double tmp;
if (x <= 5e-64) {
tmp = 1.0 / (t_1 * t_1);
} 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) :: t_1
real(8) :: tmp
t_0 = s * (x * c)
t_1 = c * (x * s)
if (x <= 5d-64) then
tmp = 1.0d0 / (t_1 * t_1)
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 t_1 = c * (x * s);
double tmp;
if (x <= 5e-64) {
tmp = 1.0 / (t_1 * t_1);
} 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) t_1 = c * (x * s) tmp = 0 if x <= 5e-64: tmp = 1.0 / (t_1 * t_1) 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)) t_1 = Float64(c * Float64(x * s)) tmp = 0.0 if (x <= 5e-64) tmp = Float64(1.0 / Float64(t_1 * t_1)); else tmp = Float64(Float64(cos(Float64(x * 2.0)) / t_0) / t_0); end return tmp end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = s * (x * c);
t_1 = c * (x * s);
tmp = 0.0;
if (x <= 5e-64)
tmp = 1.0 / (t_1 * t_1);
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]}, Block[{t$95$1 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 5e-64], N[(1.0 / N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := s \cdot \left(x \cdot c\right)\\
t_1 := c \cdot \left(x \cdot s\right)\\
\mathbf{if}\;x \leq 5 \cdot 10^{-64}:\\
\;\;\;\;\frac{1}{t_1 \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(x \cdot 2\right)}{t_0}}{t_0}\\
\end{array}
\end{array}
if x < 5.00000000000000033e-64Initial program 70.2%
associate-/r*70.2%
remove-double-neg70.2%
distribute-lft-neg-out70.2%
distribute-lft-neg-out70.2%
distribute-rgt-neg-out70.2%
associate-/l/70.2%
distribute-rgt-neg-out70.2%
distribute-lft-neg-out70.2%
associate-*l*71.7%
distribute-lft-neg-in71.7%
distribute-lft-neg-out71.7%
remove-double-neg71.7%
associate-*r*70.7%
*-commutative70.7%
associate-*r*69.8%
Simplified69.8%
Taylor expanded in x around 0 58.6%
unpow258.6%
unpow258.6%
associate-*r*58.2%
*-commutative58.2%
associate-*r*56.6%
unpow256.6%
Simplified56.6%
add-sqr-sqrt56.6%
pow256.6%
sqrt-div56.5%
metadata-eval56.5%
sqrt-prod56.5%
sqrt-prod32.8%
add-sqr-sqrt62.6%
unswap-sqr76.7%
sqrt-prod54.7%
add-sqr-sqrt85.4%
associate-*r*85.2%
*-commutative85.2%
associate-*r*85.5%
pow285.5%
associate-/r*85.6%
associate-/r*85.5%
Applied egg-rr85.5%
associate-/l/85.6%
associate-/l/85.5%
frac-times85.5%
metadata-eval85.5%
*-commutative85.5%
*-commutative85.5%
Applied egg-rr85.5%
if 5.00000000000000033e-64 < x Initial program 60.9%
associate-/r*60.0%
remove-double-neg60.0%
distribute-lft-neg-out60.0%
distribute-lft-neg-out60.0%
distribute-rgt-neg-out60.0%
associate-/l/60.9%
distribute-rgt-neg-out60.9%
distribute-lft-neg-out60.9%
associate-*l*60.8%
distribute-lft-neg-in60.8%
distribute-lft-neg-out60.8%
remove-double-neg60.8%
associate-*r*62.1%
*-commutative62.1%
associate-*r*60.9%
Simplified60.9%
associate-/r*61.3%
swap-sqr91.9%
associate-/r*82.9%
associate-/r*82.9%
associate-/r*83.0%
*-un-lft-identity83.0%
add-sqr-sqrt82.9%
times-frac82.9%
Applied egg-rr97.2%
associate-*l/97.2%
*-un-lft-identity97.2%
associate-*r*93.7%
*-commutative93.7%
associate-*r*93.7%
associate-*r*92.4%
*-commutative92.4%
associate-*r*96.0%
Applied egg-rr96.0%
Final simplification88.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 (cos (* x 2.0))) (t_1 (* c (* x s))))
(if (<= x 1.2e-17)
(/ 1.0 (* t_1 t_1))
(if (<= x 8.5e+208)
(/ t_0 (* x (* x (* c (* s (* s c))))))
(/ (/ t_0 (* s (* x s))) (* c (* 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 = cos((x * 2.0));
double t_1 = c * (x * s);
double tmp;
if (x <= 1.2e-17) {
tmp = 1.0 / (t_1 * t_1);
} else if (x <= 8.5e+208) {
tmp = t_0 / (x * (x * (c * (s * (s * c)))));
} else {
tmp = (t_0 / (s * (x * s))) / (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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((x * 2.0d0))
t_1 = c * (x * s)
if (x <= 1.2d-17) then
tmp = 1.0d0 / (t_1 * t_1)
else if (x <= 8.5d+208) then
tmp = t_0 / (x * (x * (c * (s * (s * c)))))
else
tmp = (t_0 / (s * (x * s))) / (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 t_0 = Math.cos((x * 2.0));
double t_1 = c * (x * s);
double tmp;
if (x <= 1.2e-17) {
tmp = 1.0 / (t_1 * t_1);
} else if (x <= 8.5e+208) {
tmp = t_0 / (x * (x * (c * (s * (s * c)))));
} else {
tmp = (t_0 / (s * (x * s))) / (c * (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 = math.cos((x * 2.0)) t_1 = c * (x * s) tmp = 0 if x <= 1.2e-17: tmp = 1.0 / (t_1 * t_1) elif x <= 8.5e+208: tmp = t_0 / (x * (x * (c * (s * (s * c))))) else: tmp = (t_0 / (s * (x * s))) / (c * (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 = cos(Float64(x * 2.0)) t_1 = Float64(c * Float64(x * s)) tmp = 0.0 if (x <= 1.2e-17) tmp = Float64(1.0 / Float64(t_1 * t_1)); elseif (x <= 8.5e+208) tmp = Float64(t_0 / Float64(x * Float64(x * Float64(c * Float64(s * Float64(s * c)))))); else tmp = Float64(Float64(t_0 / Float64(s * Float64(x * s))) / 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)
t_0 = cos((x * 2.0));
t_1 = c * (x * s);
tmp = 0.0;
if (x <= 1.2e-17)
tmp = 1.0 / (t_1 * t_1);
elseif (x <= 8.5e+208)
tmp = t_0 / (x * (x * (c * (s * (s * c)))));
else
tmp = (t_0 / (s * (x * s))) / (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_] := Block[{t$95$0 = N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.2e-17], N[(1.0 / N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8.5e+208], N[(t$95$0 / N[(x * N[(x * N[(c * N[(s * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / N[(s * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \cos \left(x \cdot 2\right)\\
t_1 := c \cdot \left(x \cdot s\right)\\
\mathbf{if}\;x \leq 1.2 \cdot 10^{-17}:\\
\;\;\;\;\frac{1}{t_1 \cdot t_1}\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{+208}:\\
\;\;\;\;\frac{t_0}{x \cdot \left(x \cdot \left(c \cdot \left(s \cdot \left(s \cdot c\right)\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t_0}{s \cdot \left(x \cdot s\right)}}{c \cdot \left(x \cdot c\right)}\\
\end{array}
\end{array}
if x < 1.19999999999999993e-17Initial program 70.4%
associate-/r*70.5%
remove-double-neg70.5%
distribute-lft-neg-out70.5%
distribute-lft-neg-out70.5%
distribute-rgt-neg-out70.5%
associate-/l/70.4%
distribute-rgt-neg-out70.4%
distribute-lft-neg-out70.4%
associate-*l*71.9%
distribute-lft-neg-in71.9%
distribute-lft-neg-out71.9%
remove-double-neg71.9%
associate-*r*70.9%
*-commutative70.9%
associate-*r*70.1%
Simplified70.1%
Taylor expanded in x around 0 59.5%
unpow259.5%
unpow259.5%
associate-*r*59.1%
*-commutative59.1%
associate-*r*57.6%
unpow257.6%
Simplified57.6%
add-sqr-sqrt57.6%
pow257.6%
sqrt-div57.6%
metadata-eval57.6%
sqrt-prod57.6%
sqrt-prod33.6%
add-sqr-sqrt63.8%
unswap-sqr77.0%
sqrt-prod53.6%
add-sqr-sqrt86.3%
associate-*r*86.1%
*-commutative86.1%
associate-*r*86.3%
pow286.3%
associate-/r*86.4%
associate-/r*86.3%
Applied egg-rr86.3%
associate-/l/86.4%
associate-/l/86.3%
frac-times86.4%
metadata-eval86.4%
*-commutative86.4%
*-commutative86.4%
Applied egg-rr86.4%
if 1.19999999999999993e-17 < x < 8.4999999999999992e208Initial program 58.8%
associate-/r*56.7%
remove-double-neg56.7%
distribute-lft-neg-out56.7%
distribute-lft-neg-out56.7%
distribute-rgt-neg-out56.7%
associate-/l/58.8%
distribute-rgt-neg-out58.8%
distribute-lft-neg-out58.8%
associate-*l*56.8%
distribute-lft-neg-in56.8%
distribute-lft-neg-out56.8%
remove-double-neg56.8%
associate-*r*58.7%
*-commutative58.7%
associate-*r*58.8%
Simplified65.1%
Taylor expanded in c around 0 65.1%
unpow265.1%
associate-*l*90.2%
Simplified90.2%
if 8.4999999999999992e208 < x Initial program 58.7%
associate-/r*60.4%
remove-double-neg60.4%
distribute-lft-neg-out60.4%
distribute-lft-neg-out60.4%
distribute-rgt-neg-out60.4%
associate-/l/58.7%
distribute-rgt-neg-out58.7%
distribute-lft-neg-out58.7%
associate-*l*64.1%
distribute-lft-neg-in64.1%
distribute-lft-neg-out64.1%
remove-double-neg64.1%
associate-*r*64.2%
*-commutative64.2%
associate-*r*58.6%
Simplified58.6%
swap-sqr73.9%
swap-sqr58.6%
associate-*r*70.2%
*-un-lft-identity70.2%
associate-*r*63.0%
associate-*r*51.2%
*-commutative51.2%
associate-*r*51.6%
associate-*r*58.7%
*-commutative58.7%
associate-*r*64.1%
times-frac65.8%
associate-*l*84.0%
*-commutative84.0%
*-commutative84.0%
associate-*l*94.2%
Applied egg-rr94.2%
associate-*l/94.2%
*-lft-identity94.2%
*-commutative94.2%
Simplified94.2%
Final simplification87.6%
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 (cos (* x 2.0))) (t_1 (* c (* x s))))
(if (<= x 1e-42)
(/ 1.0 (* t_1 t_1))
(if (<= x 2e+92)
(/ t_0 (* (* x x) (* (* s c) (* s c))))
(/ (/ t_0 c) (* (* s (* x c)) (* x s)))))))x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = cos((x * 2.0));
double t_1 = c * (x * s);
double tmp;
if (x <= 1e-42) {
tmp = 1.0 / (t_1 * t_1);
} else if (x <= 2e+92) {
tmp = t_0 / ((x * x) * ((s * c) * (s * c)));
} else {
tmp = (t_0 / c) / ((s * (x * c)) * (x * s));
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((x * 2.0d0))
t_1 = c * (x * s)
if (x <= 1d-42) then
tmp = 1.0d0 / (t_1 * t_1)
else if (x <= 2d+92) then
tmp = t_0 / ((x * x) * ((s * c) * (s * c)))
else
tmp = (t_0 / c) / ((s * (x * c)) * (x * s))
end if
code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = Math.cos((x * 2.0));
double t_1 = c * (x * s);
double tmp;
if (x <= 1e-42) {
tmp = 1.0 / (t_1 * t_1);
} else if (x <= 2e+92) {
tmp = t_0 / ((x * x) * ((s * c) * (s * c)));
} else {
tmp = (t_0 / c) / ((s * (x * c)) * (x * s));
}
return tmp;
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = math.cos((x * 2.0)) t_1 = c * (x * s) tmp = 0 if x <= 1e-42: tmp = 1.0 / (t_1 * t_1) elif x <= 2e+92: tmp = t_0 / ((x * x) * ((s * c) * (s * c))) else: tmp = (t_0 / c) / ((s * (x * c)) * (x * s)) return tmp
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = cos(Float64(x * 2.0)) t_1 = Float64(c * Float64(x * s)) tmp = 0.0 if (x <= 1e-42) tmp = Float64(1.0 / Float64(t_1 * t_1)); elseif (x <= 2e+92) tmp = Float64(t_0 / Float64(Float64(x * x) * Float64(Float64(s * c) * Float64(s * c)))); else tmp = Float64(Float64(t_0 / c) / Float64(Float64(s * Float64(x * c)) * Float64(x * s))); end return tmp end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = cos((x * 2.0));
t_1 = c * (x * s);
tmp = 0.0;
if (x <= 1e-42)
tmp = 1.0 / (t_1 * t_1);
elseif (x <= 2e+92)
tmp = t_0 / ((x * x) * ((s * c) * (s * c)));
else
tmp = (t_0 / c) / ((s * (x * c)) * (x * s));
end
tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1e-42], N[(1.0 / N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2e+92], N[(t$95$0 / N[(N[(x * x), $MachinePrecision] * N[(N[(s * c), $MachinePrecision] * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 / c), $MachinePrecision] / N[(N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision] * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \cos \left(x \cdot 2\right)\\
t_1 := c \cdot \left(x \cdot s\right)\\
\mathbf{if}\;x \leq 10^{-42}:\\
\;\;\;\;\frac{1}{t_1 \cdot t_1}\\
\mathbf{elif}\;x \leq 2 \cdot 10^{+92}:\\
\;\;\;\;\frac{t_0}{\left(x \cdot x\right) \cdot \left(\left(s \cdot c\right) \cdot \left(s \cdot c\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t_0}{c}}{\left(s \cdot \left(x \cdot c\right)\right) \cdot \left(x \cdot s\right)}\\
\end{array}
\end{array}
if x < 1.00000000000000004e-42Initial program 70.7%
associate-/r*70.7%
remove-double-neg70.7%
distribute-lft-neg-out70.7%
distribute-lft-neg-out70.7%
distribute-rgt-neg-out70.7%
associate-/l/70.7%
distribute-rgt-neg-out70.7%
distribute-lft-neg-out70.7%
associate-*l*72.2%
distribute-lft-neg-in72.2%
distribute-lft-neg-out72.2%
remove-double-neg72.2%
associate-*r*71.2%
*-commutative71.2%
associate-*r*70.3%
Simplified70.3%
Taylor expanded in x around 0 59.3%
unpow259.3%
unpow259.3%
associate-*r*58.9%
*-commutative58.9%
associate-*r*57.3%
unpow257.3%
Simplified57.3%
add-sqr-sqrt57.3%
pow257.3%
sqrt-div57.3%
metadata-eval57.3%
sqrt-prod57.3%
sqrt-prod32.8%
add-sqr-sqrt63.2%
unswap-sqr77.1%
sqrt-prod54.4%
add-sqr-sqrt85.7%
associate-*r*85.5%
*-commutative85.5%
associate-*r*85.7%
pow285.7%
associate-/r*85.8%
associate-/r*85.7%
Applied egg-rr85.7%
associate-/l/85.8%
associate-/l/85.7%
frac-times85.8%
metadata-eval85.8%
*-commutative85.8%
*-commutative85.8%
Applied egg-rr85.8%
if 1.00000000000000004e-42 < x < 2.0000000000000001e92Initial program 59.7%
associate-/r*59.7%
*-commutative59.7%
associate-*l*59.7%
unpow259.7%
unpow259.7%
associate-*r*60.1%
associate-/r*72.1%
associate-/l/72.2%
associate-/l/72.1%
*-commutative72.1%
associate-*l*72.4%
unpow272.4%
associate-*l*59.7%
unpow259.7%
unswap-sqr99.5%
*-commutative99.5%
*-commutative99.5%
Simplified99.5%
if 2.0000000000000001e92 < x Initial program 59.1%
associate-/r*57.5%
remove-double-neg57.5%
distribute-lft-neg-out57.5%
distribute-lft-neg-out57.5%
distribute-rgt-neg-out57.5%
associate-/l/59.1%
distribute-rgt-neg-out59.1%
distribute-lft-neg-out59.1%
associate-*l*61.2%
distribute-lft-neg-in61.2%
distribute-lft-neg-out61.2%
remove-double-neg61.2%
associate-*r*63.5%
*-commutative63.5%
associate-*r*59.1%
Simplified59.1%
associate-/r*59.8%
swap-sqr86.1%
associate-/r*70.2%
associate-/r*70.2%
associate-/r*70.2%
*-un-lft-identity70.2%
add-sqr-sqrt70.2%
times-frac70.2%
Applied egg-rr97.5%
associate-/r*97.5%
frac-times95.5%
*-un-lft-identity95.5%
associate-*r*89.2%
*-commutative89.2%
associate-*r*93.3%
Applied egg-rr93.3%
Final simplification88.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 7e-18)
(/ 1.0 (* t_0 t_0))
(/ (cos (* x 2.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 t_0 = c * (x * s);
double tmp;
if (x <= 7e-18) {
tmp = 1.0 / (t_0 * t_0);
} else {
tmp = cos((x * 2.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) :: t_0
real(8) :: tmp
t_0 = c * (x * s)
if (x <= 7d-18) then
tmp = 1.0d0 / (t_0 * t_0)
else
tmp = cos((x * 2.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 t_0 = c * (x * s);
double tmp;
if (x <= 7e-18) {
tmp = 1.0 / (t_0 * t_0);
} else {
tmp = Math.cos((x * 2.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): t_0 = c * (x * s) tmp = 0 if x <= 7e-18: tmp = 1.0 / (t_0 * t_0) else: tmp = math.cos((x * 2.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) t_0 = Float64(c * Float64(x * s)) tmp = 0.0 if (x <= 7e-18) tmp = Float64(1.0 / Float64(t_0 * t_0)); else tmp = Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(x * Float64(c * Float64(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)
t_0 = c * (x * s);
tmp = 0.0;
if (x <= 7e-18)
tmp = 1.0 / (t_0 * t_0);
else
tmp = cos((x * 2.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_] := Block[{t$95$0 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 7e-18], N[(1.0 / N[(t$95$0 * t$95$0), $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}
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 7 \cdot 10^{-18}:\\
\;\;\;\;\frac{1}{t_0 \cdot t_0}\\
\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 < 6.9999999999999997e-18Initial program 70.4%
associate-/r*70.5%
remove-double-neg70.5%
distribute-lft-neg-out70.5%
distribute-lft-neg-out70.5%
distribute-rgt-neg-out70.5%
associate-/l/70.4%
distribute-rgt-neg-out70.4%
distribute-lft-neg-out70.4%
associate-*l*71.9%
distribute-lft-neg-in71.9%
distribute-lft-neg-out71.9%
remove-double-neg71.9%
associate-*r*70.9%
*-commutative70.9%
associate-*r*70.1%
Simplified70.1%
Taylor expanded in x around 0 59.5%
unpow259.5%
unpow259.5%
associate-*r*59.1%
*-commutative59.1%
associate-*r*57.6%
unpow257.6%
Simplified57.6%
add-sqr-sqrt57.6%
pow257.6%
sqrt-div57.6%
metadata-eval57.6%
sqrt-prod57.6%
sqrt-prod33.6%
add-sqr-sqrt63.8%
unswap-sqr77.0%
sqrt-prod53.6%
add-sqr-sqrt86.3%
associate-*r*86.1%
*-commutative86.1%
associate-*r*86.3%
pow286.3%
associate-/r*86.4%
associate-/r*86.3%
Applied egg-rr86.3%
associate-/l/86.4%
associate-/l/86.3%
frac-times86.4%
metadata-eval86.4%
*-commutative86.4%
*-commutative86.4%
Applied egg-rr86.4%
if 6.9999999999999997e-18 < x Initial program 58.8%
associate-/r*57.7%
remove-double-neg57.7%
distribute-lft-neg-out57.7%
distribute-lft-neg-out57.7%
distribute-rgt-neg-out57.7%
associate-/l/58.8%
distribute-rgt-neg-out58.8%
distribute-lft-neg-out58.8%
associate-*l*58.7%
distribute-lft-neg-in58.7%
distribute-lft-neg-out58.7%
remove-double-neg58.7%
associate-*r*60.1%
*-commutative60.1%
associate-*r*58.7%
Simplified66.4%
Final simplification81.1%
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
:precision binary64
(let* ((t_0 (* c (* x s))))
(if (<= x 1.2e-17)
(/ 1.0 (* t_0 t_0))
(/ (cos (* x 2.0)) (* x (* x (* c (* s (* s 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 <= 1.2e-17) {
tmp = 1.0 / (t_0 * t_0);
} else {
tmp = cos((x * 2.0)) / (x * (x * (c * (s * (s * 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 <= 1.2d-17) then
tmp = 1.0d0 / (t_0 * t_0)
else
tmp = cos((x * 2.0d0)) / (x * (x * (c * (s * (s * 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 <= 1.2e-17) {
tmp = 1.0 / (t_0 * t_0);
} else {
tmp = Math.cos((x * 2.0)) / (x * (x * (c * (s * (s * 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 <= 1.2e-17: tmp = 1.0 / (t_0 * t_0) else: tmp = math.cos((x * 2.0)) / (x * (x * (c * (s * (s * 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 <= 1.2e-17) tmp = Float64(1.0 / Float64(t_0 * t_0)); else tmp = Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(x * Float64(c * Float64(s * Float64(s * 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 <= 1.2e-17)
tmp = 1.0 / (t_0 * t_0);
else
tmp = cos((x * 2.0)) / (x * (x * (c * (s * (s * 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, 1.2e-17], N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * N[(x * N[(c * N[(s * N[(s * 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}
t_0 := c \cdot \left(x \cdot s\right)\\
\mathbf{if}\;x \leq 1.2 \cdot 10^{-17}:\\
\;\;\;\;\frac{1}{t_0 \cdot t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(x \cdot \left(c \cdot \left(s \cdot \left(s \cdot c\right)\right)\right)\right)}\\
\end{array}
\end{array}
if x < 1.19999999999999993e-17Initial program 70.4%
associate-/r*70.5%
remove-double-neg70.5%
distribute-lft-neg-out70.5%
distribute-lft-neg-out70.5%
distribute-rgt-neg-out70.5%
associate-/l/70.4%
distribute-rgt-neg-out70.4%
distribute-lft-neg-out70.4%
associate-*l*71.9%
distribute-lft-neg-in71.9%
distribute-lft-neg-out71.9%
remove-double-neg71.9%
associate-*r*70.9%
*-commutative70.9%
associate-*r*70.1%
Simplified70.1%
Taylor expanded in x around 0 59.5%
unpow259.5%
unpow259.5%
associate-*r*59.1%
*-commutative59.1%
associate-*r*57.6%
unpow257.6%
Simplified57.6%
add-sqr-sqrt57.6%
pow257.6%
sqrt-div57.6%
metadata-eval57.6%
sqrt-prod57.6%
sqrt-prod33.6%
add-sqr-sqrt63.8%
unswap-sqr77.0%
sqrt-prod53.6%
add-sqr-sqrt86.3%
associate-*r*86.1%
*-commutative86.1%
associate-*r*86.3%
pow286.3%
associate-/r*86.4%
associate-/r*86.3%
Applied egg-rr86.3%
associate-/l/86.4%
associate-/l/86.3%
frac-times86.4%
metadata-eval86.4%
*-commutative86.4%
*-commutative86.4%
Applied egg-rr86.4%
if 1.19999999999999993e-17 < x Initial program 58.8%
associate-/r*57.7%
remove-double-neg57.7%
distribute-lft-neg-out57.7%
distribute-lft-neg-out57.7%
distribute-rgt-neg-out57.7%
associate-/l/58.8%
distribute-rgt-neg-out58.8%
distribute-lft-neg-out58.8%
associate-*l*58.7%
distribute-lft-neg-in58.7%
distribute-lft-neg-out58.7%
remove-double-neg58.7%
associate-*r*60.1%
*-commutative60.1%
associate-*r*58.7%
Simplified66.4%
Taylor expanded in c around 0 66.4%
unpow266.4%
associate-*l*85.1%
Simplified85.1%
Final simplification86.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 (/ 1.0 (* (* s c) (* (* x x) (* s 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 * c) * ((x * x) * (s * 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 * c) * ((x * x) * (s * 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 * c) * ((x * x) * (s * c)));
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return 1.0 / ((s * c) * ((x * x) * (s * 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(Float64(s * c) * Float64(Float64(x * x) * Float64(s * 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 * c) * ((x * x) * (s * 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[(N[(s * c), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{\left(s \cdot c\right) \cdot \left(\left(x \cdot x\right) \cdot \left(s \cdot c\right)\right)}
\end{array}
Initial program 67.4%
associate-/r*67.1%
remove-double-neg67.1%
distribute-lft-neg-out67.1%
distribute-lft-neg-out67.1%
distribute-rgt-neg-out67.1%
associate-/l/67.4%
distribute-rgt-neg-out67.4%
distribute-lft-neg-out67.4%
associate-*l*68.4%
distribute-lft-neg-in68.4%
distribute-lft-neg-out68.4%
remove-double-neg68.4%
associate-*r*68.1%
*-commutative68.1%
associate-*r*67.1%
Simplified67.1%
Taylor expanded in x around 0 54.3%
unpow254.3%
associate-/r*53.9%
unpow253.9%
unpow253.9%
swap-sqr68.0%
unpow268.0%
associate-/r*68.4%
unpow268.4%
swap-sqr79.0%
unpow279.0%
associate-*r*78.8%
*-commutative78.8%
associate-*l*79.0%
Simplified79.0%
unpow279.0%
associate-*r*77.8%
associate-*r*78.8%
unswap-sqr67.4%
associate-*l*69.8%
*-commutative69.8%
*-commutative69.8%
Applied egg-rr69.8%
Final simplification69.8%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (let* ((t_0 (* x (* s 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 = x * (s * 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 = x * (s * 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 = x * (s * 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 = x * (s * 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(x * Float64(s * 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 = x * (s * 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[(x * N[(s * 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 := x \cdot \left(s \cdot c\right)\\
\frac{1}{t_0 \cdot t_0}
\end{array}
\end{array}
Initial program 67.4%
associate-/r*67.1%
remove-double-neg67.1%
distribute-lft-neg-out67.1%
distribute-lft-neg-out67.1%
distribute-rgt-neg-out67.1%
associate-/l/67.4%
distribute-rgt-neg-out67.4%
distribute-lft-neg-out67.4%
associate-*l*68.4%
distribute-lft-neg-in68.4%
distribute-lft-neg-out68.4%
remove-double-neg68.4%
associate-*r*68.1%
*-commutative68.1%
associate-*r*67.1%
Simplified67.1%
Taylor expanded in x around 0 54.3%
unpow254.3%
associate-/r*53.9%
unpow253.9%
unpow253.9%
swap-sqr68.0%
unpow268.0%
associate-/r*68.4%
unpow268.4%
swap-sqr79.0%
unpow279.0%
associate-*r*78.8%
*-commutative78.8%
associate-*l*79.0%
Simplified79.0%
associate-*r*78.8%
pow-prod-down67.4%
pow267.4%
pow267.4%
*-commutative67.4%
*-commutative67.4%
associate-*r*65.4%
associate-*r*70.2%
add-sqr-sqrt70.2%
associate-*r*65.4%
associate-*r*65.4%
*-commutative65.4%
sqrt-prod65.4%
sqrt-prod32.3%
add-sqr-sqrt55.3%
sqrt-prod31.6%
add-sqr-sqrt57.7%
*-commutative57.7%
associate-*r*53.0%
associate-*r*54.0%
Applied egg-rr78.8%
Final simplification78.8%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (let* ((t_0 (* c (* x s)))) (/ 1.0 (* t_0 t_0))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = c * (x * s);
return 1.0 / (t_0 * t_0);
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
t_0 = c * (x * s)
code = 1.0d0 / (t_0 * t_0)
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = c * (x * s);
return 1.0 / (t_0 * t_0);
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = c * (x * s) return 1.0 / (t_0 * t_0)
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(c * Float64(x * s)) return Float64(1.0 / Float64(t_0 * t_0)) end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
t_0 = c * (x * s);
tmp = 1.0 / (t_0 * t_0);
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\frac{1}{t_0 \cdot t_0}
\end{array}
\end{array}
Initial program 67.4%
associate-/r*67.1%
remove-double-neg67.1%
distribute-lft-neg-out67.1%
distribute-lft-neg-out67.1%
distribute-rgt-neg-out67.1%
associate-/l/67.4%
distribute-rgt-neg-out67.4%
distribute-lft-neg-out67.4%
associate-*l*68.4%
distribute-lft-neg-in68.4%
distribute-lft-neg-out68.4%
remove-double-neg68.4%
associate-*r*68.1%
*-commutative68.1%
associate-*r*67.1%
Simplified67.1%
Taylor expanded in x around 0 54.3%
unpow254.3%
unpow254.3%
associate-*r*54.0%
*-commutative54.0%
associate-*r*52.9%
unpow252.9%
Simplified52.9%
add-sqr-sqrt52.9%
pow252.9%
sqrt-div52.9%
metadata-eval52.9%
sqrt-prod52.9%
sqrt-prod30.9%
add-sqr-sqrt60.3%
unswap-sqr71.9%
sqrt-prod45.6%
add-sqr-sqrt78.9%
associate-*r*78.7%
*-commutative78.7%
associate-*r*78.9%
pow278.9%
associate-/r*78.9%
associate-/r*78.9%
Applied egg-rr78.9%
associate-/l/78.9%
associate-/l/78.9%
frac-times79.0%
metadata-eval79.0%
*-commutative79.0%
*-commutative79.0%
Applied egg-rr79.0%
Final simplification79.0%
herbie shell --seed 2023273
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))