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

Edit detail for SandBoxPQTY revision 1 of 5

1 2 3 4 5
Editor: Kurt Pagani
Time: 2015/08/02 03:16:36 GMT+0
Note:

changed:
-
\begin{spad}
++++++++++++++++++++++++
++ $Id: 01-AUG-2015$ +++
++++++++++++++++++++++++
)abbrev domain RIA Q_INTERVAL
++ Author: Kurt Pagani
++ Date Created: 2012
++ License: BSD (same as Axiom)
++ ===================================
++ Rational Interval Arithmetics (RIA)
++ ===================================
++ This is an implementation of RIA as a FriCAS domain.
++ Ref. "Guaranteed Proofs Using Interval Arithmetic"
++ by Marc Daumas, Guillaume Melquiond, and Cesar Munoz
++ See docs for more information.
++
++ 
++
Q_INTERVAL : Exports == Implementation where

    Q ==> Fraction(Integer)
    R ==> DoubleFloat
    I ==> Integer
    
    OF ==> OutputForm
    DF ==> DoubleFloat

    Exports == Join(CoercibleTo OutputForm, ConvertibleTo String) with
    
        ----------------------------
        -- Basic interval operations
        ----------------------------
        
        "+" : (%,%) -> %
        "-" : (%,%) -> %
        "*" : (%,%) -> %
        "/" : (%,%) -> %
        "^" : (%,I) -> %
        "-" :  % -> %
        abs :  % -> %
        elt : (Q, %) -> %
        coerce: % -> OutputForm
        coerce: List Q -> %
        coerce: Float -> %
        coerce: DF -> %
        
        concise : % -> OutputForm
        
        ----------------------------------
        -- Constructors and query functions
        -----------------------------------
        
        mki : (Q,Q) -> %
        lb  :  % -> Q
        ub  :  % -> Q
        
        mid :  % -> Q
        len :  % -> Q
        
        frep    : % -> OF
        tm_frep : % -> OF
        
    Implementation == add 
    
        --------------------
        -- Represent as Rec
        --------------------     
        Rep := Record(lb:Q, ub:Q)
        
        -----------------------
        -- Implement functions
        -----------------------
        mki(a,b) == b>=a => [a,b]$Rep
            
        lb(r:%) == r.lb
        ub(r:%) == r.ub
        
        x+y == mki(x.lb + y.lb, x.ub + y.ub)
        x-y == mki(x.lb - y.ub, x.ub - y.lb)
        
        x*y == 
          a:Q:=min(min(x.lb*y.lb,x.lb*y.ub),min(x.ub*y.lb,x.ub*y.ub))
          b:Q:=max(max(x.lb*y.lb,x.lb*y.ub),max(x.ub*y.lb,x.ub*y.ub))
          mki(a,b)
          
        x/y == if y.lb*y.ub > 0 then x*mki(1/y.ub,1/y.lb)
        
        -x == mki(-x.ub,-x.lb)
        
        abs(x) ==
          if x.lb*x.ub >= 0 then 
            mki(min(abs(x.lb), abs(x.ub)), max(abs(x.lb), abs(x.ub)))
          else
            mki(0::Q, max(abs(x.lb), abs(x.ub)))
            
        x^n ==
          zero? n   => mki(1,1)
          one?  n   => x
          x.lb>=0 or odd?  n => mki(x.lb^n,x.ub^n) 
          x.ub<=0 or even? n => mki(x.ub^n,x.lb^n)
          mki(0,max(x.lb^n,x.ub^n))
        
        coerce(r : %) : OutputForm ==
          hconcat ["[",r.lb::OF,",",r.ub::OF,"]"]
        
        
        coerce(l : List Q) : % ==
          #l ~= 2 => error "Format: [lb,ub]"
          l.1 > l.2 => error "Must have lb <= ub"
          mki(l.1,l.2)
          
        coerce(r:DF):% ==
          rc:Q:=retract r
          mki(rc,rc)
          
        coerce(r:Float):% ==
          rc:Q:=retract r
          mki(rc,rc)    
        
        coerceSTR(s:String):% ==
          s1 := split(s,char ".")
          s2 := split(s1.2, char "(")
          vs := concat [s1.1,".",s2.1]
          v:=float(convert vs)
          v::Rep
        
        
        elt(q:Q,x:%):% == mki(q*x.lb, q*x.ub)

        mid(x:%):Q == (x.lb + x.ub)/2::Q
        len(x:%):Q == (x.ub - x.lb)
        
        frep(x:%):OF ==
          pm:Character:=char(177)
          sep:=concat [" ",pm::String," "]::Symbol
          hconcat [mid(x)::DF::OF, sep::OF, (len(x)/2::Q)::DF::OF]
          
        tm_frep(x:%):OF ==
          sep:=" <pm> "::Symbol
          hconcat [mid(x)::DF::OF, sep::OF, (len(x)/2::Q)::DF::OF]       
          
        concise(x:%):OF == frep(x)  -- to do
          

)abbrev category PUNIT PhysicalUnit
++
PhysicalUnit() : Category == with
        "*"  : (%,%) -> %
        "/"  : (%,%) -> %
        "^"  : (%,Integer) -> %
        "="  : (%,%) -> Boolean
        %one : -> %
        coerce : % -> OutputForm


)abbrev domain SI SI_UNIT 
++ Author: Kurt Pagani
++ Date Created: 2012
++ License: BSD (same as Axiom)
++ ================================
++ Physical Quantities and SI Units
++ ================================
++ This is an implementation of physical quantities and SI units as FriCAS 
++ domains.
++
++ See docs for more information.
++
++ Revision:
++ - removing outputForm, Ring
++ - added negation, elt
++
++
SI_UNIT : Exports == Implementation where

    EI  ==> Expression Integer
    VI  ==> Vector Integer
    LS  ==> List Symbol
    LEI ==> List EI
    LVI ==> List VI

    
    Exports == Join(PhysicalUnit,CoercibleTo OutputForm) with
      
        ----------------------------
        -- (de)-construct an SI unit  
        ----------------------------
        mksi: List(Integer) -> %
        si2l: % -> List(Integer)
        
        --------------------------------
        -- basic operation with SI units
        --------------------------------
        --"*"  : (%,%) -> %
        --"/"  : (%,%) -> %
        --"^"  : (%,Integer) -> %
        --"="  : (%,%) -> Boolean
        
        -----------------------------------------------------------------
        -- constructor for each base unit: e.g. %m(2)=m^2 -> square meter
        -----------------------------------------------------------------
        %m   :  Integer -> %
        %kg  :  Integer -> %  
        %s   :  Integer -> %
        %A   :  Integer -> %
        %K   :  Integer -> %  
        %mol :  Integer -> % 
        %cd  :  Integer -> %
        --%one :          -> %        
        
        -------------------
        -- SI derived units
        -------------------
        SI_derived : String -> %
        
        
        ----------------
        -- Buckingham Pi 
        ----------------
        buck : Table(Symbol,%) -> List(Expression(Integer))
           


    Implementation == add
        
        ---------------------------------------      
        -- Represent as 1-Array [0,0,0,0,0,0,0]
        ---------------------------------------    
        Rep := OneDimensionalArray(Integer)
        
        ---------------------------------
        -- Implementation of constructors
        ---------------------------------
        
        mksi(l) == 
          r:Rep:=new(7,0$Integer)$Rep       
          for i in 1..7 repeat r.i := l(i)
          r
          
        si2l(r) ==
          l:List(Integer):=[0,0,0,0,0,0,0]
          for i in 1..7 repeat l(i) := r.i
          l

        x * y ==
          z:Rep:=new(7,0$Integer)$Rep
          for i in 1..7 repeat z.i := x.i + y.i
          z
          
        x / y ==
          z:Rep:=new(7,0$Integer)$Rep
          for i in 1..7 repeat z.i := x.i - y.i
          z
                    
        x ^ n ==
          z:Rep:=new(7,0$Integer)$Rep
          for i in 1..7 repeat z.i := x.i * n
          z
         
        x = y ==
          res:Boolean:=true 
          for i in 1..7 repeat res:=(res and test(x.i=y.i)$Boolean) 
          res
       
        ------------------------ 
        -- Coerce to output form
        ------------------------  
        coerce(r : %) : OutputForm ==
          SYM ==> Symbol
          OF  ==> OutputForm
          sym:List(String):=["m","kg","s","A","K","mol","cd"]
          f:OutputForm:=empty()     
          for i in 1..7 repeat 
            if not zero? r.i then 
              f:=hconcat(f,super(sym(i)::SYM::OF, r.i::OF))
          f
        
        
        ------------------------------------------
        -- Base unit constructors (implementation)
        ------------------------------------------ 
                    
        %m(n:Integer) ==
          mksi([n,0,0,0,0,0,0]) 

        %kg(n:Integer) ==
          mksi([0,n,0,0,0,0,0]) 
          
        %s(n:Integer) ==
          mksi([0,0,n,0,0,0,0])          

        %A(n:Integer) ==
          mksi([0,0,0,n,0,0,0]) 

        %K(n:Integer) ==
          mksi([0,0,0,0,n,0,0]) 
          
        %mol(n:Integer) ==
          mksi([0,0,0,0,0,n,0])
          
        %cd(n:Integer) ==
          mksi([0,0,0,0,0,0,n])                   
       
        %one() ==
          mksi([0,0,0,0,0,0,0])  
          
          
        SI_derived(s:String):% ==
          s = "hertz"     => %s(-1)
          s = "newton"    => %kg(1)*%m(1)*%s(-2)
          s = "pascal"    => %kg(1)*%m(-1)*%s(-2)
          s = "joule"     => %kg(1)*%m(2)*%s(-2)
          s = "watt"      => %kg(1)*%m(2)*%s(-3)
          s = "coulomb"   => %s(1)*%A(1)
          s = "volt"      => %kg(1)*%m(2)*%s(-3)*%A(-1)
          s = "farad"     => %kg(-1)*%m(-2)*%s(4)*%A(2)
          s = "ohm"       => %kg(1)*%m(2)*%s(-3)*%A(2)
          s = "siemens"   => %kg(-1)*%m(-2)*%s(3)*%A(2)
          s = "weber"     => %kg(1)*%m(2)*%s(-2)*%A(-1)
          s = "tesla"     => %kg(1)*%s(-2)*%A(-1)
          s = "henry"     => %kg(1)*%m(2)*%s(-2)*%A(-2)
          s = "lumen"     => %cd(1)
          s = "lux"       => %m(-2)*%cd(1)
          s = "becquerel" => %s(-1)
          s = "gray"      => %m(2)*%s(-2)
          s = "sievert"   => %m(2)*%s(-2)
          s = "katal"     => %s(-1)*%mol(1)
          error "Expected string name of a derived SI unit."

        
        -- Helper function
        mkxpr(s:LS,v:VI):EI == 
          r:EI:=1
          for j in 1..#s repeat r:=r*(s.j)::EI^(v.j)
          r
          

        -- Buckingham Pi
        buck(t:Table(Symbol,%)):LEI ==
          M:Matrix(Integer):=matrix [si2l(t.x) for x in keys(t)]
          ns:LVI:=nullSpace transpose(M)
          r:LEI:=[]
          for j in 1..#ns repeat r:=append(r,[mkxpr(keys(t),ns.j)])
          r



