1 | ### cosh =====================================================================
|
2 |
|
3 | Tags
|
4 | ----
|
5 | scripting, JS, internal, treenode, general concept
|
6 |
|
7 | Parameters
|
8 | ----------
|
9 | x
|
10 |
|
11 | General description
|
12 | -------------------
|
13 | Returns the hyperbolic cosine of x
|
14 |
|
15 | ```
|
16 | exp(x) + exp(-x)
|
17 | cosh(x) = ----------------
|
18 | 2
|
19 | ```
|
20 |
|
21 | ###
|
22 |
|
23 | Eval_cosh = ->
|
24 | push(cadr(p1))
|
25 | Eval()
|
26 | ycosh()
|
27 |
|
28 | ycosh = ->
|
29 | save()
|
30 | yycosh()
|
31 | restore()
|
32 |
|
33 | yycosh = ->
|
34 | d = 0.0
|
35 | p1 = pop()
|
36 | if (car(p1) == symbol(ARCCOSH))
|
37 | push(cadr(p1))
|
38 | return
|
39 | if (isdouble(p1))
|
40 | d = Math.cosh(p1.d)
|
41 | if (Math.abs(d) < 1e-10)
|
42 | d = 0.0
|
43 | push_double(d)
|
44 | return
|
45 | if (iszero(p1))
|
46 | push(one)
|
47 | return
|
48 | push_symbol(COSH)
|
49 | push(p1)
|
50 | list(2)
|
51 |
|