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.

spad
)abbrev domain CM ComplexManifold
ComplexManifold(R:Join(Field, RadicalCategory, TranscendentalFunctionCategory, Comparable)
               ) : 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)
    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.04 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.01 SEC.
compiling exported conj : $ -> $ Time: 0 SEC.
compiling exported * : ($,$) -> $ Time: 0 SEC.
compiling exported norm : $ -> R Time: 0.01 SEC.
compiling local iabs : $ -> R Time: 0 SEC.
compiling local abs : $ -> $ Time: 0 SEC.
compiling exported arg : $ -> R Time: 0 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: (OrderedSet) ****** Domain: R already in scope augmenting R: (DifferentialRing) ****** Domain: R already in scope augmenting R: (Evalable R) ****** Domain: R already in scope augmenting R: (LinearlyExplicitOver (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: (OrderedSet) (time taken in buildFunctor: 160)
;;; *** |ComplexManifold| REDEFINED
;;; *** |ComplexManifold| REDEFINED Time: 0.21 SEC.
Cumulative Statistics for Constructor ComplexManifold Time: 0.27 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 04 APR 2022 07:19:15 PM):
; /var/aw/var/LatexWiki/CM.NRLIB/CM.fasl written ; compilation finished in 0:00:00.080 ------------------------------------------------------------------------ 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. 68 Names for 103 Operations in this Domain. ------------------------------- Operations --------------------------------
#? : % -> NonNegativeInteger ?*? : (Integer, %) -> % ?*? : (PositiveInteger, %) -> % ?*? : (%, %) -> % ?+? : (%, %) -> % ?-? : (%, %) -> % -? : % -> % ?=? : (%, %) -> Boolean D : (%, List(Symbol)) -> % D : (%, Symbol) -> % 1 : () -> % 0 : () -> % ?^? : (%, PositiveInteger) -> % annihilate? : (%, %) -> Boolean antiCommutator : (%, %) -> % arg : % -> Expression(Integer) associator : (%, %, %) -> % coerce : % -> OutputForm coerce : Expression(Integer) -> % coerce : Fraction(Integer) -> % coerce : Integer -> % coerce : % -> % commutator : (%, %) -> % conj : % -> % copy : % -> % differentiate : (%, Symbol) -> % empty : () -> % empty? : % -> Boolean eq? : (%, %) -> Boolean first : % -> Expression(Integer) hash : % -> SingleInteger imag : % -> Expression(Integer) imaginary : () -> % index? : (Integer, %) -> Boolean indices : % -> List(Integer) latex : % -> String maxIndex : % -> Integer minIndex : % -> Integer norm : % -> Expression(Integer) nthRoot : (%, Integer) -> % one? : % -> Boolean opposite? : (%, %) -> Boolean real : % -> Expression(Integer) recip : % -> Union(%,"failed") retract : % -> Fraction(Integer) retract : % -> Integer sample : () -> % sqrt : % -> % unitVector : PositiveInteger -> % 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) -> % ?^? : (%, Fraction(Integer)) -> % ?^? : (%, 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 : (%, 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 every? : ((Expression(Integer) -> Boolean), %) -> Boolean hashUpdate! : (HashState, %) -> HashState leftPower : (%, NonNegativeInteger) -> % leftPower : (%, PositiveInteger) -> % leftRecip : % -> Union(%,"failed") less? : (%, NonNegativeInteger) -> Boolean map : ((Expression(Integer) -> Expression(Integer)), %) -> % max : (((Expression(Integer), Expression(Integer)) -> Boolean), %) -> Expression(Integer) member? : (Expression(Integer), %) -> Boolean members : % -> List(Expression(Integer)) more? : (%, NonNegativeInteger) -> Boolean parts : % -> List(Expression(Integer)) qelt : (%, 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") rightPower : (%, NonNegativeInteger) -> % rightPower : (%, PositiveInteger) -> % rightRecip : % -> Union(%,"failed") size? : (%, NonNegativeInteger) -> Boolean subtractIfCan : (%, %) -> Union(%,"failed")

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. 115 Names for 167 Operations in this Domain. ------------------------------- Operations --------------------------------
?*? : (Integer, %) -> % ?*? : (PositiveInteger, %) -> % ?*? : (%, %) -> % ?+? : (%, %) -> % ?-? : (%, %) -> % -? : % -> % ?/? : (%, %) -> % ?=? : (%, %) -> Boolean D : (%, List(Symbol)) -> % D : (%, Symbol) -> % 1 : () -> % 0 : () -> % ?^? : (%, Integer) -> % ?^? : (%, PositiveInteger) -> % ?^? : (%, %) -> % acos : % -> % acosh : % -> % acot : % -> % acoth : % -> % acsc : % -> % acsch : % -> % annihilate? : (%, %) -> Boolean antiCommutator : (%, %) -> % asec : % -> % asech : % -> % asin : % -> % asinh : % -> % associates? : (%, %) -> Boolean associator : (%, %, %) -> % atan : % -> % atanh : % -> % basis : () -> Vector(%) coerce : % -> OutputForm coerce : Expression(Integer) -> % coerce : Fraction(Integer) -> % coerce : Integer -> % coerce : % -> % commutator : (%, %) -> % conjugate : % -> % convert : % -> InputForm convert : % -> Pattern(Integer) cos : % -> % cosh : % -> % cot : % -> % coth : % -> % csc : % -> % csch : % -> % differentiate : (%, Symbol) -> % exp : % -> % factor : % -> Factored(%) gcd : List(%) -> % gcd : (%, %) -> % generator : () -> % hash : % -> SingleInteger imag : % -> Expression(Integer) imaginary : () -> % inv : % -> % latex : % -> String lcm : List(%) -> % lcm : (%, %) -> % log : % -> % norm : % -> Expression(Integer) nthRoot : (%, Integer) -> % one? : % -> Boolean opposite? : (%, %) -> Boolean pi : () -> % prime? : % -> Boolean ?quo? : (%, %) -> % rank : () -> PositiveInteger real : % -> Expression(Integer) recip : % -> Union(%,"failed") ?rem? : (%, %) -> % retract : % -> Fraction(Integer) retract : % -> Integer sample : () -> % sec : % -> % sech : % -> % sin : % -> % sinh : % -> % sizeLess? : (%, %) -> Boolean smaller? : (%, %) -> Boolean sqrt : % -> % squareFree : % -> Factored(%) squareFreePart : % -> % tan : % -> % tanh : % -> % trace : % -> Expression(Integer) unit? : % -> Boolean unitCanonical : % -> % zero? : % -> Boolean ?~=? : (%, %) -> Boolean ?*? : (Expression(Integer), %) -> % ?*? : (Fraction(Integer), %) -> % ?*? : (NonNegativeInteger, %) -> % ?*? : (%, Expression(Integer)) -> % ?*? : (%, Fraction(Integer)) -> % D : (%, List(Symbol), List(NonNegativeInteger)) -> % D : (%, (Expression(Integer) -> Expression(Integer)), NonNegativeInteger) -> % D : (%, (Expression(Integer) -> Expression(Integer))) -> % D : (%, Symbol, NonNegativeInteger) -> % ?^? : (%, Fraction(Integer)) -> % ?^? : (%, NonNegativeInteger) -> % argument : % -> Expression(Integer) characteristic : () -> NonNegativeInteger characteristicPolynomial : % -> SparseUnivariatePolynomial(Expression(Integer)) complex : (Expression(Integer), Expression(Integer)) -> % 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 : (%, Symbol, NonNegativeInteger) -> % discriminant : Vector(%) -> Expression(Integer) discriminant : () -> Expression(Integer) divide : (%, %) -> Record(quotient: %,remainder: %) euclideanSize : % -> NonNegativeInteger 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(%)) gcdPolynomial : (SparseUnivariatePolynomial(%), SparseUnivariatePolynomial(%)) -> SparseUnivariatePolynomial(%) hashUpdate! : (HashState, %) -> HashState lcmCoef : (%, %) -> Record(llcm_res: %,coeff1: %,coeff2: %) leftPower : (%, NonNegativeInteger) -> % leftPower : (%, PositiveInteger) -> % leftRecip : % -> Union(%,"failed") lift : % -> SparseUnivariatePolynomial(Expression(Integer)) map : ((Expression(Integer) -> Expression(Integer)), %) -> % minimalPolynomial : % -> SparseUnivariatePolynomial(Expression(Integer)) multiEuclidean : (List(%), %) -> Union(List(%),"failed") patternMatch : (%, Pattern(Integer), PatternMatchResult(Integer,%)) -> PatternMatchResult(Integer,%) principalIdeal : List(%) -> Record(coef: List(%),generator: %) 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)) 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") rightPower : (%, NonNegativeInteger) -> % rightPower : (%, PositiveInteger) -> % rightRecip : % -> Union(%,"failed") solveLinearPolynomialEquation : (List(SparseUnivariatePolynomial(%)), SparseUnivariatePolynomial(%)) -> Union(List(SparseUnivariatePolynomial(%)),"failed") squareFreePolynomial : SparseUnivariatePolynomial(%) -> Factored(SparseUnivariatePolynomial(%)) subtractIfCan : (%, %) -> Union(%,"failed") traceMatrix : Vector(%) -> Matrix(Expression(Integer)) traceMatrix : () -> Matrix(Expression(Integer)) unitNormal : % -> Record(unit: %,canonical: %,associate: %)