-- End of SI_UNIT --        
       
       
-------------------------------------------------------------------------------
)abbrev domain PQTY PhysQty
++ Author: Kurt Pagani
++ Date Created: 2012
++ License: BSD (same as Axiom)
++
PhysQty(U): Exports == Implementation where
    
    Q   ==> Fraction(Integer)
    F   ==> Float
    R   ==> DoubleFloat
    I   ==> Integer
    QI  ==> Q_INTERVAL
    U:PhysicalUnit
       
    
    Exports == Join(CoercibleTo OutputForm) with
        
        --------------------------------------
        -- Physical quantities base operations
        --------------------------------------
        
        "*": (%,%) -> %
        "/": (%,%) -> %
        "+": (%,%) -> %
        "-": (%,%) -> %
        "^": (%,Integer) -> %
        "-":  % -> %
        elt: (Q, %) -> %
        elt: (QI,U) -> %
        elt: (Union(Q,F,R,I),U) -> %
        coerce : % -> OutputForm
        
        
        ---------------------------------------------------
        -- Main constructor: pqty(value, uncertainty, unit)
        ---------------------------------------------------
        pqty: (Q, Q, U) -> %    
        
        pqty_value: % -> Q  -- get the value
        pqty_error: % -> Q  -- get the uncertainty
        pqty_unit:  % -> U  -- get the unit
        
        pqty_interval: % -> QI  -- get the interval [v-delta,v+delta]
        pqty_scale: (%,Q) -> %       -- scale by rational number


        pqty_tm_toggle: U -> Boolean        
           
    Implementation ==  add 
    
        ----------------------
        -- Represent as Record
        ----------------------     
        Rep := Record(ival:QI, unit:U)
        
        ----------------------
        -- Implement functions
        ----------------------
        pqty(v,e,u) == [[v-e,v+e]::List(Q)::QI,u::U]$Rep
            
        pqty_value(r) == mid(r.ival)
          
        pqty_error(r) == len(r.ival)/2::Q

        pqty_unit(r) == r.unit

        pqty_interval(r) == r.ival

        ----------------------------------------------------
        -- Implement basic operations (interval arithmetic))
        ----------------------------------------------------
        
        x*y == [x.ival*y.ival, x.unit*y.unit]$Rep
         
       
        x/y == [x.ival/y.ival, x.unit/y.unit]$Rep
                 
       
        x+y == x.unit=y.unit => [x.ival+y.ival, x.unit]$Rep
            
            
        x-y == x.unit=y.unit => [x.ival-y.ival, x.unit]$Rep
          
        x^n == [x.ival^n, x.unit^n]$Rep

        - x == [-x.ival, x.unit]$Rep 

        -----------------------------------------------------------
        -- scale
        -----------------------------------------------------------
        pqty_scale(x,s) == [s x.ival,x.unit]$Rep

        --elts
        elt(q:Q,x:%):% == pqty_scale(x,q)
        elt(qi:QI,u:U):% == [qi,u]$Rep
        elt(s:Union(Q,F,R,I),u:U):% == [[s::Q,s::Q]::List(Q)::QI,u]$Rep
        

        pqty_tm := false

        pqty_tm_toggle(u:U) : Boolean ==  -- bad hack
          pqty_tm := not pqty_tm
          pqty_tm
     
        coerce(r : %) : OutputForm ==
          OF ==> OutputForm
          pqty_tm = true =>7
          hconcat [tm_frep r.ival, " "::OF, r.unit::OF ]
          hconcat [frep r.ival, " "::OF, r.unit::OF ]
          
          
          
