spreadsheet_ods_formula/generated/complex.rs
1//!
2//! Functions for complex numbers.
3
4use crate::*;
5#[allow(unused_imports)]
6use crate::complex::*;
7
8/// Creates a complex number from a given real coefficient and imaginary
9/// coefficient.
10///
11/// [documentfoundation->COMPLEX](https://wiki.documentfoundation.org/Documentation/Calc_Functions/COMPLEX)
12///
13/// __Syntax__:
14/// ```ods
15/// COMPLEX( Real: Number; Imaginary: Number )
16/// ```
17///
18/// __Constraints__:
19/// None
20///
21/// __Semantics__:
22/// Constructs a complex number from the given coefficients. The third
23/// parameter Suffix is optional, and should be either “i” or “j”.
24/// Upper case “I” or “J” are not accepted for the suffix parameter.
25///
26/// __See also__: [crate::of::complex_()],
27#[inline]
28pub fn complex<A: Number, B: Number>(real: A, imaginary: B) -> FnNumber2<A, B> {
29 FnNumber2("COMPLEX", real, imaginary)
30}
31
32/// Creates a complex number from a given real coefficient and imaginary
33/// coefficient.
34///
35/// [documentfoundation->COMPLEX](https://wiki.documentfoundation.org/Documentation/Calc_Functions/COMPLEX)
36///
37/// __Syntax__:
38/// ```ods
39/// COMPLEX( Real: Number; Imaginary: Number; Suffix: Text )
40/// ```
41///
42/// __Constraints__:
43/// None
44///
45/// __Semantics__:
46/// Constructs a complex number from the given coefficients. The third
47/// parameter Suffix is optional, and should be either “i” or “j”.
48/// Upper case “I” or “J” are not accepted for the suffix parameter.
49///
50/// __See also__: [crate::of::complex()],
51#[inline]
52pub fn complex_<A: Number, B: Number, C: Text>(real: A, imaginary: B, suffix: C) -> FnNumber3<A, B, C> {
53 FnNumber3("COMPLEX", real, imaginary, suffix)
54}
55
56/// Returns the absolute value of a complex number.
57///
58/// [documentfoundation->IMABS](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IMABS)
59///
60/// __Syntax__:
61/// ```ods
62/// IMABS( X: Complex )
63/// ```
64///
65/// __Constraints__:
66/// None
67///
68/// __Semantics__:
69/// If X = a + bi or X = a + bj, the absolute value =
70/// ; if X = r(cosφ + isinφ), the absolute value = r.
71///
72/// __See also__: [crate::of::imargument()],
73#[inline]
74pub fn imabs<A: Number>(x: A) -> FnNumber1<A> {
75 FnNumber1("IMABS", x)
76}
77
78/// Returns the imaginary coefficient of a complex number.
79///
80/// [documentfoundation->IMAGINARY](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IMAGINARY)
81///
82/// __Syntax__:
83/// ```ods
84/// IMAGINARY( X: Complex )
85/// ```
86///
87/// __Constraints__:
88/// None
89///
90/// __Semantics__:
91/// If X = a + bi or X = a + bj, then the imaginary coefficient is b.
92///
93/// __See also__: [crate::of::imreal()],
94#[inline]
95pub fn imaginary<A: Number>(x: A) -> FnNumber1<A> {
96 FnNumber1("IMAGINARY", x)
97}
98
99/// Returns the complex argument of a complex number.
100///
101/// [documentfoundation->IMARGUMENT](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IMARGUMENT)
102///
103/// __Syntax__:
104/// ```ods
105/// IMARGUMENT( X: Complex )
106/// ```
107///
108/// __Constraints__:
109/// None
110///
111/// __Semantics__:
112/// If X = a + bi = r(cosφ + isinφ), a or b is not 0 and -π < φ ≤ π,
113/// then the complex argument is φ. φ is expressed by radians. If X = 0, then
114/// IMARGUMENT(X) is implementation-defined and either 0 or an error.
115///
116/// __See also__: [crate::of::imabs()],
117#[inline]
118pub fn imargument<A: Number>(x: A) -> FnNumber1<A> {
119 FnNumber1("IMARGUMENT", x)
120}
121
122/// Returns the complex conjugate of a complex number.
123///
124/// [documentfoundation->IMCONJUGATE](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IMCONJUGATE)
125///
126/// __Syntax__:
127/// ```ods
128/// IMCONJUGATE( X: Complex )
129/// ```
130///
131/// __Constraints__:
132/// None
133///
134/// __Semantics__:
135/// If X = a + bi, then the complex conjugate is a - bi.
136///
137/// __See also__:
138#[inline]
139pub fn imconjugate<A: Number>(x: A) -> FnNumber1<A> {
140 FnNumber1("IMCONJUGATE", x)
141}
142
143/// Returns the cosine of a complex number.
144///
145/// [documentfoundation->IMCOS](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IMCOS)
146///
147/// __Syntax__:
148/// ```ods
149/// IMCOS( X: Complex )
150/// ```
151///
152/// __Constraints__:
153/// None
154///
155/// __Semantics__:
156/// If X = a + bi, then cos(X) = cos(a)cosh(b) - sin(a)sinh(b)i.
157///
158/// __See also__: [crate::of::imsin()],
159#[inline]
160pub fn imcos<A: Number>(x: A) -> FnNumber1<A> {
161 FnNumber1("IMCOS", x)
162}
163
164/// Returns the hyperbolic cosine of a complex number.
165///
166/// [documentfoundation->IMCOSH](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IMCOSH)
167///
168/// __Syntax__:
169/// ```ods
170/// IMCOSH( N: Complex )
171/// ```
172///
173/// __Constraints__:
174/// None
175///
176/// __Semantics__:
177/// If N = a + bi, then cosh(N) = cosh(a)cos(b) + sinh(a)sin(b)i.
178///
179/// __See also__:
180#[inline]
181pub fn imcosh<A: Number>(n: A) -> FnNumber1<A> {
182 FnNumber1("IMCOSH", n)
183}
184
185/// Returns the cotangent of a complex number.
186///
187/// [documentfoundation->IMCOT](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IMCOT)
188///
189/// __Syntax__:
190/// ```ods
191/// IMCOT( N: Complex )
192/// ```
193///
194/// __Constraints__:
195/// None
196///
197/// __Semantics__:
198/// Equivalent to the following (except N is computed only once):
199///
200/// IMDIV(IMCOS(N);IMSIN(N))
201///
202/// __See also__: [crate::of::imcos()], [crate::of::imdiv()], [crate::of::imsin()], [crate::of::imtan()],
203#[inline]
204pub fn imcot<A: Number>(n: A) -> FnNumber1<A> {
205 FnNumber1("IMCOT", n)
206}
207
208/// Returns the cosecant of a complex number.
209///
210/// [documentfoundation->IMCSC](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IMCSC)
211///
212/// __Syntax__:
213/// ```ods
214/// IMCSC( N: Complex )
215/// ```
216///
217/// __Constraints__:
218/// None
219///
220/// __Semantics__:
221/// Equivalent to the following:
222///
223/// IMDIV(1;IMSIN(N))
224///
225/// __See also__: [crate::of::imdiv()], [crate::of::imsin()],
226#[inline]
227pub fn imcsc<A: Number>(n: A) -> FnNumber1<A> {
228 FnNumber1("IMCSC", n)
229}
230
231/// Returns the hyperbolic cosecant of a complex number.
232///
233/// [documentfoundation->IMCSCH](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IMCSCH)
234///
235/// __Syntax__:
236/// ```ods
237/// IMCSCH( N: Complex )
238/// ```
239///
240/// __Constraints__:
241/// None
242///
243/// __Semantics__:
244/// Computes the hyperbolic cosecant. This is equivalent to:
245///
246/// IMDIV(1;IMSINH(N))
247///
248/// __See also__: [crate::of::imsinh()], [crate::of::csch()],
249#[inline]
250pub fn imcsch<A: Number>(n: A) -> FnNumber1<A> {
251 FnNumber1("IMCSCH", n)
252}
253
254/// Divides the first number by the second.
255///
256/// [documentfoundation->IMDIV](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IMDIV)
257///
258/// __Syntax__:
259/// ```ods
260/// IMDIV( X: Complex; Y: Complex )
261/// ```
262///
263/// __Constraints__:
264/// None
265///
266/// __Semantics__:
267/// Given X = a + bi and Y = c + di, return the quotient
268///
269/// Division by zero returns an Error.
270///
271/// __See also__:
272#[inline]
273pub fn imdiv<A: Number, B: Number>(x: A, y: B) -> FnNumber2<A, B> {
274 FnNumber2("IMDIV", x, y)
275}
276
277/// Returns the exponent of e and a complex number.
278///
279/// [documentfoundation->IMEXP](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IMEXP)
280///
281/// __Syntax__:
282/// ```ods
283/// IMEXP( X: Complex )
284/// ```
285///
286/// __Constraints__:
287/// None
288///
289/// __Semantics__:
290/// If X = a + bi, the result is
291/// .
292///
293/// __See also__: [crate::of::imln()],
294#[inline]
295pub fn imexp<A: Number>(x: A) -> FnNumber1<A> {
296 FnNumber1("IMEXP", x)
297}
298
299/// Returns the natural logarithm of a complex number.
300///
301/// [documentfoundation->IMLN](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IMLN)
302///
303/// __Syntax__:
304/// ```ods
305/// IMLN( X: Complex )
306/// ```
307///
308/// __Constraints__:
309/// X ≠ 0
310///
311/// __Semantics__:
312/// COMPLEX(LN(IMABS(X)); IMARGUMENT(X)) .
313///
314/// __See also__: [crate::of::complex()], [crate::of::imabs()], [crate::of::imargument()], [crate::of::imexp()], [crate::of::imlog10()], [crate::of::ln()],
315#[inline]
316pub fn imln<A: Number>(x: A) -> FnNumber1<A> {
317 FnNumber1("IMLN", x)
318}
319
320/// Returns the common logarithm of a complex number.
321///
322/// [documentfoundation->IMLOG10](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IMLOG10)
323///
324/// __Syntax__:
325/// ```ods
326/// IMLOG10( X: Complex )
327/// ```
328///
329/// __Constraints__:
330/// X ≠ 0
331///
332/// __Semantics__:
333/// IMLOG10(X) is IMDIV(IMLN(X);COMPLEX(LN(10);0)) .
334///
335/// __See also__: [crate::of::complex()], [crate::of::imdiv()], [crate::of::imln()], [crate::of::impower()], [crate::of::ln()],
336#[inline]
337pub fn imlog10<A: Number>(x: A) -> FnNumber1<A> {
338 FnNumber1("IMLOG10", x)
339}
340
341/// Returns the binary logarithm of a complex number.
342///
343/// [documentfoundation->IMLOG2](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IMLOG2)
344///
345/// __Syntax__:
346/// ```ods
347/// IMLOG2( X: Complex )
348/// ```
349///
350/// __Constraints__:
351/// X ≠ 0
352///
353/// __Semantics__:
354/// IMLOG2(X) is IMDIV(IMLN(X);COMPLEX(LN(2);0)) .
355///
356/// __See also__: [crate::of::complex()], [crate::of::imdiv()], [crate::of::imln()], [crate::of::impower()], [crate::of::ln()],
357#[inline]
358pub fn imlog2<A: Number>(x: A) -> FnNumber1<A> {
359 FnNumber1("IMLOG2", x)
360}
361
362/// Returns the complex number X raised to the Yth power.
363///
364/// [documentfoundation->IMPOWER](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IMPOWER)
365///
366/// __Syntax__:
367/// ```ods
368/// IMPOWER( X: Complex; Y: Complex )
369/// ```
370///
371/// __Constraints__:
372/// X ≠ 0
373///
374/// __Semantics__:
375/// IMPOWER(X;Y) is IMEXP(IMPRODUCT(Y; IMLN(X)))
376///
377/// An evaluator implementing this function shall permit any Number Y but may
378/// also allow any Complex Y.
379///
380/// __See also__: [crate::of::imexp()], [crate::of::imln()], [crate::of::improduct()],
381#[inline]
382pub fn impower<A: Number, B: Number>(x: A, y: B) -> FnNumber2<A, B> {
383 FnNumber2("IMPOWER", x, y)
384}
385
386/// Returns the product of complex numbers.
387///
388/// [documentfoundation->IMPRODUCT](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IMPRODUCT)
389///
390/// __Syntax__:
391/// ```ods
392/// IMPRODUCT({ N: ComplexSequence}+ )
393/// ```
394///
395/// __Constraints__:
396/// None
397///
398/// __Semantics__:
399/// Multiply the complex numbers together. Given two complex numbers X = a + bi
400/// and
401/// Y = c + di, the product X * Y = (ac - bd) + (ad + bc)i
402///
403/// __See also__: [crate::of::imdiv()],
404#[inline]
405pub fn improduct<A: Sequence>(n: A) -> FnNumber1<A> {
406 FnNumber1("IMPRODUCT", n)
407}
408
409/// Returns the real coefficient of a complex number.
410///
411/// [documentfoundation->IMREAL](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IMREAL)
412///
413/// __Syntax__:
414/// ```ods
415/// IMREAL( N: Complex )
416/// ```
417///
418/// __Constraints__:
419/// None
420///
421/// __Semantics__:
422/// If N = a + bi or N = a + bj, then the real coefficient is a.
423///
424/// __See also__: [crate::of::imaginary()],
425#[inline]
426pub fn imreal<A: Number>(n: A) -> FnNumber1<A> {
427 FnNumber1("IMREAL", n)
428}
429
430/// Returns the sine of a complex number.
431///
432/// [documentfoundation->IMSIN](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IMSIN)
433///
434/// __Syntax__:
435/// ```ods
436/// IMSIN( N: Complex )
437/// ```
438///
439/// __Constraints__:
440/// None
441///
442/// __Semantics__:
443/// If N = a + bi, then sin(N) = sin(a)cosh(b) + cos(a)sinh(b)i.
444///
445/// __See also__: [crate::of::imcos()],
446#[inline]
447pub fn imsin<A: Number>(n: A) -> FnNumber1<A> {
448 FnNumber1("IMSIN", n)
449}
450
451/// Returns the hyperbolic sine of a complex number.
452///
453/// [documentfoundation->IMSINH](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IMSINH)
454///
455/// __Syntax__:
456/// ```ods
457/// IMSINH( N: Complex )
458/// ```
459///
460/// __Constraints__:
461/// None
462///
463/// __Semantics__:
464/// If N = a + bi, then sinh(N) = sinh(a)cos(b) + cosh(a)sin(b)i.
465///
466/// __See also__:
467#[inline]
468pub fn imsinh<A: Number>(n: A) -> FnNumber1<A> {
469 FnNumber1("IMSINH", n)
470}
471
472/// Returns the secant of a complex number.
473///
474/// [documentfoundation->IMSEC](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IMSEC)
475///
476/// __Syntax__:
477/// ```ods
478/// IMSEC( N: Complex )
479/// ```
480///
481/// __Constraints__:
482/// None
483///
484/// __Semantics__:
485/// Equivalent to the following:
486///
487/// IMDIV(1;IMCOS(N))
488///
489/// __See also__: [crate::of::imcos()], [crate::of::imdiv()],
490#[inline]
491pub fn imsec<A: Number>(n: A) -> FnNumber1<A> {
492 FnNumber1("IMSEC", n)
493}
494
495/// Returns the hyperbolic secant of a complex number.
496///
497/// [documentfoundation->IMSECH](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IMSECH)
498///
499/// __Syntax__:
500/// ```ods
501/// IMSECH( N: Complex )
502/// ```
503///
504/// __Constraints__:
505/// None
506///
507/// __Semantics__:
508/// Computes the hyperbolic secant. This is equivalent to:
509///
510/// IMDIV(1;IMCOSH(N))
511///
512/// __See also__: [crate::of::imcosh()], [crate::of::imdiv()], [crate::of::sech()],
513#[inline]
514pub fn imsech<A: Number>(n: A) -> FnNumber1<A> {
515 FnNumber1("IMSECH", n)
516}
517
518/// Returns the square root of a complex number.
519///
520/// [documentfoundation->IMSQRT](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IMSQRT)
521///
522/// __Syntax__:
523/// ```ods
524/// IMSQRT( N: Complex )
525/// ```
526///
527/// __Constraints__:
528/// None
529///
530/// __Semantics__:
531/// If N = 0 + 0i, then IMSQRT(N) = 0. Otherwise IMSQRT(N) is
532/// SQRT(IMABS(N)) * sin(IMARGUMENT(N) / 2) + SQRT(IMABS(N)) *
533/// cos(IMARGUMENT(N) / 2)i.
534///
535/// __See also__: [crate::of::imabs()], [crate::of::imargument()], [crate::of::impower()], [crate::of::sqrt()],
536#[inline]
537pub fn imsqrt<A: Number>(n: A) -> FnNumber1<A> {
538 FnNumber1("IMSQRT", n)
539}
540
541/// Subtracts the second complex number from the first.
542///
543/// [documentfoundation->IMSUB](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IMSUB)
544///
545/// __Syntax__:
546/// ```ods
547/// IMSUB( X: Complex; Y: Complex )
548/// ```
549///
550/// __Constraints__:
551/// None
552///
553/// __Semantics__:
554/// Subtract complex number Y from X.
555///
556/// __See also__: [crate::of::imsum()],
557#[inline]
558pub fn imsub<A: Number, B: Number>(x: A, y: B) -> FnNumber2<A, B> {
559 FnNumber2("IMSUB", x, y)
560}
561
562/// Sums (add) a set of complex numbers, including all numbers in ranges.
563///
564/// [documentfoundation->IMSUM](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IMSUM)
565///
566/// __Syntax__:
567/// ```ods
568/// IMSUM({ N: ComplexSequence}+ )
569/// ```
570///
571/// __Constraints__:
572/// None
573///
574/// __Semantics__:
575/// Adds complex numbers together. Text that cannot be converted to a complex
576/// number is ignored.
577///
578/// It is implementation-defined what happens if this function is given zero
579/// parameters; an evaluator may either produce an Error or the Number 0 if it
580/// is given zero parameters.
581///
582/// __See also__: [crate::of::imsub()],
583#[inline]
584pub fn imsum<A: Sequence>(n: A) -> FnNumber1<A> {
585 FnNumber1("IMSUM", n)
586}
587
588/// Returns the tangent of a complex number
589///
590/// [documentfoundation->IMTAN](https://wiki.documentfoundation.org/Documentation/Calc_Functions/IMTAN)
591///
592/// __Syntax__:
593/// ```ods
594/// IMTAN( N: Complex )
595/// ```
596///
597/// __Constraints__:
598/// None
599///
600/// __Semantics__:
601/// Equivalent to the following (except N is computed only once):
602///
603/// IMDIV(IMSIN(N);IMCOS(N))
604///
605/// __See also__: [crate::of::imdiv()], [crate::of::imsin()], [crate::of::imcos()], [crate::of::imcot()],
606#[inline]
607pub fn imtan<A: Number>(n: A) -> FnNumber1<A> {
608 FnNumber1("IMTAN", n)
609}