
(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 8 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 (* 2.0 x))))
(if (<= (/ t_0 (* (pow c 2.0) (* x (* x (pow s 2.0))))) INFINITY)
(* (pow (* c (* x s)) -2.0) t_0)
(* t_0 (pow (* x (* c s)) -2.0)))))
double code(double x, double c, double s) {
double t_0 = cos((2.0 * x));
double tmp;
if ((t_0 / (pow(c, 2.0) * (x * (x * pow(s, 2.0))))) <= ((double) INFINITY)) {
tmp = pow((c * (x * s)), -2.0) * t_0;
} else {
tmp = t_0 * pow((x * (c * s)), -2.0);
}
return tmp;
}
public static double code(double x, double c, double s) {
double t_0 = Math.cos((2.0 * x));
double tmp;
if ((t_0 / (Math.pow(c, 2.0) * (x * (x * Math.pow(s, 2.0))))) <= Double.POSITIVE_INFINITY) {
tmp = Math.pow((c * (x * s)), -2.0) * t_0;
} else {
tmp = t_0 * Math.pow((x * (c * s)), -2.0);
}
return tmp;
}
def code(x, c, s): t_0 = math.cos((2.0 * x)) tmp = 0 if (t_0 / (math.pow(c, 2.0) * (x * (x * math.pow(s, 2.0))))) <= math.inf: tmp = math.pow((c * (x * s)), -2.0) * t_0 else: tmp = t_0 * math.pow((x * (c * s)), -2.0) return tmp
function code(x, c, s) t_0 = cos(Float64(2.0 * x)) tmp = 0.0 if (Float64(t_0 / Float64((c ^ 2.0) * Float64(x * Float64(x * (s ^ 2.0))))) <= Inf) tmp = Float64((Float64(c * Float64(x * s)) ^ -2.0) * t_0); else tmp = Float64(t_0 * (Float64(x * Float64(c * s)) ^ -2.0)); end return tmp end
function tmp_2 = code(x, c, s) t_0 = cos((2.0 * x)); tmp = 0.0; if ((t_0 / ((c ^ 2.0) * (x * (x * (s ^ 2.0))))) <= Inf) tmp = ((c * (x * s)) ^ -2.0) * t_0; else tmp = t_0 * ((x * (c * s)) ^ -2.0); end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[Power[c, 2.0], $MachinePrecision] * N[(x * N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision] * t$95$0), $MachinePrecision], N[(t$95$0 * N[Power[N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(2 \cdot x\right)\\
\mathbf{if}\;\frac{t\_0}{{c}^{2} \cdot \left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \leq \infty:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot {\left(x \cdot \left(c \cdot s\right)\right)}^{-2}\\
\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 81.6%
associate-/r*81.6%
*-commutative81.6%
unpow281.6%
sqr-neg81.6%
unpow281.6%
cos-neg81.6%
*-commutative81.6%
distribute-rgt-neg-in81.6%
metadata-eval81.6%
unpow281.6%
sqr-neg81.6%
unpow281.6%
associate-*r*72.6%
unpow272.6%
*-commutative72.6%
Simplified72.6%
associate-/l/72.6%
add-sqr-sqrt57.2%
add-sqr-sqrt72.6%
add-sqr-sqrt26.6%
sqrt-unprod57.8%
swap-sqr57.8%
metadata-eval57.8%
metadata-eval57.8%
swap-sqr57.8%
*-commutative57.8%
*-commutative57.8%
sqrt-unprod40.6%
add-sqr-sqrt72.6%
*-un-lft-identity72.6%
*-commutative72.6%
unpow272.6%
associate-*r*81.6%
associate-*l*83.3%
*-commutative83.3%
*-commutative83.3%
Applied egg-rr83.8%
Taylor expanded in c around 0 72.6%
*-commutative72.6%
associate-*r*71.5%
unpow271.5%
unpow271.5%
swap-sqr74.8%
unpow274.8%
*-commutative74.8%
unpow274.8%
associate-*r*83.8%
*-commutative83.8%
*-lft-identity83.8%
associate-*l/83.8%
Simplified99.7%
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-/r*0.0%
*-commutative0.0%
unpow20.0%
sqr-neg0.0%
unpow20.0%
cos-neg0.0%
*-commutative0.0%
distribute-rgt-neg-in0.0%
metadata-eval0.0%
unpow20.0%
sqr-neg0.0%
unpow20.0%
associate-*r*0.0%
unpow20.0%
*-commutative0.0%
Simplified0.0%
associate-/l/0.0%
add-sqr-sqrt0.0%
add-sqr-sqrt0.0%
add-sqr-sqrt0.0%
sqrt-unprod0.0%
swap-sqr0.0%
metadata-eval0.0%
metadata-eval0.0%
swap-sqr0.0%
*-commutative0.0%
*-commutative0.0%
sqrt-unprod0.0%
add-sqr-sqrt0.0%
*-un-lft-identity0.0%
*-commutative0.0%
unpow20.0%
associate-*r*0.0%
associate-*l*0.2%
*-commutative0.2%
*-commutative0.2%
Applied egg-rr80.6%
Taylor expanded in c around 0 0.0%
*-commutative0.0%
associate-*r*0.3%
unpow20.3%
unpow20.3%
swap-sqr67.5%
unpow267.5%
*-commutative67.5%
unpow267.5%
associate-*r*80.2%
*-commutative80.2%
*-lft-identity80.2%
associate-*l/80.2%
Simplified79.6%
*-un-lft-identity79.6%
Applied egg-rr79.6%
*-lft-identity79.6%
associate-*r*97.5%
*-commutative97.5%
Simplified97.5%
Final simplification99.3%
(FPCore (x c s) :precision binary64 (if (<= x 2e-8) (pow (* c (* x s)) -2.0) (/ (/ (cos (* 2.0 x)) c) (* (* x (* c s)) (* x s)))))
double code(double x, double c, double s) {
double tmp;
if (x <= 2e-8) {
tmp = pow((c * (x * s)), -2.0);
} else {
tmp = (cos((2.0 * x)) / c) / ((x * (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) :: tmp
if (x <= 2d-8) then
tmp = (c * (x * s)) ** (-2.0d0)
else
tmp = (cos((2.0d0 * x)) / c) / ((x * (c * s)) * (x * s))
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double tmp;
if (x <= 2e-8) {
tmp = Math.pow((c * (x * s)), -2.0);
} else {
tmp = (Math.cos((2.0 * x)) / c) / ((x * (c * s)) * (x * s));
}
return tmp;
}
def code(x, c, s): tmp = 0 if x <= 2e-8: tmp = math.pow((c * (x * s)), -2.0) else: tmp = (math.cos((2.0 * x)) / c) / ((x * (c * s)) * (x * s)) return tmp
function code(x, c, s) tmp = 0.0 if (x <= 2e-8) tmp = Float64(c * Float64(x * s)) ^ -2.0; else tmp = Float64(Float64(cos(Float64(2.0 * x)) / c) / Float64(Float64(x * Float64(c * s)) * Float64(x * s))); end return tmp end
function tmp_2 = code(x, c, s) tmp = 0.0; if (x <= 2e-8) tmp = (c * (x * s)) ^ -2.0; else tmp = (cos((2.0 * x)) / c) / ((x * (c * s)) * (x * s)); end tmp_2 = tmp; end
code[x_, c_, s_] := If[LessEqual[x, 2e-8], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / c), $MachinePrecision] / N[(N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision] * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2 \cdot 10^{-8}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(2 \cdot x\right)}{c}}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot s\right)}\\
\end{array}
\end{array}
if x < 2e-8Initial program 63.9%
associate-/r*63.9%
*-commutative63.9%
unpow263.9%
sqr-neg63.9%
unpow263.9%
cos-neg63.9%
*-commutative63.9%
distribute-rgt-neg-in63.9%
metadata-eval63.9%
unpow263.9%
sqr-neg63.9%
unpow263.9%
associate-*r*56.7%
unpow256.7%
*-commutative56.7%
Simplified56.7%
Taylor expanded in x around 0 52.4%
associate-/r*52.4%
*-commutative52.4%
unpow252.4%
unpow252.4%
swap-sqr67.7%
unpow267.7%
associate-/r*67.7%
unpow267.7%
unpow267.7%
swap-sqr82.4%
unpow282.4%
Simplified82.4%
Taylor expanded in c around 0 52.4%
unpow252.4%
*-commutative52.4%
unpow252.4%
unpow252.4%
swap-sqr67.7%
swap-sqr82.4%
associate-*l*79.8%
associate-*l*82.2%
associate-/l/82.4%
*-lft-identity82.4%
associate-*l/82.4%
unpow-182.4%
unpow-182.4%
pow-sqr82.4%
associate-*l*82.7%
*-commutative82.7%
metadata-eval82.7%
Simplified82.7%
if 2e-8 < x Initial program 67.9%
associate-/r*68.0%
*-commutative68.0%
unpow268.0%
sqr-neg68.0%
unpow268.0%
cos-neg68.0%
*-commutative68.0%
distribute-rgt-neg-in68.0%
metadata-eval68.0%
unpow268.0%
sqr-neg68.0%
unpow268.0%
associate-*r*60.8%
unpow260.8%
*-commutative60.8%
Simplified60.8%
associate-/l/60.8%
add-sqr-sqrt32.3%
add-sqr-sqrt60.8%
add-sqr-sqrt0.0%
sqrt-unprod31.2%
swap-sqr31.2%
metadata-eval31.2%
metadata-eval31.2%
swap-sqr31.2%
*-commutative31.2%
*-commutative31.2%
sqrt-unprod57.2%
add-sqr-sqrt60.8%
*-un-lft-identity60.8%
*-commutative60.8%
unpow260.8%
associate-*r*67.9%
associate-*l*69.4%
*-commutative69.4%
*-commutative69.4%
Applied egg-rr80.9%
Taylor expanded in c around 0 60.8%
*-commutative60.8%
associate-*r*58.1%
unpow258.1%
unpow258.1%
swap-sqr71.7%
unpow271.7%
*-commutative71.7%
unpow271.7%
associate-*r*80.5%
*-commutative80.5%
*-lft-identity80.5%
associate-*l/80.5%
Simplified95.6%
*-un-lft-identity95.6%
Applied egg-rr95.6%
*-lft-identity95.6%
associate-*r*99.7%
*-commutative99.7%
Simplified99.7%
*-commutative99.7%
associate-*r*95.6%
*-commutative95.6%
associate-*r*98.1%
metadata-eval98.1%
pow-prod-up98.1%
inv-pow98.1%
inv-pow98.1%
associate-*l*98.0%
associate-*l/98.0%
associate-*r*94.0%
frac-times94.0%
associate-*r/94.0%
frac-times91.4%
Applied egg-rr92.9%
Final simplification85.5%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* x (* c s)))) (/ (/ (cos (* 2.0 x)) t_0) t_0)))
double code(double x, double c, double s) {
double t_0 = x * (c * s);
return (cos((2.0 * x)) / 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 = x * (c * s)
code = (cos((2.0d0 * x)) / t_0) / t_0
end function
public static double code(double x, double c, double s) {
double t_0 = x * (c * s);
return (Math.cos((2.0 * x)) / t_0) / t_0;
}
def code(x, c, s): t_0 = x * (c * s) return (math.cos((2.0 * x)) / t_0) / t_0
function code(x, c, s) t_0 = Float64(x * Float64(c * s)) return Float64(Float64(cos(Float64(2.0 * x)) / t_0) / t_0) end
function tmp = code(x, c, s) t_0 = x * (c * s); tmp = (cos((2.0 * x)) / t_0) / t_0; end
code[x_, c_, s_] := Block[{t$95$0 = N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(c \cdot s\right)\\
\frac{\frac{\cos \left(2 \cdot x\right)}{t\_0}}{t\_0}
\end{array}
\end{array}
Initial program 65.0%
associate-/r*65.0%
*-commutative65.0%
unpow265.0%
sqr-neg65.0%
unpow265.0%
cos-neg65.0%
*-commutative65.0%
distribute-rgt-neg-in65.0%
metadata-eval65.0%
unpow265.0%
sqr-neg65.0%
unpow265.0%
associate-*r*57.8%
unpow257.8%
*-commutative57.8%
Simplified57.8%
associate-/l/57.8%
add-sqr-sqrt45.6%
add-sqr-sqrt57.8%
add-sqr-sqrt21.2%
sqrt-unprod46.1%
swap-sqr46.1%
metadata-eval46.1%
metadata-eval46.1%
swap-sqr46.1%
*-commutative46.1%
*-commutative46.1%
sqrt-unprod32.3%
add-sqr-sqrt57.8%
*-un-lft-identity57.8%
*-commutative57.8%
unpow257.8%
associate-*r*65.0%
associate-*l*66.4%
*-commutative66.4%
*-commutative66.4%
Applied egg-rr83.2%
Taylor expanded in c around 0 57.8%
*-commutative57.8%
associate-*r*57.0%
unpow257.0%
unpow257.0%
swap-sqr73.3%
unpow273.3%
*-commutative73.3%
unpow273.3%
associate-*r*83.1%
*-commutative83.1%
*-lft-identity83.1%
associate-*l/83.0%
Simplified95.6%
*-un-lft-identity95.6%
Applied egg-rr95.6%
*-lft-identity95.6%
associate-*r*97.6%
*-commutative97.6%
Simplified97.6%
*-commutative97.6%
associate-*r*95.6%
*-commutative95.6%
associate-*r*96.6%
metadata-eval96.6%
pow-prod-up96.5%
inv-pow96.5%
inv-pow96.5%
un-div-inv96.6%
associate-*l/96.6%
associate-*r*93.0%
*-commutative93.0%
Applied egg-rr97.6%
Final simplification97.6%
(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 65.0%
associate-/r*65.0%
*-commutative65.0%
unpow265.0%
sqr-neg65.0%
unpow265.0%
cos-neg65.0%
*-commutative65.0%
distribute-rgt-neg-in65.0%
metadata-eval65.0%
unpow265.0%
sqr-neg65.0%
unpow265.0%
associate-*r*57.8%
unpow257.8%
*-commutative57.8%
Simplified57.8%
Taylor expanded in x around 0 52.3%
associate-/r*52.3%
*-commutative52.3%
unpow252.3%
unpow252.3%
swap-sqr65.8%
unpow265.8%
associate-/r*65.8%
unpow265.8%
unpow265.8%
swap-sqr77.8%
unpow277.8%
Simplified77.8%
Taylor expanded in c around 0 52.3%
unpow252.3%
*-commutative52.3%
unpow252.3%
unpow252.3%
swap-sqr65.8%
swap-sqr77.8%
associate-*l*75.8%
associate-*l*77.7%
associate-/l/77.8%
*-lft-identity77.8%
associate-*l/77.8%
unpow-177.8%
unpow-177.8%
pow-sqr77.9%
associate-*l*77.9%
*-commutative77.9%
metadata-eval77.9%
Simplified77.9%
Final simplification77.9%
(FPCore (x c s) :precision binary64 (* (/ 1.0 (* c (* x s))) (* (/ 1.0 c) (/ (/ 1.0 s) x))))
double code(double x, double c, double s) {
return (1.0 / (c * (x * s))) * ((1.0 / c) * ((1.0 / s) / x));
}
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) * ((1.0d0 / s) / x))
end function
public static double code(double x, double c, double s) {
return (1.0 / (c * (x * s))) * ((1.0 / c) * ((1.0 / s) / x));
}
def code(x, c, s): return (1.0 / (c * (x * s))) * ((1.0 / c) * ((1.0 / s) / x))
function code(x, c, s) return Float64(Float64(1.0 / Float64(c * Float64(x * s))) * Float64(Float64(1.0 / c) * Float64(Float64(1.0 / s) / x))) end
function tmp = code(x, c, s) tmp = (1.0 / (c * (x * s))) * ((1.0 / c) * ((1.0 / s) / x)); end
code[x_, c_, s_] := N[(N[(1.0 / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / c), $MachinePrecision] * N[(N[(1.0 / s), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \left(\frac{1}{c} \cdot \frac{\frac{1}{s}}{x}\right)
\end{array}
Initial program 65.0%
associate-/r*65.0%
*-commutative65.0%
unpow265.0%
sqr-neg65.0%
unpow265.0%
cos-neg65.0%
*-commutative65.0%
distribute-rgt-neg-in65.0%
metadata-eval65.0%
unpow265.0%
sqr-neg65.0%
unpow265.0%
associate-*r*57.8%
unpow257.8%
*-commutative57.8%
Simplified57.8%
Applied egg-rr95.5%
*-un-lft-identity95.5%
times-frac95.6%
*-commutative95.6%
Applied egg-rr95.6%
Taylor expanded in x around 0 77.9%
associate-/r*77.9%
Simplified77.9%
(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 65.0%
associate-/r*65.0%
*-commutative65.0%
unpow265.0%
sqr-neg65.0%
unpow265.0%
cos-neg65.0%
*-commutative65.0%
distribute-rgt-neg-in65.0%
metadata-eval65.0%
unpow265.0%
sqr-neg65.0%
unpow265.0%
associate-*r*57.8%
unpow257.8%
*-commutative57.8%
Simplified57.8%
Applied egg-rr95.5%
Taylor expanded in x around 0 77.9%
(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 65.0%
associate-/r*65.0%
*-commutative65.0%
unpow265.0%
sqr-neg65.0%
unpow265.0%
cos-neg65.0%
*-commutative65.0%
distribute-rgt-neg-in65.0%
metadata-eval65.0%
unpow265.0%
sqr-neg65.0%
unpow265.0%
associate-*r*57.8%
unpow257.8%
*-commutative57.8%
Simplified57.8%
associate-/l/57.8%
add-sqr-sqrt45.6%
add-sqr-sqrt57.8%
add-sqr-sqrt21.2%
sqrt-unprod46.1%
swap-sqr46.1%
metadata-eval46.1%
metadata-eval46.1%
swap-sqr46.1%
*-commutative46.1%
*-commutative46.1%
sqrt-unprod32.3%
add-sqr-sqrt57.8%
*-un-lft-identity57.8%
*-commutative57.8%
unpow257.8%
associate-*r*65.0%
associate-*l*66.4%
*-commutative66.4%
*-commutative66.4%
Applied egg-rr83.2%
Taylor expanded in c around 0 57.8%
*-commutative57.8%
associate-*r*57.0%
unpow257.0%
unpow257.0%
swap-sqr73.3%
unpow273.3%
*-commutative73.3%
unpow273.3%
associate-*r*83.1%
*-commutative83.1%
*-lft-identity83.1%
associate-*l/83.0%
Simplified95.6%
*-commutative95.6%
associate-*l*96.6%
metadata-eval96.6%
pow-flip96.3%
pow296.3%
associate-/r*96.6%
associate-*l*93.0%
*-commutative93.0%
associate-*l*95.6%
*-commutative95.6%
Applied egg-rr95.6%
Taylor expanded in x around 0 77.9%
Final simplification77.9%
(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 65.0%
associate-/r*65.0%
*-commutative65.0%
unpow265.0%
sqr-neg65.0%
unpow265.0%
cos-neg65.0%
*-commutative65.0%
distribute-rgt-neg-in65.0%
metadata-eval65.0%
unpow265.0%
sqr-neg65.0%
unpow265.0%
associate-*r*57.8%
unpow257.8%
*-commutative57.8%
Simplified57.8%
Taylor expanded in x around 0 52.3%
associate-/r*52.3%
*-commutative52.3%
unpow252.3%
unpow252.3%
swap-sqr65.8%
unpow265.8%
associate-/r*65.8%
unpow265.8%
unpow265.8%
swap-sqr77.8%
unpow277.8%
Simplified77.8%
unpow277.8%
associate-*r*75.8%
associate-*r*77.7%
Applied egg-rr77.7%
Taylor expanded in c around 0 75.8%
*-commutative75.8%
Simplified75.8%
Taylor expanded in c around 0 77.8%
*-commutative75.8%
Simplified77.8%
herbie shell --seed 2024160
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))