-- End of PhysQty
\end{spad}

Oscillation period pendulum
\begin{axiom}
t:Table(Symbol,SI_UNIT):=table()
t.L := %m(1)
t.T := %s(1)
t.M := %kg(1)
t.g := t.M * t.L / (t.T)^2
t
buck(t)
solve(%.1=%C,T)
\end{axiom}

Pressure loss in a pipe
\begin{axiom}
r:Table(Symbol,SI_UNIT):=table()
r.p := %kg(1)*%m(-1)*%s(-2)  -- pressure
r.L := t.L                   
r.D := t.L
r.d := %kg(1) * %m(-3)
r.m := r.p * %s(1)           -- viscosity
r.v := t.L / t.T
r
buck(r)
\end{axiom}



spad
++++++++++++++++++++++++
++ $Id: 01-AUG-2015$ +++
++++++++++++++++++++++++
)abbrev domain RIA Q_INTERVAL
++ Author: Kurt Pagani
++ Date Created: 2012
++ License: BSD (same as Axiom)
++ ===================================
++ Rational Interval Arithmetics (RIA)
++ ===================================
++ This is an implementation of RIA as a FriCAS domain.
++ Ref. "Guaranteed Proofs Using Interval Arithmetic"
++ by Marc Daumas, Guillaume Melquiond, and Cesar Munoz
++ See docs for more information.
++
++ 
++
Q_INTERVAL : Exports == Implementation where
Q ==> Fraction(Integer) R ==> DoubleFloat I ==> Integer
OF ==> OutputForm DF ==> DoubleFloat
Exports == Join(CoercibleTo OutputForm, ConvertibleTo String) with
---------------------------- -- Basic interval operations ----------------------------
"+" : (%,%) -> % "-" : (%,%) -> % "*" : (%,%) -> % "/" : (%,%) -> % "^" : (%,I) -> % "-" : % -> % abs : % -> % elt : (Q, %) -> % coerce: % -> OutputForm coerce: List Q -> % coerce: Float -> % coerce: DF -> %
concise : % -> OutputForm
---------------------------------- -- Constructors and query functions -----------------------------------
mki : (Q,Q) -> % lb : % -> Q ub : % -> Q
mid : % -> Q len : % -> Q
frep : % -> OF tm_frep : % -> OF
Implementation == add
-------------------- -- Represent as Rec -------------------- Rep := Record(lb:Q, ub:Q)
----------------------- -- Implement functions ----------------------- mki(a,b) == b>=a => [a,b]$Rep
lb(r:%) == r.lb ub(r:%) == r.ub
x+y == mki(x.lb + y.lb, x.ub + y.ub) x-y == mki(x.lb - y.ub, x.ub - y.lb)
x*y == a:Q:=min(min(x.lb*y.lb,x.lb*y.ub),min(x.ub*y.lb,x.ub*y.ub)) b:Q:=max(max(x.lb*y.lb,x.lb*y.ub),max(x.ub*y.lb,x.ub*y.ub)) mki(a,b)
x/y == if y.lb*y.ub > 0 then x*mki(1/y.ub,1/y.lb)
-x == mki(-x.ub,-x.lb)
abs(x) == if x.lb*x.ub >= 0 then mki(min(abs(x.lb), abs(x.ub)), max(abs(x.lb), abs(x.ub))) else mki(0::Q, max(abs(x.lb), abs(x.ub)))
x^n == zero? n => mki(1,1) one? n => x x.lb>=0 or odd? n => mki(x.lb^n,x.ub^n) x.ub<=0 or even? n => mki(x.ub^n,x.lb^n) mki(0,max(x.lb^n,x.ub^n))
coerce(r : %) : OutputForm == hconcat ["[",r.lb::OF,",",r.ub::OF,"]"]
coerce(l : List Q) : % == #l ~= 2 => error "Format: [lb,ub]" l.1 > l.2 => error "Must have lb <= ub" mki(l.1,l.2)
coerce(r:DF):% == rc:Q:=retract r mki(rc,rc)
coerce(r:Float):% == rc:Q:=retract r mki(rc,rc)
coerceSTR(s:String):% == s1 := split(s,char ".") s2 := split(s1.2, char "(") vs := concat [s1.1,".",s2.1] v:=float(convert vs) v::Rep
elt(q:Q,x:%):% == mki(q*x.lb, q*x.ub)
mid(x:%):Q == (x.lb + x.ub)/2::Q len(x:%):Q == (x.ub - x.lb)
frep(x:%):OF == pm:Character:=char(177) sep:=concat [" ",pm::String," "]::Symbol hconcat [mid(x)::DF::OF, sep::OF, (len(x)/2::Q)::DF::OF]
tm_frep(x:%):OF == sep:=" <pm> "::Symbol hconcat [mid(x)::DF::OF, sep::OF, (len(x)/2::Q)::DF::OF]
concise(x:%):OF == frep(x) -- to do
)abbrev category PUNIT PhysicalUnit ++ PhysicalUnit() : Category == with "*" : (%,%) -> % "/" : (%,%) -> % "^" : (%,Integer) -> % "=" : (%,%) -> Boolean %one : -> % coerce : % -> OutputForm
)abbrev domain SI SI_UNIT ++ Author: Kurt Pagani ++ Date Created: 2012 ++ License: BSD (same as Axiom) ++ ================================ ++ Physical Quantities and SI Units ++ ================================ ++ This is an implementation of physical quantities and SI units as FriCAS ++ domains. ++ ++ See docs for more information. ++ ++ Revision: ++ - removing outputForm, Ring ++ - added negation, elt ++ ++ SI_UNIT : Exports == Implementation where
EI ==> Expression Integer VI ==> Vector Integer LS ==> List Symbol LEI ==> List EI LVI ==> List VI
Exports == Join(PhysicalUnit,CoercibleTo OutputForm) with
---------------------------- -- (de)-construct an SI unit ---------------------------- mksi: List(Integer) -> % si2l: % -> List(Integer)
-------------------------------- -- basic operation with SI units -------------------------------- --"*" : (%,%) -> % --"/" : (%,%) -> % --"^" : (%,Integer) -> % --"=" : (%,%) -> Boolean
----------------------------------------------------------------- -- constructor for each base unit: e.g. %m(2)=m^2 -> square meter ----------------------------------------------------------------- %m : Integer -> % %kg : Integer -> % %s : Integer -> % %A : Integer -> % %K : Integer -> % %mol : Integer -> % %cd : Integer -> % --%one : -> %
------------------- -- SI derived units ------------------- SI_derived : String -> %
---------------- -- Buckingham Pi ---------------- buck : Table(Symbol,%) -> List(Expression(Integer))
Implementation == add
--------------------------------------- -- Represent as 1-Array [0,0,0,0,0,0,0] --------------------------------------- Rep := OneDimensionalArray(Integer)
--------------------------------- -- Implementation of constructors ---------------------------------
mksi(l) == r:Rep:=new(7,0$Integer)$Rep for i in 1..7 repeat r.i := l(i) r
si2l(r) == l:List(Integer):=[0,0,0,0,0,0,0] for i in 1..7 repeat l(i) := r.i l
x * y == z:Rep:=new(7,0$Integer)$Rep for i in 1..7 repeat z.i := x.i + y.i z
x / y == z:Rep:=new(7,0$Integer)$Rep for i in 1..7 repeat z.i := x.i - y.i z
x ^ n == z:Rep:=new(7,0$Integer)$Rep for i in 1..7 repeat z.i := x.i * n z
x = y == res:Boolean:=true for i in 1..7 repeat res:=(res and test(x.i=y.i)$Boolean) res
------------------------ -- Coerce to output form ------------------------ coerce(r : %) : OutputForm == SYM ==> Symbol OF ==> OutputForm sym:List(String):=["m","kg","s","A","K","mol","cd"] f:OutputForm:=empty() for i in 1..7 repeat if not zero? r.i then f:=hconcat(f,super(sym(i)::SYM::OF, r.i::OF)) f
------------------------------------------ -- Base unit constructors (implementation) ------------------------------------------
%m(n:Integer) == mksi([n,0,0,0,0,0,0])
%kg(n:Integer) == mksi([0,n,0,0,0,0,0])
%s(n:Integer) == mksi([0,0,n,0,0,0,0])
%A(n:Integer) == mksi([0,0,0,n,0,0,0])
%K(n:Integer) == mksi([0,0,0,0,n,0,0])
%mol(n:Integer) == mksi([0,0,0,0,0,n,0])
%cd(n:Integer) == mksi([0,0,0,0,0,0,n])
%one() == mksi([0,0,0,0,0,0,0])
SI_derived(s:String):% == s = "hertz" => %s(-1) s = "newton" => %kg(1)*%m(1)*%s(-2) s = "pascal" => %kg(1)*%m(-1)*%s(-2) s = "joule" => %kg(1)*%m(2)*%s(-2) s = "watt" => %kg(1)*%m(2)*%s(-3) s = "coulomb" => %s(1)*%A(1) s = "volt" => %kg(1)*%m(2)*%s(-3)*%A(-1) s = "farad" => %kg(-1)*%m(-2)*%s(4)*%A(2) s = "ohm" => %kg(1)*%m(2)*%s(-3)*%A(2) s = "siemens" => %kg(-1)*%m(-2)*%s(3)*%A(2) s = "weber" => %kg(1)*%m(2)*%s(-2)*%A(-1) s = "tesla" => %kg(1)*%s(-2)*%A(-1) s = "henry" => %kg(1)*%m(2)*%s(-2)*%A(-2) s = "lumen" => %cd(1) s = "lux" => %m(-2)*%cd(1) s = "becquerel" => %s(-1) s = "gray" => %m(2)*%s(-2) s = "sievert" => %m(2)*%s(-2) s = "katal" => %s(-1)*%mol(1) error "Expected string name of a derived SI unit."
-- Helper function mkxpr(s:LS,v:VI):EI == r:EI:=1 for j in 1..#s repeat r:=r*(s.j)::EI^(v.j) r
-- Buckingham Pi buck(t:Table(Symbol,%)):LEI == M:Matrix(Integer):=matrix [si2l(t.x) for x in keys(t)] ns:LVI:=nullSpace transpose(M) r:LEI:=[] for j in 1..#ns repeat r:=append(r,[mkxpr(keys(t),ns.j)]) r
-- End of SI_UNIT --
------------------------------------------------------------------------------- )abbrev domain PQTY PhysQty ++ Author: Kurt Pagani ++ Date Created: 2012 ++ License: BSD (same as Axiom) ++ PhysQty(U): Exports == Implementation where
Q ==> Fraction(Integer) F ==> Float R ==> DoubleFloat I ==> Integer QI ==> Q_INTERVAL U:PhysicalUnit
Exports == Join(CoercibleTo OutputForm) with
-------------------------------------- -- Physical quantities base operations --------------------------------------
"*": (%,%) -> % "/": (%,%) -> % "+": (%,%) -> % "-": (%,%) -> % "^": (%,Integer) -> % "-": % -> % elt: (Q, %) -> % elt: (QI,U) -> % elt: (Union(Q,F,R,I),U) -> % coerce : % -> OutputForm
--------------------------------------------------- -- Main constructor: pqty(value, uncertainty, unit) --------------------------------------------------- pqty: (Q, Q, U) -> %
pqty_value: % -> Q -- get the value pqty_error: % -> Q -- get the uncertainty pqty_unit: % -> U -- get the unit
pqty_interval: % -> QI -- get the interval [v-delta,v+delta] pqty_scale: (%,Q) -> % -- scale by rational number
pqty_tm_toggle: U -> Boolean
Implementation == add
---------------------- -- Represent as Record ---------------------- Rep := Record(ival:QI, unit:U)
---------------------- -- Implement functions ---------------------- pqty(v,e,u) == [[v-e,v+e]::List(Q)::QI,u::U]$Rep
pqty_value(r) == mid(r.ival)
pqty_error(r) == len(r.ival)/2::Q
pqty_unit(r) == r.unit
pqty_interval(r) == r.ival
---------------------------------------------------- -- Implement basic operations (interval arithmetic)) ----------------------------------------------------
x*y == [x.ival*y.ival, x.unit*y.unit]$Rep
x/y == [x.ival/y.ival, x.unit/y.unit]$Rep
x+y == x.unit=y.unit => [x.ival+y.ival, x.unit]$Rep
x-y == x.unit=y.unit => [x.ival-y.ival, x.unit]$Rep
x^n == [x.ival^n, x.unit^n]$Rep
- x == [-x.ival, x.unit]$Rep
----------------------------------------------------------- -- scale ----------------------------------------------------------- pqty_scale(x,s) == [s x.ival,x.unit]$Rep
--elts elt(q:Q,x:%):% == pqty_scale(x,q) elt(qi:QI,u:U):% == [qi,u]$Rep elt(s:Union(Q,F,R,I),u:U):% == [[s::Q,s::Q]::List(Q)::QI,u]$Rep
pqty_tm := false
pqty_tm_toggle(u:U) : Boolean == -- bad hack pqty_tm := not pqty_tm pqty_tm
coerce(r : %) : OutputForm == OF ==> OutputForm pqty_tm = true =>7 hconcat [tm_frep r.ival, " "::OF, r.unit::OF ] hconcat [frep r.ival, " "::OF, r.unit::OF ]
-- End of PhysQty
spad
   Compiling FriCAS source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/8367240618814005156-25px001.spad
      using old system compiler.
   RIA abbreviates domain Q_INTERVAL 
