summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/proflycee/tex/proflycee-tools-complexes.tex
blob: d8379269b32d39a25f8b66bc315e2cf795f43e48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
% proflycee-tools-complexes.tex
% Copyright 2023  Cédric Pierquet (expérimental)
% Released under the LaTeX Project Public License v1.3c or later, see http://www.latex-project.org/lppl.txt

\NewDocumentCommand\PartieReelle{ D<>{} m O{\PartReRes} }{%
	\StrSubstitute{#2}{I}{0}[#3]%
	\IfEq{#1}{n}%
		{\ensuremath{\num{\xinteval{#3}}}}{}%
	\IfEq{#1}{f}%
		{\ensuremath{\ConversionFraction{#3}}}{}%
	\IfEq{#1}{df}%
		{\ensuremath{\ConversionFraction[d]{#3}}}{}%
}
\NewDocumentCommand\PartieImaginaire{ D<>{} m O{\PartImRes} }{%
	\StrSubstitute{#2}{I}{0}[\TmpPartReCplxA]%
	\StrSubstitute{(#2)-(\TmpPartReCplxA)}{I}{1}[#3]%
	\IfEq{#1}{n}%
		{\ensuremath{\num{\xinteval{#3}}}}{}%
	\IfEq{#1}{f}%
		{\ensuremath{\ConversionFraction{#3}}}{}%
	\IfEq{#1}{df}%
		{\ensuremath{\ConversionFraction[d]{#3}}}{}%
}

\NewDocumentCommand\AffComplexe{ O{} }{%
	\ensuremath{%
		\xintifboolexpr{\xinttmpreCalc == 0 'and' \xinttmpimCalc == 0}{0}{}%
		\xintifboolexpr{\xinttmpreCalc == 0 'and' \xinttmpimCalc == 1}{\i}{}%
		\xintifboolexpr{\xinttmpreCalc == 0 'and' \xinttmpimCalc == -1}{-\i}{}%
		\xintifboolexpr{\xinttmpreCalc == 0 'and' abs(\xinttmpimCalc) != 1 'and' \xinttmpimCalc != 0}{\ConversionFraction[#1]{\xinttmpimCalc}\i}{}%
		\xintifboolexpr{\xinttmpreCalc != 0 'and' \xinttmpimCalc < 0 'and' \xinttmpimCalc != -1}{\ConversionFraction[#1]{\xinttmpreCalc}-\ConversionFraction[#1]{-(\xinttmpimCalc)}\i}{}%
		\xintifboolexpr{\xinttmpreCalc != 0 'and' \xinttmpimCalc == -1}{\ConversionFraction[#1]{\xinttmpreCalc}-\i}{}%
		\xintifboolexpr{\xinttmpreCalc != 0 'and' \xinttmpimCalc == 1}{\ConversionFraction[#1]{\xinttmpreCalc}+\i}{}%
		\xintifboolexpr{\xinttmpreCalc != 0 'and' \xinttmpimCalc > 0 'and' \xinttmpimCalc != 1}{\ConversionFraction[#1]{\xinttmpreCalc}+\ConversionFraction[#1]{\xinttmpimCalc}\i}{}%
		\xintifboolexpr{\xinttmpreCalc != 0 'and' \xinttmpimCalc == 0}{\ConversionFraction[#1]{\xinttmpreCalc}}{}%
	}%
}

\NewDocumentCommand\Complexe{ O{} m }{%
	\PartieReelle{#2}[\tmpreA]%
	\PartieImaginaire{#2}[\tmpimA]%
	\xdef\xinttmpreCalc{\xinteval{\tmpreA}}%
	\xdef\xinttmpimCalc{\xinteval{\tmpimA}}%
	\ensuremath{%
		\xintifboolexpr{\xinttmpreCalc == 0 'and' \xinttmpimCalc == 0}{0}{}%
		\xintifboolexpr{\xinttmpreCalc == 0 'and' \xinttmpimCalc == 1}{\i}{}%
		\xintifboolexpr{\xinttmpreCalc == 0 'and' \xinttmpimCalc == -1}{-\i}{}%
		\xintifboolexpr{\xinttmpreCalc == 0 'and' abs(\xinttmpimCalc) != 1 'and' \xinttmpimCalc != 0}{\ConversionFraction[#1]{\tmpimA}\i}{}%
		\xintifboolexpr{\xinttmpreCalc != 0 'and' \xinttmpimCalc < 0 'and' \xinttmpimCalc != -1}{\ConversionFraction[#1]{\tmpreA}-\ConversionFraction[#1]{-(\tmpimA)}\i}{}%
		\xintifboolexpr{\xinttmpreCalc != 0 'and' \xinttmpimCalc == -1}{\ConversionFraction[#1]{\tmpreA}-\i}{}%
		\xintifboolexpr{\xinttmpreCalc != 0 'and' \xinttmpimCalc == 1}{\ConversionFraction[#1]{\tmpreA}+\i}{}%
		\xintifboolexpr{\xinttmpreCalc != 0 'and' \xinttmpimCalc > 0 'and' \xinttmpimCalc != 1}{\ConversionFraction[#1]{\tmpreA}+\ConversionFraction[#1]{\tmpimA}\i}{}%
		\xintifboolexpr{\xinttmpreCalc != 0 'and' \xinttmpimCalc == 0}{\ConversionFraction[#1]{\tmpreA}}{}%
	}%
}

\NewDocumentCommand\SommeComplexes{ O{} m m }{%
	\PartieReelle{#2}[\tmpreA]%
	\PartieReelle{#3}[\tmpreB]%
	\PartieImaginaire{#2}[\tmpimA]%
	\PartieImaginaire{#3}[\tmpimB]%
	%\xdef\tmpreCalc{(\tmpreA)+(\tmpreB)}%
	\xdef\xinttmpreCalc{\xinteval{(\tmpreA)+(\tmpreB)}}%
	%\xdef\tmpimCalc{(\tmpimA)+(\tmpimB)}%
	\xdef\xinttmpimCalc{\xinteval{(\tmpimA)+(\tmpimB)}}%
	%\xinttmpreCalc\text{ et }\xinttmpimCalc.
	\AffComplexe[#1]%
}

\NewDocumentCommand\DifferenceComplexes{ O{} m m }{%
	\PartieReelle{#2}[\tmpreA]%
	\PartieReelle{#3}[\tmpreB]%
	\PartieImaginaire{#2}[\tmpimA]%
	\PartieImaginaire{#3}[\tmpimB]%
	%\xdef\tmpreCalc{(\tmpreA)-(\tmpreB)}%
	\xdef\xinttmpreCalc{\xinteval{(\tmpreA)-(\tmpreB)}}%
	%\xdef\tmpimCalc{(\tmpimA)-(\tmpimB)}%
	\xdef\xinttmpimCalc{\xinteval{(\tmpimA)-(\tmpimB)}}%
	%\xinttmpreCalc\text{ et }\xinttmpimCalc.
	\AffComplexe[#1]%
}

\NewDocumentCommand\ProduitComplexes{ O{} m m }{%
	\PartieReelle{#2}[\tmpreA]%
	\PartieReelle{#3}[\tmpreB]%
	\PartieImaginaire{#2}[\tmpimA]%
	\PartieImaginaire{#3}[\tmpimB]%
	\xdef\tmpreCalc{(\tmpreA)*(\tmpreB)-(\tmpimA)*(\tmpimB)}%
	\xdef\xinttmpreCalc{\xinteval{\tmpreCalc}}%
	\xdef\tmpimCalc{(\tmpreA)*(\tmpimB)+(\tmpimA)*(\tmpreB)}%
	\xdef\xinttmpimCalc{\xinteval{\tmpimCalc}}%
	%\xinttmpreCalc\text{ et }\xinttmpimCalc.
	\AffComplexe[#1]%
}

\NewDocumentCommand\QuotientComplexes{ O{} m m }{%
	\PartieReelle{#2}[\tmpreA]%
	\PartieReelle{#3}[\tmpreB]%
	\PartieImaginaire{#2}[\tmpimA]%
	\PartieImaginaire{#3}[\tmpimB]%
	\xdef\tmpreCalc{((\tmpreA)*(\tmpreB)+(\tmpimA)*(\tmpimB))/((\tmpreB)*(\tmpreB)+(\tmpimB)*(\tmpimB))}%
	\xdef\xinttmpreCalc{\xinteval{\tmpreCalc}}%
	\xdef\tmpimCalc{(-(\tmpreA)*(\tmpimB)+(\tmpimA)*(\tmpreB))/((\tmpreB)*(\tmpreB)+(\tmpimB)*(\tmpimB))}%
	\xdef\xinttmpimCalc{\xinteval{\tmpimCalc}}%
	%\xinttmpreCalc\text{ et }\xinttmpimCalc.
	\AffComplexe[#1]%
}

\NewDocumentCommand\CarreComplexe{ O{} m }{%
	\PartieReelle{#2}[\tmpreA]%
	\PartieImaginaire{#2}[\tmpimA]%
	\xdef\tmpreCalc{(\tmpreA)*(\tmpreA)-(\tmpimA)*(\tmpimA)}%
	\xdef\xinttmpreCalc{\xinteval{\tmpreCalc}}%
	\xdef\tmpimCalc{2*(\tmpreA)*(\tmpimA)}%
	\xdef\xinttmpimCalc{\xinteval{\tmpimCalc}}%
	%\xinttmpreCalc\text{ et }\xinttmpimCalc.
	\AffComplexe[#1]%
}

\NewDocumentCommand\CubeComplexe{ O{} m }{%
	\PartieReelle{#2}[\tmpreA]%
	\PartieImaginaire{#2}[\tmpimA]%
	\xdef\tmpreCalc{(\tmpreA)*(\tmpreA)*(\tmpreA)-3*(\tmpreA)*(\tmpimA)*(\tmpimA)}%
	\xdef\xinttmpreCalc{\xinteval{\tmpreCalc}}%
	\xdef\tmpimCalc{3*(\tmpreA)*(\tmpreA)*(\tmpimA)-(\tmpimA)*(\tmpimA)*(\tmpimA)}%
	\xdef\xinttmpimCalc{\xinteval{\tmpimCalc}}%
	%\xinttmpreCalc\text{ et }\xinttmpimCalc.
	\AffComplexe[#1]%
}

\NewDocumentCommand\ModuleComplexe{ m }{%
	\PartieReelle{#1}[\tmpreA]%
	\PartieImaginaire{#1}[\tmpimA]%
	\IfSubStr{\tmpreA}{sqrt}%
		{%
			\StrDel{\tmpreA}{sqrt}[\tmpretmpA]%
		}%
		{%
			\xdef\tmpretmpA{\tmpreA}%
		}%
	\IfSubStr{\tmpimA}{sqrt}%
		{%
			\StrDel{\tmpimA}{sqrt}[\tmpimtmpA]%
		}%
		{%
			\xdef\tmpimtmpA{\tmpimA}%
		}%
	\IfSubStr{\tmpreA}{sqrt}%
		{%
			\IfSubStr{\tmpimA}{sqrt}%
				{%
					\xdef\tmpCarreModule{abs(\tmpretmpA)+abs(\tmpimtmpA)}%
				}%
				{%
					\xdef\tmpCarreModule{abs(\tmpretmpA)+(\tmpimtmpA)*(\tmpimtmpA)}%
				}%
		}%
		{%
			\xdef\tmpCarreModule{(\tmpretmpA)*(\tmpretmpA)+(\tmpimtmpA)*(\tmpimtmpA)}%
		}%
	\ensuremath{\SimplificationRacine{\tmpCarreModule}}%
}

\NewDocumentCommand\ArgumentComplexe{ O{} m }{%
	\PartieReelle{#2}[\tmpreA]%
	\PartieImaginaire{#2}[\tmpimA]%
	\xdef\tmpCarreModule{(\tmpreA)*(\tmpreA)+(\tmpimA)*(\tmpimA)}%
	\xdef\tmpModUnRe{(\tmpreA)/(sqrt(\tmpCarreModule))}%
	\xdef\tmpModUnIm{(\tmpimA)/(sqrt(\tmpCarreModule))}%
	\ensuremath{%
		\xintifboolexpr{\tmpModUnRe == 1 'and' \tmpModUnIm == 0}{0}{}%
		\xintifboolexpr{\tmpModUnRe == -1 'and' \tmpModUnIm == 0}{\pi}{}%
		\xintifboolexpr{\tmpModUnRe == 0.5 'and' \tmpModUnIm > 0}{\IfEq{#1}{d}{\dfrac{\pi}{3}}{\frac{\pi}{3}}}{}%
		\xintifboolexpr{\tmpModUnRe == 0.5 'and' \tmpModUnIm < 0}{\IfEq{#1}{d}{\dfrac{-\pi}{3}}{\frac{-\pi}{3}}}{}%
		\xintifboolexpr{\tmpModUnRe == -0.5 'and' \tmpModUnIm > 0}{\IfEq{#1}{d}{\dfrac{2\pi}{3}}{\frac{2\pi}{3}}}{}%
		\xintifboolexpr{\tmpModUnRe == -0.5 'and' \tmpModUnIm < 0}{\IfEq{#1}{d}{\dfrac{-2\pi}{3}}{\frac{-2\pi}{3}}}{}%
		\xintifboolexpr{\tmpModUnRe > 0 'and' \tmpModUnIm == 0.5}{\IfEq{#1}{d}{\dfrac{\pi}{6}}{\frac{\pi}{6}}}{}%
		\xintifboolexpr{\tmpModUnRe < 0 'and' \tmpModUnIm == 0.5}{\IfEq{#1}{d}{\dfrac{5\pi}{6}}{\frac{5\pi}{6}}}{}%
		\xintifboolexpr{\tmpModUnRe > 0 'and' \tmpModUnIm == -0.5}{\IfEq{#1}{d}{\dfrac{-\pi}{6}}{\frac{-\pi}{6}}}{}%
		\xintifboolexpr{\tmpModUnRe < 0 'and' \tmpModUnIm == -0.5}{\IfEq{#1}{d}{\dfrac{-5\pi}{6}}{\frac{-5\pi}{6}}}{}%
		\xintifboolexpr{\tmpModUnRe == \tmpModUnIm 'and' \tmpModUnRe > 0}{\IfEq{#1}{d}{\dfrac{\pi}{4}}{\frac{\pi}{4}}}{}%
		\xintifboolexpr{\tmpModUnRe == \tmpModUnIm 'and' \tmpModUnRe < 0}{\IfEq{#1}{d}{\dfrac{-3\pi}{4}}{\frac{-3\pi}{4}}}{}%
		\xintifboolexpr{\tmpModUnRe == -\tmpModUnIm 'and' \tmpModUnRe > 0}{\IfEq{#1}{d}{\dfrac{-\pi}{4}}{\frac{-\pi}{4}}}{}%
		\xintifboolexpr{\tmpModUnRe == -\tmpModUnIm 'and' \tmpModUnRe < 0}{\IfEq{#1}{d}{\dfrac{3\pi}{4}}{\frac{3\pi}{4}}}{}%
		\xintifboolexpr{\tmpModUnRe == 0 'and' \tmpModUnIm == 1}{\IfEq{#1}{d}{\dfrac{\pi}{2}}{\frac{\pi}{2}}}{}%
		\xintifboolexpr{\tmpModUnRe == 0 'and' \tmpModUnIm == -1}{\IfEq{#1}{d}{\dfrac{-\pi}{2}}{\frac{-\pi}{2}}}{}%
	}%
}

\NewDocumentCommand\FormeExpoComplexe{ m }{%
	\PartieReelle{#1}[\tmpreA]%
	\PartieImaginaire{#1}[\tmpimA]%
	\IfSubStr{\tmpreA}{sqrt}%
		{%
			\StrDel{\tmpreA}{sqrt}[\tmpretmpA]%
		}%
		{%
			\xdef\tmpretmpA{\tmpreA}%
		}%
	\IfSubStr{\tmpimA}{sqrt}%
		{%
			\StrDel{\tmpimA}{sqrt}[\tmpimtmpA]%
		}%
		{%
			\xdef\tmpimtmpA{\tmpimA}%
		}%
	\IfSubStr{\tmpreA}{sqrt}%
		{%
			\IfSubStr{\tmpimA}{sqrt}%
				{%
					\xdef\tmpCarreModule{abs(\tmpretmpA)+abs(\tmpimtmpA)}%
				}%
				{%
					\xdef\tmpCarreModule{abs(\tmpretmpA)+(\tmpimtmpA)*(\tmpimtmpA)}%
				}%
		}%
		{%
			\xdef\tmpCarreModule{(\tmpretmpA)*(\tmpretmpA)+(\tmpimtmpA)*(\tmpimtmpA)}%
		}%
	\xdef\tmpModUnRe{(\tmpreA)/(sqrt(\tmpCarreModule))}%
	\xdef\tmpModUnIm{(\tmpimA)/(sqrt(\tmpCarreModule))}%
	\ensuremath{%
		\xintifboolexpr{\tmpCarreModule == 1}{}{\SimplificationRacine{\tmpCarreModule}}%
		\e^{%
			\xintifboolexpr{\tmpModUnRe == 1 'and' \tmpModUnIm == 0}{0}{}%
			\xintifboolexpr{\tmpModUnRe == -1 'and' \tmpModUnIm == 0}{\i\pi}{}%
			\xintifboolexpr{\tmpModUnRe == 0.5 'and' \tmpModUnIm > 0}{\IfEq{#1}{d}{\dfrac{\i\pi}{3}}{\frac{\i\pi}{3}}}{}%
			\xintifboolexpr{\tmpModUnRe == 0.5 'and' \tmpModUnIm < 0}{\IfEq{#1}{d}{\dfrac{-\i\pi}{3}}{\frac{-\i\pi}{3}}}{}%
			\xintifboolexpr{\tmpModUnRe == -0.5 'and' \tmpModUnIm > 0}{\IfEq{#1}{d}{\dfrac{2\i\pi}{3}}{\frac{2\i\pi}{3}}}{}%
			\xintifboolexpr{\tmpModUnRe == -0.5 'and' \tmpModUnIm < 0}{\IfEq{#1}{d}{\dfrac{-2\i\pi}{3}}{\frac{-2\i\pi}{3}}}{}%
			\xintifboolexpr{\tmpModUnRe > 0 'and' \tmpModUnIm == 0.5}{\IfEq{#1}{d}{\dfrac{\i\pi}{6}}{\frac{\i\pi}{6}}}{}%
			\xintifboolexpr{\tmpModUnRe < 0 'and' \tmpModUnIm == 0.5}{\IfEq{#1}{d}{\dfrac{5\i\pi}{6}}{\frac{5\i\pi}{6}}}{}%
			\xintifboolexpr{\tmpModUnRe > 0 'and' \tmpModUnIm == -0.5}{\IfEq{#1}{d}{\dfrac{-\i\pi}{6}}{\frac{-\i\pi}{6}}}{}%
			\xintifboolexpr{\tmpModUnRe < 0 'and' \tmpModUnIm == -0.5}{\IfEq{#1}{d}{\dfrac{-5\i\pi}{6}}{\frac{-5\i\pi}{6}}}{}%
			\xintifboolexpr{\tmpModUnRe == \tmpModUnIm 'and' \tmpModUnRe > 0}{\IfEq{#1}{d}{\dfrac{\i\pi}{4}}{\frac{\i\pi}{4}}}{}%
			\xintifboolexpr{\tmpModUnRe == \tmpModUnIm 'and' \tmpModUnRe < 0}{\IfEq{#1}{d}{\dfrac{-3\i\pi}{4}}{\frac{-3\i\pi}{4}}}{}%
			\xintifboolexpr{\tmpModUnRe == -\tmpModUnIm 'and' \tmpModUnRe > 0}{\IfEq{#1}{d}{\dfrac{-\i\pi}{4}}{\frac{-\i\pi}{4}}}{}%
			\xintifboolexpr{\tmpModUnRe == -\tmpModUnIm 'and' \tmpModUnRe < 0}{\IfEq{#1}{d}{\dfrac{3\i\pi}{4}}{\frac{3\i\pi}{4}}}{}%
			\xintifboolexpr{\tmpModUnRe == 0 'and' \tmpModUnIm == 1}{\IfEq{#1}{d}{\dfrac{\i\pi}{2}}{\frac{\i\pi}{2}}}{}%
			\xintifboolexpr{\tmpModUnRe == 0 'and' \tmpModUnIm == -1}{\IfEq{#1}{d}{\dfrac{-\i\pi}{2}}{\frac{-\i\pi}{2}}}{}%
		}%
	}%
}

%====commandes alternatives
\NewDocumentCommand\ExtractionCoeffExprRacines{ m O{\tmpCoeffA} O{\tmpCoeffB} O{\tmpCoeffC} O{\tmpCoeffD} }{%a*rac(b)+c*rac(d)
	\IfSubStr{#1}{+}
		{%
			\StrCut{#1}{+}{\exprtestG}{\exprtestD}%
			\IfSubStr{\exprtestG}{*sqrt}%
				{%
					\StrBefore{\exprtestG}{*}[#2]%
					\StrBetween{\exprtestG}{sqrt(}{)}[#3]%
				}%
				{%
					\xdef#2{\exprtestG}\xdef#3{1}%
				}%
			\IfSubStr{\exprtestD}{*sqrt}%
				{%
					\StrBefore{\exprtestD}{*}[#4]%
					\StrBetween{\exprtestD}{sqrt(}{)}[#5]%
				}%
				{%
					\xdef#4{\exprtestD}\xdef#5{1}%
				}%
		}%
	{%
		%si 2 moins...
		\StrCount{#1}{-}[\tmpNbmoins]%
		\xintifboolexpr{\tmpNbmoins == 2}%
			{%
				\StrCut[2]{#1}{-}{\exprtestG}{\exprtestD}%
			}%
			{%
				\StrCut{#1}{-}{\exprtestG}{\exprtestD}%
			}%
		\IfSubStr{\exprtestG}{*sqrt}%
			{%
				\StrBefore{\exprtestG}{*}[#2]%
				\StrBetween{\exprtestG}{sqrt(}{)}[#3]%
			}%
			{%
				\xdef#2{\exprtestG}\xdef#3{1}%
			}%
		\IfSubStr{\exprtestD}{*sqrt}%
			{%
				\StrBefore{\exprtestD}{*}[#4]%
				\xdef#4{-#4}%
				\StrBetween{\exprtestD}{sqrt(}{)}[#5]%
			}%
			{%
				\xdef#4{-#4}\xdef#5{1}%
			}%
	}%
}

\NewDocumentCommand\SimplifCarreExprRacine{ O{} m }{%
	\ExtractionCoeffExprRacines{#2}%
	\xintifboolexpr{\tmpCoeffA > 0 'and' \tmpCoeffC > 0}%
		{%
			\ensuremath{%
				\ConversionFraction[#1]{(\tmpCoeffA)*(\tmpCoeffA)*(\tmpCoeffB)+(\tmpCoeffC)*(\tmpCoeffC)*(\tmpCoeffD)}+%
				\IfEq{#1}{d}{\displaystyle}{}\SimplificationRacine{4*(\tmpCoeffA)*(\tmpCoeffA)*(\tmpCoeffC)*(\tmpCoeffC)*(\tmpCoeffB)*(\tmpCoeffD)}%
			}%
		}%
		{}%
	\xintifboolexpr{\tmpCoeffA > 0 'and' \tmpCoeffC < 0}%
		{%
			\ensuremath{%
				\ConversionFraction[#1]{(\tmpCoeffA)*(\tmpCoeffA)*(\tmpCoeffB)+(\tmpCoeffC)*(\tmpCoeffC)*(\tmpCoeffD)}-%
				\IfEq{#1}{d}{\displaystyle}{}\SimplificationRacine{4*(\tmpCoeffA)*(\tmpCoeffA)*(\tmpCoeffC)*(\tmpCoeffC)*(\tmpCoeffB)*(\tmpCoeffD)}%
			}%
		}%
		{}%
	\xintifboolexpr{\tmpCoeffA < 0 'and' \tmpCoeffC > 0}%
		{%
			\ensuremath{%
				\ConversionFraction[#1]{(\tmpCoeffA)*(\tmpCoeffA)*(\tmpCoeffB)+(\tmpCoeffC)*(\tmpCoeffC)*(\tmpCoeffD)}-%
				\IfEq{#1}{d}{\displaystyle}{}\SimplificationRacine{4*(\tmpCoeffA)*(\tmpCoeffA)*(\tmpCoeffC)*(\tmpCoeffC)*(\tmpCoeffB)*(\tmpCoeffD)}%
			}%
		}%
		{}%
	\xintifboolexpr{\tmpCoeffA < 0 'and' \tmpCoeffC < 0}%
		{%
			\ensuremath{%
				\ConversionFraction[#1]{(\tmpCoeffA)*(\tmpCoeffA)*(\tmpCoeffB)+(\tmpCoeffC)*(\tmpCoeffC)*(\tmpCoeffD)}+%
				\IfEq{#1}{d}{\displaystyle}{}\SimplificationRacine{4*(\tmpCoeffA)*(\tmpCoeffA)*(\tmpCoeffC)*(\tmpCoeffC)*(\tmpCoeffB)*(\tmpCoeffD)}%
			}%
		}%
		{}%
}

\NewDocumentCommand\CalculModuleCplx{ O{} m m }{%
	\ExtractionCoeffExprRacines{#2}[\Crea][\Creb][\Crec][\Cred]%
	\ExtractionCoeffExprRacines{#3}[\Cima][\Cimb][\Cimc][\Cimd]%
	\xdef\TmpCoeffsDebut{(\Crea)*(\Crea)*(\Creb)+(\Crec)*(\Crec)*(\Cred)+(\Cima)*(\Cima)*(\Cimb)+(\Cimc)*(\Cimc)*(\Cimd)}%
	\xdef\TmpCoeffsRacineA{4*(\Crea)*(\Crea)*(\Crec)*(\Crec)*(\Creb)*(\Cred)}%
	\xdef\TmpCoeffsRacineB{4*(\Cima)*(\Cima)*(\Cimc)*(\Cimc)*(\Cimb)*(\Cimd)}%
	%\xinteval{\TmpCoeffsDebut}/\xinteval{\TmpCoeffsRacineA}/\xinteval{\TmpCoeffsRacineB}/\xinteval{(\Crea)*(\Crec)}/\xinteval{(\Cima)*(\Cimc)}=
	\xintifboolexpr{\TmpCoeffsRacineA == 0 'and' \TmpCoeffsRacineB == 0}%
		{%
			\ensuremath{\IfEq{#1}{d}{\displaystyle}{}\SimplificationRacine{\TmpCoeffsDebut}}%
		}%
		{}%
	\xintifboolexpr{\TmpCoeffsRacineA == 0 'and' \TmpCoeffsRacineB != 0}%
		{%
			\ensuremath{\IfEq{#1}{d}{\displaystyle}{}\sqrt{\SimplificationRacine{(\TmpCoeffsDebut)*(\TmpCoeffsDebut)}\xintifboolexpr{(\Cima)*(\Cimc) < 0}{-}{+}\SimplificationRacine{\TmpCoeffsRacineB}}}%
		}%
		{}%
	\xintifboolexpr{\TmpCoeffsRacineA != 0 'and' \TmpCoeffsRacineB == 0}%
		{%
			\ensuremath{\IfEq{#1}{d}{\displaystyle}{}\sqrt{\SimplificationRacine{(\TmpCoeffsDebut)*(\TmpCoeffsDebut)}\xintifboolexpr{(\Crea)*(\Crec) < 0}{-}{+}\SimplificationRacine{\TmpCoeffsRacineA}}}%
		}%
		{}%
	\xintifboolexpr{\TmpCoeffsRacineA != 0 'and' \TmpCoeffsRacineB != 0 'and' (\Crea)*(\Crec) < 0 'and' (\Cima)*(\Cimc) > 0 'and' \TmpCoeffsRacineA == \TmpCoeffsRacineB}%
		{%
			\ensuremath{\IfEq{#1}{d}{\displaystyle}{}\SimplificationRacine{\TmpCoeffsDebut}}%
		}%
		{}%
	\xintifboolexpr{\TmpCoeffsRacineA != 0 'and' \TmpCoeffsRacineB != 0 'and' (\Crea)*(\Crec) > 0 'and' (\Cima)*(\Cimc) < 0 'and' \TmpCoeffsRacineA == \TmpCoeffsRacineB}%
		{%
			\ensuremath{\IfEq{#1}{d}{\displaystyle}{}\SimplificationRacine{\TmpCoeffsDebut}}%
		}%
		{}%
	\xintifboolexpr{\TmpCoeffsRacineA != \TmpCoeffsRacineB}%
		{%
			\ensuremath{\IfEq{#1}{d}{\displaystyle}{}\sqrt{\SimplificationRacine{(\TmpCoeffsDebut)*(\TmpCoeffsDebut)}\xintifboolexpr{(\Crea)*(\Crec) < 0}{-}{+}\SimplificationRacine{\TmpCoeffsRacineA}\xintifboolexpr{(\Cima)*(\Cimc) < 0}{-}{+}\SimplificationRacine{\TmpCoeffsRacineB}}}%
		}%
		{}%
}

\NewDocumentCommand\TestArgumentComplexe{ O{} m m m }{%
	\xintifboolexpr{\TmpArg == #2 'or' \TmpArg == #3}{\ensuremath{\IfEq{#1}{d}{\displaystyle}{}#4}}{}%
}

\NewDocumentCommand\CalculArgumentCplx{ s O{} m m }{%
	\xdef\TmpArg{\xintfloateval{trunc(Argd(#3,#4),1)}}%\TmpArg%
	\IfBooleanTF{#1}%
		{%
			%les pi/2
			\TestArgumentComplexe[#2]{0}{0.0}{0}%
			\TestArgumentComplexe[#2]{90}{90.0}{\frac{\pi}{2}}%
			\TestArgumentComplexe[#2]{-90}{-90.0}{\frac{3\pi}{2}}%
			\TestArgumentComplexe[#2]{180}{180.0}{\pi}%
			%les pi/3
			\TestArgumentComplexe[#2]{60}{60.0}{\frac{\pi}{3}}%
			\TestArgumentComplexe[#2]{120}{120.0}{\frac{2\pi}{3}}%
			\TestArgumentComplexe[#2]{-60}{-60.0}{\frac{5\pi}{3}}%
			\TestArgumentComplexe[#2]{-120}{-120.0}{\frac{4\pi}{3}}%
			%les pi/4
			\TestArgumentComplexe[#2]{45}{45.0}{\frac{\pi}{4}}%
			\TestArgumentComplexe[#2]{135}{135.0}{\frac{3\pi}{4}}%
			\TestArgumentComplexe[#2]{-45}{-45.0}{\frac{7\pi}{4}}%
			\TestArgumentComplexe[#2]{-135}{-135.0}{\frac{5\pi}{4}}%
			%les pi/5
			\TestArgumentComplexe[#2]{36}{36.0}{\frac{\pi}{5}}%
			\TestArgumentComplexe[#2]{72}{72.0}{\frac{2\pi}{5}}%
			\TestArgumentComplexe[#2]{108}{108.0}{\frac{3\pi}{5}}%
			\TestArgumentComplexe[#2]{144}{144.0}{\frac{4\pi}{5}}%
			\TestArgumentComplexe[#2]{-36}{-36.0}{\frac{9\pi}{5}}%
			\TestArgumentComplexe[#2]{-72}{-72.0}{\frac{8\pi}{5}}%
			\TestArgumentComplexe[#2]{-108}{-108.0}{\frac{7\pi}{5}}%
			\TestArgumentComplexe[#2]{-144}{-144.0}{\frac{6\pi}{5}}%
			%les pi/6
			\TestArgumentComplexe[#2]{30}{30.0}{\frac{\pi}{6}}%
			\TestArgumentComplexe[#2]{150}{150.0}{\frac{5\pi}{6}}%
			\TestArgumentComplexe[#2]{-30}{-30.0}{\frac{11\pi}{6}}%
			\TestArgumentComplexe[#2]{-150}{-150.0}{\frac{7\pi}{6}}%
			%les pi/8
			\TestArgumentComplexe[#2]{22.5}{22.5}{\frac{\pi}{8}}%
			\TestArgumentComplexe[#2]{67.5}{67.5}{\frac{3\pi}{8}}%
			\TestArgumentComplexe[#2]{112.5}{112.5}{\frac{5\pi}{8}}%
			\TestArgumentComplexe[#2]{157.5}{157.5}{\frac{7\pi}{8}}%
			\TestArgumentComplexe[#2]{-22.5}{-22.5}{\frac{15\pi}{8}}%
			\TestArgumentComplexe[#2]{-67.5}{-67.5}{\frac{13\pi}{8}}%
			\TestArgumentComplexe[#2]{-112.5}{-112.5}{\frac{11\pi}{8}}%
			\TestArgumentComplexe[#2]{-157.5}{-157.5}{\frac{9\pi}{8}}%
			%les pi/12
			\TestArgumentComplexe[#2]{15}{15.0}{\frac{\pi}{12}}%
			\TestArgumentComplexe[#2]{75}{75.0}{\frac{5\pi}{12}}%
			\TestArgumentComplexe[#2]{105}{105.0}{\frac{7\pi}{12}}%
			\TestArgumentComplexe[#2]{165}{165.0}{\frac{11\pi}{12}}%
			\TestArgumentComplexe[#2]{-15}{-15.0}{\frac{23\pi}{12}}%
			\TestArgumentComplexe[#2]{-75}{-75.0}{\frac{19\pi}{12}}%
			\TestArgumentComplexe[#2]{-105}{-105.0}{\frac{17\pi}{12}}%
			\TestArgumentComplexe[#2]{-165}{-165.0}{\frac{13\pi}{12}}%
			%les pi/10
			\TestArgumentComplexe[#2]{18}{18.0}{\frac{\pi}{10}}%
			\TestArgumentComplexe[#2]{54}{54.0}{\frac{3\pi}{10}}%
			\TestArgumentComplexe[#2]{126}{126.0}{\frac{7\pi}{10}}%
			\TestArgumentComplexe[#2]{162}{162.0}{\frac{9\pi}{10}}%
			\TestArgumentComplexe[#2]{-18}{-18.0}{\frac{19\pi}{10}}%
			\TestArgumentComplexe[#2]{-54}{-54.0}{\frac{17\pi}{10}}%
			\TestArgumentComplexe[#2]{-126}{-126.0}{\frac{13\pi}{10}}%
			\TestArgumentComplexe[#2]{-162}{-162.0}{\frac{11\pi}{10}}%
		}%
		{%
			%les pi/2
			\TestArgumentComplexe[#2]{0}{0.0}{0}%
			\TestArgumentComplexe[#2]{90}{90.0}{\frac{\pi}{2}}%
			\TestArgumentComplexe[#2]{-90}{-90.0}{\frac{-\pi}{2}}%
			\TestArgumentComplexe[#2]{180}{180.0}{\pi}%
			%les pi/3
			\TestArgumentComplexe[#2]{60}{60.0}{\frac{\pi}{3}}%
			\TestArgumentComplexe[#2]{120}{120.0}{\frac{2\pi}{3}}%
			\TestArgumentComplexe[#2]{-60}{-60.0}{\frac{-\pi}{3}}%
			\TestArgumentComplexe[#2]{-120}{-120.0}{\frac{-2\pi}{3}}%
			%les pi/4
			\TestArgumentComplexe[#2]{45}{45.0}{\frac{\pi}{4}}%
			\TestArgumentComplexe[#2]{135}{135.0}{\frac{3\pi}{4}}%
			\TestArgumentComplexe[#2]{-45}{-45.0}{\frac{-\pi}{4}}%
			\TestArgumentComplexe[#2]{-135}{-135.0}{\frac{-3\pi}{4}}%
			%les pi/5
			\TestArgumentComplexe[#2]{36}{36.0}{\frac{\pi}{5}}%
			\TestArgumentComplexe[#2]{72}{72.0}{\frac{2\pi}{5}}%
			\TestArgumentComplexe[#2]{108}{108.0}{\frac{3\pi}{5}}%
			\TestArgumentComplexe[#2]{144}{144.0}{\frac{4\pi}{5}}%
			\TestArgumentComplexe[#2]{-36}{-36.0}{\frac{-\pi}{5}}%
			\TestArgumentComplexe[#2]{-72}{-72.0}{\frac{-2\pi}{5}}%
			\TestArgumentComplexe[#2]{-108}{-108.0}{\frac{-3\pi}{5}}%
			\TestArgumentComplexe[#2]{-144}{-144.0}{\frac{-4\pi}{5}}%
			%les pi/6
			\TestArgumentComplexe[#2]{30}{30.0}{\frac{\pi}{6}}%
			\TestArgumentComplexe[#2]{150}{150.0}{\frac{5\pi}{6}}%
			\TestArgumentComplexe[#2]{-30}{-30.0}{\frac{-\pi}{6}}%
			\TestArgumentComplexe[#2]{-150}{-150.0}{\frac{-5\pi}{6}}%
			%les pi/8
			\TestArgumentComplexe[#2]{22.5}{22.5}{\frac{\pi}{8}}%
			\TestArgumentComplexe[#2]{67.5}{67.5}{\frac{3\pi}{8}}%
			\TestArgumentComplexe[#2]{112.5}{112.5}{\frac{5\pi}{8}}%
			\TestArgumentComplexe[#2]{157.5}{157.5}{\frac{7\pi}{8}}%
			\TestArgumentComplexe[#2]{-22.5}{-22.5}{\frac{-\pi}{8}}%
			\TestArgumentComplexe[#2]{-67.5}{-67.5}{\frac{-3\pi}{8}}%
			\TestArgumentComplexe[#2]{-112.5}{-112.5}{\frac{-5\pi}{8}}%
			\TestArgumentComplexe[#2]{-157.5}{-157.5}{\frac{-7\pi}{8}}%
			%les pi/12
			\TestArgumentComplexe[#2]{15}{15.0}{\frac{\pi}{12}}%
			\TestArgumentComplexe[#2]{75}{75.0}{\frac{5\pi}{12}}%
			\TestArgumentComplexe[#2]{105}{105.0}{\frac{7\pi}{12}}%
			\TestArgumentComplexe[#2]{165}{165.0}{\frac{11\pi}{12}}%
			\TestArgumentComplexe[#2]{-15}{-15.0}{\frac{-\pi}{12}}%
			\TestArgumentComplexe[#2]{-75}{-75.0}{\frac{-5\pi}{12}}%
			\TestArgumentComplexe[#2]{-105}{-105.0}{\frac{-7\pi}{12}}%
			\TestArgumentComplexe[#2]{-165}{-165.0}{\frac{-11\pi}{12}}%
			%les pi/10
			\TestArgumentComplexe[#2]{18}{18.0}{\frac{\pi}{10}}%
			\TestArgumentComplexe[#2]{54}{54.0}{\frac{3\pi}{10}}%
			\TestArgumentComplexe[#2]{126}{126.0}{\frac{7\pi}{10}}%
			\TestArgumentComplexe[#2]{162}{162.0}{\frac{9\pi}{10}}%
			\TestArgumentComplexe[#2]{-18}{-18.0}{\frac{-\pi}{10}}%
			\TestArgumentComplexe[#2]{-54}{-54.0}{\frac{-3\pi}{10}}%
			\TestArgumentComplexe[#2]{-126}{-126.0}{\frac{-7\pi}{10}}%
			\TestArgumentComplexe[#2]{-162}{-162.0}{\frac{-9\pi}{10}}%
		}%
}

\NewDocumentCommand\CalculFormeExpoCplx{ s O{} m m }{%
	\xdef\TmpArg{\xintfloateval{trunc(Argd(#3,#4),1)}}%\TmpArg%
	\ensuremath{%
		\xintifboolexpr{(#3)**2+(#4)**2 == 1 'and' \TmpArg == 0}{1}{}%
		\xintifboolexpr{(#3)**2+(#4)**2 == 1 'and' \TmpArg != 0}{}{\CalculModuleCplx[#2]{#3}{#4}}%
		\IfBooleanTF{#1}%
			{%
				%les pi/2
				\TestArgumentComplexe[#2]{0}{0.0}{}%
				\TestArgumentComplexe[#2]{90}{90.0}{\e^{\frac{\i\pi}{2}}}%
				\TestArgumentComplexe[#2]{-90}{-90.0}{\e^{\frac{3\i\pi}{2}}}%
				\TestArgumentComplexe[#2]{180}{180.0}{\e^{\i\pi}}%
				%les pi/3
				\TestArgumentComplexe[#2]{60}{60.0}{\e^{\frac{\i\pi}{3}}}%
				\TestArgumentComplexe[#2]{120}{120.0}{\e^{\frac{2\i\pi}{3}}}%
				\TestArgumentComplexe[#2]{-60}{-60.0}{\e^{\frac{5\i\pi}{3}}}%
				\TestArgumentComplexe[#2]{-120}{-120.0}{\e^{\frac{4\i\pi}{3}}}%
				%les pi/4
				\TestArgumentComplexe[#2]{45}{45.0}{\e^{\frac{\i\pi}{4}}}%
				\TestArgumentComplexe[#2]{135}{135.0}{\e^{\frac{3\i\pi}{4}}}%
				\TestArgumentComplexe[#2]{-45}{-45.0}{\e^{\frac{7\i\pi}{4}}}%
				\TestArgumentComplexe[#2]{-135}{-135.0}{\e^{\frac{5\i\pi}{4}}}%
				%les pi/5
				\TestArgumentComplexe[#2]{36}{36.0}{\e^{\frac{\i\pi}{5}}}%
				\TestArgumentComplexe[#2]{72}{72.0}{\e^{\frac{2\i\pi}{5}}}%
				\TestArgumentComplexe[#2]{108}{108.0}{\e^{\frac{3\i\pi}{5}}}%
				\TestArgumentComplexe[#2]{144}{144.0}{\e^{\frac{4\i\pi}{5}}}%
				\TestArgumentComplexe[#2]{-36}{-36.0}{\e^{\frac{9\i\pi}{5}}}%
				\TestArgumentComplexe[#2]{-72}{-72.0}{\e^{\frac{8\i\pi}{5}}}%
				\TestArgumentComplexe[#2]{-108}{-108.0}{\e^{\frac{7\i\pi}{5}}}%
				\TestArgumentComplexe[#2]{-144}{-144.0}{\e^{\frac{6\i\pi}{5}}}%
				%les pi/6
				\TestArgumentComplexe[#2]{30}{30.0}{\e^{\frac{\i\pi}{6}}}%
				\TestArgumentComplexe[#2]{150}{150.0}{\e^{\frac{5\i\pi}{6}}}%
				\TestArgumentComplexe[#2]{-30}{-30.0}{\e^{\frac{11\i\pi}{6}}}%
				\TestArgumentComplexe[#2]{-150}{-150.0}{\e^{\frac{7\i\pi}{6}}}%
				%les pi/8
				\TestArgumentComplexe[#2]{22.5}{22.5}{\e^{\frac{\i\pi}{8}}}%
				\TestArgumentComplexe[#2]{67.5}{67.5}{\e^{\frac{3\i\pi}{8}}}%
				\TestArgumentComplexe[#2]{112.5}{112.5}{\e^{\frac{5\i\pi}{8}}}%
				\TestArgumentComplexe[#2]{157.5}{157.5}{\e^{\frac{7\i\pi}{8}}}%
				\TestArgumentComplexe[#2]{-22.5}{-22.5}{\e^{\frac{15\i\pi}{8}}}%
				\TestArgumentComplexe[#2]{-67.5}{-67.5}{\e^{\frac{13\i\pi}{8}}}%
				\TestArgumentComplexe[#2]{-112.5}{-112.5}{\e^{\frac{11\i\pi}{8}}}%
				\TestArgumentComplexe[#2]{-157.5}{-157.5}{\e^{\frac{9\i\pi}{8}}}%
				%les pi/12
				\TestArgumentComplexe[#2]{15}{15.0}{\e^{\frac{\i\pi}{12}}}%
				\TestArgumentComplexe[#2]{75}{75.0}{\e^{\frac{5\i\pi}{12}}}%
				\TestArgumentComplexe[#2]{105}{105.0}{\e^{\frac{7\i\pi}{12}}}%
				\TestArgumentComplexe[#2]{165}{165.0}{\e^{\frac{11\i\pi}{12}}}%
				\TestArgumentComplexe[#2]{-15}{-15.0}{\e^{\frac{23\i\pi}{12}}}%
				\TestArgumentComplexe[#2]{-75}{-75.0}{\e^{\frac{19\i\pi}{12}}}%
				\TestArgumentComplexe[#2]{-105}{-105.0}{\e^{\frac{17\i\pi}{12}}}%
				\TestArgumentComplexe[#2]{-165}{-165.0}{\e^{\frac{13\i\pi}{12}}}%
				%les pi/10
				\TestArgumentComplexe[#2]{18}{18.0}{\e^{\frac{\i\pi}{10}}}%
				\TestArgumentComplexe[#2]{54}{54.0}{\e^{\frac{3\i\pi}{10}}}%
				\TestArgumentComplexe[#2]{126}{126.0}{\e^{\frac{7\i\pi}{10}}}%
				\TestArgumentComplexe[#2]{162}{162.0}{\e^{\frac{9\i\pi}{10}}}%
				\TestArgumentComplexe[#2]{-18}{-18.0}{\e^{\frac{19\i\pi}{10}}}%
				\TestArgumentComplexe[#2]{-54}{-54.0}{\e^{\frac{17\i\pi}{10}}}%
				\TestArgumentComplexe[#2]{-126}{-126.0}{\e^{\frac{13\i\pi}{10}}}%
				\TestArgumentComplexe[#2]{-162}{-162.0}{\e^{\frac{11\i\pi}{10}}}%
			}%
			{%
				%les pi/2
				\TestArgumentComplexe[#2]{0}{0.0}{}%
				\TestArgumentComplexe[#2]{90}{90.0}{\e^{\frac{\i\pi}{2}}}%
				\TestArgumentComplexe[#2]{-90}{-90.0}{\e^{\frac{-\i\pi}{2}}}%
				\TestArgumentComplexe[#2]{180}{180.0}{\e^{\i\pi}}%
				%les pi/3
				\TestArgumentComplexe[#2]{60}{60.0}{\e^{\frac{\i\pi}{3}}}%
				\TestArgumentComplexe[#2]{120}{120.0}{\e^{\frac{2\i\pi}{3}}}%
				\TestArgumentComplexe[#2]{-60}{-60.0}{\e^{\frac{-\i\pi}{3}}}%
				\TestArgumentComplexe[#2]{-120}{-120.0}{\e^{\frac{-2\i\pi}{3}}}%
				%les pi/4
				\TestArgumentComplexe[#2]{45}{45.0}{\e^{\frac{\i\pi}{4}}}%
				\TestArgumentComplexe[#2]{135}{135.0}{\e^{\frac{3\i\pi}{4}}}%
				\TestArgumentComplexe[#2]{-45}{-45.0}{\e^{\frac{-\i\pi}{4}}}%
				\TestArgumentComplexe[#2]{-135}{-135.0}{\e^{\frac{-3\i\pi}{4}}}%
				%les pi/5
				\TestArgumentComplexe[#2]{36}{36.0}{\e^{\frac{\i\pi}{5}}}%
				\TestArgumentComplexe[#2]{72}{72.0}{\e^{\frac{2\i\pi}{5}}}%
				\TestArgumentComplexe[#2]{108}{108.0}{\e^{\frac{3\i\pi}{5}}}%
				\TestArgumentComplexe[#2]{144}{144.0}{\e^{\frac{4\i\pi}{5}}}%
				\TestArgumentComplexe[#2]{-36}{-36.0}{\e^{\frac{-\i\pi}{5}}}%
				\TestArgumentComplexe[#2]{-72}{-72.0}{\e^{\frac{-2\i\pi}{5}}}%
				\TestArgumentComplexe[#2]{-108}{-108.0}{\e^{\frac{-3\i\pi}{5}}}%
				\TestArgumentComplexe[#2]{-144}{-144.0}{\e^{\frac{-4\i\pi}{5}}}%
				%les pi/6
				\TestArgumentComplexe[#2]{30}{30.0}{\e^{\frac{\i\pi}{6}}}%
				\TestArgumentComplexe[#2]{150}{150.0}{\e^{\frac{5\i\pi}{6}}}%
				\TestArgumentComplexe[#2]{-30}{-30.0}{\e^{\frac{-\i\pi}{6}}}%
				\TestArgumentComplexe[#2]{-150}{-150.0}{\e^{\frac{-5\i\pi}{6}}}%
				%les pi/8
				\TestArgumentComplexe[#2]{22.5}{22.5}{\e^{\frac{\i\pi}{8}}}%
				\TestArgumentComplexe[#2]{67.5}{67.5}{\e^{\frac{3\i\pi}{8}}}%
				\TestArgumentComplexe[#2]{112.5}{112.5}{\e^{\frac{5\i\pi}{8}}}%
				\TestArgumentComplexe[#2]{157.5}{157.5}{\e^{\frac{7\i\pi}{8}}}%
				\TestArgumentComplexe[#2]{-22.5}{-22.5}{\e^{\frac{-\i\pi}{8}}}%
				\TestArgumentComplexe[#2]{-67.5}{-67.5}{\e^{\frac{-3\i\pi}{8}}}%
				\TestArgumentComplexe[#2]{-112.5}{-112.5}{\e^{\frac{-5\i\pi}{8}}}%
				\TestArgumentComplexe[#2]{-157.5}{-157.5}{\e^{\frac{-7\i\pi}{8}}}%
				%les pi/12
				\TestArgumentComplexe[#2]{15}{15.0}{\e^{\frac{\i\pi}{12}}}%
				\TestArgumentComplexe[#2]{75}{75.0}{\e^{\frac{5\i\pi}{12}}}%
				\TestArgumentComplexe[#2]{105}{105.0}{\e^{\frac{7\i\pi}{12}}}%
				\TestArgumentComplexe[#2]{165}{165.0}{\e^{\frac{11\i\pi}{12}}}%
				\TestArgumentComplexe[#2]{-15}{-15.0}{\e^{\frac{-\i\pi}{12}}}%
				\TestArgumentComplexe[#2]{-75}{-75.0}{\e^{\frac{-5\i\pi}{12}}}%
				\TestArgumentComplexe[#2]{-105}{-105.0}{\e^{\frac{-7\i\pi}{12}}}%
				\TestArgumentComplexe[#2]{-165}{-165.0}{\e^{\frac{-11\i\pi}{12}}}%
				%les pi/10
				\TestArgumentComplexe[#2]{18}{18.0}{\e^{\frac{\i\pi}{10}}}%
				\TestArgumentComplexe[#2]{54}{54.0}{\e^{\frac{3\i\pi}{10}}}%
				\TestArgumentComplexe[#2]{126}{126.0}{\e^{\frac{7\i\pi}{10}}}%
				\TestArgumentComplexe[#2]{162}{162.0}{\e^{\frac{9\i\pi}{10}}}%
				\TestArgumentComplexe[#2]{-18}{-18.0}{\e^{\frac{-\i\pi}{10}}}%
				\TestArgumentComplexe[#2]{-54}{-54.0}{\e^{\frac{-3\i\pi}{10}}}%
				\TestArgumentComplexe[#2]{-126}{-126.0}{\e^{\frac{-7\i\pi}{10}}}%
				\TestArgumentComplexe[#2]{-162}{-162.0}{\e^{\frac{-9\i\pi}{10}}}%
			}%
	}%
}

\NewDocumentCommand\ExtractParamExprRac{ m O{\tmpCoeffA} O{\tmpCoeffB} O{\tmpCoeffC} O{\tmpCoeffD} }{%
	\StrCount{#1}{sqrt}[\tmpnbrac]%
	\xintifboolexpr{\tmpnbrac == 2}%
		{%
				\StrBetween{#1}{sqrt(}{)}[#3]%
				\StrBetween[2,2]{#1}{sqrt(}{)}[#5]%
				\StrBefore{#1}{sqrt}[#2]%
				\StrBetween[1,2]{#1}{)}{sqrt}[#4]%
				\StrDel{#2}{*}[#2]%
				\IfEq{#2}{}{\xdef#2{1}}{}%
				\IfEq{#2}{-}{\xdef#2{-1}}{}%
				\StrDel{#4}{*}[#4]%
				\StrDel{#4}{+}[#4]%
				\IfEq{#4}{}{\xdef#4{1}}{}%
				\IfEq{#4}{-}{\xdef#4{-1}}{}%
			}%
		{}%
	\xintifboolexpr{\tmpnbrac == 0}%
		{%
				\xdef#2{#1}%
				\xdef#3{1}%
				\xdef#4{0}%
				\xdef#5{1}%
			}%
		{}%
	\xintifboolexpr{\tmpnbrac == 1}%
		{%
				\xdef#5{1}%
				\StrBetween{#1}{sqrt(}{)}[#3]%
				\StrBefore{#1}{sqrt}[#2]%
				\StrDel{#2}{*}[#2]%
				\IfEq{#2}{}{\xdef#2{1}}{}%
				\IfEq{#2}{-}{\xdef#2{-1}}{}%
				\StrBehind{#1}{)}[#4]%
				\StrDel{#4}{+}[#4]%
				\IfEq{#4}{}{\xdef#4{0}}{}%
			}%
		{}%
}

\NewDocumentCommand\SimplCarreExprRacine{ O{} m }{%
	\ExtractParamExprRac{#2}%
	%si le produit des racines est un entier ?
	\xintifboolexpr{isint(sqrt(\tmpCoeffB*\tmpCoeffD)) == 1}%
		{%
				\ensuremath{%
						\ConversionFraction[#1]{(\tmpCoeffA)*(\tmpCoeffA)*(\tmpCoeffB)+(\tmpCoeffC)*(\tmpCoeffC)*(\tmpCoeffD)+2*(\tmpCoeffA)*(\tmpCoeffC)*sqrt(\tmpCoeffB*\tmpCoeffD)}%
					}%
			}%
		{%
				\xintifboolexpr{\tmpCoeffA > 0 'and' \tmpCoeffC > 0}%
				{%
						\ensuremath{%
								\ConversionFraction[#1]{(\tmpCoeffA)*(\tmpCoeffA)*(\tmpCoeffB)+(\tmpCoeffC)*(\tmpCoeffC)*(\tmpCoeffD)}+%
								\IfEq{#1}{d}{\displaystyle}{}\SimplificationRacine{4*(\tmpCoeffA)*(\tmpCoeffA)*(\tmpCoeffC)*(\tmpCoeffC)*(\tmpCoeffB)*(\tmpCoeffD)}%
							}%
					}%
				{}%
				\xintifboolexpr{\tmpCoeffA > 0 'and' \tmpCoeffC < 0}%
				{%
						\ensuremath{%
								\ConversionFraction[#1]{(\tmpCoeffA)*(\tmpCoeffA)*(\tmpCoeffB)+(\tmpCoeffC)*(\tmpCoeffC)*(\tmpCoeffD)}-%
								\IfEq{#1}{d}{\displaystyle}{}\SimplificationRacine{4*(\tmpCoeffA)*(\tmpCoeffA)*(\tmpCoeffC)*(\tmpCoeffC)*(\tmpCoeffB)*(\tmpCoeffD)}%
							}%
					}%
				{}%
				\xintifboolexpr{\tmpCoeffA < 0 'and' \tmpCoeffC > 0}%
				{%
						\ensuremath{%
								\ConversionFraction[#1]{(\tmpCoeffA)*(\tmpCoeffA)*(\tmpCoeffB)+(\tmpCoeffC)*(\tmpCoeffC)*(\tmpCoeffD)}-%
								\IfEq{#1}{d}{\displaystyle}{}\SimplificationRacine{4*(\tmpCoeffA)*(\tmpCoeffA)*(\tmpCoeffC)*(\tmpCoeffC)*(\tmpCoeffB)*(\tmpCoeffD)}%
							}%
					}%
				{}%
				\xintifboolexpr{\tmpCoeffA < 0 'and' \tmpCoeffC < 0}%
				{%
						\ensuremath{%
								\ConversionFraction[#1]{(\tmpCoeffA)*(\tmpCoeffA)*(\tmpCoeffB)+(\tmpCoeffC)*(\tmpCoeffC)*(\tmpCoeffD)}+%
								\IfEq{#1}{d}{\displaystyle}{}\SimplificationRacine{4*(\tmpCoeffA)*(\tmpCoeffA)*(\tmpCoeffC)*(\tmpCoeffC)*(\tmpCoeffB)*(\tmpCoeffD)}%
							}%
					}%
				{}%
				\xintifboolexpr{\tmpCoeffC == 0 'and' abs(\tmpCoeffA) != 1}%
				{%
						\ensuremath{%
								\ConversionFraction[#1]{(\tmpCoeffA)*(\tmpCoeffA)}%
								\IfEq{#1}{d}{\displaystyle}{}\xintifboolexpr{\tmpCoeffB != 1}{\SimplificationRacine{(\tmpCoeffB)*(\tmpCoeffB)}}{}%
							}%
					}%
				{}%
				\xintifboolexpr{\tmpCoeffC == 0 'and' abs(\tmpCoeffA) == 1}%
				{%
						\ensuremath{%
								\IfEq{#1}{d}{\displaystyle}{}\SimplificationRacine{(\tmpCoeffB)*(\tmpCoeffB)}%
							}%
					}%
				{}%
			}%
}

\NewDocumentCommand\CalcModuleCplx{ O{} m m }{%
	\ExtractParamExprRac{#2}[\Crea][\Creb][\Crec][\Cred]%
	\ExtractParamExprRac{#3}[\Cima][\Cimb][\Cimc][\Cimd]%
	\xdef\TmpCoeffsDebut{(\Crea)*(\Crea)*(\Creb)+(\Crec)*(\Crec)*(\Cred)+(\Cima)*(\Cima)*(\Cimb)+(\Cimc)*(\Cimc)*(\Cimd)}%
	\xdef\TmpCoeffsRacineA{4*(\Crea)*(\Crea)*(\Crec)*(\Crec)*(\Creb)*(\Cred)}%
	\xdef\TmpCoeffsRacineB{4*(\Cima)*(\Cima)*(\Cimc)*(\Cimc)*(\Cimb)*(\Cimd)}%
	%\xinteval{\TmpCoeffsDebut}/\xinteval{\TmpCoeffsRacineA}/\xinteval{\TmpCoeffsRacineB}/\xinteval{(\Crea)*(\Crec)}/\xinteval{(\Cima)*(\Cimc)}=
	\xintifboolexpr{\TmpCoeffsRacineA == 0 'and' \TmpCoeffsRacineB == 0}%
	{%
			\ensuremath{\IfEq{#1}{d}{\displaystyle}{}\SimplificationRacine{\TmpCoeffsDebut}}%
		}%
	{}%
	\xintifboolexpr{\TmpCoeffsRacineA == 0 'and' \TmpCoeffsRacineB != 0}%
	{%
			\ensuremath{\IfEq{#1}{d}{\displaystyle}{}\sqrt{\SimplificationRacine{(\TmpCoeffsDebut)*(\TmpCoeffsDebut)}\xintifboolexpr{(\Cima)*(\Cimc) < 0}{-}{+}\SimplificationRacine{\TmpCoeffsRacineB}}}%
		}%
	{}%
	\xintifboolexpr{\TmpCoeffsRacineA != 0 'and' \TmpCoeffsRacineB == 0}%
	{%
			\ensuremath{\IfEq{#1}{d}{\displaystyle}{}\sqrt{\SimplificationRacine{(\TmpCoeffsDebut)*(\TmpCoeffsDebut)}\xintifboolexpr{(\Crea)*(\Crec) < 0}{-}{+}\SimplificationRacine{\TmpCoeffsRacineA}}}%
		}%
	{}%
	\xintifboolexpr{\TmpCoeffsRacineA != 0 'and' \TmpCoeffsRacineB != 0 'and' (\Crea)*(\Crec) < 0 'and' (\Cima)*(\Cimc) > 0 'and' \TmpCoeffsRacineA == \TmpCoeffsRacineB}%
	{%
			\ensuremath{\IfEq{#1}{d}{\displaystyle}{}\SimplificationRacine{\TmpCoeffsDebut}}%
		}%
	{}%
	\xintifboolexpr{\TmpCoeffsRacineA != 0 'and' \TmpCoeffsRacineB != 0 'and' (\Crea)*(\Crec) > 0 'and' (\Cima)*(\Cimc) < 0 'and' \TmpCoeffsRacineA == \TmpCoeffsRacineB}%
	{%
			\ensuremath{\IfEq{#1}{d}{\displaystyle}{}\SimplificationRacine{\TmpCoeffsDebut}}%
		}%
	{}%
	\xintifboolexpr{\TmpCoeffsRacineA != \TmpCoeffsRacineB}%
	{%
			\ensuremath{\IfEq{#1}{d}{\displaystyle}{}\sqrt{\SimplificationRacine{(\TmpCoeffsDebut)*(\TmpCoeffsDebut)}\xintifboolexpr{(\Crea)*(\Crec) < 0}{-}{+}\SimplificationRacine{\TmpCoeffsRacineA}\xintifboolexpr{(\Cima)*(\Cimc) < 0}{-}{+}\SimplificationRacine{\TmpCoeffsRacineB}}}%
		}%
	{}%
}

\endinput