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

Edit detail for SandBoxComplexManifold revision 6 of 7

1 2 3 4 5 6 7
Editor: Bill Page
Time: 2009/06/21 16:14:16 GMT-7
Note: clean and add a little documentation


        

Complex domain constructor done differently.

DirectProduct? lifts many operations from the underlying domain automatically.

Complex values are represented as conjugate pairs.

spad
)abbrev domain CM ComplexManifold
ComplexManifold(R:Join(Field,RadicalCategory,TranscendentalFunctionCategory,OrderedSet)): Join(RadicalCategory,DirectProductCategory(2,R)) with
    imaginary: () -> %
    real: % -> R
    imag: % -> R
    conj: % -> %
    norm: % -> R
    arg:  % -> R
    coerce: % -> Complex R
  == DirectProduct(2,R) add
    -- represent as conjugate pair
    Rep == DirectProduct(2,R)
    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 == 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/2820653749495509478-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
************* USER ERROR **********
available signatures for Rep: 
    NONE
NEED Rep: () -> ?
****** comp fails at level 1 with expression: ******
((DEF (|Rep|) (NIL) (NIL) (|DirectProduct| 2 R)))
****** level 1  ******
$x:= (DEF (Rep) (NIL) (NIL) (DirectProduct 2 R))
$m:= $EmptyMode
$f:=
((((|$Information| #) (* #) (+ #) (< #) ...)))
>> Apparent user error: unspecified error

axiom
)show CM EXPR INT
ComplexManifold is an unknown constructor and so is unavailable. Did you mean to use -> but type something different instead?

Compare:

axiom
)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:

axiom
a:CM(EXPR INT) := 3
ComplexManifold is an unknown constructor and so is unavailable. Did you mean to use -> but type something different instead? b:CM(EXPR INT) := -5
ComplexManifold is an unknown constructor and so is unavailable. Did you mean to use -> but type something different instead? real(a)

\label{eq1}a(1)
Type: Expression(Integer)
axiom
norm a
There are 7 exposed and 3 unexposed library operations named norm having 1 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op norm to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named norm with argument type(s) Variable(a)
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. norm b
There are 7 exposed and 3 unexposed library operations named norm having 1 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op norm to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named norm with argument type(s) Variable(b)
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. ab:=a*b

\label{eq2}a \  b(2)
Type: Polynomial(Integer)
axiom
real ab

\label{eq3}a \  b(3)
Type: Expression(Integer)
axiom
imag ab

\label{eq4}0(4)
Type: Expression(Integer)
axiom
s1:=sqrt(a)

\label{eq5}\sqrt{a}(5)
Type: Expression(Integer)
axiom
real s1

\label{eq6}\sqrt{a}(6)
Type: Expression(Integer)
axiom
imag s1

\label{eq7}0(7)
Type: Expression(Integer)
axiom
s2:=sqrt(b)

\label{eq8}\sqrt{b}(8)
Type: Expression(Integer)
axiom
real s2

\label{eq9}\sqrt{b}(9)
Type: Expression(Integer)
axiom
imag s2

\label{eq10}0(10)
Type: Expression(Integer)
axiom
I:CM(EXPR INT) := imaginary()
ComplexManifold is an unknown constructor and so is unavailable. Did you mean to use -> but type something different instead? real I

\label{eq11}I(11)
Type: Expression(Integer)
axiom
norm I
There are 7 exposed and 3 unexposed library operations named norm having 1 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op norm to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named norm with argument type(s) Variable(I)
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. imag I

\label{eq12}0(12)
Type: Expression(Integer)
axiom
imag conj I
There are 1 exposed and 0 unexposed library operations named conj having 1 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op conj to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named conj with argument type(s) Variable(I)
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. s3:=sqrt(I)

\label{eq13}\sqrt{I}(13)
Type: Expression(Integer)
axiom
s3*s3

\label{eq14}I(14)
Type: Expression(Integer)
axiom
c1:=conj(a+b*I)
There are 1 exposed and 0 unexposed library operations named conj having 1 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op conj to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named conj with argument type(s) Polynomial(Integer)
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. real c1

\label{eq15}c 1(15)
Type: Expression(Integer)
axiom
imag c1

\label{eq16}0(16)
Type: Expression(Integer)
axiom
norm c1
There are 7 exposed and 3 unexposed library operations named norm having 1 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op norm to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named norm with argument type(s) Variable(c1)
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. c1::Complex(EXPR INT)

\label{eq17}c 1(17)
Type: Complex(Expression(Integer))
axiom
sqrt %

\label{eq18}\sqrt{c 1}(18)
Type: Complex(Expression(Integer))
axiom
s4:=sqrt(c1)

\label{eq19}\sqrt{c 1}(19)
Type: Expression(Integer)
axiom
real s4

\label{eq20}\sqrt{c 1}(20)
Type: Expression(Integer)
axiom
imag s4

\label{eq21}0(21)
Type: Expression(Integer)
axiom
s4*s4

\label{eq22}c 1(22)
Type: Expression(Integer)
axiom
%::Complex(EXPR INT)

\label{eq23}c 1(23)
Type: Complex(Expression(Integer))
axiom
normalize %

\label{eq24}c 1(24)
Type: Expression(Integer)
axiom
%::Complex(EXPR INT)::Complex(INT)
Cannot convert from type Complex(Expression(Integer)) to Complex( Integer) for value c1