------------------------------------------------------------------------
   initializing NRLIB RIA for Q_INTERVAL 
   compiling into NRLIB RIA 
   compiling exported mki : (Fraction Integer,Fraction Integer) -> $
Time: 0.03 SEC.
compiling exported lb : $ -> Fraction Integer RIA;lb;$F;2 is replaced by QCAR Time: 0 SEC.
compiling exported ub : $ -> Fraction Integer RIA;ub;$F;3 is replaced by QCDR Time: 0 SEC.
compiling exported + : ($,$) -> $ Time: 0 SEC.
compiling exported - : ($,$) -> $ Time: 0 SEC.
compiling exported * : ($,$) -> $ Time: 0.01 SEC.
compiling exported / : ($,$) -> $ Time: 0 SEC.
compiling exported - : $ -> $ Time: 0 SEC.
compiling exported abs : $ -> $ Time: 0.01 SEC.
compiling exported ^ : ($,Integer) -> $ Time: 0.01 SEC.
compiling exported coerce : $ -> OutputForm Time: 0 SEC.
compiling exported coerce : List Fraction Integer -> $ Time: 0.02 SEC.
compiling exported coerce : DoubleFloat -> $ Time: 0.01 SEC.
compiling exported coerce : Float -> $ Time: 0 SEC.
compiling local coerceSTR : String -> $ Time: 0.02 SEC.
compiling exported elt : (Fraction Integer,$) -> $ Time: 0 SEC.
compiling exported mid : $ -> Fraction Integer Time: 0 SEC.
compiling exported len : $ -> Fraction Integer Time: 0 SEC.
compiling exported frep : $ -> OutputForm Time: 0.02 SEC.
compiling exported tm_frep : $ -> OutputForm Time: 0.01 SEC.
compiling exported concise : $ -> OutputForm Time: 0 SEC.
(time taken in buildFunctor: 0)
;;; *** Q_INTERVAL REDEFINED
;;; *** Q_INTERVAL REDEFINED Time: 0 SEC.
Cumulative Statistics for Constructor Q_INTERVAL Time: 0.14 seconds
finalizing NRLIB RIA Processing Q_INTERVAL for Browser database: --------constructor--------- --->-->Q_INTERVAL((+ (% % %))): Not documented!!!! --->-->Q_INTERVAL((- (% % %))): Not documented!!!! --->-->Q_INTERVAL((* (% % %))): Not documented!!!! --->-->Q_INTERVAL((/ (% % %))): Not documented!!!! --->-->Q_INTERVAL((^ (% % (Integer)))): Not documented!!!! --->-->Q_INTERVAL((- (% %))): Not documented!!!! --->-->Q_INTERVAL((abs (% %))): Not documented!!!! --->-->Q_INTERVAL((elt (% (Fraction (Integer)) %))): Not documented!!!! --->-->Q_INTERVAL((coerce ((OutputForm) %))): Not documented!!!! --->-->Q_INTERVAL((coerce (% (List (Fraction (Integer)))))): Not documented!!!! --->-->Q_INTERVAL((coerce (% (Float)))): Not documented!!!! --->-->Q_INTERVAL((coerce (% (DoubleFloat)))): Not documented!!!! --->-->Q_INTERVAL((concise ((OutputForm) %))): Not documented!!!! --->-->Q_INTERVAL((mki (% (Fraction (Integer)) (Fraction (Integer))))): Not documented!!!! --->-->Q_INTERVAL((lb ((Fraction (Integer)) %))): Not documented!!!! --->-->Q_INTERVAL((ub ((Fraction (Integer)) %))): Not documented!!!! --->-->Q_INTERVAL((mid ((Fraction (Integer)) %))): Not documented!!!! --->-->Q_INTERVAL((len ((Fraction (Integer)) %))): Not documented!!!! --->-->Q_INTERVAL((frep ((OutputForm) %))): Not documented!!!! --->-->Q_INTERVAL((tm_frep ((OutputForm) %))): Not documented!!!! ; compiling file "/var/aw/var/LatexWiki/RIA.NRLIB/RIA.lsp" (written 02 AUG 2015 03:16:36 AM):
; /var/aw/var/LatexWiki/RIA.NRLIB/RIA.fasl written ; compilation finished in 0:00:00.114 ------------------------------------------------------------------------ Q_INTERVAL is now explicitly exposed in frame initial Q_INTERVAL will be automatically loaded when needed from /var/aw/var/LatexWiki/RIA.NRLIB/RIA
PUNIT abbreviates category PhysicalUnit ------------------------------------------------------------------------ initializing NRLIB PUNIT for PhysicalUnit compiling into NRLIB PUNIT
;;; *** |PhysicalUnit| REDEFINED Time: 0 SEC.
finalizing NRLIB PUNIT Processing PhysicalUnit for Browser database: --------constructor--------- --->-->PhysicalUnit((+ (% % %))): Not documented!!!! --->-->PhysicalUnit((- (% % %))): Not documented!!!! --->-->PhysicalUnit((* (% % %))): Not documented!!!! --->-->PhysicalUnit((/ (% % %))): Not documented!!!! --->-->PhysicalUnit((^ (% % (Integer)))): Not documented!!!! --->-->PhysicalUnit((- (% %))): Not documented!!!! --->-->PhysicalUnit((abs (% %))): Not documented!!!! --->-->PhysicalUnit((elt (% (Fraction (Integer)) %))): Not documented!!!! --->-->PhysicalUnit((coerce ((OutputForm) %))): Not documented!!!! --->-->PhysicalUnit((coerce (% (List (Fraction (Integer)))))): Not documented!!!! --->-->PhysicalUnit((coerce (% (Float)))): Not documented!!!! --->-->PhysicalUnit((coerce (% (DoubleFloat)))): Not documented!!!! --->-->PhysicalUnit((concise ((OutputForm) %))): Not documented!!!! --->-->PhysicalUnit((mki (% (Fraction (Integer)) (Fraction (Integer))))): Not documented!!!! --->-->PhysicalUnit((lb ((Fraction (Integer)) %))): Not documented!!!! --->-->PhysicalUnit((ub ((Fraction (Integer)) %))): Not documented!!!! --->-->PhysicalUnit((mid ((Fraction (Integer)) %))): Not documented!!!! --->-->PhysicalUnit((len ((Fraction (Integer)) %))): Not documented!!!! --->-->PhysicalUnit((frep ((OutputForm) %))): Not documented!!!! --->-->PhysicalUnit((tm_frep ((OutputForm) %))): Not documented!!!! --------constructor--------- --->-->PhysicalUnit((* (% % %))): Not documented!!!! --->-->PhysicalUnit((/ (% % %))): Not documented!!!! --->-->PhysicalUnit((^ (% % (Integer)))): Not documented!!!! --->-->PhysicalUnit((= ((Boolean) % %))): Not documented!!!! --->-->PhysicalUnit((%one (%))): Not documented!!!! --->-->PhysicalUnit((coerce ((OutputForm) %))): Not documented!!!! --->-->PhysicalUnit(): Spurious comments: \blankline ; compiling file "/var/aw/var/LatexWiki/PUNIT.NRLIB/PUNIT.lsp" (written 02 AUG 2015 03:16:36 AM):
; /var/aw/var/LatexWiki/PUNIT.NRLIB/PUNIT.fasl written ; compilation finished in 0:00:00.003 ------------------------------------------------------------------------ PhysicalUnit is now explicitly exposed in frame initial PhysicalUnit will be automatically loaded when needed from /var/aw/var/LatexWiki/PUNIT.NRLIB/PUNIT
SI abbreviates domain SI_UNIT ------------------------------------------------------------------------ initializing NRLIB SI for SI_UNIT compiling into NRLIB SI Local variable Rep type redefined: (Join (OneDimensionalArrayAggregate (Integer)) (CATEGORY domain (SIGNATURE oneDimensionalArray ($ (List (Integer)))) (SIGNATURE oneDimensionalArray ($ (NonNegativeInteger) (Integer))))) to (Join (SetCategory) (CATEGORY domain (SIGNATURE construct ((Record (: lb (Fraction (Integer))) (: ub (Fraction (Integer)))) (Fraction (Integer)) (Fraction (Integer)))) (SIGNATURE ~= ((Boolean) (Record (: lb (Fraction (Integer))) (: ub (Fraction (Integer)))) (Record (: lb (Fraction (Integer))) (: ub (Fraction (Integer)))))) (SIGNATURE coerce ((OutputForm) (Record (: lb (Fraction (Integer))) (: ub (Fraction (Integer)))))) (SIGNATURE elt ((Fraction (Integer)) (Record (: lb (Fraction (Integer))) (: ub (Fraction (Integer)))) lb)) (SIGNATURE elt ((Fraction (Integer)) (Record (: lb (Fraction (Integer))) (: ub (Fraction (Integer)))) ub)) (SIGNATURE setelt! ((Fraction (Integer)) (Record (: lb (Fraction (Integer))) (: ub (Fraction (Integer)))) lb (Fraction (Integer)))) (SIGNATURE setelt! ((Fraction (Integer)) (Record (: lb (Fraction (Integer))) (: ub (Fraction (Integer)))) ub (Fraction (Integer)))) (SIGNATURE copy ((Record (: lb (Fraction (Integer))) (: ub (Fraction (Integer)))) (Record (: lb (Fraction (Integer))) (: ub (Fraction (Integer)))))))) compiling exported mksi : List Integer -> $ Time: 0.01 SEC.
compiling exported si2l : $ -> List Integer Time: 0 SEC.
compiling exported * : ($,$) -> $ Time: 0.01 SEC.
compiling exported / : ($,$) -> $ Time: 0 SEC.
compiling exported ^ : ($,Integer) -> $ Time: 0 SEC.
compiling exported = : ($,$) -> Boolean Time: 0.01 SEC.
compiling exported coerce : $ -> OutputForm processing macro definition SYM ==> Symbol processing macro definition OF ==> OutputForm Time: 0.01 SEC.
compiling exported %m : Integer -> $ Time: 0 SEC.
compiling exported %kg : Integer -> $ Time: 0 SEC.
compiling exported %s : Integer -> $ Time: 0.01 SEC.
compiling exported %A : Integer -> $ Time: 0 SEC.
compiling exported %K : Integer -> $ Time: 0 SEC.
compiling exported %mol : Integer -> $ Time: 0 SEC.
compiling exported %cd : Integer -> $ Time: 0 SEC.
compiling exported %one : () -> $ Time: 0 SEC.
compiling exported SI_derived : String -> $ Time: 0.02 SEC.
compiling local mkxpr : (List Symbol,Vector Integer) -> Expression Integer Time: 0.05 SEC.
compiling exported buck : Table(Symbol,$) -> List Expression Integer Time: 0.04 SEC.
(time taken in buildFunctor: 0)
;;; *** SI_UNIT REDEFINED
;;; *** SI_UNIT REDEFINED Time: 0 SEC.
Warnings: [1] coerce: f has no value
Cumulative Statistics for Constructor SI_UNIT Time: 0.16 seconds
finalizing NRLIB SI Processing SI_UNIT for Browser database: --------constructor--------- --->-->SI_UNIT((+ (% % %))): Not documented!!!! --->-->SI_UNIT((- (% % %))): Not documented!!!! --->-->SI_UNIT((* (% % %))): Not documented!!!! --->-->SI_UNIT((/ (% % %))): Not documented!!!! --->-->SI_UNIT((^ (% % (Integer)))): Not documented!!!! --->-->SI_UNIT((- (% %))): Not documented!!!! --->-->SI_UNIT((abs (% %))): Not documented!!!! --->-->SI_UNIT((elt (% (Fraction (Integer)) %))): Not documented!!!! --->-->SI_UNIT((coerce ((OutputForm) %))): Not documented!!!! --->-->SI_UNIT((coerce (% (List (Fraction (Integer)))))): Not documented!!!! --->-->SI_UNIT((coerce (% (Float)))): Not documented!!!! --->-->SI_UNIT((coerce (% (DoubleFloat)))): Not documented!!!! --->-->SI_UNIT((concise ((OutputForm) %))): Not documented!!!! --->-->SI_UNIT((mki (% (Fraction (Integer)) (Fraction (Integer))))): Not documented!!!! --->-->SI_UNIT((lb ((Fraction (Integer)) %))): Not documented!!!! --->-->SI_UNIT((ub ((Fraction (Integer)) %))): Not documented!!!! --->-->SI_UNIT((mid ((Fraction (Integer)) %))): Not documented!!!! --->-->SI_UNIT((len ((Fraction (Integer)) %))): Not documented!!!! --->-->SI_UNIT((frep ((OutputForm) %))): Not documented!!!! --->-->SI_UNIT((tm_frep ((OutputForm) %))): Not documented!!!! --------constructor--------- --->-->SI_UNIT((* (% % %))): Not documented!!!! --->-->SI_UNIT((/ (% % %))): Not documented!!!! --->-->SI_UNIT((^ (% % (Integer)))): Not documented!!!! --->-->SI_UNIT((= ((Boolean) % %))): Not documented!!!! --->-->SI_UNIT((%one (%))): Not documented!!!! --->-->SI_UNIT((coerce ((OutputForm) %))): Not documented!!!! --------constructor--------- --->-->SI_UNIT((mksi (% (List (Integer))))): Not documented!!!! --->-->SI_UNIT((si2l ((List (Integer)) %))): Not documented!!!! --->-->SI_UNIT( %(Integer())() ): Not documented!!!! --->-->SI_UNIT((%kg (% (Integer)))): Not documented!!!! --->-->SI_UNIT(((% (|Integer|)))): Not documented!!!! --->-->SI_UNIT((%A (% (Integer)))): Not documented!!!! --->-->SI_UNIT((%K (% (Integer)))): Not documented!!!! --->-->SI_UNIT((%mol (% (Integer)))): Not documented!!!! --->-->SI_UNIT((%cd (% (Integer)))): Not documented!!!! --->-->SI_UNIT((SI_derived (% (String)))): Not documented!!!! --->-->SI_UNIT((buck ((List (Expression (Integer))) (Table (Symbol) %)))): Not documented!!!! --->-->SI_UNIT(): Spurious comments: \blankline --->-->SI_UNIT(): Spurious comments: \indented{1}{Author: Kurt Pagani} Date Created: 2012 License: \spad{BSD} (same as Axiom) ================================ Physical Quantities and SI Units ================================ This is an implementation of physical quantities and SI units as FriCAS domains. \blankline See docs for more information. \blankline Revision: - removing outputForm,{} Ring - added negation,{} elt \blankline \blankline ; compiling file "/var/aw/var/LatexWiki/SI.NRLIB/SI.lsp" (written 02 AUG 2015 03:16:36 AM):
; /var/aw/var/LatexWiki/SI.NRLIB/SI.fasl written ; compilation finished in 0:00:00.150 ------------------------------------------------------------------------ SI_UNIT is now explicitly exposed in frame initial SI_UNIT will be automatically loaded when needed from /var/aw/var/LatexWiki/SI.NRLIB/SI
PQTY abbreviates domain PhysQty ------------------------------------------------------------------------ initializing NRLIB PQTY for PhysQty compiling into NRLIB PQTY Local variable Rep type redefined: (Join (SetCategory) (CATEGORY domain (SIGNATURE construct ((Record (: ival (Q_INTERVAL)) (: unit U)) (Q_INTERVAL) U)) (SIGNATURE ~= ((Boolean) (Record (: ival (Q_INTERVAL)) (: unit U)) (Record (: ival (Q_INTERVAL)) (: unit U)))) (SIGNATURE coerce ((OutputForm) (Record (: ival (Q_INTERVAL)) (: unit U)))) (SIGNATURE elt ((Q_INTERVAL) (Record (: ival (Q_INTERVAL)) (: unit U)) ival)) (SIGNATURE elt (U (Record (: ival (Q_INTERVAL)) (: unit U)) unit)) (SIGNATURE setelt! ((Q_INTERVAL) (Record (: ival (Q_INTERVAL)) (: unit U)) ival (Q_INTERVAL))) (SIGNATURE setelt! (U (Record (: ival (Q_INTERVAL)) (: unit U)) unit U)) (SIGNATURE copy ((Record (: ival (Q_INTERVAL)) (: unit U)) (Record (: ival (Q_INTERVAL)) (: unit U)))))) to (Join (OneDimensionalArrayAggregate (Integer)) (CATEGORY domain (SIGNATURE oneDimensionalArray ($ (List (Integer)))) (SIGNATURE oneDimensionalArray ($ (NonNegativeInteger) (Integer))))) compiling exported pqty : (Fraction Integer,Fraction Integer,U) -> $ Time: 0.01 SEC.
compiling exported pqty_value : $ -> Fraction Integer Time: 0 SEC.
compiling exported pqty_error : $ -> Fraction Integer Time: 0 SEC.
compiling exported pqty_unit : $ -> U PQTY;pqty_unit;$U;4 is replaced by QCDR Time: 0 SEC.
compiling exported pqty_interval : $ -> Q_INTERVAL PQTY;pqty_interval;$Qinterval;5 is replaced by QCAR Time: 0 SEC.
compiling exported * : ($,$) -> $ Time: 0 SEC.
compiling exported / : ($,$) -> $ Time: 0 SEC.
compiling exported + : ($,$) -> $ Time: 0 SEC.
compiling exported - : ($,$) -> $ Time: 0 SEC.
compiling exported ^ : ($,Integer) -> $ Time: 0 SEC.
compiling exported - : $ -> $ Time: 0 SEC.
compiling exported pqty_scale : ($,Fraction Integer) -> $ Time: 0 SEC.
compiling exported elt : (Fraction Integer,$) -> $ Time: 0 SEC.
compiling exported elt : (Q_INTERVAL,U) -> $ PQTY;elt;QintervalU$;14 is replaced by CONS Time: 0 SEC.
compiling exported elt : (Union(Fraction Integer,Float,DoubleFloat,Integer),U) -> $ Time: 0 SEC.
compiling exported pqty_tm_toggle : U -> Boolean Time: 0 SEC.
compiling exported coerce : $ -> OutputForm processing macro definition OF ==> OutputForm Time: 0.01 SEC.
(time taken in buildFunctor: 0)
;;; *** |PhysQty| REDEFINED
;;; *** |PhysQty| REDEFINED Time: 0 SEC.
Warnings: [1] pqty_value: ival has no value [2] pqty_error: ival has no value [3] pqty_unit: unit has no value [4] pqty_interval: ival has no value [5] *: ival has no value [6] *: unit has no value [7] /: ival has no value [8] /: unit has no value [9] +: unit has no value [10] +: ival has no value [11] -: unit has no value [12] -: ival has no value [13] ^: ival has no value [14] ^: unit has no value [15] pqty_scale: ival has no value [16] pqty_scale: unit has no value [17] coerce: ival has no value [18] coerce: unit has no value
Cumulative Statistics for Constructor PhysQty Time: 0.02 seconds
finalizing NRLIB PQTY Processing PhysQty for Browser database: --------constructor--------- --->-->PhysQty((+ (% % %))): Not documented!!!! --->-->PhysQty((- (% % %))): Not documented!!!! --->-->PhysQty((* (% % %))): Not documented!!!! --->-->PhysQty((/ (% % %))): Not documented!!!! --->-->PhysQty((^ (% % (Integer)))): Not documented!!!! --->-->PhysQty((- (% %))): Not documented!!!! --->-->PhysQty((abs (% %))): Not documented!!!! --->-->PhysQty((elt (% (Fraction (Integer)) %))): Not documented!!!! --->-->PhysQty((coerce ((OutputForm) %))): Not documented!!!! --->-->PhysQty((coerce (% (List (Fraction (Integer)))))): Not documented!!!! --->-->PhysQty((coerce (% (Float)))): Not documented!!!! --->-->PhysQty((coerce (% (DoubleFloat)))): Not documented!!!! --->-->PhysQty((concise ((OutputForm) %))): Not documented!!!! --->-->PhysQty((mki (% (Fraction (Integer)) (Fraction (Integer))))): Not documented!!!! --->-->PhysQty((lb ((Fraction (Integer)) %))): Not documented!!!! --->-->PhysQty((ub ((Fraction (Integer)) %))): Not documented!!!! --->-->PhysQty((mid ((Fraction (Integer)) %))): Not documented!!!! --->-->PhysQty((len ((Fraction (Integer)) %))): Not documented!!!! --->-->PhysQty((frep ((OutputForm) %))): Not documented!!!! --->-->PhysQty((tm_frep ((OutputForm) %))): Not documented!!!! --------constructor--------- --->-->PhysQty((* (% % %))): Not documented!!!! --->-->PhysQty((/ (% % %))): Not documented!!!! --->-->PhysQty((^ (% % (Integer)))): Not documented!!!! --->-->PhysQty((= ((Boolean) % %))): Not documented!!!! --->-->PhysQty((%one (%))): Not documented!!!! --->-->PhysQty((coerce ((OutputForm) %))): Not documented!!!! --------constructor--------- --->-->PhysQty((mksi (% (List (Integer))))): Not documented!!!! --->-->PhysQty((si2l ((List (Integer)) %))): Not documented!!!! --->-->PhysQty( %(Integer())() ): Not documented!!!! --->-->PhysQty((%kg (% (Integer)))): Not documented!!!! --->-->PhysQty(((% (|Integer|)))): Not documented!!!! --->-->PhysQty((%A (% (Integer)))): Not documented!!!! --->-->PhysQty((%K (% (Integer)))): Not documented!!!! --->-->PhysQty((%mol (% (Integer)))): Not documented!!!! --->-->PhysQty((%cd (% (Integer)))): Not documented!!!! --->-->PhysQty((SI_derived (% (String)))): Not documented!!!! --->-->PhysQty((buck ((List (Expression (Integer))) (Table (Symbol) %)))): Not documented!!!! --------constructor--------- --->-->PhysQty((* (% % %))): Not documented!!!! --->-->PhysQty((/ (% % %))): Not documented!!!! --->-->PhysQty((+ (% % %))): Not documented!!!! --->-->PhysQty((- (% % %))): Not documented!!!! --->-->PhysQty((^ (% % (Integer)))): Not documented!!!! --->-->PhysQty((- (% %))): Not documented!!!! --->-->PhysQty((elt (% (Fraction (Integer)) %))): Not documented!!!! --->-->PhysQty((elt (% (Q_INTERVAL) U))): Not documented!!!! --->-->PhysQty((elt (% (Union (Fraction (Integer)) (Float) (DoubleFloat) (Integer)) U))): Not documented!!!! --->-->PhysQty((coerce ((OutputForm) %))): Not documented!!!! --->-->PhysQty((pqty (% (Fraction (Integer)) (Fraction (Integer)) U))): Not documented!!!! --->-->PhysQty((pqty_value ((Fraction (Integer)) %))): Not documented!!!! --->-->PhysQty((pqty_error ((Fraction (Integer)) %))): Not documented!!!! --->-->PhysQty((pqty_unit (U %))): Not documented!!!! --->-->PhysQty((pqty_interval ((Q_INTERVAL) %))): Not documented!!!! --->-->PhysQty((pqty_scale (% % (Fraction (Integer))))): Not documented!!!! --->-->PhysQty((pqty_tm_toggle ((Boolean) U))): Not documented!!!! --->-->PhysQty(): Spurious comments: \blankline --->-->PhysQty(): Spurious comments: \indented{1}{Author: Kurt Pagani} Date Created: 2012 License: \spad{BSD} (same as Axiom) ================================ Physical Quantities and SI Units ================================ This is an implementation of physical quantities and SI units as FriCAS domains. \blankline See docs for more information. \blankline Revision: - removing outputForm,{} Ring - added negation,{} elt \blankline \blankline --->-->PhysQty(): Spurious comments: \indented{1}{Author: Kurt Pagani} Date Created: 2012 License: \spad{BSD} (same as Axiom) \blankline ; compiling file "/var/aw/var/LatexWiki/PQTY.NRLIB/PQTY.lsp" (written 02 AUG 2015 03:16:36 AM):
; /var/aw/var/LatexWiki/PQTY.NRLIB/PQTY.fasl written ; compilation finished in 0:00:00.066 ------------------------------------------------------------------------ PhysQty is now explicitly exposed in frame initial PhysQty will be automatically loaded when needed from /var/aw/var/LatexWiki/PQTY.NRLIB/PQTY