Tests:

fricas
a:CM(EXPR INT) := 3

\label{eq1}3(1)
Type: ComplexManifold?(Expression(Integer))
fricas
b:CM(EXPR INT) := -5

\label{eq2}- 5(2)
Type: ComplexManifold?(Expression(Integer))
fricas
real(a)

\label{eq3}3(3)
Type: Expression(Integer)
fricas
norm a

\label{eq4}9(4)
Type: Expression(Integer)
fricas
norm b

\label{eq5}25(5)
Type: Expression(Integer)
fricas
ab:=a*b

\label{eq6}-{15}(6)
Type: ComplexManifold?(Expression(Integer))
fricas
real ab

\label{eq7}-{15}(7)
Type: Expression(Integer)
fricas
imag ab

\label{eq8}0(8)
Type: Expression(Integer)
fricas
s1:=sqrt(a)

\label{eq9}\sqrt{3}(9)
Type: ComplexManifold?(Expression(Integer))
fricas
real s1

\label{eq10}\sqrt{3}(10)
Type: Expression(Integer)
fricas
imag s1

\label{eq11}0(11)
Type: Expression(Integer)
fricas
)set break resume
s2:=sqrt(b)
>> Error detected within library code: catdef: division by zero
Continuing to read the file...
real s2

\label{eq12}s 2(12)
Type: Expression(Integer)
fricas
imag s2

