
(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 (let* ((t_0 (* x (* s c)))) (* (/ 1.0 t_0) (/ (cos (* x 2.0)) t_0))))
double code(double x, double c, double s) {
double t_0 = x * (s * c);
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 = x * (s * c)
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 = x * (s * c);
return (1.0 / t_0) * (Math.cos((x * 2.0)) / t_0);
}
def code(x, c, s): t_0 = x * (s * c) return (1.0 / t_0) * (math.cos((x * 2.0)) / t_0)
function code(x, c, s) t_0 = Float64(x * Float64(s * c)) return Float64(Float64(1.0 / t_0) * Float64(cos(Float64(x * 2.0)) / t_0)) end
function tmp = code(x, c, s) t_0 = x * (s * c); tmp = (1.0 / t_0) * (cos((x * 2.0)) / t_0); end
code[x_, c_, s_] := Block[{t$95$0 = N[(x * N[(s * c), $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 := x \cdot \left(s \cdot c\right)\\
\frac{1}{t\_0} \cdot \frac{\cos \left(x \cdot 2\right)}{t\_0}
\end{array}
\end{array}
Initial program 65.8%
Taylor expanded in x around inf 58.7%
associate-/r*58.7%
*-commutative58.7%
unpow258.7%
unpow258.7%
swap-sqr77.1%
unpow277.1%
associate-/r*77.7%
unpow277.7%
unpow277.7%
swap-sqr97.4%
unpow297.4%
*-commutative97.4%
Simplified97.4%
*-commutative97.4%
unpow297.4%
*-un-lft-identity97.4%
times-frac97.4%
*-commutative97.4%
associate-*l*95.9%
*-commutative95.9%
*-commutative95.9%
associate-*l*98.1%
Applied egg-rr98.1%
(FPCore (x c s) :precision binary64 (if (<= x 5.1e-14) (pow (/ 1.0 (* c (* x s))) 2.0) (/ (cos (* x 2.0)) (* s (* (* x (* s c)) (* x c))))))
double code(double x, double c, double s) {
double tmp;
if (x <= 5.1e-14) {
tmp = pow((1.0 / (c * (x * s))), 2.0);
} else {
tmp = cos((x * 2.0)) / (s * ((x * (s * c)) * (x * 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.1d-14) then
tmp = (1.0d0 / (c * (x * s))) ** 2.0d0
else
tmp = cos((x * 2.0d0)) / (s * ((x * (s * c)) * (x * c)))
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double tmp;
if (x <= 5.1e-14) {
tmp = Math.pow((1.0 / (c * (x * s))), 2.0);
} else {
tmp = Math.cos((x * 2.0)) / (s * ((x * (s * c)) * (x * c)));
}
return tmp;
}
def code(x, c, s): tmp = 0 if x <= 5.1e-14: tmp = math.pow((1.0 / (c * (x * s))), 2.0) else: tmp = math.cos((x * 2.0)) / (s * ((x * (s * c)) * (x * c))) return tmp
function code(x, c, s) tmp = 0.0 if (x <= 5.1e-14) tmp = Float64(1.0 / Float64(c * Float64(x * s))) ^ 2.0; else tmp = Float64(cos(Float64(x * 2.0)) / Float64(s * Float64(Float64(x * Float64(s * c)) * Float64(x * c)))); end return tmp end
function tmp_2 = code(x, c, s) tmp = 0.0; if (x <= 5.1e-14) tmp = (1.0 / (c * (x * s))) ^ 2.0; else tmp = cos((x * 2.0)) / (s * ((x * (s * c)) * (x * c))); end tmp_2 = tmp; end
code[x_, c_, s_] := If[LessEqual[x, 5.1e-14], N[Power[N[(1.0 / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(s * N[(N[(x * N[(s * c), $MachinePrecision]), $MachinePrecision] * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.1 \cdot 10^{-14}:\\
\;\;\;\;{\left(\frac{1}{c \cdot \left(x \cdot s\right)}\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{s \cdot \left(\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(x \cdot c\right)\right)}\\
\end{array}
\end{array}
if x < 5.0999999999999997e-14Initial program 65.3%
associate-/r*65.3%
*-commutative65.3%
unpow265.3%
sqr-neg65.3%
unpow265.3%
cos-neg65.3%
*-commutative65.3%
distribute-rgt-neg-in65.3%
metadata-eval65.3%
unpow265.3%
sqr-neg65.3%
unpow265.3%
associate-*r*58.1%
unpow258.1%
*-commutative58.1%
Simplified58.1%
Taylor expanded in x around 0 53.1%
associate-/r*53.1%
*-commutative53.1%
unpow253.1%
unpow253.1%
swap-sqr71.0%
unpow271.0%
associate-/r*71.4%
unpow271.4%
unpow271.4%
swap-sqr84.3%
unpow284.3%
Simplified84.3%
add-sqr-sqrt84.2%
sqrt-div84.3%
metadata-eval84.3%
sqrt-pow163.5%
metadata-eval63.5%
pow163.5%
*-commutative63.5%
associate-*l*63.4%
sqrt-div63.5%
metadata-eval63.5%
sqrt-pow183.8%
metadata-eval83.8%
pow183.8%
*-commutative83.8%
associate-*l*85.2%
Applied egg-rr85.2%
unpow285.2%
*-commutative85.2%
*-commutative85.2%
associate-*r*84.3%
Simplified84.3%
if 5.0999999999999997e-14 < x Initial program 67.2%
Taylor expanded in x around inf 60.3%
associate-/r*60.3%
*-commutative60.3%
unpow260.3%
unpow260.3%
swap-sqr70.4%
unpow270.4%
associate-/r*71.5%
unpow271.5%
unpow271.5%
swap-sqr98.3%
unpow298.3%
*-commutative98.3%
Simplified98.3%
unpow298.3%
associate-*r*94.3%
associate-*r*85.0%
*-commutative85.0%
associate-*l*85.0%
*-commutative85.0%
Applied egg-rr85.0%
Final simplification84.5%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* c (* x s)))) (if (<= x 3e-25) (pow t_0 -2.0) (/ (cos (* x 2.0)) (* (* x c) (* s t_0))))))
double code(double x, double c, double s) {
double t_0 = c * (x * s);
double tmp;
if (x <= 3e-25) {
tmp = pow(t_0, -2.0);
} else {
tmp = cos((x * 2.0)) / ((x * c) * (s * 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) :: tmp
t_0 = c * (x * s)
if (x <= 3d-25) then
tmp = t_0 ** (-2.0d0)
else
tmp = cos((x * 2.0d0)) / ((x * c) * (s * 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 tmp;
if (x <= 3e-25) {
tmp = Math.pow(t_0, -2.0);
} else {
tmp = Math.cos((x * 2.0)) / ((x * c) * (s * t_0));
}
return tmp;
}
def code(x, c, s): t_0 = c * (x * s) tmp = 0 if x <= 3e-25: tmp = math.pow(t_0, -2.0) else: tmp = math.cos((x * 2.0)) / ((x * c) * (s * t_0)) return tmp
function code(x, c, s) t_0 = Float64(c * Float64(x * s)) tmp = 0.0 if (x <= 3e-25) tmp = t_0 ^ -2.0; else tmp = Float64(cos(Float64(x * 2.0)) / Float64(Float64(x * c) * Float64(s * t_0))); end return tmp end
function tmp_2 = code(x, c, s) t_0 = c * (x * s); tmp = 0.0; if (x <= 3e-25) tmp = t_0 ^ -2.0; else tmp = cos((x * 2.0)) / ((x * c) * (s * t_0)); end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 3e-25], N[Power[t$95$0, -2.0], $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(N[(x * c), $MachinePrecision] * N[(s * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\mathbf{if}\;x \leq 3 \cdot 10^{-25}:\\
\;\;\;\;{t\_0}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{\left(x \cdot c\right) \cdot \left(s \cdot t\_0\right)}\\
\end{array}
\end{array}
if x < 2.9999999999999998e-25Initial program 64.9%
associate-/r*64.9%
*-commutative64.9%
unpow264.9%
sqr-neg64.9%
unpow264.9%
cos-neg64.9%
*-commutative64.9%
distribute-rgt-neg-in64.9%
metadata-eval64.9%
unpow264.9%
sqr-neg64.9%
unpow264.9%
associate-*r*57.6%
unpow257.6%
*-commutative57.6%
Simplified57.6%
Taylor expanded in x around 0 52.6%
associate-/r*52.6%
*-commutative52.6%
unpow252.6%
unpow252.6%
swap-sqr70.7%
unpow270.7%
associate-/r*71.1%
unpow271.1%
unpow271.1%
swap-sqr84.1%
unpow284.1%
Simplified84.1%
*-un-lft-identity84.1%
pow-flip84.1%
*-commutative84.1%
associate-*l*85.0%
metadata-eval85.0%
Applied egg-rr85.0%
*-lft-identity85.0%
*-commutative85.0%
*-commutative85.0%
associate-*r*84.1%
Simplified84.1%
if 2.9999999999999998e-25 < x Initial program 68.1%
Taylor expanded in x around inf 61.5%
associate-/r*61.4%
*-commutative61.4%
unpow261.4%
unpow261.4%
swap-sqr71.2%
unpow271.2%
associate-/r*72.3%
unpow272.3%
unpow272.3%
swap-sqr98.4%
unpow298.4%
*-commutative98.4%
Simplified98.4%
unpow298.4%
associate-*r*94.4%
associate-*l*90.5%
*-commutative90.5%
*-commutative90.5%
associate-*l*90.3%
Applied egg-rr90.3%
*-commutative90.3%
*-commutative90.3%
*-commutative90.3%
associate-*r*90.5%
Simplified90.5%
Final simplification85.9%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* x (* s c)))) (/ (/ (cos (* x 2.0)) t_0) t_0)))
double code(double x, double c, double s) {
double t_0 = x * (s * 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 = x * (s * 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 = x * (s * c);
return (Math.cos((x * 2.0)) / t_0) / t_0;
}
def code(x, c, s): t_0 = x * (s * c) return (math.cos((x * 2.0)) / t_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) / t_0) end
function tmp = code(x, c, s) t_0 = x * (s * c); tmp = (cos((x * 2.0)) / t_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] / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(s \cdot c\right)\\
\frac{\frac{\cos \left(x \cdot 2\right)}{t\_0}}{t\_0}
\end{array}
\end{array}
Initial program 65.8%
associate-/r*65.5%
*-commutative65.5%
unpow265.5%
sqr-neg65.5%
unpow265.5%
cos-neg65.5%
*-commutative65.5%
distribute-rgt-neg-in65.5%
metadata-eval65.5%
unpow265.5%
sqr-neg65.5%
unpow265.5%
associate-*r*58.7%
unpow258.7%
*-commutative58.7%
Simplified58.7%
Applied egg-rr97.4%
associate-*l/97.4%
*-un-lft-identity97.4%
unpow297.4%
associate-/r*97.4%
*-commutative97.4%
*-commutative97.4%
associate-*l*95.9%
*-commutative95.9%
associate-*l*98.0%
Applied egg-rr98.0%
(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.8%
associate-/r*65.5%
*-commutative65.5%
unpow265.5%
sqr-neg65.5%
unpow265.5%
cos-neg65.5%
*-commutative65.5%
distribute-rgt-neg-in65.5%
metadata-eval65.5%
unpow265.5%
sqr-neg65.5%
unpow265.5%
associate-*r*58.7%
unpow258.7%
*-commutative58.7%
Simplified58.7%
Taylor expanded in x around 0 52.9%
associate-/r*52.9%
*-commutative52.9%
unpow252.9%
unpow252.9%
swap-sqr67.3%
unpow267.3%
associate-/r*67.6%
unpow267.6%
unpow267.6%
swap-sqr78.0%
unpow278.0%
Simplified78.0%
*-un-lft-identity78.0%
pow-flip78.0%
*-commutative78.0%
associate-*l*78.7%
metadata-eval78.7%
Applied egg-rr78.7%
*-lft-identity78.7%
*-commutative78.7%
*-commutative78.7%
associate-*r*78.0%
Simplified78.0%
Final simplification78.0%
(FPCore (x c s) :precision binary64 (let* ((t_0 (/ 1.0 (* x (* s c))))) (* t_0 t_0)))
double code(double x, double c, double s) {
double t_0 = 1.0 / (x * (s * c));
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 / (x * (s * c))
code = t_0 * t_0
end function
public static double code(double x, double c, double s) {
double t_0 = 1.0 / (x * (s * c));
return t_0 * t_0;
}
def code(x, c, s): t_0 = 1.0 / (x * (s * c)) return t_0 * t_0
function code(x, c, s) t_0 = Float64(1.0 / Float64(x * Float64(s * c))) return Float64(t_0 * t_0) end
function tmp = code(x, c, s) t_0 = 1.0 / (x * (s * c)); tmp = t_0 * t_0; end
code[x_, c_, s_] := Block[{t$95$0 = N[(1.0 / N[(x * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{x \cdot \left(s \cdot c\right)}\\
t\_0 \cdot t\_0
\end{array}
\end{array}
Initial program 65.8%
associate-/r*65.5%
*-commutative65.5%
unpow265.5%
sqr-neg65.5%
unpow265.5%
cos-neg65.5%
*-commutative65.5%
distribute-rgt-neg-in65.5%
metadata-eval65.5%
unpow265.5%
sqr-neg65.5%
unpow265.5%
associate-*r*58.7%
unpow258.7%
*-commutative58.7%
Simplified58.7%
Taylor expanded in x around 0 52.9%
associate-/r*52.9%
*-commutative52.9%
unpow252.9%
unpow252.9%
swap-sqr67.3%
unpow267.3%
associate-/r*67.6%
unpow267.6%
unpow267.6%
swap-sqr78.0%
unpow278.0%
Simplified78.0%
add-sqr-sqrt78.0%
sqrt-div78.0%
metadata-eval78.0%
sqrt-pow161.4%
metadata-eval61.4%
pow161.4%
*-commutative61.4%
associate-*l*61.4%
sqrt-div61.4%
metadata-eval61.4%
sqrt-pow177.6%
metadata-eval77.6%
pow177.6%
*-commutative77.6%
associate-*l*78.7%
Applied egg-rr78.7%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* x (* s c)))) (/ (/ 1.0 t_0) t_0)))
double code(double x, double c, double s) {
double t_0 = x * (s * c);
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 = x * (s * c)
code = (1.0d0 / t_0) / t_0
end function
public static double code(double x, double c, double s) {
double t_0 = x * (s * c);
return (1.0 / t_0) / t_0;
}
def code(x, c, s): t_0 = x * (s * c) return (1.0 / t_0) / t_0
function code(x, c, s) t_0 = Float64(x * Float64(s * c)) return Float64(Float64(1.0 / t_0) / t_0) end
function tmp = code(x, c, s) t_0 = x * (s * c); tmp = (1.0 / t_0) / t_0; end
code[x_, c_, s_] := Block[{t$95$0 = N[(x * N[(s * c), $MachinePrecision]), $MachinePrecision]}, N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(s \cdot c\right)\\
\frac{\frac{1}{t\_0}}{t\_0}
\end{array}
\end{array}
Initial program 65.8%
associate-/r*65.5%
*-commutative65.5%
unpow265.5%
sqr-neg65.5%
unpow265.5%
cos-neg65.5%
*-commutative65.5%
distribute-rgt-neg-in65.5%
metadata-eval65.5%
unpow265.5%
sqr-neg65.5%
unpow265.5%
associate-*r*58.7%
unpow258.7%
*-commutative58.7%
Simplified58.7%
Applied egg-rr97.4%
associate-*l/97.4%
*-un-lft-identity97.4%
unpow297.4%
associate-/r*97.4%
*-commutative97.4%
*-commutative97.4%
associate-*l*95.9%
*-commutative95.9%
associate-*l*98.0%
Applied egg-rr98.0%
Taylor expanded in x around 0 78.7%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* x (* s c)))) (/ 1.0 (* t_0 t_0))))
double code(double x, double c, double s) {
double t_0 = x * (s * c);
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 = x * (s * c)
code = 1.0d0 / (t_0 * t_0)
end function
public static double code(double x, double c, double s) {
double t_0 = x * (s * c);
return 1.0 / (t_0 * t_0);
}
def code(x, c, s): t_0 = x * (s * c) return 1.0 / (t_0 * t_0)
function code(x, c, s) t_0 = Float64(x * Float64(s * c)) return Float64(1.0 / Float64(t_0 * t_0)) end
function tmp = code(x, c, s) t_0 = x * (s * c); tmp = 1.0 / (t_0 * t_0); end
code[x_, c_, s_] := Block[{t$95$0 = N[(x * N[(s * c), $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(s \cdot c\right)\\
\frac{1}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 65.8%
associate-/r*65.5%
*-commutative65.5%
unpow265.5%
sqr-neg65.5%
unpow265.5%
cos-neg65.5%
*-commutative65.5%
distribute-rgt-neg-in65.5%
metadata-eval65.5%
unpow265.5%
sqr-neg65.5%
unpow265.5%
associate-*r*58.7%
unpow258.7%
*-commutative58.7%
Simplified58.7%
Taylor expanded in x around 0 52.9%
associate-/r*52.9%
*-commutative52.9%
unpow252.9%
unpow252.9%
swap-sqr67.3%
unpow267.3%
associate-/r*67.6%
unpow267.6%
unpow267.6%
swap-sqr78.0%
unpow278.0%
Simplified78.0%
unpow278.0%
*-commutative78.0%
associate-*l*77.6%
*-commutative77.6%
associate-*l*78.7%
Applied egg-rr78.7%
(FPCore (x c s) :precision binary64 (/ 1.0 (* (* x c) (* s (* c (* x s))))))
double code(double x, double c, double s) {
return 1.0 / ((x * c) * (s * (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 = 1.0d0 / ((x * c) * (s * (c * (x * s))))
end function
public static double code(double x, double c, double s) {
return 1.0 / ((x * c) * (s * (c * (x * s))));
}
def code(x, c, s): return 1.0 / ((x * c) * (s * (c * (x * s))))
function code(x, c, s) return Float64(1.0 / Float64(Float64(x * c) * Float64(s * Float64(c * Float64(x * s))))) end
function tmp = code(x, c, s) tmp = 1.0 / ((x * c) * (s * (c * (x * s)))); end
code[x_, c_, s_] := N[(1.0 / N[(N[(x * c), $MachinePrecision] * N[(s * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\left(x \cdot c\right) \cdot \left(s \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)}
\end{array}
Initial program 65.8%
associate-/r*65.5%
*-commutative65.5%
unpow265.5%
sqr-neg65.5%
unpow265.5%
cos-neg65.5%
*-commutative65.5%
distribute-rgt-neg-in65.5%
metadata-eval65.5%
unpow265.5%
sqr-neg65.5%
unpow265.5%
associate-*r*58.7%
unpow258.7%
*-commutative58.7%
Simplified58.7%
Taylor expanded in x around 0 52.9%
associate-/r*52.9%
*-commutative52.9%
unpow252.9%
unpow252.9%
swap-sqr67.3%
unpow267.3%
associate-/r*67.6%
unpow267.6%
unpow267.6%
swap-sqr78.0%
unpow278.0%
Simplified78.0%
unpow297.4%
associate-*r*95.5%
associate-*l*93.4%
*-commutative93.4%
*-commutative93.4%
associate-*l*93.3%
Applied egg-rr76.7%
*-commutative93.3%
*-commutative93.3%
*-commutative93.3%
associate-*r*93.4%
Simplified76.3%
Final simplification76.3%
herbie shell --seed 2024149
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))