Oscillation period pendulum

fricas
t:Table(Symbol,SI_UNIT):=table()

\label{eq1} \mbox{\rm table} \left({}\right)(1)
Type: Table(Symbol,SI_UNIT)
fricas
t.L := %m(1)

\label{eq2}m_{\ }^{1}(2)
Type: SI_UNIT
fricas
t.T := %s(1)

\label{eq3}s_{\ }^{1}(3)
Type: SI_UNIT
fricas
t.M := %kg(1)

\label{eq4}kg_{\ }^{1}(4)
Type: SI_UNIT
fricas
t.g := t.M * t.L / (t.T)^2

\label{eq5}{{m_{\ }^{1}}{kg_{\ }^{1}}}{s_{\ }^{- 2}}(5)
Type: SI_UNIT
fricas
t

\label{eq6} \mbox{\rm table} \left({{g ={{{m_{\ }^{1}}{kg_{\ }^{1}}}{s_{\ }^{- 2}}}}, \:{M ={kg_{\ }^{1}}}, \:{T ={s_{\ }^{1}}}, \:{L ={m_{\ }^{1}}}}\right)(6)
Type: Table(Symbol,SI_UNIT)
fricas
buck(t)

\label{eq7}\left[{{L \  M}\over{{{T}^{2}}\  g}}\right](7)
Type: List(Expression(Integer))
fricas
solve(%.1=%C,T)

