In a recent report Arnold Doray observed that conjugate sometimes seems to fail when operating on complicated exact complex numbers:
http://lists.gnu.org/archive/html/axiom-mail/2009-06/msg00027.html To resolve this problem, the following cumulative patch against FriCAS adds 'conjugate' and 'norm' for symbolic complex expressions to the to the patch I sent earlier today. wsp...@debian:~$ svn diff ~/fricas-src/src/algebra/efstruc.spad.pamphlet > ctrigmnp.patch wsp...@debian:~$ cat ctrigmnp.patchIndex: /home/wspage/fricas-src/src/algebra/efstruc.spad.pamphlet =================================================================== --- /home/wspage/fricas-src/src/algebra/efstruc.spad.pamphlet (revision 627) +++ /home/wspage/fricas-src/src/algebra/efstruc.spad.pamphlet (working copy) @@ -767,6 +767,7 @@ Implementation ==> add ker2explogs: (KG, List KG, List SY) -> FG smp2explogs: (PG, List KG, List SY) -> FG + nthroot: (GF,GF) -> GF supexp : (UP, GF, GF, Z) -> GF GR2GF : GR -> GF GR2F : GR -> F @@ -847,13 +848,24 @@ map(x +-> explogs2trigs(x::FG), GR2GF, p)$PolynomialCategoryLifting( IndexedExponents KG, KG, GR, PG, GF) - explogs2trigs f == - (m := mainKernel f) case "failed" => + -- De Moivre's theorem + nthroot(a:GF,n:GF):GF == + r := nthRoot(sqrt(norm(a)),retract(n)@Z) + e := exp(complex(0, 1)*argument(a)/n) + r*e + + explogs2trigs(f:FG):GF == + m := mainKernel f + m case "failed" => GR2GF(retract(numer f)@GR) / GR2GF(retract(denom f)@GR) - op := operator(operator(k := m::KG))$F + k := m::KG + op := operator(operator(k))$F arg := [explogs2trigs x for x in argument k] num := univariate(numer f, k) den := univariate(denom f, k) + is?(op,'nthRoot) => + h := nthroot(first arg, second arg) + supexp(num,h,0,0)/supexp(den,h,0,0) is?(op, 'exp) => e := exp real first arg y := imag first arg @@ -926,6 +938,10 @@ imag : F -> F ++ imag(f) returns the imaginary part of \spad{f} where \spad{f} ++ is a complex function. + conjugate:F-> F + ++ conjugate(x+%i*y) returns x-%i*y + norm : F -> F + ++ norm(f) returns f*conjugate(f) real? : F -> Boolean ++ real?(f) returns \spad{true} if \spad{f = real f}. complexForm: F -> Complex F @@ -952,6 +968,8 @@ real? f == empty?(complexKernels(f).ker) real f == real complexForm f imag f == imag complexForm f + conjugate f == real(f) - sqrt(-1) * imag(f) + norm f == f * conjugate(f) -- returns [[k1,...,kn], [v1,...,vn]] such that ki should be replaced by vi complexKernels f == @@ -1067,6 +1085,10 @@ imag : F -> FR ++ imag(f) returns the imaginary part of \spad{f} where \spad{f} ++ is a complex function. + conjugate:F-> F + ++ conjugate(x+%i*y) returns x-%i*y + norm : F -> FR + ++ norm(f) returns f*conjugate(f) real? : F -> Boolean ++ real?(f) returns \spad{true} if \spad{f = real f}. trigs : F -> F @@ -1087,6 +1109,8 @@ real f == real complexForm f imag f == imag complexForm f + conjugate f == F2FG real(f) - complex(0,1) * F2FG imag(f) + norm f == FG2F(f * conjugate f) rreal? r == zero? imag r kreal? k == every?(real?, argument k)$List(F) complexForm f == explogs2trigs f wsp...@debian:~$ --- Note: These functions treat symbols appearing in values of type 'Expression Complex R' as variables of type R. (1) -> conjugate(x+%i*y) (1) - %i y + x Type: Expression(Complex(Integer)) (2) -> norm(x+%i*y) 2 2 (2) y + x Type: Expression(Integer) (3) -> conjugate(sqrt(x)) +-+ (3) \|x Type: Expression(Integer) (4) -> conjugate(sqrt(x*%i)) +--+ +--+ | 2 4| 2 (\|x - %i x)\|x (4) ------------------- +--+ +-+ | 2 \|2 \|x Type: Expression(Complex(Integer)) (5) -> Further testing is encouraged. Regards, Bill Page.
ctrigmnp-fricas.patch
Description: Binary data
_______________________________________________ Axiom-developer mailing list Axiom-developer@nongnu.org http://lists.nongnu.org/mailman/listinfo/axiom-developer