| 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 (pow (pow (cosh x) -0.5) 2.0))
double code(double x) {
return 2.0 / (exp(x) + exp(-x));
}
double code(double x) {
return pow(pow(cosh(x), -0.5), 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 = (cosh(x) ** (-0.5d0)) ** 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.pow(Math.pow(Math.cosh(x), -0.5), 2.0);
}
def code(x): return 2.0 / (math.exp(x) + math.exp(-x))
def code(x): return math.pow(math.pow(math.cosh(x), -0.5), 2.0)
function code(x) return Float64(2.0 / Float64(exp(x) + exp(Float64(-x)))) end
function code(x) return (cosh(x) ^ -0.5) ^ 2.0 end
function tmp = code(x) tmp = 2.0 / (exp(x) + exp(-x)); end
function tmp = code(x) tmp = (cosh(x) ^ -0.5) ^ 2.0; end
code[x_] := N[(2.0 / N[(N[Exp[x], $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := N[Power[N[Power[N[Cosh[x], $MachinePrecision], -0.5], $MachinePrecision], 2.0], $MachinePrecision]
\frac{2}{e^{x} + e^{-x}}
{\left({\cosh x}^{-0.5}\right)}^{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 | 1.0 |
| Cost | 841 |
| Alternative 3 | |
|---|---|
| Error | 1.0 |
| Cost | 832 |
| Alternative 4 | |
|---|---|
| Error | 15.1 |
| Cost | 713 |
| Alternative 5 | |
|---|---|
| Error | 15.3 |
| Cost | 585 |
| Alternative 6 | |
|---|---|
| Error | 15.1 |
| Cost | 448 |
| Alternative 7 | |
|---|---|
| Error | 31.2 |
| Cost | 64 |
herbie shell --seed 2023053
(FPCore (x)
:name "Hyperbolic secant"
:precision binary64
(/ 2.0 (+ (exp x) (exp (- x)))))