\label{eq8}\begin{array}{@{}l}
\displaystyle
\left[{T ={\root{3}\of{{L \  M}\over g}}}, \:{T ={{{\left({\sqrt{- 3}}- 1 \right)}\ {\root{3}\of{{L \  M}\over g}}}\over 2}}, \: \right.
\
\
\displaystyle
\left.{T ={{{\left(-{\sqrt{- 3}}- 1 \right)}\ {\root{3}\of{{L \  M}\over g}}}\over 2}}\right] 
(8)
Type: List(Equation(Expression(Integer)))

Pressure loss in a pipe

fricas
r:Table(Symbol,SI_UNIT):=table()

\label{eq9} \mbox{\rm table} \left({}\right)(9)
Type: Table(Symbol,SI_UNIT)
fricas
r.p := %kg(1)*%m(-1)*%s(-2)  -- pressure

\label{eq10}{{m_{\ }^{- 1}}{kg_{\ }^{1}}}{s_{\ }^{- 2}}(10)
Type: SI_UNIT
fricas
r.L := t.L

\label{eq11}m_{\ }^{1}(11)
Type: SI_UNIT
fricas
r.D := t.L

\label{eq12}m_{\ }^{1}(12)
Type: SI_UNIT
fricas
r.d := %kg(1) * %m(-3)

