
(FPCore (x) :precision binary64 (+ (- (exp x) 2.0) (exp (- x))))
double code(double x) {
return (exp(x) - 2.0) + exp(-x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (exp(x) - 2.0d0) + exp(-x)
end function
public static double code(double x) {
return (Math.exp(x) - 2.0) + Math.exp(-x);
}
def code(x): return (math.exp(x) - 2.0) + math.exp(-x)
function code(x) return Float64(Float64(exp(x) - 2.0) + exp(Float64(-x))) end
function tmp = code(x) tmp = (exp(x) - 2.0) + exp(-x); end
code[x_] := N[(N[(N[Exp[x], $MachinePrecision] - 2.0), $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(e^{x} - 2\right) + e^{-x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (+ (- (exp x) 2.0) (exp (- x))))
double code(double x) {
return (exp(x) - 2.0) + exp(-x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (exp(x) - 2.0d0) + exp(-x)
end function
public static double code(double x) {
return (Math.exp(x) - 2.0) + Math.exp(-x);
}
def code(x): return (math.exp(x) - 2.0) + math.exp(-x)
function code(x) return Float64(Float64(exp(x) - 2.0) + exp(Float64(-x))) end
function tmp = code(x) tmp = (exp(x) - 2.0) + exp(-x); end
code[x_] := N[(N[(N[Exp[x], $MachinePrecision] - 2.0), $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(e^{x} - 2\right) + e^{-x}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (cosh x))))
(if (<= (+ (- (exp x) 2.0) (exp (- x))) 4e-5)
(+
(* 0.002777777777777778 (pow x 6.0))
(fma x x (* 0.08333333333333333 (pow x 4.0))))
(fma (* 2.0 t_0) t_0 -2.0))))
double code(double x) {
double t_0 = sqrt(cosh(x));
double tmp;
if (((exp(x) - 2.0) + exp(-x)) <= 4e-5) {
tmp = (0.002777777777777778 * pow(x, 6.0)) + fma(x, x, (0.08333333333333333 * pow(x, 4.0)));
} else {
tmp = fma((2.0 * t_0), t_0, -2.0);
}
return tmp;
}
function code(x) t_0 = sqrt(cosh(x)) tmp = 0.0 if (Float64(Float64(exp(x) - 2.0) + exp(Float64(-x))) <= 4e-5) tmp = Float64(Float64(0.002777777777777778 * (x ^ 6.0)) + fma(x, x, Float64(0.08333333333333333 * (x ^ 4.0)))); else tmp = fma(Float64(2.0 * t_0), t_0, -2.0); end return tmp end
code[x_] := Block[{t$95$0 = N[Sqrt[N[Cosh[x], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(N[Exp[x], $MachinePrecision] - 2.0), $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], 4e-5], N[(N[(0.002777777777777778 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(x * x + N[(0.08333333333333333 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * t$95$0), $MachinePrecision] * t$95$0 + -2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\cosh x}\\
\mathbf{if}\;\left(e^{x} - 2\right) + e^{-x} \leq 4 \cdot 10^{-5}:\\
\;\;\;\;0.002777777777777778 \cdot {x}^{6} + \mathsf{fma}\left(x, x, 0.08333333333333333 \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2 \cdot t_0, t_0, -2\right)\\
\end{array}
\end{array}
if (+.f64 (-.f64 (exp.f64 x) 2) (exp.f64 (neg.f64 x))) < 4.00000000000000033e-5Initial program 58.0%
associate-+l-58.0%
sub-neg58.0%
sub-neg58.0%
distribute-neg-in58.0%
remove-double-neg58.0%
+-commutative58.0%
metadata-eval58.0%
Simplified58.0%
Taylor expanded in x around 0 100.0%
+-commutative100.0%
unpow2100.0%
fma-def100.0%
Applied egg-rr100.0%
if 4.00000000000000033e-5 < (+.f64 (-.f64 (exp.f64 x) 2) (exp.f64 (neg.f64 x))) Initial program 99.9%
associate-+l-99.9%
sub-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
metadata-eval99.9%
Simplified99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
sub-neg99.9%
+-commutative99.9%
associate-+r-99.9%
+-commutative99.9%
cosh-undef99.9%
Applied egg-rr99.9%
sub-neg99.9%
add-sqr-sqrt99.9%
associate-*r*99.9%
fma-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Final simplification100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (- (exp x) 2.0) (exp (- x)))))
(if (<= t_0 4e-5)
(+
(* 0.002777777777777778 (pow x 6.0))
(fma x x (* 0.08333333333333333 (pow x 4.0))))
t_0)))
double code(double x) {
double t_0 = (exp(x) - 2.0) + exp(-x);
double tmp;
if (t_0 <= 4e-5) {
tmp = (0.002777777777777778 * pow(x, 6.0)) + fma(x, x, (0.08333333333333333 * pow(x, 4.0)));
} else {
tmp = t_0;
}
return tmp;
}
function code(x) t_0 = Float64(Float64(exp(x) - 2.0) + exp(Float64(-x))) tmp = 0.0 if (t_0 <= 4e-5) tmp = Float64(Float64(0.002777777777777778 * (x ^ 6.0)) + fma(x, x, Float64(0.08333333333333333 * (x ^ 4.0)))); else tmp = t_0; end return tmp end
code[x_] := Block[{t$95$0 = N[(N[(N[Exp[x], $MachinePrecision] - 2.0), $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 4e-5], N[(N[(0.002777777777777778 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(x * x + N[(0.08333333333333333 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{x} - 2\right) + e^{-x}\\
\mathbf{if}\;t_0 \leq 4 \cdot 10^{-5}:\\
\;\;\;\;0.002777777777777778 \cdot {x}^{6} + \mathsf{fma}\left(x, x, 0.08333333333333333 \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (+.f64 (-.f64 (exp.f64 x) 2) (exp.f64 (neg.f64 x))) < 4.00000000000000033e-5Initial program 58.0%
associate-+l-58.0%
sub-neg58.0%
sub-neg58.0%
distribute-neg-in58.0%
remove-double-neg58.0%
+-commutative58.0%
metadata-eval58.0%
Simplified58.0%
Taylor expanded in x around 0 100.0%
+-commutative100.0%
unpow2100.0%
fma-def100.0%
Applied egg-rr100.0%
if 4.00000000000000033e-5 < (+.f64 (-.f64 (exp.f64 x) 2) (exp.f64 (neg.f64 x))) Initial program 99.9%
Final simplification100.0%
(FPCore (x) :precision binary64 (let* ((t_0 (+ (- (exp x) 2.0) (exp (- x))))) (if (<= t_0 0.0) (pow x 2.0) t_0)))
double code(double x) {
double t_0 = (exp(x) - 2.0) + exp(-x);
double tmp;
if (t_0 <= 0.0) {
tmp = pow(x, 2.0);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = (exp(x) - 2.0d0) + exp(-x)
if (t_0 <= 0.0d0) then
tmp = x ** 2.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x) {
double t_0 = (Math.exp(x) - 2.0) + Math.exp(-x);
double tmp;
if (t_0 <= 0.0) {
tmp = Math.pow(x, 2.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x): t_0 = (math.exp(x) - 2.0) + math.exp(-x) tmp = 0 if t_0 <= 0.0: tmp = math.pow(x, 2.0) else: tmp = t_0 return tmp
function code(x) t_0 = Float64(Float64(exp(x) - 2.0) + exp(Float64(-x))) tmp = 0.0 if (t_0 <= 0.0) tmp = x ^ 2.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x) t_0 = (exp(x) - 2.0) + exp(-x); tmp = 0.0; if (t_0 <= 0.0) tmp = x ^ 2.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(N[Exp[x], $MachinePrecision] - 2.0), $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[Power[x, 2.0], $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{x} - 2\right) + e^{-x}\\
\mathbf{if}\;t_0 \leq 0:\\
\;\;\;\;{x}^{2}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (+.f64 (-.f64 (exp.f64 x) 2) (exp.f64 (neg.f64 x))) < 0.0Initial program 57.7%
associate-+l-57.7%
sub-neg57.7%
sub-neg57.7%
distribute-neg-in57.7%
remove-double-neg57.7%
+-commutative57.7%
metadata-eval57.7%
Simplified57.7%
Taylor expanded in x around 0 100.0%
if 0.0 < (+.f64 (-.f64 (exp.f64 x) 2) (exp.f64 (neg.f64 x))) Initial program 99.7%
Final simplification99.8%
(FPCore (x) :precision binary64 (let* ((t_0 (+ (- (exp x) 2.0) (exp (- x))))) (if (<= t_0 5e-6) (fma x x (* 0.08333333333333333 (pow x 4.0))) t_0)))
double code(double x) {
double t_0 = (exp(x) - 2.0) + exp(-x);
double tmp;
if (t_0 <= 5e-6) {
tmp = fma(x, x, (0.08333333333333333 * pow(x, 4.0)));
} else {
tmp = t_0;
}
return tmp;
}
function code(x) t_0 = Float64(Float64(exp(x) - 2.0) + exp(Float64(-x))) tmp = 0.0 if (t_0 <= 5e-6) tmp = fma(x, x, Float64(0.08333333333333333 * (x ^ 4.0))); else tmp = t_0; end return tmp end
code[x_] := Block[{t$95$0 = N[(N[(N[Exp[x], $MachinePrecision] - 2.0), $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e-6], N[(x * x + N[(0.08333333333333333 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{x} - 2\right) + e^{-x}\\
\mathbf{if}\;t_0 \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(x, x, 0.08333333333333333 \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (+.f64 (-.f64 (exp.f64 x) 2) (exp.f64 (neg.f64 x))) < 5.00000000000000041e-6Initial program 57.8%
associate-+l-57.8%
sub-neg57.8%
sub-neg57.8%
distribute-neg-in57.8%
remove-double-neg57.8%
+-commutative57.8%
metadata-eval57.8%
Simplified57.8%
Taylor expanded in x around 0 99.9%
+-commutative100.0%
unpow2100.0%
fma-def100.0%
Applied egg-rr99.9%
if 5.00000000000000041e-6 < (+.f64 (-.f64 (exp.f64 x) 2) (exp.f64 (neg.f64 x))) Initial program 99.8%
Final simplification99.9%
(FPCore (x) :precision binary64 (if (<= x 0.00015) (pow x 2.0) (+ (exp x) (+ (exp (- x)) -2.0))))
double code(double x) {
double tmp;
if (x <= 0.00015) {
tmp = pow(x, 2.0);
} else {
tmp = exp(x) + (exp(-x) + -2.0);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.00015d0) then
tmp = x ** 2.0d0
else
tmp = exp(x) + (exp(-x) + (-2.0d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.00015) {
tmp = Math.pow(x, 2.0);
} else {
tmp = Math.exp(x) + (Math.exp(-x) + -2.0);
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.00015: tmp = math.pow(x, 2.0) else: tmp = math.exp(x) + (math.exp(-x) + -2.0) return tmp
function code(x) tmp = 0.0 if (x <= 0.00015) tmp = x ^ 2.0; else tmp = Float64(exp(x) + Float64(exp(Float64(-x)) + -2.0)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.00015) tmp = x ^ 2.0; else tmp = exp(x) + (exp(-x) + -2.0); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.00015], N[Power[x, 2.0], $MachinePrecision], N[(N[Exp[x], $MachinePrecision] + N[(N[Exp[(-x)], $MachinePrecision] + -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.00015:\\
\;\;\;\;{x}^{2}\\
\mathbf{else}:\\
\;\;\;\;e^{x} + \left(e^{-x} + -2\right)\\
\end{array}
\end{array}
if x < 1.49999999999999987e-4Initial program 72.1%
associate-+l-72.1%
sub-neg72.1%
sub-neg72.1%
distribute-neg-in72.1%
remove-double-neg72.1%
+-commutative72.1%
metadata-eval72.1%
Simplified72.1%
Taylor expanded in x around 0 86.1%
if 1.49999999999999987e-4 < x Initial program 99.5%
associate-+l-99.4%
sub-neg99.4%
sub-neg99.4%
distribute-neg-in99.4%
remove-double-neg99.4%
+-commutative99.4%
metadata-eval99.4%
Simplified99.4%
Final simplification90.3%
(FPCore (x) :precision binary64 (if (<= x 0.000175) (pow x 2.0) (- (* 2.0 (cosh x)) 2.0)))
double code(double x) {
double tmp;
if (x <= 0.000175) {
tmp = pow(x, 2.0);
} else {
tmp = (2.0 * cosh(x)) - 2.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.000175d0) then
tmp = x ** 2.0d0
else
tmp = (2.0d0 * cosh(x)) - 2.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.000175) {
tmp = Math.pow(x, 2.0);
} else {
tmp = (2.0 * Math.cosh(x)) - 2.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.000175: tmp = math.pow(x, 2.0) else: tmp = (2.0 * math.cosh(x)) - 2.0 return tmp
function code(x) tmp = 0.0 if (x <= 0.000175) tmp = x ^ 2.0; else tmp = Float64(Float64(2.0 * cosh(x)) - 2.0); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.000175) tmp = x ^ 2.0; else tmp = (2.0 * cosh(x)) - 2.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.000175], N[Power[x, 2.0], $MachinePrecision], N[(N[(2.0 * N[Cosh[x], $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.000175:\\
\;\;\;\;{x}^{2}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \cosh x - 2\\
\end{array}
\end{array}
if x < 1.74999999999999998e-4Initial program 72.1%
associate-+l-72.1%
sub-neg72.1%
sub-neg72.1%
distribute-neg-in72.1%
remove-double-neg72.1%
+-commutative72.1%
metadata-eval72.1%
Simplified72.1%
Taylor expanded in x around 0 86.1%
if 1.74999999999999998e-4 < x Initial program 99.5%
associate-+l-99.4%
sub-neg99.4%
sub-neg99.4%
distribute-neg-in99.4%
remove-double-neg99.4%
+-commutative99.4%
metadata-eval99.4%
Simplified99.4%
+-commutative99.4%
associate-+r+99.5%
metadata-eval99.5%
sub-neg99.5%
+-commutative99.5%
associate-+r-99.3%
+-commutative99.3%
cosh-undef99.3%
Applied egg-rr99.3%
Final simplification90.3%
(FPCore (x) :precision binary64 (if (<= x 1.65) (pow x 2.0) (expm1 x)))
double code(double x) {
double tmp;
if (x <= 1.65) {
tmp = pow(x, 2.0);
} else {
tmp = expm1(x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 1.65) {
tmp = Math.pow(x, 2.0);
} else {
tmp = Math.expm1(x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.65: tmp = math.pow(x, 2.0) else: tmp = math.expm1(x) return tmp
function code(x) tmp = 0.0 if (x <= 1.65) tmp = x ^ 2.0; else tmp = expm1(x); end return tmp end
code[x_] := If[LessEqual[x, 1.65], N[Power[x, 2.0], $MachinePrecision], N[(Exp[x] - 1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.65:\\
\;\;\;\;{x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(x\right)\\
\end{array}
\end{array}
if x < 1.6499999999999999Initial program 72.3%
associate-+l-72.2%
sub-neg72.2%
sub-neg72.2%
distribute-neg-in72.2%
remove-double-neg72.2%
+-commutative72.2%
metadata-eval72.2%
Simplified72.2%
Taylor expanded in x around 0 85.4%
if 1.6499999999999999 < x Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in x around inf 100.0%
expm1-def100.0%
Simplified100.0%
Final simplification89.8%
(FPCore (x) :precision binary64 (if (<= x 2.25e-103) 0.0 (expm1 x)))
double code(double x) {
double tmp;
if (x <= 2.25e-103) {
tmp = 0.0;
} else {
tmp = expm1(x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 2.25e-103) {
tmp = 0.0;
} else {
tmp = Math.expm1(x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 2.25e-103: tmp = 0.0 else: tmp = math.expm1(x) return tmp
function code(x) tmp = 0.0 if (x <= 2.25e-103) tmp = 0.0; else tmp = expm1(x); end return tmp end
code[x_] := If[LessEqual[x, 2.25e-103], 0.0, N[(Exp[x] - 1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.25 \cdot 10^{-103}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(x\right)\\
\end{array}
\end{array}
if x < 2.25e-103Initial program 77.0%
associate-+l-77.0%
sub-neg77.0%
sub-neg77.0%
distribute-neg-in77.0%
remove-double-neg77.0%
+-commutative77.0%
metadata-eval77.0%
Simplified77.0%
+-commutative77.0%
associate-+r+77.0%
metadata-eval77.0%
sub-neg77.0%
add-log-exp77.0%
sub-neg77.0%
metadata-eval77.0%
associate-+r+77.0%
+-commutative77.0%
associate-+r+77.0%
+-commutative77.0%
cosh-undef77.0%
Applied egg-rr77.0%
+-commutative77.0%
add-log-exp77.0%
add-sqr-sqrt77.0%
associate-*r*77.0%
add-sqr-sqrt38.9%
associate-*l*38.9%
fma-def38.9%
pow1/238.9%
pow1/238.9%
pow-prod-down38.9%
Applied egg-rr38.9%
unpow1/238.9%
associate-*l*38.9%
Simplified38.9%
Taylor expanded in x around 0 3.5%
unpow23.5%
rem-square-sqrt41.1%
metadata-eval41.1%
Simplified41.1%
if 2.25e-103 < x Initial program 87.1%
associate-+l-87.0%
sub-neg87.0%
sub-neg87.0%
distribute-neg-in87.0%
remove-double-neg87.0%
+-commutative87.0%
metadata-eval87.0%
Simplified87.0%
Taylor expanded in x around 0 84.8%
Taylor expanded in x around inf 84.8%
expm1-def85.1%
Simplified85.1%
Final simplification56.9%
(FPCore (x) :precision binary64 (if (<= x 2.25e-103) 0.0 x))
double code(double x) {
double tmp;
if (x <= 2.25e-103) {
tmp = 0.0;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 2.25d-103) then
tmp = 0.0d0
else
tmp = x
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 2.25e-103) {
tmp = 0.0;
} else {
tmp = x;
}
return tmp;
}
def code(x): tmp = 0 if x <= 2.25e-103: tmp = 0.0 else: tmp = x return tmp
function code(x) tmp = 0.0 if (x <= 2.25e-103) tmp = 0.0; else tmp = x; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 2.25e-103) tmp = 0.0; else tmp = x; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 2.25e-103], 0.0, x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.25 \cdot 10^{-103}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < 2.25e-103Initial program 77.0%
associate-+l-77.0%
sub-neg77.0%
sub-neg77.0%
distribute-neg-in77.0%
remove-double-neg77.0%
+-commutative77.0%
metadata-eval77.0%
Simplified77.0%
+-commutative77.0%
associate-+r+77.0%
metadata-eval77.0%
sub-neg77.0%
add-log-exp77.0%
sub-neg77.0%
metadata-eval77.0%
associate-+r+77.0%
+-commutative77.0%
associate-+r+77.0%
+-commutative77.0%
cosh-undef77.0%
Applied egg-rr77.0%
+-commutative77.0%
add-log-exp77.0%
add-sqr-sqrt77.0%
associate-*r*77.0%
add-sqr-sqrt38.9%
associate-*l*38.9%
fma-def38.9%
pow1/238.9%
pow1/238.9%
pow-prod-down38.9%
Applied egg-rr38.9%
unpow1/238.9%
associate-*l*38.9%
Simplified38.9%
Taylor expanded in x around 0 3.5%
unpow23.5%
rem-square-sqrt41.1%
metadata-eval41.1%
Simplified41.1%
if 2.25e-103 < x Initial program 87.1%
associate-+l-87.0%
sub-neg87.0%
sub-neg87.0%
distribute-neg-in87.0%
remove-double-neg87.0%
+-commutative87.0%
metadata-eval87.0%
Simplified87.0%
Taylor expanded in x around 0 84.8%
Taylor expanded in x around 0 5.8%
Final simplification28.4%
(FPCore (x) :precision binary64 0.0)
double code(double x) {
return 0.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.0d0
end function
public static double code(double x) {
return 0.0;
}
def code(x): return 0.0
function code(x) return 0.0 end
function tmp = code(x) tmp = 0.0; end
code[x_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 80.6%
associate-+l-80.6%
sub-neg80.6%
sub-neg80.6%
distribute-neg-in80.6%
remove-double-neg80.6%
+-commutative80.6%
metadata-eval80.6%
Simplified80.6%
+-commutative80.6%
associate-+r+80.6%
metadata-eval80.6%
sub-neg80.6%
add-log-exp79.9%
sub-neg79.9%
metadata-eval79.9%
associate-+r+79.8%
+-commutative79.8%
associate-+r+79.8%
+-commutative79.8%
cosh-undef79.8%
Applied egg-rr79.8%
+-commutative79.8%
add-log-exp80.6%
add-sqr-sqrt80.5%
associate-*r*80.5%
add-sqr-sqrt56.2%
associate-*l*56.2%
fma-def56.2%
pow1/256.2%
pow1/256.2%
pow-prod-down55.9%
Applied egg-rr55.9%
unpow1/255.9%
associate-*l*55.9%
Simplified55.9%
Taylor expanded in x around 0 3.6%
unpow23.6%
rem-square-sqrt27.0%
metadata-eval27.0%
Simplified27.0%
Final simplification27.0%
(FPCore (x) :precision binary64 (* 4.0 (pow (sinh (/ x 2.0)) 2.0)))
double code(double x) {
return 4.0 * pow(sinh((x / 2.0)), 2.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 4.0d0 * (sinh((x / 2.0d0)) ** 2.0d0)
end function
public static double code(double x) {
return 4.0 * Math.pow(Math.sinh((x / 2.0)), 2.0);
}
def code(x): return 4.0 * math.pow(math.sinh((x / 2.0)), 2.0)
function code(x) return Float64(4.0 * (sinh(Float64(x / 2.0)) ^ 2.0)) end
function tmp = code(x) tmp = 4.0 * (sinh((x / 2.0)) ^ 2.0); end
code[x_] := N[(4.0 * N[Power[N[Sinh[N[(x / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
4 \cdot {\sinh \left(\frac{x}{2}\right)}^{2}
\end{array}
herbie shell --seed 2023319
(FPCore (x)
:name "exp2 (problem 3.3.7)"
:precision binary64
:herbie-target
(* 4.0 (pow (sinh (/ x 2.0)) 2.0))
(+ (- (exp x) 2.0) (exp (- x))))