
(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 80.0) x) (* x 0.125))))
double code(double x) {
return cos(x) * pow(pow(exp(80.0), x), (x * 0.125));
}
real(8) function code(x)
real(8), intent (in) :: x
code = cos(x) * ((exp(80.0d0) ** x) ** (x * 0.125d0))
end function
public static double code(double x) {
return Math.cos(x) * Math.pow(Math.pow(Math.exp(80.0), x), (x * 0.125));
}
def code(x): return math.cos(x) * math.pow(math.pow(math.exp(80.0), x), (x * 0.125))
function code(x) return Float64(cos(x) * ((exp(80.0) ^ x) ^ Float64(x * 0.125))) end
function tmp = code(x) tmp = cos(x) * ((exp(80.0) ^ x) ^ (x * 0.125)); end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[Power[N[Exp[80.0], $MachinePrecision], x], $MachinePrecision], N[(x * 0.125), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot {\left({\left(e^{80}\right)}^{x}\right)}^{\left(x \cdot 0.125\right)}
\end{array}
Initial program 94.3%
pow-exp95.1%
sqr-pow95.2%
pow-prod-down95.1%
associate-/l*95.1%
pow-unpow98.0%
prod-exp99.3%
metadata-eval99.3%
Applied egg-rr99.3%
sqr-pow99.0%
pow-prod-down99.4%
pow-prod-down99.3%
prod-exp99.3%
metadata-eval99.3%
div-inv99.3%
metadata-eval99.3%
associate-/l*99.3%
metadata-eval99.3%
Applied egg-rr99.3%
sqr-pow99.1%
pow-prod-down99.3%
pow-prod-down99.2%
prod-exp99.4%
metadata-eval99.4%
associate-/l*99.4%
metadata-eval99.4%
Applied egg-rr99.4%
(FPCore (x) :precision binary64 (* (cos x) (pow (pow (exp 20.0) x) (/ x 2.0))))
double code(double x) {
return cos(x) * pow(pow(exp(20.0), x), (x / 2.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = cos(x) * ((exp(20.0d0) ** x) ** (x / 2.0d0))
end function
public static double code(double x) {
return Math.cos(x) * Math.pow(Math.pow(Math.exp(20.0), x), (x / 2.0));
}
def code(x): return math.cos(x) * math.pow(math.pow(math.exp(20.0), x), (x / 2.0))
function code(x) return Float64(cos(x) * ((exp(20.0) ^ x) ^ Float64(x / 2.0))) end
function tmp = code(x) tmp = cos(x) * ((exp(20.0) ^ x) ^ (x / 2.0)); end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[Power[N[Exp[20.0], $MachinePrecision], x], $MachinePrecision], N[(x / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot {\left({\left(e^{20}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}
\end{array}
Initial program 94.3%
pow-exp95.1%
sqr-pow95.2%
pow-prod-down95.1%
associate-/l*95.1%
pow-unpow98.0%
prod-exp99.3%
metadata-eval99.3%
Applied egg-rr99.3%
(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.3%
pow-exp95.1%
pow-unpow98.0%
Applied egg-rr98.0%
(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.3%
exp-prod95.1%
Simplified95.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.3%
(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.3%
Taylor expanded in x around 0 9.6%
Taylor expanded in x around 0 9.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.3%
Taylor expanded in x around 0 9.6%
Taylor expanded in x around 0 9.7%
unpow29.7%
Applied egg-rr9.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.3%
pow-exp95.1%
sqr-pow95.2%
pow-prod-down95.1%
associate-/l*95.1%
pow-unpow98.0%
prod-exp99.3%
metadata-eval99.3%
Applied egg-rr99.3%
Taylor expanded in x around 0 1.5%
herbie shell --seed 2024096
(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)))))