login  home  contents  what's new  discussion  bug reports help  links  subscribe  changes  refresh  edit

Complex domain constructor done differently.

DirectProduct? lifts many operations from the underlying domain automatically.

Complex values are represented as conjugate pairs.

)abbrev domain CM ComplexManifold
imaginary: () -> %
real: % -> R
imag: % -> R
conj: % -> %
norm: % -> R
arg:  % -> R
coerce: % -> Complex R
-- represent as conjugate pair
Rep ==> DirectProduct(2,R)
per x ==> (x@Rep) pretend %
rep x ==> (x@%) pretend Rep
pair(x:R,y:R):Rep == directProduct vector [x,y] dup(x:R):Rep == directProduct vector [x,x] import List R
imaginary():% == per pair(1,-1) real(x:%):R == (rep(x).1 + rep(x).2)/(2::R) imag(x:%):R == (rep(x).1 - rep(x).2)/(2::R) -- just swap conj(x:%):% == per pair(rep(x).2,rep(x).1) -- multiplication is interesting (x:% * y:%):% == per pair( _ real(x)*rep(y).1 + imag(x)*rep(y).2, _ real(x)*rep(y).2 - imag(x)*rep(y).1) norm(x:%):R == retract(x*conj(x)) iabs(x:%):R == sqrt norm x abs(x:%):% == per dup iabs x arg(x:%):R == -- does not work since we have no order -- real(x)<0 and imag(x)=0 => pi() (2::R)*atan(imag(x)/(iabs(x)+real(x))) sqrt(x:%):% == per( sqrt(iabs(x))*pair( _ cos(arg(x)/(2::R)) + sin(arg(x)/(2::R)), _ cos(arg(x)/(2::R)) - sin(arg(x)/(2::R)) ) )
coerce(x:%):OutputForm == complex(real x,imag x)$Complex(R)::OutputForm coerce(x:%):Complex(R) == complex(real x,imag x) spad Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/5781501376748542802-25px001.spad using old system compiler. CM abbreviates domain ComplexManifold ------------------------------------------------------------------------ initializing NRLIB CM for ComplexManifold compiling into NRLIB CM ****** Domain: R already in scope ****** Domain: R already in scope ****** Domain: R already in scope processing macro definition Rep ==> DirectProduct(2,R) processing macro definition per x ==> pretend(@(x,DirectProduct(2,R)),$)
processing macro definition rep x ==> pretend(@(x,$),DirectProduct(2,R)) compiling local pair : (R,R) -> DirectProduct(2,R) Time: 0.05 SEC. compiling local dup : R -> DirectProduct(2,R) Time: 0 SEC. importing List R compiling exported imaginary : () ->$ Time: 0 SEC.
compiling exported real : $-> R Time: 0 SEC. compiling exported imag :$ -> R Time: 0 SEC.
compiling exported conj : $->$ Time: 0 SEC.
compiling exported * : ($,$) -> $Time: 0.01 SEC. compiling exported norm :$ -> R Time: 0 SEC.
compiling local iabs : $-> R Time: 0 SEC. compiling exported abs :$ -> $Time: 0 SEC. compiling exported arg :$ -> R Time: 0.01 SEC.
compiling exported sqrt : $->$ Time: 0 SEC.
compiling exported coerce : $-> OutputForm Time: 0 SEC. compiling exported coerce :$ -> Complex R Time: 0 SEC.
****** Domain: R already in scope augmenting R: (DifferentialRing) ****** Domain: R already in scope augmenting R: (Evalable R) ****** Domain: R already in scope augmenting R: (LinearlyExplicitRingOver (Integer)) ****** Domain: R already in scope augmenting R: (PartialDifferentialRing (Symbol)) ****** Domain: R already in scope augmenting R: (RetractableTo (Fraction (Integer))) ****** Domain: R already in scope augmenting R: (RetractableTo (Integer)) ****** Domain: $already in scope augmenting$: (shallowlyMutable) ****** Domain: R already in scope augmenting R: (Finite) ****** Domain: R already in scope augmenting R: (OrderedAbelianMonoidSup) ****** Domain: R already in scope augmenting R: (OrderedRing) (time taken in buildFunctor: 180)
;;; *** |ComplexManifold| REDEFINED
;;; *** |ComplexManifold| REDEFINED Time: 0.21 SEC.
Cumulative Statistics for Constructor ComplexManifold Time: 0.28 seconds
--------------non extending category---------------------- .. ComplexManifold(#1) of cat (|Join| (|RadicalCategory|) (|DirectProductCategory| 2 |#1|) (CATEGORY |domain| (SIGNATURE |imaginary| ($)) (SIGNATURE |real| (|#1|$)) (SIGNATURE |imag| (|#1| $)) (SIGNATURE |conj| ($ $)) (SIGNATURE |norm| (|#1|$)) (SIGNATURE |arg| (|#1| $)) (SIGNATURE |coerce| ((|Complex| |#1|)$)))) has no (|DirectProductCategory| NIL |#1|) finalizing NRLIB CM Processing ComplexManifold for Browser database: --->-->ComplexManifold(constructor): Not documented!!!! --->-->ComplexManifold((imaginary (%))): Not documented!!!! --->-->ComplexManifold((real (R %))): Not documented!!!! --->-->ComplexManifold((imag (R %))): Not documented!!!! --->-->ComplexManifold((conj (% %))): Not documented!!!! --->-->ComplexManifold((norm (R %))): Not documented!!!! --->-->ComplexManifold((arg (R %))): Not documented!!!! --->-->ComplexManifold((coerce ((Complex R) %))): Not documented!!!! --->-->ComplexManifold(): Missing Description ; compiling file "/var/aw/var/LatexWiki/CM.NRLIB/CM.lsp" (written 25 APR 2013 07:29:44 PM):
; /var/aw/var/LatexWiki/CM.NRLIB/CM.fasl written ; compilation finished in 0:00:00.081 ------------------------------------------------------------------------ ComplexManifold is now explicitly exposed in frame initial ComplexManifold will be automatically loaded when needed from /var/aw/var/LatexWiki/CM.NRLIB/CM

fricas
)show CM EXPR INT
ComplexManifold(Expression(Integer)) is a domain constructor. Abbreviation for ComplexManifold is CM This constructor is exposed in this frame. ------------------------------- Operations --------------------------------
#? : % -> NonNegativeInteger ?*? : (Integer,%) -> % ?*? : (PositiveInteger,%) -> % ?*? : (%,%) -> % ?+? : (%,%) -> % ?-? : (%,%) -> % -? : % -> % ?<? : (%,%) -> Boolean ?<=? : (%,%) -> Boolean ?=? : (%,%) -> Boolean ?>? : (%,%) -> Boolean ?>=? : (%,%) -> Boolean D : (%,List(Symbol)) -> % D : (%,NonNegativeInteger) -> % D : (%,Symbol) -> % D : % -> % 1 : () -> % 0 : () -> % ?^? : (%,Fraction(Integer)) -> % ?^? : (%,PositiveInteger) -> % abs : % -> % arg : % -> Expression(Integer) coerce : % -> OutputForm coerce : Expression(Integer) -> % coerce : Fraction(Integer) -> % coerce : Integer -> % conj : % -> % convert : % -> InputForm copy : % -> % differentiate : (%,Symbol) -> % differentiate : % -> % dimension : () -> CardinalNumber empty : () -> % empty? : % -> Boolean enumerate : () -> List(%) eq? : (%,%) -> Boolean first : % -> Expression(Integer) hash : % -> SingleInteger imag : % -> Expression(Integer) imaginary : () -> % index : PositiveInteger -> % index? : (Integer,%) -> Boolean indices : % -> List(Integer) latex : % -> String lookup : % -> PositiveInteger max : (%,%) -> % maxIndex : % -> Integer min : (%,%) -> % minIndex : % -> Integer negative? : % -> Boolean norm : % -> Expression(Integer) nthRoot : (%,Integer) -> % one? : % -> Boolean positive? : % -> Boolean random : () -> % real : % -> Expression(Integer) recip : % -> Union(%,"failed") retract : % -> Fraction(Integer) retract : % -> Integer sample : () -> % sign : % -> Integer size : () -> NonNegativeInteger smaller? : (%,%) -> Boolean sqrt : % -> % sup : (%,%) -> % unitVector : PositiveInteger -> % zero? : % -> Boolean ?~=? : (%,%) -> Boolean ?*? : (Expression(Integer),%) -> % ?*? : (NonNegativeInteger,%) -> % ?*? : (%,Expression(Integer)) -> % ?/? : (%,Expression(Integer)) -> % D : (%,List(Symbol),List(NonNegativeInteger)) -> % D : (%,(Expression(Integer) -> Expression(Integer)),NonNegativeInteger) -> % D : (%,(Expression(Integer) -> Expression(Integer))) -> % D : (%,Symbol,NonNegativeInteger) -> % ?^? : (%,NonNegativeInteger) -> % any? : ((Expression(Integer) -> Boolean),%) -> Boolean characteristic : () -> NonNegativeInteger coerce : % -> Complex(Expression(Integer)) coerce : % -> Vector(Expression(Integer)) count : (Expression(Integer),%) -> NonNegativeInteger count : ((Expression(Integer) -> Boolean),%) -> NonNegativeInteger differentiate : (%,List(Symbol),List(NonNegativeInteger)) -> % differentiate : (%,List(Symbol)) -> % differentiate : (%,(Expression(Integer) -> Expression(Integer)),NonNegativeInteger) -> % differentiate : (%,(Expression(Integer) -> Expression(Integer))) -> % differentiate : (%,NonNegativeInteger) -> % differentiate : (%,Symbol,NonNegativeInteger) -> % directProduct : Vector(Expression(Integer)) -> % dot : (%,%) -> Expression(Integer) elt : (%,Integer,Expression(Integer)) -> Expression(Integer) ?.? : (%,Integer) -> Expression(Integer) entries : % -> List(Expression(Integer)) entry? : (Expression(Integer),%) -> Boolean eval : (%,Equation(Expression(Integer))) -> % eval : (%,Expression(Integer),Expression(Integer)) -> % eval : (%,List(Equation(Expression(Integer)))) -> % eval : (%,List(Expression(Integer)),List(Expression(Integer))) -> % every? : ((Expression(Integer) -> Boolean),%) -> Boolean fill! : (%,Expression(Integer)) -> % hashUpdate! : (HashState,%) -> HashState less? : (%,NonNegativeInteger) -> Boolean map : ((Expression(Integer) -> Expression(Integer)),%) -> % map! : ((Expression(Integer) -> Expression(Integer)),%) -> % member? : (Expression(Integer),%) -> Boolean members : % -> List(Expression(Integer)) more? : (%,NonNegativeInteger) -> Boolean parts : % -> List(Expression(Integer)) qelt : (%,Integer) -> Expression(Integer) qsetelt! : (%,Integer,Expression(Integer)) -> Expression(Integer) reducedSystem : Matrix(%) -> Matrix(Expression(Integer)) reducedSystem : Matrix(%) -> Matrix(Integer) reducedSystem : (Matrix(%),Vector(%)) -> Record(mat: Matrix(Expression(Integer)),vec: Vector(Expression(Integer))) reducedSystem : (Matrix(%),Vector(%)) -> Record(mat: Matrix(Integer),vec: Vector(Integer)) retract : % -> Expression(Integer) retractIfCan : % -> Union(Expression(Integer),"failed") retractIfCan : % -> Union(Fraction(Integer),"failed") retractIfCan : % -> Union(Integer,"failed") setelt : (%,Integer,Expression(Integer)) -> Expression(Integer) size? : (%,NonNegativeInteger) -> Boolean subtractIfCan : (%,%) -> Union(%,"failed") swap! : (%,Integer,Integer) -> Void

