
(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 8 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%
*-commutative95.2%
pow-exp94.5%
associate-*r*94.3%
add-log-exp94.3%
log-pow94.3%
pow-pow94.8%
add-exp-log96.9%
add-cbrt-cube96.8%
add-cbrt-cube96.8%
cbrt-unprod96.8%
Applied egg-rr98.9%
add-cube-cbrt98.9%
rem-cbrt-cube98.9%
rem-cbrt-cube98.9%
pow298.9%
rem-cbrt-cube98.9%
Applied egg-rr98.9%
Taylor expanded in x around inf 94.0%
*-commutative94.0%
unpow1/398.8%
*-rgt-identity98.8%
exp-prod95.4%
*-commutative95.4%
exp-prod95.2%
*-commutative95.2%
exp-prod95.5%
Simplified95.5%
add-exp-log94.6%
pow1/394.1%
pow-pow93.7%
log-pow93.9%
add-log-exp93.9%
pow-exp94.0%
pow-exp94.5%
*-commutative94.5%
pow-exp94.0%
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%
associate-*r*94.3%
exp-prod95.0%
sqr-pow94.9%
sqr-pow95.0%
exp-prod98.0%
Simplified98.0%
Final simplification98.0%
(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.5%
pow-exp95.2%
*-commutative95.2%
pow-exp94.5%
associate-*r*94.3%
add-log-exp94.3%
log-pow94.3%
pow-pow94.8%
add-exp-log96.9%
add-cbrt-cube96.8%
add-cbrt-cube96.8%
cbrt-unprod96.8%
Applied egg-rr98.9%
add-cube-cbrt98.9%
rem-cbrt-cube98.9%
rem-cbrt-cube98.9%
pow298.9%
rem-cbrt-cube98.9%
Applied egg-rr98.9%
Taylor expanded in x around inf 94.0%
*-commutative94.0%
unpow1/398.8%
*-rgt-identity98.8%
exp-prod95.4%
*-commutative95.4%
exp-prod95.2%
*-commutative95.2%
exp-prod95.5%
Simplified95.5%
pow-exp95.2%
Applied egg-rr95.2%
Final simplification95.2%
(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%
exp-prod95.2%
Simplified95.2%
Final simplification95.2%
(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%
*-commutative94.5%
exp-prod95.2%
exp-prod96.7%
Applied egg-rr96.7%
Taylor expanded in x around inf 95.2%
unpow295.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 (* (* x x) 9.5)))
double code(double x) {
return 1.0 + ((x * x) * 9.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 + ((x * x) * 9.5d0)
end function
public static double code(double x) {
return 1.0 + ((x * x) * 9.5);
}
def code(x): return 1.0 + ((x * x) * 9.5)
function code(x) return Float64(1.0 + Float64(Float64(x * x) * 9.5)) end
function tmp = code(x) tmp = 1.0 + ((x * x) * 9.5); end
code[x_] := N[(1.0 + N[(N[(x * x), $MachinePrecision] * 9.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(x \cdot x\right) \cdot 9.5
\end{array}
Initial program 94.5%
Taylor expanded in x around 0 1.5%
unpow21.5%
Simplified1.5%
Final simplification1.5%
herbie shell --seed 2023178
(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)))))