
(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 6 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 1.04e-10) (/ 1.0 (* (/ (/ x (/ 1.0 s)) (/ 1.0 c)) (* c (* x s)))) (* (pow (* s (* x c)) -2.0) (cos (* x 2.0)))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double tmp;
if (x <= 1.04e-10) {
tmp = 1.0 / (((x / (1.0 / s)) / (1.0 / c)) * (c * (x * s)));
} else {
tmp = pow((s * (x * c)), -2.0) * cos((x * 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) :: tmp
if (x <= 1.04d-10) then
tmp = 1.0d0 / (((x / (1.0d0 / s)) / (1.0d0 / c)) * (c * (x * s)))
else
tmp = ((s * (x * c)) ** (-2.0d0)) * cos((x * 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 tmp;
if (x <= 1.04e-10) {
tmp = 1.0 / (((x / (1.0 / s)) / (1.0 / c)) * (c * (x * s)));
} else {
tmp = Math.pow((s * (x * c)), -2.0) * Math.cos((x * 2.0));
}
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 <= 1.04e-10: tmp = 1.0 / (((x / (1.0 / s)) / (1.0 / c)) * (c * (x * s))) else: tmp = math.pow((s * (x * c)), -2.0) * math.cos((x * 2.0)) 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 <= 1.04e-10) tmp = Float64(1.0 / Float64(Float64(Float64(x / Float64(1.0 / s)) / Float64(1.0 / c)) * Float64(c * Float64(x * s)))); else tmp = Float64((Float64(s * Float64(x * c)) ^ -2.0) * cos(Float64(x * 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)
tmp = 0.0;
if (x <= 1.04e-10)
tmp = 1.0 / (((x / (1.0 / s)) / (1.0 / c)) * (c * (x * s)));
else
tmp = ((s * (x * c)) ^ -2.0) * cos((x * 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_] := If[LessEqual[x, 1.04e-10], N[(1.0 / N[(N[(N[(x / N[(1.0 / s), $MachinePrecision]), $MachinePrecision] / N[(1.0 / c), $MachinePrecision]), $MachinePrecision] * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision] * N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.04 \cdot 10^{-10}:\\
\;\;\;\;\frac{1}{\frac{\frac{x}{\frac{1}{s}}}{\frac{1}{c}} \cdot \left(c \cdot \left(x \cdot s\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left(s \cdot \left(x \cdot c\right)\right)}^{-2} \cdot \cos \left(x \cdot 2\right)\\
\end{array}
\end{array}
if x < 1.04e-10Initial program 61.8%
associate-/r*61.8%
*-commutative61.8%
associate-*r*57.0%
unpow257.0%
associate-/l/56.2%
Simplified56.2%
Taylor expanded in x around 0 54.7%
associate-/r*54.7%
*-commutative54.7%
unpow254.7%
unpow254.7%
swap-sqr68.6%
unpow268.6%
associate-/r*68.6%
unpow268.6%
rem-square-sqrt68.6%
swap-sqr78.2%
unpow278.2%
unpow278.2%
rem-sqrt-square85.9%
*-commutative85.9%
Simplified85.9%
add-sqr-sqrt55.0%
sqrt-prod85.9%
unpow285.9%
pow285.9%
add-sqr-sqrt85.9%
unpow285.9%
add-sqr-sqrt45.5%
fabs-sqr45.5%
add-sqr-sqrt54.3%
add-sqr-sqrt38.8%
fabs-sqr38.8%
add-sqr-sqrt85.9%
Applied egg-rr85.9%
associate-*r*84.1%
*-commutative84.1%
/-rgt-identity84.1%
clear-num84.1%
div-inv84.1%
clear-num84.1%
div-inv84.2%
div-inv84.2%
associate-/r*86.0%
Applied egg-rr86.0%
if 1.04e-10 < x Initial program 69.9%
Taylor expanded in c around 0 67.3%
*-commutative67.3%
unpow267.3%
unpow267.3%
swap-sqr88.0%
unpow288.0%
unpow288.0%
rem-square-sqrt88.0%
swap-sqr91.6%
unpow291.6%
unpow291.6%
rem-sqrt-square93.7%
*-commutative93.7%
Simplified93.7%
Taylor expanded in x around inf 88.0%
associate-/r*88.0%
*-commutative88.0%
unpow288.0%
sqr-abs88.0%
unpow288.0%
associate-/l/88.0%
*-commutative88.0%
unpow288.0%
unpow288.0%
swap-sqr93.7%
associate-/l/93.7%
*-rgt-identity93.7%
associate-*r/93.7%
*-rgt-identity93.7%
associate-*r/93.6%
associate-*l*93.6%
Simplified93.8%
associate-*r*96.2%
*-commutative96.2%
/-rgt-identity96.2%
clear-num96.1%
div-inv96.0%
clear-num94.9%
div-inv95.0%
associate-/l/95.1%
Applied egg-rr95.1%
associate-/r/96.2%
/-rgt-identity96.2%
associate-*r*95.1%
Applied egg-rr95.1%
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 (* (cos (* x 2.0)) (pow (* c (* x s)) -2.0)))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
return cos((x * 2.0)) * pow((c * (x * s)), -2.0);
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = cos((x * 2.0d0)) * ((c * (x * s)) ** (-2.0d0))
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
return Math.cos((x * 2.0)) * Math.pow((c * (x * s)), -2.0);
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): return math.cos((x * 2.0)) * math.pow((c * (x * s)), -2.0)
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) return Float64(cos(Float64(x * 2.0)) * (Float64(c * Float64(x * s)) ^ -2.0)) end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
tmp = cos((x * 2.0)) * ((c * (x * s)) ^ -2.0);
end
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. code[x_, c_, s_] := N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\cos \left(x \cdot 2\right) \cdot {\left(c \cdot \left(x \cdot s\right)\right)}^{-2}
\end{array}
Initial program 63.7%
Taylor expanded in c around 0 59.5%
*-commutative59.5%
unpow259.5%
unpow259.5%
swap-sqr78.7%
unpow278.7%
unpow278.7%
rem-square-sqrt78.7%
swap-sqr88.5%
unpow288.5%
unpow288.5%
rem-sqrt-square96.0%
*-commutative96.0%
Simplified96.0%
Taylor expanded in x around inf 78.7%
associate-/r*78.7%
*-commutative78.7%
unpow278.7%
sqr-abs78.7%
unpow278.7%
associate-/l/78.7%
*-commutative78.7%
unpow278.7%
unpow278.7%
swap-sqr96.0%
associate-/l/96.0%
*-rgt-identity96.0%
associate-*r/96.0%
*-rgt-identity96.0%
associate-*r/96.0%
associate-*l*96.0%
Simplified96.0%
Final simplification96.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(cos(Float64(x * 2.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 = 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[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 := c \cdot \left(x \cdot s\right)\\
\frac{\cos \left(x \cdot 2\right)}{t_0 \cdot t_0}
\end{array}
\end{array}
Initial program 63.7%
Taylor expanded in c around 0 59.5%
*-commutative59.5%
unpow259.5%
unpow259.5%
swap-sqr78.7%
unpow278.7%
unpow278.7%
rem-square-sqrt78.7%
swap-sqr88.5%
unpow288.5%
unpow288.5%
rem-sqrt-square96.0%
*-commutative96.0%
Simplified96.0%
add-sqr-sqrt50.6%
sqrt-prod81.8%
unpow281.8%
pow281.8%
add-sqr-sqrt81.8%
unpow281.8%
add-sqr-sqrt42.5%
fabs-sqr42.5%
add-sqr-sqrt56.7%
add-sqr-sqrt37.3%
fabs-sqr37.3%
add-sqr-sqrt81.8%
Applied egg-rr96.0%
Final simplification96.0%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (/ 1.0 (* (/ (/ x (/ 1.0 s)) (/ 1.0 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 / (1.0 / s)) / (1.0 / 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 / (1.0d0 / s)) / (1.0d0 / 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 / (1.0 / s)) / (1.0 / 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 / (1.0 / s)) / (1.0 / 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(1.0 / Float64(Float64(Float64(x / Float64(1.0 / s)) / Float64(1.0 / 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 / (1.0 / s)) / (1.0 / 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[(1.0 / N[(N[(N[(x / N[(1.0 / s), $MachinePrecision]), $MachinePrecision] / N[(1.0 / c), $MachinePrecision]), $MachinePrecision] * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{\frac{\frac{x}{\frac{1}{s}}}{\frac{1}{c}} \cdot \left(c \cdot \left(x \cdot s\right)\right)}
\end{array}
Initial program 63.7%
associate-/r*63.7%
*-commutative63.7%
associate-*r*59.5%
unpow259.5%
associate-/l/58.5%
Simplified58.5%
Taylor expanded in x around 0 54.8%
associate-/r*54.8%
*-commutative54.8%
unpow254.8%
unpow254.8%
swap-sqr67.7%
unpow267.7%
associate-/r*67.7%
unpow267.7%
rem-square-sqrt67.7%
swap-sqr75.9%
unpow275.9%
unpow275.9%
rem-sqrt-square81.8%
*-commutative81.8%
Simplified81.8%
add-sqr-sqrt50.6%
sqrt-prod81.8%
unpow281.8%
pow281.8%
add-sqr-sqrt81.8%
unpow281.8%
add-sqr-sqrt42.5%
fabs-sqr42.5%
add-sqr-sqrt56.7%
add-sqr-sqrt37.3%
fabs-sqr37.3%
add-sqr-sqrt81.8%
Applied egg-rr81.8%
associate-*r*80.4%
*-commutative80.4%
/-rgt-identity80.4%
clear-num80.4%
div-inv80.4%
clear-num80.3%
div-inv80.4%
div-inv80.4%
associate-/r*81.9%
Applied egg-rr81.9%
Final simplification81.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 (/ 1.0 (/ (* c (* x s)) (/ (/ 1.0 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)) / ((1.0 / 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)) / ((1.0d0 / 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)) / ((1.0 / 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)) / ((1.0 / c) / (x * 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(Float64(1.0 / 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)) / ((1.0 / 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[(1.0 / N[(N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{\frac{c \cdot \left(x \cdot s\right)}{\frac{\frac{1}{c}}{x \cdot s}}}
\end{array}
Initial program 63.7%
associate-/r*63.7%
*-commutative63.7%
associate-*r*59.5%
unpow259.5%
associate-/l/58.5%
Simplified58.5%
Taylor expanded in x around 0 54.8%
associate-/r*54.8%
*-commutative54.8%
unpow254.8%
unpow254.8%
swap-sqr67.7%
unpow267.7%
associate-/r*67.7%
unpow267.7%
rem-square-sqrt67.7%
swap-sqr75.9%
unpow275.9%
unpow275.9%
rem-sqrt-square81.8%
*-commutative81.8%
Simplified81.8%
add-sqr-sqrt50.6%
sqrt-prod81.8%
unpow281.8%
pow281.8%
add-sqr-sqrt81.8%
unpow281.8%
add-sqr-sqrt42.5%
fabs-sqr42.5%
add-sqr-sqrt56.7%
add-sqr-sqrt37.3%
fabs-sqr37.3%
add-sqr-sqrt81.8%
Applied egg-rr81.8%
/-rgt-identity81.8%
associate-/l*81.8%
associate-/r*81.8%
Applied egg-rr81.8%
Final simplification81.8%
NOTE: x should be positive before calling this function NOTE: c should be positive before calling this function NOTE: s should be positive before calling this function NOTE: c and s should be sorted in increasing order before calling this function. (FPCore (x c s) :precision binary64 (let* ((t_0 (* c (* x s)))) (/ 1.0 (* t_0 t_0))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
double t_0 = c * (x * s);
return 1.0 / (t_0 * t_0);
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
t_0 = c * (x * s)
code = 1.0d0 / (t_0 * t_0)
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
double t_0 = c * (x * s);
return 1.0 / (t_0 * t_0);
}
x = abs(x) c = abs(c) s = abs(s) [c, s] = sort([c, s]) def code(x, c, s): t_0 = c * (x * s) return 1.0 / (t_0 * t_0)
x = abs(x) c = abs(c) s = abs(s) c, s = sort([c, s]) function code(x, c, s) t_0 = Float64(c * Float64(x * s)) return Float64(1.0 / Float64(t_0 * t_0)) end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
t_0 = c * (x * s);
tmp = 1.0 / (t_0 * t_0);
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\frac{1}{t_0 \cdot t_0}
\end{array}
\end{array}
Initial program 63.7%
associate-/r*63.7%
*-commutative63.7%
associate-*r*59.5%
unpow259.5%
associate-/l/58.5%
Simplified58.5%
Taylor expanded in x around 0 54.8%
associate-/r*54.8%
*-commutative54.8%
unpow254.8%
unpow254.8%
swap-sqr67.7%
unpow267.7%
associate-/r*67.7%
unpow267.7%
rem-square-sqrt67.7%
swap-sqr75.9%
unpow275.9%
unpow275.9%
rem-sqrt-square81.8%
*-commutative81.8%
Simplified81.8%
add-sqr-sqrt50.6%
sqrt-prod81.8%
unpow281.8%
pow281.8%
add-sqr-sqrt81.8%
unpow281.8%
add-sqr-sqrt42.5%
fabs-sqr42.5%
add-sqr-sqrt56.7%
add-sqr-sqrt37.3%
fabs-sqr37.3%
add-sqr-sqrt81.8%
Applied egg-rr81.8%
Final simplification81.8%
herbie shell --seed 2023308
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))