Compare:

fricas
)show COMPLEX EXPR INT
Complex(Expression(Integer)) is a domain constructor. Abbreviation for Complex is COMPLEX This constructor is exposed in this frame. ------------------------------- Operations --------------------------------
?*? : (Fraction(Integer),%) -> % ?*? : (Integer,%) -> % ?*? : (PositiveInteger,%) -> % ?*? : (%,Fraction(Integer)) -> % ?*? : (%,%) -> % ?+? : (%,%) -> % ?-? : (%,%) -> % -? : % -> % ?/? : (%,%) -> % ?=? : (%,%) -> Boolean D : (%,List(Symbol)) -> % D : (%,NonNegativeInteger) -> % D : (%,Symbol) -> % D : % -> % OMwrite : (%,Boolean) -> String OMwrite : % -> String 1 : () -> % 0 : () -> % ?^? : (%,Fraction(Integer)) -> % ?^? : (%,Integer) -> % ?^? : (%,PositiveInteger) -> % ?^? : (%,%) -> % abs : % -> % acos : % -> % acosh : % -> % acot : % -> % acoth : % -> % acsc : % -> % acsch : % -> % asec : % -> % asech : % -> % asin : % -> % asinh : % -> % associates? : (%,%) -> Boolean atan : % -> % atanh : % -> % basis : () -> Vector(%) charthRoot : % -> % coerce : % -> OutputForm coerce : Expression(Integer) -> % coerce : Fraction(Integer) -> % coerce : Integer -> % coerce : % -> % conjugate : % -> % convert : % -> Complex(Float) convert : % -> InputForm convert : % -> Pattern(Float) convert : % -> Pattern(Integer) cos : % -> % cosh : % -> % cot : % -> % coth : % -> % createPrimitiveElement : () -> % csc : % -> % csch : % -> % differentiate : (%,Symbol) -> % differentiate : % -> % enumerate : () -> List(%) exp : % -> % factor : % -> Factored(%) gcd : List(%) -> % gcd : (%,%) -> % generator : () -> % hash : % -> SingleInteger imag : % -> Expression(Integer) imaginary : () -> % index : PositiveInteger -> % init : () -> % inv : % -> % latex : % -> String lcm : List(%) -> % lcm : (%,%) -> % log : % -> % lookup : % -> PositiveInteger norm : % -> Expression(Integer) nthRoot : (%,Integer) -> % one? : % -> Boolean order : % -> PositiveInteger pi : () -> % prime? : % -> Boolean primeFrobenius : % -> % primitive? : % -> Boolean primitiveElement : () -> % ?quo? : (%,%) -> % random : () -> % rank : () -> PositiveInteger rational : % -> Fraction(Integer) rational? : % -> Boolean real : % -> Expression(Integer) recip : % -> Union(%,"failed") ?rem? : (%,%) -> % retract : % -> Fraction(Integer) retract : % -> Integer sample : () -> % sec : % -> % sech : % -> % sin : % -> % sinh : % -> % size : () -> NonNegativeInteger sizeLess? : (%,%) -> Boolean smaller? : (%,%) -> Boolean sqrt : % -> % squareFree : % -> Factored(%) squareFreePart : % -> % tan : % -> % tanh : % -> % trace : % -> Expression(Integer) unit? : % -> Boolean unitCanonical : % -> % zero? : % -> Boolean ?~=? : (%,%) -> Boolean ?*? : (Expression(Integer),%) -> % ?*? : (NonNegativeInteger,%) -> % ?*? : (%,Expression(Integer)) -> % D : (%,List(Symbol),List(NonNegativeInteger)) -> % D : (%,(Expression(Integer) -> Expression(Integer)),NonNegativeInteger) -> % D : (%,(Expression(Integer) -> Expression(Integer))) -> % D : (%,Symbol,NonNegativeInteger) -> % OMwrite : (OpenMathDevice,%,Boolean) -> Void OMwrite : (OpenMathDevice,%) -> Void ?^? : (%,NonNegativeInteger) -> % argument : % -> Expression(Integer) characteristic : () -> NonNegativeInteger characteristicPolynomial : % -> SparseUnivariatePolynomial(Expression(Integer)) charthRoot : % -> Union(%,"failed") complex : (Expression(Integer),Expression(Integer)) -> % conditionP : Matrix(%) -> Union(Vector(%),"failed") convert : % -> Complex(DoubleFloat) convert : % -> SparseUnivariatePolynomial(Expression(Integer)) convert : % -> Vector(Expression(Integer)) convert : SparseUnivariatePolynomial(Expression(Integer)) -> % convert : Vector(Expression(Integer)) -> % coordinates : (Vector(%),Vector(%)) -> Matrix(Expression(Integer)) coordinates : Vector(%) -> Matrix(Expression(Integer)) coordinates : (%,Vector(%)) -> Vector(Expression(Integer)) coordinates : % -> Vector(Expression(Integer)) definingPolynomial : () -> SparseUnivariatePolynomial(Expression(Integer)) derivationCoordinates : (Vector(%),(Expression(Integer) -> Expression(Integer))) -> Matrix(Expression(Integer)) differentiate : (%,List(Symbol),List(NonNegativeInteger)) -> % differentiate : (%,List(Symbol)) -> % differentiate : (%,(Expression(Integer) -> Expression(Integer)),NonNegativeInteger) -> % differentiate : (%,(Expression(Integer) -> Expression(Integer))) -> % differentiate : (%,NonNegativeInteger) -> % differentiate : (%,Symbol,NonNegativeInteger) -> % discreteLog : % -> NonNegativeInteger discreteLog : (%,%) -> Union(NonNegativeInteger,"failed") discriminant : Vector(%) -> Expression(Integer) discriminant : () -> Expression(Integer) divide : (%,%) -> Record(quotient: %,remainder: %) ?.? : (%,Expression(Integer)) -> % euclideanSize : % -> NonNegativeInteger eval : (%,Equation(Expression(Integer))) -> % eval : (%,Expression(Integer),Expression(Integer)) -> % eval : (%,List(Equation(Expression(Integer)))) -> % eval : (%,List(Expression(Integer)),List(Expression(Integer))) -> % eval : (%,List(Symbol),List(Expression(Integer))) -> % eval : (%,Symbol,Expression(Integer)) -> % expressIdealMember : (List(%),%) -> Union(List(%),"failed") exquo : (%,Expression(Integer)) -> Union(%,"failed") exquo : (%,%) -> Union(%,"failed") extendedEuclidean : (%,%) -> Record(coef1: %,coef2: %,generator: %) extendedEuclidean : (%,%,%) -> Union(Record(coef1: %,coef2: %),"failed") factorPolynomial : SparseUnivariatePolynomial(%) -> Factored(SparseUnivariatePolynomial(%)) factorSquareFreePolynomial : SparseUnivariatePolynomial(%) -> Factored(SparseUnivariatePolynomial(%)) factorsOfCyclicGroupSize : () -> List(Record(factor: Integer,exponent: Integer)) gcdPolynomial : (SparseUnivariatePolynomial(%),SparseUnivariatePolynomial(%)) -> SparseUnivariatePolynomial(%) hashUpdate! : (HashState,%) -> HashState lcmCoef : (%,%) -> Record(llcm_res: %,coeff1: %,coeff2: %) lift : % -> SparseUnivariatePolynomial(Expression(Integer)) map : ((Expression(Integer) -> Expression(Integer)),%) -> % minimalPolynomial : % -> SparseUnivariatePolynomial(Expression(Integer)) multiEuclidean : (List(%),%) -> Union(List(%),"failed") nextItem : % -> Union(%,"failed") order : % -> OnePointCompletion(PositiveInteger) patternMatch : (%,Pattern(Float),PatternMatchResult(Float,%)) -> PatternMatchResult(Float,%) patternMatch : (%,Pattern(Integer),PatternMatchResult(Integer,%)) -> PatternMatchResult(Integer,%) polarCoordinates : % -> Record(r: Expression(Integer),phi: Expression(Integer)) primeFrobenius : (%,NonNegativeInteger) -> % principalIdeal : List(%) -> Record(coef: List(%),generator: %) rationalIfCan : % -> Union(Fraction(Integer),"failed") reduce : Fraction(SparseUnivariatePolynomial(Expression(Integer))) -> Union(%,"failed") reduce : SparseUnivariatePolynomial(Expression(Integer)) -> % reducedSystem : Matrix(%) -> Matrix(Expression(Integer)) reducedSystem : Matrix(%) -> Matrix(Integer) reducedSystem : (Matrix(%),Vector(%)) -> Record(mat: Matrix(Expression(Integer)),vec: Vector(Expression(Integer))) reducedSystem : (Matrix(%),Vector(%)) -> Record(mat: Matrix(Integer),vec: Vector(Integer)) regularRepresentation : (%,Vector(%)) -> Matrix(Expression(Integer)) regularRepresentation : % -> Matrix(Expression(Integer)) representationType : () -> Union("prime",polynomial,normal,cyclic) represents : (Vector(Expression(Integer)),Vector(%)) -> % represents : Vector(Expression(Integer)) -> % retract : % -> Expression(Integer) retractIfCan : % -> Union(Expression(Integer),"failed") retractIfCan : % -> Union(Fraction(Integer),"failed") retractIfCan : % -> Union(Integer,"failed") solveLinearPolynomialEquation : (List(SparseUnivariatePolynomial(%)),SparseUnivariatePolynomial(%)) -> Union(List(SparseUnivariatePolynomial(%)),"failed") squareFreePolynomial : SparseUnivariatePolynomial(%) -> Factored(SparseUnivariatePolynomial(%)) subtractIfCan : (%,%) -> Union(%,"failed") tableForDiscreteLogarithm : Integer -> Table(PositiveInteger,NonNegativeInteger) traceMatrix : Vector(%) -> Matrix(Expression(Integer)) traceMatrix : () -> Matrix(Expression(Integer)) unitNormal : % -> Record(unit: %,canonical: %,associate: %)

