
(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 (* (cos x) (sqrt (pow (pow (exp 80.0) x) (* x 0.25)))))
double code(double x) {
return cos(x) * sqrt(pow(pow(exp(80.0), x), (x * 0.25)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = cos(x) * sqrt(((exp(80.0d0) ** x) ** (x * 0.25d0)))
end function
public static double code(double x) {
return Math.cos(x) * Math.sqrt(Math.pow(Math.pow(Math.exp(80.0), x), (x * 0.25)));
}
def code(x): return math.cos(x) * math.sqrt(math.pow(math.pow(math.exp(80.0), x), (x * 0.25)))
function code(x) return Float64(cos(x) * sqrt(((exp(80.0) ^ x) ^ Float64(x * 0.25)))) end
function tmp = code(x) tmp = cos(x) * sqrt(((exp(80.0) ^ x) ^ (x * 0.25))); end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Sqrt[N[Power[N[Power[N[Exp[80.0], $MachinePrecision], x], $MachinePrecision], N[(x * 0.25), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot \sqrt{{\left({\left(e^{80}\right)}^{x}\right)}^{\left(x \cdot 0.25\right)}}
\end{array}
Initial program 94.4%
pow-exp95.3%
sqr-pow95.3%
pow-prod-down95.3%
associate-/l*95.3%
pow-unpow98.0%
prod-exp99.4%
metadata-eval99.4%
Applied egg-rr99.4%
add-sqr-sqrt99.2%
sqrt-unprod99.4%
pow-prod-down99.2%
prod-exp99.2%
metadata-eval99.2%
Applied egg-rr99.2%
add-sqr-sqrt99.2%
sqrt-unprod99.2%
pow-prod-down99.2%
prod-exp99.4%
metadata-eval99.4%
Applied egg-rr99.4%
add-sqr-sqrt99.0%
sqrt-unprod99.4%
sqrt-pow299.4%
sqrt-pow299.4%
pow-prod-down99.4%
add-sqr-sqrt99.4%
div-inv99.4%
metadata-eval99.4%
associate-/l*99.4%
metadata-eval99.4%
Applied egg-rr99.4%
Final simplification99.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.4%
pow-exp95.3%
sqr-pow95.3%
pow-prod-down95.3%
associate-/l*95.3%
pow-unpow98.0%
prod-exp99.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.4%
pow-exp95.3%
pow-unpow98.0%
Applied egg-rr98.0%
Final simplification98.0%
(FPCore (x) :precision binary64 (* (cos x) (pow (+ 1.0 (expm1 (* x 20.0))) (/ x 2.0))))
double code(double x) {
return cos(x) * pow((1.0 + expm1((x * 20.0))), (x / 2.0));
}
public static double code(double x) {
return Math.cos(x) * Math.pow((1.0 + Math.expm1((x * 20.0))), (x / 2.0));
}
def code(x): return math.cos(x) * math.pow((1.0 + math.expm1((x * 20.0))), (x / 2.0))
function code(x) return Float64(cos(x) * (Float64(1.0 + expm1(Float64(x * 20.0))) ^ Float64(x / 2.0))) end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[(1.0 + N[(Exp[N[(x * 20.0), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision], N[(x / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos x \cdot {\left(1 + \mathsf{expm1}\left(x \cdot 20\right)\right)}^{\left(\frac{x}{2}\right)}
\end{array}
Initial program 94.4%
pow-exp95.3%
sqr-pow95.3%
pow-prod-down95.3%
associate-/l*95.3%
pow-unpow98.0%
prod-exp99.4%
metadata-eval99.4%
Applied egg-rr99.4%
add-sqr-sqrt99.2%
sqrt-unprod99.4%
pow-prod-down99.2%
prod-exp99.2%
metadata-eval99.2%
Applied egg-rr99.2%
sqrt-pow199.2%
metadata-eval99.2%
prod-exp99.2%
pow-prod-down99.2%
expm1-log1p-u95.4%
sqr-pow95.4%
expm1-undefine95.4%
Applied egg-rr95.4%
log1p-undefine95.4%
rem-exp-log99.4%
associate--l+99.4%
exp-prod95.4%
*-commutative95.4%
expm1-define95.4%
*-commutative95.4%
Simplified95.4%
Final simplification95.4%
(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.4%
pow-exp95.3%
sqr-pow95.3%
pow-prod-down95.3%
associate-/l*95.3%
pow-unpow98.0%
prod-exp99.4%
metadata-eval99.4%
Applied egg-rr99.4%
add-exp-log95.4%
log-pow95.4%
rem-log-exp95.4%
Applied egg-rr95.4%
Final simplification95.4%
(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.4%
exp-prod95.3%
Simplified95.3%
Final simplification95.3%
(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.4%
pow-exp95.3%
sqr-pow95.3%
pow-prod-down95.3%
associate-/l*95.3%
pow-unpow98.0%
prod-exp99.4%
metadata-eval99.4%
Applied egg-rr99.4%
Taylor expanded in x around inf 94.4%
*-commutative94.4%
exp-prod94.4%
unpow1/294.4%
*-commutative94.4%
exp-to-pow99.3%
Simplified99.3%
sqrt-pow199.4%
sqr-pow99.2%
pow-prod-down99.2%
prod-exp99.2%
metadata-eval99.2%
sqrt-pow199.2%
add-sqr-sqrt99.0%
unpow-prod-down98.9%
sqrt-pow198.9%
metadata-eval98.9%
prod-exp98.9%
pow-prod-down99.0%
sqr-pow99.0%
div-inv99.0%
metadata-eval99.0%
Applied egg-rr99.0%
pow-sqr99.2%
count-299.2%
distribute-lft-out99.2%
metadata-eval99.2%
*-rgt-identity99.2%
Simplified99.2%
Taylor expanded in x around inf 95.3%
exp-prod99.2%
unpow1/299.2%
exp-prod95.3%
*-commutative95.3%
exp-prod95.3%
associate-*l*95.3%
metadata-eval95.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.4%
Final simplification94.4%
(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.4%
associate-*r*94.4%
Simplified94.4%
Final simplification94.4%
(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.4%
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 (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.4%
Taylor expanded in x around 0 9.6%
Final simplification9.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.4%
pow-exp95.3%
sqr-pow95.3%
pow-prod-down95.3%
associate-/l*95.3%
pow-unpow98.0%
prod-exp99.4%
metadata-eval99.4%
Applied egg-rr99.4%
Taylor expanded in x around 0 1.5%
Final simplification1.5%
herbie shell --seed 2024078
(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)))))