numz 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { mapfun
|
|
2
|
-
import {
|
|
1
|
+
import { mapfun } from "ziko/math/mapfun";
|
|
2
|
+
import { nthr, pow } from '../../../ufunc/index.js'
|
|
3
|
+
import { Matrix } from '../../../matrix/index.js'
|
|
3
4
|
|
|
4
5
|
export const zeros = (n, m, d) => {
|
|
5
6
|
if(m) return Matrix.zeros(n, m);
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { mapfun, MapFunResult } from 'ziko/math/mapfun'
|
|
2
|
+
import { complex } from '../complex/index'
|
|
3
|
+
|
|
4
|
+
// --- Standard Unary / Multi-Argument Math Functions ---
|
|
5
|
+
|
|
6
|
+
export function abs<T>(x: T): MapFunResult<T, any>;
|
|
7
|
+
export function abs<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
8
|
+
|
|
9
|
+
export function sqrt<T>(x: T): MapFunResult<T, any>;
|
|
10
|
+
export function sqrt<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
11
|
+
|
|
12
|
+
export function cbrt<T>(x: T): MapFunResult<T, any>;
|
|
13
|
+
export function cbrt<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
14
|
+
|
|
15
|
+
export function exp<T>(x: T): MapFunResult<T, any>;
|
|
16
|
+
export function exp<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
17
|
+
|
|
18
|
+
export function ln<T>(x: T): MapFunResult<T, any>;
|
|
19
|
+
export function ln<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
20
|
+
|
|
21
|
+
export function sign<T>(x: T): MapFunResult<T, any>;
|
|
22
|
+
export function sign<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
23
|
+
|
|
24
|
+
export function floor<T>(x: T): MapFunResult<T, any>;
|
|
25
|
+
export function floor<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
26
|
+
|
|
27
|
+
export function ceil<T>(x: T): MapFunResult<T, any>;
|
|
28
|
+
export function ceil<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
29
|
+
|
|
30
|
+
export function round<T>(x: T): MapFunResult<T, any>;
|
|
31
|
+
export function round<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
32
|
+
|
|
33
|
+
export function trunc<T>(x: T): MapFunResult<T, any>;
|
|
34
|
+
export function trunc<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
35
|
+
|
|
36
|
+
export function fract<T>(x: T): MapFunResult<T, any>;
|
|
37
|
+
export function fract<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
38
|
+
|
|
39
|
+
export function cos<T>(x: T): MapFunResult<T, any>;
|
|
40
|
+
export function cos<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
41
|
+
|
|
42
|
+
export function sin<T>(x: T): MapFunResult<T, any>;
|
|
43
|
+
export function sin<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
44
|
+
|
|
45
|
+
export function tan<T>(x: T): MapFunResult<T, any>;
|
|
46
|
+
export function tan<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
47
|
+
|
|
48
|
+
export function sec<T>(x: T): MapFunResult<T, any>;
|
|
49
|
+
export function sec<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
50
|
+
|
|
51
|
+
export function acos<T>(x: T): MapFunResult<T, any>;
|
|
52
|
+
export function acos<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
53
|
+
|
|
54
|
+
export function asin<T>(x: T): MapFunResult<T, any>;
|
|
55
|
+
export function asin<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
56
|
+
|
|
57
|
+
export function atan<T>(x: T): MapFunResult<T, any>;
|
|
58
|
+
export function atan<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
59
|
+
|
|
60
|
+
export function acot<T>(x: T): MapFunResult<T, any>;
|
|
61
|
+
export function acot<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
62
|
+
|
|
63
|
+
export function cosh<T>(x: T): MapFunResult<T, any>;
|
|
64
|
+
export function cosh<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
65
|
+
|
|
66
|
+
export function sinh<T>(x: T): MapFunResult<T, any>;
|
|
67
|
+
export function sinh<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
68
|
+
|
|
69
|
+
export function tanh<T>(x: T): MapFunResult<T, any>;
|
|
70
|
+
export function tanh<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
71
|
+
|
|
72
|
+
export function coth<T>(x: T): MapFunResult<T, any>;
|
|
73
|
+
export function coth<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
74
|
+
|
|
75
|
+
export function acosh<T>(x: T): MapFunResult<T, any>;
|
|
76
|
+
export function acosh<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
77
|
+
|
|
78
|
+
export function asinh<T>(x: T): MapFunResult<T, any>;
|
|
79
|
+
export function asinh<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
80
|
+
|
|
81
|
+
export function atanh<T>(x: T): MapFunResult<T, any>;
|
|
82
|
+
export function atanh<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
83
|
+
|
|
84
|
+
export function sig<T>(x: T): MapFunResult<T, any>;
|
|
85
|
+
export function sig<T extends any[]>(...x: T): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
86
|
+
|
|
87
|
+
// --- Functions that pop parameters from the end (pow, nthr, croot) ---
|
|
88
|
+
|
|
89
|
+
export function pow<T, N>(base: T, n: N): MapFunResult<T, any>;
|
|
90
|
+
export function pow<T extends any[], N>(...args: [...T, N]): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
91
|
+
|
|
92
|
+
export function nthr<T, N extends number>(base: T, n: N): MapFunResult<T, any>;
|
|
93
|
+
export function nthr<T extends any[], N extends number>(...args: [...T, N]): { [K in keyof T]: MapFunResult<T[K], any> };
|
|
94
|
+
|
|
95
|
+
export function croot<T, C>(base: T, root: C): MapFunResult<T, any>;
|
|
96
|
+
export function croot<T extends any[], C>(...args: [...T, C]): { [K in keyof T]: MapFunResult<T[K], any> };
|
package/src/ufunc/index.js
CHANGED
|
@@ -1 +1,372 @@
|
|
|
1
|
-
|
|
1
|
+
import { mapfun } from 'ziko/math/mapfun';
|
|
2
|
+
import { complex } from '../complex/index.js'
|
|
3
|
+
|
|
4
|
+
const PRECESION = 8
|
|
5
|
+
|
|
6
|
+
export const abs = (...x) => mapfun(
|
|
7
|
+
x =>{
|
|
8
|
+
if(x.isComplex?.()) return x.z;
|
|
9
|
+
return Math.abs(x)
|
|
10
|
+
},
|
|
11
|
+
...x
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
export const pow = (...x) => {
|
|
15
|
+
const n = x.pop();
|
|
16
|
+
return mapfun(
|
|
17
|
+
x => {
|
|
18
|
+
if(x.isComplex?.()) {
|
|
19
|
+
if(n.isComplex?.()) return new x.constructor({
|
|
20
|
+
z: Math.exp(n.a * Math.log(x.z) - n.b * x.phi),
|
|
21
|
+
phi: n.b * Math.log(x.z) + n.a * x.phi
|
|
22
|
+
})
|
|
23
|
+
return new x.constructor({z: x.z ** n, phi: x.phi * n});
|
|
24
|
+
}
|
|
25
|
+
if(n.isComplex?.()) return new x.constructor({
|
|
26
|
+
z: Math.exp(n.a * Math.log(x)),
|
|
27
|
+
phi: n.b * Math.log(x)
|
|
28
|
+
})
|
|
29
|
+
return Math.pow(x, n)
|
|
30
|
+
},
|
|
31
|
+
...x
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const sqrt = (...x) => mapfun(
|
|
36
|
+
x=>{
|
|
37
|
+
if(x.isComplex?.())
|
|
38
|
+
return new x.constructor({z: x.z**(1/2), phi: x.phi/2});
|
|
39
|
+
if(x < 0) return complex(0, Math.sqrt(-x)).toFixed(PRECESION)
|
|
40
|
+
return + Math.sqrt(x).toFixed(PRECESION);
|
|
41
|
+
},
|
|
42
|
+
...x
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
export const cbrt = (...x) => mapfun(
|
|
46
|
+
x=>{
|
|
47
|
+
if(x.isComplex?.())
|
|
48
|
+
return new x.constructor({z: x.z**(1/3), phi: x.phi/3}).toFixed(PRECESION)
|
|
49
|
+
return + Math.cbrt(x).toFixed(PRECESION);
|
|
50
|
+
},
|
|
51
|
+
...x
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
export const nthr = (...x) => {
|
|
55
|
+
const n = x.pop();
|
|
56
|
+
if(typeof n !== 'number') throw Error('nthr expects a real number n');
|
|
57
|
+
return mapfun(
|
|
58
|
+
x => {
|
|
59
|
+
if(x.isComplex?.()) return new x.constructor({z: x.z ** (1/n), phi: x.phi / n});
|
|
60
|
+
if(x<0) return n %2 ===2
|
|
61
|
+
? complex(0, (-x)**(1/n)).toFixed(PRECESION)
|
|
62
|
+
: + (-1 * (-x)**(1/n)).toFixed(PRECESION)
|
|
63
|
+
return + (x**(1/n)).toFixed(PRECESION)
|
|
64
|
+
},
|
|
65
|
+
...x
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const croot = (...x) =>{
|
|
70
|
+
const c = x.pop()
|
|
71
|
+
if(!c.isComplex?.()) throw Error('croot expect Complex number as root')
|
|
72
|
+
return mapfun(
|
|
73
|
+
x => {
|
|
74
|
+
if(typeof x === 'number') x = new c.constructor(x, 0);
|
|
75
|
+
const {a : c_a, b : c_b} = c;
|
|
76
|
+
const {z, phi} = x;
|
|
77
|
+
const D = Math.hypot(c_a, c_b);
|
|
78
|
+
const A = Math.exp((Math.log(z)*c_a + phi*c_b)/D);
|
|
79
|
+
const B = (phi*c_a - Math.log(z)*c_b)/D
|
|
80
|
+
return new c.constructor(
|
|
81
|
+
A * Math.cos(B),
|
|
82
|
+
A * Math.sin(B)
|
|
83
|
+
).toFixed(PRECESION)
|
|
84
|
+
},
|
|
85
|
+
...x
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export const exp = (...x) => mapfun(
|
|
90
|
+
x => {
|
|
91
|
+
if(x.isComplex?.()) return new x.constructor(
|
|
92
|
+
Math.exp(x.a) * Math.cos(x.b),
|
|
93
|
+
Math.exp(x.a) * Math.sin(x.b)
|
|
94
|
+
).toFixed(PRECESION);
|
|
95
|
+
return + Math.exp(x).toFixed(PRECESION)
|
|
96
|
+
}
|
|
97
|
+
,...x
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
export const ln = (...x) => mapfun(
|
|
101
|
+
x => {
|
|
102
|
+
if(x.isComplex?.()) return new x.constructor(
|
|
103
|
+
Math.log(x.z),
|
|
104
|
+
x.phi
|
|
105
|
+
).toFixed(PRECESION);
|
|
106
|
+
return + Math.log(x).toFixed(PRECESION)
|
|
107
|
+
}
|
|
108
|
+
,...x
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
export const sign = (...x) => mapfun(
|
|
112
|
+
x => {
|
|
113
|
+
if(x.isComplex?.()){
|
|
114
|
+
const {z, phi} = x;
|
|
115
|
+
if(z===0) return new x.constructor(0, 0);
|
|
116
|
+
return new x.constructor({z:1, phi})
|
|
117
|
+
}
|
|
118
|
+
return Math.sign(x)
|
|
119
|
+
}
|
|
120
|
+
,...x
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
export const floor = (...x) => mapfun(
|
|
124
|
+
x => {
|
|
125
|
+
if(x.isComplex?.()) return new x.constructor(
|
|
126
|
+
Math.floor(x.a),
|
|
127
|
+
Math.floor(x.b)
|
|
128
|
+
)
|
|
129
|
+
return Math.floor(x)
|
|
130
|
+
},
|
|
131
|
+
...x
|
|
132
|
+
)
|
|
133
|
+
export const ceil = (...x) => mapfun(
|
|
134
|
+
x => {
|
|
135
|
+
if(x.isComplex?.()) return new x.constructor(
|
|
136
|
+
Math.ceil(x.a),
|
|
137
|
+
Math.ceil(x.b)
|
|
138
|
+
)
|
|
139
|
+
return Math.ceil(x)
|
|
140
|
+
},
|
|
141
|
+
...x
|
|
142
|
+
)
|
|
143
|
+
export const round = (...x) => mapfun(
|
|
144
|
+
x => {
|
|
145
|
+
if(x.isComplex?.()) return new x.constructor(
|
|
146
|
+
Math.round(x.a),
|
|
147
|
+
Math.round(x.b)
|
|
148
|
+
)
|
|
149
|
+
return Math.round(x)
|
|
150
|
+
},
|
|
151
|
+
...x
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
export const trunc = (...x) => mapfun(
|
|
155
|
+
x => {
|
|
156
|
+
if(x.isComplex?.()) return new x.constructor(
|
|
157
|
+
Math.trunc(x.a),
|
|
158
|
+
Math.trunc(x.b)
|
|
159
|
+
)
|
|
160
|
+
return Math.trunc(x)
|
|
161
|
+
},
|
|
162
|
+
...x
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
export const fract = (...x) => mapfun(
|
|
166
|
+
x => {
|
|
167
|
+
if(x.isComplex?.()) return new x.constructor(
|
|
168
|
+
x.a - Math.trunc(x.a),
|
|
169
|
+
x.b - Math.trunc(x.b)
|
|
170
|
+
)
|
|
171
|
+
return x - Math.trunc(x)
|
|
172
|
+
},
|
|
173
|
+
...x
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
export const cos = (...x) => mapfun(
|
|
177
|
+
x => {
|
|
178
|
+
if(x.isComplex?.()) return new x.constructor(
|
|
179
|
+
Math.cos(x.a) * Math.cosh(x.b),
|
|
180
|
+
-Math.sin(x.a) * Math.sinh(x.b)
|
|
181
|
+
).toFixed(PRECESION);
|
|
182
|
+
return + Math.cos(x).toFixed(PRECESION)
|
|
183
|
+
}
|
|
184
|
+
,...x
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
export const sin = (...x) => mapfun(
|
|
188
|
+
x =>{
|
|
189
|
+
if(x?.isComplex) return new x.constructor(
|
|
190
|
+
Math.sin(x.a) * Math.cosh(x.b),
|
|
191
|
+
Math.cos(x.a) * Math.sinh(x.b)
|
|
192
|
+
).toFixed(PRECESION);
|
|
193
|
+
return + Math.sin(x).toFixed(PRECESION)
|
|
194
|
+
}
|
|
195
|
+
, ...x
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
export const tan = (...x) => mapfun(
|
|
199
|
+
x =>{
|
|
200
|
+
if(x?.isComplex){
|
|
201
|
+
const D = Math.cos(2*x.a) + Math.cosh(2*x.b);
|
|
202
|
+
return new x.constructor(
|
|
203
|
+
Math.sin(2*x.a) / D,
|
|
204
|
+
Math.sinh(2*x.b) / D
|
|
205
|
+
).toFixed(PRECESION);
|
|
206
|
+
}
|
|
207
|
+
return + Math.tan(x).toFixed(PRECESION)
|
|
208
|
+
},
|
|
209
|
+
...x
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
export const sec = (...x) => mapfun(
|
|
213
|
+
x => {
|
|
214
|
+
if(x.isComplex?.()) {
|
|
215
|
+
|
|
216
|
+
}
|
|
217
|
+
return + (1 / Math.cos(x)).toFixed(PRECESION)
|
|
218
|
+
}
|
|
219
|
+
,...x
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
export const acos = (...x) => mapfun(
|
|
223
|
+
x =>{
|
|
224
|
+
if(x?.isComplex){
|
|
225
|
+
const { a, b } = x;
|
|
226
|
+
const Rp = Math.hypot(a + 1, b);
|
|
227
|
+
const Rm = Math.hypot(a - 1, b);
|
|
228
|
+
globalThis.Rp = Rp
|
|
229
|
+
globalThis.Rm = Rm
|
|
230
|
+
return new x.constructor(
|
|
231
|
+
Math.acos((Rp - Rm) / 2),
|
|
232
|
+
-Math.acosh((Rp + Rm) / 2),
|
|
233
|
+
).toFixed(PRECESION)
|
|
234
|
+
}
|
|
235
|
+
return + Math.acos(x).toFixed(PRECESION)
|
|
236
|
+
},
|
|
237
|
+
...x
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
export const asin = (...x) => mapfun(
|
|
241
|
+
x => {
|
|
242
|
+
if(x?.isComplex){
|
|
243
|
+
const { a, b } = x;
|
|
244
|
+
const Rp = Math.hypot(a + 1, b);
|
|
245
|
+
const Rm = Math.hypot(a - 1, b);
|
|
246
|
+
return new x.constructor(
|
|
247
|
+
Math.asin((Rp - Rm) / 2),
|
|
248
|
+
Math.acosh((Rp + Rm) / 2)
|
|
249
|
+
).toFixed(PRECESION);
|
|
250
|
+
}
|
|
251
|
+
return + Math.asin(x).toFixed(PRECESION);
|
|
252
|
+
},
|
|
253
|
+
...x
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
export const atan = (...x) => mapfun(
|
|
257
|
+
x => {
|
|
258
|
+
if(x?.isComplex){
|
|
259
|
+
const { a, b } = x;
|
|
260
|
+
return new x.constructor(
|
|
261
|
+
Math.atan((a*2/(1-a**2-b**2)))/2,
|
|
262
|
+
Math.log((a**2 + (1+b)**2)/(a**2 + (1-b)**2))/4
|
|
263
|
+
).toFixed(PRECESION)
|
|
264
|
+
}
|
|
265
|
+
return + Math.atan(x).toFixed(PRECESION);
|
|
266
|
+
},
|
|
267
|
+
...x
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
export const acot = (...x) => mapfun(
|
|
271
|
+
x => {
|
|
272
|
+
if(x?.isComplex){
|
|
273
|
+
const { a, b } = x;
|
|
274
|
+
return new x.constructor(
|
|
275
|
+
Math.atan(2*a/(a**2+(b-1)*(b+1)))/2,
|
|
276
|
+
Math.log((a**2 + (b-1)**2)/(a**2 + (b+1)**2))/4
|
|
277
|
+
).toFixed(PRECESION)
|
|
278
|
+
}
|
|
279
|
+
return + (Math.PI/2 - Math.atan(x)).toFixed(PRECESION);
|
|
280
|
+
},
|
|
281
|
+
...x
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
export const cosh = (...x) => mapfun(
|
|
286
|
+
x =>{
|
|
287
|
+
if(x?.isComplex) return new x.constructor(
|
|
288
|
+
Math.cosh(x.a) * Math.cos(x.b),
|
|
289
|
+
Math.sinh(x.a) * Math.sin(x.b)
|
|
290
|
+
).toFixed(PRECESION);
|
|
291
|
+
return + Math.cosh(x).toFixed(PRECESION)
|
|
292
|
+
},
|
|
293
|
+
...x
|
|
294
|
+
)
|
|
295
|
+
export const sinh = (...x) => mapfun(
|
|
296
|
+
x =>{
|
|
297
|
+
if(x?.isComplex) return new x.constructor(
|
|
298
|
+
Math.sinh(x.a) * Math.cos(x.b),
|
|
299
|
+
Math.cosh(x.a) * Math.sin(x.b)
|
|
300
|
+
).toFixed(PRECESION);
|
|
301
|
+
return + Math.sinh(x).toFixed(PRECESION)
|
|
302
|
+
},
|
|
303
|
+
...x
|
|
304
|
+
)
|
|
305
|
+
export const tanh = (...x) => mapfun(
|
|
306
|
+
x =>{
|
|
307
|
+
if(x?.isComplex){
|
|
308
|
+
const D = Math.cosh(2*a) + Math.cos(2*b);
|
|
309
|
+
return new x.constructor(
|
|
310
|
+
Math.sinh(2*a) / D,
|
|
311
|
+
Math.sin(2*b) / D
|
|
312
|
+
).toFixed(PRECESION)
|
|
313
|
+
}
|
|
314
|
+
return + Math.tanh(x).toFixed(PRECESION)
|
|
315
|
+
},
|
|
316
|
+
...x
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
export const coth = (...x) => mapfun(
|
|
320
|
+
x =>{
|
|
321
|
+
if(x?.isComplex){
|
|
322
|
+
const {a, b} = x
|
|
323
|
+
const D = (Math.sinh(a)**2)*(Math.cos(b)**2) + (Math.cosh(a)**2)*(Math.sin(b)**2)
|
|
324
|
+
return new x.constructor(
|
|
325
|
+
Math.cosh(a) * Math.sinh(a) / D,
|
|
326
|
+
- Math.sin(b) * Math.cos(b) / D
|
|
327
|
+
).toFixed(PRECESION)
|
|
328
|
+
}
|
|
329
|
+
return + (1 / Math.tanh(x)).toFixed(PRECESION)
|
|
330
|
+
},
|
|
331
|
+
...x
|
|
332
|
+
)
|
|
333
|
+
|
|
334
|
+
export const acosh = (...x) => mapfun(
|
|
335
|
+
x =>{
|
|
336
|
+
if(x?.isComplex){
|
|
337
|
+
return ln(x.clone().add(sqrt(x.clone().mul(x.clone()).sub(1))))
|
|
338
|
+
}
|
|
339
|
+
return + Math.acosh(x).toFixed(PRECESION)
|
|
340
|
+
},
|
|
341
|
+
...x
|
|
342
|
+
)
|
|
343
|
+
|
|
344
|
+
export const asinh = (...x) => mapfun(
|
|
345
|
+
x =>{
|
|
346
|
+
if(x?.isComplex){
|
|
347
|
+
return ln(x.clone().add(sqrt(x.clone().mul(x.clone()).add(1))))
|
|
348
|
+
}
|
|
349
|
+
return + Math.asinh(x).toFixed(PRECESION)
|
|
350
|
+
},
|
|
351
|
+
...x
|
|
352
|
+
)
|
|
353
|
+
|
|
354
|
+
export const atanh = (...x) => mapfun(
|
|
355
|
+
x =>{
|
|
356
|
+
if(x?.isComplex){
|
|
357
|
+
|
|
358
|
+
}
|
|
359
|
+
return + Math.atanh(x).toFixed(PRECESION)
|
|
360
|
+
},
|
|
361
|
+
...x
|
|
362
|
+
)
|
|
363
|
+
|
|
364
|
+
export const sig = (...x) => mapfun(
|
|
365
|
+
x =>{
|
|
366
|
+
if(x?.isComplex){
|
|
367
|
+
|
|
368
|
+
}
|
|
369
|
+
return + 1/(1 + Math.exp(-x)).toFixed(PRECESION)
|
|
370
|
+
},
|
|
371
|
+
...x
|
|
372
|
+
)
|