
(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: c 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))) (t_1 (cos (* 2.0 x))))
(if (<= (/ t_1 (* (pow c 2.0) (* x (* x (pow s 2.0))))) INFINITY)
(/ (/ t_1 t_0) t_0)
(/ (/ (* t_1 (/ -1.0 x)) (* c s)) (* x (* c (- s)))))))c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = c * (x * s);
double t_1 = cos((2.0 * x));
double tmp;
if ((t_1 / (pow(c, 2.0) * (x * (x * pow(s, 2.0))))) <= ((double) INFINITY)) {
tmp = (t_1 / t_0) / t_0;
} else {
tmp = ((t_1 * (-1.0 / x)) / (c * s)) / (x * (c * -s));
}
return tmp;
}
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = c * (x * s);
double t_1 = Math.cos((2.0 * x));
double tmp;
if ((t_1 / (Math.pow(c, 2.0) * (x * (x * Math.pow(s, 2.0))))) <= Double.POSITIVE_INFINITY) {
tmp = (t_1 / t_0) / t_0;
} else {
tmp = ((t_1 * (-1.0 / x)) / (c * s)) / (x * (c * -s));
}
return tmp;
}
c = abs(c) [c, s] = sort([c, s]) def code(x, c, s): t_0 = c * (x * s) t_1 = math.cos((2.0 * x)) tmp = 0 if (t_1 / (math.pow(c, 2.0) * (x * (x * math.pow(s, 2.0))))) <= math.inf: tmp = (t_1 / t_0) / t_0 else: tmp = ((t_1 * (-1.0 / x)) / (c * s)) / (x * (c * -s)) return tmp
c = abs(c) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(c * Float64(x * s)) t_1 = cos(Float64(2.0 * x)) tmp = 0.0 if (Float64(t_1 / Float64((c ^ 2.0) * Float64(x * Float64(x * (s ^ 2.0))))) <= Inf) tmp = Float64(Float64(t_1 / t_0) / t_0); else tmp = Float64(Float64(Float64(t_1 * Float64(-1.0 / x)) / Float64(c * s)) / Float64(x * Float64(c * Float64(-s)))); end return tmp end
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
t_0 = c * (x * s);
t_1 = cos((2.0 * x));
tmp = 0.0;
if ((t_1 / ((c ^ 2.0) * (x * (x * (s ^ 2.0))))) <= Inf)
tmp = (t_1 / t_0) / t_0;
else
tmp = ((t_1 * (-1.0 / x)) / (c * s)) / (x * (c * -s));
end
tmp_2 = tmp;
end
NOTE: c 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]}, Block[{t$95$1 = N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$1 / N[(N[Power[c, 2.0], $MachinePrecision] * N[(x * N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(t$95$1 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[(t$95$1 * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision] / N[(c * s), $MachinePrecision]), $MachinePrecision] / N[(x * N[(c * (-s)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
t_1 := \cos \left(2 \cdot x\right)\\
\mathbf{if}\;\frac{t_1}{{c}^{2} \cdot \left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \leq \infty:\\
\;\;\;\;\frac{\frac{t_1}{t_0}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t_1 \cdot \frac{-1}{x}}{c \cdot s}}{x \cdot \left(c \cdot \left(-s\right)\right)}\\
\end{array}
\end{array}
if (/.f64 (cos.f64 (*.f64 2 x)) (*.f64 (pow.f64 c 2) (*.f64 (*.f64 x (pow.f64 s 2)) x))) < +inf.0Initial program 79.2%
*-un-lft-identity79.2%
add-sqr-sqrt79.2%
times-frac79.2%
sqrt-prod79.2%
unpow279.2%
sqrt-prod38.3%
add-sqr-sqrt58.9%
*-commutative58.9%
associate-*r*54.8%
unpow254.8%
pow-prod-down59.0%
sqrt-prod58.9%
Applied egg-rr95.3%
associate-*l/95.4%
*-lft-identity95.4%
unpow295.4%
rem-sqrt-square95.4%
*-commutative95.4%
unpow295.4%
rem-sqrt-square99.7%
*-commutative99.7%
Simplified99.7%
associate-/r*96.9%
add-sqr-sqrt51.4%
fabs-sqr51.4%
add-sqr-sqrt68.2%
associate-/l/69.5%
div-inv69.5%
times-frac68.2%
*-commutative68.2%
add-sqr-sqrt48.1%
fabs-sqr48.1%
add-sqr-sqrt96.9%
associate-*r*96.0%
Applied egg-rr96.0%
frac-times98.0%
div-inv98.0%
associate-*l*99.7%
*-commutative99.7%
associate-*r*98.0%
*-commutative98.0%
*-commutative98.0%
associate-*l*99.7%
Applied egg-rr99.7%
if +inf.0 < (/.f64 (cos.f64 (*.f64 2 x)) (*.f64 (pow.f64 c 2) (*.f64 (*.f64 x (pow.f64 s 2)) x))) Initial program 0.0%
*-un-lft-identity0.0%
add-sqr-sqrt0.0%
times-frac0.0%
sqrt-prod0.0%
unpow20.0%
sqrt-prod0.0%
add-sqr-sqrt0.0%
*-commutative0.0%
associate-*r*0.0%
unpow20.0%
pow-prod-down0.0%
sqrt-prod0.0%
Applied egg-rr44.3%
associate-*l/44.3%
*-lft-identity44.3%
unpow244.3%
rem-sqrt-square44.3%
*-commutative44.3%
unpow244.3%
rem-sqrt-square78.3%
*-commutative78.3%
Simplified78.3%
frac-2neg78.3%
distribute-frac-neg78.3%
associate-/r*78.4%
add-sqr-sqrt39.4%
fabs-sqr39.4%
add-sqr-sqrt40.8%
associate-/r*40.8%
*-commutative40.8%
associate-*r*40.8%
add-sqr-sqrt30.4%
fabs-sqr30.4%
add-sqr-sqrt76.4%
associate-*r*97.0%
Applied egg-rr97.0%
associate-/r*97.0%
div-inv97.2%
Applied egg-rr97.2%
associate-*l/97.2%
Applied egg-rr97.2%
Final simplification99.2%
NOTE: c should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (/ (* (/ (cos (* 2.0 x)) (* c s)) (/ -1.0 x)) (* x (* c (- s)))))
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
return ((cos((2.0 * x)) / (c * s)) * (-1.0 / x)) / (x * (c * -s));
}
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = ((cos((2.0d0 * x)) / (c * s)) * ((-1.0d0) / x)) / (x * (c * -s))
end function
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
return ((Math.cos((2.0 * x)) / (c * s)) * (-1.0 / x)) / (x * (c * -s));
}
c = abs(c) [c, s] = sort([c, s]) def code(x, c, s): return ((math.cos((2.0 * x)) / (c * s)) * (-1.0 / x)) / (x * (c * -s))
c = abs(c) c, s = sort([c, s]) function code(x, c, s) return Float64(Float64(Float64(cos(Float64(2.0 * x)) / Float64(c * s)) * Float64(-1.0 / x)) / Float64(x * Float64(c * Float64(-s)))) end
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = ((cos((2.0 * x)) / (c * s)) * (-1.0 / x)) / (x * (c * -s));
end
NOTE: c should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(N[(N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(c * s), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision] / N[(x * N[(c * (-s)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot s} \cdot \frac{-1}{x}}{x \cdot \left(c \cdot \left(-s\right)\right)}
\end{array}
Initial program 64.9%
*-un-lft-identity64.9%
add-sqr-sqrt64.9%
times-frac65.0%
sqrt-prod65.0%
unpow265.0%
sqrt-prod31.4%
add-sqr-sqrt48.4%
*-commutative48.4%
associate-*r*45.0%
unpow245.0%
pow-prod-down48.4%
sqrt-prod48.3%
Applied egg-rr86.1%
associate-*l/86.2%
*-lft-identity86.2%
unpow286.2%
rem-sqrt-square86.2%
*-commutative86.2%
unpow286.2%
rem-sqrt-square95.9%
*-commutative95.9%
Simplified95.9%
frac-2neg95.9%
distribute-frac-neg95.9%
associate-/r*95.9%
add-sqr-sqrt50.3%
fabs-sqr50.3%
add-sqr-sqrt64.3%
associate-/r*64.3%
*-commutative64.3%
associate-*r*63.3%
add-sqr-sqrt44.9%
fabs-sqr44.9%
add-sqr-sqrt94.1%
associate-*r*97.8%
Applied egg-rr97.8%
associate-/r*97.9%
div-inv97.9%
Applied egg-rr97.9%
Final simplification97.9%
NOTE: c should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (/ (/ (- (cos (* 2.0 x))) (* x (* c s))) (* x (* c (- s)))))
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
return (-cos((2.0 * x)) / (x * (c * s))) / (x * (c * -s));
}
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = (-cos((2.0d0 * x)) / (x * (c * s))) / (x * (c * -s))
end function
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
return (-Math.cos((2.0 * x)) / (x * (c * s))) / (x * (c * -s));
}
c = abs(c) [c, s] = sort([c, s]) def code(x, c, s): return (-math.cos((2.0 * x)) / (x * (c * s))) / (x * (c * -s))
c = abs(c) c, s = sort([c, s]) function code(x, c, s) return Float64(Float64(Float64(-cos(Float64(2.0 * x))) / Float64(x * Float64(c * s))) / Float64(x * Float64(c * Float64(-s)))) end
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = (-cos((2.0 * x)) / (x * (c * s))) / (x * (c * -s));
end
NOTE: c should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(N[((-N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]) / N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * N[(c * (-s)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\frac{-\cos \left(2 \cdot x\right)}{x \cdot \left(c \cdot s\right)}}{x \cdot \left(c \cdot \left(-s\right)\right)}
\end{array}
Initial program 64.9%
*-un-lft-identity64.9%
add-sqr-sqrt64.9%
times-frac65.0%
sqrt-prod65.0%
unpow265.0%
sqrt-prod31.4%
add-sqr-sqrt48.4%
*-commutative48.4%
associate-*r*45.0%
unpow245.0%
pow-prod-down48.4%
sqrt-prod48.3%
Applied egg-rr86.1%
associate-*l/86.2%
*-lft-identity86.2%
unpow286.2%
rem-sqrt-square86.2%
*-commutative86.2%
unpow286.2%
rem-sqrt-square95.9%
*-commutative95.9%
Simplified95.9%
frac-2neg95.9%
distribute-frac-neg95.9%
associate-/r*95.9%
add-sqr-sqrt50.3%
fabs-sqr50.3%
add-sqr-sqrt64.3%
associate-/r*64.3%
*-commutative64.3%
associate-*r*63.3%
add-sqr-sqrt44.9%
fabs-sqr44.9%
add-sqr-sqrt94.1%
associate-*r*97.8%
Applied egg-rr97.8%
Final simplification97.8%
NOTE: c should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (/ (/ (/ (- (cos (* 2.0 x))) (* c s)) x) (* x (* c (- s)))))
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
return ((-cos((2.0 * x)) / (c * s)) / x) / (x * (c * -s));
}
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = ((-cos((2.0d0 * x)) / (c * s)) / x) / (x * (c * -s))
end function
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
return ((-Math.cos((2.0 * x)) / (c * s)) / x) / (x * (c * -s));
}
c = abs(c) [c, s] = sort([c, s]) def code(x, c, s): return ((-math.cos((2.0 * x)) / (c * s)) / x) / (x * (c * -s))
c = abs(c) c, s = sort([c, s]) function code(x, c, s) return Float64(Float64(Float64(Float64(-cos(Float64(2.0 * x))) / Float64(c * s)) / x) / Float64(x * Float64(c * Float64(-s)))) end
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = ((-cos((2.0 * x)) / (c * s)) / x) / (x * (c * -s));
end
NOTE: c should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(N[(N[((-N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]) / N[(c * s), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / N[(x * N[(c * (-s)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\frac{\frac{-\cos \left(2 \cdot x\right)}{c \cdot s}}{x}}{x \cdot \left(c \cdot \left(-s\right)\right)}
\end{array}
Initial program 64.9%
*-un-lft-identity64.9%
add-sqr-sqrt64.9%
times-frac65.0%
sqrt-prod65.0%
unpow265.0%
sqrt-prod31.4%
add-sqr-sqrt48.4%
*-commutative48.4%
associate-*r*45.0%
unpow245.0%
pow-prod-down48.4%
sqrt-prod48.3%
Applied egg-rr86.1%
associate-*l/86.2%
*-lft-identity86.2%
unpow286.2%
rem-sqrt-square86.2%
*-commutative86.2%
unpow286.2%
rem-sqrt-square95.9%
*-commutative95.9%
Simplified95.9%
frac-2neg95.9%
distribute-frac-neg95.9%
associate-/r*95.9%
add-sqr-sqrt50.3%
fabs-sqr50.3%
add-sqr-sqrt64.3%
associate-/r*64.3%
*-commutative64.3%
associate-*r*63.3%
add-sqr-sqrt44.9%
fabs-sqr44.9%
add-sqr-sqrt94.1%
associate-*r*97.8%
Applied egg-rr97.8%
associate-/r*97.9%
div-inv97.9%
Applied egg-rr97.9%
un-div-inv97.9%
Applied egg-rr97.9%
Final simplification97.9%
NOTE: c 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)))) (/ (/ (cos (* 2.0 x)) t_0) t_0)))
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = c * (x * s);
return (cos((2.0 * x)) / t_0) / t_0;
}
NOTE: c 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 = (cos((2.0d0 * x)) / t_0) / t_0
end function
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = c * (x * s);
return (Math.cos((2.0 * x)) / t_0) / t_0;
}
c = abs(c) [c, s] = sort([c, s]) def code(x, c, s): t_0 = c * (x * s) return (math.cos((2.0 * x)) / t_0) / t_0
c = abs(c) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(c * Float64(x * s)) return Float64(Float64(cos(Float64(2.0 * x)) / t_0) / t_0) end
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
t_0 = c * (x * s);
tmp = (cos((2.0 * x)) / t_0) / t_0;
end
NOTE: c 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[(N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\frac{\frac{\cos \left(2 \cdot x\right)}{t_0}}{t_0}
\end{array}
\end{array}
Initial program 64.9%
*-un-lft-identity64.9%
add-sqr-sqrt64.9%
times-frac65.0%
sqrt-prod65.0%
unpow265.0%
sqrt-prod31.4%
add-sqr-sqrt48.4%
*-commutative48.4%
associate-*r*45.0%
unpow245.0%
pow-prod-down48.4%
sqrt-prod48.3%
Applied egg-rr86.1%
associate-*l/86.2%
*-lft-identity86.2%
unpow286.2%
rem-sqrt-square86.2%
*-commutative86.2%
unpow286.2%
rem-sqrt-square95.9%
*-commutative95.9%
Simplified95.9%
associate-/r*90.7%
add-sqr-sqrt48.9%
fabs-sqr48.9%
add-sqr-sqrt62.9%
associate-/l/64.3%
div-inv64.3%
times-frac62.9%
*-commutative62.9%
add-sqr-sqrt44.5%
fabs-sqr44.5%
add-sqr-sqrt90.4%
associate-*r*89.7%
Applied egg-rr89.7%
frac-times94.1%
div-inv94.1%
associate-*l*95.9%
*-commutative95.9%
associate-*r*94.1%
*-commutative94.1%
*-commutative94.1%
associate-*l*95.9%
Applied egg-rr95.9%
Final simplification95.9%
NOTE: c should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (/ 1.0 (* (* x s) (* c (* s (* x c))))))
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
return 1.0 / ((x * s) * (c * (s * (x * c))));
}
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = 1.0d0 / ((x * s) * (c * (s * (x * c))))
end function
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
return 1.0 / ((x * s) * (c * (s * (x * c))));
}
c = abs(c) [c, s] = sort([c, s]) def code(x, c, s): return 1.0 / ((x * s) * (c * (s * (x * c))))
c = abs(c) c, s = sort([c, s]) function code(x, c, s) return Float64(1.0 / Float64(Float64(x * s) * Float64(c * Float64(s * Float64(x * c))))) end
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = 1.0 / ((x * s) * (c * (s * (x * c))));
end
NOTE: c 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[(x * s), $MachinePrecision] * N[(c * N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{\left(x \cdot s\right) \cdot \left(c \cdot \left(s \cdot \left(x \cdot c\right)\right)\right)}
\end{array}
Initial program 64.9%
Taylor expanded in x around 0 56.9%
associate-/r*56.4%
*-commutative56.4%
unpow256.4%
unpow256.4%
swap-sqr67.2%
unpow267.2%
associate-/r*67.7%
rem-square-sqrt67.7%
unpow267.7%
swap-sqr74.6%
unpow274.6%
unpow274.6%
rem-sqrt-square79.8%
*-commutative79.8%
Simplified79.8%
unpow279.8%
add-sqr-sqrt42.3%
fabs-sqr42.3%
add-sqr-sqrt57.6%
associate-*r*56.8%
add-sqr-sqrt37.3%
fabs-sqr37.3%
add-sqr-sqrt77.6%
associate-*r*77.2%
Applied egg-rr77.2%
expm1-log1p-u53.1%
expm1-udef33.5%
associate-*l*33.4%
Applied egg-rr33.4%
expm1-def52.5%
expm1-log1p76.6%
associate-*l*77.0%
*-commutative77.0%
Simplified77.0%
Final simplification77.0%
NOTE: c 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))))
c = abs(c);
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: c 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
c = Math.abs(c);
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);
}
c = abs(c) [c, s] = sort([c, s]) def code(x, c, s): t_0 = x * (c * s) return 1.0 / (t_0 * t_0)
c = abs(c) 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
c = abs(c)
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: c 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}
c = |c|\\
[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 64.9%
Taylor expanded in x around 0 56.9%
associate-/r*56.4%
*-commutative56.4%
unpow256.4%
unpow256.4%
swap-sqr67.2%
unpow267.2%
associate-/r*67.7%
rem-square-sqrt67.7%
unpow267.7%
swap-sqr74.6%
unpow274.6%
unpow274.6%
rem-sqrt-square79.8%
*-commutative79.8%
Simplified79.8%
unpow-prod-down67.7%
unpow267.7%
pow267.7%
sqr-abs67.7%
swap-sqr79.8%
associate-*r*78.4%
associate-*r*80.9%
Applied egg-rr80.9%
Final simplification80.9%
NOTE: c 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)))
c = abs(c);
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: c 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
c = Math.abs(c);
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;
}
c = abs(c) [c, s] = sort([c, s]) def code(x, c, s): t_0 = c * (x * s) return (1.0 / t_0) / t_0
c = abs(c) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(c * Float64(x * s)) return Float64(Float64(1.0 / t_0) / t_0) end
c = abs(c)
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: c 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[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\frac{\frac{1}{t_0}}{t_0}
\end{array}
\end{array}
Initial program 64.9%
Taylor expanded in x around 0 56.9%
associate-/r*56.4%
*-commutative56.4%
unpow256.4%
unpow256.4%
swap-sqr67.2%
unpow267.2%
associate-/r*67.7%
rem-square-sqrt67.7%
unpow267.7%
swap-sqr74.6%
unpow274.6%
unpow274.6%
rem-sqrt-square79.8%
*-commutative79.8%
Simplified79.8%
pow-flip80.0%
add-sqr-sqrt42.3%
fabs-sqr42.3%
add-sqr-sqrt80.0%
*-commutative80.0%
*-commutative80.0%
associate-*r*81.1%
metadata-eval81.1%
Applied egg-rr81.1%
metadata-eval81.1%
pow-div81.1%
inv-pow81.1%
associate-*l*78.6%
pow178.6%
associate-*l*80.0%
Applied egg-rr80.0%
Final simplification80.0%
herbie shell --seed 2023305
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))