
(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 (let* ((t_0 (/ (/ (/ 1.0 c) s) x))) (* t_0 (* t_0 (cos (* x 2.0))))))
double code(double x, double c, double s) {
double t_0 = ((1.0 / c) / s) / x;
return 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 = ((1.0d0 / c) / s) / x
code = t_0 * (t_0 * cos((x * 2.0d0)))
end function
public static double code(double x, double c, double s) {
double t_0 = ((1.0 / c) / s) / x;
return t_0 * (t_0 * Math.cos((x * 2.0)));
}
def code(x, c, s): t_0 = ((1.0 / c) / s) / x return t_0 * (t_0 * math.cos((x * 2.0)))
function code(x, c, s) t_0 = Float64(Float64(Float64(1.0 / c) / s) / x) return Float64(t_0 * Float64(t_0 * cos(Float64(x * 2.0)))) end
function tmp = code(x, c, s) t_0 = ((1.0 / c) / s) / x; tmp = t_0 * (t_0 * cos((x * 2.0))); end
code[x_, c_, s_] := Block[{t$95$0 = N[(N[(N[(1.0 / c), $MachinePrecision] / s), $MachinePrecision] / x), $MachinePrecision]}, N[(t$95$0 * N[(t$95$0 * N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{\frac{1}{c}}{s}}{x}\\
t\_0 \cdot \left(t\_0 \cdot \cos \left(x \cdot 2\right)\right)
\end{array}
\end{array}
Initial program 66.4%
associate-/r*66.0%
cos-neg66.0%
distribute-rgt-neg-out66.0%
distribute-rgt-neg-out66.0%
*-commutative66.0%
distribute-rgt-neg-in66.0%
metadata-eval66.0%
*-commutative66.0%
associate-*l*62.1%
unpow262.1%
Simplified62.1%
Taylor expanded in x around inf 62.5%
associate-/r*62.1%
*-commutative62.1%
unpow262.1%
unpow262.1%
swap-sqr76.3%
unpow276.3%
associate-/r*76.7%
*-commutative76.7%
unpow276.7%
unpow276.7%
swap-sqr96.1%
unpow296.1%
*-commutative96.1%
Simplified96.1%
unpow296.1%
Applied egg-rr96.1%
clear-num96.1%
associate-/r/96.1%
add-sqr-sqrt96.0%
add-sqr-sqrt44.2%
sqrt-unprod74.1%
swap-sqr74.1%
metadata-eval74.1%
metadata-eval74.1%
swap-sqr74.1%
sqrt-unprod45.4%
add-sqr-sqrt96.0%
associate-*l*96.0%
Applied egg-rr98.4%
Final simplification98.4%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (/ (/ 1.0 c) (* s x))))
(if (<= x 1.75e-208)
(* t_0 t_0)
(/ (cos (* x -2.0)) (* (* c s) (* x (* c (* s x))))))))
double code(double x, double c, double s) {
double t_0 = (1.0 / c) / (s * x);
double tmp;
if (x <= 1.75e-208) {
tmp = t_0 * t_0;
} else {
tmp = cos((x * -2.0)) / ((c * s) * (x * (c * (s * x))));
}
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 = (1.0d0 / c) / (s * x)
if (x <= 1.75d-208) then
tmp = t_0 * t_0
else
tmp = cos((x * (-2.0d0))) / ((c * s) * (x * (c * (s * x))))
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double t_0 = (1.0 / c) / (s * x);
double tmp;
if (x <= 1.75e-208) {
tmp = t_0 * t_0;
} else {
tmp = Math.cos((x * -2.0)) / ((c * s) * (x * (c * (s * x))));
}
return tmp;
}
def code(x, c, s): t_0 = (1.0 / c) / (s * x) tmp = 0 if x <= 1.75e-208: tmp = t_0 * t_0 else: tmp = math.cos((x * -2.0)) / ((c * s) * (x * (c * (s * x)))) return tmp
function code(x, c, s) t_0 = Float64(Float64(1.0 / c) / Float64(s * x)) tmp = 0.0 if (x <= 1.75e-208) tmp = Float64(t_0 * t_0); else tmp = Float64(cos(Float64(x * -2.0)) / Float64(Float64(c * s) * Float64(x * Float64(c * Float64(s * x))))); end return tmp end
function tmp_2 = code(x, c, s) t_0 = (1.0 / c) / (s * x); tmp = 0.0; if (x <= 1.75e-208) tmp = t_0 * t_0; else tmp = cos((x * -2.0)) / ((c * s) * (x * (c * (s * x)))); end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[(N[(1.0 / c), $MachinePrecision] / N[(s * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.75e-208], N[(t$95$0 * t$95$0), $MachinePrecision], N[(N[Cos[N[(x * -2.0), $MachinePrecision]], $MachinePrecision] / N[(N[(c * s), $MachinePrecision] * N[(x * N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{1}{c}}{s \cdot x}\\
\mathbf{if}\;x \leq 1.75 \cdot 10^{-208}:\\
\;\;\;\;t\_0 \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot -2\right)}{\left(c \cdot s\right) \cdot \left(x \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)}\\
\end{array}
\end{array}
if x < 1.74999999999999996e-208Initial program 64.7%
Taylor expanded in x around 0 57.2%
associate-/r*57.2%
*-commutative57.2%
unpow257.2%
unpow257.2%
swap-sqr65.8%
unpow265.8%
associate-/r*65.8%
unpow265.8%
unpow265.8%
swap-sqr80.7%
unpow280.7%
*-commutative80.7%
Simplified80.7%
unpow280.7%
associate-*r*78.8%
associate-*l*73.3%
Applied egg-rr73.3%
inv-pow73.3%
associate-*r*78.8%
associate-*r*80.7%
unpow-prod-down80.6%
metadata-eval80.6%
metadata-eval80.6%
sqr-pow80.7%
unpow-prod-down65.9%
metadata-eval65.9%
pow-prod-up65.9%
inv-pow65.9%
inv-pow65.9%
metadata-eval65.9%
pow-flip65.9%
div-inv65.8%
unpow265.8%
times-frac80.7%
Applied egg-rr80.7%
if 1.74999999999999996e-208 < x Initial program 68.7%
associate-/r*67.8%
cos-neg67.8%
distribute-rgt-neg-out67.8%
distribute-rgt-neg-out67.8%
*-commutative67.8%
distribute-rgt-neg-in67.8%
metadata-eval67.8%
*-commutative67.8%
associate-*l*63.0%
unpow263.0%
Simplified63.0%
Taylor expanded in x around inf 63.9%
associate-/r*63.0%
*-commutative63.0%
unpow263.0%
unpow263.0%
swap-sqr77.7%
unpow277.7%
associate-/r*78.7%
*-commutative78.7%
unpow278.7%
unpow278.7%
swap-sqr97.0%
unpow297.0%
*-commutative97.0%
Simplified97.0%
unpow279.0%
associate-*r*78.9%
associate-*l*78.8%
Applied egg-rr94.4%
Final simplification86.4%
(FPCore (x c s) :precision binary64 (* (/ (/ 1.0 c) (* s x)) (/ (cos (* x -2.0)) (* c (* s x)))))
double code(double x, double c, double s) {
return ((1.0 / c) / (s * x)) * (cos((x * -2.0)) / (c * (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) / (s * x)) * (cos((x * (-2.0d0))) / (c * (s * x)))
end function
public static double code(double x, double c, double s) {
return ((1.0 / c) / (s * x)) * (Math.cos((x * -2.0)) / (c * (s * x)));
}
def code(x, c, s): return ((1.0 / c) / (s * x)) * (math.cos((x * -2.0)) / (c * (s * x)))
function code(x, c, s) return Float64(Float64(Float64(1.0 / c) / Float64(s * x)) * Float64(cos(Float64(x * -2.0)) / Float64(c * Float64(s * x)))) end
function tmp = code(x, c, s) tmp = ((1.0 / c) / (s * x)) * (cos((x * -2.0)) / (c * (s * x))); end
code[x_, c_, s_] := N[(N[(N[(1.0 / c), $MachinePrecision] / N[(s * x), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[N[(x * -2.0), $MachinePrecision]], $MachinePrecision] / N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{c}}{s \cdot x} \cdot \frac{\cos \left(x \cdot -2\right)}{c \cdot \left(s \cdot x\right)}
\end{array}
Initial program 66.4%
associate-/r*66.0%
cos-neg66.0%
distribute-rgt-neg-out66.0%
distribute-rgt-neg-out66.0%
*-commutative66.0%
distribute-rgt-neg-in66.0%
metadata-eval66.0%
*-commutative66.0%
associate-*l*62.1%
unpow262.1%
Simplified62.1%
Taylor expanded in x around inf 62.5%
associate-/r*62.1%
*-commutative62.1%
unpow262.1%
unpow262.1%
swap-sqr76.3%
unpow276.3%
associate-/r*76.7%
*-commutative76.7%
unpow276.7%
unpow276.7%
swap-sqr96.1%
unpow296.1%
*-commutative96.1%
Simplified96.1%
associate-*r*98.1%
unpow-prod-down76.5%
pow276.5%
associate-*l*84.9%
add-sqr-sqrt40.9%
associate-*l*40.9%
sqrt-prod40.9%
sqrt-pow127.4%
metadata-eval27.4%
pow127.4%
sqrt-prod27.4%
sqrt-pow149.0%
metadata-eval49.0%
pow149.0%
Applied egg-rr49.0%
Applied egg-rr96.1%
Final simplification96.1%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* c (* s x)))) (/ 1.0 (* t_0 (/ t_0 (cos (* x 2.0)))))))
double code(double x, double c, double s) {
double t_0 = c * (s * x);
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 = c * (s * x)
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 = c * (s * x);
return 1.0 / (t_0 * (t_0 / Math.cos((x * 2.0))));
}
def code(x, c, s): t_0 = c * (s * x) return 1.0 / (t_0 * (t_0 / math.cos((x * 2.0))))
function code(x, c, s) t_0 = Float64(c * Float64(s * x)) return Float64(1.0 / Float64(t_0 * Float64(t_0 / cos(Float64(x * 2.0))))) end
function tmp = code(x, c, s) t_0 = c * (s * x); tmp = 1.0 / (t_0 * (t_0 / cos((x * 2.0)))); end
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * N[(t$95$0 / N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot \left(s \cdot x\right)\\
\frac{1}{t\_0 \cdot \frac{t\_0}{\cos \left(x \cdot 2\right)}}
\end{array}
\end{array}
Initial program 66.4%
Applied egg-rr83.9%
*-commutative83.9%
div-inv83.8%
associate-*r*76.3%
inv-pow76.3%
inv-pow76.3%
pow-sqr76.3%
metadata-eval76.3%
associate-*l*76.3%
*-commutative76.3%
unpow-prod-down96.1%
*-commutative96.1%
metadata-eval96.1%
pow-flip96.1%
associate-*r*98.1%
unpow-prod-down76.5%
pow276.5%
associate-*l*84.9%
div-inv84.9%
Applied egg-rr96.1%
pow296.1%
associate-/l*96.1%
Applied egg-rr96.1%
Final simplification96.1%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* c (* s x)))) (/ (cos (* x -2.0)) (* t_0 t_0))))
double code(double x, double c, double s) {
double t_0 = c * (s * x);
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 * (s * x)
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 * (s * x);
return Math.cos((x * -2.0)) / (t_0 * t_0);
}
def code(x, c, s): t_0 = c * (s * x) return math.cos((x * -2.0)) / (t_0 * t_0)
function code(x, c, s) t_0 = Float64(c * Float64(s * x)) return Float64(cos(Float64(x * -2.0)) / Float64(t_0 * t_0)) end
function tmp = code(x, c, s) t_0 = c * (s * x); tmp = cos((x * -2.0)) / (t_0 * t_0); end
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(s * x), $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(s \cdot x\right)\\
\frac{\cos \left(x \cdot -2\right)}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 66.4%
associate-/r*66.0%
cos-neg66.0%
distribute-rgt-neg-out66.0%
distribute-rgt-neg-out66.0%
*-commutative66.0%
distribute-rgt-neg-in66.0%
metadata-eval66.0%
*-commutative66.0%
associate-*l*62.1%
unpow262.1%
Simplified62.1%
Taylor expanded in x around inf 62.5%
associate-/r*62.1%
*-commutative62.1%
unpow262.1%
unpow262.1%
swap-sqr76.3%
unpow276.3%
associate-/r*76.7%
*-commutative76.7%
unpow276.7%
unpow276.7%
swap-sqr96.1%
unpow296.1%
*-commutative96.1%
Simplified96.1%
unpow296.1%
Applied egg-rr96.1%
Final simplification96.1%
(FPCore (x c s) :precision binary64 (pow (* c (* s x)) -2.0))
double code(double x, double c, double s) {
return pow((c * (s * 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 = (c * (s * x)) ** (-2.0d0)
end function
public static double code(double x, double c, double s) {
return Math.pow((c * (s * x)), -2.0);
}
def code(x, c, s): return math.pow((c * (s * x)), -2.0)
function code(x, c, s) return Float64(c * Float64(s * x)) ^ -2.0 end
function tmp = code(x, c, s) tmp = (c * (s * x)) ^ -2.0; end
code[x_, c_, s_] := N[Power[N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]
\begin{array}{l}
\\
{\left(c \cdot \left(s \cdot x\right)\right)}^{-2}
\end{array}
Initial program 66.4%
Taylor expanded in x around 0 56.7%
associate-/r*56.3%
*-commutative56.3%
unpow256.3%
unpow256.3%
swap-sqr66.0%
unpow266.0%
associate-/r*66.4%
unpow266.4%
unpow266.4%
swap-sqr80.0%
unpow280.0%
*-commutative80.0%
Simplified80.0%
*-un-lft-identity80.0%
pow-flip80.0%
metadata-eval80.0%
Applied egg-rr80.0%
*-lft-identity80.0%
Simplified80.0%
Final simplification80.0%
(FPCore (x c s) :precision binary64 (if (<= x 2.2e-210) (/ 1.0 (* x (* c (* (* s x) (* c s))))) (/ 1.0 (* (* c s) (* x (* c (* s x)))))))
double code(double x, double c, double s) {
double tmp;
if (x <= 2.2e-210) {
tmp = 1.0 / (x * (c * ((s * x) * (c * s))));
} else {
tmp = 1.0 / ((c * s) * (x * (c * (s * x))));
}
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 <= 2.2d-210) then
tmp = 1.0d0 / (x * (c * ((s * x) * (c * s))))
else
tmp = 1.0d0 / ((c * s) * (x * (c * (s * x))))
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double tmp;
if (x <= 2.2e-210) {
tmp = 1.0 / (x * (c * ((s * x) * (c * s))));
} else {
tmp = 1.0 / ((c * s) * (x * (c * (s * x))));
}
return tmp;
}
def code(x, c, s): tmp = 0 if x <= 2.2e-210: tmp = 1.0 / (x * (c * ((s * x) * (c * s)))) else: tmp = 1.0 / ((c * s) * (x * (c * (s * x)))) return tmp
function code(x, c, s) tmp = 0.0 if (x <= 2.2e-210) tmp = Float64(1.0 / Float64(x * Float64(c * Float64(Float64(s * x) * Float64(c * s))))); else tmp = Float64(1.0 / Float64(Float64(c * s) * Float64(x * Float64(c * Float64(s * x))))); end return tmp end
function tmp_2 = code(x, c, s) tmp = 0.0; if (x <= 2.2e-210) tmp = 1.0 / (x * (c * ((s * x) * (c * s)))); else tmp = 1.0 / ((c * s) * (x * (c * (s * x)))); end tmp_2 = tmp; end
code[x_, c_, s_] := If[LessEqual[x, 2.2e-210], N[(1.0 / N[(x * N[(c * N[(N[(s * x), $MachinePrecision] * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(c * s), $MachinePrecision] * N[(x * N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.2 \cdot 10^{-210}:\\
\;\;\;\;\frac{1}{x \cdot \left(c \cdot \left(\left(s \cdot x\right) \cdot \left(c \cdot s\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(c \cdot s\right) \cdot \left(x \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)}\\
\end{array}
\end{array}
if x < 2.19999999999999989e-210Initial program 64.7%
Applied egg-rr82.1%
Taylor expanded in x around 0 61.1%
associate-/r*61.1%
unpow261.1%
unpow261.1%
swap-sqr71.2%
unpow271.2%
Simplified71.2%
div-inv71.2%
associate-*r*65.9%
inv-pow65.9%
inv-pow65.9%
pow-prod-up65.9%
metadata-eval65.9%
pow-flip65.9%
metadata-eval65.9%
unpow-prod-down80.7%
sqr-pow80.6%
metadata-eval80.6%
metadata-eval80.6%
unpow-prod-down80.7%
associate-*r*78.8%
associate-*r*73.3%
inv-pow73.3%
associate-/r*73.2%
clear-num73.3%
associate-*r*73.0%
Applied egg-rr73.0%
associate-/l*74.8%
associate-*l*76.4%
div-inv76.4%
remove-double-div76.4%
Applied egg-rr76.4%
if 2.19999999999999989e-210 < x Initial program 68.7%
Taylor expanded in x around 0 55.9%
associate-/r*54.9%
*-commutative54.9%
unpow254.9%
unpow254.9%
swap-sqr66.4%
unpow266.4%
associate-/r*67.3%
unpow267.3%
unpow267.3%
swap-sqr79.0%
unpow279.0%
*-commutative79.0%
Simplified79.0%
unpow279.0%
associate-*r*78.9%
associate-*l*78.8%
Applied egg-rr78.8%
Final simplification77.4%
(FPCore (x c s) :precision binary64 (/ 1.0 (* c (* x (* (* s x) (* c s))))))
double code(double x, double c, double s) {
return 1.0 / (c * (x * ((s * 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 = 1.0d0 / (c * (x * ((s * x) * (c * s))))
end function
public static double code(double x, double c, double s) {
return 1.0 / (c * (x * ((s * x) * (c * s))));
}
def code(x, c, s): return 1.0 / (c * (x * ((s * x) * (c * s))))
function code(x, c, s) return Float64(1.0 / Float64(c * Float64(x * Float64(Float64(s * x) * Float64(c * s))))) end
function tmp = code(x, c, s) tmp = 1.0 / (c * (x * ((s * x) * (c * s)))); end
code[x_, c_, s_] := N[(1.0 / N[(c * N[(x * N[(N[(s * x), $MachinePrecision] * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{c \cdot \left(x \cdot \left(\left(s \cdot x\right) \cdot \left(c \cdot s\right)\right)\right)}
\end{array}
Initial program 66.4%
Applied egg-rr83.9%
Taylor expanded in x around 0 61.3%
associate-/r*61.3%
unpow261.3%
unpow261.3%
swap-sqr72.7%
unpow272.7%
Simplified72.7%
div-inv72.7%
associate-*r*66.1%
inv-pow66.1%
inv-pow66.1%
pow-prod-up66.1%
metadata-eval66.1%
pow-flip66.1%
metadata-eval66.1%
unpow-prod-down80.0%
sqr-pow79.9%
metadata-eval79.9%
metadata-eval79.9%
unpow-prod-down80.0%
associate-*r*78.9%
associate-*r*75.6%
inv-pow75.6%
associate-/r*75.6%
clear-num75.5%
associate-*r*74.6%
Applied egg-rr74.6%
associate-/l*73.9%
*-commutative73.9%
associate-*l*73.8%
div-inv73.8%
remove-double-div73.8%
Applied egg-rr73.8%
Final simplification73.8%
(FPCore (x c s) :precision binary64 (/ 1.0 (* x (* c (* (* s x) (* c s))))))
double code(double x, double c, double s) {
return 1.0 / (x * (c * ((s * 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 = 1.0d0 / (x * (c * ((s * x) * (c * s))))
end function
public static double code(double x, double c, double s) {
return 1.0 / (x * (c * ((s * x) * (c * s))));
}
def code(x, c, s): return 1.0 / (x * (c * ((s * x) * (c * s))))
function code(x, c, s) return Float64(1.0 / Float64(x * Float64(c * Float64(Float64(s * x) * Float64(c * s))))) end
function tmp = code(x, c, s) tmp = 1.0 / (x * (c * ((s * x) * (c * s)))); end
code[x_, c_, s_] := N[(1.0 / N[(x * N[(c * N[(N[(s * x), $MachinePrecision] * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot \left(c \cdot \left(\left(s \cdot x\right) \cdot \left(c \cdot s\right)\right)\right)}
\end{array}
Initial program 66.4%
Applied egg-rr83.9%
Taylor expanded in x around 0 61.3%
associate-/r*61.3%
unpow261.3%
unpow261.3%
swap-sqr72.7%
unpow272.7%
Simplified72.7%
div-inv72.7%
associate-*r*66.1%
inv-pow66.1%
inv-pow66.1%
pow-prod-up66.1%
metadata-eval66.1%
pow-flip66.1%
metadata-eval66.1%
unpow-prod-down80.0%
sqr-pow79.9%
metadata-eval79.9%
metadata-eval79.9%
unpow-prod-down80.0%
associate-*r*78.9%
associate-*r*75.6%
inv-pow75.6%
associate-/r*75.6%
clear-num75.5%
associate-*r*74.6%
Applied egg-rr74.6%
associate-/l*73.9%
associate-*l*74.9%
div-inv74.9%
remove-double-div74.9%
Applied egg-rr74.9%
Final simplification74.9%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* c (* s x)))) (/ 1.0 (* t_0 t_0))))
double code(double x, double c, double s) {
double t_0 = c * (s * x);
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 * (s * x)
code = 1.0d0 / (t_0 * t_0)
end function
public static double code(double x, double c, double s) {
double t_0 = c * (s * x);
return 1.0 / (t_0 * t_0);
}
def code(x, c, s): t_0 = c * (s * x) return 1.0 / (t_0 * t_0)
function code(x, c, s) t_0 = Float64(c * Float64(s * x)) return Float64(1.0 / Float64(t_0 * t_0)) end
function tmp = code(x, c, s) t_0 = c * (s * x); tmp = 1.0 / (t_0 * t_0); end
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(s * x), $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(s \cdot x\right)\\
\frac{1}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 66.4%
Taylor expanded in x around 0 56.7%
associate-/r*56.3%
*-commutative56.3%
unpow256.3%
unpow256.3%
swap-sqr66.0%
unpow266.0%
associate-/r*66.4%
unpow266.4%
unpow266.4%
swap-sqr80.0%
unpow280.0%
*-commutative80.0%
Simplified80.0%
unpow296.1%
Applied egg-rr80.0%
Final simplification80.0%
herbie shell --seed 2024080
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))