
(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 (* (cos x) (pow (pow (exp 20.0) (* x 2.0)) (* x 0.25))))
double code(double x) {
return cos(x) * pow(pow(exp(20.0), (x * 2.0)), (x * 0.25));
}
real(8) function code(x)
real(8), intent (in) :: x
code = cos(x) * ((exp(20.0d0) ** (x * 2.0d0)) ** (x * 0.25d0))
end function
public static double code(double x) {
return Math.cos(x) * Math.pow(Math.pow(Math.exp(20.0), (x * 2.0)), (x * 0.25));
}
def code(x): return math.cos(x) * math.pow(math.pow(math.exp(20.0), (x * 2.0)), (x * 0.25))
function code(x) return Float64(cos(x) * ((exp(20.0) ^ Float64(x * 2.0)) ^ Float64(x * 0.25))) end
function tmp = code(x) tmp = cos(x) * ((exp(20.0) ^ (x * 2.0)) ^ (x * 0.25)); end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[Power[N[Exp[20.0], $MachinePrecision], N[(x * 2.0), $MachinePrecision]], $MachinePrecision], N[(x * 0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot {\left({\left(e^{20}\right)}^{\left(x \cdot 2\right)}\right)}^{\left(x \cdot 0.25\right)}
\end{array}
Initial program 94.6%
associate-*r*94.4%
*-commutative94.4%
exp-prod94.9%
expm1-log1p-u92.8%
expm1-undefine92.8%
pow-sub92.8%
*-commutative92.8%
pow192.8%
Applied egg-rr92.8%
log1p-undefine92.9%
rem-exp-log94.9%
*-commutative94.9%
Simplified94.9%
pow194.9%
pow-div94.9%
add-exp-log92.9%
expm1-undefine92.9%
log1p-define92.8%
expm1-log1p-u94.9%
pow-unpow96.7%
exp-prod95.1%
*-commutative95.1%
pow-exp97.9%
metadata-eval97.9%
pow-exp93.8%
pow-unpow94.2%
sqr-pow94.2%
pow-prod-down94.3%
pow-exp94.9%
metadata-eval94.9%
pow-exp95.1%
metadata-eval95.1%
prod-exp95.1%
metadata-eval95.1%
associate-*r/95.1%
Applied egg-rr99.2%
associate-*l*99.2%
metadata-eval99.2%
Simplified99.2%
metadata-eval99.2%
prod-exp99.2%
pow-prod-down99.3%
Applied egg-rr99.3%
pow-sqr99.5%
*-commutative99.5%
Simplified99.5%
(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.6%
pow-exp95.1%
sqr-pow95.1%
pow-prod-down95.1%
associate-/l*95.1%
pow-unpow97.9%
prod-exp99.4%
metadata-eval99.4%
Applied egg-rr99.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%
pow-exp95.1%
pow-unpow97.9%
Applied egg-rr97.9%
(FPCore (x) :precision binary64 (* (cos x) (pow (exp (* x 40.0)) (* x 0.25))))
double code(double x) {
return cos(x) * pow(exp((x * 40.0)), (x * 0.25));
}
real(8) function code(x)
real(8), intent (in) :: x
code = cos(x) * (exp((x * 40.0d0)) ** (x * 0.25d0))
end function
public static double code(double x) {
return Math.cos(x) * Math.pow(Math.exp((x * 40.0)), (x * 0.25));
}
def code(x): return math.cos(x) * math.pow(math.exp((x * 40.0)), (x * 0.25))
function code(x) return Float64(cos(x) * (exp(Float64(x * 40.0)) ^ Float64(x * 0.25))) end
function tmp = code(x) tmp = cos(x) * (exp((x * 40.0)) ^ (x * 0.25)); end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[Exp[N[(x * 40.0), $MachinePrecision]], $MachinePrecision], N[(x * 0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot {\left(e^{x \cdot 40}\right)}^{\left(x \cdot 0.25\right)}
\end{array}
Initial program 94.6%
associate-*r*94.4%
*-commutative94.4%
exp-prod94.9%
expm1-log1p-u92.8%
expm1-undefine92.8%
pow-sub92.8%
*-commutative92.8%
pow192.8%
Applied egg-rr92.8%
log1p-undefine92.9%
rem-exp-log94.9%
*-commutative94.9%
Simplified94.9%
pow194.9%
pow-div94.9%
add-exp-log92.9%
expm1-undefine92.9%
log1p-define92.8%
expm1-log1p-u94.9%
pow-unpow96.7%
exp-prod95.1%
*-commutative95.1%
pow-exp97.9%
metadata-eval97.9%
pow-exp93.8%
pow-unpow94.2%
sqr-pow94.2%
pow-prod-down94.3%
pow-exp94.9%
metadata-eval94.9%
pow-exp95.1%
metadata-eval95.1%
prod-exp95.1%
metadata-eval95.1%
associate-*r/95.1%
Applied egg-rr99.2%
associate-*l*99.2%
metadata-eval99.2%
Simplified99.2%
add-exp-log95.2%
log-pow95.2%
rem-log-exp95.2%
Applied egg-rr95.2%
(FPCore (x) :precision binary64 (* (cos x) (pow (exp (* x 20.0)) (/ x 2.0))))
double code(double x) {
return cos(x) * pow(exp((x * 20.0)), (x / 2.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = cos(x) * (exp((x * 20.0d0)) ** (x / 2.0d0))
end function
public static double code(double x) {
return Math.cos(x) * Math.pow(Math.exp((x * 20.0)), (x / 2.0));
}
def code(x): return math.cos(x) * math.pow(math.exp((x * 20.0)), (x / 2.0))
function code(x) return Float64(cos(x) * (exp(Float64(x * 20.0)) ^ Float64(x / 2.0))) end
function tmp = code(x) tmp = cos(x) * (exp((x * 20.0)) ^ (x / 2.0)); end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[Exp[N[(x * 20.0), $MachinePrecision]], $MachinePrecision], N[(x / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot {\left(e^{x \cdot 20}\right)}^{\left(\frac{x}{2}\right)}
\end{array}
Initial program 94.6%
pow-exp95.1%
sqr-pow95.1%
pow-prod-down95.1%
associate-/l*95.1%
pow-unpow97.9%
prod-exp99.4%
metadata-eval99.4%
Applied egg-rr99.4%
add-exp-log95.2%
log-pow95.2%
rem-log-exp95.2%
Applied egg-rr95.2%
(FPCore (x) :precision binary64 (* (cos x) (pow (exp (* x 10.0)) x)))
double code(double x) {
return cos(x) * pow(exp((x * 10.0)), x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = cos(x) * (exp((x * 10.0d0)) ** x)
end function
public static double code(double x) {
return Math.cos(x) * Math.pow(Math.exp((x * 10.0)), x);
}
def code(x): return math.cos(x) * math.pow(math.exp((x * 10.0)), x)
function code(x) return Float64(cos(x) * (exp(Float64(x * 10.0)) ^ x)) end
function tmp = code(x) tmp = cos(x) * (exp((x * 10.0)) ^ x); end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[Exp[N[(x * 10.0), $MachinePrecision]], $MachinePrecision], x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot {\left(e^{x \cdot 10}\right)}^{x}
\end{array}
Initial program 94.6%
pow-exp95.1%
pow-unpow97.9%
Applied egg-rr97.9%
add-exp-log95.1%
log-pow95.1%
rem-log-exp95.1%
Applied egg-rr95.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%
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.6%
(FPCore (x) :precision binary64 (+ 1.0 (* (pow x 2.0) -0.5)))
double code(double x) {
return 1.0 + (pow(x, 2.0) * -0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 + ((x ** 2.0d0) * (-0.5d0))
end function
public static double code(double x) {
return 1.0 + (Math.pow(x, 2.0) * -0.5);
}
def code(x): return 1.0 + (math.pow(x, 2.0) * -0.5)
function code(x) return Float64(1.0 + Float64((x ^ 2.0) * -0.5)) end
function tmp = code(x) tmp = 1.0 + ((x ^ 2.0) * -0.5); end
code[x_] := N[(1.0 + N[(N[Power[x, 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + {x}^{2} \cdot -0.5
\end{array}
Initial program 94.6%
Taylor expanded in x around 0 9.6%
Taylor expanded in x around 0 9.7%
*-commutative9.7%
Simplified9.7%
(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.6%
Taylor expanded in x around 0 9.6%
Taylor expanded in x around inf 9.6%
(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%
pow-exp95.1%
sqr-pow95.1%
pow-prod-down95.1%
associate-/l*95.1%
pow-unpow97.9%
prod-exp99.4%
metadata-eval99.4%
Applied egg-rr99.4%
Taylor expanded in x around 0 1.5%
herbie shell --seed 2024135
(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)))))