
(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 11 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 (cos (* x 2.0))))
(if (<= x 5e-75)
(* (pow (* c (* x s)) -2.0) t_1)
(* (/ t_1 t_0) (/ 1.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 = cos((x * 2.0));
double tmp;
if (x <= 5e-75) {
tmp = pow((c * (x * s)), -2.0) * t_1;
} else {
tmp = (t_1 / t_0) * (1.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 = cos((x * 2.0d0))
if (x <= 5d-75) then
tmp = ((c * (x * s)) ** (-2.0d0)) * t_1
else
tmp = (t_1 / t_0) * (1.0d0 / 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 = Math.cos((x * 2.0));
double tmp;
if (x <= 5e-75) {
tmp = Math.pow((c * (x * s)), -2.0) * t_1;
} else {
tmp = (t_1 / t_0) * (1.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 = math.cos((x * 2.0)) tmp = 0 if x <= 5e-75: tmp = math.pow((c * (x * s)), -2.0) * t_1 else: tmp = (t_1 / t_0) * (1.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 = cos(Float64(x * 2.0)) tmp = 0.0 if (x <= 5e-75) tmp = Float64((Float64(c * Float64(x * s)) ^ -2.0) * t_1); else tmp = Float64(Float64(t_1 / t_0) * Float64(1.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 = cos((x * 2.0));
tmp = 0.0;
if (x <= 5e-75)
tmp = ((c * (x * s)) ^ -2.0) * t_1;
else
tmp = (t_1 / t_0) * (1.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[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 5e-75], N[(N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(t$95$1 / t$95$0), $MachinePrecision] * N[(1.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)\\
t_1 := \cos \left(x \cdot 2\right)\\
\mathbf{if}\;x \leq 5 \cdot 10^{-75}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2} \cdot t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{t_0} \cdot \frac{1}{t_0}\\
\end{array}
\end{array}
if x < 4.99999999999999979e-75Initial program 65.9%
*-commutative65.9%
associate-*r*60.7%
associate-*r*60.7%
unpow260.7%
unswap-sqr74.6%
unpow274.6%
swap-sqr93.9%
*-commutative93.9%
*-commutative93.9%
*-commutative93.9%
*-commutative93.9%
Simplified93.9%
Taylor expanded in x around inf 60.7%
associate-/r*60.5%
*-commutative60.5%
unpow260.5%
unpow260.5%
swap-sqr77.9%
unpow277.9%
associate-/l/78.1%
unpow278.1%
unpow278.1%
swap-sqr96.8%
associate-*r*91.7%
associate-*r*93.9%
associate-/r*94.2%
*-rgt-identity94.2%
associate-*r/94.2%
Simplified97.2%
if 4.99999999999999979e-75 < x Initial program 59.1%
*-commutative59.1%
associate-*r*55.6%
associate-*r*54.6%
unpow254.6%
unswap-sqr66.0%
unpow266.0%
swap-sqr97.9%
*-commutative97.9%
*-commutative97.9%
*-commutative97.9%
*-commutative97.9%
Simplified97.9%
associate-/r*98.4%
div-inv98.4%
*-commutative98.4%
Applied egg-rr98.4%
Final simplification97.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 (/ (/ 1.0 c) (* x s))))
(if (<= x 9e-9)
(* t_0 t_0)
(if (<= x 6.6e+150)
(/ (cos (* x 2.0)) (* s (* (* x x) (* s (* c c)))))
(/ 1.0 (* s (* s (pow (* x c) 2.0))))))))x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = (1.0 / c) / (x * s);
double tmp;
if (x <= 9e-9) {
tmp = t_0 * t_0;
} else if (x <= 6.6e+150) {
tmp = cos((x * 2.0)) / (s * ((x * x) * (s * (c * c))));
} else {
tmp = 1.0 / (s * (s * pow((x * c), 2.0)));
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: tmp
t_0 = (1.0d0 / c) / (x * s)
if (x <= 9d-9) then
tmp = t_0 * t_0
else if (x <= 6.6d+150) then
tmp = cos((x * 2.0d0)) / (s * ((x * x) * (s * (c * c))))
else
tmp = 1.0d0 / (s * (s * ((x * c) ** 2.0d0)))
end if
code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = (1.0 / c) / (x * s);
double tmp;
if (x <= 9e-9) {
tmp = t_0 * t_0;
} else if (x <= 6.6e+150) {
tmp = Math.cos((x * 2.0)) / (s * ((x * x) * (s * (c * c))));
} else {
tmp = 1.0 / (s * (s * Math.pow((x * c), 2.0)));
}
return tmp;
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = (1.0 / c) / (x * s) tmp = 0 if x <= 9e-9: tmp = t_0 * t_0 elif x <= 6.6e+150: tmp = math.cos((x * 2.0)) / (s * ((x * x) * (s * (c * c)))) else: tmp = 1.0 / (s * (s * math.pow((x * c), 2.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(Float64(1.0 / c) / Float64(x * s)) tmp = 0.0 if (x <= 9e-9) tmp = Float64(t_0 * t_0); elseif (x <= 6.6e+150) tmp = Float64(cos(Float64(x * 2.0)) / Float64(s * Float64(Float64(x * x) * Float64(s * Float64(c * c))))); else tmp = Float64(1.0 / Float64(s * Float64(s * (Float64(x * c) ^ 2.0)))); end return tmp end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = (1.0 / c) / (x * s);
tmp = 0.0;
if (x <= 9e-9)
tmp = t_0 * t_0;
elseif (x <= 6.6e+150)
tmp = cos((x * 2.0)) / (s * ((x * x) * (s * (c * c))));
else
tmp = 1.0 / (s * (s * ((x * c) ^ 2.0)));
end
tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 9e-9], N[(t$95$0 * t$95$0), $MachinePrecision], If[LessEqual[x, 6.6e+150], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(s * N[(N[(x * x), $MachinePrecision] * N[(s * N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(s * N[(s * N[Power[N[(x * c), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{1}{c}}{x \cdot s}\\
\mathbf{if}\;x \leq 9 \cdot 10^{-9}:\\
\;\;\;\;t_0 \cdot t_0\\
\mathbf{elif}\;x \leq 6.6 \cdot 10^{+150}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{s \cdot \left(\left(x \cdot x\right) \cdot \left(s \cdot \left(c \cdot c\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{s \cdot \left(s \cdot {\left(x \cdot c\right)}^{2}\right)}\\
\end{array}
\end{array}
if x < 8.99999999999999953e-9Initial program 66.1%
associate-/r*65.8%
unpow265.8%
*-commutative65.8%
unpow265.8%
Simplified65.8%
Taylor expanded in x around 0 60.7%
unpow260.7%
Simplified60.7%
add-sqr-sqrt60.7%
sqrt-div60.7%
sqrt-div60.7%
metadata-eval60.7%
sqrt-prod27.7%
add-sqr-sqrt39.0%
associate-*r*36.9%
sqrt-prod36.9%
sqrt-unprod12.6%
add-sqr-sqrt44.3%
sqrt-prod24.4%
add-sqr-sqrt44.1%
*-commutative44.1%
sqrt-div44.0%
sqrt-div44.6%
metadata-eval44.6%
sqrt-prod22.6%
add-sqr-sqrt42.7%
associate-*r*40.2%
sqrt-prod41.8%
Applied egg-rr84.7%
if 8.99999999999999953e-9 < x < 6.59999999999999962e150Initial program 61.6%
*-commutative61.6%
associate-*l*61.6%
associate-*r*61.9%
*-commutative61.9%
unpow261.9%
associate-*r*75.2%
associate-*r*77.4%
*-commutative77.4%
unpow277.4%
Simplified77.4%
if 6.59999999999999962e150 < x Initial program 52.7%
*-commutative52.7%
associate-*r*43.7%
associate-*r*43.7%
unpow243.7%
unswap-sqr67.1%
unpow267.1%
swap-sqr95.6%
*-commutative95.6%
*-commutative95.6%
*-commutative95.6%
*-commutative95.6%
Simplified95.6%
Taylor expanded in x around 0 43.7%
associate-/r*43.7%
unpow243.7%
unpow243.7%
swap-sqr60.7%
unpow260.7%
associate-/l/60.7%
unpow260.7%
unpow260.7%
swap-sqr71.1%
associate-*r*70.8%
associate-*r*70.8%
unpow270.8%
associate-*r*71.1%
*-commutative71.1%
Simplified71.1%
associate-*r*70.9%
pow270.9%
*-commutative70.9%
associate-*r*70.6%
associate-*r*69.5%
*-commutative69.5%
*-commutative69.5%
associate-*r*69.7%
associate-*r*69.7%
pow269.7%
*-commutative69.7%
Applied egg-rr69.7%
Final simplification81.3%
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 (/ (/ 1.0 c) (* x s)))) (if (<= x 1.3e-77) (* t_1 t_1) (* (/ (cos (* x 2.0)) t_0) (/ 1.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 = (1.0 / c) / (x * s);
double tmp;
if (x <= 1.3e-77) {
tmp = t_1 * t_1;
} else {
tmp = (cos((x * 2.0)) / t_0) * (1.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 = (1.0d0 / c) / (x * s)
if (x <= 1.3d-77) then
tmp = t_1 * t_1
else
tmp = (cos((x * 2.0d0)) / t_0) * (1.0d0 / 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 = (1.0 / c) / (x * s);
double tmp;
if (x <= 1.3e-77) {
tmp = t_1 * t_1;
} else {
tmp = (Math.cos((x * 2.0)) / t_0) * (1.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 = (1.0 / c) / (x * s) tmp = 0 if x <= 1.3e-77: tmp = t_1 * t_1 else: tmp = (math.cos((x * 2.0)) / t_0) * (1.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(Float64(1.0 / c) / Float64(x * s)) tmp = 0.0 if (x <= 1.3e-77) tmp = Float64(t_1 * t_1); else tmp = Float64(Float64(cos(Float64(x * 2.0)) / t_0) * Float64(1.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 = (1.0 / c) / (x * s);
tmp = 0.0;
if (x <= 1.3e-77)
tmp = t_1 * t_1;
else
tmp = (cos((x * 2.0)) / t_0) * (1.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[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.3e-77], N[(t$95$1 * t$95$1), $MachinePrecision], N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] * N[(1.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)\\
t_1 := \frac{\frac{1}{c}}{x \cdot s}\\
\mathbf{if}\;x \leq 1.3 \cdot 10^{-77}:\\
\;\;\;\;t_1 \cdot t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{t_0} \cdot \frac{1}{t_0}\\
\end{array}
\end{array}
if x < 1.3000000000000001e-77Initial program 66.2%
associate-/r*65.9%
unpow265.9%
*-commutative65.9%
unpow265.9%
Simplified65.9%
Taylor expanded in x around 0 60.2%
unpow260.2%
Simplified60.2%
add-sqr-sqrt60.2%
sqrt-div60.2%
sqrt-div60.2%
metadata-eval60.2%
sqrt-prod28.7%
add-sqr-sqrt39.9%
associate-*r*37.5%
sqrt-prod37.6%
sqrt-unprod10.6%
add-sqr-sqrt45.8%
sqrt-prod25.0%
add-sqr-sqrt45.5%
*-commutative45.5%
sqrt-div45.5%
sqrt-div46.1%
metadata-eval46.1%
sqrt-prod23.1%
add-sqr-sqrt41.5%
associate-*r*38.8%
sqrt-prod40.5%
Applied egg-rr83.2%
if 1.3000000000000001e-77 < x Initial program 58.9%
*-commutative58.9%
associate-*r*55.4%
associate-*r*54.5%
unpow254.5%
unswap-sqr65.6%
unpow265.6%
swap-sqr97.9%
*-commutative97.9%
*-commutative97.9%
*-commutative97.9%
*-commutative97.9%
Simplified97.9%
associate-/r*98.4%
div-inv98.5%
*-commutative98.5%
Applied egg-rr98.5%
Final simplification89.0%
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
:precision binary64
(let* ((t_0 (/ (/ 1.0 c) (* x s))))
(if (<= s 1.95e+125)
(/ (cos (* x 2.0)) (* x (* x (* (* s s) (* c c)))))
(* 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 = (1.0 / c) / (x * s);
double tmp;
if (s <= 1.95e+125) {
tmp = cos((x * 2.0)) / (x * (x * ((s * s) * (c * c))));
} else {
tmp = 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 = (1.0d0 / c) / (x * s)
if (s <= 1.95d+125) then
tmp = cos((x * 2.0d0)) / (x * (x * ((s * s) * (c * c))))
else
tmp = 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 = (1.0 / c) / (x * s);
double tmp;
if (s <= 1.95e+125) {
tmp = Math.cos((x * 2.0)) / (x * (x * ((s * s) * (c * c))));
} else {
tmp = 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 = (1.0 / c) / (x * s) tmp = 0 if s <= 1.95e+125: tmp = math.cos((x * 2.0)) / (x * (x * ((s * s) * (c * c)))) else: tmp = 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(Float64(1.0 / c) / Float64(x * s)) tmp = 0.0 if (s <= 1.95e+125) tmp = Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(x * Float64(Float64(s * s) * Float64(c * c))))); else tmp = 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 = (1.0 / c) / (x * s);
tmp = 0.0;
if (s <= 1.95e+125)
tmp = cos((x * 2.0)) / (x * (x * ((s * s) * (c * c))));
else
tmp = 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[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[s, 1.95e+125], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * N[(x * N[(N[(s * s), $MachinePrecision] * N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * t$95$0), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{1}{c}}{x \cdot s}\\
\mathbf{if}\;s \leq 1.95 \cdot 10^{+125}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(x \cdot \left(\left(s \cdot s\right) \cdot \left(c \cdot c\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot t_0\\
\end{array}
\end{array}
if s < 1.9500000000000001e125Initial program 66.7%
associate-*r*69.2%
*-commutative69.2%
*-commutative69.2%
associate-*r*67.5%
*-commutative67.5%
unpow267.5%
unpow267.5%
Simplified67.5%
if 1.9500000000000001e125 < s Initial program 47.5%
associate-/r*46.5%
unpow246.5%
*-commutative46.5%
unpow246.5%
Simplified46.5%
Taylor expanded in x around 0 46.5%
unpow246.5%
Simplified46.5%
add-sqr-sqrt46.6%
sqrt-div46.5%
sqrt-div46.6%
metadata-eval46.6%
sqrt-prod25.4%
add-sqr-sqrt42.1%
associate-*r*39.3%
sqrt-prod39.4%
sqrt-unprod25.8%
add-sqr-sqrt42.1%
sqrt-prod42.1%
add-sqr-sqrt42.1%
*-commutative42.1%
sqrt-div42.1%
sqrt-div44.5%
metadata-eval44.5%
sqrt-prod26.8%
add-sqr-sqrt48.5%
associate-*r*45.7%
sqrt-prod45.7%
Applied egg-rr86.9%
Final simplification70.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 (/ (/ 1.0 c) (* x s))))
(if (<= s 2.05e+148)
(/ (cos (* x 2.0)) (* x (* (* c (* x c)) (* s s))))
(* 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 = (1.0 / c) / (x * s);
double tmp;
if (s <= 2.05e+148) {
tmp = cos((x * 2.0)) / (x * ((c * (x * c)) * (s * s)));
} else {
tmp = 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 = (1.0d0 / c) / (x * s)
if (s <= 2.05d+148) then
tmp = cos((x * 2.0d0)) / (x * ((c * (x * c)) * (s * s)))
else
tmp = 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 = (1.0 / c) / (x * s);
double tmp;
if (s <= 2.05e+148) {
tmp = Math.cos((x * 2.0)) / (x * ((c * (x * c)) * (s * s)));
} else {
tmp = 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 = (1.0 / c) / (x * s) tmp = 0 if s <= 2.05e+148: tmp = math.cos((x * 2.0)) / (x * ((c * (x * c)) * (s * s))) else: tmp = 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(Float64(1.0 / c) / Float64(x * s)) tmp = 0.0 if (s <= 2.05e+148) tmp = Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(Float64(c * Float64(x * c)) * Float64(s * s)))); else tmp = 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 = (1.0 / c) / (x * s);
tmp = 0.0;
if (s <= 2.05e+148)
tmp = cos((x * 2.0)) / (x * ((c * (x * c)) * (s * s)));
else
tmp = 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[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[s, 2.05e+148], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * N[(N[(c * N[(x * c), $MachinePrecision]), $MachinePrecision] * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * t$95$0), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{1}{c}}{x \cdot s}\\
\mathbf{if}\;s \leq 2.05 \cdot 10^{+148}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(\left(c \cdot \left(x \cdot c\right)\right) \cdot \left(s \cdot s\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot t_0\\
\end{array}
\end{array}
if s < 2.0499999999999999e148Initial program 67.2%
associate-*r*69.6%
*-commutative69.6%
associate-*r*70.0%
unpow270.0%
unpow270.0%
Simplified70.0%
Taylor expanded in c around 0 70.0%
unpow270.0%
associate-*l*75.4%
Simplified75.4%
if 2.0499999999999999e148 < s Initial program 41.9%
associate-/r*40.7%
unpow240.7%
*-commutative40.7%
unpow240.7%
Simplified40.7%
Taylor expanded in x around 0 40.7%
unpow240.7%
Simplified40.7%
add-sqr-sqrt40.7%
sqrt-div40.7%
sqrt-div40.7%
metadata-eval40.7%
sqrt-prod24.0%
add-sqr-sqrt40.7%
associate-*r*37.5%
sqrt-prod37.5%
sqrt-unprod29.8%
add-sqr-sqrt40.7%
sqrt-prod40.7%
add-sqr-sqrt40.7%
*-commutative40.7%
sqrt-div40.7%
sqrt-div43.4%
metadata-eval43.4%
sqrt-prod28.4%
add-sqr-sqrt50.8%
associate-*r*47.5%
sqrt-prod47.5%
Applied egg-rr84.9%
Final simplification76.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 (/ (/ 1.0 c) (* x s))))
(if (<= x 4.5e-60)
(* t_0 t_0)
(/ (cos (* x 2.0)) (* (* c (* x s)) (* 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 = (1.0 / c) / (x * s);
double tmp;
if (x <= 4.5e-60) {
tmp = t_0 * t_0;
} else {
tmp = cos((x * 2.0)) / ((c * (x * s)) * (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 = (1.0d0 / c) / (x * s)
if (x <= 4.5d-60) then
tmp = t_0 * t_0
else
tmp = cos((x * 2.0d0)) / ((c * (x * s)) * (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 = (1.0 / c) / (x * s);
double tmp;
if (x <= 4.5e-60) {
tmp = t_0 * t_0;
} else {
tmp = Math.cos((x * 2.0)) / ((c * (x * s)) * (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 = (1.0 / c) / (x * s) tmp = 0 if x <= 4.5e-60: tmp = t_0 * t_0 else: tmp = math.cos((x * 2.0)) / ((c * (x * s)) * (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(Float64(1.0 / c) / Float64(x * s)) tmp = 0.0 if (x <= 4.5e-60) tmp = Float64(t_0 * t_0); else tmp = Float64(cos(Float64(x * 2.0)) / Float64(Float64(c * Float64(x * s)) * 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 = (1.0 / c) / (x * s);
tmp = 0.0;
if (x <= 4.5e-60)
tmp = t_0 * t_0;
else
tmp = cos((x * 2.0)) / ((c * (x * s)) * (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[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 4.5e-60], N[(t$95$0 * t$95$0), $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision] * 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 := \frac{\frac{1}{c}}{x \cdot s}\\
\mathbf{if}\;x \leq 4.5 \cdot 10^{-60}:\\
\;\;\;\;t_0 \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)}\\
\end{array}
\end{array}
if x < 4.50000000000000001e-60Initial program 65.6%
associate-/r*65.4%
unpow265.4%
*-commutative65.4%
unpow265.4%
Simplified65.4%
Taylor expanded in x around 0 59.9%
unpow259.9%
Simplified59.9%
add-sqr-sqrt59.9%
sqrt-div59.9%
sqrt-div59.9%
metadata-eval59.9%
sqrt-prod27.7%
add-sqr-sqrt39.1%
associate-*r*36.9%
sqrt-prod36.9%
sqrt-unprod10.9%
add-sqr-sqrt44.8%
sqrt-prod24.8%
add-sqr-sqrt45.2%
*-commutative45.2%
sqrt-div45.1%
sqrt-div45.7%
metadata-eval45.7%
sqrt-prod22.8%
add-sqr-sqrt41.9%
associate-*r*39.2%
sqrt-prod40.9%
Applied egg-rr83.8%
if 4.50000000000000001e-60 < x Initial program 59.3%
*-commutative59.3%
associate-*r*55.7%
associate-*r*54.7%
unpow254.7%
unswap-sqr65.5%
unpow265.5%
swap-sqr97.8%
*-commutative97.8%
*-commutative97.8%
*-commutative97.8%
*-commutative97.8%
Simplified97.8%
Taylor expanded in s around 0 95.9%
Final simplification88.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 (* s (* x c))) (t_1 (/ (/ 1.0 c) (* x s)))) (if (<= x 1.15e-58) (* 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 = (1.0 / c) / (x * s);
double tmp;
if (x <= 1.15e-58) {
tmp = 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 = (1.0d0 / c) / (x * s)
if (x <= 1.15d-58) then
tmp = 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 = (1.0 / c) / (x * s);
double tmp;
if (x <= 1.15e-58) {
tmp = 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 = (1.0 / c) / (x * s) tmp = 0 if x <= 1.15e-58: tmp = 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(Float64(1.0 / c) / Float64(x * s)) tmp = 0.0 if (x <= 1.15e-58) tmp = Float64(t_1 * t_1); 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);
t_1 = (1.0 / c) / (x * s);
tmp = 0.0;
if (x <= 1.15e-58)
tmp = 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[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.15e-58], N[(t$95$1 * t$95$1), $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)\\
t_1 := \frac{\frac{1}{c}}{x \cdot s}\\
\mathbf{if}\;x \leq 1.15 \cdot 10^{-58}:\\
\;\;\;\;t_1 \cdot t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{t_0 \cdot t_0}\\
\end{array}
\end{array}
if x < 1.1499999999999999e-58Initial program 65.8%
associate-/r*65.6%
unpow265.6%
*-commutative65.6%
unpow265.6%
Simplified65.6%
Taylor expanded in x around 0 60.1%
unpow260.1%
Simplified60.1%
add-sqr-sqrt60.1%
sqrt-div60.1%
sqrt-div60.1%
metadata-eval60.1%
sqrt-prod27.5%
add-sqr-sqrt38.9%
associate-*r*36.6%
sqrt-prod36.7%
sqrt-unprod10.9%
add-sqr-sqrt44.6%
sqrt-prod24.6%
add-sqr-sqrt44.9%
*-commutative44.9%
sqrt-div44.9%
sqrt-div45.5%
metadata-eval45.5%
sqrt-prod22.7%
add-sqr-sqrt42.2%
associate-*r*39.6%
sqrt-prod41.2%
Applied egg-rr83.9%
if 1.1499999999999999e-58 < x Initial program 58.9%
*-commutative58.9%
associate-*r*55.2%
associate-*r*54.2%
unpow254.2%
unswap-sqr65.1%
unpow265.1%
swap-sqr97.8%
*-commutative97.8%
*-commutative97.8%
*-commutative97.8%
*-commutative97.8%
Simplified97.8%
Final simplification88.8%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (let* ((t_0 (/ 1.0 (* c (* x s))))) (* 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 = 1.0 / (c * (x * s));
return 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 = 1.0d0 / (c * (x * s))
code = 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 = 1.0 / (c * (x * s));
return 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 = 1.0 / (c * (x * s)) return 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(1.0 / Float64(c * Float64(x * s))) return 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 = 1.0 / (c * (x * s));
tmp = 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[(1.0 / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * t$95$0), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \frac{1}{c \cdot \left(x \cdot s\right)}\\
t_0 \cdot t_0
\end{array}
\end{array}
Initial program 63.4%
*-commutative63.4%
associate-*r*58.8%
associate-*r*58.4%
unpow258.4%
unswap-sqr71.4%
unpow271.4%
swap-sqr95.4%
*-commutative95.4%
*-commutative95.4%
*-commutative95.4%
*-commutative95.4%
Simplified95.4%
Taylor expanded in x around 0 54.1%
unpow254.1%
associate-*r*53.2%
*-commutative53.2%
associate-*r*54.0%
unpow254.0%
associate-/r*54.2%
unpow254.2%
unpow254.2%
unpow254.2%
Simplified54.2%
add-sqr-sqrt54.2%
pow254.2%
sqrt-div54.2%
sqrt-div54.2%
metadata-eval54.2%
sqrt-prod30.9%
add-sqr-sqrt58.0%
unswap-sqr69.3%
*-commutative69.3%
*-commutative69.3%
sqrt-prod45.9%
add-sqr-sqrt76.4%
associate-/r*76.3%
pow276.3%
inv-pow76.3%
inv-pow76.3%
pow-prod-up76.4%
metadata-eval76.4%
associate-*r*77.4%
Applied egg-rr77.3%
metadata-eval77.3%
pow-prod-up77.2%
inv-pow77.2%
inv-pow77.2%
associate-*l*76.3%
associate-*l*77.4%
Applied egg-rr77.4%
Final simplification77.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 (/ (/ 1.0 c) (* x s)))) (* 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 = (1.0 / c) / (x * s);
return 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 = (1.0d0 / c) / (x * s)
code = 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 = (1.0 / c) / (x * s);
return 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 = (1.0 / c) / (x * s) return 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(Float64(1.0 / c) / Float64(x * s)) return 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 = (1.0 / c) / (x * s);
tmp = 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[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * t$95$0), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{1}{c}}{x \cdot s}\\
t_0 \cdot t_0
\end{array}
\end{array}
Initial program 63.4%
associate-/r*63.2%
unpow263.2%
*-commutative63.2%
unpow263.2%
Simplified63.2%
Taylor expanded in x around 0 57.1%
unpow257.1%
Simplified57.1%
add-sqr-sqrt57.1%
sqrt-div57.1%
sqrt-div57.1%
metadata-eval57.1%
sqrt-prod27.2%
add-sqr-sqrt41.4%
associate-*r*39.4%
sqrt-prod39.5%
sqrt-unprod23.2%
add-sqr-sqrt45.1%
sqrt-prod24.5%
add-sqr-sqrt45.3%
*-commutative45.3%
sqrt-div45.2%
sqrt-div45.6%
metadata-eval45.6%
sqrt-prod24.3%
add-sqr-sqrt45.8%
associate-*r*43.6%
sqrt-prod44.9%
Applied egg-rr77.4%
Final simplification77.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 (/ 1.0 (* (* c c) (* (* s s) (* x x)))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return 1.0 / ((c * c) * ((s * s) * (x * x)));
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = 1.0d0 / ((c * c) * ((s * s) * (x * x)))
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return 1.0 / ((c * c) * ((s * s) * (x * x)));
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return 1.0 / ((c * c) * ((s * s) * (x * x)))
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(c * c) * Float64(Float64(s * s) * Float64(x * x)))) end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = 1.0 / ((c * c) * ((s * s) * (x * x)));
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[(c * c), $MachinePrecision] * N[(N[(s * s), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{\left(c \cdot c\right) \cdot \left(\left(s \cdot s\right) \cdot \left(x \cdot x\right)\right)}
\end{array}
Initial program 63.4%
*-commutative63.4%
associate-*r*58.8%
associate-*r*58.4%
unpow258.4%
unswap-sqr71.4%
unpow271.4%
swap-sqr95.4%
*-commutative95.4%
*-commutative95.4%
*-commutative95.4%
*-commutative95.4%
Simplified95.4%
associate-/r*95.8%
div-inv95.8%
*-commutative95.8%
Applied egg-rr95.8%
un-div-inv95.8%
associate-*r*93.5%
*-commutative93.5%
associate-*r*93.8%
associate-*r*95.0%
*-commutative95.0%
associate-*r*97.3%
Applied egg-rr97.3%
Taylor expanded in x around 0 54.1%
unpow254.1%
unpow254.1%
unpow254.1%
Simplified54.1%
Final simplification54.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 (/ 1.0 (* (* c (* x s)) (* x (* c s)))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return 1.0 / ((c * (x * s)) * (x * (c * s)));
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = 1.0d0 / ((c * (x * s)) * (x * (c * s)))
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return 1.0 / ((c * (x * s)) * (x * (c * s)));
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return 1.0 / ((c * (x * s)) * (x * (c * s)))
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(1.0 / Float64(Float64(c * Float64(x * s)) * Float64(x * Float64(c * s)))) end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = 1.0 / ((c * (x * s)) * (x * (c * s)));
end
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(1.0 / N[(N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision] * N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)}
\end{array}
Initial program 63.4%
*-commutative63.4%
associate-*r*58.8%
associate-*r*58.4%
unpow258.4%
unswap-sqr71.4%
unpow271.4%
swap-sqr95.4%
*-commutative95.4%
*-commutative95.4%
*-commutative95.4%
*-commutative95.4%
Simplified95.4%
associate-/r*95.8%
div-inv95.8%
*-commutative95.8%
Applied egg-rr95.8%
clear-num95.8%
frac-times95.4%
metadata-eval95.4%
associate-*r*93.3%
*-commutative93.3%
associate-*r*93.3%
associate-*r*94.7%
*-commutative94.7%
associate-*r*96.9%
Applied egg-rr96.9%
Taylor expanded in x around 0 76.1%
*-commutative76.1%
Simplified76.1%
Final simplification76.1%
herbie shell --seed 2023207
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))