Tests:

fricas
a:CM(EXPR INT) := 3
 (1)
Type: ComplexManifold?(Expression(Integer))
fricas
b:CM(EXPR INT) := -5
 (2)
Type: ComplexManifold?(Expression(Integer))
fricas
real(a)
 (3)
Type: Expression(Integer)
fricas
norm a
 (4)
Type: Expression(Integer)
fricas
norm b
 (5)
Type: Expression(Integer)
fricas
ab:=a*b
 (6)
Type: ComplexManifold?(Expression(Integer))
fricas
real ab
 (7)
Type: Expression(Integer)
fricas
imag ab
 (8)
Type: Expression(Integer)
fricas
s1:=sqrt(a)
 (9)
Type: ComplexManifold?(Expression(Integer))
fricas
real s1
 (10)
Type: Expression(Integer)
fricas
imag s1
 (11)
Type: Expression(Integer)
fricas
)set break resume
s2:=sqrt(b)
>> Error detected within library code: catdef: division by zero
real s2
 (12)
Type: Expression(Integer)
fricas
imag s2
 (13)
Type: Expression(Integer)
fricas
I:CM(EXPR INT) := imaginary()
 (14)
Type: ComplexManifold?(Expression(Integer))
fricas
real I
 (15)
Type: Expression(Integer)
fricas
norm I
 (16)
