
(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 10 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 (* (pow (* s (* x c)) -2.0) (cos (* x 2.0))))
double code(double x, double c, double s) {
return pow((s * (x * c)), -2.0) * cos((x * 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 = ((s * (x * c)) ** (-2.0d0)) * cos((x * 2.0d0))
end function
public static double code(double x, double c, double s) {
return Math.pow((s * (x * c)), -2.0) * Math.cos((x * 2.0));
}
def code(x, c, s): return math.pow((s * (x * c)), -2.0) * math.cos((x * 2.0))
function code(x, c, s) return Float64((Float64(s * Float64(x * c)) ^ -2.0) * cos(Float64(x * 2.0))) end
function tmp = code(x, c, s) tmp = ((s * (x * c)) ^ -2.0) * cos((x * 2.0)); end
code[x_, c_, s_] := 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}
\\
{\left(s \cdot \left(x \cdot c\right)\right)}^{-2} \cdot \cos \left(x \cdot 2\right)
\end{array}
Initial program 64.4%
*-commutative64.4%
associate-*r*59.8%
associate-*r*60.5%
unpow260.5%
unswap-sqr76.7%
unpow276.7%
swap-sqr97.5%
*-commutative97.5%
*-commutative97.5%
*-commutative97.5%
*-commutative97.5%
Simplified97.5%
div-inv97.6%
*-commutative97.6%
pow297.6%
pow-flip97.8%
metadata-eval97.8%
Applied egg-rr97.8%
Final simplification97.8%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (/ (cos (* x 2.0)) (* s (* (* x x) (* c (* s c)))))))
(if (<= x -1.9e-18)
t_0
(if (<= x 1.05e-10)
(/ 1.0 (pow (* c (* x s)) 2.0))
(if (<= x 5.8e+174) t_0 (/ 1.0 (pow (* s (* x c)) 2.0)))))))
double code(double x, double c, double s) {
double t_0 = cos((x * 2.0)) / (s * ((x * x) * (c * (s * c))));
double tmp;
if (x <= -1.9e-18) {
tmp = t_0;
} else if (x <= 1.05e-10) {
tmp = 1.0 / pow((c * (x * s)), 2.0);
} else if (x <= 5.8e+174) {
tmp = t_0;
} else {
tmp = 1.0 / pow((s * (x * c)), 2.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) :: tmp
t_0 = cos((x * 2.0d0)) / (s * ((x * x) * (c * (s * c))))
if (x <= (-1.9d-18)) then
tmp = t_0
else if (x <= 1.05d-10) then
tmp = 1.0d0 / ((c * (x * s)) ** 2.0d0)
else if (x <= 5.8d+174) then
tmp = t_0
else
tmp = 1.0d0 / ((s * (x * c)) ** 2.0d0)
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double t_0 = Math.cos((x * 2.0)) / (s * ((x * x) * (c * (s * c))));
double tmp;
if (x <= -1.9e-18) {
tmp = t_0;
} else if (x <= 1.05e-10) {
tmp = 1.0 / Math.pow((c * (x * s)), 2.0);
} else if (x <= 5.8e+174) {
tmp = t_0;
} else {
tmp = 1.0 / Math.pow((s * (x * c)), 2.0);
}
return tmp;
}
def code(x, c, s): t_0 = math.cos((x * 2.0)) / (s * ((x * x) * (c * (s * c)))) tmp = 0 if x <= -1.9e-18: tmp = t_0 elif x <= 1.05e-10: tmp = 1.0 / math.pow((c * (x * s)), 2.0) elif x <= 5.8e+174: tmp = t_0 else: tmp = 1.0 / math.pow((s * (x * c)), 2.0) return tmp
function code(x, c, s) t_0 = Float64(cos(Float64(x * 2.0)) / Float64(s * Float64(Float64(x * x) * Float64(c * Float64(s * c))))) tmp = 0.0 if (x <= -1.9e-18) tmp = t_0; elseif (x <= 1.05e-10) tmp = Float64(1.0 / (Float64(c * Float64(x * s)) ^ 2.0)); elseif (x <= 5.8e+174) tmp = t_0; else tmp = Float64(1.0 / (Float64(s * Float64(x * c)) ^ 2.0)); end return tmp end
function tmp_2 = code(x, c, s) t_0 = cos((x * 2.0)) / (s * ((x * x) * (c * (s * c)))); tmp = 0.0; if (x <= -1.9e-18) tmp = t_0; elseif (x <= 1.05e-10) tmp = 1.0 / ((c * (x * s)) ^ 2.0); elseif (x <= 5.8e+174) tmp = t_0; else tmp = 1.0 / ((s * (x * c)) ^ 2.0); end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(s * N[(N[(x * x), $MachinePrecision] * N[(c * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.9e-18], t$95$0, If[LessEqual[x, 1.05e-10], N[(1.0 / N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.8e+174], t$95$0, N[(1.0 / N[Power[N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\cos \left(x \cdot 2\right)}{s \cdot \left(\left(x \cdot x\right) \cdot \left(c \cdot \left(s \cdot c\right)\right)\right)}\\
\mathbf{if}\;x \leq -1.9 \cdot 10^{-18}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{-10}:\\
\;\;\;\;\frac{1}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{+174}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{{\left(s \cdot \left(x \cdot c\right)\right)}^{2}}\\
\end{array}
\end{array}
if x < -1.8999999999999999e-18 or 1.05e-10 < x < 5.7999999999999999e174Initial program 65.5%
*-commutative65.5%
associate-*l*60.6%
associate-*r*60.7%
*-commutative60.7%
unpow260.7%
associate-*r*69.2%
associate-*r*71.1%
*-commutative71.1%
unpow271.1%
Simplified71.1%
Taylor expanded in c around 0 71.1%
*-commutative71.1%
unpow271.1%
associate-*l*78.5%
Simplified78.5%
if -1.8999999999999999e-18 < x < 1.05e-10Initial program 67.6%
*-commutative67.6%
associate-*r*65.4%
associate-*r*67.0%
unpow267.0%
unswap-sqr81.4%
unpow281.4%
swap-sqr97.2%
*-commutative97.2%
*-commutative97.2%
*-commutative97.2%
*-commutative97.2%
Simplified97.2%
Taylor expanded in x around 0 65.4%
unpow265.4%
unpow265.4%
associate-*r*64.8%
*-commutative64.8%
associate-*r*67.0%
unpow267.0%
unpow267.0%
unpow267.0%
associate-/r*67.0%
associate-/r*67.0%
unpow267.0%
*-commutative67.0%
unpow267.0%
swap-sqr81.4%
unpow281.4%
associate-/l/89.2%
associate-/r*89.2%
*-commutative89.2%
associate-*r*81.4%
Simplified98.1%
if 5.7999999999999999e174 < x Initial program 51.7%
*-commutative51.7%
associate-*r*40.3%
associate-*r*40.3%
unpow240.3%
unswap-sqr74.1%
unpow274.1%
swap-sqr97.3%
*-commutative97.3%
*-commutative97.3%
*-commutative97.3%
*-commutative97.3%
Simplified97.3%
Taylor expanded in x around 0 40.3%
unpow240.3%
unpow240.3%
unpow240.3%
Simplified40.3%
*-commutative40.3%
unswap-sqr57.6%
*-commutative57.6%
*-commutative57.6%
unpow257.6%
pow257.6%
pow-prod-down67.4%
*-commutative67.4%
associate-*r*67.4%
Applied egg-rr67.4%
Final simplification85.8%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (cos (* x 2.0))) (t_1 (/ t_0 (* s (* (* x x) (* c (* s c)))))))
(if (<= x -2.7e-12)
t_1
(if (<= x 9.5e-11)
(/ 1.0 (pow (* c (* x s)) 2.0))
(if (<= x 2e+150) t_1 (/ t_0 (* x (* (* c c) (* s (* x s))))))))))
double code(double x, double c, double s) {
double t_0 = cos((x * 2.0));
double t_1 = t_0 / (s * ((x * x) * (c * (s * c))));
double tmp;
if (x <= -2.7e-12) {
tmp = t_1;
} else if (x <= 9.5e-11) {
tmp = 1.0 / pow((c * (x * s)), 2.0);
} else if (x <= 2e+150) {
tmp = t_1;
} else {
tmp = t_0 / (x * ((c * c) * (s * (x * s))));
}
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 = t_0 / (s * ((x * x) * (c * (s * c))))
if (x <= (-2.7d-12)) then
tmp = t_1
else if (x <= 9.5d-11) then
tmp = 1.0d0 / ((c * (x * s)) ** 2.0d0)
else if (x <= 2d+150) then
tmp = t_1
else
tmp = t_0 / (x * ((c * c) * (s * (x * s))))
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 = t_0 / (s * ((x * x) * (c * (s * c))));
double tmp;
if (x <= -2.7e-12) {
tmp = t_1;
} else if (x <= 9.5e-11) {
tmp = 1.0 / Math.pow((c * (x * s)), 2.0);
} else if (x <= 2e+150) {
tmp = t_1;
} else {
tmp = t_0 / (x * ((c * c) * (s * (x * s))));
}
return tmp;
}
def code(x, c, s): t_0 = math.cos((x * 2.0)) t_1 = t_0 / (s * ((x * x) * (c * (s * c)))) tmp = 0 if x <= -2.7e-12: tmp = t_1 elif x <= 9.5e-11: tmp = 1.0 / math.pow((c * (x * s)), 2.0) elif x <= 2e+150: tmp = t_1 else: tmp = t_0 / (x * ((c * c) * (s * (x * s)))) return tmp
function code(x, c, s) t_0 = cos(Float64(x * 2.0)) t_1 = Float64(t_0 / Float64(s * Float64(Float64(x * x) * Float64(c * Float64(s * c))))) tmp = 0.0 if (x <= -2.7e-12) tmp = t_1; elseif (x <= 9.5e-11) tmp = Float64(1.0 / (Float64(c * Float64(x * s)) ^ 2.0)); elseif (x <= 2e+150) tmp = t_1; else tmp = Float64(t_0 / Float64(x * Float64(Float64(c * c) * Float64(s * Float64(x * s))))); end return tmp end
function tmp_2 = code(x, c, s) t_0 = cos((x * 2.0)); t_1 = t_0 / (s * ((x * x) * (c * (s * c)))); tmp = 0.0; if (x <= -2.7e-12) tmp = t_1; elseif (x <= 9.5e-11) tmp = 1.0 / ((c * (x * s)) ^ 2.0); elseif (x <= 2e+150) tmp = t_1; else tmp = t_0 / (x * ((c * c) * (s * (x * s)))); 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[(t$95$0 / N[(s * N[(N[(x * x), $MachinePrecision] * N[(c * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.7e-12], t$95$1, If[LessEqual[x, 9.5e-11], N[(1.0 / N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2e+150], t$95$1, N[(t$95$0 / N[(x * N[(N[(c * c), $MachinePrecision] * N[(s * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(x \cdot 2\right)\\
t_1 := \frac{t_0}{s \cdot \left(\left(x \cdot x\right) \cdot \left(c \cdot \left(s \cdot c\right)\right)\right)}\\
\mathbf{if}\;x \leq -2.7 \cdot 10^{-12}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-11}:\\
\;\;\;\;\frac{1}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}\\
\mathbf{elif}\;x \leq 2 \cdot 10^{+150}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{x \cdot \left(\left(c \cdot c\right) \cdot \left(s \cdot \left(x \cdot s\right)\right)\right)}\\
\end{array}
\end{array}
if x < -2.6999999999999998e-12 or 9.49999999999999951e-11 < x < 1.99999999999999996e150Initial program 65.1%
*-commutative65.1%
associate-*l*61.2%
associate-*r*61.3%
*-commutative61.3%
unpow261.3%
associate-*r*69.9%
associate-*r*71.7%
*-commutative71.7%
unpow271.7%
Simplified71.7%
Taylor expanded in c around 0 71.7%
*-commutative71.7%
unpow271.7%
associate-*l*79.2%
Simplified79.2%
if -2.6999999999999998e-12 < x < 9.49999999999999951e-11Initial program 67.6%
*-commutative67.6%
associate-*r*65.4%
associate-*r*67.0%
unpow267.0%
unswap-sqr81.4%
unpow281.4%
swap-sqr97.2%
*-commutative97.2%
*-commutative97.2%
*-commutative97.2%
*-commutative97.2%
Simplified97.2%
Taylor expanded in x around 0 65.4%
unpow265.4%
unpow265.4%
associate-*r*64.8%
*-commutative64.8%
associate-*r*67.0%
unpow267.0%
unpow267.0%
unpow267.0%
associate-/r*67.0%
associate-/r*67.0%
unpow267.0%
*-commutative67.0%
unpow267.0%
swap-sqr81.4%
unpow281.4%
associate-/l/89.2%
associate-/r*89.2%
*-commutative89.2%
associate-*r*81.4%
Simplified98.1%
if 1.99999999999999996e150 < x Initial program 52.9%
associate-*r*60.1%
*-commutative60.1%
*-commutative60.1%
associate-*r*54.7%
*-commutative54.7%
unpow254.7%
unpow254.7%
Simplified54.7%
Taylor expanded in x around 0 59.7%
unpow259.7%
*-commutative59.7%
associate-*r*60.1%
unpow260.1%
associate-*r*79.7%
*-commutative79.7%
Simplified79.7%
Final simplification87.9%
(FPCore (x c s)
:precision binary64
(if (<= c -1.15e+84)
(/ 1.0 (pow (* s (* x c)) 2.0))
(if (<= c -2.75e-157)
(/ (cos (* x 2.0)) (* (* c c) (* x (* s (* x s)))))
(/ 1.0 (pow (* c (* x s)) 2.0)))))
double code(double x, double c, double s) {
double tmp;
if (c <= -1.15e+84) {
tmp = 1.0 / pow((s * (x * c)), 2.0);
} else if (c <= -2.75e-157) {
tmp = cos((x * 2.0)) / ((c * c) * (x * (s * (x * s))));
} else {
tmp = 1.0 / pow((c * (x * s)), 2.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) :: tmp
if (c <= (-1.15d+84)) then
tmp = 1.0d0 / ((s * (x * c)) ** 2.0d0)
else if (c <= (-2.75d-157)) then
tmp = cos((x * 2.0d0)) / ((c * c) * (x * (s * (x * s))))
else
tmp = 1.0d0 / ((c * (x * s)) ** 2.0d0)
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double tmp;
if (c <= -1.15e+84) {
tmp = 1.0 / Math.pow((s * (x * c)), 2.0);
} else if (c <= -2.75e-157) {
tmp = Math.cos((x * 2.0)) / ((c * c) * (x * (s * (x * s))));
} else {
tmp = 1.0 / Math.pow((c * (x * s)), 2.0);
}
return tmp;
}
def code(x, c, s): tmp = 0 if c <= -1.15e+84: tmp = 1.0 / math.pow((s * (x * c)), 2.0) elif c <= -2.75e-157: tmp = math.cos((x * 2.0)) / ((c * c) * (x * (s * (x * s)))) else: tmp = 1.0 / math.pow((c * (x * s)), 2.0) return tmp
function code(x, c, s) tmp = 0.0 if (c <= -1.15e+84) tmp = Float64(1.0 / (Float64(s * Float64(x * c)) ^ 2.0)); elseif (c <= -2.75e-157) tmp = Float64(cos(Float64(x * 2.0)) / Float64(Float64(c * c) * Float64(x * Float64(s * Float64(x * s))))); else tmp = Float64(1.0 / (Float64(c * Float64(x * s)) ^ 2.0)); end return tmp end
function tmp_2 = code(x, c, s) tmp = 0.0; if (c <= -1.15e+84) tmp = 1.0 / ((s * (x * c)) ^ 2.0); elseif (c <= -2.75e-157) tmp = cos((x * 2.0)) / ((c * c) * (x * (s * (x * s)))); else tmp = 1.0 / ((c * (x * s)) ^ 2.0); end tmp_2 = tmp; end
code[x_, c_, s_] := If[LessEqual[c, -1.15e+84], N[(1.0 / N[Power[N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -2.75e-157], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(N[(c * c), $MachinePrecision] * N[(x * N[(s * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.15 \cdot 10^{+84}:\\
\;\;\;\;\frac{1}{{\left(s \cdot \left(x \cdot c\right)\right)}^{2}}\\
\mathbf{elif}\;c \leq -2.75 \cdot 10^{-157}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot \left(x \cdot s\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}\\
\end{array}
\end{array}
if c < -1.1499999999999999e84Initial program 56.2%
*-commutative56.2%
associate-*r*55.9%
associate-*r*60.2%
unpow260.2%
unswap-sqr78.5%
unpow278.5%
swap-sqr96.4%
*-commutative96.4%
*-commutative96.4%
*-commutative96.4%
*-commutative96.4%
Simplified96.4%
Taylor expanded in x around 0 55.9%
unpow255.9%
unpow255.9%
unpow255.9%
Simplified55.9%
*-commutative55.9%
unswap-sqr67.7%
*-commutative67.7%
*-commutative67.7%
unpow267.7%
pow267.7%
pow-prod-down93.1%
*-commutative93.1%
associate-*r*94.2%
Applied egg-rr94.2%
if -1.1499999999999999e84 < c < -2.7499999999999999e-157Initial program 75.3%
unpow275.3%
*-commutative75.3%
unpow275.3%
Simplified75.3%
Taylor expanded in x around 0 75.3%
unpow275.3%
*-commutative75.3%
associate-*r*89.5%
*-commutative89.5%
Simplified89.5%
if -2.7499999999999999e-157 < c Initial program 63.7%
*-commutative63.7%
associate-*r*58.7%
associate-*r*58.6%
unpow258.6%
unswap-sqr76.1%
unpow276.1%
swap-sqr98.4%
*-commutative98.4%
*-commutative98.4%
*-commutative98.4%
*-commutative98.4%
Simplified98.4%
Taylor expanded in x around 0 53.1%
unpow253.1%
unpow253.1%
associate-*r*51.5%
*-commutative51.5%
associate-*r*53.1%
unpow253.1%
unpow253.1%
unpow253.1%
associate-/r*53.0%
associate-/r*53.0%
unpow253.0%
*-commutative53.0%
unpow253.0%
swap-sqr62.8%
unpow262.8%
associate-/l/70.6%
associate-/r*70.6%
*-commutative70.6%
associate-*r*62.8%
Simplified76.1%
Final simplification81.5%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* s (* x c)))) (* (/ (/ 1.0 t_0) t_0) (cos (* x 2.0)))))
double code(double x, double c, double s) {
double t_0 = s * (x * c);
return ((1.0 / t_0) / t_0) * cos((x * 2.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 = s * (x * c)
code = ((1.0d0 / t_0) / t_0) * cos((x * 2.0d0))
end function
public static double code(double x, double c, double s) {
double t_0 = s * (x * c);
return ((1.0 / t_0) / t_0) * Math.cos((x * 2.0));
}
def code(x, c, s): t_0 = s * (x * c) return ((1.0 / t_0) / t_0) * math.cos((x * 2.0))
function code(x, c, s) t_0 = Float64(s * Float64(x * c)) return Float64(Float64(Float64(1.0 / t_0) / t_0) * cos(Float64(x * 2.0))) end
function tmp = code(x, c, s) t_0 = s * (x * c); tmp = ((1.0 / t_0) / t_0) * cos((x * 2.0)); end
code[x_, c_, s_] := Block[{t$95$0 = N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision] * N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := s \cdot \left(x \cdot c\right)\\
\frac{\frac{1}{t_0}}{t_0} \cdot \cos \left(x \cdot 2\right)
\end{array}
\end{array}
Initial program 64.4%
*-commutative64.4%
associate-*r*59.8%
associate-*r*60.5%
unpow260.5%
unswap-sqr76.7%
unpow276.7%
swap-sqr97.5%
*-commutative97.5%
*-commutative97.5%
*-commutative97.5%
*-commutative97.5%
Simplified97.5%
div-inv97.6%
*-commutative97.6%
pow297.6%
pow-flip97.8%
metadata-eval97.8%
Applied egg-rr97.8%
metadata-eval97.8%
pow-prod-up97.7%
unpow-197.7%
unpow-197.7%
Applied egg-rr97.7%
un-div-inv97.8%
Applied egg-rr97.8%
Final simplification97.8%
(FPCore (x c s) :precision binary64 (/ (cos (* x 2.0)) (* (* s (* x c)) (* c (* x s)))))
double code(double x, double c, double s) {
return cos((x * 2.0)) / ((s * (x * c)) * (c * (x * s)));
}
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)) / ((s * (x * c)) * (c * (x * s)))
end function
public static double code(double x, double c, double s) {
return Math.cos((x * 2.0)) / ((s * (x * c)) * (c * (x * s)));
}
def code(x, c, s): return math.cos((x * 2.0)) / ((s * (x * c)) * (c * (x * s)))
function code(x, c, s) return Float64(cos(Float64(x * 2.0)) / Float64(Float64(s * Float64(x * c)) * Float64(c * Float64(x * s)))) end
function tmp = code(x, c, s) tmp = cos((x * 2.0)) / ((s * (x * c)) * (c * (x * s))); end
code[x_, c_, s_] := N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision] * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos \left(x \cdot 2\right)}{\left(s \cdot \left(x \cdot c\right)\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}
\end{array}
Initial program 64.4%
*-commutative64.4%
associate-*r*59.8%
associate-*r*60.5%
unpow260.5%
unswap-sqr76.7%
unpow276.7%
swap-sqr97.5%
*-commutative97.5%
*-commutative97.5%
*-commutative97.5%
*-commutative97.5%
Simplified97.5%
Taylor expanded in s around 0 95.5%
Final simplification95.5%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* s (* x c)))) (/ (cos (* x 2.0)) (* t_0 t_0))))
double code(double x, double c, double s) {
double t_0 = s * (x * c);
return cos((x * 2.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 = s * (x * c)
code = cos((x * 2.0d0)) / (t_0 * t_0)
end function
public static double code(double x, double c, double s) {
double t_0 = s * (x * c);
return Math.cos((x * 2.0)) / (t_0 * t_0);
}
def code(x, c, s): t_0 = s * (x * c) return math.cos((x * 2.0)) / (t_0 * t_0)
function code(x, c, s) t_0 = Float64(s * Float64(x * c)) return Float64(cos(Float64(x * 2.0)) / Float64(t_0 * t_0)) end
function tmp = code(x, c, s) t_0 = s * (x * c); tmp = cos((x * 2.0)) / (t_0 * t_0); end
code[x_, c_, s_] := Block[{t$95$0 = N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]}, N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := s \cdot \left(x \cdot c\right)\\
\frac{\cos \left(x \cdot 2\right)}{t_0 \cdot t_0}
\end{array}
\end{array}
Initial program 64.4%
*-commutative64.4%
associate-*r*59.8%
associate-*r*60.5%
unpow260.5%
unswap-sqr76.7%
unpow276.7%
swap-sqr97.5%
*-commutative97.5%
*-commutative97.5%
*-commutative97.5%
*-commutative97.5%
Simplified97.5%
Final simplification97.5%
(FPCore (x c s) :precision binary64 (/ 1.0 (pow (* c (* x s)) 2.0)))
double code(double x, double c, double s) {
return 1.0 / 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 = 1.0d0 / ((c * (x * s)) ** 2.0d0)
end function
public static double code(double x, double c, double s) {
return 1.0 / Math.pow((c * (x * s)), 2.0);
}
def code(x, c, s): return 1.0 / math.pow((c * (x * s)), 2.0)
function code(x, c, s) return Float64(1.0 / (Float64(c * Float64(x * s)) ^ 2.0)) end
function tmp = code(x, c, s) tmp = 1.0 / ((c * (x * s)) ^ 2.0); end
code[x_, c_, s_] := N[(1.0 / N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}
\end{array}
Initial program 64.4%
*-commutative64.4%
associate-*r*59.8%
associate-*r*60.5%
unpow260.5%
unswap-sqr76.7%
unpow276.7%
swap-sqr97.5%
*-commutative97.5%
*-commutative97.5%
*-commutative97.5%
*-commutative97.5%
Simplified97.5%
Taylor expanded in x around 0 54.9%
unpow254.9%
unpow254.9%
associate-*r*54.6%
*-commutative54.6%
associate-*r*55.7%
unpow255.7%
unpow255.7%
unpow255.7%
associate-/r*55.7%
associate-/r*55.7%
unpow255.7%
*-commutative55.7%
unpow255.7%
swap-sqr65.7%
unpow265.7%
associate-/l/73.8%
associate-/r*73.7%
*-commutative73.7%
associate-*r*65.7%
Simplified78.4%
Final simplification78.4%
(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 64.4%
associate-/r*64.3%
unpow264.3%
*-commutative64.3%
unpow264.3%
Simplified64.3%
Taylor expanded in x around 0 57.2%
unpow257.2%
Simplified57.2%
div-inv57.2%
inv-pow57.2%
inv-pow57.2%
associate-*r*54.9%
pow254.9%
pow254.9%
unpow-prod-down66.0%
*-commutative66.0%
unpow-prod-down66.1%
associate-*r*73.5%
inv-pow73.5%
add-sqr-sqrt73.4%
Applied egg-rr78.3%
Final simplification78.3%
(FPCore (x c s) :precision binary64 (/ 1.0 (* c (* c (* (* x s) (* x s))))))
double code(double x, double c, double s) {
return 1.0 / (c * (c * ((x * s) * (x * s))));
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = 1.0d0 / (c * (c * ((x * s) * (x * s))))
end function
public static double code(double x, double c, double s) {
return 1.0 / (c * (c * ((x * s) * (x * s))));
}
def code(x, c, s): return 1.0 / (c * (c * ((x * s) * (x * s))))
function code(x, c, s) return Float64(1.0 / Float64(c * Float64(c * Float64(Float64(x * s) * Float64(x * s))))) end
function tmp = code(x, c, s) tmp = 1.0 / (c * (c * ((x * s) * (x * s)))); end
code[x_, c_, s_] := N[(1.0 / N[(c * N[(c * N[(N[(x * s), $MachinePrecision] * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{c \cdot \left(c \cdot \left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)\right)}
\end{array}
Initial program 64.4%
*-commutative64.4%
associate-*r*59.8%
associate-*r*60.5%
unpow260.5%
unswap-sqr76.7%
unpow276.7%
swap-sqr97.5%
*-commutative97.5%
*-commutative97.5%
*-commutative97.5%
*-commutative97.5%
Simplified97.5%
Taylor expanded in x around 0 54.9%
unpow254.9%
unpow254.9%
unpow254.9%
Simplified54.9%
Taylor expanded in c around 0 55.7%
unpow255.7%
unpow255.7%
unpow255.7%
associate-*r*54.6%
*-commutative54.6%
associate-*r*54.9%
swap-sqr66.1%
unpow266.1%
associate-*r*73.5%
Simplified73.5%
unpow273.5%
Applied egg-rr73.5%
Final simplification73.5%
herbie shell --seed 2023194
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))