
(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 9 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}
(FPCore (x c s) :precision binary64 (* (cos (* x 2.0)) (pow (* x (* s c)) -2.0)))
double code(double x, double c, double s) {
return cos((x * 2.0)) * pow((x * (s * c)), -2.0);
}
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)) * ((x * (s * c)) ** (-2.0d0))
end function
public static double code(double x, double c, double s) {
return Math.cos((x * 2.0)) * Math.pow((x * (s * c)), -2.0);
}
def code(x, c, s): return math.cos((x * 2.0)) * math.pow((x * (s * c)), -2.0)
function code(x, c, s) return Float64(cos(Float64(x * 2.0)) * (Float64(x * Float64(s * c)) ^ -2.0)) end
function tmp = code(x, c, s) tmp = cos((x * 2.0)) * ((x * (s * c)) ^ -2.0); end
code[x_, c_, s_] := N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(x * N[(s * c), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(x \cdot 2\right) \cdot {\left(x \cdot \left(s \cdot c\right)\right)}^{-2}
\end{array}
Initial program 61.7%
*-un-lft-identity61.7%
add-sqr-sqrt61.7%
times-frac61.7%
sqrt-prod61.7%
sqrt-pow146.0%
metadata-eval46.0%
pow146.0%
*-commutative46.0%
associate-*r*43.6%
unpow243.6%
pow-prod-down46.0%
sqrt-pow147.0%
metadata-eval47.0%
pow147.0%
*-commutative47.0%
Applied egg-rr97.2%
*-commutative97.2%
associate-/r*97.3%
frac-times92.6%
*-commutative92.6%
Applied egg-rr92.6%
*-rgt-identity92.6%
*-rgt-identity92.6%
*-rgt-identity92.6%
div-inv92.6%
associate-/l*92.6%
associate-/r*92.3%
associate-*l*96.9%
pow296.9%
pow-flip97.2%
metadata-eval97.2%
*-commutative97.2%
associate-*l*98.3%
Applied egg-rr98.3%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (cos (* x 2.0))) (t_1 (* c (* x s))))
(if (<= x 1.5e+91)
(/ (/ t_0 t_1) t_1)
(/ (/ (/ t_0 x) c) (* s (* x (* s c)))))))
double code(double x, double c, double s) {
double t_0 = cos((x * 2.0));
double t_1 = c * (x * s);
double tmp;
if (x <= 1.5e+91) {
tmp = (t_0 / t_1) / t_1;
} else {
tmp = ((t_0 / x) / c) / (s * (x * (s * c)));
}
return tmp;
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((x * 2.0d0))
t_1 = c * (x * s)
if (x <= 1.5d+91) then
tmp = (t_0 / t_1) / t_1
else
tmp = ((t_0 / x) / c) / (s * (x * (s * c)))
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double t_0 = Math.cos((x * 2.0));
double t_1 = c * (x * s);
double tmp;
if (x <= 1.5e+91) {
tmp = (t_0 / t_1) / t_1;
} else {
tmp = ((t_0 / x) / c) / (s * (x * (s * c)));
}
return tmp;
}
def code(x, c, s): t_0 = math.cos((x * 2.0)) t_1 = c * (x * s) tmp = 0 if x <= 1.5e+91: tmp = (t_0 / t_1) / t_1 else: tmp = ((t_0 / x) / c) / (s * (x * (s * c))) return tmp
function code(x, c, s) t_0 = cos(Float64(x * 2.0)) t_1 = Float64(c * Float64(x * s)) tmp = 0.0 if (x <= 1.5e+91) tmp = Float64(Float64(t_0 / t_1) / t_1); else tmp = Float64(Float64(Float64(t_0 / x) / c) / Float64(s * Float64(x * Float64(s * c)))); end return tmp end
function tmp_2 = code(x, c, s) t_0 = cos((x * 2.0)); t_1 = c * (x * s); tmp = 0.0; if (x <= 1.5e+91) tmp = (t_0 / t_1) / t_1; else tmp = ((t_0 / x) / c) / (s * (x * (s * c))); end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.5e+91], N[(N[(t$95$0 / t$95$1), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(N[(t$95$0 / x), $MachinePrecision] / c), $MachinePrecision] / N[(s * N[(x * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(x \cdot 2\right)\\
t_1 := c \cdot \left(x \cdot s\right)\\
\mathbf{if}\;x \leq 1.5 \cdot 10^{+91}:\\
\;\;\;\;\frac{\frac{t\_0}{t\_1}}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{t\_0}{x}}{c}}{s \cdot \left(x \cdot \left(s \cdot c\right)\right)}\\
\end{array}
\end{array}
if x < 1.50000000000000003e91Initial program 62.0%
*-un-lft-identity62.0%
add-sqr-sqrt62.0%
times-frac62.0%
sqrt-prod62.0%
sqrt-pow145.1%
metadata-eval45.1%
pow145.1%
*-commutative45.1%
associate-*r*42.8%
unpow242.8%
pow-prod-down45.1%
sqrt-pow144.6%
metadata-eval44.6%
pow144.6%
*-commutative44.6%
Applied egg-rr97.1%
associate-*l/97.1%
*-un-lft-identity97.1%
*-commutative97.1%
Applied egg-rr97.1%
if 1.50000000000000003e91 < x Initial program 60.2%
*-un-lft-identity60.2%
add-sqr-sqrt60.3%
times-frac60.3%
sqrt-prod60.2%
sqrt-pow149.6%
metadata-eval49.6%
pow149.6%
*-commutative49.6%
associate-*r*47.3%
unpow247.3%
pow-prod-down49.7%
sqrt-pow157.9%
metadata-eval57.9%
pow157.9%
*-commutative57.9%
Applied egg-rr97.7%
*-commutative97.7%
associate-/r*97.6%
frac-times93.8%
*-commutative93.8%
Applied egg-rr93.8%
*-rgt-identity93.8%
*-commutative93.8%
*-un-lft-identity93.8%
*-rgt-identity93.8%
div-inv93.8%
associate-*l*87.9%
times-frac87.5%
*-commutative87.5%
associate-*l*87.6%
Applied egg-rr87.6%
associate-*r/82.9%
un-div-inv83.0%
Applied egg-rr83.0%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (* c (* x s))) (t_1 (cos (* x 2.0))))
(if (<= c 8e-236)
(/ (/ t_1 x) (* (* s c) (* x (* s c))))
(/ (/ t_1 t_0) t_0))))
double code(double x, double c, double s) {
double t_0 = c * (x * s);
double t_1 = cos((x * 2.0));
double tmp;
if (c <= 8e-236) {
tmp = (t_1 / x) / ((s * c) * (x * (s * c)));
} else {
tmp = (t_1 / t_0) / t_0;
}
return tmp;
}
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 = c * (x * s)
t_1 = cos((x * 2.0d0))
if (c <= 8d-236) then
tmp = (t_1 / x) / ((s * c) * (x * (s * c)))
else
tmp = (t_1 / t_0) / t_0
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double t_0 = c * (x * s);
double t_1 = Math.cos((x * 2.0));
double tmp;
if (c <= 8e-236) {
tmp = (t_1 / x) / ((s * c) * (x * (s * c)));
} else {
tmp = (t_1 / t_0) / t_0;
}
return tmp;
}
def code(x, c, s): t_0 = c * (x * s) t_1 = math.cos((x * 2.0)) tmp = 0 if c <= 8e-236: tmp = (t_1 / x) / ((s * c) * (x * (s * c))) else: tmp = (t_1 / t_0) / t_0 return tmp
function code(x, c, s) t_0 = Float64(c * Float64(x * s)) t_1 = cos(Float64(x * 2.0)) tmp = 0.0 if (c <= 8e-236) tmp = Float64(Float64(t_1 / x) / Float64(Float64(s * c) * Float64(x * Float64(s * c)))); else tmp = Float64(Float64(t_1 / t_0) / t_0); end return tmp end
function tmp_2 = code(x, c, s) t_0 = c * (x * s); t_1 = cos((x * 2.0)); tmp = 0.0; if (c <= 8e-236) tmp = (t_1 / x) / ((s * c) * (x * (s * c))); else tmp = (t_1 / t_0) / t_0; end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[c, 8e-236], N[(N[(t$95$1 / x), $MachinePrecision] / N[(N[(s * c), $MachinePrecision] * N[(x * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
t_1 := \cos \left(x \cdot 2\right)\\
\mathbf{if}\;c \leq 8 \cdot 10^{-236}:\\
\;\;\;\;\frac{\frac{t\_1}{x}}{\left(s \cdot c\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_1}{t\_0}}{t\_0}\\
\end{array}
\end{array}
if c < 8.0000000000000004e-236Initial program 61.1%
*-un-lft-identity61.1%
add-sqr-sqrt61.1%
times-frac61.1%
sqrt-prod61.1%
sqrt-pow128.9%
metadata-eval28.9%
pow128.9%
*-commutative28.9%
associate-*r*28.0%
unpow228.0%
pow-prod-down28.9%
sqrt-pow145.3%
metadata-eval45.3%
pow145.3%
*-commutative45.3%
Applied egg-rr95.4%
*-commutative95.4%
associate-/r*95.5%
frac-times91.6%
*-commutative91.6%
Applied egg-rr91.6%
*-rgt-identity91.6%
*-commutative91.6%
*-un-lft-identity91.6%
*-rgt-identity91.6%
div-inv91.5%
associate-*l*89.4%
times-frac90.3%
*-commutative90.3%
associate-*l*92.3%
Applied egg-rr92.3%
clear-num92.2%
un-div-inv92.3%
*-commutative92.3%
*-un-lft-identity92.3%
times-frac94.5%
/-rgt-identity94.5%
div-inv94.4%
clear-num94.5%
/-rgt-identity94.5%
Applied egg-rr94.5%
if 8.0000000000000004e-236 < c Initial program 62.2%
*-un-lft-identity62.2%
add-sqr-sqrt62.2%
times-frac62.2%
sqrt-prod62.2%
sqrt-pow162.2%
metadata-eval62.2%
pow162.2%
*-commutative62.2%
associate-*r*58.6%
unpow258.6%
pow-prod-down62.3%
sqrt-pow148.6%
metadata-eval48.6%
pow148.6%
*-commutative48.6%
Applied egg-rr98.9%
associate-*l/99.0%
*-un-lft-identity99.0%
*-commutative99.0%
Applied egg-rr99.0%
Final simplification96.8%
(FPCore (x c s) :precision binary64 (if (<= x 5.8e-10) (/ (/ 1.0 c) (* (* x s) (* c (* x s)))) (/ (/ (cos (* x 2.0)) x) (* (* s c) (* x (* s c))))))
double code(double x, double c, double s) {
double tmp;
if (x <= 5.8e-10) {
tmp = (1.0 / c) / ((x * s) * (c * (x * s)));
} else {
tmp = (cos((x * 2.0)) / x) / ((s * c) * (x * (s * c)));
}
return tmp;
}
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 <= 5.8d-10) then
tmp = (1.0d0 / c) / ((x * s) * (c * (x * s)))
else
tmp = (cos((x * 2.0d0)) / x) / ((s * c) * (x * (s * c)))
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double tmp;
if (x <= 5.8e-10) {
tmp = (1.0 / c) / ((x * s) * (c * (x * s)));
} else {
tmp = (Math.cos((x * 2.0)) / x) / ((s * c) * (x * (s * c)));
}
return tmp;
}
def code(x, c, s): tmp = 0 if x <= 5.8e-10: tmp = (1.0 / c) / ((x * s) * (c * (x * s))) else: tmp = (math.cos((x * 2.0)) / x) / ((s * c) * (x * (s * c))) return tmp
function code(x, c, s) tmp = 0.0 if (x <= 5.8e-10) tmp = Float64(Float64(1.0 / c) / Float64(Float64(x * s) * Float64(c * Float64(x * s)))); else tmp = Float64(Float64(cos(Float64(x * 2.0)) / x) / Float64(Float64(s * c) * Float64(x * Float64(s * c)))); end return tmp end
function tmp_2 = code(x, c, s) tmp = 0.0; if (x <= 5.8e-10) tmp = (1.0 / c) / ((x * s) * (c * (x * s))); else tmp = (cos((x * 2.0)) / x) / ((s * c) * (x * (s * c))); end tmp_2 = tmp; end
code[x_, c_, s_] := If[LessEqual[x, 5.8e-10], N[(N[(1.0 / c), $MachinePrecision] / N[(N[(x * s), $MachinePrecision] * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision] / N[(N[(s * c), $MachinePrecision] * N[(x * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.8 \cdot 10^{-10}:\\
\;\;\;\;\frac{\frac{1}{c}}{\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(x \cdot 2\right)}{x}}{\left(s \cdot c\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)}\\
\end{array}
\end{array}
if x < 5.79999999999999962e-10Initial program 61.5%
*-un-lft-identity61.5%
add-sqr-sqrt61.5%
times-frac61.5%
sqrt-prod61.5%
sqrt-pow144.3%
metadata-eval44.3%
pow144.3%
*-commutative44.3%
associate-*r*41.7%
unpow241.7%
pow-prod-down44.3%
sqrt-pow144.8%
metadata-eval44.8%
pow144.8%
*-commutative44.8%
Applied egg-rr96.9%
*-commutative96.9%
associate-/r*97.0%
frac-times92.2%
*-commutative92.2%
Applied egg-rr92.2%
Taylor expanded in x around 0 78.3%
if 5.79999999999999962e-10 < x Initial program 62.2%
*-un-lft-identity62.2%
add-sqr-sqrt62.3%
times-frac62.3%
sqrt-prod62.2%
sqrt-pow151.1%
metadata-eval51.1%
pow151.1%
*-commutative51.1%
associate-*r*49.4%
unpow249.4%
pow-prod-down51.2%
sqrt-pow153.9%
metadata-eval53.9%
pow153.9%
*-commutative53.9%
Applied egg-rr98.2%
*-commutative98.2%
associate-/r*98.1%
frac-times93.8%
*-commutative93.8%
Applied egg-rr93.8%
*-rgt-identity93.8%
*-commutative93.8%
*-un-lft-identity93.8%
*-rgt-identity93.8%
div-inv93.9%
associate-*l*89.4%
times-frac89.2%
*-commutative89.2%
associate-*l*89.3%
Applied egg-rr89.3%
clear-num89.2%
un-div-inv89.3%
*-commutative89.3%
*-un-lft-identity89.3%
times-frac90.8%
/-rgt-identity90.8%
div-inv90.7%
clear-num90.6%
/-rgt-identity90.6%
Applied egg-rr90.6%
Final simplification81.4%
(FPCore (x c s) :precision binary64 (if (<= x 3.5e-10) (/ (/ 1.0 c) (* (* x s) (* c (* x s)))) (/ (cos (* x 2.0)) (* x (* (* s c) (* x (* s c)))))))
double code(double x, double c, double s) {
double tmp;
if (x <= 3.5e-10) {
tmp = (1.0 / c) / ((x * s) * (c * (x * s)));
} else {
tmp = cos((x * 2.0)) / (x * ((s * c) * (x * (s * c))));
}
return tmp;
}
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 <= 3.5d-10) then
tmp = (1.0d0 / c) / ((x * s) * (c * (x * s)))
else
tmp = cos((x * 2.0d0)) / (x * ((s * c) * (x * (s * c))))
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double tmp;
if (x <= 3.5e-10) {
tmp = (1.0 / c) / ((x * s) * (c * (x * s)));
} else {
tmp = Math.cos((x * 2.0)) / (x * ((s * c) * (x * (s * c))));
}
return tmp;
}
def code(x, c, s): tmp = 0 if x <= 3.5e-10: tmp = (1.0 / c) / ((x * s) * (c * (x * s))) else: tmp = math.cos((x * 2.0)) / (x * ((s * c) * (x * (s * c)))) return tmp
function code(x, c, s) tmp = 0.0 if (x <= 3.5e-10) tmp = Float64(Float64(1.0 / c) / Float64(Float64(x * s) * Float64(c * Float64(x * s)))); else tmp = Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(Float64(s * c) * Float64(x * Float64(s * c))))); end return tmp end
function tmp_2 = code(x, c, s) tmp = 0.0; if (x <= 3.5e-10) tmp = (1.0 / c) / ((x * s) * (c * (x * s))); else tmp = cos((x * 2.0)) / (x * ((s * c) * (x * (s * c)))); end tmp_2 = tmp; end
code[x_, c_, s_] := If[LessEqual[x, 3.5e-10], N[(N[(1.0 / c), $MachinePrecision] / N[(N[(x * s), $MachinePrecision] * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * N[(N[(s * c), $MachinePrecision] * N[(x * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.5 \cdot 10^{-10}:\\
\;\;\;\;\frac{\frac{1}{c}}{\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(\left(s \cdot c\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)\right)}\\
\end{array}
\end{array}
if x < 3.4999999999999998e-10Initial program 61.5%
*-un-lft-identity61.5%
add-sqr-sqrt61.5%
times-frac61.5%
sqrt-prod61.5%
sqrt-pow144.3%
metadata-eval44.3%
pow144.3%
*-commutative44.3%
associate-*r*41.7%
unpow241.7%
pow-prod-down44.3%
sqrt-pow144.8%
metadata-eval44.8%
pow144.8%
*-commutative44.8%
Applied egg-rr96.9%
*-commutative96.9%
associate-/r*97.0%
frac-times92.2%
*-commutative92.2%
Applied egg-rr92.2%
Taylor expanded in x around 0 78.3%
if 3.4999999999999998e-10 < x Initial program 62.2%
*-un-lft-identity62.2%
add-sqr-sqrt62.3%
times-frac62.3%
sqrt-prod62.2%
sqrt-pow151.1%
metadata-eval51.1%
pow151.1%
*-commutative51.1%
associate-*r*49.4%
unpow249.4%
pow-prod-down51.2%
sqrt-pow153.9%
metadata-eval53.9%
pow153.9%
*-commutative53.9%
Applied egg-rr98.2%
*-commutative98.2%
associate-/r*98.1%
frac-times93.8%
*-commutative93.8%
Applied egg-rr93.8%
*-rgt-identity93.8%
*-commutative93.8%
*-un-lft-identity93.8%
*-rgt-identity93.8%
div-inv93.9%
associate-*l*89.4%
times-frac89.2%
*-commutative89.2%
associate-*l*89.3%
Applied egg-rr89.3%
*-commutative89.3%
clear-num89.2%
frac-times88.8%
*-un-lft-identity88.8%
*-commutative88.8%
*-un-lft-identity88.8%
times-frac90.3%
/-rgt-identity90.3%
div-inv90.2%
clear-num90.1%
/-rgt-identity90.1%
Applied egg-rr90.1%
Final simplification81.2%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* x (* s c)))) (* (/ (cos (* x 2.0)) t_0) (/ 1.0 t_0))))
double code(double x, double c, double s) {
double t_0 = x * (s * c);
return (cos((x * 2.0)) / t_0) * (1.0 / t_0);
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
t_0 = x * (s * c)
code = (cos((x * 2.0d0)) / t_0) * (1.0d0 / t_0)
end function
public static double code(double x, double c, double s) {
double t_0 = x * (s * c);
return (Math.cos((x * 2.0)) / t_0) * (1.0 / t_0);
}
def code(x, c, s): t_0 = x * (s * c) return (math.cos((x * 2.0)) / t_0) * (1.0 / t_0)
function code(x, c, s) t_0 = Float64(x * Float64(s * c)) return Float64(Float64(cos(Float64(x * 2.0)) / t_0) * Float64(1.0 / t_0)) end
function tmp = code(x, c, s) t_0 = x * (s * c); tmp = (cos((x * 2.0)) / t_0) * (1.0 / t_0); end
code[x_, c_, s_] := Block[{t$95$0 = N[(x * N[(s * c), $MachinePrecision]), $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}
\\
\begin{array}{l}
t_0 := x \cdot \left(s \cdot c\right)\\
\frac{\cos \left(x \cdot 2\right)}{t\_0} \cdot \frac{1}{t\_0}
\end{array}
\end{array}
Initial program 61.7%
*-un-lft-identity61.7%
add-sqr-sqrt61.7%
times-frac61.7%
sqrt-prod61.7%
sqrt-pow146.0%
metadata-eval46.0%
pow146.0%
*-commutative46.0%
associate-*r*43.6%
unpow243.6%
pow-prod-down46.0%
sqrt-pow147.0%
metadata-eval47.0%
pow147.0%
*-commutative47.0%
Applied egg-rr97.2%
*-commutative97.2%
associate-/r*97.3%
frac-times92.6%
*-commutative92.6%
Applied egg-rr92.6%
*-rgt-identity92.6%
frac-times97.3%
*-rgt-identity97.3%
associate-/l/97.2%
associate-*l*96.0%
*-commutative96.0%
associate-*l*98.3%
Applied egg-rr98.3%
(FPCore (x c s) :precision binary64 (pow (* c (* x s)) -2.0))
double code(double x, double c, double s) {
return pow((c * (x * s)), -2.0);
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = (c * (x * s)) ** (-2.0d0)
end function
public static double code(double x, double c, double s) {
return Math.pow((c * (x * s)), -2.0);
}
def code(x, c, s): return math.pow((c * (x * s)), -2.0)
function code(x, c, s) return Float64(c * Float64(x * s)) ^ -2.0 end
function tmp = code(x, c, s) tmp = (c * (x * s)) ^ -2.0; end
code[x_, c_, s_] := N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]
\begin{array}{l}
\\
{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}
\end{array}
Initial program 61.7%
Taylor expanded in x around 0 51.3%
associate-/r*50.6%
*-commutative50.6%
unpow250.6%
unpow250.6%
swap-sqr62.7%
unpow262.7%
associate-/r*63.4%
unpow263.4%
unpow263.4%
swap-sqr76.5%
unpow276.5%
*-commutative76.5%
Simplified76.5%
pow-flip76.7%
*-commutative76.7%
metadata-eval76.7%
Applied egg-rr76.7%
(FPCore (x c s) :precision binary64 (let* ((t_0 (/ 1.0 (* c (* x s))))) (* t_0 t_0)))
double code(double x, double c, double s) {
double t_0 = 1.0 / (c * (x * s));
return t_0 * t_0;
}
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
public static double code(double x, double c, double s) {
double t_0 = 1.0 / (c * (x * s));
return t_0 * t_0;
}
def code(x, c, s): t_0 = 1.0 / (c * (x * s)) return t_0 * t_0
function code(x, c, s) t_0 = Float64(1.0 / Float64(c * Float64(x * s))) return Float64(t_0 * t_0) end
function tmp = code(x, c, s) t_0 = 1.0 / (c * (x * s)); tmp = t_0 * t_0; end
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}
\\
\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 61.7%
Taylor expanded in x around 0 51.3%
associate-/r*50.6%
*-commutative50.6%
unpow250.6%
unpow250.6%
swap-sqr62.7%
unpow262.7%
associate-/r*63.4%
unpow263.4%
unpow263.4%
swap-sqr76.5%
unpow276.5%
*-commutative76.5%
Simplified76.5%
*-commutative76.5%
pow-flip76.7%
metadata-eval76.7%
metadata-eval76.7%
pow-prod-up76.7%
inv-pow76.7%
inv-pow76.7%
Applied egg-rr76.7%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* c (* x s)))) (/ 1.0 (* t_0 t_0))))
double code(double x, double c, double s) {
double t_0 = c * (x * s);
return 1.0 / (t_0 * t_0);
}
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
public static double code(double x, double c, double s) {
double t_0 = c * (x * s);
return 1.0 / (t_0 * t_0);
}
def code(x, c, s): t_0 = c * (x * s) return 1.0 / (t_0 * t_0)
function code(x, c, s) t_0 = Float64(c * Float64(x * s)) return Float64(1.0 / Float64(t_0 * t_0)) end
function tmp = code(x, c, s) t_0 = c * (x * s); tmp = 1.0 / (t_0 * t_0); end
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}
\\
\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 61.7%
Taylor expanded in x around 0 51.3%
associate-/r*50.6%
*-commutative50.6%
unpow250.6%
unpow250.6%
swap-sqr62.7%
unpow262.7%
associate-/r*63.4%
unpow263.4%
unpow263.4%
swap-sqr76.5%
unpow276.5%
*-commutative76.5%
Simplified76.5%
*-commutative76.5%
pow276.5%
Applied egg-rr76.5%
herbie shell --seed 2024132
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))