
(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 (* (sqrt (pow (pow (exp 20.0) x) x)) (cos x)))
double code(double x) {
return sqrt(pow(pow(exp(20.0), x), x)) * cos(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt(((exp(20.0d0) ** x) ** x)) * cos(x)
end function
public static double code(double x) {
return Math.sqrt(Math.pow(Math.pow(Math.exp(20.0), x), x)) * Math.cos(x);
}
def code(x): return math.sqrt(math.pow(math.pow(math.exp(20.0), x), x)) * math.cos(x)
function code(x) return Float64(sqrt(((exp(20.0) ^ x) ^ x)) * cos(x)) end
function tmp = code(x) tmp = sqrt(((exp(20.0) ^ x) ^ x)) * cos(x); end
code[x_] := N[(N[Sqrt[N[Power[N[Power[N[Exp[20.0], $MachinePrecision], x], $MachinePrecision], x], $MachinePrecision]], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{{\left({\left(e^{20}\right)}^{x}\right)}^{x}} \cdot \cos x
\end{array}
Initial program 94.6%
cos-neg94.6%
*-commutative94.6%
cos-neg94.6%
Simplified94.6%
pow-exp95.1%
add-sqr-sqrt95.1%
sqrt-unprod95.1%
pow-prod-down95.1%
pow-pow98.1%
prod-exp99.4%
metadata-eval99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x) :precision binary64 (* (cos x) (pow (pow (exp 5.0) (+ x x)) x)))
double code(double x) {
return cos(x) * pow(pow(exp(5.0), (x + x)), x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = cos(x) * ((exp(5.0d0) ** (x + x)) ** x)
end function
public static double code(double x) {
return Math.cos(x) * Math.pow(Math.pow(Math.exp(5.0), (x + x)), x);
}
def code(x): return math.cos(x) * math.pow(math.pow(math.exp(5.0), (x + x)), x)
function code(x) return Float64(cos(x) * ((exp(5.0) ^ Float64(x + x)) ^ x)) end
function tmp = code(x) tmp = cos(x) * ((exp(5.0) ^ (x + x)) ^ x); end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[Power[N[Exp[5.0], $MachinePrecision], N[(x + x), $MachinePrecision]], $MachinePrecision], x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot {\left({\left(e^{5}\right)}^{\left(x + x\right)}\right)}^{x}
\end{array}
Initial program 94.6%
cos-neg94.6%
*-commutative94.6%
cos-neg94.6%
Simplified94.6%
pow-exp95.1%
add-sqr-sqrt95.1%
sqrt-unprod95.1%
pow-prod-down95.1%
pow-pow98.1%
prod-exp99.4%
metadata-eval99.4%
Applied egg-rr99.4%
sqrt-pow199.4%
add-sqr-sqrt99.1%
unpow-prod-down99.0%
metadata-eval99.0%
prod-exp98.7%
pow-prod-down98.7%
exp-prod97.1%
exp-prod96.0%
sqrt-unprod95.9%
add-sqr-sqrt96.0%
sqrt-pow295.9%
Applied egg-rr98.4%
Final simplification98.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) ^ 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.6%
cos-neg94.6%
*-commutative94.6%
cos-neg94.6%
Simplified94.6%
pow-exp95.1%
pow-pow97.9%
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.6%
cos-neg94.6%
*-commutative94.6%
associate-*r*94.6%
exp-prod94.8%
exp-prod97.9%
cos-neg97.9%
Simplified97.9%
Final simplification97.9%
(FPCore (x) :precision binary64 (* (cos x) (pow (exp 5.0) (* 2.0 (* x x)))))
double code(double x) {
return cos(x) * pow(exp(5.0), (2.0 * (x * x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = cos(x) * (exp(5.0d0) ** (2.0d0 * (x * x)))
end function
public static double code(double x) {
return Math.cos(x) * Math.pow(Math.exp(5.0), (2.0 * (x * x)));
}
def code(x): return math.cos(x) * math.pow(math.exp(5.0), (2.0 * (x * x)))
function code(x) return Float64(cos(x) * (exp(5.0) ^ Float64(2.0 * Float64(x * x)))) end
function tmp = code(x) tmp = cos(x) * (exp(5.0) ^ (2.0 * (x * x))); end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[Exp[5.0], $MachinePrecision], N[(2.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot {\left(e^{5}\right)}^{\left(2 \cdot \left(x \cdot x\right)\right)}
\end{array}
Initial program 94.6%
cos-neg94.6%
*-commutative94.6%
cos-neg94.6%
Simplified94.6%
pow-exp95.1%
add-sqr-sqrt95.2%
pow295.2%
pow-pow95.1%
pow1/295.1%
pow-exp95.1%
metadata-eval95.1%
Applied egg-rr95.1%
Final simplification95.1%
(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.6%
cos-neg94.6%
*-commutative94.6%
exp-prod95.1%
cos-neg95.1%
Simplified95.1%
Final simplification95.1%
(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.6%
Final simplification94.6%
(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.6%
cos-neg94.6%
*-commutative94.6%
cos-neg94.6%
Simplified94.6%
Taylor expanded in x around 0 18.2%
unpow29.7%
Simplified18.2%
Final simplification18.2%
(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.6%
cos-neg94.6%
*-commutative94.6%
cos-neg94.6%
Simplified94.6%
pow-exp95.1%
add-sqr-sqrt95.1%
sqrt-unprod95.1%
pow-prod-down95.1%
pow-pow98.1%
prod-exp99.4%
metadata-eval99.4%
Applied egg-rr99.4%
Taylor expanded in x around 0 9.8%
unpow29.8%
Simplified9.8%
Final simplification9.8%
(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.6%
cos-neg94.6%
*-commutative94.6%
cos-neg94.6%
Simplified94.6%
Taylor expanded in x around 0 9.6%
Taylor expanded in x around 0 9.7%
unpow29.7%
Simplified9.7%
Final simplification9.7%
(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.6%
cos-neg94.6%
*-commutative94.6%
cos-neg94.6%
Simplified94.6%
pow-exp95.1%
add-sqr-sqrt95.1%
sqrt-unprod95.1%
pow-prod-down95.1%
pow-pow98.1%
prod-exp99.4%
metadata-eval99.4%
Applied egg-rr99.4%
sqrt-pow199.4%
Applied egg-rr99.4%
Taylor expanded in x around 0 1.5%
Final simplification1.5%
herbie shell --seed 2023290
(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)))))