Type: Expression(Integer)
fricas
imag I
 (17)
Type: Expression(Integer)
fricas
imag conj I
 (18)
Type: Expression(Integer)
fricas
s3:=sqrt(I)
 (19)
Type: ComplexManifold?(Expression(Integer))
fricas
s3*s3
 (20)
Type: ComplexManifold?(Expression(Integer))
fricas
c1:=conj(a+b*I)
 (21)
Type: ComplexManifold?(Expression(Integer))
fricas
real c1
 (22)
Type: Expression(Integer)
fricas
imag c1
 (23)
Type: Expression(Integer)
fricas
norm c1
 (24)
Type: Expression(Integer)
fricas
c1::Complex(EXPR INT)
 (25)
Type: Complex(Expression(Integer))
fricas
sqrt %
 (26)
Type: Complex(Expression(Integer))
fricas
s4:=sqrt(c1)
 (27)
Type: ComplexManifold?(Expression(Integer))
fricas
real s4
 (28)
Type: Expression(Integer)
fricas
imag s4
 (29)
Type: Expression(Integer)
fricas
s4*s4
 (30)
Type: ComplexManifold?(Expression(Integer))
fricas
%::Complex(EXPR INT)
 (31)
Type: Complex(Expression(Integer))
fricas
normalize %
 (32)
Type: Expression(Integer)
fricas
%::Complex(EXPR INT)::Complex(INT)
Cannot convert from type Complex(Expression(Integer)) to Complex( Integer) for value +---+ 5\|- 1 + 3

 Subject:   Be Bold !! ( 15 subscribers )