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

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.02 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.01 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.01 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.13 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:44:21 AM):
; /var/aw/var/LatexWiki/RIA.NRLIB/RIA.fasl written ; compilation finished in 0:00:00.139 ------------------------------------------------------------------------ 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:44:21 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.01 SEC.
compiling exported * : ($,$) -> $ Time: 0 SEC.
compiling exported / : ($,$) -> $ Time: 0 SEC.
compiling exported ^ : ($,Integer) -> $ Time: 0.01 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 SEC.
compiling exported %A : Integer -> $ Time: 0.01 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.01 SEC.
compiling local mkxpr : (List Symbol,Vector Integer) -> Expression Integer Time: 0.05 SEC.
compiling exported buck : Table(Symbol,$) -> List Expression Integer Time: 0.03 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.15 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:44:22 AM):
; /var/aw/var/LatexWiki/SI.NRLIB/SI.fasl written ; compilation finished in 0:00:00.115 ------------------------------------------------------------------------ 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.01 SEC.
compiling exported pqty_tm_toggle : U -> Boolean Time: 0 SEC.
compiling exported coerce : $ -> OutputForm processing macro definition OF ==> OutputForm Time: 0 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:44:22 AM):
; /var/aw/var/LatexWiki/PQTY.NRLIB/PQTY.fasl written ; compilation finished in 0:00:00.060 ------------------------------------------------------------------------ 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.L / (t.T)^2

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

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

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

\label{eq8}\left[{T ={\sqrt{L \over g}}}, \:{T = -{\sqrt{L \over g}}}\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))

New: SI derived

fricas
SI_derived("newton")

\label{eq18}{{m_{\ }^{1}}{kg_{\ }^{1}}}{s_{\ }^{- 2}}(18)
Type: SI_UNIT
fricas
SI_derived("pascal")

\label{eq19}{{m_{\ }^{- 1}}{kg_{\ }^{1}}}{s_{\ }^{- 2}}(19)
Type: SI_UNIT
fricas
SI_derived("joule")

\label{eq20}{{m_{\ }^{2}}{kg_{\ }^{1}}}{s_{\ }^{- 2}}(20)
Type: SI_UNIT
fricas
SI_derived("volt")

\label{eq21}{{{m_{\ }^{2}}{kg_{\ }^{1}}}{s_{\ }^{- 3}}}{A_{\ }^{- 1}}(21)
Type: SI_UNIT
fricas
SI_derived("fard")
>> Error detected within library code: Expected string name of a derived SI unit.

New: PQTY ELT

fricas
volume := 3.2 %m(3)

\label{eq22}{{3.2}\mbox{\rm ��}{0.0}}{\ }{m_{\ }^{3}}(22)
Type: PhysQty?(SI_UNIT)
fricas
mass := 16.7 %kg(1)

\label{eq23}{{16.7}\mbox{\rm ��}{0.0}}{\ }{kg_{\ }^{1}}(23)
Type: PhysQty?(SI_UNIT)
fricas
pressure :=  pressure := 999.9 SI_derived("pascal")

\label{eq24}{{999.9}\mbox{\rm ��}{0.0}}{\ }{{{m_{\ }^{- 1}}{kg_{\ }^{1}}}{s_{\ }^{- 2}}}(24)
Type: PhysQty?(SI_UNIT)
fricas
temp := temp := -200 %K(1)

\label{eq25}{-{200.0}\mbox{\rm ��}{0.0}}{\ }{K_{\ }^{1}}(25)
Type: PhysQty?(SI_UNIT)
fricas
rho := mass/volume

\label{eq26}{{5.21875}\mbox{\rm ��}{0.0}}{\ }{{m_{\ }^{- 3}}{kg_{\ }^{1}}}(26)
Type: PhysQty?(SI_UNIT)

Test internals:

fricas
pqty_value(rho)

\label{eq27}{167}\over{32}(27)
Type: Fraction(Integer)
fricas
pqty_error(rho)

\label{eq28}0(28)
Type: Fraction(Integer)
fricas
pqty_unit(rho)

\label{eq29}{m_{\ }^{- 3}}{kg_{\ }^{1}}(29)
Type: SI_UNIT
fricas
pqty_interval(rho)

\label{eq30}[{{167}\over{32}},{{167}\over{32}}](30)
Type: Q_INTERVAL

Test errors:

fricas
area:= pqty(2,2/10,%m(2))

\label{eq31}{{2.0}\mbox{\rm ��}{0.2}}{\ }{m_{\ }^{2}}(31)
Type: PhysQty?(SI_UNIT)
fricas
height:= pqty(12/10,3/10,%m(1))

\label{eq32}{{1.2}\mbox{\rm ��}{0.3}}{\ }{m_{\ }^{1}}(32)
Type: PhysQty?(SI_UNIT)
fricas
vol :=  area * height

\label{eq33}{{2.46}\mbox{\rm ��}{0.84}}{\ }{m_{\ }^{3}}(33)
Type: PhysQty?(SI_UNIT)
fricas
pqty_interval(vol)

\label{eq34}[{{81}\over{50}},{{33}\over{10}}](34)
Type: Q_INTERVAL
fricas
pqty_error(vol)

\label{eq35}{21}\over{25}(35)
Type: Fraction(Integer)

Unit to list (si2l)

fricas
si2l(SI_derived("siemens"))

\label{eq36}\left[ - 2, \: - 1, \: 3, \: 2, \: 0, \: 0, \: 0 \right](36)
Type: List(Integer)
fricas
si2l(%m(1)/%s(1))

\label{eq37}\left[ 1, \: 0, \: - 1, \: 0, \: 0, \: 0, \: 0 \right](37)
Type: List(Integer)

ok.




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