
(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 11 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 (* (pow (pow (exp 20.0) x) (* x 0.5)) (cos x)))
double code(double x) {
return pow(pow(exp(20.0), x), (x * 0.5)) * cos(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((exp(20.0d0) ** x) ** (x * 0.5d0)) * cos(x)
end function
public static double code(double x) {
return Math.pow(Math.pow(Math.exp(20.0), x), (x * 0.5)) * Math.cos(x);
}
def code(x): return math.pow(math.pow(math.exp(20.0), x), (x * 0.5)) * math.cos(x)
function code(x) return Float64(((exp(20.0) ^ x) ^ Float64(x * 0.5)) * cos(x)) end
function tmp = code(x) tmp = ((exp(20.0) ^ x) ^ (x * 0.5)) * cos(x); end
code[x_] := N[(N[Power[N[Power[N[Exp[20.0], $MachinePrecision], x], $MachinePrecision], N[(x * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left({\left(e^{20}\right)}^{x}\right)}^{\left(x \cdot 0.5\right)} \cdot \cos x
\end{array}
Initial program 94.5%
cos-neg94.5%
*-commutative94.5%
cos-neg94.5%
Simplified94.5%
pow-exp95.4%
pow-pow98.0%
sqr-pow98.0%
pow-prod-down98.0%
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 (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%
cos-neg94.5%
*-commutative94.5%
associate-*r*94.5%
exp-prod95.2%
exp-prod98.0%
cos-neg98.0%
Simplified98.0%
Final simplification98.0%
(FPCore (x) :precision binary64 (* (cos x) (pow (exp 20.0) (* 0.5 (* x x)))))
double code(double x) {
return cos(x) * pow(exp(20.0), (0.5 * (x * x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = cos(x) * (exp(20.0d0) ** (0.5d0 * (x * x)))
end function
public static double code(double x) {
return Math.cos(x) * Math.pow(Math.exp(20.0), (0.5 * (x * x)));
}
def code(x): return math.cos(x) * math.pow(math.exp(20.0), (0.5 * (x * x)))
function code(x) return Float64(cos(x) * (exp(20.0) ^ Float64(0.5 * Float64(x * x)))) end
function tmp = code(x) tmp = cos(x) * (exp(20.0) ^ (0.5 * (x * x))); end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[Exp[20.0], $MachinePrecision], N[(0.5 * N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot {\left(e^{20}\right)}^{\left(0.5 \cdot \left(x \cdot x\right)\right)}
\end{array}
Initial program 94.5%
cos-neg94.5%
*-commutative94.5%
cos-neg94.5%
Simplified94.5%
pow-exp95.4%
sqr-pow95.4%
pow-prod-down95.4%
prod-exp95.4%
metadata-eval95.4%
div-inv95.4%
metadata-eval95.4%
Applied egg-rr95.4%
Final simplification95.4%
(FPCore (x) :precision binary64 (* (cos x) (pow (exp 40.0) (* (* x x) 0.25))))
double code(double x) {
return cos(x) * pow(exp(40.0), ((x * x) * 0.25));
}
real(8) function code(x)
real(8), intent (in) :: x
code = cos(x) * (exp(40.0d0) ** ((x * x) * 0.25d0))
end function
public static double code(double x) {
return Math.cos(x) * Math.pow(Math.exp(40.0), ((x * x) * 0.25));
}
def code(x): return math.cos(x) * math.pow(math.exp(40.0), ((x * x) * 0.25))
function code(x) return Float64(cos(x) * (exp(40.0) ^ Float64(Float64(x * x) * 0.25))) end
function tmp = code(x) tmp = cos(x) * (exp(40.0) ^ ((x * x) * 0.25)); end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[Exp[40.0], $MachinePrecision], N[(N[(x * x), $MachinePrecision] * 0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot {\left(e^{40}\right)}^{\left(\left(x \cdot x\right) \cdot 0.25\right)}
\end{array}
Initial program 94.5%
cos-neg94.5%
*-commutative94.5%
cos-neg94.5%
Simplified94.5%
pow-exp95.4%
add-sqr-sqrt95.4%
sqrt-unprod95.4%
pow-prod-down95.4%
pow-pow98.0%
prod-exp99.4%
metadata-eval99.4%
Applied egg-rr99.4%
pow1/299.4%
pow-exp95.2%
*-commutative95.2%
pow-pow95.2%
*-commutative95.2%
pow-exp99.4%
sqr-pow99.2%
pow-prod-down99.2%
prod-exp99.2%
metadata-eval99.2%
sqrt-pow199.2%
pow1/299.2%
pow1/299.2%
sqrt-pow199.2%
pow-pow95.4%
div-inv95.4%
metadata-eval95.4%
swap-sqr95.4%
metadata-eval95.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.5%
cos-neg94.5%
*-commutative94.5%
exp-prod95.4%
cos-neg95.4%
Simplified95.4%
Final simplification95.4%
(FPCore (x) :precision binary64 (* (cos x) (pow (exp (* x x)) 10.0)))
double code(double x) {
return cos(x) * pow(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.pow(Math.exp((x * x)), 10.0);
}
def code(x): return math.cos(x) * math.pow(math.exp((x * x)), 10.0)
function code(x) return Float64(cos(x) * (exp(Float64(x * 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[Power[N[Exp[N[(x * x), $MachinePrecision]], $MachinePrecision], 10.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot {\left(e^{x \cdot x}\right)}^{10}
\end{array}
Initial program 94.5%
cos-neg94.5%
*-commutative94.5%
cos-neg94.5%
Simplified94.5%
Taylor expanded in x around inf 94.5%
unpow294.5%
*-commutative94.5%
exp-prod95.4%
Simplified95.4%
Final simplification95.4%
(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) (+ (* 10.0 (* x x)) 1.0)))
double code(double x) {
return cos(x) * ((10.0 * (x * x)) + 1.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = cos(x) * ((10.0d0 * (x * x)) + 1.0d0)
end function
public static double code(double x) {
return Math.cos(x) * ((10.0 * (x * x)) + 1.0);
}
def code(x): return math.cos(x) * ((10.0 * (x * x)) + 1.0)
function code(x) return Float64(cos(x) * Float64(Float64(10.0 * Float64(x * x)) + 1.0)) end
function tmp = code(x) tmp = cos(x) * ((10.0 * (x * x)) + 1.0); end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[(N[(10.0 * N[(x * x), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot \left(10 \cdot \left(x \cdot x\right) + 1\right)
\end{array}
Initial program 94.5%
cos-neg94.5%
*-commutative94.5%
cos-neg94.5%
Simplified94.5%
Taylor expanded in x around 0 9.8%
unpow29.8%
Simplified9.8%
Final simplification9.8%
(FPCore (x) :precision binary64 (* x (* (cos x) (* x 10.0))))
double code(double x) {
return x * (cos(x) * (x * 10.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * (cos(x) * (x * 10.0d0))
end function
public static double code(double x) {
return x * (Math.cos(x) * (x * 10.0));
}
def code(x): return x * (math.cos(x) * (x * 10.0))
function code(x) return Float64(x * Float64(cos(x) * Float64(x * 10.0))) end
function tmp = code(x) tmp = x * (cos(x) * (x * 10.0)); end
code[x_] := N[(x * N[(N[Cos[x], $MachinePrecision] * N[(x * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(\cos x \cdot \left(x \cdot 10\right)\right)
\end{array}
Initial program 94.5%
cos-neg94.5%
*-commutative94.5%
cos-neg94.5%
Simplified94.5%
Taylor expanded in x around 0 9.8%
unpow29.8%
Simplified9.8%
Taylor expanded in x around inf 9.8%
associate-*r*9.8%
*-commutative9.8%
unpow29.8%
associate-*r*9.8%
associate-*l*9.8%
Simplified9.8%
Final simplification9.8%
(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%
cos-neg94.5%
*-commutative94.5%
cos-neg94.5%
Simplified94.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%
cos-neg94.5%
*-commutative94.5%
cos-neg94.5%
Simplified94.5%
pow-exp95.4%
pow-pow98.0%
sqr-pow98.0%
pow-prod-down98.0%
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 2023271
(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)))))