| Alternative 1 | |
|---|---|
| Error | 0.0 |
| Cost | 6592 |
\[\frac{1}{\cosh x}
\]
(FPCore (x) :precision binary64 (/ 2.0 (+ (exp x) (exp (- x)))))
(FPCore (x) :precision binary64 (sqrt (pow (cosh x) -2.0)))
double code(double x) {
return 2.0 / (exp(x) + exp(-x));
}
double code(double x) {
return sqrt(pow(cosh(x), -2.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 2.0d0 / (exp(x) + exp(-x))
end function
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt((cosh(x) ** (-2.0d0)))
end function
public static double code(double x) {
return 2.0 / (Math.exp(x) + Math.exp(-x));
}
public static double code(double x) {
return Math.sqrt(Math.pow(Math.cosh(x), -2.0));
}
def code(x): return 2.0 / (math.exp(x) + math.exp(-x))
def code(x): return math.sqrt(math.pow(math.cosh(x), -2.0))
function code(x) return Float64(2.0 / Float64(exp(x) + exp(Float64(-x)))) end
function code(x) return sqrt((cosh(x) ^ -2.0)) end
function tmp = code(x) tmp = 2.0 / (exp(x) + exp(-x)); end
function tmp = code(x) tmp = sqrt((cosh(x) ^ -2.0)); end
code[x_] := N[(2.0 / N[(N[Exp[x], $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := N[Sqrt[N[Power[N[Cosh[x], $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]
\frac{2}{e^{x} + e^{-x}}
\sqrt{{\cosh x}^{-2}}
Results
Initial program 0.0
Taylor expanded in x around inf 0.0
Simplified0.0
[Start]0.0 | \[ \frac{2}{e^{-x} + e^{x}}
\] |
|---|---|
metadata-eval [<=]0.0 | \[ \frac{\color{blue}{1 \cdot 2}}{e^{-x} + e^{x}}
\] |
associate-*l/ [<=]0.0 | \[ \color{blue}{\frac{1}{e^{-x} + e^{x}} \cdot 2}
\] |
associate-/r/ [<=]0.0 | \[ \color{blue}{\frac{1}{\frac{e^{-x} + e^{x}}{2}}}
\] |
+-commutative [=>]0.0 | \[ \frac{1}{\frac{\color{blue}{e^{x} + e^{-x}}}{2}}
\] |
cosh-def [<=]0.0 | \[ \frac{1}{\color{blue}{\cosh x}}
\] |
Applied egg-rr0.0
Final simplification0.0
| Alternative 1 | |
|---|---|
| Error | 0.0 |
| Cost | 6592 |
| Alternative 2 | |
|---|---|
| Error | 0.9 |
| Cost | 841 |
| Alternative 3 | |
|---|---|
| Error | 15.1 |
| Cost | 713 |
| Alternative 4 | |
|---|---|
| Error | 15.3 |
| Cost | 585 |
| Alternative 5 | |
|---|---|
| Error | 15.1 |
| Cost | 448 |
| Alternative 6 | |
|---|---|
| Error | 31.1 |
| Cost | 64 |
herbie shell --seed 2023083
(FPCore (x)
:name "Hyperbolic secant"
:precision binary64
(/ 2.0 (+ (exp x) (exp (- x)))))