
(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 0.5)) x)))
double code(double x) {
return cos(x) * pow(pow(exp(20.0), (x * 0.5)), x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = cos(x) * ((exp(20.0d0) ** (x * 0.5d0)) ** x)
end function
public static double code(double x) {
return Math.cos(x) * Math.pow(Math.pow(Math.exp(20.0), (x * 0.5)), x);
}
def code(x): return math.cos(x) * math.pow(math.pow(math.exp(20.0), (x * 0.5)), x)
function code(x) return Float64(cos(x) * ((exp(20.0) ^ Float64(x * 0.5)) ^ x)) end
function tmp = code(x) tmp = cos(x) * ((exp(20.0) ^ (x * 0.5)) ^ x); end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[Power[N[Exp[20.0], $MachinePrecision], N[(x * 0.5), $MachinePrecision]], $MachinePrecision], x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot {\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}^{x}
\end{array}
Initial program 94.1%
pow-exp95.1%
pow-unpow97.9%
Applied egg-rr97.9%
add-sqr-sqrt97.7%
sqrt-unprod97.9%
pow-prod-down97.9%
prod-exp99.2%
metadata-eval99.2%
Applied egg-rr99.2%
pow1/299.2%
pow-pow99.2%
Applied egg-rr99.2%
Final simplification99.2%
(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.1%
pow-exp95.1%
pow-unpow97.9%
Applied egg-rr97.9%
Final simplification97.9%
(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.1%
exp-prod95.1%
Simplified95.1%
Final simplification95.1%
(FPCore (x) :precision binary64 (* (/ -1.0 (/ -1.0 (cos x))) (exp (* x (* x 10.0)))))
double code(double x) {
return (-1.0 / (-1.0 / cos(x))) * exp((x * (x * 10.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((-1.0d0) / ((-1.0d0) / cos(x))) * exp((x * (x * 10.0d0)))
end function
public static double code(double x) {
return (-1.0 / (-1.0 / Math.cos(x))) * Math.exp((x * (x * 10.0)));
}
def code(x): return (-1.0 / (-1.0 / math.cos(x))) * math.exp((x * (x * 10.0)))
function code(x) return Float64(Float64(-1.0 / Float64(-1.0 / cos(x))) * exp(Float64(x * Float64(x * 10.0)))) end
function tmp = code(x) tmp = (-1.0 / (-1.0 / cos(x))) * exp((x * (x * 10.0))); end
code[x_] := N[(N[(-1.0 / N[(-1.0 / N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(x * N[(x * 10.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1}{\frac{-1}{\cos x}} \cdot e^{x \cdot \left(x \cdot 10\right)}
\end{array}
Initial program 94.1%
associate-*r*94.1%
Simplified94.1%
add-log-exp94.1%
add-cube-cbrt94.2%
log-prod94.1%
cos-sum94.1%
Applied egg-rr94.1%
associate-*r*94.1%
*-commutative94.1%
metadata-eval94.1%
*-commutative94.1%
associate-*r*94.1%
*-commutative94.1%
metadata-eval94.1%
*-commutative94.1%
Simplified94.1%
flip--94.1%
cos-diff94.1%
clear-num94.1%
distribute-lft-out--94.1%
metadata-eval94.1%
Applied egg-rr94.1%
frac-2neg94.1%
metadata-eval94.1%
div-inv94.1%
/-rgt-identity94.1%
/-rgt-identity94.1%
associate-/r*94.1%
*-inverses94.1%
distribute-neg-frac94.1%
metadata-eval94.1%
Applied egg-rr94.1%
Final simplification94.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.1%
Final simplification94.1%
(FPCore (x) :precision binary64 (* (cos x) (exp (* x (* x 10.0)))))
double code(double x) {
return cos(x) * 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.exp((x * (x * 10.0)));
}
def code(x): return math.cos(x) * math.exp((x * (x * 10.0)))
function code(x) return Float64(cos(x) * exp(Float64(x * Float64(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[Exp[N[(x * N[(x * 10.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot e^{x \cdot \left(x \cdot 10\right)}
\end{array}
Initial program 94.1%
associate-*r*94.1%
Simplified94.1%
Final simplification94.1%
(FPCore (x) :precision binary64 (* (pow x 2.0) -0.5))
double code(double x) {
return pow(x, 2.0) * -0.5;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x ** 2.0d0) * (-0.5d0)
end function
public static double code(double x) {
return Math.pow(x, 2.0) * -0.5;
}
def code(x): return math.pow(x, 2.0) * -0.5
function code(x) return Float64((x ^ 2.0) * -0.5) end
function tmp = code(x) tmp = (x ^ 2.0) * -0.5; end
code[x_] := N[(N[Power[x, 2.0], $MachinePrecision] * -0.5), $MachinePrecision]
\begin{array}{l}
\\
{x}^{2} \cdot -0.5
\end{array}
Initial program 94.1%
Taylor expanded in x around 0 9.6%
Taylor expanded in x around 0 9.7%
*-commutative9.7%
Simplified9.7%
Taylor expanded in x around inf 9.7%
*-commutative9.7%
Simplified9.7%
Final simplification9.7%
(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.1%
Taylor expanded in x around 0 9.6%
Taylor expanded in x around 0 9.7%
*-commutative9.7%
Simplified9.7%
pow29.7%
Applied egg-rr9.7%
Final simplification9.7%
herbie shell --seed 2024021
(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)))))