
(FPCore (x) :precision binary64 (* (cos x) (exp (* 10.0 (* x x)))))
double code(double x) {
return cos(x) * exp((10.0 * (x * x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = cos(x) * exp((10.0d0 * (x * x)))
end function
public static double code(double x) {
return Math.cos(x) * Math.exp((10.0 * (x * x)));
}
def code(x): return math.cos(x) * math.exp((10.0 * (x * x)))
function code(x) return Float64(cos(x) * exp(Float64(10.0 * Float64(x * x)))) end
function tmp = code(x) tmp = cos(x) * exp((10.0 * (x * x))); end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Exp[N[(10.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot e^{10 \cdot \left(x \cdot x\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (* (cos x) (exp (* 10.0 (* x x)))))
double code(double x) {
return cos(x) * exp((10.0 * (x * x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = cos(x) * exp((10.0d0 * (x * x)))
end function
public static double code(double x) {
return Math.cos(x) * Math.exp((10.0 * (x * x)));
}
def code(x): return math.cos(x) * math.exp((10.0 * (x * x)))
function code(x) return Float64(cos(x) * exp(Float64(10.0 * Float64(x * x)))) end
function tmp = code(x) tmp = cos(x) * exp((10.0 * (x * x))); end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Exp[N[(10.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot e^{10 \cdot \left(x \cdot x\right)}
\end{array}
(FPCore (x) :precision binary64 (* (cos x) (sqrt (cbrt (pow (pow (exp 60.0) x) x)))))
double code(double x) {
return cos(x) * sqrt(cbrt(pow(pow(exp(60.0), x), x)));
}
public static double code(double x) {
return Math.cos(x) * Math.sqrt(Math.cbrt(Math.pow(Math.pow(Math.exp(60.0), x), x)));
}
function code(x) return Float64(cos(x) * sqrt(cbrt(((exp(60.0) ^ x) ^ x)))) end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Sqrt[N[Power[N[Power[N[Power[N[Exp[60.0], $MachinePrecision], x], $MachinePrecision], x], $MachinePrecision], 1/3], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot \sqrt{\sqrt[3]{{\left({\left(e^{60}\right)}^{x}\right)}^{x}}}
\end{array}
Initial program 94.6%
associate-*r*94.6%
add-log-exp94.6%
log-pow94.5%
pow-pow94.9%
add-exp-log96.8%
add-cbrt-cube96.8%
add-exp-log96.5%
pow-pow96.2%
log-pow96.4%
add-log-exp96.4%
associate-*r*96.4%
pow-exp96.8%
*-commutative96.8%
Applied egg-rr98.8%
add-sqr-sqrt98.7%
sqrt-unprod98.8%
pow-prod-down98.8%
prod-exp99.1%
metadata-eval99.1%
Applied egg-rr99.1%
add-sqr-sqrt98.9%
sqrt-unprod99.1%
cbrt-unprod99.2%
pow-prod-down99.3%
add-sqr-sqrt99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x) :precision binary64 (* (cos x) (cbrt (pow (sqrt (pow (exp 60.0) x)) x))))
double code(double x) {
return cos(x) * cbrt(pow(sqrt(pow(exp(60.0), x)), x));
}
public static double code(double x) {
return Math.cos(x) * Math.cbrt(Math.pow(Math.sqrt(Math.pow(Math.exp(60.0), x)), x));
}
function code(x) return Float64(cos(x) * cbrt((sqrt((exp(60.0) ^ x)) ^ x))) end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[Power[N[Sqrt[N[Power[N[Exp[60.0], $MachinePrecision], x], $MachinePrecision]], $MachinePrecision], x], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot \sqrt[3]{{\left(\sqrt{{\left(e^{60}\right)}^{x}}\right)}^{x}}
\end{array}
Initial program 94.6%
associate-*r*94.6%
add-log-exp94.6%
log-pow94.5%
pow-pow94.9%
add-exp-log96.8%
add-cbrt-cube96.8%
add-exp-log96.5%
pow-pow96.2%
log-pow96.4%
add-log-exp96.4%
associate-*r*96.4%
pow-exp96.8%
*-commutative96.8%
Applied egg-rr98.8%
add-sqr-sqrt98.7%
sqrt-unprod98.8%
pow-prod-down98.8%
prod-exp99.1%
metadata-eval99.1%
Applied egg-rr99.1%
Final simplification99.1%
(FPCore (x) :precision binary64 (* (cos x) (cbrt (pow (pow (exp 30.0) x) x))))
double code(double x) {
return cos(x) * cbrt(pow(pow(exp(30.0), x), x));
}
public static double code(double x) {
return Math.cos(x) * Math.cbrt(Math.pow(Math.pow(Math.exp(30.0), x), x));
}
function code(x) return Float64(cos(x) * cbrt(((exp(30.0) ^ x) ^ x))) end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[Power[N[Power[N[Exp[30.0], $MachinePrecision], x], $MachinePrecision], x], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot \sqrt[3]{{\left({\left(e^{30}\right)}^{x}\right)}^{x}}
\end{array}
Initial program 94.6%
associate-*r*94.6%
add-log-exp94.6%
log-pow94.5%
pow-pow94.9%
add-exp-log96.8%
add-cbrt-cube96.8%
add-exp-log96.5%
pow-pow96.2%
log-pow96.4%
add-log-exp96.4%
associate-*r*96.4%
pow-exp96.8%
*-commutative96.8%
Applied egg-rr98.8%
Final simplification98.8%
(FPCore (x) :precision binary64 (* (cos x) (pow (pow (exp 10.0) x) x)))
double code(double x) {
return cos(x) * pow(pow(exp(10.0), x), x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = cos(x) * ((exp(10.0d0) ** x) ** x)
end function
public static double code(double x) {
return Math.cos(x) * Math.pow(Math.pow(Math.exp(10.0), x), x);
}
def code(x): return math.cos(x) * math.pow(math.pow(math.exp(10.0), x), x)
function code(x) return Float64(cos(x) * ((exp(10.0) ^ x) ^ x)) end
function tmp = code(x) tmp = cos(x) * ((exp(10.0) ^ x) ^ x); end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[Power[N[Exp[10.0], $MachinePrecision], x], $MachinePrecision], x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{x}
\end{array}
Initial program 94.6%
associate-*r*94.6%
exp-prod95.0%
sqr-pow95.0%
sqr-pow95.0%
exp-prod97.9%
Simplified97.9%
Final simplification97.9%
(FPCore (x) :precision binary64 (* (cos x) (cbrt (exp (* x (* x 30.0))))))
double code(double x) {
return cos(x) * cbrt(exp((x * (x * 30.0))));
}
public static double code(double x) {
return Math.cos(x) * Math.cbrt(Math.exp((x * (x * 30.0))));
}
function code(x) return Float64(cos(x) * cbrt(exp(Float64(x * Float64(x * 30.0))))) end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[Exp[N[(x * N[(x * 30.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot \sqrt[3]{e^{x \cdot \left(x \cdot 30\right)}}
\end{array}
Initial program 94.6%
associate-*r*94.6%
add-log-exp94.6%
log-pow94.5%
pow-pow94.9%
add-exp-log96.8%
add-cbrt-cube96.8%
add-exp-log96.5%
pow-pow96.2%
log-pow96.4%
add-log-exp96.4%
associate-*r*96.4%
pow-exp96.8%
*-commutative96.8%
Applied egg-rr98.8%
add-exp-log95.6%
log-pow95.3%
pow-exp95.4%
add-log-exp95.4%
Applied egg-rr95.4%
Final simplification95.4%
(FPCore (x) :precision binary64 (* (cos x) (pow (exp 10.0) (* x x))))
double code(double x) {
return cos(x) * pow(exp(10.0), (x * x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = cos(x) * (exp(10.0d0) ** (x * x))
end function
public static double code(double x) {
return Math.cos(x) * Math.pow(Math.exp(10.0), (x * x));
}
def code(x): return math.cos(x) * math.pow(math.exp(10.0), (x * x))
function code(x) return Float64(cos(x) * (exp(10.0) ^ Float64(x * x))) end
function tmp = code(x) tmp = cos(x) * (exp(10.0) ^ (x * x)); end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[Exp[10.0], $MachinePrecision], N[(x * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot {\left(e^{10}\right)}^{\left(x \cdot x\right)}
\end{array}
Initial program 94.6%
exp-prod95.2%
Simplified95.2%
Final simplification95.2%
(FPCore (x) :precision binary64 (* (cos x) (exp (* 10.0 (* x x)))))
double code(double x) {
return cos(x) * exp((10.0 * (x * x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = cos(x) * exp((10.0d0 * (x * x)))
end function
public static double code(double x) {
return Math.cos(x) * Math.exp((10.0 * (x * x)));
}
def code(x): return math.cos(x) * math.exp((10.0 * (x * x)))
function code(x) return Float64(cos(x) * exp(Float64(10.0 * Float64(x * x)))) end
function tmp = code(x) tmp = cos(x) * exp((10.0 * (x * x))); end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Exp[N[(10.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot e^{10 \cdot \left(x \cdot x\right)}
\end{array}
Initial program 94.6%
Final simplification94.6%
(FPCore (x) :precision binary64 (* (cos x) (exp (* x (* x 10.0)))))
double code(double x) {
return cos(x) * exp((x * (x * 10.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = cos(x) * exp((x * (x * 10.0d0)))
end function
public static double code(double x) {
return Math.cos(x) * Math.exp((x * (x * 10.0)));
}
def code(x): return math.cos(x) * math.exp((x * (x * 10.0)))
function code(x) return Float64(cos(x) * exp(Float64(x * Float64(x * 10.0)))) end
function tmp = code(x) tmp = cos(x) * exp((x * (x * 10.0))); end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Exp[N[(x * N[(x * 10.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot e^{x \cdot \left(x \cdot 10\right)}
\end{array}
Initial program 94.6%
associate-*r*94.6%
add-log-exp94.6%
log-pow94.5%
pow-pow94.9%
add-exp-log96.8%
pow-pow94.7%
add-sqr-sqrt94.4%
unpow-prod-down94.4%
pow-prod-up94.3%
add-log-exp94.3%
log-pow94.3%
add-log-exp94.3%
log-pow94.2%
sum-log94.2%
pow-prod-down94.3%
prod-exp94.4%
pow-exp94.3%
add-log-exp94.3%
log-pow94.3%
pow-prod-up94.3%
add-exp-log94.3%
Applied egg-rr94.3%
add-exp-log94.2%
sqrt-pow294.5%
log-pow94.6%
associate-/l*93.9%
metadata-eval93.9%
div-inv94.6%
metadata-eval94.6%
add-log-exp94.6%
Applied egg-rr94.6%
Final simplification94.6%
(FPCore (x) :precision binary64 (* x (* x -0.5)))
double code(double x) {
return x * (x * -0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * (x * (-0.5d0))
end function
public static double code(double x) {
return x * (x * -0.5);
}
def code(x): return x * (x * -0.5)
function code(x) return Float64(x * Float64(x * -0.5)) end
function tmp = code(x) tmp = x * (x * -0.5); end
code[x_] := N[(x * N[(x * -0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(x \cdot -0.5\right)
\end{array}
Initial program 94.6%
associate-*r*94.6%
add-log-exp94.6%
log-pow94.5%
pow-pow94.9%
add-exp-log96.8%
pow-pow94.7%
add-sqr-sqrt93.0%
pow-unpow93.2%
Applied egg-rr93.2%
metadata-eval93.2%
associate-*r*93.2%
metadata-eval93.2%
associate-/r/93.6%
associate-*r/93.6%
metadata-eval93.6%
associate-/l*93.2%
*-commutative93.2%
associate-/l*93.8%
metadata-eval93.8%
metadata-eval93.8%
associate-*r*93.8%
metadata-eval93.8%
associate-/r/93.6%
associate-*r/93.6%
metadata-eval93.6%
associate-/l*93.8%
*-commutative93.8%
associate-/l*93.0%
metadata-eval93.0%
Simplified93.0%
Taylor expanded in x around 0 9.7%
*-commutative9.7%
unpow29.7%
Simplified9.7%
Taylor expanded in x around inf 9.7%
*-commutative9.7%
unpow29.7%
associate-*r*9.7%
Simplified9.7%
Final simplification9.7%
herbie shell --seed 2023174
(FPCore (x)
:name "ENA, Section 1.4, Exercise 1"
:precision binary64
:pre (and (<= 1.99 x) (<= x 2.01))
(* (cos x) (exp (* 10.0 (* x x)))))