
(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 12 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 (cbrt (* (pow (sqrt (pow (exp 60.0) x)) x) (pow (cos x) 3.0))))
double code(double x) {
return cbrt((pow(sqrt(pow(exp(60.0), x)), x) * pow(cos(x), 3.0)));
}
public static double code(double x) {
return Math.cbrt((Math.pow(Math.sqrt(Math.pow(Math.exp(60.0), x)), x) * Math.pow(Math.cos(x), 3.0)));
}
function code(x) return cbrt(Float64((sqrt((exp(60.0) ^ x)) ^ x) * (cos(x) ^ 3.0))) end
code[x_] := N[Power[N[(N[Power[N[Sqrt[N[Power[N[Exp[60.0], $MachinePrecision], x], $MachinePrecision]], $MachinePrecision], x], $MachinePrecision] * N[Power[N[Cos[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{{\left(\sqrt{{\left(e^{60}\right)}^{x}}\right)}^{x} \cdot {\cos x}^{3}}
\end{array}
Initial program 94.7%
pow-exp95.3%
*-commutative95.3%
pow-exp94.7%
associate-*r*94.5%
add-log-exp94.5%
log-pow94.5%
pow-pow95.0%
add-exp-log96.8%
add-cbrt-cube96.8%
add-cbrt-cube96.8%
cbrt-unprod96.8%
Applied egg-rr98.8%
add-sqr-sqrt98.7%
sqrt-unprod98.8%
pow-prod-down98.9%
prod-exp99.2%
metadata-eval99.2%
Applied egg-rr99.2%
Final simplification99.2%
(FPCore (x) :precision binary64 (* (cos x) (cbrt (sqrt (pow (pow (exp 60.0) x) x)))))
double code(double x) {
return cos(x) * cbrt(sqrt(pow(pow(exp(60.0), x), x)));
}
public static double code(double x) {
return Math.cos(x) * Math.cbrt(Math.sqrt(Math.pow(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[Sqrt[N[Power[N[Power[N[Exp[60.0], $MachinePrecision], x], $MachinePrecision], x], $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot \sqrt[3]{\sqrt{{\left({\left(e^{60}\right)}^{x}\right)}^{x}}}
\end{array}
Initial program 94.7%
pow-exp95.3%
*-commutative95.3%
pow-exp94.7%
associate-*r*94.5%
add-log-exp94.5%
log-pow94.5%
pow-pow95.0%
add-exp-log96.8%
add-cbrt-cube96.8%
add-cbrt-cube96.8%
cbrt-unprod96.8%
Applied egg-rr98.8%
add-sqr-sqrt98.7%
sqrt-unprod98.8%
pow-prod-down98.9%
prod-exp99.2%
metadata-eval99.2%
Applied egg-rr99.2%
*-commutative99.2%
cbrt-prod98.9%
rem-cbrt-cube99.0%
add-sqr-sqrt99.1%
sqrt-unprod99.0%
pow-prod-down99.1%
add-sqr-sqrt99.1%
Applied egg-rr99.1%
Final simplification99.1%
(FPCore (x) :precision binary64 (* (* (cos x) 0.3333333333333333) (* 3.0 (cbrt (pow (pow (exp 30.0) x) x)))))
double code(double x) {
return (cos(x) * 0.3333333333333333) * (3.0 * cbrt(pow(pow(exp(30.0), x), x)));
}
public static double code(double x) {
return (Math.cos(x) * 0.3333333333333333) * (3.0 * Math.cbrt(Math.pow(Math.pow(Math.exp(30.0), x), x)));
}
function code(x) return Float64(Float64(cos(x) * 0.3333333333333333) * Float64(3.0 * cbrt(((exp(30.0) ^ x) ^ x)))) end
code[x_] := N[(N[(N[Cos[x], $MachinePrecision] * 0.3333333333333333), $MachinePrecision] * N[(3.0 * N[Power[N[Power[N[Power[N[Exp[30.0], $MachinePrecision], x], $MachinePrecision], x], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\cos x \cdot 0.3333333333333333\right) \cdot \left(3 \cdot \sqrt[3]{{\left({\left(e^{30}\right)}^{x}\right)}^{x}}\right)
\end{array}
Initial program 94.7%
pow-exp95.3%
*-commutative95.3%
pow-exp94.7%
associate-*r*94.5%
add-log-exp94.5%
log-pow94.5%
pow-pow95.0%
add-exp-log96.8%
add-cbrt-cube96.8%
add-cbrt-cube96.8%
cbrt-unprod96.8%
Applied egg-rr98.8%
Taylor expanded in x around inf 95.6%
cbrt-prod95.6%
rem-cbrt-cube95.6%
*-un-lft-identity95.6%
metadata-eval95.6%
associate-*r*95.6%
associate-*r*95.6%
exp-prod98.8%
*-commutative98.8%
Applied egg-rr98.8%
Final simplification98.8%
(FPCore (x) :precision binary64 (* 3.0 (* (cbrt (pow (pow (exp 30.0) x) x)) (* (cos x) 0.3333333333333333))))
double code(double x) {
return 3.0 * (cbrt(pow(pow(exp(30.0), x), x)) * (cos(x) * 0.3333333333333333));
}
public static double code(double x) {
return 3.0 * (Math.cbrt(Math.pow(Math.pow(Math.exp(30.0), x), x)) * (Math.cos(x) * 0.3333333333333333));
}
function code(x) return Float64(3.0 * Float64(cbrt(((exp(30.0) ^ x) ^ x)) * Float64(cos(x) * 0.3333333333333333))) end
code[x_] := N[(3.0 * N[(N[Power[N[Power[N[Power[N[Exp[30.0], $MachinePrecision], x], $MachinePrecision], x], $MachinePrecision], 1/3], $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
3 \cdot \left(\sqrt[3]{{\left({\left(e^{30}\right)}^{x}\right)}^{x}} \cdot \left(\cos x \cdot 0.3333333333333333\right)\right)
\end{array}
Initial program 94.7%
pow-exp95.3%
*-commutative95.3%
pow-exp94.7%
associate-*r*94.5%
add-log-exp94.5%
log-pow94.5%
pow-pow95.0%
add-exp-log96.8%
add-cbrt-cube96.8%
add-cbrt-cube96.8%
cbrt-unprod96.8%
Applied egg-rr98.8%
Taylor expanded in x around inf 95.6%
cbrt-prod95.6%
rem-cbrt-cube95.6%
*-un-lft-identity95.6%
metadata-eval95.6%
associate-*r*95.6%
*-commutative95.6%
associate-*r*95.6%
exp-prod98.9%
*-commutative98.9%
Applied egg-rr98.9%
Final simplification98.9%
(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.7%
associate-*r*94.5%
add-log-exp94.5%
log-pow94.5%
pow-pow95.0%
add-exp-log96.8%
add-cbrt-cube96.8%
add-exp-log96.5%
pow-pow96.2%
log-pow96.3%
add-log-exp96.3%
associate-*r*96.5%
pow-exp96.9%
*-commutative96.9%
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.7%
associate-*r*94.5%
exp-prod95.1%
sqr-pow95.0%
sqr-pow95.1%
exp-prod98.0%
Simplified98.0%
Final simplification98.0%
(FPCore (x) :precision binary64 (* (* 3.0 (* (cos x) 0.3333333333333333)) (pow (exp 10.0) (* x x))))
double code(double x) {
return (3.0 * (cos(x) * 0.3333333333333333)) * pow(exp(10.0), (x * x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (3.0d0 * (cos(x) * 0.3333333333333333d0)) * (exp(10.0d0) ** (x * x))
end function
public static double code(double x) {
return (3.0 * (Math.cos(x) * 0.3333333333333333)) * Math.pow(Math.exp(10.0), (x * x));
}
def code(x): return (3.0 * (math.cos(x) * 0.3333333333333333)) * math.pow(math.exp(10.0), (x * x))
function code(x) return Float64(Float64(3.0 * Float64(cos(x) * 0.3333333333333333)) * (exp(10.0) ^ Float64(x * x))) end
function tmp = code(x) tmp = (3.0 * (cos(x) * 0.3333333333333333)) * (exp(10.0) ^ (x * x)); end
code[x_] := N[(N[(3.0 * N[(N[Cos[x], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision] * N[Power[N[Exp[10.0], $MachinePrecision], N[(x * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(3 \cdot \left(\cos x \cdot 0.3333333333333333\right)\right) \cdot {\left(e^{10}\right)}^{\left(x \cdot x\right)}
\end{array}
Initial program 94.7%
exp-prod95.3%
Simplified95.3%
add-log-exp95.3%
add-cube-cbrt95.3%
log-prod95.3%
Applied egg-rr95.3%
log-prod95.3%
count-295.3%
distribute-lft1-in95.3%
metadata-eval95.3%
Simplified95.3%
Taylor expanded in x around inf 95.3%
log-pow95.3%
rem-log-exp95.3%
Simplified95.3%
Final simplification95.3%
(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.7%
exp-prod95.3%
Simplified95.3%
Final simplification95.3%
(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.7%
Final simplification94.7%
(FPCore (x) :precision binary64 (* (exp (* 10.0 (* x x))) (+ 1.0 (* (* x x) -0.5))))
double code(double x) {
return exp((10.0 * (x * x))) * (1.0 + ((x * x) * -0.5));
}
real(8) function code(x)
real(8), intent (in) :: x
code = exp((10.0d0 * (x * x))) * (1.0d0 + ((x * x) * (-0.5d0)))
end function
public static double code(double x) {
return Math.exp((10.0 * (x * x))) * (1.0 + ((x * x) * -0.5));
}
def code(x): return math.exp((10.0 * (x * x))) * (1.0 + ((x * x) * -0.5))
function code(x) return Float64(exp(Float64(10.0 * Float64(x * x))) * Float64(1.0 + Float64(Float64(x * x) * -0.5))) end
function tmp = code(x) tmp = exp((10.0 * (x * x))) * (1.0 + ((x * x) * -0.5)); end
code[x_] := N[(N[Exp[N[(10.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(N[(x * x), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{10 \cdot \left(x \cdot x\right)} \cdot \left(1 + \left(x \cdot x\right) \cdot -0.5\right)
\end{array}
Initial program 94.7%
Taylor expanded in x around 0 18.2%
unpow29.7%
Simplified18.2%
Final simplification18.2%
(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.7%
Taylor expanded in x around 0 1.5%
unpow21.5%
Simplified1.5%
Final simplification1.5%
(FPCore (x) :precision binary64 (+ 1.0 (* (* x x) -0.5)))
double code(double x) {
return 1.0 + ((x * x) * -0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 + ((x * x) * (-0.5d0))
end function
public static double code(double x) {
return 1.0 + ((x * x) * -0.5);
}
def code(x): return 1.0 + ((x * x) * -0.5)
function code(x) return Float64(1.0 + Float64(Float64(x * x) * -0.5)) end
function tmp = code(x) tmp = 1.0 + ((x * x) * -0.5); end
code[x_] := N[(1.0 + N[(N[(x * x), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(x \cdot x\right) \cdot -0.5
\end{array}
Initial program 94.7%
Taylor expanded in x around 0 9.6%
Taylor expanded in x around 0 9.7%
unpow29.7%
Simplified9.7%
Final simplification9.7%
herbie shell --seed 2023171
(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)))))