\label{eq13}0(13)
Type: Expression(Integer)
fricas
I:CM(EXPR INT) := imaginary()

\label{eq14}i(14)
Type: ComplexManifold?(Expression(Integer))
fricas
real I

\label{eq15}0(15)
Type: Expression(Integer)
fricas
norm I

\label{eq16}1(16)
Type: Expression(Integer)
fricas
imag I

\label{eq17}1(17)
Type: Expression(Integer)
fricas
imag conj I

\label{eq18}- 1(18)
Type: Expression(Integer)
fricas
s3:=sqrt(I)

\label{eq19}{{\sqrt{2}}\over 2}+{{{\sqrt{2}}\over 2}\  i}(19)
Type: ComplexManifold?(Expression(Integer))
fricas
s3*s3

\label{eq20}i(20)
Type: ComplexManifold?(Expression(Integer))
fricas
c1:=conj(a+b*I)

\label{eq21}3 +{5 \  i}(21)
Type: ComplexManifold?(Expression(Integer))
fricas
real c1

\label{eq22}3(22)
Type: Expression(Integer)
fricas
imag c1

\label{eq23}5(23)
Type: Expression(Integer)
fricas
norm c1

\label{eq24}34(24)
Type: Expression(Integer)
fricas
c1::Complex(EXPR INT)

\label{eq25}3 +{5 \  i}(25)
Type: Complex(Expression(Integer))
fricas
sqrt %

\label{eq26}{{\root{4}\of{34}}\over{\sqrt{{{6 \ {\sqrt{34}}}+{68}}\over{{6 \ {\sqrt{34}}}+{43}}}}}+{{{5 \ {\root{4}\of{34}}}\over{{\left({\sqrt{3
4}}+ 3 \right)}\ {\sqrt{{{6 \ {\sqrt{34}}}+{68}}\over{{6 \ {\sqrt{3
4}}}+{43}}}}}}\  i}(26)
Type: Complex(Expression(Integer))
fricas
s4:=sqrt(c1)

\label{eq27}{{\sqrt{\sqrt{34}}}\over{\sqrt{{{6 \ {\sqrt{34}}}+{68}}\over{{6 \ {\sqrt{34}}}+{43}}}}}+{{{5 \ {\sqrt{\sqrt{34}}}}\over{{\left({\sqrt{3
4}}+ 3 \right)}\ {\sqrt{{{6 \ {\sqrt{34}}}+{68}}\over{{6 \ {\sqrt{3
4}}}+{43}}}}}}\  i}(27)
Type: ComplexManifold?(Expression(Integer))
fricas
real s4

\label{eq28}{\sqrt{\sqrt{34}}}\over{\sqrt{{{6 \ {\sqrt{34}}}+{68}}\over{{6 \ {\sqrt{34}}}+{43}}}}(28)
Type: Expression(Integer)
fricas
imag s4

\label{eq29}{5 \ {\sqrt{\sqrt{34}}}}\over{{\left({\sqrt{34}}+ 3 \right)}\ {\sqrt{{{6 \ {\sqrt{34}}}+{68}}\over{{6 \ {\sqrt{34}}}+{43}}}}}(29)
Type: Expression(Integer)
fricas
s4*s4

\label{eq30}3 +{5 \  i}(30)
Type: ComplexManifold?(Expression(Integer))
fricas
%::Complex(EXPR INT)

\label{eq31}3 +{5 \  i}(31)
Type: Complex(Expression(Integer))
fricas
normalize %

\label{eq32}{5 \ {\sqrt{- 1}}}+ 3(32)
Type: Expression(Integer)
fricas
%::Complex(EXPR INT)::Complex(INT)
Cannot convert the value from type Complex(Expression(Integer)) to Complex(Integer) .
Continuing to read the file...




  Subject:   Be Bold !!
  ( 14 subscribers )  
Please rate this page: