
(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 (* (pow (* (* c s) x) -2.0) (cos (* x -2.0))))
double code(double x, double c, double s) {
return pow(((c * s) * x), -2.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
code = (((c * s) * x) ** (-2.0d0)) * cos((x * (-2.0d0)))
end function
public static double code(double x, double c, double s) {
return Math.pow(((c * s) * x), -2.0) * Math.cos((x * -2.0));
}
def code(x, c, s): return math.pow(((c * s) * x), -2.0) * math.cos((x * -2.0))
function code(x, c, s) return Float64((Float64(Float64(c * s) * x) ^ -2.0) * cos(Float64(x * -2.0))) end
function tmp = code(x, c, s) tmp = (((c * s) * x) ^ -2.0) * cos((x * -2.0)); end
code[x_, c_, s_] := N[(N[Power[N[(N[(c * s), $MachinePrecision] * x), $MachinePrecision], -2.0], $MachinePrecision] * N[Cos[N[(x * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(\left(c \cdot s\right) \cdot x\right)}^{-2} \cdot \cos \left(x \cdot -2\right)
\end{array}
Initial program 69.7%
associate-/r*69.2%
cos-neg69.2%
distribute-rgt-neg-out69.2%
distribute-rgt-neg-out69.2%
*-commutative69.2%
distribute-rgt-neg-in69.2%
metadata-eval69.2%
*-commutative69.2%
associate-*l*64.1%
unpow264.1%
Simplified64.1%
Taylor expanded in x around inf 64.6%
associate-/r*64.1%
*-commutative64.1%
unpow264.1%
unpow264.1%
swap-sqr79.5%
unpow279.5%
associate-/r*80.0%
*-commutative80.0%
unpow280.0%
unpow280.0%
swap-sqr97.2%
unpow297.2%
*-commutative97.2%
Simplified97.2%
unpow-prod-down80.0%
*-commutative80.0%
unpow-prod-down64.6%
/-rgt-identity64.6%
clear-num64.6%
div-inv64.6%
clear-num64.6%
div-inv64.6%
unpow264.6%
associate-/l/64.6%
unpow-prod-down80.0%
*-commutative80.0%
pow-flip80.3%
*-commutative80.3%
metadata-eval80.3%
sqr-pow80.3%
times-frac97.1%
Applied egg-rr97.6%
Applied egg-rr97.5%
Final simplification97.5%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* (* c s) x))) (* (/ 1.0 t_0) (/ (cos (* x -2.0)) t_0))))
double code(double x, double c, double s) {
double t_0 = (c * s) * x;
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 * s) * x
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 * s) * x;
return (1.0 / t_0) * (Math.cos((x * -2.0)) / t_0);
}
def code(x, c, s): t_0 = (c * s) * x return (1.0 / t_0) * (math.cos((x * -2.0)) / t_0)
function code(x, c, s) t_0 = Float64(Float64(c * s) * x) 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 * s) * x; tmp = (1.0 / t_0) * (cos((x * -2.0)) / t_0); end
code[x_, c_, s_] := Block[{t$95$0 = N[(N[(c * s), $MachinePrecision] * x), $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 := \left(c \cdot s\right) \cdot x\\
\frac{1}{t\_0} \cdot \frac{\cos \left(x \cdot -2\right)}{t\_0}
\end{array}
\end{array}
Initial program 69.7%
associate-/r*69.2%
cos-neg69.2%
distribute-rgt-neg-out69.2%
distribute-rgt-neg-out69.2%
*-commutative69.2%
distribute-rgt-neg-in69.2%
metadata-eval69.2%
*-commutative69.2%
associate-*l*64.1%
unpow264.1%
Simplified64.1%
Taylor expanded in x around inf 64.6%
associate-/r*64.1%
*-commutative64.1%
unpow264.1%
unpow264.1%
swap-sqr79.5%
unpow279.5%
associate-/r*80.0%
*-commutative80.0%
unpow280.0%
unpow280.0%
swap-sqr97.2%
unpow297.2%
*-commutative97.2%
Simplified97.2%
unpow-prod-down80.0%
*-commutative80.0%
unpow-prod-down64.6%
/-rgt-identity64.6%
clear-num64.6%
div-inv64.6%
clear-num64.6%
div-inv64.6%
unpow264.6%
associate-/l/64.6%
unpow-prod-down80.0%
*-commutative80.0%
pow-flip80.3%
*-commutative80.3%
metadata-eval80.3%
sqr-pow80.3%
times-frac97.1%
Applied egg-rr97.6%
associate-/r*97.5%
div-inv97.5%
associate-/r/95.4%
div-inv95.4%
clear-num95.4%
/-rgt-identity95.4%
associate-/r/97.5%
div-inv97.4%
clear-num97.4%
/-rgt-identity97.4%
Applied egg-rr97.4%
Final simplification97.4%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* (* c s) x))) (/ (cos (* x -2.0)) (/ t_0 (/ 1.0 t_0)))))
double code(double x, double c, double s) {
double t_0 = (c * s) * x;
return cos((x * -2.0)) / (t_0 / (1.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 / (1.0d0 / 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 / (1.0 / t_0));
}
def code(x, c, s): t_0 = (c * s) * x return math.cos((x * -2.0)) / (t_0 / (1.0 / t_0))
function code(x, c, s) t_0 = Float64(Float64(c * s) * x) return Float64(cos(Float64(x * -2.0)) / Float64(t_0 / Float64(1.0 / t_0))) end
function tmp = code(x, c, s) t_0 = (c * s) * x; tmp = cos((x * -2.0)) / (t_0 / (1.0 / t_0)); end
code[x_, c_, s_] := Block[{t$95$0 = N[(N[(c * s), $MachinePrecision] * x), $MachinePrecision]}, N[(N[Cos[N[(x * -2.0), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 / N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(c \cdot s\right) \cdot x\\
\frac{\cos \left(x \cdot -2\right)}{\frac{t\_0}{\frac{1}{t\_0}}}
\end{array}
\end{array}
Initial program 69.7%
associate-/r*69.2%
cos-neg69.2%
distribute-rgt-neg-out69.2%
distribute-rgt-neg-out69.2%
*-commutative69.2%
distribute-rgt-neg-in69.2%
metadata-eval69.2%
*-commutative69.2%
associate-*l*64.1%
unpow264.1%
Simplified64.1%
Taylor expanded in x around inf 64.6%
associate-/r*64.1%
*-commutative64.1%
unpow264.1%
unpow264.1%
swap-sqr79.5%
unpow279.5%
associate-/r*80.0%
*-commutative80.0%
unpow280.0%
unpow280.0%
swap-sqr97.2%
unpow297.2%
*-commutative97.2%
Simplified97.2%
unpow-prod-down80.0%
*-commutative80.0%
unpow-prod-down64.6%
/-rgt-identity64.6%
clear-num64.6%
div-inv64.6%
clear-num64.6%
div-inv64.6%
unpow264.6%
associate-/l/64.6%
unpow-prod-down80.0%
*-commutative80.0%
pow-flip80.3%
*-commutative80.3%
metadata-eval80.3%
sqr-pow80.3%
times-frac97.1%
Applied egg-rr97.6%
clear-num97.5%
clear-num97.5%
div-inv97.0%
associate-/l/97.1%
*-commutative97.1%
remove-double-div97.1%
inv-pow97.1%
metadata-eval97.1%
un-div-inv97.2%
associate-/r/95.1%
div-inv95.1%
clear-num95.1%
/-rgt-identity95.1%
metadata-eval95.1%
inv-pow95.1%
associate-*r*97.5%
Applied egg-rr97.5%
Final simplification97.5%
(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 69.7%
associate-/r*69.2%
cos-neg69.2%
distribute-rgt-neg-out69.2%
distribute-rgt-neg-out69.2%
*-commutative69.2%
distribute-rgt-neg-in69.2%
metadata-eval69.2%
*-commutative69.2%
associate-*l*64.1%
unpow264.1%
Simplified64.1%
Taylor expanded in x around inf 64.6%
associate-/r*64.1%
*-commutative64.1%
unpow264.1%
unpow264.1%
swap-sqr79.5%
unpow279.5%
associate-/r*80.0%
*-commutative80.0%
unpow280.0%
unpow280.0%
swap-sqr97.2%
unpow297.2%
*-commutative97.2%
Simplified97.2%
unpow279.2%
Applied egg-rr97.2%
Final simplification97.2%
(FPCore (x c s) :precision binary64 (let* ((t_0 (/ c (/ (/ 1.0 s) x)))) (/ 1.0 (* t_0 t_0))))
double code(double x, double c, double s) {
double t_0 = c / ((1.0 / 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 / ((1.0d0 / 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 / ((1.0 / s) / x);
return 1.0 / (t_0 * t_0);
}
def code(x, c, s): t_0 = c / ((1.0 / s) / x) return 1.0 / (t_0 * t_0)
function code(x, c, s) t_0 = Float64(c / Float64(Float64(1.0 / s) / x)) return Float64(1.0 / Float64(t_0 * t_0)) end
function tmp = code(x, c, s) t_0 = c / ((1.0 / s) / x); tmp = 1.0 / (t_0 * t_0); end
code[x_, c_, s_] := Block[{t$95$0 = N[(c / N[(N[(1.0 / s), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c}{\frac{\frac{1}{s}}{x}}\\
\frac{1}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 69.7%
Taylor expanded in x around 0 57.9%
associate-/r*57.5%
*-commutative57.5%
unpow257.5%
unpow257.5%
swap-sqr68.0%
unpow268.0%
associate-/r*68.5%
unpow268.5%
unpow268.5%
swap-sqr79.2%
unpow279.2%
*-commutative79.2%
Simplified79.2%
unpow-prod-down80.0%
*-commutative80.0%
unpow-prod-down64.6%
/-rgt-identity64.6%
clear-num64.6%
div-inv64.6%
clear-num64.6%
div-inv64.6%
unpow264.6%
associate-/l/64.6%
unpow-prod-down80.0%
*-commutative80.0%
pow-flip80.3%
*-commutative80.3%
metadata-eval80.3%
sqr-pow80.3%
times-frac97.1%
Applied egg-rr79.3%
Final simplification79.3%
(FPCore (x c s) :precision binary64 (let* ((t_0 (/ (/ (/ 1.0 s) x) c))) (* t_0 t_0)))
double code(double x, double c, double s) {
double t_0 = ((1.0 / s) / x) / 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 / s) / x) / c
code = t_0 * t_0
end function
public static double code(double x, double c, double s) {
double t_0 = ((1.0 / s) / x) / c;
return t_0 * t_0;
}
def code(x, c, s): t_0 = ((1.0 / s) / x) / c return t_0 * t_0
function code(x, c, s) t_0 = Float64(Float64(Float64(1.0 / s) / x) / c) return Float64(t_0 * t_0) end
function tmp = code(x, c, s) t_0 = ((1.0 / s) / x) / c; tmp = t_0 * t_0; end
code[x_, c_, s_] := Block[{t$95$0 = N[(N[(N[(1.0 / s), $MachinePrecision] / x), $MachinePrecision] / c), $MachinePrecision]}, N[(t$95$0 * t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{\frac{1}{s}}{x}}{c}\\
t\_0 \cdot t\_0
\end{array}
\end{array}
Initial program 69.7%
Taylor expanded in x around 0 57.9%
associate-/r*57.5%
*-commutative57.5%
unpow257.5%
unpow257.5%
swap-sqr68.0%
unpow268.0%
associate-/r*68.5%
unpow268.5%
unpow268.5%
swap-sqr79.2%
unpow279.2%
*-commutative79.2%
Simplified79.2%
metadata-eval79.2%
*-commutative79.2%
unpow-prod-down68.5%
*-commutative68.5%
frac-times68.0%
unpow-prod-down57.5%
associate-/l/57.5%
div-inv57.9%
add-sqr-sqrt57.9%
Applied egg-rr79.2%
Final simplification79.2%
(FPCore (x c s) :precision binary64 (/ 1.0 (* c (* s (* c (* x (* s x)))))))
double code(double x, double c, double s) {
return 1.0 / (c * (s * (c * (x * (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 * (c * (x * (s * x)))))
end function
public static double code(double x, double c, double s) {
return 1.0 / (c * (s * (c * (x * (s * x)))));
}
def code(x, c, s): return 1.0 / (c * (s * (c * (x * (s * x)))))
function code(x, c, s) return Float64(1.0 / Float64(c * Float64(s * Float64(c * Float64(x * Float64(s * x)))))) end
function tmp = code(x, c, s) tmp = 1.0 / (c * (s * (c * (x * (s * x))))); end
code[x_, c_, s_] := N[(1.0 / N[(c * N[(s * N[(c * N[(x * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{c \cdot \left(s \cdot \left(c \cdot \left(x \cdot \left(s \cdot x\right)\right)\right)\right)}
\end{array}
Initial program 69.7%
Taylor expanded in x around 0 57.9%
associate-/r*57.5%
*-commutative57.5%
unpow257.5%
unpow257.5%
swap-sqr68.0%
unpow268.0%
associate-/r*68.5%
unpow268.5%
unpow268.5%
swap-sqr79.2%
unpow279.2%
*-commutative79.2%
Simplified79.2%
/-rgt-identity79.2%
clear-num79.2%
pow-flip79.2%
metadata-eval79.2%
Applied egg-rr79.2%
pow-flip79.2%
remove-double-div79.1%
*-commutative79.1%
associate-/l/79.1%
div-inv79.3%
metadata-eval79.3%
pow279.3%
associate-*l/76.1%
*-un-lft-identity76.1%
times-frac78.1%
/-rgt-identity78.1%
associate-/r/76.9%
div-inv76.9%
clear-num76.9%
/-rgt-identity76.9%
associate-/l/76.9%
*-commutative76.9%
Applied egg-rr76.9%
associate-/l*73.3%
*-commutative73.3%
associate-*l*73.9%
div-inv73.9%
remove-double-div73.9%
Applied egg-rr73.9%
Final simplification73.9%
(FPCore (x c s) :precision binary64 (/ 1.0 (* c (* (* s x) (* c (* s x))))))
double code(double x, double c, double s) {
return 1.0 / (c * ((s * x) * (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) * (c * (s * x))))
end function
public static double code(double x, double c, double s) {
return 1.0 / (c * ((s * x) * (c * (s * x))));
}
def code(x, c, s): return 1.0 / (c * ((s * x) * (c * (s * x))))
function code(x, c, s) return Float64(1.0 / Float64(c * Float64(Float64(s * x) * Float64(c * Float64(s * x))))) end
function tmp = code(x, c, s) tmp = 1.0 / (c * ((s * x) * (c * (s * x)))); end
code[x_, c_, s_] := N[(1.0 / N[(c * N[(N[(s * x), $MachinePrecision] * N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{c \cdot \left(\left(s \cdot x\right) \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)}
\end{array}
Initial program 69.7%
Taylor expanded in x around 0 57.9%
associate-/r*57.5%
*-commutative57.5%
unpow257.5%
unpow257.5%
swap-sqr68.0%
unpow268.0%
associate-/r*68.5%
unpow268.5%
unpow268.5%
swap-sqr79.2%
unpow279.2%
*-commutative79.2%
Simplified79.2%
/-rgt-identity79.2%
clear-num79.2%
pow-flip79.2%
metadata-eval79.2%
Applied egg-rr79.2%
pow-flip79.2%
remove-double-div79.1%
*-commutative79.1%
associate-/l/79.1%
div-inv79.3%
metadata-eval79.3%
pow279.3%
associate-*l/76.1%
*-un-lft-identity76.1%
times-frac78.1%
/-rgt-identity78.1%
associate-/r/76.9%
div-inv76.9%
clear-num76.9%
/-rgt-identity76.9%
associate-/l/76.9%
*-commutative76.9%
Applied egg-rr76.9%
associate-/r/76.9%
/-rgt-identity76.9%
*-commutative76.9%
associate-*r*78.1%
Applied egg-rr78.1%
Final simplification78.1%
(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 69.7%
Taylor expanded in x around 0 57.9%
associate-/r*57.5%
*-commutative57.5%
unpow257.5%
unpow257.5%
swap-sqr68.0%
unpow268.0%
associate-/r*68.5%
unpow268.5%
unpow268.5%
swap-sqr79.2%
unpow279.2%
*-commutative79.2%
Simplified79.2%
unpow279.2%
Applied egg-rr79.2%
Final simplification79.2%
herbie shell --seed 2024075
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))