
(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 23 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 (pow (exp 20.0) x) (- x)) -0.5)))
double code(double x) {
return cos(x) * pow(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.pow(Math.exp(20.0), x), -x), -0.5);
}
def code(x): return math.cos(x) * math.pow(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[Power[N[Exp[20.0], $MachinePrecision], x], $MachinePrecision], (-x)], $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot {\left({\left({\left(e^{20}\right)}^{x}\right)}^{\left(-x\right)}\right)}^{-0.5}
\end{array}
Initial program 94.3%
lift-exp.f64N/A
lift-*.f64N/A
exp-prodN/A
sqr-powN/A
pow-prod-downN/A
frac-2negN/A
div-invN/A
pow-unpowN/A
lower-pow.f64N/A
Applied rewrites95.1%
lift-pow.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-rgt-neg-outN/A
neg-mul-1N/A
pow-unpowN/A
remove-double-negN/A
distribute-rgt-neg-outN/A
lift-neg.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-neg.f64N/A
pow-unpowN/A
lower-pow.f64N/A
Applied rewrites99.3%
lift-pow.f64N/A
lift-exp.f64N/A
pow-expN/A
lift-neg.f64N/A
neg-mul-1N/A
associate-*r*N/A
metadata-evalN/A
rem-log-expN/A
pow-to-expN/A
lower-pow.f64N/A
rem-log-expN/A
lower-exp.f64N/A
rem-log-exp99.4
Applied rewrites99.4%
(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) ^ Float64(-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)}^{\left(-x\right)}\right)}^{\left(x \cdot 0.5\right)}
\end{array}
Initial program 94.4%
lift-exp.f64N/A
lift-*.f64N/A
exp-prodN/A
sqr-powN/A
pow-prod-downN/A
frac-2negN/A
div-invN/A
pow-unpowN/A
lower-pow.f64N/A
Applied rewrites95.3%
lift-pow.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-rgt-neg-outN/A
neg-mul-1N/A
pow-unpowN/A
remove-double-negN/A
distribute-rgt-neg-outN/A
lift-neg.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-neg.f64N/A
pow-unpowN/A
lower-pow.f64N/A
Applied rewrites99.3%
lift-pow.f64N/A
lift-exp.f64N/A
pow-expN/A
lift-neg.f64N/A
neg-mul-1N/A
associate-*r*N/A
metadata-evalN/A
rem-log-expN/A
pow-to-expN/A
lower-pow.f64N/A
rem-log-expN/A
lower-exp.f64N/A
rem-log-exp99.4
Applied rewrites99.4%
Applied rewrites99.3%
herbie shell --seed 2024228
(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)))))