
(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 7 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 (if (<= x 2.5e-7) (/ (/ (/ (/ 1.0 s) x) c) (* c (* x s))) (/ (/ (/ (cos (* x 2.0)) (* s (* x c))) (* x c)) s)))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double tmp;
if (x <= 2.5e-7) {
tmp = (((1.0 / s) / x) / c) / (c * (x * s));
} else {
tmp = ((cos((x * 2.0)) / (s * (x * c))) / (x * c)) / s;
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: tmp
if (x <= 2.5d-7) then
tmp = (((1.0d0 / s) / x) / c) / (c * (x * s))
else
tmp = ((cos((x * 2.0d0)) / (s * (x * c))) / (x * c)) / s
end if
code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double tmp;
if (x <= 2.5e-7) {
tmp = (((1.0 / s) / x) / c) / (c * (x * s));
} else {
tmp = ((Math.cos((x * 2.0)) / (s * (x * c))) / (x * c)) / s;
}
return tmp;
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): tmp = 0 if x <= 2.5e-7: tmp = (((1.0 / s) / x) / c) / (c * (x * s)) else: tmp = ((math.cos((x * 2.0)) / (s * (x * c))) / (x * c)) / s return tmp
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) tmp = 0.0 if (x <= 2.5e-7) tmp = Float64(Float64(Float64(Float64(1.0 / s) / x) / c) / Float64(c * Float64(x * s))); else tmp = Float64(Float64(Float64(cos(Float64(x * 2.0)) / Float64(s * Float64(x * c))) / Float64(x * c)) / s); end return tmp end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
tmp = 0.0;
if (x <= 2.5e-7)
tmp = (((1.0 / s) / x) / c) / (c * (x * s));
else
tmp = ((cos((x * 2.0)) / (s * (x * c))) / (x * c)) / s;
end
tmp_2 = tmp;
end
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := If[LessEqual[x, 2.5e-7], N[(N[(N[(N[(1.0 / s), $MachinePrecision] / x), $MachinePrecision] / c), $MachinePrecision] / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * c), $MachinePrecision]), $MachinePrecision] / s), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.5 \cdot 10^{-7}:\\
\;\;\;\;\frac{\frac{\frac{\frac{1}{s}}{x}}{c}}{c \cdot \left(x \cdot s\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{\cos \left(x \cdot 2\right)}{s \cdot \left(x \cdot c\right)}}{x \cdot c}}{s}\\
\end{array}
\end{array}
if x < 2.49999999999999989e-7Initial program 68.1%
Applied egg-rr97.7%
associate-*l/97.8%
*-un-lft-identity97.8%
*-commutative97.8%
Applied egg-rr97.8%
*-commutative97.8%
*-un-lft-identity97.8%
times-frac97.8%
*-commutative97.8%
Applied egg-rr97.8%
associate-*l/97.8%
*-lft-identity97.8%
*-commutative97.8%
Simplified97.8%
Taylor expanded in x around 0 84.3%
associate-/r*84.4%
Simplified84.4%
if 2.49999999999999989e-7 < x Initial program 72.5%
Applied egg-rr96.0%
inv-pow96.0%
*-commutative96.0%
associate-*r*94.5%
unpow-prod-down94.5%
inv-pow94.5%
Applied egg-rr94.5%
*-commutative94.5%
unpow-194.5%
associate-*r/94.5%
*-rgt-identity94.5%
Simplified94.5%
associate-*r/94.5%
associate-*r*98.2%
associate-/r*98.3%
clear-num98.3%
associate-*l/98.3%
*-un-lft-identity98.3%
*-commutative98.3%
div-inv98.3%
*-commutative98.3%
clear-num98.3%
/-rgt-identity98.3%
associate-*l*99.7%
*-commutative99.7%
*-commutative99.7%
Applied egg-rr99.7%
Final simplification88.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 (* c (* x s)))) (/ (/ (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 = c * (x * s);
return (cos((x * 2.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 = (cos((x * 2.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 (Math.cos((x * 2.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 (math.cos((x * 2.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(Float64(cos(Float64(x * 2.0)) / 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 = (cos((x * 2.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[(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 := c \cdot \left(x \cdot s\right)\\
\frac{\frac{\cos \left(x \cdot 2\right)}{t_0}}{t_0}
\end{array}
\end{array}
Initial program 69.2%
Applied egg-rr97.3%
associate-*l/97.4%
*-un-lft-identity97.4%
*-commutative97.4%
Applied egg-rr97.4%
Final simplification97.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 (* c (* x s))))
(if (<= c 4e-254)
(/ (/ (+ (* -2.0 (/ x s)) (/ 1.0 (* x s))) c) t_0)
(/ (/ (/ (/ 1.0 s) x) c) 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);
double tmp;
if (c <= 4e-254) {
tmp = (((-2.0 * (x / s)) + (1.0 / (x * s))) / c) / t_0;
} else {
tmp = (((1.0 / s) / x) / c) / 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 = c * (x * s)
if (c <= 4d-254) then
tmp = ((((-2.0d0) * (x / s)) + (1.0d0 / (x * s))) / c) / t_0
else
tmp = (((1.0d0 / s) / x) / c) / 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 = c * (x * s);
double tmp;
if (c <= 4e-254) {
tmp = (((-2.0 * (x / s)) + (1.0 / (x * s))) / c) / t_0;
} else {
tmp = (((1.0 / s) / x) / c) / 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 = c * (x * s) tmp = 0 if c <= 4e-254: tmp = (((-2.0 * (x / s)) + (1.0 / (x * s))) / c) / t_0 else: tmp = (((1.0 / s) / x) / c) / 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(c * Float64(x * s)) tmp = 0.0 if (c <= 4e-254) tmp = Float64(Float64(Float64(Float64(-2.0 * Float64(x / s)) + Float64(1.0 / Float64(x * s))) / c) / t_0); else tmp = Float64(Float64(Float64(Float64(1.0 / s) / x) / c) / 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 = c * (x * s);
tmp = 0.0;
if (c <= 4e-254)
tmp = (((-2.0 * (x / s)) + (1.0 / (x * s))) / c) / t_0;
else
tmp = (((1.0 / s) / x) / c) / 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[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, 4e-254], N[(N[(N[(N[(-2.0 * N[(x / s), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[(N[(1.0 / s), $MachinePrecision] / x), $MachinePrecision] / c), $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 := c \cdot \left(x \cdot s\right)\\
\mathbf{if}\;c \leq 4 \cdot 10^{-254}:\\
\;\;\;\;\frac{\frac{-2 \cdot \frac{x}{s} + \frac{1}{x \cdot s}}{c}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{\frac{1}{s}}{x}}{c}}{t_0}\\
\end{array}
\end{array}
if c < 3.9999999999999996e-254Initial program 70.2%
Applied egg-rr98.1%
associate-*l/98.1%
*-un-lft-identity98.1%
*-commutative98.1%
Applied egg-rr98.1%
*-commutative98.1%
*-un-lft-identity98.1%
times-frac98.1%
*-commutative98.1%
Applied egg-rr98.1%
associate-*l/98.1%
*-lft-identity98.1%
*-commutative98.1%
Simplified98.1%
Taylor expanded in x around 0 71.7%
if 3.9999999999999996e-254 < c Initial program 67.9%
Applied egg-rr96.4%
associate-*l/96.5%
*-un-lft-identity96.5%
*-commutative96.5%
Applied egg-rr96.5%
*-commutative96.5%
*-un-lft-identity96.5%
times-frac96.5%
*-commutative96.5%
Applied egg-rr96.5%
associate-*l/96.6%
*-lft-identity96.6%
*-commutative96.6%
Simplified96.6%
Taylor expanded in x around 0 79.6%
associate-/r*79.7%
Simplified79.7%
Final simplification75.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 (* 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 69.2%
Taylor expanded in x around 0 58.1%
unpow258.1%
*-commutative58.1%
unpow258.1%
unpow258.1%
swap-sqr67.8%
swap-sqr79.1%
unpow279.1%
*-commutative79.1%
Simplified79.1%
*-commutative79.1%
pow279.1%
Applied egg-rr79.1%
Final simplification79.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)) (* c (* x 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)) / (c * (x * 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)) / (c * (x * 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)) / (c * (x * 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)) / (c * (x * s))
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(Float64(Float64(1.0 / c) / Float64(x * s)) / Float64(c * Float64(x * 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)) / (c * (x * 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[(N[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision] / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\frac{\frac{1}{c}}{x \cdot s}}{c \cdot \left(x \cdot s\right)}
\end{array}
Initial program 69.2%
Applied egg-rr97.3%
associate-*l/97.4%
*-un-lft-identity97.4%
*-commutative97.4%
Applied egg-rr97.4%
*-commutative97.4%
*-un-lft-identity97.4%
times-frac97.4%
*-commutative97.4%
Applied egg-rr97.4%
associate-*l/97.4%
*-lft-identity97.4%
*-commutative97.4%
Simplified97.4%
Taylor expanded in x around 0 79.3%
associate-/r*79.3%
Simplified79.3%
Final simplification79.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 (/ (/ (/ 1.0 (* x s)) c) (* c (* x s))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return ((1.0 / (x * s)) / c) / (c * (x * 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 / (x * s)) / c) / (c * (x * 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 / (x * s)) / c) / (c * (x * s));
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return ((1.0 / (x * s)) / c) / (c * (x * s))
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(Float64(Float64(1.0 / Float64(x * s)) / c) / Float64(c * Float64(x * 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 / (x * s)) / c) / (c * (x * 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[(N[(N[(1.0 / N[(x * s), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision] / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\frac{\frac{1}{x \cdot s}}{c}}{c \cdot \left(x \cdot s\right)}
\end{array}
Initial program 69.2%
Applied egg-rr97.3%
associate-*l/97.4%
*-un-lft-identity97.4%
*-commutative97.4%
Applied egg-rr97.4%
*-commutative97.4%
*-un-lft-identity97.4%
times-frac97.4%
*-commutative97.4%
Applied egg-rr97.4%
associate-*l/97.4%
*-lft-identity97.4%
*-commutative97.4%
Simplified97.4%
Taylor expanded in x around 0 79.4%
Final simplification79.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 s) x) c) (* c (* x s))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return (((1.0 / s) / x) / c) / (c * (x * 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 / s) / x) / c) / (c * (x * 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 / s) / x) / c) / (c * (x * s));
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return (((1.0 / s) / x) / c) / (c * (x * s))
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(Float64(Float64(Float64(1.0 / s) / x) / c) / Float64(c * Float64(x * 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 / s) / x) / c) / (c * (x * 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[(N[(N[(N[(1.0 / s), $MachinePrecision] / x), $MachinePrecision] / c), $MachinePrecision] / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\frac{\frac{\frac{1}{s}}{x}}{c}}{c \cdot \left(x \cdot s\right)}
\end{array}
Initial program 69.2%
Applied egg-rr97.3%
associate-*l/97.4%
*-un-lft-identity97.4%
*-commutative97.4%
Applied egg-rr97.4%
*-commutative97.4%
*-un-lft-identity97.4%
times-frac97.4%
*-commutative97.4%
Applied egg-rr97.4%
associate-*l/97.4%
*-lft-identity97.4%
*-commutative97.4%
Simplified97.4%
Taylor expanded in x around 0 79.4%
associate-/r*79.4%
Simplified79.4%
Final simplification79.4%
herbie shell --seed 2023310
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))