
(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) (pow (pow (exp 20.0) x) (* x 0.5))))
double code(double x) {
return cos(x) * pow(pow(exp(20.0), x), (x * 0.5));
}
real(8) function code(x)
real(8), intent (in) :: x
code = cos(x) * ((exp(20.0d0) ** x) ** (x * 0.5d0))
end function
public static double code(double x) {
return Math.cos(x) * Math.pow(Math.pow(Math.exp(20.0), x), (x * 0.5));
}
def code(x): return math.cos(x) * math.pow(math.pow(math.exp(20.0), x), (x * 0.5))
function code(x) return Float64(cos(x) * ((exp(20.0) ^ x) ^ Float64(x * 0.5))) end
function tmp = code(x) tmp = cos(x) * ((exp(20.0) ^ x) ^ (x * 0.5)); end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[Power[N[Exp[20.0], $MachinePrecision], x], $MachinePrecision], N[(x * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot {\left({\left(e^{20}\right)}^{x}\right)}^{\left(x \cdot 0.5\right)}
\end{array}
Initial program 94.5%
pow-exp95.2%
add-cbrt-cube95.2%
pow395.2%
pow295.2%
Applied egg-rr95.2%
rem-cbrt-cube95.2%
unpow295.2%
pow-pow97.9%
sqr-pow98.0%
pow-prod-down97.9%
pow-prod-down98.0%
prod-exp99.4%
metadata-eval99.4%
div-inv99.4%
metadata-eval99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x) :precision binary64 (* (cos x) (pow (exp (pow x 2.0)) 10.0)))
double code(double x) {
return cos(x) * pow(exp(pow(x, 2.0)), 10.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = cos(x) * (exp((x ** 2.0d0)) ** 10.0d0)
end function
public static double code(double x) {
return Math.cos(x) * Math.pow(Math.exp(Math.pow(x, 2.0)), 10.0);
}
def code(x): return math.cos(x) * math.pow(math.exp(math.pow(x, 2.0)), 10.0)
function code(x) return Float64(cos(x) * (exp((x ^ 2.0)) ^ 10.0)) end
function tmp = code(x) tmp = cos(x) * (exp((x ^ 2.0)) ^ 10.0); end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[Exp[N[Power[x, 2.0], $MachinePrecision]], $MachinePrecision], 10.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot {\left(e^{{x}^{2}}\right)}^{10}
\end{array}
Initial program 94.5%
cos-neg94.5%
sqr-neg94.5%
*-commutative94.5%
distribute-lft-neg-out94.5%
distribute-lft-neg-out94.5%
exp-neg94.5%
metadata-eval94.5%
associate-*r/94.5%
metadata-eval94.5%
*-rgt-identity94.5%
cos-neg94.5%
metadata-eval94.5%
metadata-eval94.5%
distribute-rgt-neg-in94.5%
distribute-lft-neg-in94.5%
distribute-lft-neg-out94.5%
exp-prod95.2%
sqr-neg95.2%
exp-prod96.7%
Simplified96.7%
Taylor expanded in x around inf 95.3%
Final simplification95.3%
(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.5%
pow-exp95.2%
pow-unpow97.9%
Applied egg-rr97.9%
Final simplification97.9%
(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}
\\
\frac{\cos x}{{\left({\left(e^{-10}\right)}^{x}\right)}^{x}}
\end{array}
Initial program 94.5%
cos-neg94.5%
sqr-neg94.5%
*-commutative94.5%
distribute-lft-neg-out94.5%
distribute-lft-neg-out94.5%
exp-neg94.5%
metadata-eval94.5%
associate-*r/94.5%
metadata-eval94.5%
*-rgt-identity94.5%
cos-neg94.5%
associate-*l*94.4%
*-commutative94.4%
exp-prod94.8%
distribute-rgt-neg-out94.8%
*-commutative94.8%
distribute-rgt-neg-in94.8%
metadata-eval94.8%
Simplified94.8%
add-sqr-sqrt94.3%
unpow-prod-down94.2%
Applied egg-rr94.2%
pow-sqr94.2%
*-commutative94.2%
associate-*r*94.2%
metadata-eval94.2%
Simplified94.2%
sqrt-pow294.8%
pow-exp94.4%
*-commutative94.4%
associate-/l*93.8%
metadata-eval93.8%
Applied egg-rr93.8%
associate-*r/94.2%
unpow294.2%
div-inv94.5%
metadata-eval94.5%
rem-log-exp94.5%
log-pow94.5%
add-exp-log95.2%
unpow295.2%
pow-unpow98.1%
Applied egg-rr98.1%
Final simplification98.1%
(FPCore (x) :precision binary64 (* (cos x) (pow (exp (* x 10.0)) x)))
double code(double x) {
return cos(x) * pow(exp((x * 10.0)), x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = cos(x) * (exp((x * 10.0d0)) ** x)
end function
public static double code(double x) {
return Math.cos(x) * Math.pow(Math.exp((x * 10.0)), x);
}
def code(x): return math.cos(x) * math.pow(math.exp((x * 10.0)), x)
function code(x) return Float64(cos(x) * (exp(Float64(x * 10.0)) ^ x)) end
function tmp = code(x) tmp = cos(x) * (exp((x * 10.0)) ^ x); end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[Exp[N[(x * 10.0), $MachinePrecision]], $MachinePrecision], x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot {\left(e^{x \cdot 10}\right)}^{x}
\end{array}
Initial program 94.5%
pow-exp95.2%
pow-unpow97.9%
Applied egg-rr97.9%
add-exp-log95.0%
log-pow95.0%
rem-log-exp95.0%
Applied egg-rr95.0%
Final simplification95.0%
(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.5%
cos-neg94.5%
*-commutative94.5%
exp-prod95.2%
cos-neg95.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.5%
Final simplification94.5%
(FPCore (x) :precision binary64 (cos x))
double code(double x) {
return cos(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = cos(x)
end function
public static double code(double x) {
return Math.cos(x);
}
def code(x): return math.cos(x)
function code(x) return cos(x) end
function tmp = code(x) tmp = cos(x); end
code[x_] := N[Cos[x], $MachinePrecision]
\begin{array}{l}
\\
\cos x
\end{array}
Initial program 94.5%
Taylor expanded in x around 0 9.6%
Final simplification9.6%
(FPCore (x) :precision binary64 1.0)
double code(double x) {
return 1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0
end function
public static double code(double x) {
return 1.0;
}
def code(x): return 1.0
function code(x) return 1.0 end
function tmp = code(x) tmp = 1.0; end
code[x_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 94.5%
pow-exp95.2%
add-cbrt-cube95.2%
pow395.2%
pow295.2%
Applied egg-rr95.2%
rem-cbrt-cube95.2%
unpow295.2%
pow-pow97.9%
sqr-pow98.0%
pow-prod-down97.9%
pow-prod-down98.0%
prod-exp99.4%
metadata-eval99.4%
div-inv99.4%
metadata-eval99.4%
Applied egg-rr99.4%
Taylor expanded in x around 0 1.5%
Final simplification1.5%
herbie shell --seed 2023336
(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)))))