
(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}
(FPCore (x c s)
:precision binary64
(let* ((t_0 (cos (* x -2.0))))
(if (<=
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* x (* x (pow s 2.0)))))
INFINITY)
(* (/ (* (/ 1.0 x) (/ t_0 s)) c) (/ (/ 1.0 (* x s)) c))
(* (/ (/ t_0 x) (* c s)) (/ (/ 1.0 x) (* c s))))))
double code(double x, double c, double s) {
double t_0 = cos((x * -2.0));
double tmp;
if ((cos((2.0 * x)) / (pow(c, 2.0) * (x * (x * pow(s, 2.0))))) <= ((double) INFINITY)) {
tmp = (((1.0 / x) * (t_0 / s)) / c) * ((1.0 / (x * s)) / c);
} else {
tmp = ((t_0 / x) / (c * s)) * ((1.0 / x) / (c * s));
}
return tmp;
}
public static double code(double x, double c, double s) {
double t_0 = Math.cos((x * -2.0));
double tmp;
if ((Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * (x * (x * Math.pow(s, 2.0))))) <= Double.POSITIVE_INFINITY) {
tmp = (((1.0 / x) * (t_0 / s)) / c) * ((1.0 / (x * s)) / c);
} else {
tmp = ((t_0 / x) / (c * s)) * ((1.0 / x) / (c * s));
}
return tmp;
}
def code(x, c, s): t_0 = math.cos((x * -2.0)) tmp = 0 if (math.cos((2.0 * x)) / (math.pow(c, 2.0) * (x * (x * math.pow(s, 2.0))))) <= math.inf: tmp = (((1.0 / x) * (t_0 / s)) / c) * ((1.0 / (x * s)) / c) else: tmp = ((t_0 / x) / (c * s)) * ((1.0 / x) / (c * s)) return tmp
function code(x, c, s) t_0 = cos(Float64(x * -2.0)) tmp = 0.0 if (Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(x * Float64(x * (s ^ 2.0))))) <= Inf) tmp = Float64(Float64(Float64(Float64(1.0 / x) * Float64(t_0 / s)) / c) * Float64(Float64(1.0 / Float64(x * s)) / c)); else tmp = Float64(Float64(Float64(t_0 / x) / Float64(c * s)) * Float64(Float64(1.0 / x) / Float64(c * s))); end return tmp end
function tmp_2 = code(x, c, s) t_0 = cos((x * -2.0)); tmp = 0.0; if ((cos((2.0 * x)) / ((c ^ 2.0) * (x * (x * (s ^ 2.0))))) <= Inf) tmp = (((1.0 / x) * (t_0 / s)) / c) * ((1.0 / (x * s)) / c); else tmp = ((t_0 / x) / (c * s)) * ((1.0 / x) / (c * s)); end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[Cos[N[(x * -2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(x * N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / s), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision] * N[(N[(1.0 / N[(x * s), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t$95$0 / x), $MachinePrecision] / N[(c * s), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / x), $MachinePrecision] / N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(x \cdot -2\right)\\
\mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \leq \infty:\\
\;\;\;\;\frac{\frac{1}{x} \cdot \frac{t\_0}{s}}{c} \cdot \frac{\frac{1}{x \cdot s}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0}{x}}{c \cdot s} \cdot \frac{\frac{1}{x}}{c \cdot s}\\
\end{array}
\end{array}
if (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < +inf.0Initial program 78.3%
associate-/l/78.3%
remove-double-neg78.3%
distribute-frac-neg78.3%
distribute-neg-frac78.3%
remove-double-neg78.3%
*-commutative78.3%
associate-*r*72.4%
unpow272.4%
associate-/r*72.5%
cos-neg72.5%
*-commutative72.5%
distribute-rgt-neg-in72.5%
metadata-eval72.5%
Simplified72.5%
*-un-lft-identity72.5%
unpow272.5%
times-frac72.5%
add-sqr-sqrt38.7%
sqrt-unprod57.1%
*-commutative57.1%
*-commutative57.1%
swap-sqr57.1%
metadata-eval57.1%
metadata-eval57.1%
swap-sqr57.1%
sqrt-unprod30.9%
add-sqr-sqrt72.5%
Applied egg-rr72.5%
*-commutative72.5%
unpow272.5%
times-frac89.7%
add-sqr-sqrt37.4%
sqrt-unprod67.0%
*-commutative67.0%
*-commutative67.0%
swap-sqr67.0%
metadata-eval67.0%
metadata-eval67.0%
swap-sqr67.0%
sqrt-unprod47.6%
add-sqr-sqrt89.7%
Applied egg-rr89.7%
unpow289.7%
times-frac99.6%
associate-/l/99.6%
*-commutative99.6%
associate-/l/99.6%
*-commutative99.6%
Applied egg-rr99.6%
*-un-lft-identity99.6%
times-frac99.6%
Applied egg-rr99.6%
if +inf.0 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) Initial program 0.0%
associate-/l/0.0%
remove-double-neg0.0%
distribute-frac-neg0.0%
distribute-neg-frac0.0%
remove-double-neg0.0%
*-commutative0.0%
associate-*r*0.0%
unpow20.0%
associate-/r*0.0%
cos-neg0.0%
*-commutative0.0%
distribute-rgt-neg-in0.0%
metadata-eval0.0%
Simplified0.0%
*-un-lft-identity0.0%
unpow20.0%
times-frac0.0%
add-sqr-sqrt0.0%
sqrt-unprod0.0%
*-commutative0.0%
*-commutative0.0%
swap-sqr0.0%
metadata-eval0.0%
metadata-eval0.0%
swap-sqr0.0%
sqrt-unprod0.0%
add-sqr-sqrt0.0%
Applied egg-rr0.0%
associate-/l/0.5%
*-commutative0.5%
unpow-prod-down71.7%
unpow271.7%
times-frac99.3%
add-sqr-sqrt45.1%
sqrt-unprod67.4%
*-commutative67.4%
*-commutative67.4%
swap-sqr67.4%
metadata-eval67.4%
metadata-eval67.4%
swap-sqr67.4%
sqrt-unprod43.3%
add-sqr-sqrt99.3%
Applied egg-rr99.3%
Final simplification99.6%
(FPCore (x c s) :precision binary64 (* (/ (/ (cos (* x -2.0)) x) (* c s)) (/ (/ 1.0 x) (* c s))))
double code(double x, double c, double s) {
return ((cos((x * -2.0)) / x) / (c * s)) * ((1.0 / x) / (c * 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))) / x) / (c * s)) * ((1.0d0 / x) / (c * s))
end function
public static double code(double x, double c, double s) {
return ((Math.cos((x * -2.0)) / x) / (c * s)) * ((1.0 / x) / (c * s));
}
def code(x, c, s): return ((math.cos((x * -2.0)) / x) / (c * s)) * ((1.0 / x) / (c * s))
function code(x, c, s) return Float64(Float64(Float64(cos(Float64(x * -2.0)) / x) / Float64(c * s)) * Float64(Float64(1.0 / x) / Float64(c * s))) end
function tmp = code(x, c, s) tmp = ((cos((x * -2.0)) / x) / (c * s)) * ((1.0 / x) / (c * s)); end
code[x_, c_, s_] := N[(N[(N[(N[Cos[N[(x * -2.0), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision] / N[(c * s), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / x), $MachinePrecision] / N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\cos \left(x \cdot -2\right)}{x}}{c \cdot s} \cdot \frac{\frac{1}{x}}{c \cdot s}
\end{array}
Initial program 62.1%
associate-/l/62.1%
remove-double-neg62.1%
distribute-frac-neg62.1%
distribute-neg-frac62.1%
remove-double-neg62.1%
*-commutative62.1%
associate-*r*57.4%
unpow257.4%
associate-/r*57.5%
cos-neg57.5%
*-commutative57.5%
distribute-rgt-neg-in57.5%
metadata-eval57.5%
Simplified57.5%
*-un-lft-identity57.5%
unpow257.5%
times-frac57.5%
add-sqr-sqrt30.7%
sqrt-unprod45.3%
*-commutative45.3%
*-commutative45.3%
swap-sqr45.3%
metadata-eval45.3%
metadata-eval45.3%
swap-sqr45.3%
sqrt-unprod24.5%
add-sqr-sqrt57.5%
Applied egg-rr57.5%
associate-/l/57.5%
*-commutative57.5%
unpow-prod-down77.3%
unpow277.3%
times-frac97.3%
add-sqr-sqrt41.5%
sqrt-unprod72.2%
*-commutative72.2%
*-commutative72.2%
swap-sqr72.2%
metadata-eval72.2%
metadata-eval72.2%
swap-sqr72.2%
sqrt-unprod49.1%
add-sqr-sqrt97.3%
Applied egg-rr97.3%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* c (* x s)))) (* (/ 1.0 t_0) (/ (cos (* x -2.0)) t_0))))
double code(double x, double c, double s) {
double t_0 = c * (x * s);
return (1.0 / t_0) * (cos((x * -2.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) * (cos((x * (-2.0d0))) / 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) * (Math.cos((x * -2.0)) / t_0);
}
def code(x, c, s): t_0 = c * (x * s) return (1.0 / t_0) * (math.cos((x * -2.0)) / t_0)
function code(x, c, s) t_0 = Float64(c * Float64(x * s)) return Float64(Float64(1.0 / t_0) * Float64(cos(Float64(x * -2.0)) / t_0)) end
function tmp = code(x, c, s) t_0 = c * (x * s); tmp = (1.0 / t_0) * (cos((x * -2.0)) / t_0); end
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(N[Cos[N[(x * -2.0), $MachinePrecision]], $MachinePrecision] / 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 \frac{\cos \left(x \cdot -2\right)}{t\_0}
\end{array}
\end{array}
Initial program 62.1%
associate-/l/62.1%
remove-double-neg62.1%
distribute-frac-neg62.1%
distribute-neg-frac62.1%
remove-double-neg62.1%
*-commutative62.1%
associate-*r*57.4%
unpow257.4%
associate-/r*57.5%
cos-neg57.5%
*-commutative57.5%
distribute-rgt-neg-in57.5%
metadata-eval57.5%
Simplified57.5%
Taylor expanded in x around inf 57.4%
associate-/r*57.0%
unpow257.0%
unpow257.0%
swap-sqr73.0%
unpow273.0%
associate-/r*73.3%
*-commutative73.3%
unpow273.3%
rem-square-sqrt73.3%
swap-sqr85.3%
unpow285.3%
unpow285.3%
rem-sqrt-square96.2%
Simplified96.2%
*-un-lft-identity96.2%
unpow296.2%
times-frac96.6%
add-sqr-sqrt59.9%
fabs-sqr59.9%
add-sqr-sqrt69.6%
add-sqr-sqrt56.4%
fabs-sqr56.4%
add-sqr-sqrt96.6%
Applied egg-rr96.6%
Final simplification96.6%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* c (* x s)))) (/ (cos (* x -2.0)) (* t_0 t_0))))
double code(double x, double c, double s) {
double t_0 = c * (x * s);
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 = c * (x * s)
code = cos((x * (-2.0d0))) / (t_0 * t_0)
end function
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);
}
def code(x, c, s): t_0 = c * (x * s) return math.cos((x * -2.0)) / (t_0 * t_0)
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
function tmp = code(x, c, s) t_0 = c * (x * s); tmp = cos((x * -2.0)) / (t_0 * t_0); end
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}
\\
\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 62.1%
associate-/l/62.1%
remove-double-neg62.1%
distribute-frac-neg62.1%
distribute-neg-frac62.1%
remove-double-neg62.1%
*-commutative62.1%
associate-*r*57.4%
unpow257.4%
associate-/r*57.5%
cos-neg57.5%
*-commutative57.5%
distribute-rgt-neg-in57.5%
metadata-eval57.5%
Simplified57.5%
Taylor expanded in x around inf 57.4%
associate-/r*57.0%
unpow257.0%
unpow257.0%
swap-sqr73.0%
unpow273.0%
associate-/r*73.3%
*-commutative73.3%
unpow273.3%
rem-square-sqrt73.3%
swap-sqr85.3%
unpow285.3%
unpow285.3%
rem-sqrt-square96.2%
Simplified96.2%
unpow-prod-down73.3%
unpow273.3%
pow273.3%
sqr-abs73.3%
swap-sqr96.2%
Applied egg-rr96.2%
Final simplification96.2%
(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 62.1%
associate-/l/62.1%
remove-double-neg62.1%
distribute-frac-neg62.1%
distribute-neg-frac62.1%
remove-double-neg62.1%
*-commutative62.1%
associate-*r*57.4%
unpow257.4%
associate-/r*57.5%
cos-neg57.5%
*-commutative57.5%
distribute-rgt-neg-in57.5%
metadata-eval57.5%
Simplified57.5%
Taylor expanded in x around inf 57.4%
associate-/r*57.0%
unpow257.0%
unpow257.0%
swap-sqr73.0%
unpow273.0%
associate-/r*73.3%
*-commutative73.3%
unpow273.3%
rem-square-sqrt73.3%
swap-sqr85.3%
unpow285.3%
unpow285.3%
rem-sqrt-square96.2%
Simplified96.2%
Taylor expanded in x around 0 63.7%
associate-/r*63.5%
unpow263.5%
sqr-abs63.5%
unpow263.5%
associate-/r*63.7%
unpow263.7%
unpow263.7%
swap-sqr79.8%
unpow279.8%
unpow-179.8%
exp-to-pow47.3%
*-commutative47.3%
exp-prod47.5%
*-commutative47.5%
associate-*l*47.5%
metadata-eval47.5%
exp-to-pow80.1%
Simplified80.1%
Final simplification80.1%
(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(Float64(1.0 / 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[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\frac{\frac{1}{t\_0}}{t\_0}
\end{array}
\end{array}
Initial program 62.1%
Taylor expanded in x around 0 52.8%
associate-/r*52.4%
unpow252.4%
unpow252.4%
swap-sqr63.5%
unpow263.5%
associate-/r*63.7%
unpow263.7%
rem-square-sqrt63.7%
swap-sqr73.2%
unpow273.2%
unpow273.2%
rem-sqrt-square79.8%
Simplified79.8%
unpow-prod-down73.3%
unpow273.3%
pow273.3%
sqr-abs73.3%
swap-sqr96.2%
Applied egg-rr79.8%
metadata-eval79.8%
frac-times80.0%
associate-*r*78.7%
associate-/l/78.7%
associate-*r*80.2%
associate-/l/80.2%
associate-*r/77.6%
times-frac75.2%
associate-/l/75.2%
associate-*r*76.2%
*-commutative76.2%
associate-/l/76.2%
*-commutative76.2%
Applied egg-rr76.2%
*-commutative76.2%
frac-times80.1%
*-un-lft-identity80.1%
*-commutative80.1%
Applied egg-rr80.1%
Final simplification80.1%
(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 62.1%
Taylor expanded in x around 0 52.8%
associate-/r*52.4%
unpow252.4%
unpow252.4%
swap-sqr63.5%
unpow263.5%
associate-/r*63.7%
unpow263.7%
rem-square-sqrt63.7%
swap-sqr73.2%
unpow273.2%
unpow273.2%
rem-sqrt-square79.8%
Simplified79.8%
unpow-prod-down73.3%
unpow273.3%
pow273.3%
sqr-abs73.3%
swap-sqr96.2%
Applied egg-rr79.8%
Final simplification79.8%
herbie shell --seed 2024103
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))