
(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 (* 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 64.4%
*-un-lft-identity64.4%
add-sqr-sqrt64.4%
times-frac64.4%
Applied egg-rr98.8%
Final simplification98.8%
(FPCore (x c s) :precision binary64 (if (<= x 4.8e-11) (/ (/ (/ 1.0 c) (* x s)) (* c (* x s))) (/ (/ (cos (* x 2.0)) x) (* (* c s) (* x (* c s))))))
double code(double x, double c, double s) {
double tmp;
if (x <= 4.8e-11) {
tmp = ((1.0 / c) / (x * s)) / (c * (x * s));
} else {
tmp = (cos((x * 2.0)) / x) / ((c * s) * (x * (c * 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 <= 4.8d-11) then
tmp = ((1.0d0 / c) / (x * s)) / (c * (x * s))
else
tmp = (cos((x * 2.0d0)) / x) / ((c * s) * (x * (c * s)))
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double tmp;
if (x <= 4.8e-11) {
tmp = ((1.0 / c) / (x * s)) / (c * (x * s));
} else {
tmp = (Math.cos((x * 2.0)) / x) / ((c * s) * (x * (c * s)));
}
return tmp;
}
def code(x, c, s): tmp = 0 if x <= 4.8e-11: tmp = ((1.0 / c) / (x * s)) / (c * (x * s)) else: tmp = (math.cos((x * 2.0)) / x) / ((c * s) * (x * (c * s))) return tmp
function code(x, c, s) tmp = 0.0 if (x <= 4.8e-11) tmp = Float64(Float64(Float64(1.0 / c) / Float64(x * s)) / Float64(c * Float64(x * s))); else tmp = Float64(Float64(cos(Float64(x * 2.0)) / x) / Float64(Float64(c * s) * Float64(x * Float64(c * s)))); end return tmp end
function tmp_2 = code(x, c, s) tmp = 0.0; if (x <= 4.8e-11) tmp = ((1.0 / c) / (x * s)) / (c * (x * s)); else tmp = (cos((x * 2.0)) / x) / ((c * s) * (x * (c * s))); end tmp_2 = tmp; end
code[x_, c_, s_] := If[LessEqual[x, 4.8e-11], N[(N[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision] / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision] / N[(N[(c * s), $MachinePrecision] * N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.8 \cdot 10^{-11}:\\
\;\;\;\;\frac{\frac{\frac{1}{c}}{x \cdot s}}{c \cdot \left(x \cdot s\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(x \cdot 2\right)}{x}}{\left(c \cdot s\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)}\\
\end{array}
\end{array}
if x < 4.8000000000000002e-11Initial program 63.8%
*-un-lft-identity63.8%
add-sqr-sqrt63.8%
times-frac63.7%
Applied egg-rr99.1%
*-commutative99.1%
associate-*l/99.1%
div-inv99.1%
*-commutative99.1%
Applied egg-rr99.1%
Taylor expanded in x around 0 85.9%
associate-/r*86.0%
Simplified86.0%
if 4.8000000000000002e-11 < x Initial program 65.8%
*-un-lft-identity65.8%
add-sqr-sqrt65.8%
times-frac65.8%
Applied egg-rr98.2%
*-commutative98.2%
associate-*l/98.2%
div-inv98.2%
*-commutative98.2%
Applied egg-rr98.2%
div-inv98.2%
*-commutative98.2%
associate-*l*98.4%
*-commutative98.4%
*-commutative98.4%
associate-*l*99.5%
*-commutative99.5%
Applied egg-rr99.5%
*-commutative99.5%
associate-/r*99.6%
frac-times95.8%
metadata-eval95.8%
times-frac95.8%
*-un-lft-identity95.8%
*-un-lft-identity95.8%
Applied egg-rr95.8%
Final simplification88.8%
(FPCore (x c s) :precision binary64 (/ (/ (cos (* x 2.0)) c) (* (* c (* x s)) (* x s))))
double code(double x, double c, double s) {
return (cos((x * 2.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 = (cos((x * 2.0d0)) / c) / ((c * (x * s)) * (x * s))
end function
public static double code(double x, double c, double s) {
return (Math.cos((x * 2.0)) / c) / ((c * (x * s)) * (x * s));
}
def code(x, c, s): return (math.cos((x * 2.0)) / c) / ((c * (x * s)) * (x * s))
function code(x, c, s) return Float64(Float64(cos(Float64(x * 2.0)) / c) / Float64(Float64(c * Float64(x * s)) * Float64(x * s))) end
function tmp = code(x, c, s) tmp = (cos((x * 2.0)) / c) / ((c * (x * s)) * (x * s)); end
code[x_, c_, s_] := N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / c), $MachinePrecision] / N[(N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision] * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\cos \left(x \cdot 2\right)}{c}}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(x \cdot s\right)}
\end{array}
Initial program 64.4%
*-un-lft-identity64.4%
add-sqr-sqrt64.4%
times-frac64.4%
Applied egg-rr98.8%
*-commutative98.8%
associate-/r*98.8%
frac-times94.6%
div-inv94.7%
*-commutative94.7%
Applied egg-rr94.7%
Final simplification94.7%
(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(Float64(cos(Float64(x * 2.0)) / 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[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / 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{\cos \left(x \cdot 2\right)}{t\_0}}{t\_0}
\end{array}
\end{array}
Initial program 64.4%
*-un-lft-identity64.4%
add-sqr-sqrt64.4%
times-frac64.4%
Applied egg-rr98.8%
*-commutative98.8%
associate-*l/98.8%
div-inv98.8%
*-commutative98.8%
Applied egg-rr98.8%
Final simplification98.8%
(FPCore (x c s) :precision binary64 (if (<= x 2e-214) (/ 1.0 (* (* c x) (* c (* s (* x s))))) (/ 1.0 (* (* c s) (* x (* c (* x s)))))))
double code(double x, double c, double s) {
double tmp;
if (x <= 2e-214) {
tmp = 1.0 / ((c * x) * (c * (s * (x * s))));
} else {
tmp = 1.0 / ((c * s) * (x * (c * (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-214) then
tmp = 1.0d0 / ((c * x) * (c * (s * (x * s))))
else
tmp = 1.0d0 / ((c * s) * (x * (c * (x * s))))
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double tmp;
if (x <= 2e-214) {
tmp = 1.0 / ((c * x) * (c * (s * (x * s))));
} else {
tmp = 1.0 / ((c * s) * (x * (c * (x * s))));
}
return tmp;
}
def code(x, c, s): tmp = 0 if x <= 2e-214: tmp = 1.0 / ((c * x) * (c * (s * (x * s)))) else: tmp = 1.0 / ((c * s) * (x * (c * (x * s)))) return tmp
function code(x, c, s) tmp = 0.0 if (x <= 2e-214) tmp = Float64(1.0 / Float64(Float64(c * x) * Float64(c * Float64(s * Float64(x * s))))); else tmp = Float64(1.0 / Float64(Float64(c * s) * Float64(x * Float64(c * Float64(x * s))))); end return tmp end
function tmp_2 = code(x, c, s) tmp = 0.0; if (x <= 2e-214) tmp = 1.0 / ((c * x) * (c * (s * (x * s)))); else tmp = 1.0 / ((c * s) * (x * (c * (x * s)))); end tmp_2 = tmp; end
code[x_, c_, s_] := If[LessEqual[x, 2e-214], N[(1.0 / N[(N[(c * x), $MachinePrecision] * N[(c * N[(s * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(c * s), $MachinePrecision] * N[(x * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2 \cdot 10^{-214}:\\
\;\;\;\;\frac{1}{\left(c \cdot x\right) \cdot \left(c \cdot \left(s \cdot \left(x \cdot s\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(c \cdot s\right) \cdot \left(x \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)}\\
\end{array}
\end{array}
if x < 1.99999999999999983e-214Initial program 63.1%
Taylor expanded in x around 0 48.1%
associate-/r*48.1%
*-commutative48.1%
unpow248.1%
unpow248.1%
swap-sqr63.5%
unpow263.5%
associate-/r*63.9%
unpow263.9%
unpow263.9%
swap-sqr81.5%
unpow281.5%
*-commutative81.5%
Simplified81.5%
unpow-prod-down63.9%
*-commutative63.9%
unpow-prod-down81.5%
unpow281.5%
associate-*r*78.3%
associate-*l*75.5%
Applied egg-rr75.5%
pow175.5%
associate-*r*74.9%
*-commutative74.9%
Applied egg-rr74.9%
unpow174.9%
associate-*l*73.2%
*-commutative73.2%
Simplified73.2%
if 1.99999999999999983e-214 < x Initial program 65.9%
Taylor expanded in x around 0 55.3%
associate-/r*53.5%
*-commutative53.5%
unpow253.5%
unpow253.5%
swap-sqr58.8%
unpow258.8%
associate-/r*60.1%
unpow260.1%
unpow260.1%
swap-sqr71.2%
unpow271.2%
*-commutative71.2%
Simplified71.2%
unpow271.2%
associate-*r*71.2%
*-commutative71.2%
associate-*l*71.1%
Applied egg-rr71.1%
Final simplification72.2%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (* c (* x s))))
(if (<= s 7.2e+212)
(/ 1.0 (* (* c x) (* s t_0)))
(/ 1.0 (* (* c s) (* x t_0))))))
double code(double x, double c, double s) {
double t_0 = c * (x * s);
double tmp;
if (s <= 7.2e+212) {
tmp = 1.0 / ((c * x) * (s * t_0));
} else {
tmp = 1.0 / ((c * s) * (x * 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 (s <= 7.2d+212) then
tmp = 1.0d0 / ((c * x) * (s * t_0))
else
tmp = 1.0d0 / ((c * s) * (x * 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 (s <= 7.2e+212) {
tmp = 1.0 / ((c * x) * (s * t_0));
} else {
tmp = 1.0 / ((c * s) * (x * t_0));
}
return tmp;
}
def code(x, c, s): t_0 = c * (x * s) tmp = 0 if s <= 7.2e+212: tmp = 1.0 / ((c * x) * (s * t_0)) else: tmp = 1.0 / ((c * s) * (x * t_0)) return tmp
function code(x, c, s) t_0 = Float64(c * Float64(x * s)) tmp = 0.0 if (s <= 7.2e+212) tmp = Float64(1.0 / Float64(Float64(c * x) * Float64(s * t_0))); else tmp = Float64(1.0 / Float64(Float64(c * s) * Float64(x * t_0))); end return tmp end
function tmp_2 = code(x, c, s) t_0 = c * (x * s); tmp = 0.0; if (s <= 7.2e+212) tmp = 1.0 / ((c * x) * (s * t_0)); else tmp = 1.0 / ((c * s) * (x * t_0)); end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[s, 7.2e+212], N[(1.0 / N[(N[(c * x), $MachinePrecision] * N[(s * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(c * s), $MachinePrecision] * N[(x * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\mathbf{if}\;s \leq 7.2 \cdot 10^{+212}:\\
\;\;\;\;\frac{1}{\left(c \cdot x\right) \cdot \left(s \cdot t\_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(c \cdot s\right) \cdot \left(x \cdot t\_0\right)}\\
\end{array}
\end{array}
if s < 7.2e212Initial program 65.1%
Taylor expanded in x around 0 51.3%
associate-/r*50.9%
*-commutative50.9%
unpow250.9%
unpow250.9%
swap-sqr61.0%
unpow261.0%
associate-/r*61.4%
unpow261.4%
unpow261.4%
swap-sqr74.9%
unpow274.9%
*-commutative74.9%
Simplified74.9%
unpow-prod-down61.4%
*-commutative61.4%
unpow-prod-down74.9%
unpow274.9%
associate-*r*73.8%
associate-*l*72.2%
Applied egg-rr72.2%
if 7.2e212 < s Initial program 56.8%
Taylor expanded in x around 0 52.2%
associate-/r*47.8%
*-commutative47.8%
unpow247.8%
unpow247.8%
swap-sqr65.5%
unpow265.5%
associate-/r*69.8%
unpow269.8%
unpow269.8%
swap-sqr95.8%
unpow295.8%
*-commutative95.8%
Simplified95.8%
unpow295.8%
associate-*r*95.8%
*-commutative95.8%
associate-*l*95.8%
Applied egg-rr95.8%
Final simplification74.3%
(FPCore (x c s) :precision binary64 (/ 1.0 (* (* c s) (* x (* c (* x s))))))
double code(double x, double c, double s) {
return 1.0 / ((c * s) * (x * (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 / ((c * s) * (x * (c * (x * s))))
end function
public static double code(double x, double c, double s) {
return 1.0 / ((c * s) * (x * (c * (x * s))));
}
def code(x, c, s): return 1.0 / ((c * s) * (x * (c * (x * s))))
function code(x, c, s) return Float64(1.0 / Float64(Float64(c * s) * Float64(x * Float64(c * Float64(x * s))))) end
function tmp = code(x, c, s) tmp = 1.0 / ((c * s) * (x * (c * (x * s)))); end
code[x_, c_, s_] := N[(1.0 / N[(N[(c * s), $MachinePrecision] * N[(x * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\left(c \cdot s\right) \cdot \left(x \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)}
\end{array}
Initial program 64.4%
Taylor expanded in x around 0 51.4%
associate-/r*50.6%
*-commutative50.6%
unpow250.6%
unpow250.6%
swap-sqr61.4%
unpow261.4%
associate-/r*62.2%
unpow262.2%
unpow262.2%
swap-sqr76.8%
unpow276.8%
*-commutative76.8%
Simplified76.8%
unpow276.8%
associate-*r*76.1%
*-commutative76.1%
associate-*l*72.9%
Applied egg-rr72.9%
Final simplification72.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 64.4%
Taylor expanded in x around 0 51.4%
associate-/r*50.6%
*-commutative50.6%
unpow250.6%
unpow250.6%
swap-sqr61.4%
unpow261.4%
associate-/r*62.2%
unpow262.2%
unpow262.2%
swap-sqr76.8%
unpow276.8%
*-commutative76.8%
Simplified76.8%
unpow-prod-down62.2%
*-commutative62.2%
unpow-prod-down76.8%
unpow276.8%
Applied egg-rr76.8%
Final simplification76.8%
(FPCore (x c s) :precision binary64 (/ (/ (/ 1.0 c) (* x s)) (* c (* x s))))
double code(double x, double c, double s) {
return ((1.0 / c) / (x * 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 / c) / (x * s)) / (c * (x * s))
end function
public static double code(double x, double c, double s) {
return ((1.0 / c) / (x * s)) / (c * (x * s));
}
def code(x, c, s): return ((1.0 / c) / (x * s)) / (c * (x * s))
function code(x, c, s) return Float64(Float64(Float64(1.0 / c) / Float64(x * s)) / Float64(c * Float64(x * s))) end
function tmp = code(x, c, s) tmp = ((1.0 / c) / (x * s)) / (c * (x * s)); end
code[x_, c_, s_] := N[(N[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision] / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\frac{1}{c}}{x \cdot s}}{c \cdot \left(x \cdot s\right)}
\end{array}
Initial program 64.4%
*-un-lft-identity64.4%
add-sqr-sqrt64.4%
times-frac64.4%
Applied egg-rr98.8%
*-commutative98.8%
associate-*l/98.8%
div-inv98.8%
*-commutative98.8%
Applied egg-rr98.8%
Taylor expanded in x around 0 77.2%
associate-/r*77.2%
Simplified77.2%
Final simplification77.2%
herbie shell --seed 2024041
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))