\label{eq13}{m_{\ }^{- 3}}{kg_{\ }^{1}}(13)
Type: SI_UNIT
fricas
r.m := r.p * %s(1)           -- viscosity

\label{eq14}{{m_{\ }^{- 1}}{kg_{\ }^{1}}}{s_{\ }^{- 1}}(14)
Type: SI_UNIT
fricas
r.v := t.L / t.T

\label{eq15}{m_{\ }^{1}}{s_{\ }^{- 1}}(15)
Type: SI_UNIT
fricas
r

\label{eq16} \mbox{\rm table} \left({{v ={{m_{\ }^{1}}{s_{\ }^{- 1}}}}, \:{m ={{{m_{\ }^{- 1}}{kg_{\ }^{1}}}{s_{\ }^{- 1}}}}, \:{d ={{m_{\ }^{- 3}}{kg_{\ }^{1}}}}, \:{D ={m_{\ }^{1}}}, \:{L ={m_{\ }^{1}}}, \:{p ={{{m_{\ }^{- 1}}{kg_{\ }^{1}}}{s_{\ }^{- 2}}}}}\right)(16)
Type: Table(Symbol,SI_UNIT)
fricas
buck(r)

\label{eq17}\left[{{D \  d \  v}\over m}, \:{{L \  d \  v}\over m}, \:{p \over{d \ {{v}^{2}}}}\right](17)
Type: List(Expression(Integer))