Chapter 9.83-91: Some Examples of Domains and Packages
+9.83 UnivariatePolynomial
+9.84 UniversalSegment
+9.85 Vector
+9.86 Void
+9.87 WuWenTsunTriangularSet
+9.88 XPBWPolynomial
+9.89 XPolynomial
+9.90 XPolynomialRing
+9.91 ZeroDimensionalSolvePackage
+
+
\ No newline at end of file
diff --git a/src/axiom-website/hyperdoc/axbook/graphicstyle.css b/src/axiom-website/hyperdoc/axbook/graphicstyle.css
new file mode 100644
index 0000000..c682243
--- /dev/null
+++ b/src/axiom-website/hyperdoc/axbook/graphicstyle.css
@@ -0,0 +1,114 @@
+body { background-color: #FFFF66 }
+html {
+ background-color: #FFFF66;
+ }
+div.spadcommand, div.spadgraph
+ {
+ display: block;
+ font-size: large;
+ color: black;
+ padding: 5pt 10pt;
+ border: inset 1pt;
+ border-color: silver;
+ margin-top: 1em;
+ margin-bottom: 1em;
+}
+form { display: inline;}
+input.command {
+ display: inline;
+ font-size: 12pt;
+ padding: 5pt 10pt;
+ border: inset 1pt;
+ border-color: silver;
+ margin-top: 1em;
+ margin-bottom: 1em;
+}
+input.restore {
+ display: inline;
+ margin-bottom: 1em;
+}
+div.axerror {text-align: center; font-family: monospace; font-size: 12pt;}
+div.mathbox {border: solid; border: outset 1pt; border-color: silver;
+ padding: 2pt;}
+div.boxed {
+ text-align: left;
+}
+div.boxed2 {
+ display: block;
+ padding: 2em;
+ border: solid 2pt;
+ width: 60%;
+ text-align: center;
+ margin-top: 1em;
+ margin-left: auto; margin-right: auto;
+}
+div.center {
+ padding-top: 10px; padding-bottom: 10px;
+ }
+div.returnType {
+ margin-top: 1em;
+ margin-bottom: 1em;
+ text-align: center;
+}
+div.quote { border: solid 1pt; margin-left: 10%; margin-right: 10%;
+ padding: 1em;
+}
+div.quotation {text-align: left; margin-left: 15%; margin-right: 15%;}
+div.person {margin-top: 1em;}
+div.item {margin-top: 1em;}
+div.centerline {text-align: center; margin-top: 1em; margin-bottom: 1em;}
+div.image {text-align: center;}
+div.figcaption {text-align: center;}
+span.index {
+ visibility: hidden;
+}
+span.commSav {visibility: hidden;}
+dt {
+ font-weight: bold;
+ padding: 1em;
+ }
+span.index {
+ display: none;
+}
+span.funArgs {font-style: italic; font-weight: normal;}
+span.argDef {font-weight: bold;}
+span.hspace75pc {margin-left: 1em;}
+span.hspace200pc {margin-left: 2em;}
+span.hspace300pc {margin-left: 3em;}
+span.hspace600pc {margin-left: 6em;}
+span.teletype {font-family: monospace; font-size: 12pt;}
+span.aliascon {font-family: monospace; font-size: 12pt;}
+span.italic {font-style: italic;}
+span.slant {font-style: italic;}
+span.bold {font-weight: bold;}
+span.em {font-weight: bold;}
+span.spadfunFrom {font-weight: bold;}
+span.spadopFrom {font-weight: bold;}
+table.begintabular {
+ margin-top: 1em;
+ text-align: left;
+}
+table.begintabular td {padding-left: 1em; vertical-align: top;}
+table.image {padding-left: 100px;}
+span.verbatim {
+ padding: 0em 0em 0em 2em;
+}
+div.verbatim {
+ padding: 0em 0em 0em 2em; margin-bottom: 1em;
+ font-family: monospace; font-size: 10pt;
+}
+div.math { text-align: center; padding: 20pt;}
+div.math math {
+ border: none;
+ padding: 0em 0em;
+ margin-top: 0pt;
+}
+div.math table tr td { }
+div.math table {margin-left: auto; margin-right: auto; }
+div#verbatimtable2 td {padding-left: 1em; padding-right: 1em;}
+div#verbatimtable1 td {padding-left: 1em; padding-right: 1em;}
+div#verbatimtable3 td {padding-left: 1em; padding-right: 1em;}
+table.category-domain-package tr td:first-child {color: blue;
+ vertical-align: top;}
+a.subseccontents {padding-left: 2em;}
+a.subsubseccontents {padding-left: 4em;}
\ No newline at end of file
diff --git a/src/axiom-website/hyperdoc/axbook/graphicstyle.diff b/src/axiom-website/hyperdoc/axbook/graphicstyle.diff
new file mode 100644
index 0000000..256dc8e
--- /dev/null
+++ b/src/axiom-website/hyperdoc/axbook/graphicstyle.diff
@@ -0,0 +1,7 @@
+--- /tmp/axbook/graphicstyle.css 2007-10-08 16:32:42.000000000 -0400
++++ graphicstyle.css 2007-10-03 17:09:41.000000000 -0400
+@@ -1,3 +1,4 @@
++body { background-color: #FFFF66 }
+ div.spadcommand, div.spadgraph
+ {
+ display: block;
diff --git a/src/axiom-website/hyperdoc/axbook/hrefs.txt b/src/axiom-website/hyperdoc/axbook/hrefs.txt
new file mode 100644
index 0000000..37be753
--- /dev/null
+++ b/src/axiom-website/hyperdoc/axbook/hrefs.txt
@@ -0,0 +1,499 @@
+This is a list of all hrefs, i.e. fig-intro-br section-0.1.xhtml
+ugHyper section-1.1.xhtml
+ugTypes section-1.3.xhtml
+ugLangAssign section-1.3.xhtml
+ugTypesConvert section-1.3.xhtml
+ugUserMacros section-1.3.xhtml
+ugInOutIn section-1.3.xhtml
+ugLangBlocks section-1.3.xhtml
+ugxProblemFinitePrime section-1.4.xhtml
+ListXmpPage section-1.5.xhtml
+OneDimensionalArrayXmpPage section-1.5.xhtml
+FlexibleArrayXmpPage section-1.5.xhtml
+HeapXmpPage section-1.5.xhtml
+BinarySearchTreeXmpPage section-1.5.xhtml
+SetXmpPage section-1.5.xhtml
+MultiSetXmpPage section-1.5.xhtml
+ugTypesRecords section-1.5.xhtml
+ugTypesUnions section-1.5.xhtml
+ugDomains section-1.5.xhtml
+ugProblemEigen section-1.6.xhtml
+ugProblemLinPolEqn section-1.6.xhtml
+ugLangIts section-1.6.xhtml
+ugUser section-1.7.xhtml
+ugInOutIn section-1.7.xhtml
+ugProblemLimits section-1.9.xhtml
+ugProblemSeries section-1.10.xhtml
+ugProblemIntegration section-1.12.xhtml
+ugProblemNumeric section-1.16.xhtml
+ugAppGraphics section-1.16.xhtml
+ugGraph section-1.16.xhtml
+ugCategories section-2.1.xhtml
+ugTypesConvert section-2.1.xhtml
+ugTypesBasic section-2.2.xhtml
+ugTypesDeclare section-2.2.xhtml
+ugTypesConvert section-2.2.xhtml
+ugTypesPkgCall section-2.2.xhtml
+ugTypesPkgCall section-2.2.xhtml
+ugTypesDeclare section-2.2.xhtml
+ugTypesConvert section-2.2.xhtml
+ugSysCmdwhat section-2.2.xhtml
+ugIntroAssign section-2.3.xhtml
+ugLangAssign section-2.3.xhtml
+ugUserDeclare section-2.3.xhtml
+ugTypesConvert section-2.3.xhtml
+ugTypesRecords section-2.5.xhtml
+ugTypesUnionsWOSel section-2.5.xhtml
+ugTypesBasic section-2.7.xhtml
+ugTypesDeclare section-2.9.xhtml
+ugUserUse section-2.9.xhtml
+ugTypesPkgCall section-2.11.xhtml
+ugUserTriangle section-2.11.xhtml
+ugSysCmdframe section-2.11.xhtml
+ugBrowse section-2.12.xhtml
+Complex section-2.12.xhtml
+ugUserDeclare section-2.12.xhtml
+ugHyperScroll section-3.2.xhtml
+ugHyperInput section-3.2.xhtml
+ugHyperInput section-3.3.xhtml
+ugLangBlocks section-4.1.xhtml
+ugUserDelay section-5.1.xhtml
+ugLangIf section-5.2.xhtml
+ugTypesResolve section-5.3.xhtml
+ugTypesPkgCall section-5.3.xhtml
+ugUserCompInt section-5.4.xhtml
+ugUserBlocks section-5.4.xhtml
+ugLangLoopsReturn section-5.4.xhtml
+ugLangLoopsForIn section-5.4.xhtml
+SegmentXmpPage section-5.4.xhtml
+ugLangLoopsForInPred section-5.4.xhtml
+ugLangLoops section-5.5.xhtml
+ListXmpPage section-5.5.xhtml
+StreamXmpPage section-5.5.xhtml
+ugUserAnon section-6.1.xhtml
+ExitXmpPage section-6.1.xhtml
+VoidXmpPage section-6.1.xhtml
+ugTypesPkgCall section-6.3.xhtml
+ugUserAnon section-6.3.xhtml
+ugTypesDeclare section-6.4.xhtml
+ugTypesDeclare section-6.4.xhtml
+ugCategories section-6.6.xhtml
+MappingPackage1XmpPage section-6.7.xhtml
+ugPackagesAbstract section-6.7.xhtml
+ugPackages section-6.7.xhtml
+ugCategories section-6.7.xhtml
+ugLangAssign section-6.8.xhtml
+ugTypesPkgCall section-6.9.xhtml
+ugTypesResolve section-6.9.xhtml
+ugTypesSubdomains section-6.10.xhtml
+ugUserPieceBasic section-6.11.xhtml
+ugLangIts section-6.11.xhtml
+ugUserFreeLocal section-6.12.xhtml
+ugUserFreeLocal section-6.13.xhtml
+ugUserCache section-6.13.xhtml
+MakeFunctionXmpPage section-6.14.xhtml
+ugLangBlocks section-6.15.xhtml
+ugUserCache section-6.16.xhtml
+ugUserRecur section-6.16.xhtml
+ugTypesExpose section-6.19.xhtml
+ugGraphTwoDOptions section-7.1.xhtml
+ugGraphThreeDOptions section-7.1.xhtml
+ugGraphTwoDOptions section-7.1.xhtml
+ugGraphColor section-7.1.xhtml
+ugGraphColorPalette section-7.1.xhtml
+ugGraphColor section-7.1.xhtml
+ugGraphColorPalette section-7.1.xhtml
+ugGraphCoord section-7.1.xhtml
+ugGraphThreeDOptions section-7.2.xhtml
+ugGraphThreeDOptions section-7.2.xhtml
+ugGraphThreeDOptions section-7.2.xhtml
+ugGraphCoord section-7.2.xhtml
+ugGraphCoord section-7.2.xhtml
+ugIntro section-8.1.xhtml
+FloatXmpPage section-8.1.xhtml
+DoubleFloatXmpPage section-8.1.xhtml
+ugProblemFinite section-8.2.xhtml
+ugxProblemOnePol section-8.3.xhtml
+ugxProblemPolSys section-8.3.xhtml
+ugxProblemOnePol section-8.3.xhtml
+ugProblemDEQ section-8.5.xhtml
+ugxProblemOnePol section-8.5.xhtml
+ugxProblemSymRootAll section-8.8.xhtml
+ugxProblemDEQSeries section-8.9.xhtml
+ugxProblemSeriesConversions section-8.9.xhtml
+ugTypesDeclare section-8.9.xhtml
+ugxProblemSeriesFunctions section-8.9.xhtml
+ugxProblemSeriesFormula section-8.9.xhtml
+ugxProblemSeriesConversions section-8.9.xhtml
+ugUserAnon section-8.9.xhtml
+ugxProblemSeriesConversions section-8.9.xhtml
+ugProblemLinPolEqn section-8.10.xhtml
+ugTypesPkgCall section-8.11.xhtml
+ugxProblemFiniteExtensionFinite section-8.11.xhtml
+ugxProblemFiniteUtility section-8.11.xhtml
+ugxProblemFiniteUtility section-8.11.xhtml
+ugxProblemFiniteUtility section-8.11.xhtml
+ugxProblemFiniteExtensionFinite section-8.11.xhtml
+TableXmpPage section-9.1.xhtml
+ListXmpPage section-9.1.xhtml
+ExpressionXmpPage section-9.3.xhtml
+KernelXmpPage section-9.3.xhtml
+ugProblemDEQPage section-9.3.xhtml
+ugProblemDEQNumber section-9.3.xhtml
+DecimalExpansionXmpPage section-9.4.xhtml
+HexadecimalExpansionXmpPage section-9.4.xhtml
+RadixExpansionXmpPage section-9.4.xhtml
+CharacterClassXmpPage section-9.8.xhtml
+StringXmpPage section-9.8.xhtml
+CharacterXmpPage section-9.9.xhtml
+StringXmpPage section-9.9.xhtml
+ComplexXmpPage section-9.10.xhtml
+QuaternionXmpPage section-9.10.xhtml
+ugProblemNumeric section-9.11.xhtml
+ugTypesConvertPage section-9.11.xhtml
+ugTypesConvertNumber section-9.11.xhtml
+StreamXmpPage section-9.12.xhtml
+OperatorXmpPage section-9.14.xhtml
+BinaryExpansionXmpPage section-9.15.xhtml
+HexadecimalExpansionXmpPage section-9.15.xhtml
+RadixExpansionXmpPage section-9.15.xhtml
+ugIntroVariablesPage section-9.16.xhtml
+ugIntroVariablesNumber section-9.16.xhtml
+ugTypesConvertPage section-9.16.xhtml
+ugTypesConvertNumber section-9.16.xhtml
+PolynomialXmpPage section-9.16.xhtml
+UnivariatePolynomialXmpPage section-9.16.xhtml
+MultivariatePolynomialXmpPage section-9.16.xhtml
+ugGraph section-9.17.xhtml
+ugProblemNumeric section-9.17.xhtml
+FloatXmpPage section-9.17.xhtml
+TableXmpPage section-9.18.xhtml
+ugUserPage section-9.20.xhtml
+ugUserNumber section-9.20.xhtml
+VoidXmpPage section-9.20.xhtml
+KernelXmpPage section-9.21.xhtml
+KernelXmpPage section-9.21.xhtml
+ugIntroCalcDerivPage section-9.21.xhtml
+ugIntroCalcDerivNumber section-9.21.xhtml
+ugIntroCalcLimitsPage section-9.21.xhtml
+ugIntroCalcLimitsNumber section-9.21.xhtml
+ugIntroSeriesPage section-9.21.xhtml
+ugIntroSeriesNumber section-9.21.xhtml
+ugProblemDEQPage section-9.21.xhtml
+ugProblemDEQNumber section-9.21.xhtml
+ugProblemIntegrationPage section-9.21.xhtml
+ugProblemIntegrationNumber section-9.21.xhtml
+ugUserRulesPage section-9.21.xhtml
+ugUserRulesNumber section-9.21.xhtml
+ugTypesPkgCallPage section-9.22.xhtml
+ugTypesPkgCallNumber section-9.22.xhtml
+FactoredFunctionsTwoXmpPage section-9.22.xhtml
+FactoredXmpPage section-9.23.xhtml
+ugProblemGaloisPage section-9.23.xhtml
+ugProblemGaloisNumber section-9.23.xhtml
+TextFileXmpPage section-9.24.xhtml
+KeyedAccessFileXmpPage section-9.24.xhtml
+LibraryXmpPage section-9.24.xhtml
+FileNameXmpPage section-9.24.xhtml
+OneDimensionalArrayXmpPage section-9.26.xhtml
+VectorXmpPage section-9.26.xhtml
+ugGraphPage section-9.27.xhtml
+ugGraphNumber section-9.27.xhtml
+ugProblemNumeric section-9.27.xhtml
+DoubleFloatXmpPage section-9.27.xhtml
+ugTypesConvertPage section-9.27.xhtml
+ugTypesConvertNumber section-9.27.xhtml
+IntegerXmpPage section-9.28.xhtml
+ContinuedFractionXmpPage section-9.28.xhtml
+PartialFractionXmpPage section-9.28.xhtml
+ugTypesConvertPage section-9.28.xhtml
+PartialFractionXmpPage section-9.29.xhtml
+TableXmpPage section-9.30.xhtml
+FlexibleArrayXmpPage section-9.32.xhtml
+DecimalExpansionXmpPage section-9.33.xhtml
+BinaryExpansionXmpPage section-9.33.xhtml
+RadixExpansionXmpPage section-9.33.xhtml
+ugIntroNumbersPage section-9.34.xhtml
+ugIntroNumbersNumber section-9.34.xhtml
+IntegerNumberTheoryFunctionsXmpPage section-9.34.xhtml
+DecimalExpansionXmpPage section-9.34.xhtml
+BinaryExpansionXmpPage section-9.34.xhtml
+HexadecimalExpansionXmpPage section-9.34.xhtml
+RadixExpansionXmpPage section-9.34.xhtml
+FractionXmpPage section-9.34.xhtml
+ugTypesUnionsPage section-9.34.xhtml
+ugTypesUnionsNumber section-9.34.xhtml
+ugTypesRecords section-9.34.xhtml
+FactoredXmpPage section-9.34.xhtml
+ComplexXmpPage section-9.34.xhtml
+IntegerNumberTheoryFunctionsXmpPage section-9.34.xhtml
+BasicOperatorXmpPage section-9.37.xhtml
+ExpressionXmpPage section-9.37.xhtml
+ExpressionXmpPage section-9.37.xhtml
+FileXmpPage section-9.38.xhtml
+TextFileXmpPage section-9.38.xhtml
+LibraryXmpPage section-9.38.xhtml
+FileXmpPage section-9.41.xhtml
+TextFileXmpPage section-9.41.xhtml
+KeyedAccessFileXmpPage section-9.41.xhtml
+StreamXmpPage section-9.47.xhtml
+ugUserMakePage section-9.50.xhtml
+ugUserMakeNumber section-9.50.xhtml
+ugIntroTwoDimPage section-9.52.xhtml
+ugIntroTwoDimNumber section-9.52.xhtml
+ugProblemEigenPage section-9.52.xhtml
+ugProblemEigenNumber section-9.52.xhtml
+ugxFloatHilbertPage section-9.52.xhtml
+ugxFloatHilbertNumber section-9.52.xhtml
+PermanentXmpPage section-9.52.xhtml
+VectorXmpPage section-9.52.xhtml
+OneDimensionalArrayXmpPage section-9.52.xhtml
+TwoDimensionalArrayXmpPage section-9.52.xhtml
+PolynomialXmpPage section-9.54.xhtml
+UnivariatePolynomialXmpPage section-9.54.xhtml
+DistributedMultivariatePolynomialXmpPage section-9.54.xhtml
+QuaternionXmpPage section-9.56.xhtml
+VectorXmpPage section-9.57.xhtml
+FlexibleArrayXmpPage section-9.57.xhtml
+ComplexXmpPage section-9.61.xhtml
+FactoredXmpPage section-9.61.xhtml
+FullPartialFractionExpansionXmpPage section-9.61.xhtml
+DistributedMultivariatePolynomialXmpPage section-9.63.xhtml
+FactoredXmpPage section-9.63.xhtml
+ugProblemFactorPage section-9.63.xhtml
+ugProblemFactorNumber section-9.63.xhtml
+UnivariatePolynomialXmpPage section-9.63.xhtml
+MultivariatePolynomialXmpPage section-9.63.xhtml
+DistributedMultivariatePolynomialXmpPage section-9.63.xhtml
+ComplexXmpPage section-9.64.xhtml
+OctonionXmpPage section-9.64.xhtml
+DecimalExpansionXmpPage section-9.65.xhtml
+BinaryExpansionXmpPage section-9.65.xhtml
+HexadecimalExpansionXmpPage section-9.65.xhtml
+SegmentBindingXmpPage section-9.69.xhtml
+UniversalSegmentXmpPage section-9.69.xhtml
+SegmentXmpPage section-9.70.xhtml
+UniversalSegmentXmpPage section-9.70.xhtml
+ListXmpPage section-9.71.xhtml
+ugTypesDeclarePage section-9.72.xhtml
+ugTypesDeclareNumber section-9.72.xhtml
+ugTypesPkgCallPage section-9.72.xhtml
+ugTypesPkgCallNumber section-9.72.xhtml
+ugBrowsePage section-9.72.xhtml
+ugBrowseNumber section-9.72.xhtml
+TableXmpPage section-9.73.xhtml
+GeneralSparseTableXmpPage section-9.73.xhtml
+MatrixXmpPage section-9.74.xhtml
+ugTypesWritingModesPage section-9.74.xhtml
+ugTypesWritingModesNumber section-9.74.xhtml
+ugTypesExposePage section-9.74.xhtml
+ugTypesExposeNumber section-9.74.xhtml
+MatrixXmpPage section-9.74.xhtml
+ugLangItsPage section-9.76.xhtml
+ugLangItsNumber section-9.76.xhtml
+ugProblemSeriesPage section-9.76.xhtml
+ugProblemSeriesNumber section-9.76.xhtml
+ContinuedFractionXmpPage section-9.76.xhtml
+ListXmpPage section-9.76.xhtml
+CharacterXmpPage section-9.77.xhtml
+CharacterClassXmpPage section-9.77.xhtml
+TableXmpPage section-9.78.xhtml
+AssociationListXmpPage section-9.80.xhtml
+EqTableXmpPage section-9.80.xhtml
+StringTableXmpPage section-9.80.xhtml
+SparseTableXmpPage section-9.80.xhtml
+KeyedAccessFileXmpPage section-9.80.xhtml
+FileXmpPage section-9.81.xhtml
+KeyedAccessFileXmpPage section-9.81.xhtml
+LibraryXmpPage section-9.81.xhtml
+ugTypesAnyNonePage section-9.82.xhtml
+ugTypesAnyNoneNumber section-9.82.xhtml
+MatrixXmpPage section-9.82.xhtml
+OneDimensionalArrayXmpPage section-9.82.xhtml
+ugProblemFactorPage section-9.83.xhtml
+ugProblemFactorNumber section-9.83.xhtml
+ugIntroVariablesPage section-9.83.xhtml
+ugIntroVariablesNumber section-9.83.xhtml
+ugTypesConvertPage section-9.83.xhtml
+ugTypesConvertNumber section-9.83.xhtml
+PolynomialXmpPage section-9.83.xhtml
+MultivariatePolynomialXmpPage section-9.83.xhtml
+DistributedMultivariatePolynomialXmpPage section-9.83.xhtml
+SegmentXmpPage section-9.84.xhtml
+SegmentBindingXmpPage section-9.84.xhtml
+ListXmpPage section-9.84.xhtml
+StreamXmpPage section-9.84.xhtml
+OneDimensionalArrayXmpPage section-9.85.xhtml
+ListXmpPage section-9.85.xhtml
+MatrixXmpPage section-9.85.xhtml
+OneDimensionalArrayXmpPage section-9.85.xhtml
+SetXmpPage section-9.85.xhtml
+TableXmpPage section-9.85.xhtml
+TwoDimensionalArrayXmpPage section-9.85.xhtml
+ugGraph section-10.1.xhtml
+ugUser section-10.2.xhtml
+ugLangBlocks section-10.2.xhtml
+ugGraph section-10.8.xhtml
+ugUserMake section-10.9.xhtml
+ugIntProg section-11.0.xhtml
+ugIntProg section-11.0.xhtml
+ugIntProg section-11.1.xhtml
+ugTypesWritingAbbr section-11.1.xhtml
+fig-pak-cdraw section-11.1.xhtml
+ugIntProgCompFuns section-11.3.xhtml
+ugTypes section-11.7.xhtml
+ugUserBlocks section-11.7.xhtml
+ugCategoriesAttributes section-11.7.xhtml
+ugUserBlocks section-11.8.xhtml
+ugCategoriesHier section-11.10.xhtml
+ugTypesBasicDomainCons section-12.0.xhtml
+ugTypes section-12.1.xhtml
+ugCategoriesHier section-12.6.xhtml
+ugDomainsAssertions section-12.9.xhtml
+ugPackagesConds section-12.11.xhtml
+ugPackages section-12.12.xhtml
+ugPackagesAbstract section-12.12.xhtml
+ugPackages section-13.1.xhtml
+ugCategoriesCorrectness section-13.3.xhtml
+ugCategoriesConditionals section-13.3.xhtml
+figquadform section-13.6.xhtml
+ugDomainsDemo section-13.6.xhtml
+ugDomainsDemo section-13.6.xhtml
+ugTypesUnions section-13.7.xhtml
+ugDomainsDemo section-13.8.xhtml
+ugPackages section-13.9.xhtml
+ugCategoriesDefaults section-13.9.xhtml
+ugBrowseDomain section-14.1.xhtml
+ugBrowseCapitalizationConvention section-14.1.xhtml
+ugBrowseOptions section-14.1.xhtml
+ugBrowseViewsOfConstructors section-14.1.xhtml
+ugBrowseViewsOfOperations section-14.1.xhtml
+ugBrowseOptions section-14.1.xhtml
+ugBrowseViewsOfOperations section-14.2.xhtml
+ugBrowseOptions section-14.3.xhtml
+ugTypesExpose section-14.3.xhtml
+aspSection section-15.3.xhtml
+aspSection section-15.3.xhtml
+generalFortran section-15.3.xhtml
+nugNagd section-15.3.xhtml
+ugLangLoopsBreak section-15.4.xhtml
+ugLangBlocks section-15.4.xhtml
+ugGraphTwoDbuild section-15.7.xhtml
+ugGraphTwoDappend section-15.7.xhtml
+ugIntroCallFun section-15.7.xhtml
+ugUserRules section-15.7.xhtml
+ugSysCmdset section-16.1.xhtml
+ugSysCmdcd section-16.7.xhtml
+ugSysCmdtrace section-16.7.xhtml
+ugSysCmdframe section-16.13.xhtml
+ugSysCmdcd section-16.13.xhtml
+ugSysCmdcd section-16.13.xhtml
+ugSysCmdabbreviation section-16.16.xhtml
+ugTypesExpose section-16.16.xhtml
+ugInOutIn section-16.20.xhtml
+ugSysCmdcompile section-16.26.xhtml
+ugSysCmdcompile section-16.26.xhtml
+ugBrowse section-17.1.xhtml
+ugBrowse section-18.1.xhtml
+ugBrowse section-19.1.xhtml
+ugFimagesFive section-21.10.xhtml
+
+
+Following are the undefined hrefs. These appear in the above list
+in the href attribute without a section prefix. It would be nice to
+figure out where these are supposed to link to.
+
+fig-intro-br section-0.1.xhtml
+ugSysCmdwhat section-2.2.xhtml
+Complex section-2.12.xhtml
+ExitXmpPage section-6.1.xhtml
+MappingPackage1XmpPage section-6.7.xhtml
+ugProblemDEQPage section-9.3.xhtml
+ugProblemDEQNumber section-9.3.xhtml
+ugTypesConvertPage section-9.11.xhtml
+ugTypesConvertNumber section-9.11.xhtml
+ugIntroVariablesPage section-9.16.xhtml
+ugIntroVariablesNumber section-9.16.xhtml
+ugTypesConvertPage section-9.16.xhtml
+ugTypesConvertNumber section-9.16.xhtml
+ugUserPage section-9.20.xhtml
+ugUserNumber section-9.20.xhtml
+ugIntroCalcDerivPage section-9.21.xhtml
+ugIntroCalcDerivNumber section-9.21.xhtml
+ugIntroCalcLimitsPage section-9.21.xhtml
+ugIntroCalcLimitsNumber section-9.21.xhtml
+ugIntroSeriesPage section-9.21.xhtml
+ugIntroSeriesNumber section-9.21.xhtml
+ugProblemDEQPage section-9.21.xhtml
+ugProblemDEQNumber section-9.21.xhtml
+ugProblemIntegrationPage section-9.21.xhtml
+ugProblemIntegrationNumber section-9.21.xhtml
+ugUserRulesPage section-9.21.xhtml
+ugUserRulesNumber section-9.21.xhtml
+ugTypesPkgCallPage section-9.22.xhtml
+ugTypesPkgCallNumber section-9.22.xhtml
+FactoredFunctionsTwoXmpPage section-9.22.xhtml
+ugProblemGaloisPage section-9.23.xhtml
+ugProblemGaloisNumber section-9.23.xhtml
+ugGraphPage section-9.27.xhtml
+ugGraphNumber section-9.27.xhtml
+ugTypesConvertPage section-9.27.xhtml
+ugTypesConvertNumber section-9.27.xhtml
+ugTypesConvertPage section-9.28.xhtml
+ugIntroNumbersPage section-9.34.xhtml
+ugIntroNumbersNumber section-9.34.xhtml
+ugTypesUnionsPage section-9.34.xhtml
+ugTypesUnionsNumber section-9.34.xhtml
+ugUserMakePage section-9.50.xhtml
+ugUserMakeNumber section-9.50.xhtml
+ugIntroTwoDimPage section-9.52.xhtml
+ugIntroTwoDimNumber section-9.52.xhtml
+ugProblemEigenPage section-9.52.xhtml
+ugProblemEigenNumber section-9.52.xhtml
+ugxFloatHilbertPage section-9.52.xhtml
+ugxFloatHilbertNumber section-9.52.xhtml
+ugProblemFactorPage section-9.63.xhtml
+ugProblemFactorNumber section-9.63.xhtml
+ugTypesDeclarePage section-9.72.xhtml
+ugTypesDeclareNumber section-9.72.xhtml
+ugTypesPkgCallPage section-9.72.xhtml
+ugTypesPkgCallNumber section-9.72.xhtml
+ugBrowsePage section-9.72.xhtml
+ugBrowseNumber section-9.72.xhtml
+ugTypesWritingModesPage section-9.74.xhtml
+ugTypesWritingModesNumber section-9.74.xhtml
+ugTypesExposePage section-9.74.xhtml
+ugTypesExposeNumber section-9.74.xhtml
+ugLangItsPage section-9.76.xhtml
+ugLangItsNumber section-9.76.xhtml
+ugProblemSeriesPage section-9.76.xhtml
+ugProblemSeriesNumber section-9.76.xhtml
+ContinuedFractionXmpPage section-9.76.xhtml
+ugTypesAnyNonePage section-9.82.xhtml
+ugTypesAnyNoneNumber section-9.82.xhtml
+ugProblemFactorPage section-9.83.xhtml
+ugProblemFactorNumber section-9.83.xhtml
+ugIntroVariablesPage section-9.83.xhtml
+ugIntroVariablesNumber section-9.83.xhtml
+ugTypesConvertPage section-9.83.xhtml
+ugTypesConvertNumber section-9.83.xhtml
+fig-pak-cdraw section-11.1.xhtml
+aspSection section-15.3.xhtml
+aspSection section-15.3.xhtml
+generalFortran section-15.3.xhtml
+nugNagd section-15.3.xhtml
+ugSysCmdset section-16.1.xhtml
+ugSysCmdcd section-16.7.xhtml
+ugSysCmdtrace section-16.7.xhtml
+ugSysCmdcd section-16.13.xhtml
+ugSysCmdcd section-16.13.xhtml
+ugSysCmdabbreviation section-16.16.xhtml
+ugSysCmdcompile section-16.26.xhtml
+ugSysCmdcompile section-16.26.xhtml
diff --git a/src/axiom-website/hyperdoc/axbook/ps/23DColA.png b/src/axiom-website/hyperdoc/axbook/ps/23DColA.png
new file mode 100644
index 0000000..6f1528a
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/23DColA.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/23DColB.png b/src/axiom-website/hyperdoc/axbook/ps/23DColB.png
new file mode 100644
index 0000000..6f1528a
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/23DColB.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/23DPal.png b/src/axiom-website/hyperdoc/axbook/ps/23DPal.png
new file mode 100644
index 0000000..6f1528a
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/23DPal.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/2D1VarA.png b/src/axiom-website/hyperdoc/axbook/ps/2D1VarA.png
new file mode 100644
index 0000000..ae8de0c
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/2D1VarA.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/2D1VarB.png b/src/axiom-website/hyperdoc/axbook/ps/2D1VarB.png
new file mode 100644
index 0000000..e3e8f0b
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/2D1VarB.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/2DOptAd.png b/src/axiom-website/hyperdoc/axbook/ps/2DOptAd.png
new file mode 100644
index 0000000..d313bab
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/2DOptAd.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/2DOptCp.png b/src/axiom-website/hyperdoc/axbook/ps/2DOptCp.png
new file mode 100644
index 0000000..9b108b8
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/2DOptCp.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/2DOptCvC.png b/src/axiom-website/hyperdoc/axbook/ps/2DOptCvC.png
new file mode 100644
index 0000000..21ec048
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/2DOptCvC.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/2DOptPlr.png b/src/axiom-website/hyperdoc/axbook/ps/2DOptPlr.png
new file mode 100644
index 0000000..1b0d264
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/2DOptPlr.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/2DOptPtC.png b/src/axiom-website/hyperdoc/axbook/ps/2DOptPtC.png
new file mode 100644
index 0000000..21ec048
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/2DOptPtC.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/2Dcos.png b/src/axiom-website/hyperdoc/axbook/ps/2Dcos.png
new file mode 100644
index 0000000..cc4ae62
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/2Dcos.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/2Dctrl.png b/src/axiom-website/hyperdoc/axbook/ps/2Dctrl.png
new file mode 100644
index 0000000..598e93e
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/2Dctrl.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/2DppcA.png b/src/axiom-website/hyperdoc/axbook/ps/2DppcA.png
new file mode 100644
index 0000000..4f68832
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/2DppcA.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/2DppcE.png b/src/axiom-website/hyperdoc/axbook/ps/2DppcE.png
new file mode 100644
index 0000000..47ab958
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/2DppcE.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/2Dsin.png b/src/axiom-website/hyperdoc/axbook/ps/2Dsin.png
new file mode 100644
index 0000000..1abfedb
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/2Dsin.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/2Dsincos.png b/src/axiom-website/hyperdoc/axbook/ps/2Dsincos.png
new file mode 100644
index 0000000..d2732cf
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/2Dsincos.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/3D2VarA.png b/src/axiom-website/hyperdoc/axbook/ps/3D2VarA.png
new file mode 100644
index 0000000..0faf8e9
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/3D2VarA.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/3D2VarB.png b/src/axiom-website/hyperdoc/axbook/ps/3D2VarB.png
new file mode 100644
index 0000000..6d2e8ae
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/3D2VarB.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/3DBuildA.png b/src/axiom-website/hyperdoc/axbook/ps/3DBuildA.png
new file mode 100644
index 0000000..bc9a82f
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/3DBuildA.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/3DBuildB.png b/src/axiom-website/hyperdoc/axbook/ps/3DBuildB.png
new file mode 100644
index 0000000..2fa6774
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/3DBuildB.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/3DOptCf1.png b/src/axiom-website/hyperdoc/axbook/ps/3DOptCf1.png
new file mode 100644
index 0000000..fe97001
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/3DOptCf1.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/3DOptCf2.png b/src/axiom-website/hyperdoc/axbook/ps/3DOptCf2.png
new file mode 100644
index 0000000..5410ee5
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/3DOptCf2.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/3DOptCf3.png b/src/axiom-website/hyperdoc/axbook/ps/3DOptCf3.png
new file mode 100644
index 0000000..0985233
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/3DOptCf3.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/3DOptCrd.png b/src/axiom-website/hyperdoc/axbook/ps/3DOptCrd.png
new file mode 100644
index 0000000..d75662f
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/3DOptCrd.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/3DOptPts.png b/src/axiom-website/hyperdoc/axbook/ps/3DOptPts.png
new file mode 100644
index 0000000..4a0776a
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/3DOptPts.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/3DOptRad.png b/src/axiom-website/hyperdoc/axbook/ps/3DOptRad.png
new file mode 100644
index 0000000..4a254b9
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/3DOptRad.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/3DOptSty.png b/src/axiom-website/hyperdoc/axbook/ps/3DOptSty.png
new file mode 100644
index 0000000..6aa99b1
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/3DOptSty.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/3DOptTtl.png b/src/axiom-website/hyperdoc/axbook/ps/3DOptTtl.png
new file mode 100644
index 0000000..1dc3ccd
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/3DOptTtl.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/3DOptvB.png b/src/axiom-website/hyperdoc/axbook/ps/3DOptvB.png
new file mode 100644
index 0000000..97eb310
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/3DOptvB.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/3Dctrl.png b/src/axiom-website/hyperdoc/axbook/ps/3Dctrl.png
new file mode 100644
index 0000000..463c6ec
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/3Dctrl.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/3Dgamma11.png b/src/axiom-website/hyperdoc/axbook/ps/3Dgamma11.png
new file mode 100644
index 0000000..5104953
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/3Dgamma11.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/3Dlight.png b/src/axiom-website/hyperdoc/axbook/ps/3Dlight.png
new file mode 100644
index 0000000..737ca19
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/3Dlight.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/3Dmult1A.png b/src/axiom-website/hyperdoc/axbook/ps/3Dmult1A.png
new file mode 100644
index 0000000..a2253f6
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/3Dmult1A.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/3Dmult1B.png b/src/axiom-website/hyperdoc/axbook/ps/3Dmult1B.png
new file mode 100644
index 0000000..c0922c5
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/3Dmult1B.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/3DpsA.png b/src/axiom-website/hyperdoc/axbook/ps/3DpsA.png
new file mode 100644
index 0000000..70bafe7
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/3DpsA.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/3DpsB.png b/src/axiom-website/hyperdoc/axbook/ps/3DpsB.png
new file mode 100644
index 0000000..ec5a662
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/3DpsB.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/3DpscA.png b/src/axiom-website/hyperdoc/axbook/ps/3DpscA.png
new file mode 100644
index 0000000..41b186a
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/3DpscA.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/3DpscB.png b/src/axiom-website/hyperdoc/axbook/ps/3DpscB.png
new file mode 100644
index 0000000..52aedfb
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/3DpscB.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/3Dvolume.png b/src/axiom-website/hyperdoc/axbook/ps/3Dvolume.png
new file mode 100644
index 0000000..9bdc0ad
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/3Dvolume.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/P28a.png b/src/axiom-website/hyperdoc/axbook/ps/P28a.png
new file mode 100644
index 0000000..ec61f58
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/P28a.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/P28b.png b/src/axiom-website/hyperdoc/axbook/ps/P28b.png
new file mode 100644
index 0000000..f45eb57
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/P28b.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/arrow.png b/src/axiom-website/hyperdoc/axbook/ps/arrow.png
new file mode 100644
index 0000000..a864d8d
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/arrow.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/arrowr.png b/src/axiom-website/hyperdoc/axbook/ps/arrowr.png
new file mode 100644
index 0000000..a0dbb07
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/arrowr.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/atan-1.png b/src/axiom-website/hyperdoc/axbook/ps/atan-1.png
new file mode 100644
index 0000000..fea6589
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/atan-1.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/axiomFront.png b/src/axiom-website/hyperdoc/axbook/ps/axiomFront.png
new file mode 100644
index 0000000..17dba30
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/axiomFront.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/basic2d.png b/src/axiom-website/hyperdoc/axbook/ps/basic2d.png
new file mode 100644
index 0000000..d9f6b6b
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/basic2d.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/bessel.png b/src/axiom-website/hyperdoc/axbook/ps/bessel.png
new file mode 100644
index 0000000..d0164a6
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/bessel.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/bessintr.png b/src/axiom-website/hyperdoc/axbook/ps/bessintr.png
new file mode 100644
index 0000000..2a9b6c1
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/bessintr.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/bluebayou.png b/src/axiom-website/hyperdoc/axbook/ps/bluebayou.png
new file mode 100644
index 0000000..0827019
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/bluebayou.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/bouquet.png b/src/axiom-website/hyperdoc/axbook/ps/bouquet.png
new file mode 100644
index 0000000..d6acd55
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/bouquet.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/cartcoord.png b/src/axiom-website/hyperdoc/axbook/ps/cartcoord.png
new file mode 100644
index 0000000..09adca2
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/cartcoord.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/clipGamma.png b/src/axiom-website/hyperdoc/axbook/ps/clipGamma.png
new file mode 100644
index 0000000..c086f4c
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/clipGamma.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/compatan.png b/src/axiom-website/hyperdoc/axbook/ps/compatan.png
new file mode 100644
index 0000000..98303a0
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/compatan.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/compexp.png b/src/axiom-website/hyperdoc/axbook/ps/compexp.png
new file mode 100644
index 0000000..7a4216a
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/compexp.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/compgamm.png b/src/axiom-website/hyperdoc/axbook/ps/compgamm.png
new file mode 100644
index 0000000..7167baf
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/compgamm.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/complexExp.png b/src/axiom-website/hyperdoc/axbook/ps/complexExp.png
new file mode 100644
index 0000000..190672d
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/complexExp.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/complexRoot.png b/src/axiom-website/hyperdoc/axbook/ps/complexRoot.png
new file mode 100644
index 0000000..079cc86
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/complexRoot.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/cylCoord.png b/src/axiom-website/hyperdoc/axbook/ps/cylCoord.png
new file mode 100644
index 0000000..4131426
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/cylCoord.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/defcoord.png b/src/axiom-website/hyperdoc/axbook/ps/defcoord.png
new file mode 100644
index 0000000..d1d9ac7
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/defcoord.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/exit.png b/src/axiom-website/hyperdoc/axbook/ps/exit.png
new file mode 100644
index 0000000..3307b8c
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/exit.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-alldoms.png b/src/axiom-website/hyperdoc/axbook/ps/h-alldoms.png
new file mode 100644
index 0000000..29a2d5d
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-alldoms.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-allrank.png b/src/axiom-website/hyperdoc/axbook/ps/h-allrank.png
new file mode 100644
index 0000000..2dd9896
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-allrank.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-atsearch.png b/src/axiom-website/hyperdoc/axbook/ps/h-atsearch.png
new file mode 100644
index 0000000..3e11f4d
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-atsearch.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-brfront.png b/src/axiom-website/hyperdoc/axbook/ps/h-brfront.png
new file mode 100644
index 0000000..b6a8c38
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-brfront.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-browse.png b/src/axiom-website/hyperdoc/axbook/ps/h-browse.png
new file mode 100644
index 0000000..11ff5de
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-browse.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-comsearch.png b/src/axiom-website/hyperdoc/axbook/ps/h-comsearch.png
new file mode 100644
index 0000000..39fe30b
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-comsearch.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-condition.png b/src/axiom-website/hyperdoc/axbook/ps/h-condition.png
new file mode 100644
index 0000000..353c6a3
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-condition.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-consearch.png b/src/axiom-website/hyperdoc/axbook/ps/h-consearch.png
new file mode 100644
index 0000000..8619782
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-consearch.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-consearch2.png b/src/axiom-website/hyperdoc/axbook/ps/h-consearch2.png
new file mode 100644
index 0000000..7fcda52
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-consearch2.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-crossref.png b/src/axiom-website/hyperdoc/axbook/ps/h-crossref.png
new file mode 100644
index 0000000..aab04f1
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-crossref.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-docsearch.png b/src/axiom-website/hyperdoc/axbook/ps/h-docsearch.png
new file mode 100644
index 0000000..8c1e07d
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-docsearch.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-gensearch.png b/src/axiom-website/hyperdoc/axbook/ps/h-gensearch.png
new file mode 100644
index 0000000..4a38e65
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-gensearch.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-inverse.png b/src/axiom-website/hyperdoc/axbook/ps/h-inverse.png
new file mode 100644
index 0000000..a1a109b
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-inverse.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-matargs.png b/src/axiom-website/hyperdoc/axbook/ps/h-matargs.png
new file mode 100644
index 0000000..fac6516
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-matargs.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-matats.png b/src/axiom-website/hyperdoc/axbook/ps/h-matats.png
new file mode 100644
index 0000000..430665d
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-matats.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-matdesc.png b/src/axiom-website/hyperdoc/axbook/ps/h-matdesc.png
new file mode 100644
index 0000000..5a225b7
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-matdesc.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-matexamp.png b/src/axiom-website/hyperdoc/axbook/ps/h-matexamp.png
new file mode 100644
index 0000000..47e9cf2
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-matexamp.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-matexports.png b/src/axiom-website/hyperdoc/axbook/ps/h-matexports.png
new file mode 100644
index 0000000..344a7d1
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-matexports.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-matimp.png b/src/axiom-website/hyperdoc/axbook/ps/h-matimp.png
new file mode 100644
index 0000000..fa03dd0
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-matimp.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-matinv.png b/src/axiom-website/hyperdoc/axbook/ps/h-matinv.png
new file mode 100644
index 0000000..2d01cef
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-matinv.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-matmap.png b/src/axiom-website/hyperdoc/axbook/ps/h-matmap.png
new file mode 100644
index 0000000..cb870d9
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-matmap.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-matops.png b/src/axiom-website/hyperdoc/axbook/ps/h-matops.png
new file mode 100644
index 0000000..04dafe4
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-matops.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-matpage.png b/src/axiom-website/hyperdoc/axbook/ps/h-matpage.png
new file mode 100644
index 0000000..f053b42
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-matpage.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-matrelops.png b/src/axiom-website/hyperdoc/axbook/ps/h-matrelops.png
new file mode 100644
index 0000000..a6c0de8
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-matrelops.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-matrix.png b/src/axiom-website/hyperdoc/axbook/ps/h-matrix.png
new file mode 100644
index 0000000..2860da7
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-matrix.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-matrixops.png b/src/axiom-website/hyperdoc/axbook/ps/h-matrixops.png
new file mode 100644
index 0000000..09deb1c
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-matrixops.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-matrixops1.png b/src/axiom-website/hyperdoc/axbook/ps/h-matrixops1.png
new file mode 100644
index 0000000..8ed2e7e
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-matrixops1.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-matrixops2.png b/src/axiom-website/hyperdoc/axbook/ps/h-matrixops2.png
new file mode 100644
index 0000000..62f524d
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-matrixops2.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-matsource.png b/src/axiom-website/hyperdoc/axbook/ps/h-matsource.png
new file mode 100644
index 0000000..62c9ace
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-matsource.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-matusers.png b/src/axiom-website/hyperdoc/axbook/ps/h-matusers.png
new file mode 100644
index 0000000..08eca11
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-matusers.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-matxref.png b/src/axiom-website/hyperdoc/axbook/ps/h-matxref.png
new file mode 100644
index 0000000..9c2d2cf
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-matxref.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-opsearch.png b/src/axiom-website/hyperdoc/axbook/ps/h-opsearch.png
new file mode 100644
index 0000000..8f3a895
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-opsearch.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-origins.png b/src/axiom-website/hyperdoc/axbook/ps/h-origins.png
new file mode 100644
index 0000000..c92160d
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-origins.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-parameter.png b/src/axiom-website/hyperdoc/axbook/ps/h-parameter.png
new file mode 100644
index 0000000..c92160d
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-parameter.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-root.png b/src/axiom-website/hyperdoc/axbook/ps/h-root.png
new file mode 100644
index 0000000..489aa4d
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-root.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/h-signature.png b/src/axiom-website/hyperdoc/axbook/ps/h-signature.png
new file mode 100644
index 0000000..422836e
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/h-signature.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/help.png b/src/axiom-website/hyperdoc/axbook/ps/help.png
new file mode 100644
index 0000000..f5c12d5
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/help.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/home.png b/src/axiom-website/hyperdoc/axbook/ps/home.png
new file mode 100644
index 0000000..b5991d5
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/home.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/knot3.png b/src/axiom-website/hyperdoc/axbook/ps/knot3.png
new file mode 100644
index 0000000..301f31f
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/knot3.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/modbessc.png b/src/axiom-website/hyperdoc/axbook/ps/modbessc.png
new file mode 100644
index 0000000..31a0f46
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/modbessc.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/newmap.png b/src/axiom-website/hyperdoc/axbook/ps/newmap.png
new file mode 100644
index 0000000..e6d0485
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/newmap.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/realbeta.png b/src/axiom-website/hyperdoc/axbook/ps/realbeta.png
new file mode 100644
index 0000000..effc667
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/realbeta.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/ribbon1.png b/src/axiom-website/hyperdoc/axbook/ps/ribbon1.png
new file mode 100644
index 0000000..32f1771
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/ribbon1.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/ribbon2.png b/src/axiom-website/hyperdoc/axbook/ps/ribbon2.png
new file mode 100644
index 0000000..9608596
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/ribbon2.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/ribbon2r.png b/src/axiom-website/hyperdoc/axbook/ps/ribbon2r.png
new file mode 100644
index 0000000..b9bc13e
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/ribbon2r.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/ribbons.png b/src/axiom-website/hyperdoc/axbook/ps/ribbons.png
new file mode 100644
index 0000000..a768bf3
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/ribbons.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/ribbons2.png b/src/axiom-website/hyperdoc/axbook/ps/ribbons2.png
new file mode 100644
index 0000000..359dffc
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/ribbons2.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/ribbons2b.png b/src/axiom-website/hyperdoc/axbook/ps/ribbons2b.png
new file mode 100644
index 0000000..ea1437d
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/ribbons2b.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/ribbons5.png b/src/axiom-website/hyperdoc/axbook/ps/ribbons5.png
new file mode 100644
index 0000000..a21aac5
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/ribbons5.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/segbind.png b/src/axiom-website/hyperdoc/axbook/ps/segbind.png
new file mode 100644
index 0000000..b0470f1
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/segbind.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/torusKnot.png b/src/axiom-website/hyperdoc/axbook/ps/torusKnot.png
new file mode 100644
index 0000000..a1957c4
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/torusKnot.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/up.png b/src/axiom-website/hyperdoc/axbook/ps/up.png
new file mode 100644
index 0000000..41f35c6
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/up.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/vectorRoot.png b/src/axiom-website/hyperdoc/axbook/ps/vectorRoot.png
new file mode 100644
index 0000000..682f6dc
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/vectorRoot.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/vectorSin.png b/src/axiom-website/hyperdoc/axbook/ps/vectorSin.png
new file mode 100644
index 0000000..eeeecec
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/vectorSin.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/wd-atanz.png b/src/axiom-website/hyperdoc/axbook/ps/wd-atanz.png
new file mode 100644
index 0000000..89b4c49
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/wd-atanz.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/wd-bessi.png b/src/axiom-website/hyperdoc/axbook/ps/wd-bessi.png
new file mode 100644
index 0000000..ed6f45c
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/wd-bessi.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/wd-bessi3.png b/src/axiom-website/hyperdoc/axbook/ps/wd-bessi3.png
new file mode 100644
index 0000000..f699545
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/wd-bessi3.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/wd-bessi3s.png b/src/axiom-website/hyperdoc/axbook/ps/wd-bessi3s.png
new file mode 100644
index 0000000..b981075
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/wd-bessi3s.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/wd-bessj.png b/src/axiom-website/hyperdoc/axbook/ps/wd-bessj.png
new file mode 100644
index 0000000..7c1722d
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/wd-bessj.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/wd-beta.png b/src/axiom-website/hyperdoc/axbook/ps/wd-beta.png
new file mode 100644
index 0000000..2603abd
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/wd-beta.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/wd-expz.png b/src/axiom-website/hyperdoc/axbook/ps/wd-expz.png
new file mode 100644
index 0000000..ef511cc
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/wd-expz.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/ps/wd-gammaz.png b/src/axiom-website/hyperdoc/axbook/ps/wd-gammaz.png
new file mode 100644
index 0000000..3a6a846
Binary files /dev/null and b/src/axiom-website/hyperdoc/axbook/ps/wd-gammaz.png differ
diff --git a/src/axiom-website/hyperdoc/axbook/section-0.1.xhtml b/src/axiom-website/hyperdoc/axbook/section-0.1.xhtml
new file mode 100644
index 0000000..6fa32fc
--- /dev/null
+++ b/src/axiom-website/hyperdoc/axbook/section-0.1.xhtml
@@ -0,0 +1,977 @@
+
+
+
+]>
+
+
+
+
+
+ Section0.1
+
+
+
+
+
+Book ContentsNext Section 0.2 A Technical Introduction
+Book Index
+
0.1 Introduction to Axiom
+
+
+
Welcome to the world of Axiom.
+We call Axiom a scientific computation system:
+a self-contained toolbox designed to meet
+your scientific programming needs,
+from symbolics, to numerics, to graphics.
+
+
+
+
This introduction is a quick overview of what Axiom offers.
+
+
+
+
+
+
+
0.1.1 Symbolic Computation
+
+
+
Axiom provides a wide range of simple commands for symbolic
+mathematical problem solving. Do you need to solve an equation, to
+expand a series, or to obtain an integral? If so, just ask Axiom
+to do it.
+
+
+
+
Given
+we would enter this into Axiom as:
+
+
+
+
+
+
+
+integrate(1/(x**3 * (a+b*x)**(1/3)),x)
+
+
+
+
+
which would give the result:
+
+
+
+
+
+
+Type: Union(Expression Integer,...)
+
+
+
+
Axiom provides state-of-the-art algebraic machinery to handle your
+most advanced symbolic problems. For example, Axiom's integrator
+gives you the answer when an answer exists. If one does not, it
+provides a proof that there is no answer. Integration is just one of
+a multitude of symbolic operations that Axiom provides.
+
+
+
+
+
+
+
+
+
+
+
+
0.1.2 Numeric Computation
+
+
+
Axiom has a numerical library that includes operations for linear
+algebra, solution of equations, and special functions. For many of
+these operations, you can select any number of floating point digits
+to be carried out in the computation.
+
+
+
+
Solve to 49 digits of accuracy.
+First we need to change the default output length of numbers:
+
+
+
+
+
+
+
+digits(49)
+
+
+
+
+
and then we execute the command:
+
+
+
+
+
+
+
+solve(x**49-49*x**4+9 = 0,1.e-49)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Equation Polynomial Float
+
+
+
+
The output of a computation can be converted to FORTRAN to be used
+in a later numerical computation.
+Besides floating point numbers, Axiom provides literally
+dozens of kinds of numbers to compute with.
+These range from various kinds of integers, to fractions, complex
+numbers, quaternions, continued fractions, and to numbers represented
+with an arbitrary base.
+
The AXIOM numerical library can be enhanced with a
+substantial number of functions from the NAG library of numerical and
+statistical algorithms. These functions will provide coverage of a wide
+range of areas including roots of functions, Fourier transforms, quadrature,
+differential equations, data approximation, non-linear optimization, linear
+algebra, basic statistics, step-wise regression, analysis of variance,
+time series analysis, mathematical programming, and special functions.
+Contact the Numerical Algorithms Group Limited, Oxford, England.
+
+
+
+
+
+
+
+
+
+
+
+
0.1.3 Graphics
+
+
+
You may often want to visualize a symbolic formula or draw
+a graph from a set of numerical values.
+To do this, you can call upon the Axiom
+graphics capability.
+
Graphs in Axiom are interactive objects you can manipulate with
+your mouse. Just click on the graph, and a control panel pops up.
+Using this mouse and the control panel, you can translate, rotate,
+zoom, change the coloring, lighting, shading, and perspective on the
+picture. You can also generate a PostScript copy of your graph to
+produce hard-copy output.
+
+
+
+
+
+
+
+
+
+
+
+
0.1.4 HyperDoc
+
+
+
+
+
+
+
Hyperdoc opening menu
+
+
+
HyperDoc presents you windows on the world of Axiom,
+offering on-line help, examples, tutorials, a browser, and reference
+material. HyperDoc gives you on-line access to this document in a
+``hypertext'' format. Words that appear in a different font (for
+example, Matrix, factor, and
+category) are generally mouse-active; if you click on one
+with your mouse, HyperDoc shows you a new window for that word.
+
+
+
+
As another example of a HyperDoc facility, suppose that you want to
+compute the roots of to 49 digits (as in our
+previous example) and you don't know how to tell Axiom to do this.
+The ``basic command'' facility of HyperDoc leads the way. Through the
+series of HyperDoc windows shown in Figure fig-intro-br and the specified mouse clicks, you and
+HyperDoc generate the correct command to issue to compute the answer.
+
+
+
+
+
+
+
+
+
+
+
+
0.1.5 Interactive Programming
+
+
+
Axiom's interactive programming language lets you define your
+own functions. A simple example of a user-defined function is one
+that computes the successive Legendre polynomials. Axiom lets
+you define these polynomials in a piece-wise way.
+
In addition to letting you define simple functions like this, the
+interactive language can be used to create entire application
+packages. All the graphs in the Axiom images section were created by
+programs written in the interactive language.
+
+
+
+
The above definitions for do no computation---they simply
+tell Axiom how to compute for some positive integer
+ .
+
+
+
+
To actually get a value of a Legendre polynomial, you ask for it.
+Legendre polynomials
+
+
+
+
What is the tenth Legendre polynomial?
+
+
+
+
+
+
+
+p(10)
+
+
+
+
+
+
+
+ Compiling function p with type Integer -> Polynomial Fraction
+ Integer
+ Compiling function p as a recurrence relation.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Fraction Integer
+
+
+
+
Axiom applies the above pieces for to obtain the value
+of . But it does more: it creates an optimized, compiled
+function for . The function is formed by putting the pieces
+together into a single piece of code. By compiled, we mean that
+the function is translated into basic machine-code. By optimized, we mean that certain transformations are performed on that
+code to make it run faster. For , Axiom actually
+translates the original definition that is recursive (one that calls
+itself) to one that is iterative (one that consists of a simple loop).
+
+
+
+
What is the coefficient of in ?
+
+
+
+
+
+
+
+coefficient(p(90),x,90)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Fraction Integer
+
+
+
+
+
In general, a user function is type-analyzed and compiled on first use.
+Later, if you use it with a different kind of object, the function
+is recompiled if necessary.
+
+
+
+
+
+
+
+
+
+
+
+
0.1.6 Data Structures
+
+
+
+
A variety of data structures are available for interactive use. These
+include strings, lists, vectors, sets, multisets, and hash tables. A
+particularly useful structure for interactive use is the infinite
+stream:
+
+
+
+
Create the infinite stream of derivatives of Legendre polynomials.
+
+
+
+
+
+
+
+[D(p(i),x) for i in 1..]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Polynomial Fraction Integer
+
+
+
+
+
+
Streams display only a few of their initial elements. Otherwise, they
+are ``lazy'': they only compute elements when you ask for them.
+
+
+
+
Data structures are an important component for building application
+software. Advanced users can represent data for applications in
+optimal fashion. In all, Axiom offers over forty kinds of
+aggregate data structures, ranging from mutable structures (such as
+cyclic lists and flexible arrays) to storage efficient structures
+(such as bit vectors). As an example, streams are used as the
+internal data structure for power series.
+
Series and streams make no attempt to compute all their
+elements! Rather, they stand ready to deliver elements on demand.
+
+
+
+
What is the coefficient of the -th
+term of this series?
+
+
+
+
+
+
+
+coefficient(%,50)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
0.1.7 Mathematical Structures
+
+
+
Axiom also has many kinds of mathematical structures. These
+range from simple ones (like polynomials and matrices) to more
+esoteric ones (like ideals and Clifford algebras). Most structures
+allow the construction of arbitrarily complicated ``types.''
+
+
+
+
Even a simple input expression can
+result in a type with several levels.
+
+
+
+
+
+
+
+matrix [ [x + %i,0], [1,-2] ]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Polynomial Complex Integer
+
+
+
+
+
The Axiom interpreter builds types in response to user input.
+Often, the type of the result is changed in order to be applicable to
+an operation.
+
+
+
+
The inverse operation requires that elements of the above matrices
+are fractions.
+
A convenient facility for symbolic computation is ``pattern
+matching.'' Suppose you have a trigonometric expression and you want
+to transform it to some equivalent form. Use a command to
+describe the transformation rules you rule need. Then give
+the rules a name and apply that name as a function to your
+trigonometric expression.
+
Apply the rules to a simple trigonometric expression.
+
+
+
+
+
+
+
+sinCosExpandRules(sin(a+2*b+c))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
+
Using input files, you can create your own library of transformation
+rules relevant to your applications, then selectively apply the rules
+you need.
+
+
+
+
+
+
+
+
+
+
+
+
0.1.9 Polymorphic Algorithms
+
+
+
All components of the Axiom algebra library are written in the
+Axiom library language. This language is similar to the
+interactive language except for protocols that authors are obliged to
+follow. The library language permits you to write ``polymorphic
+algorithms,'' algorithms defined to work in their most natural
+settings and over a variety of types.
+
+
+
+
Define a system of polynomial equations .
+
+
+
+
+
+
+
+S := [3*x**3 + y + 1 = 0,y**2 = 4]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Equation Polynomial Integer
+
+
+
+
+
Solve the system using rational number arithmetic and
+30 digits of accuracy.
+
+
+
+
+
+
+
+solve(S,1/10**30)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List List Equation Polynomial Fraction Integer
+
+
+
+
+
Solve with the solutions expressed in radicals.
+
+
+
+
+
+
+
+radicalSolve(S)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List List Equation Expression Integer
+
+
+
+
+
While these solutions look very different, the results were produced
+by the same internal algorithm! The internal algorithm actually works
+with equations over any ``field.'' Examples of fields are the
+rational numbers, floating point numbers, rational functions, power
+series, and general expressions involving radicals.
+
+
+
+
+
+
+
+
+
+
+
+
0.1.10 Extensibility
+
+
+
+
Users and system developers alike can augment the Axiom library,
+all using one common language. Library code, like interpreter code,
+is compiled into machine binary code for run-time efficiency.
+
+
+
+
Using this language, you can create new computational types and new
+algorithmic packages. All library code is polymorphic, described in
+terms of a database of algebraic properties. By following the
+language protocols, there is an automatic, guaranteed interaction
+between your code and that of colleagues and system implementers.
+
Axiom has both an interactive language for user
+interactions and a programming language for building library
+modules. Like Modula 2, Modula 2 PASCAL, PASCAL
+FORTRAN, FORTRAN and Ada, Ada the programming language
+emphasizes strict type-checking. Unlike these languages, types in
+Axiom are dynamic objects: they are created at run-time in
+response to user commands.
+
+
+
+
Here is the idea of the Axiom programming language in a
+nutshell. Axiom types range from algebraic ones (like
+polynomials, matrices, and power series) to data structures (like
+lists, dictionaries, and input files). Types combine in any
+meaningful way. You can build polynomials of matrices, matrices of
+polynomials of power series, hash tables with symbolic keys and
+rational function entries, and so on.
+
+
+
+
Categories define algebraic properties to ensure mathematical
+correctness. They ensure, for example, that matrices of polynomials
+are OK, but matrices of input files are not. Through categories,
+programs can discover that polynomials of continued fractions have a
+commutative multiplication whereas polynomials of matrices do not.
+
+
+
+
Categories allow algorithms to be defined in their most natural
+setting. For example, an algorithm can be defined to solve polynomial
+equations over any field. Likewise a greatest common divisor
+can compute the ``gcd'' of two elements from any Euclidean
+domain. Categories foil attempts to compute meaningless ``gcds'', for
+example, of two hashtables. Categories also enable algorithms to be
+compiled into machine code that can be run with arbitrary types.
+
+
+
+
The Axiom interactive language is oriented towards ease-of-use.
+The Axiom interpreter uses type-inferencing to deduce the type
+of an object from user input. Type declarations can generally be
+omitted for common types in the interactive language.
+
+
+
+
So much for the nutshell.
+Here are these basic ideas described by ten design principles:
+
+
+
+
+
+
+
0.2.1 Types are Defined by Abstract Datatype Programs
+
+
+
+
Basic types are called domains of computation, or,
+simply, domains.
+domain
+Domains are defined by Axiom programs of the form:
+
+
+
+
+
+
+Name(...): Exports == Implementation
+
+
+
+
+
Each domain has a capitalized Name that is used to refer to the
+class of its members. For example, Integer denotes ``the
+class of integers,'' Float, ``the class of floating point
+numbers,'' and String, ``the class of strings.''
+
+
+
+
The ``...'' part following Name lists zero or more
+parameters to the constructor. Some basic ones like Integer take
+no parameters. Others, like Matrix, Polynomial and
+List, take a single parameter that again must be a domain. For
+example, Matrix(Integer) denotes ``matrices over the integers,''
+Polynomial (Float) denotes ``polynomial with floating point
+coefficients,'' and List (Matrix (Polynomial (Integer))) denotes
+``lists of matrices of polynomials over the integers.'' There is no
+restriction on the number or type of parameters of a domain
+constructor.
+
+
+
+
SquareMatrix(2,Integer) is an example of a domain constructor that accepts
+both a particular data value as well as an integer. In this case the
+number 2 specifies the number of rows and columns the square matrix
+will contain. Elements of the matricies are integers.
+
+
+
+
The Exports part specifies operations for creating and
+manipulating objects of the domain. For example, type
+Integer exports constants and , and
+operations +, -, and
+*. While these operations are common, others
+such as odd?odd?Integer and bit?bit?Integer
+are not. In addition the Exports section can contain symbols that
+represent properties that can be tested. For example, the Category
+EntireRing has the symbol noZeroDivisors which asserts
+that if a product is zero then one of the factors must be zero.
+
+
+
+
The Implementation part defines functions that implement the
+exported operations of the domain. These functions are frequently
+described in terms of another lower-level domain used to represent the
+objects of the domain. Thus the operation of adding two vectors of
+real numbers can be described and implemented using the addition
+operation from Float.
+
+
+
+
+
+
+
+
+
+
+
+
0.2.2 The Type of Basic Objects is a Domain or Subdomain
+
+
+
+
Every Axiom object belongs to a unique domain. The domain
+of an object is also called its type. Thus the integer
+has type Integer and the string "daniel" has type
+String.
+
+
+
+
The type of an object, however, is not unique. The type of integer
+ is not only Integer but NonNegativeInteger,
+PositiveInteger, and possibly, in general, any other
+``subdomain'' of the domain Integer. A subdomain
+subdomain is a domain with a ``membership predicate''.
+PositiveInteger is a subdomain of Integer with the
+predicate ``is the integer ?''.
+
+
+
+
Subdomains with names are defined by abstract datatype programs
+similar to those for domains. The Export part of a subdomain,
+however, must list a subset of the exports of the domain. The Implementation part optionally gives special definitions for
+subdomain objects.
+
+
+
+
+
+
+
+
+
+
+
+
0.2.3 Domains Have Types Called Categories
+
+
+
+
Domain and subdomains in Axiom are themselves objects that have
+types. The type of a domain or subdomain is called a category.
+category Categories are described by programs of the form:
+
+
+
+
+
+
+Name(...): Category == Exports
+
+
+
+
The type of every category is the distinguished symbol Category.
+The category Name is used to designate the class of domains of
+that type. For example, category Ring designates the class
+of all rings. Like domains, categories can take zero or more
+parameters as indicated by the ``...'' part following Name. Two examples are Module(R) and
+MatrixCategory(R,Row,Col).
+
+
+
+
The Exports part defines a set of operations. For example,
+Ring exports the operations 0,
+1, +, -, and
+*. Many algebraic domains such as
+Integer and Polynomial (Float) are rings.
+String and List (R) (for any domain )
+are not.
+
+
+
+
Categories serve to ensure the type-correctness. The definition of
+matrices states Matrix(R: Ring) requiring its single parameter
+ to be a ring. Thus a ``matrix of polynomials'' is allowed,
+but ``matrix of lists'' is not.
+
+
+
+
Categories say nothing about representation. Domains, which are
+instances of category types, specify representations.
+
+
+
+
+
+
+
+
+
+
+
+
0.2.4 Operations Can Refer To Abstract Types
+
+
+
+
All operations have prescribed source and target types. Types can be
+denoted by symbols that stand for domains, called ``symbolic
+domains.'' The following lines of Axiom code use a symbolic
+domain :
+
+
+
+
+
+
+R: Ring
+power: (R, NonNegativeInteger): R -> R
+power(x, n) == x ** n
+
+
+
+
+
Line 1 declares the symbol to be a ring. Line 2 declares the
+type of in terms of . From the definition on
+line 3, produces 9 for and
+Integer. Also, produces for
+ and Float.
+ however fails since has type
+String which is not a ring.
+
+
+
+
Using symbolic domains, algorithms can be defined in their most
+natural or general setting.
+
+
+
+
+
+
+
+
+
+
+
+
0.2.5 Categories Form Hierarchies
+
+
+
+
Categories form hierarchies (technically, directed-acyclic graphs). A
+simplified hierarchical world of algebraic categories is shown below.
+At the top of this world is SetCategory, the class of
+algebraic sets. The notions of parents, ancestors, and descendants is
+clear. Thus ordered sets (domains of category OrderedSet)
+and rings are also algebraic sets. Likewise, fields and integral
+domains are rings and algebraic sets. However fields and integral
+domains are not ordered sets.
+
A category designates a class of domains. Which domains? You might
+think that Ring designates the class of all domains that
+export , , +,
+-, and *. But this is not
+so. Each domain must assert which categories it belongs to.
+
+
+
+
The Export part of the definition for Integer reads,
+for example:
+
+
+
+
+
+
+Join(OrderedSet, IntegralDomain, ...) with ...
+
+
+
+
+
This definition asserts that Integer is both an ordered set
+and an integral domain. In fact, Integer does not
+explicitly export constants and and operations
++, - and * at
+all: it inherits them all from ! Since
+IntegralDomain is a descendant of ,
+Integer is therefore also a ring.
+
+
+
+
Assertions can be conditional. For example, Complex(R)
+defines its exports by:
+
+
+
+
+
+
+Ring with ... if R has Field then Field ...
+
+
+
+
Thus Complex(Float) is a field but Complex(Integer)
+is not since Integer is not a field.
+
+
+
+
You may wonder: ``Why not simply let the set of operations determine
+whether a domain belongs to a given category?''. Axiom allows
+operation names (for example, norm) to have very different
+meanings in different contexts. The meaning of an operation in
+Axiom is determined by context. By associating operations with
+categories, operation names can be reused whenever appropriate or
+convenient to do so. As a simple example, the operation <
+might be used to denote lexicographic-comparison in an algorithm.
+However, it is wrong to use the same < with this definition
+of absolute-value: Such a
+definition for abs in Axiom is protected by context:
+argument is required to be a member of a domain of category
+OrderedSet.
+
+
+
+
+
+
+
+
+
+
+
+
0.2.7 Packages Are Clusters of Polymorphic Operations
+
+
+
+
In Axiom, facilities for symbolic integration, solution of
+equations, and the like are placed in ``packages''. A package
+package is a special kind of domain: one whose exported
+operations depend solely on the parameters of the constructor and/or
+explicit domains. Packages, unlike Domains, do not specify the
+representation.
+
+
+
+
If you want to use Axiom, for example, to define some algorithms
+for solving equations of polynomials over an arbitrary field ,
+you can do so with a package of the form:
+
+
+
+
+
+
+MySolve(F: Field): Exports == Implementation
+
+
+
+
where Exports specifies the solve operations
+you wish to export from the domain and the Implementation
+defines functions for implementing your algorithms. Once Axiom has
+compiled your package, your algorithms can then be used for any F:
+floating-point numbers, rational numbers, complex rational functions,
+and power series, to name a few.
+
+
+
+
+
+
+
+
+
+
+
+
0.2.8 The Interpreter Builds Domains Dynamically
+
+
+
+
The Axiom interpreter reads user input then builds whatever types
+it needs to perform the indicated computations.
+For example, to create the matrix
+
+using the command:
+
the interpreter first loads the modules Matrix,
+Polynomial, Fraction, and Integer
+from the library, then builds the domain tower ``matrices of
+polynomials of rational numbers (i.e. fractions of integers)''.
+
+
+
+
You can watch the loading process by first typing
+
+
+
+
+
+
+
+)set message autoload on
+
+
+
+
+
In addition to the named
+domains above many additional domains and categories are loaded.
+Most systems are preloaded with such common types. For efficiency
+reasons the most common domains are preloaded but most (there are
+more than 1100 domains, categories, and packages) are not. Once these
+domains are loaded they are immediately available to the interpreter.
+
+
+
+
Once a domain tower is built, it contains all the operations specific
+to the type. Computation proceeds by calling operations that exist in
+the tower. For example, suppose that the user asks to square the
+above matrix. To do this, the function * from
+Matrix is passed the matrix to compute .
+The function is also passed an environment containing
+that, in this case, is Polynomial (Fraction (Integer)).
+This results in the successive calling of the *
+operations from Polynomial, then from Fraction,
+and then finally from Integer.
+
+
+
+
Categories play a policing role in the building of domains. Because
+the argument of Matrix is required to be a Ring,
+Axiom will not build nonsensical types such as ``matrices of
+input files''.
+
+
+
+
+
+
+
+
+
+
+
+
0.2.9 Axiom Code is Compiled
+
+
+
+
Axiom programs are statically compiled to machine code, then
+placed into library modules. Categories provide an important role in
+obtaining efficient object code by enabling:
+
+
+
+
+
+
+ static type-checking at compile time;
+
+
fast linkage to operations in domain-valued parameters;
+
+
optimization techniques to be used for partially specified types
+(operations for ``vectors of '', for instance, can be open-coded even
+though R is unknown).
+
+
+
+
+
+
+
+
+
+
+
+
+
+
0.2.10 Axiom is Extensible
+
+
+
+
Users and system implementers alike use the Axiom language to
+add facilities to the Axiom library. The entire Axiom
+library is in fact written in the Axiom source code and
+available for user modification and/or extension.
+
+
+
+
Axiom's use of abstract datatypes clearly separates the exports
+of a domain (what operations are defined) from its implementation (how
+the objects are represented and operations are defined). Users of a
+domain can thus only create and manipulate objects through these
+exported operations. This allows implementers to ``remove and
+replace'' parts of the library safely by newly upgraded (and, we hope,
+correct) implementations without consequence to its users.
+
+
+
+
Categories protect names by context, making the same names available
+for use in other contexts. Categories also provide for code-economy.
+Algorithms can be parameterized categorically to characterize their
+correct and most general context. Once compiled, the same machine
+code is applicable in all such contexts.
+
+
+
+
Finally, Axiom provides an automatic, guaranteed interaction
+between new and old code. For example:
+
+
+
+
+
+
+ if you write a new algorithm that requires a parameter to be a
+field, then your algorithm will work automatically with every field
+defined in the system; past, present, or future.
+
+
if you introduce a new domain constructor that produces a field,
+then the objects of that domain can be used as parameters to any algorithm
+using field objects defined in the system; past, present, or future.
+
+
+
+
+
+
These are the key ideas. For further information, we particularly
+recommend your reading chapters 11, 12, and 13, where these ideas are
+explained in greater detail.
+
At the simplest level Axiom can be used as a pocket calculator
+where expressions involving numbers and operators are entered
+directly in infix notation. In this sense the more advanced
+features of the calculator can be regarded as operators (e.g
+ sin, cos, etc).
+
+
+
+
+
+
+
0.3.1 Basic Arithmetic
+
+
+
An example of this might be to calculate the cosine of 2.45 (in radians).
+To do this one would type:
+
+
+
+
+
+
+
+cos 2.45
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
Before proceeding any further it would be best to explain the previous
+three lines. Firstly the text ``(1) -> '' is part of the prompt that the
+Axiom system provides when in interactive mode. The full prompt has other
+text preceding this but it is not relevant here. The number in parenthesis
+is the step number of the input which may be used to refer to the
+results of previous calculations. The step number appears at the start
+of the second line to tell you which step the result belongs to. Since the
+interpreter probably loaded numberous libraries to calculate the result given
+above and listed each one in the prcess, there could easily be several pages
+of text between your input and the answer.
+
+
+
+
The last line contains the type of the result. The type Float is used
+to represent real numbers of arbitrary size and precision (where the user is
+able to define how big arbitrary is -- the default is 20 digits but can be
+as large as your computer system can handle). The type of the result can help
+track down mistakes in your input if you don't get the answer you expected.
+
+
+
+
Other arithmetic operations such as addition, subtraction, and multiplication
+behave as expected:
+
+
+
+
+
+
+
+6.93 * 4.1328
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+
+6.93 / 4.1328
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
but integer division isn't quite so obvious. For example, if one types:
+
+
+
+
+
+
+
+4/6
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
a fractional result is obtained. The function used to display fractions
+attempts to produce the most readable answer. In the example:
+
+
+
+
+
+
+
+4/2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
the result is stored as the fraction 2/1 but is displayed as the integer 2.
+This fraction could be converted to type Integer with no loss of
+informatin but Axiom will not do so automatically.
+
+
+
+
+
+
+
+
+
+
+
+
0.3.2 Type Conversion
+
+
+
To obtain the floating point value of a fraction one must convert (
+ conversions are applied by the user and
+ coercions are applied automatically by the interpreter) the result
+to type Float using the ``::'' operator as follows:
+
+
+
+
+
+
+
+(4.6)::Float
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
Although Axiom can convert this back to a fraction it might not be the
+same fraction you started with as due to rounding errors. For example, the
+following conversion appears to be without error but others might not:
+
+
+
+
+
+
+
+%::Fraction Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
where ``%'' represents the previous result (not the calculation).
+
+
+
+
Although Axiom has the ability to work with floating-point numbers to
+a very high precision it must be remembered that calculations with these
+numbers are not exact. Since Axiom is a computer algebra package and
+not a numerical solutions package this should not create too many problems.
+The idea is that the user should use Axiom to do all the necessary symbolic
+manipulation and only at the end should actual numerical results be extracted.
+
+
+
+
If you bear in mind that Axiom appears to store expressions just as you have
+typed them and does not perform any evalutation of them unless forced to then
+programming in the system will be much easier. It means that anything you
+ask Axiom to do (within reason) will be carried with complete accuracy.
+
+
+
+
In the previous examples the ``::'' operator was used to convert values from
+one type to another. This type conversion is not possible for all values.
+For instance, it is not possible to convert the number 3.4 to an integer
+type since it can't be represented as an integer. The number 4.0 can be
+converted to an integer type since it has no fractional part.
+
+
+
+
Conversion from floating point values to integers is performed using the
+functions round and truncate. The first of these rounds a
+floating point number to the nearest integer while the other truncates
+(i.e. removes the fractional part). Both functions return the result as a
+ floating point number. To extract the fractional part of a floating
+point number use the function fractionPart but note that the sign
+of the result depends on the sign of the argument. Axiom obtains the
+fractional partof using :
+
+
+
+
+
+
+
+round(3.77623)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+
+round(-3.77623)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+
+truncate(9.235)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+
+truncate(-9.654)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+
+fractionPart(-3.77623)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+
+
+
+
+
+
0.3.3 Useful Functions
+
+
+
To obtain the absolute value of a number the abs function can be used.
+This takes a single argument which is usually an integer or a floating point
+value but doesn't necessarily have to be. The sign of a value can be obtained
+via the sign function which rturns , , or depending on the
+sign of the argument.
+
+
+
+
+
+
+
+abs(4)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+abs(-3)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+abs(-34254.12314)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+
+sign(-49543.2345346)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Integer
+
+
+
+
+
+
+
+
+sign(0)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: NonNegativeInteger
+
+
+
+
+
+
+
+
+sign(234235.42354)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Tests on values can be done using various functions which are generally more
+efficient than using relational operators such as particularly if the
+value is a matrix. Examples of some of these functions are:
+
+
+
+
+
+
+
+positive?(-234)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+negative?(-234)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+zero?(42)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+one?(1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+odd?(23)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+odd?(9.435)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+even?(-42)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+prime?(37)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+prime?(-37)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
Some other functions that are quite useful for manipulating numerical values
+are:
+
+
+
+
+
+
+sin(x) Sine of x
+cos(x) Cosine of x
+tan(x) Tangent of x
+asin(x) Arcsin of x
+acos(x) Arccos of x
+atan(x) Arctangent of x
+gcd(x,y) Greatest common divisor of x and y
+lcm(x,y) Lowest common multiple of x and y
+max(x,y) Maximum of x and y
+min(x,y) Minimum of x and y
+factorial(x) Factorial of x
+factor(x) Prime factors of x
+divide(x,y) Quotient and remainder of x/y
+
+
+
+
+
Some simple infix and prefix operators:
+
+
+
+
+
++ Addition - Subtraction
+- Numerical Negation ~ Logical Negation
+/ Conjunction (AND) \/ Disjunction (OR)
+and Logical AND (/\) or Logical OR (\/)
+not Logical Negation ** Exponentiation
+* Multiplication / Division
+quo Quotient rem Remainder
+< less than > greater than
+<= less than or equal >= greater than or equal
+
+
+
+
+
Some useful Axiom macros:
+
+
+
+
+
+%i The square root of -1
+%e The base of the natural logarithm
+%pi Pi
+%infinity Infinity
+%plusInfinity Positive Infinity
+%minusInfinity Negative Infinity
+
In the previous section all the examples involved numbers and simple
+functions. Also none of the expressions entered were assigned to anything.
+In this section we will move on to simple algebra (i.e. expressions involving
+symbols and other features available on more sophisticated calculators).
+
+
+
+
+
+
+
0.4.1 Expressions Involving Symbols
+
+
+
Expressions involving symbols are entered just as they are written down,
+for example:
+
+
+
+
+
+
+
+xSquared := x**2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
where the assignment operator ``:='' represents immediate assignment. Later
+it will be seen that this form of assignment is not always desirable and
+the use of the delayed assignment operator ``=='' will be introduced. The
+type of the result is Polynomial Integer which is used to represent
+polynomials with integer coefficients. Some other examples along similar
+lines are:
+
+
+
+
+
+
+
+xDummy := 3.21*x**2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Float
+
+
+
+
+
+
+
+
+xDummy := x**2.5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Float
+
+
+
+
+
+
+
+
+xDummy := x**3.3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Float
+
+
+
+
+
+
+
+
+xyDummy := x**2 - y**2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
Given that we can define expressions involving symbols, how do we actually
+compute the result when the symbols are assigned values? The answer is to
+use the eval function which takes an expression as its first argument
+followed by a list of assignments. For example, to evaluate the expressions
+ XDummy and {xyDummy} resulting from their respective assignments above
+we type:
+
+
+
+
+
+
+
+eval(xDummy,x=3)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Float
+
+
+
+
+
+
+
+
+eval(xyDummy, [x=3, y=2.1])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Float
+
+
+
+
+
+
+
+
+
+
+
+
+
0.4.2 Complex Numbers
+
+
+
For many scientific calculations real numbers aren't sufficient and support
+for complex numbers is also required. Complex numbers are handled in an
+intuitive manner and Axiom, which uses the %i macro to represent
+the square root of . Thus expressions involving complex numbers are
+entered just like other expressions.
+
+
+
+
+
+
+
+(2/3 + %i)**3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Fraction Integer
+
+
+
+
+
The real and imaginary parts of a complex number can be extracted using
+the real and imag functions and the complex conjugate of a
+number can be obtained using conjugate:
+
+
+
+
+
+
+
+real(3 + 2*%i)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+imag(3+ 2*%i)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+conjugate(3 + 2*%i)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Integer
+
+
+
+
+
The function factor can also be applied to complex numbers but the
+results aren't quite so obvious as for factoring integer:
+
+
+
+
+
+
+
+144 + 24*%i
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
0.4.3 Number Representations
+
+
+
By default all numerical results are displayed in decimal with real numbers
+shown to 20 significant figures. If the integer part of a number is longer
+than 20 digits then nothing after the decimal point is shown and the integer
+part is given in full. To alter the number of digits shown the function
+ digits can be called. The result returned by this function is the
+previous setting. For example, to find the value of to 40 digits
+we type:
+
+
+
+
+
+
+
+digits(40)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+%pi::Float
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
As can be seen in the example above, there is a gap after every ten digits.
+This can be changed using the outputSpacing function where the argument
+is the number of digits to be displayed before a space is inserted. If no
+spaces are desired then use the value . Two other functions controlling
+the appearance of real numbers are outputFloating and outputFixed.
+The former causes Axiom to display floating-point values in exponent notation
+and the latter causes it to use fixed-point notation. For example:
+
+
+
+
+
+
+
+outputFloating(); %
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+
+outputFloating(3); 0.00345
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+
+outputFixed(); %
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+
+outputFixed(3); %
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+
+outputGeneral(); %
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
Note that the semicolon ``;'' in the examples above allows several
+expressions to be entered on one line. The result of the last expression
+is displayed. remember also that the percent symbol ``%'' is used to
+represent the result of a previous calculation.
+
+
+
+
To display rational numbers in a base other than 10 the function radix
+is used. The first argument of this function is the expression to be
+displayed and the second is the base to be used.
+
+
+
+
+
+
+
+radix(10**10,32)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: RadixExpansion 32
+
+
+
+
+
+
+
+
+radix(3/21,5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: RadixExpansion 5
+
+
+
+
+
Rational numbers can be represented as a repeated decimal expansion using
+the decimal function or as a continued fraction using
+ continuedFraction. Any attempt to call these functions with irrational
+values will fail.
+
+
+
+
+
+
+
+decimal(22/7)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DecimalExpansion
+
+
+
+
+
+
+
+
+continuedFraction(6543/210)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: ContinuedFraction Integer
+
+
+
+
+
Finally, partial fractions in compact and expanded form are available via the
+functions partialFraction and padicFraction respectively. The
+former takes two arguments, the first being the numerator of the fraction
+and the second being the denominator. The latter function takes a fraction
+and expands it further while the function compactFraction does the
+reverse:
+
+
+
+
+
+
+
+partialFraction(234,40)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PartialFraction Integer
+
+
+
+
+
+
+
+
+padicFraction(%)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PartialFraction Integer
+
+
+
+
+
+
+
+
+compactFraction(%)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PartialFraction Integer
+
+
+
+
+
+
+
+
+padicFraction(234/40)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PartialFraction Fraction Integer
+
+
+
+
+
To extract parts of a partial fraction the function nthFractionalTerm
+is available and returns a partial fraction of one term. To decompose this
+further the numerator can be obtained using firstNumer and the
+denominator with firstDenom. The whole part of a partial fraction can
+be retrieved using wholePart and the number of fractional parts can
+be found using the function numberOf FractionalTerms:
+
+
+
+
+
+
+
+t := partialFraction(234,40)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PartialFraction Integer
+
+
+
+
+
+
+
+
+wholePart(t)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+numberOfFractionalTerms(t)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+p := nthFractionalTerm(t,1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PartialFraction Integer
+
+
+
+
+
+
+
+
+firstNumer(p)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Integer
+
+
+
+
+
+
+
+
+firstDenom(p)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
0.4.4 Modular Arithmetic
+
+
+
By using the type constructor PrimeField it is possible to do
+arithmetic modulo some prime number. For example, arithmetic module
+can be performed as follows:
+
+
+
+
+
+
+
+x : PrimeField 7 := 5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PrimeField 7
+
+
+
+
+
+
+
+
+x**5 + 6
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PrimeField 7
+
+
+
+
+
+
+
+
+1/x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PrimeField 7
+
+
+
+
+
The first example should be read as:
+
+
+
+
+
+
+
+
Let be of type PrimeField(7) and assign to it the value
+
+
+
+
+
+
+
+
+
Note that it is only possible to invert non-zero values if the arithmetic
+is performed modulo a prime number. Thus arithmetic modulo a non-prime
+integer is possible but the reciprocal operation is undefined and will
+generate an error. Attempting to use the PrimeField type constructor
+with a non-prime argument will generate an error. An example of non-prime
+modulo arithmetic is:
+
+
+
+
+
+
+
+y : IntegerMod 8 := 11
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: IntegerMod 8
+
+
+
+
+
+
+
+
+y*4 + 27
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: IntegerMod 8
+
+
+
+
+
Note that polynomials can be constructed in a similar way:
+
It is sometimes desirable to enter an expression and prevent Axiom from
+displaying the result. To do this the expression should be terminated with
+a semicolon ``;''. In a previous section it was mentioned that a set of
+expressions separated by semicolons would be evaluated and the result
+of the last one displayed. Thus if a single expression is followed by a
+semicolon no output will be produced (except for its type):
+
+
+
+
+
+
+
+2 + 4*5;
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+
+
+
+
+
0.5.2 Accessing Earlier Results
+
+
+
The ``%'' macro represents the result of the previous computation. The
+``%%'' macro is available which takes a single integer argument. If the
+argument is positive then it refers to the step number of the calculation
+where the numbering begins from one and can be seen at the end of each
+prompt (the number in parentheses). If the argument is negative then it
+refers to previous results counting backwards from the last result. That is,
+``%%(-1)'' is the same as ``%''. The value of ``%%(0)'' is not defined and
+will generate an error if requested.
+
+
+
+
+
+
+
+
+
+
+
+
0.5.3 Splitting Expressions Over Several Lines
+
+
+
Although Axiom will quite happily accept expressions that are longer than
+the width of the screen (just keep typing without pressing the Return
+key) it is often preferable to split the expression being entered at a point
+where it would result in more readable input. To do this the underscore
+``_'' symbol is placed before the break point and then the Return
+key is pressed. The rest of the expression is typed on the next line,
+can be preceeded by any number of whitespace chars, for example:
+
+
+
+
+
+2_
++_
+3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The underscore symbol is an escape character and its presence alters the
+meaning of the characters that follow it. As mentions above whitespace
+following an underscore is ignored (the Return key generates a
+whitespace character). Any other character following an underscore loses
+whatever special meaning it may have had. Thus one can create the
+identifier ``a+b'' by typing ``a_+b'' although this might lead to confusions.
+Also note the result of the following example:
+
+
+
+
+
+
+
+ThisIsAVeryLong_
+VariableName
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Variable ThisIsAVeryLongVariableName
+
+
+
+
+
+
+
+
+
+
+
+
+
0.5.4 Comments and Descriptions
+
+
+
Comments and descriptions are really only of use in files of Axiom code but
+can be used when the output of an interactive session is being spooled to
+a file (via the system command )spool). A comment begins with two
+dashes ``- -'' and continues until the end of the line. Multi-line
+comments are only possible if each individual line begins with two dashes.
+
+
+
+
Descriptions are the same as comments except that the Axiom compiler will
+include them in the object files produced and make them availabe to the
+end user for documentation purposes.
+
+
+
+
A description is placed before a calculation begins with three
+``+++'' signs and a description placed after a calculation begins with
+two plus symbols ``+''. The so-called ``plus plus'' comments are used
+within the algebra files and are processed by the compiler to add
+to the documentation. The so-called ``minus minus'' comments are ignored
+everywhere.
+
+
+
+
+
+
+
+
+
+
+
+
0.5.5 Control of Result Types
+
+
+
In earlier sections the type of an expression was converted to another
+via the ``::'' operator. However, this is not the only method for
+converting between types and two other operators need to be introduced
+and explained.
+
+
+
+
The first operator is ``$'' and is used to specify the package to be
+used to calculate the result. Thus:
+
+
+
+
+
+
+
+(2/3)$Float
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
tells Axiom to use the ``/'' operator from the Float package to
+evaluate the expression . This does not necessarily mean that the
+result will be of the same type as the domain from which the operator
+was taken. In the following example the sign operator is taken
+from the Float package but the result is of type Integer.
+
+
+
+
+
+
+
+sign(2.3)$Float
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Integer
+
+
+
+
+
The other operator is ``@'' which is used to tell Axiom what the desired
+type of the result of the calculation is. In most situations all three
+operators yield the same results but the example below should help
+distinguish them.
+
+
+
+
+
+
+
+(2 + 3)::String
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
+
+
+
+(2 + 3)@String
+
+
+
+
+
+
+
+An expression involving @ String actually evaluated to one of
+ type PositiveInteger . Perhaps you should use :: String .
+
+
+
+
+
+
+
+
+(2 + 3)$String
+
+
+
+
+
+
+
+ The function + is not implemented in String .
+
+
+
+
+
If an expression X is converted using one of the three operators to
+type T the interpretations are:
+
+
+
+
:: means explicitly convert X to type T if possible.
+
+
+
+
$ means use the available operators for type T to compute X.
+
+
+
+
@ means choose operators to compute X so that the result is of
+type T.
+
This chapter is an overview of some of the data structures provided
+by Axiom.
+
+
+
+
+
+
0.6.1 Lists
+
+
+
The Axiom List type constructor is used to create homogenous lists of
+finite size. The notation for lists and the names of the functions that
+operate over them are similar to those found in functional languages such
+as ML.
+
+
+
+
Lists can be created by placing a comma separated list of values inside
+square brackets or if a list with just one element is desired then the
+function list is available:
+
+
+
+
+
+
+
+[4]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
+
+
+
+list(4)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
+
+
+
+[1,2,3,5,7,11]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
The function append takes two lists as arguments and returns the list
+consisting of the second argument appended to the first. A single element
+can be added to the front of a list using cons:
+
+
+
+
+
+
+
+append([1,2,3,5],[7,11])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
+
+
+
+cons(23,[65,42,19])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
Lists are accessed sequentially so if Axiom is asked for the value of the
+twentieth element in the list it will move from the start of the list over
+nineteen elements before it reaches the desired element. Each element of a
+list is stored as a node consisting of the value of the element and a pointer
+to the rest of the list. As a result the two main operations on a list are
+called first and rest. Both of these functions take a second
+optional argument which specifies the length of the first part of the list:
+
+
+
+
+
+
+
+first([1,5,6,2,3])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+first([1,5,6,2,3],2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
+
+
+
+rest([1,5,6,2,3])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
+
+
+
+rest([1,5,6,2,3],2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
Other functions are empty? which tests to see if a list contains no
+elements, member? which tests to see if the first argument is a member
+of the second, reverse which reverses the order of the list, sort
+which sorts a list, and removeDuplicates which removes any duplicates.
+The length of a list can be obtained using the `` #'' operator.
+
+
+
+
+
+
+
+empty?([7,2,-1,2])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+member?(-1,[7,2,-1,2])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+reverse([7,2,-1,2])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
+
+
+
+sort([7,2,-1,2])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
+
+
+
+removeDuplicates([1,5,3,5,1,1,2])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
+
+
+
+ #[7,2,-1,2]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Lists in Axiom are mutable and so their contents (the elements and the links)
+can be modified in place. Functions that operator over lists in this way have
+names ending in the symbol ``!''. For example, concat! takes two lists
+as arguments and appends the second argument to the first (except when the
+first argument is an empty list) and setrest! changes the link
+emanating from the first argument to point to the second argument:
+
+
+
+
+
+
+
+u := [9,2,4,7]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
+
+
+
+concat!(u,[1,5,42]); u
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
+
+
+
+endOfu := rest(u,4)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
+
+
+
+partOfu := rest(u,2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
+
+
+
+setrest!(endOfu,partOfu); u
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
From this it can be seen that the lists returned by first and rest
+are pointers to the original list and not a copy. Thus great care must
+be taken when dealing with lists in Axiom.
+
+
+
+
Although the nth element of the list l can be obtained by
+applying the first function to applications of rest
+to l, Axiom provides a more useful access method in the form of
+the ``.'' operator:
+
+
+
+
+
+
+
+u.3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+u.5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+u.6
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+first rest rest u -- Same as u.3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+u.first
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+u(3)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The operation u.i is referred to as indexing into u or
+elting into u. The latter term comes from the elt function
+which is used to extract elements (the first element of the list is at
+index ).
+
+
+
+
+
+
+
+elt(u,4)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
If a list has no cycles then any attempt to access an element beyond the
+end of the list will generate an error. However, in the example above there
+was a cycle starting at the third element so the access to the sixth
+element wrapped around to give the third element. Since lists are mutable it
+is possible to modify elements directly:
+
+
+
+
+
+
+
+u.3 := 42; u
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
Other list operations are:
+
+
+
+
+
+
+L := [9,3,4,7]; #L
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+last(L)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+L.last
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+L.( #L - 1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Note that using the `` #'' operator on a list with cycles causes Axiom to
+enter an infinite loop.
+
+
+
+
Note that any operation on a list L that returns a list
+will, in general, be such that any changes to will have the
+side-effect of altering L. For example:
+
+
+
+
+
+
+
+m := rest(L,2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
+
+
+
+m.1 := 20; L
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
+
+
+
+n := L
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
+
+
+
+n.2 := 99; L
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
+
+
+
+n
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
Thus the only save way of copying lists is to copy each element from one to
+another and not use the assignment operator:
+
+
+
+
+
+
+
+p := [i for i in n] -- Same as `p := copy(n)'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
+
+
+
+p.2 := 5; p
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
+
+
+
+n
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
In the previous example a new way of constructing lists was given. This is
+a powerful method which gives the reader more information about the contents
+of the list than before and which is extremely flexible. The example
+
+
+
+
+
+
+
+[i for i in 1..10]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
should be read as
+
+
+
+
+
+
+
+
+
``Using the expression i, generate each element of the list by
+iterating the symbol i over the range of integers [1,10]''
+
+
+
+
+
+
+
+
+
To generate the list of the squares of the first ten elements we just use:
+
+
+
+
+
+
+
+[i**2 for i in 1..10]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
For more complex lists we can apply a condition to the elements that are to
+be placed into the list to obtain a list of even numbers between 0 and 11:
+
+
+
+
+
+
+
+[i for i in 1..10 | even?(i)]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
This example should be read as:
+
+
+
+
+
+
+
+
``Using the expression i, generate each element of the list
+by iterating the symbol i over the range of integers [1,10] such that
+i is even''
+
+
+
+
+
+
+
+
+
The following achieves the same result:
+
+
+
+
+
+
+
+[i for i in 2..10 by 2]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
+
+
+
+
+
+
+
+
0.6.2 Segmented Lists
+
+
+
A segmented list is one in which some of the elements are ranges of values.
+The expand function converts lists of this type into ordinary lists:
+
+
+
+
+
+
+
+[1..10]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Segment PositiveInteger
+
+
+
+
+
+
+
+
+[1..3,5,6,8..10]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Segment PositiveInteger
+
+
+
+
+
+
+
+
+expand(%)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
If the upper bound of a segment is omitted then a different type of
+segmented list is obtained and expanding it will produce a stream (which
+will be considered in the next section):
+
+
+
+
+
+
+
+[1..]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List UniversalSegment PositiveInteger
+
+
+
+
+
+
+
+
+expand(%)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
0.6.3 Streams
+
+
+
Streams are infinite lists which have the ability to calculate the next
+element should it be required. For example, a stream of positive integers
+and a list of prime numbers can be generated by:
+
+
+
+
+
+
+
+[i for i in 1..]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream PositiveInteger
+
+
+
+
+
+
+
+
+[i for i in 1.. | prime?(i)]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream PositiveInteger
+
+
+
+
+
In each case the first few elements of the stream are calculated for display
+purposes but the rest of the stream remains unevaluated. The value of items
+in a stream are only calculated when they are needed which gives rise to
+their alternative name of ``lazy lists''.
+
+
+
+
Another method of creating streams is to use the generate(f,a) function.
+This applies its first argument repeatedly onto its second to produce the
+stream . Given that the function
+ nextPrime returns the lowest prime number greater than its argument we
+can generate a stream of primes as follows:
+
+
+
+
+
+
+generate(nextPrime,2)$Stream Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Integer
+
+
+
+
+
As a longer example a stream of Fibonacci numbers will be computed. The
+Fibonacci numbers start at and each following number is the addition
+of the two numbers that precede it so the Fibonacci sequence is:
+.
+
+
+
+
Since the generation of any Fibonacci number only relies on knowing the
+previous two numbers we can look at the series through a window of two
+elements. To create the series the window is placed at the start over
+the values and their sum obtained. The window is now shifted to
+the right by one position and the sum placed into the empty slot of the
+window; the process is then repeated. To implement this we require a
+function that takes a list of two elements (the current view of the window),
+adds them, and outputs the new window. The result is the function
+ :
+
+
+
+
+
+
+win : List Integer -> List Integer
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+win(x) == [x.2, x.1 + x.2]
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+win([1,1])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
+
+
+
+win(%)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
Thus it can be seen that repeatedly applying win to the results
+of the previous invocation each element of the series is obtained. Clearly
+ win is an ideal function to construct streams using the generate
+function:
+
+
+
+
+
+
+fibs := [generate(win,[1,1])]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream List Integer
+
+
+
+
+
This isn't quite what is wanted -- we need to extract the first element of
+each list and place that in our series:
+
+
+
+
+
+
+fibs := [i.1 for i in [generate(win,[1,1])] ]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Integer
+
+
+
+
+
Obtaining the 200th Fibonacci number is trivial:
+
+
+
+
+
+
+fibs.200
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
One other function of interest is complete which expands a finite
+stream derived from an infinite one (and thus was still stored as an
+infinite stream) to form a finite stream.
+
+
+
+
+
+
+
+
+
+
+
+
0.6.4 Arrays, Vectors, Strings, and Bits
+
+
+
The simplest array data structure is the one-dimensional array which
+can be obtained by applying the oneDimensionalArray function to a list:
+
+
+
+
+
+
+oneDimensionalArray([7,2,5,4,1,9])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: OneDimensionalArray PositiveInteger
+
+
+
+
+
One-dimensional array are homogenous (all elements must have the same type)
+and mutable (elements can be changed) like lists but unlike lists they are
+constant in size and have uniform access times (it is just as quick to read
+the last element of a one-dimensional array as it is to read the first; this
+is not true for lists).
+
+
+
+
Since these arrays are mutable all the warnings that apply to lists apply to
+arrays. That is, it is possible to modify an element in a copy of an array
+and change the original:
+
+
+
+
+
+
+x := oneDimensionalArray([7,2,5,4,1,9])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: OneDimensionalArray PositiveInteger
+
+
+
+
+
+
+
+
+y := x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: OneDimensionalArray PositiveInteger
+
+
+
+
+
+
+
+
+y.3 := 20 ; x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: OneDimensionalArray PositiveInteger
+
+
+
+
+
Note that because these arrays are of fixed size the concat! function
+cannot be applied to them without generating an error. If arrays of this
+type are required use the FlexibleArray constructor.
+
+
+
+
One-dimensional arrays can be created using new which specifies the size
+of the array and the initial value for each of the elements. Other operations
+that can be applied to one-dimensional arrays are map! which applies
+a mapping onto each element, swap! which swaps two elements and
+ copyInto!(a,b,c) which copies the array b onto a starting at
+position c.
+
+
+
+
+
+
+a : ARRAY1 PositiveInteger := new(10,3)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: OneDimensionalArray PositiveInteger
+
+
+
+
+
(note that ARRAY1 is an abbreviation for the type
+OneDimensionalArray.) Other types based on one-dimensional arrays are
+Vector, String, and Bits.
+
+
+
+
+
+
+
+map!(i +-> i+1,a); a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: OneDimensionalArray PositiveInteger
+
+
+
+
+
+
+
+
+b := oneDimensionalArray([2,3,4,5,6])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: OneDimensionalArray PositiveInteger
+
+
+
+
+
+
+
+
+swap!(b,2,3); b
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: OneDimensionalArray PositiveInteger
+
+
+
+
+
+
+
+
+copyInto!(a,b,3)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: OneDimensionalArray PositiveInteger
+
+
+
+
+
+
+
+
+a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: OneDimensionalArray PositiveInteger
+
+
+
+
+
+
+
+
+vector([1/2,1/3,1/14])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Vector Fraction Integer
+
+
+
+
+
+
+
+
+"Hello, World"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
+
+
+
+bits(8,true)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Bits
+
+
+
+
+
A vector is similar to a one-dimensional array except that if its
+components belong to a ring then arithmetic operations are provided.
+
+
+
+
+
+
+
+
+
+
+
+
0.6.5 Flexible Arrays
+
+
+
Flexible arrays are designed to provide the efficiency of one-dimensional
+arrays while retaining the flexibility of lists. They are implemented by
+allocating a fixed block of storage for the array. If the array needs to
+be expanded then a larger block of storage is allocated and the contents
+of the old block are copied into the new one.
+
+
+
+
There are several operations that can be applied to this type, most of
+which modify the array in place. As a result these functions all have
+names ending in ``!''. The physicalLength returns the actual length
+of the array as stored in memory while the physicalLength! allows this
+value to be changed by the user.
+
+
+
+
+
+
+f : FARRAY INT := new(6,1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FlexibleArray Integer
+
+
+
+
+
+
+
+
+f.1:=4; f.2:=3 ; f.3:=8 ; f.5:=2 ; f
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FlexibleArray Integer
+
+
+
+
+
+
+
+
+insert!(42,f,3); f
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FlexibleArray Integer
+
+
+
+
+
+
+
+
+insert!(28,f,8); f
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FlexibleArray Integer
+
+
+
+
+
+
+
+
+removeDuplicates!(f)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FlexibleArray Integer
+
+
+
+
+
+
+
+
+delete!(f,5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FlexibleArray Integer
+
+
+
+
+
+
+
+
+g:=f(3..5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FlexibleArray Integer
+
+
+
+
+
+
+
+
+g.2:=7; f
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FlexibleArray Integer
+
+
+
+
+
+
+
+
+insert!(g,f,1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FlexibleArray Integer
+
+
+
+
+
+
+
+
+physicalLength(f)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+physicalLength!(f,20)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FlexibleArray Integer
+
+
+
+
+
+
+
+
+merge!(sort!(f),sort!(g))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FlexibleArray Integer
+
+
+
+
+
+
+
+
+shrinkable(false)$FlexibleArray(Integer)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
There are several things to point out concerning these
+examples. First, although flexible arrays are mutable, making copies
+of these arrays creates separate entities. This can be seen by the
+fact that the modification of element b.2 above did not alter
+a. Second, the merge! function can take an extra argument
+before the two arrays are merged. The argument is a comparison
+function and defaults to ``<='' if omitted. Lastly,
+ shrinkable tells the system whether or not to let flexible arrays
+contract when elements are deleted from them. An explicit package
+reference must be given as in the example above.
+
By now the reader should be able to construct simple one-line expressions
+involving variables and different data structures. This section builds on
+this knowledge and shows how to use iteration, make choices, and build
+functions in Axiom. At the moment it is assumed that the reader has a rough
+idea of how types are specified and constructed so that they can follow
+the examples given.
+
+
+
+
From this point on most examples will be taken from input files.
+
+
+
+
+
+
+
0.7.1 Reading Code from a File
+
+
+
Input files contain code that will be fed to the command prompt. The
+primary different between the command line and an input file is that
+indentation matters. In an input file you can specify ``piles'' of code
+by using indentation.
+
+
+
+
The names of all input files in Axiom should end in ``.input'' otherwise
+Axiom will refuse to read them.
+
+
+
+
If an input file is named foo.input you can feed the contents of
+the file to the command prompt (as though you typed them) by writing:
+ )read foo.input.
+
+
+
+
It is good practice to start each input file with the )clear all
+command so that all functions and variables in the current environment
+are erased.
+
+
+
+
+
+
+
+
+
+
+
0.7.2 Blocks
+
+
+
The Axiom constructs that provide looping, choices, and user-defined
+functions all rely on the notion of blocks. A block is a sequence of
+expressions which are evaluated in the order that they appear except
+when it is modified by control expressions such as loops. To leave a
+block prematurely use an expression of the form:
+BoolExpr=>Expr
+where BoolExpr is any Axiom expression that has type Boolean.
+The value and type of Expr determines the value and type returned
+by the block.
+
+
+
+
If blocks are entered at the keyboard (as opposed to reading them from
+a text file) then there is only one way of creating them. The syntax is:
+
+
+
+
+
In an input file a block can be constructed as above or by placing all the
+statements at the same indentation level. When indentation is used to
+indicate program structure the block is called a pile. As an example
+of a simple block a list of three integers can be constructed using
+parentheses:
+
+
+
+
+
+
+( a:=4; b:=1; c:=9; L:=[a,b,c])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
Doing the same thing using piles in an input file you could type:
+
+
+
+
+
+L :=
+ a:=4
+ b:=1
+ c:=9
+ [a,b,c]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
Since blocks have a type and a value they can be used as arguments to
+functions or as part of other expressions. It should be pointed out that
+the following example is not recommended practice but helps to illustrate
+the idea of blocks and their ability to return values:
+
+
+
+
+
+sqrt(4.0 +
+ a:=3.0
+ b:=1.0
+ c:=a + b
+ c
+ )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
Note that indentation is extremely important. If the example above
+had the pile starting at ``a:='' moved left by two spaces so that the
+``a'' was under the ``('' of the first line then the interpreter would
+signal an error. Furthermore if the closing parenthesis ``)'' is moved
+up to give
+
+
+
+
+
+sqrt(4.0 +
+ a:=3.0
+ b:=1.0
+ c:=a + b
+ c)
+
+
+
+
+
+
+ Line 1: sqrt(4.0 +
+ ....A
+ Error A: Missing mate.
+ Line 2: a:=3.0
+ Line 3: b:=1.0
+ Line 4: c:=a + b
+ Line 5: c)
+ .........AB
+ Error A: (from A up to B) Ignored.
+ Error B: Improper syntax.
+ Error B: syntax error at top level
+ Error B: Possibly missing a )
+ 5 error(s) parsing
+
+
+
+
then the parser will generate errors. If the parenthesis is shifted right
+by several spaces so that it is in line with the ``c'' thus:
+
+
+
+
+
+sqrt(4.0 +
+ a:=3.0
+ b:=1.0
+ c:=a + b
+ c
+ )
+
+
+
+
+
+
+ Line 1: sqrt(4.0 +
+ ....A
+ Error A: Missing mate.
+ Line 2: a:=3.0
+ Line 3: b:=1.0
+ Line 4: c:=a + b
+ Line 5: c
+ Line 6: )
+ .........A
+ Error A: (from A up to A) Ignored.
+ Error A: Improper syntax.
+ Error A: syntax error at top level
+ Error A: Possibly missing a )
+ 5 error(s) parsing
+
+
+
+
a similar error will be raised. Finally, the ``)'' must be indented by
+at least one space relative to the sqrt thus:
+
+
+
+
+
+sqrt(4.0 +
+ a:=3.0
+ b:=1.0
+ c:=a + b
+ c
+ )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
or an error will be generated.
+
+
+
+
It can be seen that great care needs to be taken when constructing input
+files consisting of piles of expressions. It would seem prudent to add
+one pile at a time and check if it is acceptable before adding more,
+particularly if piles are nested. However, it should be pointed out that
+the use of piles as values for functions is not very readable and so
+perhaps the delicate nature of their interpretation should deter programmers
+from using them in these situations. Using piles should really be restricted
+to constructing functions, etc. and a small amount of rewriting can remove
+the need to use them as arguments. For example, the previous block could
+easily be implemented as:
+
+
+
+
+
+a:=3.0
+b:=1.0
+c:=a + b
+sqrt(4.0 + c)
+
+
+
+
+
+
+a:=3.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+b:=1.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+c:=a + b
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+sqrt(4.0 + c)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
which achieves the same result and is easier to understand. Note that this
+is still a pile but it is not as fragile as the previous version.
+
+
+
+
+
+
+
+
+
+
+
0.7.3 Functions
+
+
+
Definitions of functions in Axiom are quite simple providing two things
+are observed. First, the type of the function must either be completely
+specified or completely unspecified. Second, the body of the function is
+assigned to the function identifier using the delayed assignment operator
+``==''.
+
+
+
+
To specify the type of something the ``:'' operator is used. Thus to define
+a variable x to be of type Fraction Integer we enter:
+
+
+
+
+
+
+x : Fraction Integer
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
For functions the method is the same except that the arguments are
+placed in parentheses and the return type is placed after the symbol
+``->''. Some examples of function definitions taking zero, one,
+two, or three arguments and returning a list of integers are:
+
+ Compiling function f with type () -> List Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
+
+
+
+g(4)
+
+
+
+
+
+
+
+ Compiling function g with type Integer -> List Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
+
+
+
+h(2,9)
+
+
+
+
+
+
+
+ Compiling function h with type (Integer,Integer) -> List Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
+
+
+
+k(-3,42,100)
+
+
+
+
+
+
+
+ Compiling function k with type (Integer,Integer,Integer) -> List
+ Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
The value returned by a function is either the value of the last expression
+evaluated or the result of a return statement. For example, the
+following are effectively the same:
+
+
+
+
+
+
+p : Integer -> Integer
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+p x == (a:=1; b:=2; a+b+x)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+p x == (a:=1; b:=2; return(a+b+x))
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Note that a block (pile) is assigned to the function identifier p and
+thus all the rules about blocks apply to function definitions. Also there was
+only one argument so the parenthese are not needed.
+
+
+
+
This is basically all that one needs to know about defining functions in
+Axiom -- first specify the complete type and then assign a block to the
+function name. The rest of this section is concerned with defining more
+complex blocks than those in this section and as a result function definitions
+will crop up continually particularly since they are a good way of testing
+examples. Since the block structure is more complex we will use the pile
+notation and thus have to use input files to read the piles.
+
+
+
+
+
+
+
+
+
+
+
+
0.7.4 Choices
+
+
+
Apart from the ``=>'' operator that allows a block to exit before the end
+Axiom provides the standard if-then-else construct. The general
+syntax is:
+
+
+
+
+
+
+
+
if BooleanExpr then Expr1 else Expr2
+
+
+
+
+
+
+
+
where ``else Expr2'' can be omitted. If the expression BooleanExpr
+evaluates to true then Expr1 is executed otherwise Expr2
+(if present) will be executed. An example of piles and if-then-else is:
+(read from an input file)
+
+
+
+
+
+h := 2.0
+if h > 3.1 then
+ 1.0
+ else
+ z:= cos(h)
+ max(x,0.5)
+
+
+
+
+
+
+h := 2.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+if h > 3.1 then
+ 1.0
+ else
+ z:= cos(h)
+ max(x,0.5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Float
+
+
+
+
+
Note the indentation -- the ``else'' must be indented relative to the ``if''
+otherwise it will generate an error (Axiom will think there are two piles,
+the second one beginning with ``else'').
+
+
+
+
Any expression that has type Boolean can be used as BooleanExpr
+and the most common will be those involving the relational operators `` '',
+`` '', and ``=''. Usually the type of an expression involving the equality
+operator ``='' will be Boolean but in those situations when it isn't
+you may need to use the ``@'' operator to ensure that it is.
+
+
+
+
+
+
+
+
+
+
+
+
0.7.5 Loops
+
+
+
Loops in Axiom are regarded as expressions containing another expression
+called the loop body. The loop body is executed zero or more times
+depending on the kind of loop. Loops can be nested to any depth.
+
+
+
+
+
+
+
0.7.5.1 The repeat loop
+
+
+
The simplest kind of loop provided by Axiom is the repeat loop. The
+general syntax of this is:
+
+
repeat loopBody
+
+
+
This will cause Axiom to execute loopBody repeatedly until either a
+ break or return statement is encountered. If loopBody
+contains neither of these statements then it will loop forever. The
+following piece of code will display the numbers from to :
+
+
+
+
+
+i:=1
+repeat
+ if i > 4 then break
+ output(i)
+ i:=i+1
+
+
+
+
+
+
+i:=1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+repeat
+ if i > 4 then break
+ output(i)
+ i:=i+1
+
+ 1
+ 2
+ 3
+ 4
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
It was mentioned that loops will only be left when either a break or
+ return statement is encountered so why can't one use the ``=>''
+operator? The reason is that the ``=>'' operator tells Axiom to leave the
+current block whereas break leaves the current loop. The return
+statement leave the current function.
+
+
+
+
To skip the rest of a loop body and continue the next iteration of the loop
+use the iterate statement (the -- starts a comment in Axiom)
+
+
+
+
+
+i := 0
+repeat
+ i := i + 1
+ if i > 6 then break
+ -- Return to start if i is odd
+ if odd?(i) then iterate
+ output(i)
+
+
+
+
+
+
+i := 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: NonNegativeInteger
+
+
+
+
+
+
+
+repeat
+ i := i + 1
+ if i > 6 then break
+ -- Return to start if i is odd
+ if odd?(i) then iterate
+ output(i)
+
+ 2
+ 4
+ 6
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+
+
+
+
+
0.7.5.2 The while loop
+
+
+
The while statement extends the basic repeat loop to place the control
+of leaving the loop at the start rather than have it buried in the middle.
+Since the body of the loop is still part of a repeat loop, break
+and ``=>'' work in the same way as in the previous section. The general
+syntax of a while loop is:
+
+
+
+
+
+
+
+
while BoolExpr repeat loopBody
+
+
+
+
+
+
+
+
As before, BoolExpr must be an expression of type Boolean. Before
+the body of the loop is executed BoolExpr is tested. If it evaluates to
+true then the loop body is entered otherwise the loop is terminated.
+Multiple conditions can be applied using the logical operators such as
+ and or by using several while statements before the repeat.
+
+
+
+
+
+x:=1
+y:=1
+while x < 4 and y < 10 repeat
+ output [x,y]
+ x := x + 1
+ y := y + 2
+
+
+
+
+
+
+x:=1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+y:=1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+while x < 4 and y < 10 repeat
+ output [x,y]
+ x := x + 1
+ y := y + 2
+
+ [1,1]
+ [2,3]
+ [3,5]
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+x:=1
+y:=1
+while x < 4 while y < 10 repeat
+ output [x,y]
+ x := x + 1
+ y := y + 2
+
+
+
+
+
+
+x:=1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+y:=1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+while x < 4 while y < 10 repeat
+ output [x,y]
+ x := x + 1
+ y := y + 2
+
+ [1,1]
+ [2,3]
+ [3,5]
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Note that the last example using two while statements is not a
+nested loop but the following one is:
+
+
+
+
+
+x:=1
+y:=1
+while x < 4 repeat
+ while y < 10 repeat
+ output [x,y]
+ x := x + 1
+ y := y + 2
+
+
+
+
+
+
+x:=1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+y:=1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+while x < 4 repeat
+ while y < 10 repeat
+ output [x,y]
+ x := x + 1
+ y := y + 2
+
+ [1,1]
+ [2,3]
+ [3,5]
+ [4,7]
+ [5,9]
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Suppose we that, given a matrix of arbitrary size, find the position and
+value of the first negative element by examining the matrix in row-major
+order:
+
+
+
+
+
+m := matrix [ [ 21, 37, 53, 14 ],_
+ [ 8, 22,-24, 16 ],_
+ [ 2, 10, 15, 14 ],_
+ [ 26, 33, 55,-13 ] ]
+
+lastrow := nrows(m)
+lastcol := ncols(m)
+r := 1
+while r <= lastrow repeat
+ c := 1 -- Index of first column
+ while c <= lastcol repeat
+ if elt(m,r,c) < 0 then
+ output [r,c,elt(m,r,c)]
+ r := lastrow
+ break -- Don't look any further
+ c := c + 1
+ r := r + 1
+
+while r <= lastrow repeat
+ c := 1 -- Index of first column
+ while c <= lastcol repeat
+ if elt(m,r,c) < 0 then
+ output [r,c,elt(m,r,c)]
+ r := lastrow
+ break -- Don't look any further
+ c := c + 1
+ r := r + 1
+
+ [2,3,- 24]
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+
+
+
+
+
0.7.5.3 The for loop
+
+
+
The last loop statement of interest is the for loop. There are two
+ways of creating a for loop. The first way uses either a list or
+a segment:
+
+
+
+
+
+
+
+
for var in seg repeat loopBody
+for var in list repeat loopBody
+
+
+
+
+
+
+
+
where var is an index variable which is iterated over the values in
+seg or list. The value seg is a segment such as
+or and list is a list of some type. For example:
+
+for w in ["This", "is", "your", "life!"] repeat
+ output(w)
+
+
+
+
+
+
+for w in ["This", "is", "your", "life!"] repeat
+ output(w)
+
+ This
+ is
+ your
+ life!
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
The second form of the for loop syntax includes a `` such that''
+clause which must be of type Boolean:
+
+
+
+
+
+
+
+
for var in seg | BoolExpr repeat loopBody
+for var in list | BoolExpr repeat loopBody
+
+
+
+
+
+
+
+
Some examples are:
+
+
+
+
+
+for i in 1..10 | prime?(i) repeat
+ output(i)
+
+ 2
+ 3
+ 5
+ 7
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+for i in [1,2,3,4,5,6,7,8,9,10] | prime?(i) repeat
+ output(i)
+
+ 2
+ 3
+ 5
+ 7
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
You can also use a while clause:
+
+
+
+
+
+for i in 1.. while i < 7 repeat
+ if even?(i) then output(i)
+
+ 2
+ 4
+ 6
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Using the `` such that'' clause makes this appear simpler:
+
+
+
+
+
+
+for i in 1.. | even?(i) while i < 7 repeat
+ output(i)
+
+ 2
+ 4
+ 6
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
You can use multiple for clauses to iterate over several sequences
+in parallel:
+
+
+
+
+
+for a in 1..4 for b in 5..8 repeat
+ output [a,b]
+
+ [1,5]
+ [2,6]
+ [3,7]
+ [4,8]
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
As a general point it should be noted that any symbols referred to in the
+`` such that'' and while clauses must be pre-defined. This
+either means that the symbols must have been defined in an outer level
+(e.g. in an enclosing loop) or in a for clause appearing before the
+`` such that'' or while. For example:
+
+
+
+
+
+for a in 1..4 repeat
+ for b in 7..9 | prime?(a+b) repeat
+ output [a,b,a+b]
+
+ [2,9,11]
+ [3,8,11]
+ [4,7,11]
+ [4,9,13]
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Finally, the for statement has a by clause to specify the
+step size. This makes it possible to iterate over the segment in
+reverse order:
+
+
+
+
+
+
+for a in 1..4 for b in 8..5 by -1 repeat
+ output [a,b]
+
+ [1,8]
+ [2,7]
+ [3,6]
+ [4,5]
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Note that without the ``by -1'' the segment 8..5 is empty so there is
+nothing to iterate over and the loop exits immediately.
+
When we start cataloging the gains in tools sitting on a computer, the
+benefits of software are amazing. But, if the benefits of software are
+so great, why do we worry about making it easier -- don't the ends pay
+for the means? We worry becuase making such software is extraordinarily
+hard and almost no one can do it -- the detail is exhausting, the
+creativity required is extreme, the hours of failure upon failure
+requiring patience and persistence would tax anyone claiming to be
+sane. Yet we require people with such characteristics be found and
+employed and employed cheaply.
+
+
+
+
-- Christopher Alexander
+
+
+
+
(from Patterns of Software by Richard Gabriel)
+
+
+
+
+
+
+
+
+
+
+
+
Welcome to the Axiom environment for interactive computation and
+problem solving. Consider this chapter a brief, whirlwind tour of the
+Axiom world. We introduce you to Axiom's graphics and the
+Axiom language. Then we give a sampling of the large variety of
+facilities in the Axiom system, ranging from the various kinds
+of numbers, to data types (like lists, arrays, and sets) and
+mathematical objects (like matrices, integrals, and differential
+equations). We conclude with the discussion of system commands and an
+interactive ``undo.''
+
+
+
+
Before embarking on the tour, we need to brief those readers working
+interactively with Axiom on some details.
+
You need to know how to start the Axiom system and how to stop it.
+We assume that Axiom has been correctly installed on your
+machine (as described in another Axiom document).
+
+
+
+
To begin using Axiom, issue the command axiom to the
+Axiom operating system shell.
+axiom @ axiom There is a brief pause, some start-up
+messages, and then one or more windows appear.
+
+
+
+
If you are not running Axiom under the X Window System, there is
+only one window (the console). At the lower left of the screen there
+is a prompt that prompt looks like
+
+
+
+
+
+(1) ->
+
+
+
+
+
When you want to enter input to Axiom, you do so on the same
+line after the prompt. The ``1'' in ``(1)'', also called the equation
+number, is the computation step number and is incremented
+step number after you enter Axiom statements.
+Note, however, that a system command such as )clear all
+may change the step number in other ways. We talk about step numbers
+more when we discuss system commands and the workspace history facility.
+
+
+
+
If you are running Axiom under the X Window System, there may be
+two X Window System windows: the console window (as just
+described) and the HyperDoc main menu. Hyper@{HyperDoc}
+HyperDoc is a multiple-window hypertext system
+that lets you window view Axiom documentation and
+examples on-line, execute Axiom expressions, and generate
+graphics. If you are in a graphical windowing environment, it is
+usually started automatically when Axiom begins. If it is not
+running, issue )hd to start it. We discuss the basics of
+HyperDoc in Chapter ugHyper .
+
+
+
+
To interrupt an Axiom computation, hold down the interrupt
+ Ctrl (control) key and press c. This brings you back to
+the Axiom prompt.
+
+
+
+
+
+
+
+
+
+
+
+
+
To exit from Axiom, move to the console window, stopping
+@{stopping Axiom} type )quitexiting @{exiting
+Axiom} at the input prompt and press the Enter key.
+You will probably be prompted with the following
+message:
+
+
+
+
+
+
+
+
Please enter y or yes if you really want to leave the
+interactive environment and return to the operating system
+
+
+
+
+
+
+
+
You should respond yes, for example, to exit Axiom.
+
+
+
+
+
+
+
+
+
+
We are purposely vague in describing exactly what your screen looks
+like or what messages Axiom displays. Axiom runs on a number of
+different machines, operating systems and window environments, and
+these differences all affect the physical look of the system. You can
+also change the way that Axiom behaves via system commands
+described later in this chapter and in Appendix A.
+System commands are special commands, like )set, that begin with
+a closing parenthesis and are used to change your environment. For
+example, you can set a system variable so that you are not prompted
+for confirmation when you want to leave Axiom.
+
+
+
+
+
+
+
1.1.1 Clef
+
+
+
+
+
If you are using Axiom under the X Window System, the
+Clefcommand line editor Clef command
+line editor is probably available and installed. With this editor you
+can recall previous lines with the up and down arrow keys. To move
+forward and backward on a line, use the right and left arrows. You
+can use the Insert key to toggle insert mode on or off. When
+you are in insert mode, the cursor appears as a large block and if you
+type anything, the characters are inserted into the line without
+deleting the previous ones.
+
+
+
+
If you press the Home key, the cursor moves to the beginning of
+the line and if you press the End key, the cursor moves to the
+end of the line. Pressing Ctrl-End deletes all the text from
+the cursor to the end of the line.
+
+
+
+
Clef also provides Axiom operation name completion for
+operation name completion a limited set of operations. If you
+enter a few letters and then press the Tab key, Clef tries to
+use those letters as the prefix of an Axiom operation name. If
+a name appears and it is not what you want, press Tab again to
+see another name.
+
+
+
+
You are ready to begin your journey into the world of Axiom.
+
Axiom also provides power series. series:power By default,
+Axiom tries to compute and display the first ten elements of a series.
+Use )set streams calculate to change the default value to
+something else. For the purposes of this document, we have used this
+system command to display fewer than ten terms. For more information
+about working with series, see ugProblemSeries.
+
+
+
+
You can convert a functional expression to a power series by using the
+operation series. In this example, sin(a*x) is
+expanded in powers of , that is, in powers of .
+
Axiom provides series:PuiseuxPuiseux series:
+Puiseux series series with rational number exponents. The
+first argument to series is an in-place function that
+computes the -th coefficient. (Recall that the
+``+->'' is an infix operator meaning ``maps to.'')
+
Use the Axiom function D to differentiate an
+derivative expression. differentiation
+
+
+
+
To find the derivative of an expression with respect to a
+variable , enter D(f, x).
+
+
+
+
+
+
+
+f := exp exp x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
+
+
+
+D(f, x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
An optional third argument in D asks Axiom for the -th
+derivative of . This finds the fourth derivative of with
+respect to .
+
+
+
+
+
+
+
+D(f, x, 4)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
You can also compute partial derivatives by specifying the order of
+differentiation:partial
+differentiation.
+
+
+
+
+
+
+g := sin(x**2 + y)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
+
+
+
+D(g, y)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
+
+
+
+D(g, [y, y, x, x])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
Axiom can manipulate the derivatives (partial and iterated) of
+differentiation:formal expressions involving formal operators.
+All the dependencies must be explicit.
+
+
+
+
This returns since F (so far) does not explicitly depend on .
+
+
+
+
+
+
+
+D(F,x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
Suppose that we have F a function of , , and ,
+where and are themselves functions of .
+
+
+
+
Start by declaring that , , and are operators.
+operator
+
+
+
+
+
+
+
+F := operator 'F; x := operator 'x; y := operator 'y
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: BasicOperator
+
+
+
+
+
You can use F, , and in expressions.
+
+
+
+
+
+
+
+a := F(x z, y z, z**2) + x y(z+1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
Differentiate formally with respect to .
+The formal derivatives appearing in are not just formal symbols,
+but do represent the derivatives of , , and F.
+
+
+
+
+
+
+
+dadz := D(a, z)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
+
You can evaluate the above for particular functional values of
+F, , and . If is exp(z) and is log(z+1),
+then evaluates dadz.
+
+
+
+
+
+
+
+eval(eval(dadz, 'x, z +-> exp z), 'y, z +-> log(z+1))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
You obtain the same result by first evaluating and
+then differentiating.
+
+
+
+
+
+
+
+eval(eval(a, 'x, z +-> exp z), 'y, z +-> log(z+1))
+
+
Axiom has extensive library facilities for integration.
+integration
+
+
+
+
The first example is the integration of a fraction with denominator
+that factors into a quadratic and a quartic irreducible polynomial.
+The usual partial fraction approach used by most other computer
+algebra systems either fails or introduces expensive unneeded
+algebraic numbers.
+
+
+
+
We use a factorization-free algorithm.
+
+
+
+
+
+
+integrate((x**2+2*x+1)/((x+1)**6+1),x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(Expression Integer,...)
+
+
+
+
+
When real parameters are present, the form of the integral can depend on
+the signs of some expressions.
+
+
+
+
Rather than query the user or make sign assumptions, Axiom returns
+all possible answers.
+
+
+
+
+
+
+integrate(1/(x**2 + a),x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(List Expression Integer,...)
+
+
+
+
+
The integrate operation generally assumes that all
+parameters are real. The only exception is when the integrand has
+complex valued quantities.
+
+
+
+
If the parameter is complex instead of real, then the notion of sign
+is undefined and there is a unique answer. You can request this
+answer by ``prepending'' the word ``complex'' to the command name:
+
+
+
+
+
+
+
+complexIntegrate(1/(x**2 + a),x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
The following two examples illustrate the limitations of table-based
+approaches. The two integrands are very similar, but the answer to
+one of them requires the addition of two new algebraic numbers.
+
+
+
+
This one is the easy one.
+The next one looks very similar
+but the answer is much more complicated.
+
+
+
+
+
+
+integrate(x**3 / (a+b*x)**(1/3),x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(Expression Integer,...)
+
+
+
+
+
Only an algorithmic approach is guaranteed to find what new constants
+must be added in order to find a solution.
+
+
+
+
+
+
+
+integrate(1 / (x**3 * (a+b*x)**(1/3)),x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(Expression Integer,...)
+
+
+
+
+
Some computer algebra systems use heuristics or table-driven
+approaches to integration. When these systems cannot determine the
+answer to an integration problem, they reply ``I don't know.'' Axiom
+uses an algorithm which is a decision procedure for integration.
+If Axiom returns the original integral that conclusively proves that
+an integral cannot be expressed in terms of elementary functions.
+
+
+
+
When Axiom returns an integral sign, it has proved that no answer
+exists as an elementary function.
+
+
+
+
+
+
+
+integrate(log(1 + sqrt(a*x + b)) / x,x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(Expression Integer,...)
+
+
+
+
+
Axiom can handle complicated mixed functions much beyond what you
+can find in tables.
+
+
+
+
Whenever possible, Axiom tries to express the answer using the
+functions present in the integrand.
+
Rather than attempting to get a closed form solution of
+a differential equation, you instead might want to find an
+approximate solution in the form of a series.
+
+
+
+
Let's solve a system of nonlinear first order equations and get a
+solution in power series. Tell Axiom that is also an
+operator.
+
+
+
+
+
+
+
+x := operator 'x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: BasicOperator
+
+
+
+
+
Here are the two equations forming our system.
+
+
+
+
+
+
+eq1 := D(x(t), t) = 1 + x(t)**2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Equation Expression Integer
+
+
+
+
+
+
+
+
+eq2 := D(y(t), t) = x(t) * y(t)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Equation Expression Integer
+
+
+
+
+
We can solve the system around with the initial
+conditions and . Notice that since
+we give the unknowns in the order , the answer is a list
+of two series in the order
+.
+
Axiom also has state-of-the-art algorithms for the solution of
+systems of polynomial equations. When the number of equations and
+unknowns is the same, and you have no symbolic coefficients, you can
+use solve for real roots and complexSolve for
+complex roots. In each case, you tell Axiom how accurate you
+want your result to be. All operations in the solve family
+return answers in the form of a list of solution sets, where each
+solution set is a list of equations.
+
+
+
+
A system of two equations involving a symbolic parameter .
+
+
+
+
+
+
+S(t) == [x**2-2*y**2 - t,x*y-y-5*x + 5]
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Find the real roots of with
+rational arithmetic, correct to within .
+
+
+
+
+
+
+solve(S(19),1/10**20)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List List Equation Polynomial Fraction Integer
+
+
+
+
+
Find the complex roots of with floating
+point coefficients to digits accuracy in the mantissa.
+
+
+
+
+
+
+
+complexSolve(S(19),10.e-20)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List List Equation Polynomial Complex Float
+
+
+
+
+
If a system of equations has symbolic coefficients and you want
+a solution in radicals, try radicalSolve.
+
+
+
+
+
+
+radicalSolve(S(a),[x,y])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List List Equation Expression Integer
+
+
+
+
+
For systems of equations with symbolic coefficients, you can apply
+ solve, listing the variables that you want Axiom to
+solve for. For polynomial equations, a solution cannot usually be
+expressed solely in terms of the other variables. Instead, the
+solution is presented as a ``triangular'' system of equations, where
+each polynomial has coefficients involving only the succeeding
+variables. This is analogous to converting a linear system of
+equations to ``triangular form''.
+
+
+
+
A system of three equations in five variables.
+
+
+
+
+
+
+eqns := [x**2 - y + z,x**2*z + x**4 - b*y, y**2 *z - a - b*x]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Polynomial Integer
+
+
+
+
+
Solve the system for unknowns ,
+reducing the solution to triangular form.
+
+
+
+
+
+
+solve(eqns,[x,y,z])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List List Equation Fraction Polynomial Integer
+
We conclude our tour of Axiom with a brief discussion of
+system commands. System commands are special statements
+that start with a closing parenthesis ()). They are used
+to control or display your Axiom environment, start the
+HyperDoc system, issue operating system commands and leave
+Axiom. For example, )system is used to issue commands
+to the operating system from Axiom. Here
+is a brief description of some of these commands. For more
+information on specific commands, see Appendix A .
+
+
+
+
+
Perhaps the most important user command is the )clear all
+command that initializes your environment. Every section and
+subsection in this document has an invisible )clear all that is
+read prior to the examples given in the section. )clear all
+gives you a fresh, empty environment with no user variables defined
+and the step number reset to . The )clear command
+can also be used to selectively clear values and properties of system
+variables.
+
+
+
+
+
Another useful system command is )read. A preferred way to
+develop an application in Axiom is to put your interactive
+commands into a file, say my.input file. To get Axiom to
+read this file, you use the system command )read my.input.
+If you need to make changes to your approach or definitions, go into
+your favorite editor, change my.input, then )read
+my.input again.
+
+
+
+
+
Other system commands include: )history, to display
+previous input and/or output lines; )display, to display
+properties and values of workspace variables; and )what.
+
+
+
+
+
Issue )what to get a list of Axiom objects that
+contain a given substring in their name.
+
+
+
+
+
+
+
+
+)what operations integrate
+
+
+
+
+
+
+
+
+Operations whose names satisfy the above pattern(s):
+
+HermiteIntegrate algintegrate complexIntegrate
+expintegrate extendedIntegrate fintegrate
+infieldIntegrate integrate internalIntegrate
+internalIntegrate0 lazyGintegrate lazyIntegrate
+lfintegrate limitedIntegrate monomialIntegrate
+nagPolygonIntegrate palgintegrate pmComplexintegrate
+pmintegrate primintegrate tanintegrate
+
+To get more information about an operation such as
+limitedIntegrate , issue the command )display op limitedIntegrate
+
+
+
+
+
+
+
+
1.15.1 Undo
+
+
+
+
+
+
+
A useful system command is )undo. Sometimes while computing
+interactively with Axiom, you make a mistake and enter an
+incorrect definition or assignment. Or perhaps you need to try one of
+several alternative approaches, one after another, to find the best
+way to approach an application. For this, you will find the
+undo facility of Axiom helpful.
+
+
+
+
+
System command )undo n means ``undo back to step
+''; it restores the values of user variables to those that
+existed immediately after input expression was evaluated.
+Similarly, )undo -n undoes changes caused by the last
+ input expressions. Once you have done an )undo,
+you can continue on from there, or make a change and redo all
+your input expressions from the point of the )undo forward.
+The )undo is completely general: it changes the environment
+like any user expression. Thus you can )undo any previous
+undo.
+
+
+
+
+
Here is a sample dialogue between user and Axiom.
+
+
+
+
+
``Let me define
+two mutually dependent functions and piece-wise.''
+
+
+
+
+
+
+
+
+f(0) == 1; g(0) == 1
+
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
``Here is the general term for .''
+
+
+
+
+
+
+
+
+f(n) == e/2*f(n-1) - x*g(n-1)
+
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
``And here is the general term for .''
+
+
+
+
+
+
+
+
+g(n) == -x*f(n-1) + d/3*g(n-1)
+
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
``What is value of ?''
+
+
+
+
+
+
+
+
+f(3)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Fraction Integer
+
+
+
+
+
+
``Hmm, I think I want to define differently.
+Undo to the environment right after I defined .''
+
+
+
+
+
+
+)undo 2
+
+
+
+
+
+
+
``Here is how I think I want to be defined instead.''
+
+
+
+
+
+
+
+f(n) == d/3*f(n-1) - x*g(n-1)
+
+
+
+
+
+
+
+
+ 1 old definition(s) deleted for function or rule f
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
Redo the computation from expression forward.
+
+
+
+
+
+
+
+
+)undo )redo
+
+
+
+
+
+
+
+
+g(n) == -x*f(n-1) + d/3*g(n-1)
+
+ Type: Void
+f(3)
+
+ Compiling function g with type Integer -> Polynomial Fraction
+ Integer
+ Compiling function g as a recurrence relation.
+
++++ |*1;g;1;G82322;AUX| redefined
+
++++ |*1;g;1;G82322| redefined
+ Compiling function g with type Integer -> Polynomial Fraction
+ Integer
+ Compiling function g as a recurrence relation.
+
++++ |*1;g;1;G82322;AUX| redefined
+
++++ |*1;g;1;G82322| redefined
+ Compiling function f with type Integer -> Polynomial Fraction
+ Integer
+ Compiling function f as a recurrence relation.
+
++++ |*1;f;1;G82322;AUX| redefined
+
++++ |*1;f;1;G82322| redefined
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Fraction Integer
+
+
+
+
+
+
``I want my old definition of
+ after all. Undo the undo and restore
+the environment to that immediately after .''
+
+
+
+
+
+
+
+
+)undo 4
+
+
+
+
+
+
+
``Check that the value of is restored.''
+
+
+
+
+
+
+
+
+f(3)
+
+
+
+
+
+
+
+
+ Compiling function g with type Integer -> Polynomial Fraction
+ Integer
+ Compiling function g as a recurrence relation.
+
++++ |*1;g;1;G82322;AUX| redefined
+
++++ |*1;g;1;G82322| redefined
+ Compiling function g with type Integer -> Polynomial Fraction
+ Integer
+ Compiling function g as a recurrence relation.
+
++++ |*1;g;1;G82322;AUX| redefined
+
++++ |*1;g;1;G82322| redefined
+ Compiling function f with type Integer -> Polynomial Fraction
+ Integer
+ Compiling function f as a recurrence relation.
+
++++ |*1;f;1;G82322;AUX| redefined
+
++++ |*1;f;1;G82322| redefined
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Fraction Integer
+
+
+
+
+
+
After you have gone off on several tangents, then backtracked to
+previous points in your conversation using )undo, you might
+want to save all the ``correct'' input commands you issued,
+disregarding those undone. The system command )history
+)write mynew.input writes a clean straight-line program onto the file
+ mynew.input on your disk.
+
Axiom has a two- and three-dimensional drawing and rendering
+graphics package that allows you to draw, shade, color,
+rotate, translate, map, clip, scale and combine graphic output of
+Axiom computations. The graphics interface is capable of
+plotting functions of one or more variables and plotting parametric
+surfaces. Once the graphics figure appears in a window, move your
+mouse to the window and click. A control panel appears immediately
+and allows you to interactively transform the object.
+
+
+
+
+
This is an example of Axiom's two-dimensional plotting.
+From the 2D Control Panel you can rescale the plot, turn axes and units
+on and off and save the image, among other things.
+This PostScript image was produced by clicking on the
+ PS 2D Control Panel button.
+
This is an example of Axiom's three-dimensional plotting.
+It is a monochrome graph of the complex arctangent
+function.
+The image displayed was rotated and had the ``shade'' and ``outline''
+display options set from the 3D Control Panel.
+The PostScript output was produced by clicking on the
+ save 3D Control Panel button and then
+clicking on the PS button.
+See Section ugProblemNumeric
+for more details and examples of Axiom's numeric and graphics capabilities.
+
+
+
+
+
+
+
+draw((x,y) +-> real atan complex(x,y), -%pi..%pi, -%pi..%pi, colorFunction == (x,y) +-> argument atan complex(x,y))
+
+
+
+
+
+
+
+
+
atan
+
+
+
+
An exhibit of Axiom images is given later. For a description of the
+commands and programs that produced these figures, see
+ugAppGraphics . PostScript
+PostScript output is available so that Axiom images can be
+printed.PostScript is a trademark of Adobe Systems
+Incorporated, registered in the United States. See ugGraph for more examples and details about using
+Axiom's graphics facilities.
+
+
+
+
+
This concludes your tour of Axiom.
+To disembark, issue the system command )quit to leave Axiom
+and return to the operating system.
+
In this document we have followed these typographical conventions:
+
+
+
+
+
+
+ Categories, domains and packages are displayed in this font:
+Ring, Integer, DiophantineSolutionPackage.
+
+
Prefix operators, infix operators, and punctuation symbols in
+the Axiom language are displayed in the text like this:
++, $, +->.
+
+
Axiom expressions or expression fragments are displayed in this font:
+inc(x) == x + 1.
+
+
For clarity of presentation, TeX is often used to format expressions
+.
+
+
Function names and HyperDoc button names are displayed in the text in
+this font:
+ factor, integrate, Lighting.
+
+
Italics are used for emphasis and for words defined in the glossary:
+category.
+
+
+
+
+
+
This document contains over 2500 examples of Axiom input and output. All
+examples were run though Axiom and their output was created in TeX
+form by the Axiom TexFormat package. We have deleted system
+messages from the example output if those messages are not important
+for the discussions in which the examples appear.
+
The Axiom language is a rich language for performing interactive
+computations and for building components of the Axiom library.
+Here we present only some basic aspects of the language that you need
+to know for the rest of this chapter. Our discussion here is
+intentionally informal, with details unveiled on an ``as needed''
+basis. For more information on a particular construct, we suggest you
+consult the index.
+
+
+
+
+
+
+
1.3.1 Arithmetic Expressions
+
+
+
+
+
For arithmetic expressions, use the ``+'' and ``-'' operator
+as in mathematics. Use ``*'' for multiplication, and ``**''
+for exponentiation. To create a fraction, use ``/''. When an
+expression contains several operators, those of highest
+precedence are evaluated first. For arithmetic operators,
+``**'' has highest precedence, ``*'' and ``/'' have the
+next highest precedence, and ``+'' and ``-'' have the lowest
+precedence.
+
+
+
+
Axiom puts implicit parentheses around operations of higher
+precedence, and groups those of equal precedence from left to right.
+
+
+
+
+
+
+1 + 2 - 3 / 4 * 3 ** 2 - 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
The above expression is equivalent to this.
+
+
+
+
+
+
+((1 + 2) - ((3 / 4) * (3 ** 2))) - 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
If an expression contains subexpressions enclosed in parentheses,
+the parenthesized subexpressions are evaluated first (from left to
+right, from inside out).
+
+
+
+
+
+
+1 + 2 - 3/ (4 * 3 ** (2 - 1))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
1.3.2 Previous Results
+
+
+
+
+
Use the percent sign ``%'' to refer to the last result.
+result:previous Also, use ``%%" to refer to
+previous results. percentpercent@{%%} ``%%(-1)'' is
+equivalent to ``%'', ``%%(-2)'' returns the next to
+the last result, and so on. ``%%(1)'' returns the result from
+step number 1, ``%%(2)'' returns the result from step number 2,
+and so on. ``%%(0)'' is not defined.
+
+
+
+
This is ten to the tenth power.
+
+
+
+
+
+
+10 ** 10
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
This is the last result minus one.
+
+
+
+
+
+
+% - 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
This is the last result.
+
+
+
+
+
+
+%%(-1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
This is the result from step number 1.
+
+
+
+
+
+
+%%(1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+
+
+
+
+
1.3.3 Some Types
+
+
+
+
+
Everything in Axiom has a type. The type determines what operations
+you can perform on an object and how the object can be used.
+Chapter~ugTypes is dedicated to the
+interactive use of types. Several of the final chapters discuss how
+types are built and how they are organized in the Axiom library.
+
+
+
+
Positive integers are given type PositiveInteger.
+
+
+
+
+
+
+8
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Negative ones are given type Integer. This fine
+distinction is helpful to the Axiom interpreter.
+
+
+
+
+
+
+
+-8
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Integer
+
+
+
+
+
Here a positive integer exponent gives a polynomial result.
+
+
+
+
+
+
+x**8
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
Here a negative integer exponent produces a fraction.
+
+
+
+
+
+
+x**(-8)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Polynomial Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
1.3.4 Symbols, Variables, Assignments, and Declarations
+
+
+
+
+
A symbol is a literal used for the input of things like
+the ``variables'' in polynomials and power series.
+
+
+
+
We use the three symbols , , and in
+entering this polynomial.
+
+
+
+
+
+
+(x - y*z)**2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
A symbol has a name beginning with an uppercase or lowercase
+alphabetic symbol:naming character, ``%'', or
+``!''. Successive characters (if any) can be any of the
+above, digits, or ``?''. Case is distinguished: the symbol
+points is different from the symbol Points.
+
+
+
+
A symbol can also be used in Axiom as a variable. A variable
+refers to a value. To assign a value to a variable,
+variable:naming the operator ``:='' assignment
+is used. Axiom actually has two forms of assignment:
+immediate assignment, as discussed here, and delayed
+assignment. See Section ugLangAssign
+for details. A variable initially has no restrictions on the kinds
+of declaration values to which it can refer.
+
+
+
+
This assignment gives the value (an integer) to
+a variable named .
+
+
+
+
+
+
+x := 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
This gives the value (a polynomial) to .
+
+
+
+
+
+
+x := z + 3/5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Fraction Integer
+
+
+
+
+
To restrict the types of objects that can be assigned to a variable,
+use a declaration
+
+
+
+
+
+
+y : Integer
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
After a variable is declared to be of some type, only values
+of that type can be assigned to that variable.
+
+
+
+
+
+
+y := 89
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Integer
+
+
+
+
+
The declaration for forces values assigned to to
+be converted to integer values.
+
+
+
+
+
+
+y := sin %pi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Integer
+
+
+
+
+
If no such conversion is possible,
+Axiom refuses to assign a value to .
+
+
+
+
+
+
+y := 2/3
+
+
+
+
+
+
+
+ Cannot convert right-hand side of assignment
+ 2
+ -
+ 3
+
+ to an object of the type Integer of the left-hand side.
+
+
+
+
+
A type declaration can also be given together with an assignment.
+The declaration can assist Axiom in choosing the correct
+operations to apply.
+
+
+
+
+
+
+f : Float := 2/3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
Any number of expressions can be given on input line.
+Just separate them by semicolons.
+Only the result of evaluating the last expression is displayed.
+
+
+
+
These two expressions have the same effect as
+the previous single expression.
+
+
+
+
+
+
+
+f : Float; f := 2/3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
The type of a symbol is either Symbol
+or Variable(name) where name is the name
+of the symbol.
+
+
+
+
By default, the interpreter
+gives this symbol the type Variable(q).
+
+
+
+
+
+
+
+q
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Variable q
+
+
+
+
+
When multiple symbols are involved, Symbol is used.
+
+
+
+
+
+
+[q, r]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List OrderedVariableList [q,r]
+
+
+
+
+
What happens when you try to use a symbol that is the name of a variable?
+
+
+
+
+
+
+f
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
Use a single quote ``''' before quote the name to get the symbol.
+
+
+
+
+
+
+
+'f
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Variable f
+
+
+
+
+
Quoting a name creates a symbol by preventing evaluation of the name
+as a variable. Experience will teach you when you are most likely
+going to need to use a quote. We try to point out the location of
+such trouble spots.
+
+
+
+
+
+
+
+
+
+
+
+
1.3.5 Conversion
+
+
+
+
+
Objects of one type can usually be ``converted'' to objects of several
+other types. To convert an object to a new type, use the ``::''
+infix operator. Conversion is discussed in detail in
+ugTypesConvert. For example,
+to display an object, it is necessary to convert the object to type
+OutputForm.
+
+
+
+
This produces a polynomial with rational number coefficients.
+
+
+
+
+
+
+
+p := r**2 + 2/3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Fraction Integer
+
+
+
+
+
Create a quotient of polynomials with integer coefficients
+by using ``::''.
+
+
+
+
+
+
+
+p :: Fraction Polynomial Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Polynomial Integer
+
+
+
+
+
Some conversions can be performed automatically when Axiom tries
+to evaluate your input. Others conversions must be explicitly
+requested.
+
+
+
+
+
+
+
+
+
+
+
+
1.3.6 Calling Functions
+
+
+
+
+
As we saw earlier, when you want to add or subtract two values, you
+place the arithmetic operator ``+'' or ``-'' between the two
+arguments denoting the values. To use most other Axiom
+operations, however, you use another syntax: function:calling
+write the name of the operation first, then an open parenthesis, then
+each of the arguments separated by commas, and, finally, a closing
+parenthesis. If the operation takes only one argument and the
+argument is a number or a symbol, you can omit the parentheses.
+
+
+
+
This calls the operation factor with the single integer argument .
+
+
+
+
+
+
+
+factor(120)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Integer
+
+
+
+
+
This is a call to divide with the two integer arguments
+ and .
+
This calls quatern with four floating-point arguments.
+
+
+
+
+
+
+quatern(3.4,5.6,2.9,0.1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Quaternion Float
+
+
+
+
+
This is the same as factorial(10).
+
+
+
+
+
+
+factorial 10
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
An operation that returns a Boolean value (that is,
+true or false) frequently has a name suffixed with
+a question mark (``?''). For example, the even?
+operation returns true if its integer argument is an even
+number, false otherwise.
+
+
+
+
An operation that can be destructive on one or more arguments
+usually has a name ending in a exclamation point (``!'').
+This actually means that it is allowed to update its
+arguments but it is not required to do so. For example,
+the underlying representation of a collection type may not allow
+the very last element to be removed and so an empty object may be
+returned instead. Therefore it is important that you use the
+object returned by the operation and not rely on a physical
+change having occurred within the object. Usually destructive
+operations are provided for efficiency reasons.
+
+
+
+
+
+
+
+
+
+
+
+
1.3.7 Some Predefined Macros
+
+
+
+
+
Axiom provides several macros for your convenience.See
+ugUserMacros for a discussion on
+how to write your own macros. Macros are names
+macro:predefined (or forms) that expand to larger expressions
+for commonly used values.
+
To display all the macros (along with anything you have
+defined in the workspace), issue the system command )display all.
+
+
+
+
+
+
+
+
+
+
+
+
1.3.8 Long Lines
+
+
+
+
+
When you enter Axiom expressions from your keyboard, there will
+be times when they are too long to fit on one line. Axiom does
+not care how long your lines are, so you can let them continue from
+the right margin to the left side of the next line.
+
+
+
+
Alternatively, you may want to enter several shorter lines and have
+Axiom glue them together. To get this glue, put an underscore
+(_) at the end of each line you wish to continue.
+
+
+
+
+
+
+2_
++_
+3
+
+
+
+
is the same as if you had entered
+
+
+
+
+
+2+3
+
+
+
+
+
Axiom statements in an input file
+(see Section ugInOutIn ),
+can use indentation to indicate the program structure .
+(see Section ugLangBlocks ).
+
+
+
+
+
+
+
+
+
+
+
+
1.3.9 Comments
+
+
+
+
+
Comment statements begin with two consecutive hyphens or two
+consecutive plus signs and continue until the end of the line.
+
+
+
+
The comment beginning with ``--'' is ignored by Axiom.
+
+
+
+
+
+
+2 + 3 -- this is rather simple, no?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
There is no way to write long multi-line comments other than starting
+each line with ``--'' or ``++''.
+
Axiom distinguishes very carefully between different kinds of
+numbers, how they are represented and what their properties are. Here
+are a sampling of some of these kinds of numbers and some things you
+can do with them.
+
To factor fractions, you have to pmap factor onto the numerator
+and denominator.
+
+
+
+
+
+
+
+map(factor,r)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Factored Integer
+
+
+
+
+
SingleInteger refers to machine word-length integers.
+
+
+
+
In English, this expression means `` as a small integer''.
+
+
+
+
+
+
+11@SingleInteger
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SingleInteger
+
+
+
+
+
Machine double-precision floating-point numbers are also available for
+numeric and graphical applications.
+
+
+
+
+
+
+123.21@DoubleFloat
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DoubleFloat
+
+
+
+
+
The normal floating-point type in Axiom, Float, is a
+software implementation of floating-point numbers in which the
+exponent and the mantissa may have any number of digits.
+The types Complex(Float) and
+Complex(DoubleFloat) are the corresponding software
+implementations of complex floating-point numbers.
+
+
+
+
This is a floating-point approximation to about twenty digits.
+floating point The ``::'' is used here to change from
+one kind of object (here, a rational number) to another (a
+floating-point number).
+
+
+
+
+
+
+
+r :: Float
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
Use digitsdigitsFloat to change the number of digits in
+the representation.
+This operation returns the previous value so you can reset it
+later.
+
+
+
+
+
+
+digits(22)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
To digits of precision, the number
+ appears to be an integer.
+
+
+
+
+
+
+exp(%pi * sqrt 163.0)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
Increase the precision to forty digits and try again.
+
+
+
+
+
+
+digits(40); exp(%pi * sqrt 163.0)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
Here are complex numbers with rational numbers as real and
+complex numbers imaginary parts.
+
+
+
+
+
+
+(2/3 + %i)**3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Fraction Integer
+
+
+
+
+
The standard operations on complex numbers are available.
+
+
+
+
+
+
+conjugate %
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Fraction Integer
+
+
+
+
+
You can factor complex integers.
+
+
+
+
+
+
+factor(89 - 23 * %i)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Complex Integer
+
+
+
+
+
Complex numbers with floating point parts are also available.
+
+
+
+
+
+
+exp(%pi/4.0 * %i)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Float
+
+
+
+
+
The real and imaginary parts can be symbolic.
+
+
+
+
+
+
+complex(u,v)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Polynomial Integer
+
+
+
+
+
Of course, you can do complex arithmetic with these also.
+
+
+
+
+
+
+% ** 2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Polynomial Integer
+
+
+
+
+
Every rational number has an exact representation as a
+repeating decimal expansion
+
+
+
+
+
+
+decimal(1/352)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DecimalExpansion
+
+
+
+
+
A rational number can also be expressed as a continued fraction.
+
+
+
+
+
+
+
+continuedFraction(6543/210)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: ContinuedFraction Integer
+
+
+
+
+
Also, partial fractions can be used and can be displayed in a
+partial fraction
+compact format
+fraction:partial
+
+
+
+
+
+
+partialFraction(1,factorial(10))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PartialFraction Integer
+
+
+
+
+
or expanded format.
+
+
+
+
+
+
+padicFraction(%)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PartialFraction Integer
+
+
+
+
+
Like integers, bases (radices) other than ten can be used for rational
+numbers.
+Here we use base eight.
+
+
+
+
+
+
+radix(4/7, 8)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: RadixExpansion 8
+
+
+
+
+
Of course, there are complex versions of these as well.
+Axiom decides to make the result a complex rational number.
+
+
+
+
+
+
+% + 2/3*%i
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Fraction Integer
+
+
+
+
+
You can also use Axiom to manipulate fractional powers.
+radical
+
+
+
+
+
+
+(5 + sqrt 63 + sqrt 847)**(1/3)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: AlgebraicNumber
+
+
+
+
+
You can also compute with integers modulo a prime.
+
+
+
+
+
+
+x : PrimeField 7 := 5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PrimeField 7
+
+
+
+
+
Arithmetic is then done modulo .
+
+
+
+
+
+
+x**3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PrimeField 7
+
+
+
+
+
Since is prime, you can invert nonzero values.
+
+
+
+
+
+
+1/x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PrimeField 7
+
+
+
+
+
You can also compute modulo an integer that is not a prime.
+
+
+
+
+
+
+y : IntegerMod 6 := 5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: IntegerMod 6
+
+
+
+
+
All of the usual arithmetic operations are available.
+
+
+
+
+
+
+y**3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: IntegerMod 6
+
+
+
+
+
Inversion is not available if the modulus is not a prime number.
+Modular arithmetic and prime fields are discussed in Section
+ugxProblemFinitePrime .
+
+
+
+
+
+
+
+1/y
+
+
+
+
+
+
+
+ There are 12 exposed and 13 unexposed library operations named /
+ having 2 argument(s) but none was determined to be applicable.
+ Use HyperDoc Browse, or issue
+ )display op /
+ to learn more about the available operations. Perhaps
+ package-calling the operation or using coercions on the arguments
+ will allow you to apply the operation.
+
+ Cannot find a definition or applicable library operation named /
+ with argument type(s)
+ PositiveInteger
+ IntegerMod 6
+
+ Perhaps you should use "@" to indicate the required return type,
+ or "$" to specify which version of the function you need.
+
+
+
+
+
This defines to be an algebraic number, that is,
+a root of a polynomial equation.
+
+
+
+
+
+
+a := rootOf(a**5 + a**3 + a**2 + 3,a)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
Computations with are reduced according to the polynomial equation.
+
+
+
+
+
+
+(a + 1)**10
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
Define to be an algebraic number involving .
+
+
+
+
+
+
+b := rootOf(b**4 + a,b)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
Do some arithmetic.
+
+
+
+
+
+
+2/(b - 1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
To expand and simplify this, call ratDenom
+to rationalize the denominator.
+
+
+
+
+
+
+ratDenom(%)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
If we do this, we should get .
+
+
+
+
+
+
+2/%+1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
But we need to rationalize the denominator again.
+
+
+
+
+
+
+
+ratDenom(%)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
Types Quaternion and Octonion are also available.
+Multiplication of quaternions is non-commutative, as expected.
+
Axiom has a large variety of data structures available. Many
+data structures are particularly useful for interactive computation
+and others are useful for building applications. The data structures
+of Axiom are organized into category hierarchies.
+
+
+
+
A list, Lists are discussed in Section ListXmpPage, is the most commonly used data structure in
+Axiom for holding objects all of the same type. The name list is
+short for ``linked-list of nodes.'' Each node consists of a value
+(firstfirstList) and a link (restrestList) that
+points to the next node, or to a distinguished value denoting the
+empty list. To get to, say, the third element, Axiom starts at the
+front of the list, then traverses across two links to the third node.
+
+
+
+
Write a list of elements using square brackets with commas separating
+the elements.
+
+
+
+
+
+
+u := [1,-7,11]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
This is the value at the third node. Alternatively, you can say .
+
+
+
+
+
+
+first rest rest u
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Many operations are defined on lists, such as: empty?, to test
+that a list has no elements; cons, to create a new list
+with first element and rest ; reverse, to
+create a new list with elements in reverse order; and sort, to
+arrange elements in order.
+
+
+
+
An important point about lists is that they are ``mutable'': their
+constituent elements and links can be changed ``in place.''
+To do this, use any of the operations whose names end with the
+character ``!''.
+
+
+
+
The operation concat!concat!List replaces the
+last link of the list to point to some other list .
+Since refers to the original list, this change is seen by .
+
+
+
+
+
+
+concat!(u,[9,1,3,-4]); u
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
A cyclic list is a list with a ``cycle'': list:cyclic a
+link pointing back to an earlier node of the list. cyclic
+list To create a cycle, first get a node somewhere down the list.
+
+
+
+
+
+
+lastnode := rest(u,3)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
Use setrest!setrest!List to change the link emanating from
+that node to point back to an earlier part of the list.
+
+
+
+
+
+
+
+setrest!(lastnode,rest(u,2)); u
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
A stream is a structure that (potentially) has an infinite
+number of distinct elements. Think of a stream as an
+``infinite list'' where elements are computed successively.
+Streams are discussed in Section{StreamXmpPage}.
+
+
+
+
Create an infinite stream of factored integers. Only a certain number
+of initial elements are computed and displayed.
+
+
+
+
+
+
+
+[factor(i) for i in 2.. by 2]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Factored Integer
+
+
+
+
+
Axiom represents streams by a collection of already-computed
+elements together with a function to compute the next element ``on
+demand.'' Asking for the -th element causes elements
+ through to be evaluated.
+
+
+
+
+
+
+%.36
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Integer
+
+
+
+
+
Streams can also be finite or cyclic.
+They are implemented by a linked list structure similar to lists
+and have many of the same operations.
+For example, first and rest are used to access
+elements and successive nodes of a stream.
+
+
+
+
A one-dimensional array is another data structure used to hold
+objects of the same type OnedimensionalArray is discussed in
+Section OneDimensionalArrayXmpPage. Unlike lists,
+one-dimensional arrays are inflexible---they are
+array:one-dimensional implemented using a fixed block of
+storage. Their advantage is that they give quick and equal access
+time to any element.
+
+
+
+
A simple way to create a one-dimensional array is to apply the
+operation oneDimensionalArray to a list of elements.
+
+
+
+
+
+
+a := oneDimensionalArray [1, -7, 3, 3/2]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: OneDimensionalArray Fraction Integer
+
+
+
+
+
One-dimensional arrays are also mutable: you can change their
+constituent elements ``in place.''
+
+
+
+
+
+
+a.3 := 11; a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: OneDimensionalArray Fraction Integer
+
+
+
+
+
However, one-dimensional arrays are not flexible structures.
+You cannot destructively concat! them together.
+
+
+
+
+
+
+concat!(a,oneDimensionalArray [1,-2])
+
+
+
+
+
+
+
+ There are 5 exposed and 0 unexposed library operations named concat!
+ having 2 argument(s) but none was determined to be applicable.
+ Use HyperDoc Browse, or issue
+ )display op concat!
+ to learn more about the available operations. Perhaps
+ package-calling the operation or using coercions on the arguments
+ will allow you to apply the operation.
+
+ Cannot find a definition or applicable library operation named
+ concat! with argument type(s)
+ OneDimensionalArray Fraction Integer
+ OneDimensionalArray Integer
+
+ Perhaps you should use "@" to indicate the required return type,
+ or "$" to specify which version of the function you need.
+
+
+
+
+
Examples of datatypes similar to OneDimensionalArray
+are: Vector (vectors are mathematical structures
+implemented by one-dimensional arrays), String (arrays
+of ``characters,'' represented by byte vectors), and
+Bits (represented by ``bit vectors'').
+
+
+
+
A vector of 32 bits, each representing the Boolean value
+.
+
+
+
+
+
+
+bits(32,true)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Bits
+
+
+
+
+
A flexible array (FlexibleArray is discussed in Section
+FlexibleArrayXmpPage) is
+a cross between a list array:flexible and a one-dimensional
+array. Like a one-dimensional array, a flexible array occupies a fixed
+block of storage. Its block of storage, however, has room to expand.
+When it gets full, it grows (a new, larger block of storage is
+allocated); when it has too much room, it contracts.
+
+
+
+
Create a flexible array of three elements.
+
+
+
+
+
+
+f := flexibleArray [2, 7, -5]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FlexibleArray Integer
+
+
+
+
+
Insert some elements between the second and third elements.
+
+
+
+
+
+
+insert!(flexibleArray [11, -3],f,2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FlexibleArray Integer
+
+
+
+
+
Flexible arrays are used to implement ``heaps.'' A heap is an
+example of a data structure called a priority queue, where
+elements are ordered with respect to one another. A heap
+(Heap is discussed in Section HeapXmpPage) is organized so as to optimize insertion
+and extraction of maximum elements. The extract! operation
+returns the maximum element of the heap, after destructively removing
+that element and reorganizing the heap so that the next maximum
+element is ready to be delivered.
+
+
+
+
An easy way to create a heap is to apply the operation heap
+to a list of values.
+
+
+
+
+
+
+h := heap [-4,7,11,3,4,-7]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Heap Integer
+
+
+
+
+
This loop extracts elements one-at-a-time from until the heap
+is exhausted, returning the elements as a list in the order they were
+extracted.
+
+
+
+
+
+
+[extract!(h) while not empty?(h)]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
A binary tree is a ``tree'' with at most two branches
+tree per node: it is either empty, or else is a node
+consisting of a value, and a left and right subtree (again, binary
+trees). (BinarySearchTrees are discussed in Section
+BinarySearchTreeXmpPage)
+Examples of binary tree types are BinarySearchTree,
+PendantTree, TournamentTree, and BalancedBinaryTree.
+
+
+
+
A binary search tree is a binary tree such that,
+tree:binary search for each node, the value of the node is
+binary search tree greater than all values (if any) in the
+left subtree, and less than or equal all values (if any) in the right
+subtree.
+
+
+
+
+
+
+binarySearchTree [5,3,2,9,4,7,11]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: BinarySearchTree PositiveInteger
+
+
+
+
+
A balanced binary tree is useful for doing modular computations.
+balanced binary tree Given a list of moduli,
+tree:balanced binary modTree produces
+a balanced binary tree with the values at its leaves.
+
+
+
+
+
+
+modTree(8,[2,3,5,7])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
A set is a collection of elements where duplication and order is
+irrelevant. Sets are discussed in Section SetXmpPage
+ Sets are always finite and have no
+corresponding structure like streams for infinite collections.
+
+
+
+
Create sets using braces ``{`` and ``}'' rather than brackets.
+
+
+
+
+
+
+
+fs := set[1/3,4/5,-1/3,4/5]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Set Fraction Integer
+
+
+
+
+
A multiset is a set that keeps track of the number of duplicate
+values. Multisets are discussed in Section
+MultiSetXmpPage
+
+
+
+
For all the primes between 2 and 1000, find the
+distribution of .
+
+
+
+
+
+
+multiset [x rem 5 for x in primes(2,1000)]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Multiset Integer
+
+
+
+
+
A table is conceptually a set of ``key--value'' pairs and is a
+generalization of a multiset. For examples of tables, see
+AssociationList, HashTable, KeyedAccessFile,
+Library, SparseTable, StringTable, and Table. The
+domain Table(Key, Entry) provides a general-purpose type for
+tables with values of type indexed by keys of type
+.
+
+
+
+
Compute the above distribution of primes using tables. First, let
+ denote an empty table of keys and values, each of type Integer.
+
+
+
+
+
+
+t : Table(Integer,Integer) := empty()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Table(Integer,Integer)
+
+
+
+
+
We define a function howMany to return the number of values
+of a given modulus seen so far. It calls
+ search which returns the number of values
+stored under the key in table , or ``failed''
+if no such value is yet stored in under .
+
+
+
+
In English, this says ``Define as follows.
+First, let be the value of search.
+Then, if has the value , return the value
+; otherwise return .''
+
+
+
+
+
+
+howMany(k) == (n:=search(k,t); n case "failed" => 1; n+1)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Run through the primes to create the table, then print the table.
+The expression t.m := howMany(m) updates the value in table
+stored under key .
+
+
+
+
+
+
+for p in primes(2,1000) repeat (m:= p rem 5; t.m:= howMany(m)); t
+
+
+
+
+
+
+
+ Compiling function howMany with type Integer -> Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Table(Integer,Integer)
+
+
+
+
+
+
A record is an example of an inhomogeneous collection of
+objects.See ugTypesRecords for details. A record consists of a
+set of named selectors that can be used to access its
+components. Record@{\sf Record}
+
+
+
+
Declare that can only be
+assigned a record with two prescribed fields.
+
All told, there are over forty different data structures in Axiom.
+Using the domain constructors described in Chapter ugDomains you can add your own data structure or
+extend an existing one. Choosing the right data structure for your
+application may be the key to obtaining good performance.
+
To get higher dimensional aggregates, you can create one-dimensional
+aggregates with elements that are themselves aggregates, for example,
+lists of lists, one-dimensional arrays of lists of multisets, and so
+on. For applications requiring two-dimensional homogeneous
+aggregates, you will likely find two-dimensional arrays
+matrix and matrices most useful.
+array:two-dimensional
+
+
+
+
The entries in TwoDimensionalArray and Matrix objects are
+all the same type, except that those for Matrix must belong to a
+Ring. You create and access elements in roughly the same way.
+Since matrices have an understood algebraic structure, certain
+algebraic operations are available for matrices but not for arrays.
+Because of this, we limit our discussion here to Matrix, that
+can be regarded as an extension of TwoDimensionalArray. See
+TwoDimensionalArray for more information about arrays. For more
+information about Axiom's linear algebra facilities, see Matrix,
+Permanent, SquareMatrix, Vector, see Section
+ugProblemEigen (computation of
+eigenvalues and eigenvectors), and Section ugProblemLinPolEqn (solution of linear and polynomial
+equations).
+
+
+
+
You can create a matrix from a list of lists, matrix:creating
+where each of the inner lists represents a row of the matrix.
+
+
+
+
+
+
+m := matrix([ [1,2], [3,4] ])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Integer
+
+
+
+
+
The ``collections'' construct (see ugLangIts) is useful for creating matrices whose
+entries are given by formulas. matrix:Hilbert
+
+
+
+
+
+
+matrix([ [1/(i + j - x) for i in 1..4] for j in 1..4])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Fraction Polynomial Integer
+
+
+
+
+
Let denote the three by three Vandermonde matrix.
+
Axiom provides you with a very large library of predefined
+operations and objects to compute with. You can use the Axiom
+library of constructors to create new objects dynamically of quite
+arbitrary complexity. For example, you can make lists of matrices of
+fractions of polynomials with complex floating point numbers as
+coefficients. Moreover, the library provides a wealth of operations
+that allow you to create and manipulate these objects.
+
+
+
+
For many applications, you need to interact with the interpreter and
+write some Axiom programs to tackle your application.
+Axiom allows you to write functions interactively,
+function thereby effectively extending the system library.
+Here we give a few simple examples, leaving the details to
+Chapter ugUser .
+
+
+
+
We begin by looking at several ways that you can define the
+``factorial'' function in Axiom. The first way is to give a
+function:piece-wise definition piece-wise definition of the
+function. piece-wise function definition This method is best
+for a general recurrence relation since the pieces are gathered
+together and compiled into an efficient iterative function.
+Furthermore, enough previously computed values are automatically saved
+so that a subsequent call to the function can pick up from where it
+left off.
+
+
+
+
Define the value of fact at .
+
+
+
+
+
+
+fact(0) == 1
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Define the value of fact(n) for general .
+
+
+
+
+
+
+fact(n) == n*fact(n-1)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Ask for the value at . The resulting function created by
+Axiom computes the value by iteration.
+
+
+
+
+
+
+
+fact(50)
+
+
+
+
+
+
+
+ Compiling function fact with type Integer -> Integer
+ Compiling function fact as a recurrence relation.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
A second definition uses an if-then-else and recursion.
+
+
+
+
+
+
+fac(n) == if n < 3 then n else n * fac(n - 1)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
This function is less efficient than the previous version since
+each iteration involves a recursive function call.
+
+
+
+
+
+
+fac(50)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
A third version directly uses iteration.
+
+
+
+
+
+
+fa(n) == (a := 1; for i in 2..n repeat a := a*i; a)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
This is the least space-consumptive version.
+
+
+
+
+
+
+fa(50)
+
+
+
+
+
+
+
+ Compiling function fac with type Integer -> Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
A final version appears to construct a large list and then reduces over
+it with multiplication.
+
+
+
+
+
+
+f(n) == reduce(*,[i for i in 2..n])
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
In fact, the resulting computation is optimized into an efficient
+iteration loop equivalent to that of the third version.
+
+
+
+
+
+
+f(50)
+
+
+
+
+
+
+
+Compiling function f with type
+ PositiveInteger -> PositiveInteger
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The library version uses an algorithm that is different from the four
+above because it highly optimizes the recurrence relation definition of
+ factorial.
+
+
+
+
+
+
+
+factorial(50)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
You are not limited to one-line functions in Axiom. If you place your
+function definitions in .input files file:input (see
+ugInOutIn ), you can have multi-line
+functions that use indentation for grouping.
+
+
+
+
Given elements, diagonalMatrix creates an
+ by matrix with those elements down the diagonal.
+This function uses a permutation matrix
+that interchanges the th and th rows of a matrix
+by which it is right-multiplied.
+
+
+
+
This function definition shows a style of definition that can be used
+in .input files. Indentation is used to create blocks:
+sequences of expressions that are evaluated in sequence except as
+modified by control statements such as if-then-else and return.
+
+
+
+
+
+
+permMat(n, i, j) ==
+ m := diagonalMatrix
+ [(if i = k or j = k then 0 else 1)
+ for k in 1..n]
+ m(i,j) := 1
+ m(j,i) := 1
+ m
+
+
+
+
+
This creates a four by four matrix that interchanges the second and third
+rows.
+
+
+
+
+
+
+p := permMat(4,2,3)
+
+
+
+
+
+
+
+ Compiling function permMat with type (PositiveInteger,
+ PositiveInteger,PositiveInteger) -> Matrix Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Integer
+
+
+
+
+
Create an example matrix to permute.
+
+
+
+
+
+
+m := matrix [ [4*i + j for j in 1..4] for i in 0..3]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Integer
+
+
+
+
+
Interchange the second and third rows of m.
+
+
+
+
+
+
+permMat(4,2,3) * m
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Integer
+
+
+
+
+
A function can also be passed as an argument to another function,
+which then applies the function or passes it off to some other
+function that does. You often have to declare the type of a function
+that has functional arguments.
+
+
+
+
This declares t to be a two-argument function that returns a
+Float. The first argument is a function that takes one
+Float argument and returns a Float.
+
+
+
+
+
+
+
+t : (Float -> Float, Float) -> Float
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
This is the definition of t.
+
+
+
+
+
+
+
+t(fun, x) == fun(x)**2 + sin(x)**2
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
We have not defined a cos in the workspace. The one from the
+Axiom library will do.
+
+
+
+
+
+
+
+t(cos, 5.2058)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
Here we define our own (user-defined) function.
+
+
+
+
+
+
+cosinv(y) == cos(1/y)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Pass this function as an argument to t.
+
+
+
+
+
+
+t(cosinv, 5.2058)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
Axiom also has pattern matching capabilities for
+simplification
+simplification
+pattern matching
+of expressions and for defining new functions by rules.
+For example, suppose that you want to apply regularly a transformation
+that groups together products of radicals:
+
+Note that such a transformation is not generally correct.
+Axiom never uses it automatically.
+
Polynomials are the commonly used algebraic types in symbolic
+computation. polynomial Interactive users of Axiom
+generally only see one type of polynomial: Polynomial(R).
+This type represents polynomials in any number of unspecified
+variables over a particular coefficient domain . This type
+represents its coefficients sparsely: only terms with non-zero
+coefficients are represented.
+
+
+
+
In building applications, many other kinds of polynomial
+representations are useful. Polynomials may have one variable or
+multiple variables, the variables can be named or unnamed, the
+coefficients can be stored sparsely or densely. So-called
+``distributed multivariate polynomials'' store polynomials as
+coefficients paired with vectors of exponents. This type is
+particularly efficient for use in algorithms for solving systems of
+non-linear polynomial equations.
+
+
+
+
The polynomial constructor most familiar to the interactive user
+is Polynomial.
+
+
+
+
+
+
+(x**2 - x*y**3 +3*y)**2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
If you wish to restrict the variables used,
+UnivariatePolynomial provides polynomials in one variable.
+
+
+
+
+
+
+
+p: UP(x,INT) := (3*x-1)**2 * (2*x + 8)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: UnivariatePolynomial(x,Integer)
+
+
+
+
+
The constructor MultivariatePolynomial provides polynomials
+in one or more specified variables.
+
You can change the way the polynomial appears by modifying the variable
+ordering in the explicit list.
+
+
+
+
+
+
+m :: MPOLY([y,x],INT)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: MultivariatePolynomial([y,x],Integer)
+
+
+
+
+
The constructor DistributedMultivariatePolynomial provides
+polynomials in one or more specified variables with the monomials
+ordered lexicographically.
+
The constructor
+HomogeneousDistributedMultivariatePolynomial is similar
+except that the monomials are ordered by total order refined by
+reverse lexicographic order.
+
More generally, the domain constructor
+GeneralDistributedMultivariatePolynomial allows the user to
+provide an arbitrary predicate to define his own term ordering. These
+last three constructors are typically used in Gröbner basis
+applications and
+when a flat (that is, non-recursive) display is wanted and the term
+ordering is critical for controlling the computation.
+
Axiom's limit function is usually used to evaluate
+limits of quotients where the numerator and denominator limit
+both tend to zero or both tend to infinity. To find the limit of an
+expression as a real variable tends to a limit
+value , enter limit(f, x=a). Use
+ complexLimit if the variable is complex. Additional
+information and examples of limits are in
+Section ugProblemLimits .
+
+
+
+
You can take limits of functions with parameters.
+limit:of function with parameters
+
+
+
+
+
+
+g := csc(a*x) / csch(b*x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
As you can see, the limit is expressed in terms of the parameters.
+
A function can be defined on both sides of a particular value, but
+may tend to different limits as its variable approaches that value from the
+left and from the right.
+
However, if is allowed to approach along any path in the
+complex plane, the limiting value of exp(-1/x**2) depends on the
+path taken because the function has an essential singularity at .
+This is reflected in the error message returned by the function.
+
Programming in the interpreter is easy.
+So is the use of Axiom's graphics facility.
+Both are rather flexible and allow you to use them for many
+interesting applications.
+However, both require learning some basic ideas and skills.
+
+
+
+
All graphics examples in the gallery section are either
+produced directly by interactive commands or by interpreter
+programs.
+Four of these programs are introduced here.
+By the end of this chapter you will know enough about graphics and
+programming in the interpreter to not only understand all these
+examples, but to tackle interesting and difficult problems on your
+own.
+The appendix on graphics lists all the remaining commands and
+programs used to create these images.
+
We begin our discussion of interactive graphics with the creation
+of a useful facility: plotting ribbons of two-graphs in
+three-space.
+Suppose you want to draw the two-dimensional graphs of
+functions all over some fixed range of .
+One approach is to create a two-dimensional graph for each one, then
+superpose one on top of the other.
+What you will more than likely get is a jumbled mess.
+Even if you make each function a different color, the result is
+likely to be confusing.
+
+
+
+
A better approach is to display each of the in three
+ribbon
+dimensions as a ``ribbon'' of some appropriate width along the
+ -direction, laying down each ribbon next to the
+previous one.
+A ribbon is simply a function of and depending
+only on .
+
+
+
+
We illustrate this for defined as simple powers of
+ for ranging between and .
+
+
+
+
+
Draw the ribbon for .
+
+
+
+
+
+
+draw(x**2,x=-1..1,y=0..1)
+
+
+
+
+
+
+
+
+
Now that was easy!
+What you get is a ``wire-mesh'' rendition of the ribbon.
+That's fine for now.
+Notice that the mesh-size is small in both the and the
+ directions.
+Axiom normally computes points in both these directions.
+This is unnecessary.
+One step is all we need in the -direction.
+To have Axiom economize on -points, we re-draw the
+ribbon with option .
+
+
+
+
Re-draw the ribbon, but with option
+so that only step is computed in the
+ direction.
+
+
+
+
+
+
+vp := draw(x**2,x=-1..1,y=0..1,var2Steps==1)
+
+
+
+
+
+
+
+
+
The operation has created a viewport, that is, a graphics window
+on your screen.
+We assigned the viewport to and now we manipulate
+its contents.
+
+
+
+
+
Graphs are objects, like numbers and algebraic expressions.
+You may want to do some experimenting with graphs.
+For example, say
+
+
+
+
+
+showRegion(vp, "on")
+
+
+
+
to put a bounding box around the ribbon.
+Try it!
+Issue to rotate the
+figure longitudinal degrees and latitudinal
+degrees.
+
+
+
+
Here is a different rotation.
+This turns the graph so you can view it along the -axis.
+
+
+
+
+
+
+
+rotate(vp, 0, -90)
+
+
+
+
+
+
+
+
+
+
+
There are many other things you can do.
+In fact, most everything you can do interactively using the
+three-dimensional control panel (such as translating, zooming, resizing,
+coloring, perspective and lighting selections) can also be done
+directly by operations (see Chapter
+ugGraph for more details).
+
+
+
+
When you are done experimenting, say to restore the
+picture to its original position and settings.
+
+
+
+
+
Let's add another ribbon to our picture---one
+for .
+Since ranges from to for the
+first ribbon, now let range from to
+ .
+This puts the second ribbon next to the first one.
+
+
+
+
How do you add a second ribbon to the viewport?
+One method is
+to extract the ``space'' component from the
+viewport using the operation
+subspacesubspaceThreeDimensionalViewport.
+You can think of the space component as the object inside the
+window (here, the ribbon).
+Let's call it .
+To add the second ribbon, you draw the second ribbon using the
+option .
+
Unless you moved the original viewport, the new viewport covers
+the old one.
+You might want to check that the old object is still there by
+moving the top window.
+
+
+
+
Let's show quadrilateral polygon outlines on the ribbons and then
+enclose the ribbons in a box.
+
This process has become tedious!
+If we had to add two or three more ribbons, we would have to
+repeat the above steps several more times.
+It is time to write an interpreter program to help us take care of
+the details.
+
This setting is needed to get Newton's iterations to converge.
+
+
+
+
+
+
+
+)set streams calculate 10
+
+
+
+
+
+
We resume
+our continuing saga of arrows and complex functions.
+Suppose we want to investigate the behavior of Newton's iteration function
+Newton iteration
+in the complex plane.
+Given a function , we want to find the complex values
+ such that .
+
+
+
+
The first step is to produce a Newton iteration formula for
+a given :
+
+We represent this formula by a function
+that performs the computation on the right-hand side, that is,
+ .
+
+
+
+
The type Expression Integer (abbreviated EXPR
+INT) is used to represent general symbolic expressions in
+Axiom.
+Expression
+To make our facility as general as possible, we assume
+ has this type.
+Given , we want
+to produce a Newton iteration function which,
+given a complex point , delivers the next
+Newton iteration point .
+
+
+
+
This time we write an input file called newton.input.
+We need to import MakeUnaryCompiledFunction (discussed
+in the last section), call it with appropriate types, and then define
+the function which references it.
+Here is the function :
+
+
+
+
+
+
+C := Complex DoubleFloat The complex numbers
+complexFunPack:=MakeUnaryCompiledFunction(EXPR INT,C,C)
+ Package for making functions
+
+newtonStep(f) == Newton's iteration function
+ fun := complexNumericFunction f Function for $f$
+ deriv := complexDerivativeFunction(f,1) Function for $f'$
+ (x:C):C +-> Return the iterator function
+ x - fun(x)/deriv(x)
+
+complexNumericFunction f == Turn an expression $f$ into a
+ v := theVariableIn f function
+ compiledFunction(f, v)$complexFunPack
+
+complexDerivativeFunction(f,n) == Create an nth derivative
+ v := theVariableIn f function
+ df := D(f,v,n)
+ compiledFunction(df, v)$complexFunPack
+
+theVariableIn f == Returns the variable in $f$
+ vl := variables f The list of variables
+ nv := # vl The number of variables
+ nv > 1 => error "Expression is not univariate."
+ nv = 0 => 'x Return a dummy variable
+ first vl
+
+
+
+
+
Do you see what is going on here?
+A formula is passed into the function newtonStep.
+First, the function turns into a compiled program mapping
+complex numbers into complex numbers. Next, it does the same thing
+for the derivative of . Finally, it returns a function which
+computes a single step of Newton's iteration.
+
+
+
+
The function complexNumericFunction extracts the variable
+from the expression and then turns into a function
+which maps complex numbers into complex numbers. The function
+ complexDerivativeFunction does the same thing for the
+derivative of . The function theVariableIn
+extracts the variable from the expression , calling the function
+ error if has more than one variable.
+It returns the dummy variable if has no variables.
+
+
+
+
Let's now apply newtonStep to the formula for computing
+cube roots of two.
+
+
+
+
Read the input file with the definitions.
+
+
+
+
+
+
+
+)read newton
+
+
+
+
+
+
+
+
+
+)read vectors
+
+
+
+
+
+
The cube root of two.
+
+
+
+
+
+
+
+f := x**3 - 2
+
+
+
+
+
+
Get Newton's iteration formula.
+
+
+
+
+
+
+
+g := newtonStep f
+
+
+
+
+
+
Let denote the result of
+applying Newton's iteration once to the complex number .
+
+
+
+
+
+
+
+a := g(1.0 + %i)
+
+
+
+
+
+
Now apply it repeatedly. How fast does it converge?
+
+
+
+
+
+
+
+[(a := g(a)) for i in 1..]
+
+
+
+
+
+
Check the accuracy of the last iterate.
+
+
+
+
+
+
+
+a**3
+
+
+
+
+
+
In MappingPackage1, we show how functions can be
+manipulated as objects in Axiom.
+A useful operation to consider here is , which means
+composition.
+For example causes the Newton iteration formula
+to be applied twice.
+Correspondingly, means to apply the iteration formula
+ times.
+
+
+
+
Apply twice to the point .
+
+
+
+
+
+
+(g*g) (1.0 + %i)
+
+
+
+
+
+
Apply 11 times.
+
+
+
+
+
+
+
+(g**11) (1.0 + %i)
+
+
+
+
+
+
Look now at the vector field and surface generated
+after two steps of Newton's formula for the cube root of two.
+The poles in these pictures represent bad starting values, and the
+flat areas are the regions of convergence to the three roots.
+
The above approach creates a new viewport for each additional ribbon.
+A better approach is to build one object composed of all ribbons
+before creating a viewport. To do this, use makeObject rather
+than draw. The operations have similar formats, but draw
+returns a viewport and makeObject returns a space object.
+
+
+
+
We now create a function drawRibbons of two arguments:
+ , a list of formulas for the ribbons you want to draw,
+and , the range over which you want them drawn.
+Using this function, you can just say
+
+
+
+
+
+drawRibbons([x**2, x**3], x=-1..1)
+
+
+
+
to do all of the work required in the last section.
+Here is the drawRibbons program.
+Invoke your favorite editor and create a file called ribbon.input
+containing the following program.
+
+
+
+
+
+
+drawRibbons(flist, xrange) ==}{}
+ sp := createThreeSpace() Create empty space $sp$.
+ y0 := 0 The initial ribbon position.
+ for f in flist repeat For each function $f$,
+ makeObject(f, xrange, y=y0..y0+1, create and add a ribbon
+ space==sp, var2Steps == 1) for $f$ to the space $sp$.
+ y0 := y0 + 1 The next ribbon position.
+ vp := makeViewport3D(sp, "Ribbons") Create viewport.
+ drawStyle(vp, "shade") Select shading style.
+ outlineRender(vp, "on") Show polygon outlines.
+ showRegion(vp,"on") Enclose in a box.
+ n := # flist The number of ribbons
+ zoom(vp,n,1,n) Zoom in x- and z-directions.
+ rotate(vp,0,75) Change the angle of view.
+ vp Return the viewport.
+
+
+
+
+
The first drawRibbons function.
+
+
+
+
+
Here are some remarks on the syntax used in the drawRibbons function
+(consult Chapter ugUser for more details).
+Unlike most other programming languages which use semicolons,
+parentheses, or begin--end brackets to delineate the
+structure of programs, the structure of an Axiom program is
+determined by indentation.
+The first line of the function definition always begins in column 1.
+All other lines of the function are indented with respect to the first
+line and form a pile (see ugLangBlocks ).
+
+
+
+
The definition of drawRibbons
+consists of a pile of expressions to be executed one after
+another.
+Each expression of the pile is indented at the same level.
+Lines 4-7 designate one single expression:
+since lines 5-7 are indented with respect to the others, these
+lines are treated as a continuation of line 4.
+Also since lines 5 and 7 have the same indentation level, these
+lines designate a pile within the outer pile.
+
+
+
+
The last line of a pile usually gives the value returned by the
+pile.
+Here it is also the value returned by the function.
+Axiom knows this is the last line of the function because it
+is the last line of the file.
+In other cases, a new expression beginning in column one signals
+the end of a function.
+
+
+
+
The line drawStyle(vp,"shade") is given after the viewport
+has been created to select the draw style.
+We have also used the zoomzoomThreeDimensionalViewport
+option.
+Without the zoom, the viewport region would be scaled equally in
+all three coordinate directions.
+
+
+
+
Let's try the function drawRibbons.
+First you must read the file to give Axiom the function definition.
+
Before leaving the ribbon example, we make two improvements.
+Normally, the color given to each point in the space is a
+function of its height within a bounding box.
+The points at the bottom of the
+box are red, those at the top are purple.
+
+
+
+
To change the normal coloring, you can give
+an option .
+When Axiom goes about displaying the data, it
+determines the range of colors used for all points within the box.
+Axiom then distributes these numbers uniformly over the number of hues.
+Here we use the simple color function
+ for the
+ -th ribbon.
+
+
+
+
Also, we add an argument so you can give the range of
+ occupied by the ribbons.
+For example, if the is given as
+ and there are ribbons to be displayed, each
+ribbon would have width and would appear in the
+range .
+
+
+
+
Refer to lines 4-9.
+Line 4 assigns to the variable part of the
+ (after all, it need not be ).
+Suppose that is given as where and
+ have numerical values.
+Then line 5 assigns the value of to the variable .
+Line 6 computes the width of the ribbon by dividing the difference of
+ and by the number, , of ribbons.
+The result is assigned to the variable .
+Note that in the for-loop in line 7, we are iterating in parallel; it is
+not a nested loop.
+
+
+
+
+
+
+
+drawRibbons(flist, xrange, yrange) ==}{}
+ sp := createThreeSpace() Create empty space $sp$.
+ num := # flist The number of ribbons.
+ yVar := variable yrange The ribbon variable.
+ y0:Float := lo segment yrange The first ribbon coordinate.
+ width:Float := (hi segment yrange - y0)/num The width of a ribbon.
+ for f in flist for color in 1..num repeat For each function $f$,
+ makeObject(f, xrange, yVar = y0..y0+width, create and add ribbon to
+ var2Steps == 1, colorFunction == (x,y) +-> color, _
+ space == sp) $sp$ of a different color.
+ y0 := y0 + width The next ribbon coordinate.
+ vp := makeViewport3D(sp, "Ribbons") Create viewport.
+ drawStyle(vp, "shade") Select shading style.
+ outlineRender(vp, "on") Show polygon outlines.
+ showRegion(vp, "on") Enclose in a box.
+ vp Return the viewport.
+
What you have seen so far is a high-level program using the
+graphics facility.
+We now turn to the more basic notions of points, lines, and curves
+in three-dimensional graphs.
+These facilities use small floats (objects
+of type DoubleFloat) for data.
+Let us first give names to the small float values and
+ .
+
+
+
+
The small float 0.
+
+
+
+
+
+
+
+zero := 0.0@DFLOAT
+
+
+
+
+
+
The small float 1.
+
+
+
+
+
+
+
+one := 1.0@DFLOAT
+
+
+
+
+
+
The @ sign means ``of the type.'' Thus is
+ of the type DoubleFloat.
+You can also say .
+
+
+
+
Points can have four small float components: coordinates and an
+optional color.
+A ``curve'' is simply a list of points connected by straight line
+segments.
+
+
+
+
Create the point with color zero, that is, the lowest color
+on the color map.
+
+
+
+
+
+
+
+origin := point [zero,zero,zero,zero]
+
+
+
+
+
+
Create the point with color zero.
+
+
+
+
+
+
+
+unit := point [one,one,one,zero]
+
+
+
+
+
+
Create the curve (well, here, a line) from
+ to .
+
+
+
+
+
+
+
+line := [origin, unit]
+
+
+
+
+
+
+
We make this line segment into an arrow by adding an arrowhead.
+The arrowhead extends to,
+say, on the left, and to, say, on the right.
+To describe an arrow, you tell Axiom to draw the two curves
+ and
+We also decide through experimentation on
+values for , the ratio of the size of
+the arrowhead to the stem of the arrow, and ,
+the angle between the arrowhead and the arrow.
+
+
+
+
Invoke your favorite editor and create
+an input file called arrows.input.
+This input file first defines the values of
+
+
+
+
and , then
+defines the function makeArrow to
+draw an arrow from point to .
+
+
+
+
+
+
+arrowAngle := %pi-%pi/10.0@DFLOAT The angle of the arrowhead.
+arrowScale := 0.2@DFLOAT The size of the arrowhead
+ relative to the stem.
+makeArrow(p1, p2) ==
+ delta := p2 - p1 The arrow.
+ len := arrowScale * length delta The length of the arrowhead.
+ theta := atan(delta.1, delta.2) The angle from the x-axis
+ c1 := len*cos(theta + arrowAngle) The x-coord of left endpoint
+ s1 := len*sin(theta + arrowAngle) The y-coord of left endpoint
+ c2 := len*cos(theta - arrowAngle) The x-coord of right endpoint
+ s2 := len*sin(theta - arrowAngle) The y-coord of right endpoint
+ z := p2.3*(1 - arrowScale) The z-coord of both endpoints
+ p3 := point [p2.1 + c1, p2.2 + s1, z, p2.4] The left endpoint of head
+ p4 := point [p2.1 + c2, p2.2 + s2, z, p2.4] The right endpoint of head
+ [ [p1, p2, p3], [p2, p4] ] The arrow as a list of curves
+
+
+
+
+
Read the file and then create
+an arrow from the point to the point .
+
+
+
+
Read the input file defining makeArrow.
+
+
+
+
+
+
+
+)read arrows
+
+
+
+
+
+
Construct the arrow (a list of two curves).
+
+
+
+
+
+
+
+arrow := makeArrow(origin,unit)
+
+
+
+
+
+
Create an empty object of type .
+
+
+
+
+
+
+
+sp := createThreeSpace()
+
+
+
+
+
+
Add each curve of the arrow to the space .
+
+
+
+
+
+
+
+for a in arrow repeat sp := curve(sp,a)
+
+
+
+
+
+
Create a three-dimensional viewport containing that space.
+
Let's draw a ``bouquet'' of arrows.
+Each arrow is identical. The arrowheads are
+uniformly placed on a circle parallel to the -plane.
+Thus the position of each arrow differs only
+by the angle ,
+ ,
+between the arrow and
+the -axis on the -plane.
+
+
+
+
Our bouquet is rather special: each arrow has a different
+color (which won't be evident here, unfortunately).
+This is arranged by letting the color of each successive arrow be
+denoted by .
+In this way, the color of arrows ranges from red to green to violet.
+Here is a program to draw a bouquet of arrows.
+
+
+
+
+
+
+drawBouquet(n,title) ==}{}
+ angle := 0.0@DFLOAT The initial angle
+ sp := createThreeSpace() Create empty space $sp$
+ for i in 0..n-1 repeat For each index i, create:
+ start := point [0.0@DFLOAT,0.0@DFLOAT,0.0@DFLOAT,angle]
+ the point at base of arrow;
+ end := point [cos angle, sin angle, 1.0@DFLOAT, angle]
+ the point at tip of arrow;
+ arrow := makeArrow(start,end) the $i$th arrow
+ for a in makeArrow(start,end) repeat For each arrow component,
+ curve(sp,a) add the component to $sp$
+ angle := angle + 2*%pi/n The next angle
+ makeViewport3D(sp,title) Create the viewport from $sp$
+
Up to now, if you have typed in all the programs exactly as they are in
+the book, you have encountered no errors.
+In practice, however, it is easy to make mistakes.
+Computers are unforgiving: your program must be letter-for-letter correct
+or you will encounter some error.
+
+
+
+
One thing that can go wrong is that you can create a syntactically
+incorrect program.
+As pointed out in Diversion 1 the meaning of Axiom programs is
+affected by indentation.
+
+
+
+
The Axiom parser will ensure that all parentheses, brackets, and
+braces balance, and that commas and operators appear in the correct
+context.
+
+
+
+
+
A common mistake is to misspell an identifier or operation name.
+These are generally easy to spot since the interpreter will tell you the
+name of the operation together with the type and number of arguments which
+it is trying to find.
+
+
+
+
Another mistake is to either to omit an argument or to give too many.
+Again Axiom will notify you of the offending operation.
+
+
+
+
Indentation makes your programs more readable.
+However there are several ways to create a syntactically valid program.
+A most common problem occurs when a line is indented improperly.
+If this is a first line of a pile then all the other lines will act as an
+inner pile to the first line.
+If it is a line of the pile other than the first line Axiom then
+thinks that this line is a continuation of the previous line.
+More frequently than not a syntactically correct expression is created.
+Almost never however will this be a semantically correct.
+Only when the program is run will an error be discovered.
+
We now put our arrows to good use drawing complex vector fields.
+These vector fields give a representation of complex-valued
+functions of complex variables.
+Consider a Cartesian coordinate grid of points in
+the plane, and some complex-valued function defined on
+this grid.
+At every point on this grid, compute the value of and call it .
+Since has both a real and imaginary value for a given
+ grid point, there are four dimensions to plot.
+What do we do?
+We represent the values of by arrows planted at each
+grid point.
+Each arrow represents the value of in polar coordinates
+ .
+The length of the arrow is proportional to .
+Its direction is given by .
+
+
+
+
The code for drawing vector fields is in the file vectors.input.
+We discuss its contents from top to bottom.
+
+
+
+
Before showing you the code, we have two small
+matters to take care of.
+First, what if the function has large spikes, say, ones that go off
+to infinity?
+We define a variable for this purpose. When
+ exceeds the value of , then the value of
+ is used instead of that for .
+For convenience, we define a function which uses
+ to ``clip'' the value of .
+
+
+
+
+
+
+
+clipValue : DFLOAT := 6 Maximum value allowed
+clipFun(x) == min(max(x,-clipValue),clipValue)
+
+
+
+
+
Notice that we identify as a small float but do
+not declare the type of the function clipFun.
+As it turns out, clipFun is called with a
+small float value.
+This declaration ensures that clipFun never does a
+conversion when it is called.
+
+
+
+
The second matter concerns the possible ``poles'' of a
+function, the actual points where the spikes have infinite
+values.
+Axiom uses normal DoubleFloat arithmetic which
+does not directly handle infinite values.
+If your function has poles, you must adjust your step size to
+avoid landing directly on them (Axiom calls error
+when asked to divide a value by , for example).
+
+
+
+
We set the variables and to
+hold the number of steps taken in the real and imaginary
+directions, respectively.
+Most examples will have ranges centered around the origin.
+To avoid a pole at the origin, the number of points is taken
+to be odd.
+
+
+
+
+
+
+realSteps: INT := 25 Number of real steps
+imagSteps: INT := 25 Number of imaginary steps
+)read arrows
+
+
+
+
+
Now define the function drawComplexVectorField to draw the arrows.
+It is good practice to declare the type of the main function in
+the file.
+This one declaration is usually sufficient to ensure that other
+lower-level functions are compiled with the correct types.
+
The first argument is a function mapping complex small floats into
+complex small floats.
+The second and third arguments give the range of real and
+imaginary values as segments like .
+The result is a three-dimensional viewport.
+Here is the full function definition:
+
+
+
+
+
+
+drawComplexVectorField(f, realRange,imagRange) ==
+ delReal := (hi(realRange)-lo(realRange))/realSteps The real step size
+ delImag := (hi(imagRange)-lo(imagRange))/imagSteps The imaginary step size
+ sp := createThreeSpace() Create empty space $sp$
+ real := lo(realRange) The initial real value
+ for i in 1..realSteps+1 repeat Begin real iteration
+ imag := lo(imagRange) initial imaginary value
+ for j in 1..imagSteps+1 repeat Begin imaginary iteration
+ z := f complex(real,imag) value of $f$ at the point
+ arg := argument z direction of the arrow
+ len := clipFun sqrt norm z length of the arrow
+ p1 := point [real, imag, 0.0@DFLOAT, arg] base point of the arrow
+ scaleLen := delReal * len scaled length of the arrow
+ p2 := point [p1.1 + scaleLen*cos(arg), tip point of the arrow
+ p1.2 + scaleLen*sin(arg),0.0@DFLOAT, arg]
+ arrow := makeArrow(p1, p2) Create the arrow
+ for a in arrow repeat curve(sp, a) Add arrow to space $sp$
+ imag := imag + delImag The next imaginary value
+ real := real + delReal The next real value
+ makeViewport3D(sp, "Complex Vector Field") Draw it
+
+
+
+
+
As a first example, let us draw .
+There is no need to create a user function: just pass the
+sinsinComplex DoubleFloat from Complex DoubleFloat.
+
Here is another way to graph a complex function of complex
+arguments.
+For each complex value , compute , again
+expressing the value in polar coordinates .
+We draw the complex valued function, again considering the
+ -plane as the complex plane, using as the
+height (or -coordinate) and as the color.
+This is a standard plot---we learned how to do this in
+Chapter ugGraph ---
+but here we write a new program to illustrate
+the creation of polygon meshes, or grids.
+
+
+
+
Call this function drawComplex.
+It displays the points using the ``mesh'' of points.
+The function definition is in three parts.
+
+
+
+
+
+
+drawComplex: (C -> C, S, S) -> VIEW3D
+drawComplex(f, realRange, imagRange) == The first part
+ delReal := (hi(realRange)-lo(realRange))/realSteps The real step size
+ delImag := (hi(imagRange)-lo(imagRange))/imagSteps The imaginary step size
+ Initial list of list of points $llp$
+ llp:List List Point DFLOAT := []
+
+
+
+
+
Variables and give the step
+sizes along the real and imaginary directions as computed by the values
+of the global variables and .
+The mesh is represented by a list of lists of points ,
+initially empty.
+Now alone is ambiguous, so
+to set this initial value
+you have to tell Axiom what type of empty list it is.
+Next comes the loop which builds .
+
+
+
+
+
+
+ real := lo(realRange) The initial real value
+ for i in 1..realSteps+1 repeat Begin real iteration
+ imag := lo(imagRange) initial imaginary value
+ lp := []$(List Point DFLOAT) initial list of points $lp$
+ for j in 1..imagSteps+1 repeat Begin imaginary iteration
+ z := f complex(real,imag) value of $f$ at the point
+ pt := point [real,imag, clipFun sqrt norm z, Create a point
+ argument z]
+ lp := cons(pt,lp) Add the point to $lp$
+ imag := imag + delImag The next imaginary value
+ real := real + delReal The next real value
+ llp := cons(lp, llp) Add $lp$ to $llp$
+
+
+
+
+
The code consists of both an inner and outer loop.
+Each pass through the inner loop adds one list of points
+to the list of lists of points .
+The elements of are collected in reverse order.
+
+
+
+
+
+
+ makeViewport3D(mesh(llp), "Complex Function") Create a mesh and display
+
+
+
+
+
The operation mesh then creates an object of type
+ThreeSpace(DoubleFloat) from the list of lists of points.
+This is then passed to makeViewport3D to display the
+image.
+
+
+
+
Now add this function directly to your vectors.input
+file and re-read the file using read vectors.
+We try drawComplex using
+a user-defined function .
+
+
+
+
Read the file.
+
+
+
+
+
+
+
+)read vectors
+
+
+
+
+
+
This one has a pole at .
+
+
+
+
+
+
+
+f(z) == exp(1/z)
+
+
+
+
+
+
Draw it with an odd number of steps to avoid the pole.
+
In ugUserMake ,
+you learned how to use the operation
+ function to create a function from symbolic formulas.
+Here we introduce a similar operation which not only
+creates functions, but functions from functions.
+
+
+
+
The facility we need is provided by the package
+MakeUnaryCompiledFunction(E,S,T).
+MakeUnaryCompiledFunction
+This package produces a unary (one-argument) compiled
+function from some symbolic data
+generated by a previous computation.
+MakeBinaryCompiledFunction is available for binary
+functions.
+MakeBinaryCompiledFunction
+The tells where the symbolic data comes from;
+the and give Axiom the
+source and target type of the function, respectively.
+The compiled function produced has type
+ -> .
+To produce a compiled function with definition , call
+ from this package.
+The function you get has no name.
+You must to assign the function to the variable to give it that name.
+
+
+
+
+
Do some computation.
+
+
+
+
+
+
+
+(x+1/3)**5
+
+
+
+
+
+
Convert this to an anonymous function of .
+Assign it to the variable to give the function a name.
+
Packages provide the bulk of
+package
+Axiom's algorithmic library, from numeric packages for computing
+special functions to symbolic facilities for
+constructor:package
+differential equations, symbolic integration, and limits.
+package:constructor
+
+
+
+
In Chapter ugIntProg ,
+we developed several useful functions for drawing
+vector fields and complex functions.
+We now show you how you can add these functions to the
+Axiom library to make them available for general use.
+
+
+
+
The way we created the functions in Chapter ugIntProg
+ is typical of how
+you, as an advanced Axiom user, may interact with Axiom.
+You have an application.
+You go to your editor and create an input file defining some
+functions for the application.
+Then you run the file and try the functions.
+Once you get them all to work, you will often want to extend them,
+add new features, perhaps write additional functions.
+
+
+
+
Eventually, when you have a useful set of functions for your application,
+you may want to add them to your local Axiom library.
+To do this, you embed these function definitions in a package and add
+that package to the library.
+
+
+
+
To introduce new packages, categories, and domains into the system,
+you need to use the Axiom compiler to convert the constructors
+into executable machine code.
+An existing compiler in Axiom is available on an ``as-is''
+basis.
+A new, faster compiler will be available in version 2.0
+of Axiom.
+
+
+
+
+
+
+
+
+C ==> Complex DoubleFloat All constructors used in a file
+S ==> Segment DoubleFloat must be spelled out in full
+INT ==> Integer unless abbreviated by macros
+DFLOAT ==> DoubleFloat like these at the top of
+VIEW3D ==> ThreeDimensionalViewport a file
+CURVE ==> List List Point DFLOAT
+
+)abbrev package DRAWCX DrawComplex Identify kinds and abbreviations
+DrawComplex(): Exports == Implementation where Type definition begins here
+
+ Exports == with Export part begins
+ drawComplex: (C -> C,S,S,Boolean) -> VIEW3D Exported Operations
+ drawComplexVectorField: (C -> C,S,S) -> VIEW3D
+ setRealSteps: INT -> INT
+ setImagSteps: INT -> INT
+ setClipValue: DFLOAT-> DFLOAT
+
+ Implementation == add Implementation part begins
+ arrowScale : DFLOAT := (0.2)::DFLOAT --relative size Local variable 1
+ arrowAngle : DFLOAT := pi()-pi()/(20::DFLOAT) Local variable 2
+ realSteps : INT := 11 --# real steps Local variable 3
+ imagSteps : INT := 11 --# imaginary steps Local variable 4
+ clipValue : DFLOAT := 10::DFLOAT --maximum vector length
+ Local variable 5
+
+ setRealSteps(n) == realSteps := n Exported function definition 1
+ setImagSteps(n) == imagSteps := n Exported function definition 2
+ setClipValue(c) == clipValue := c Exported function definition 3
+
+ clipFun: DFLOAT -> DFLOAT --Clip large magnitudes.
+ clipFun(x) == min(max(x, -clipValue), clipValue)
+ Local function definition 1
+
+ makeArrow: (Point DFLOAT,Point DFLOAT,DFLOAT,DFLOAT) -> CURVE
+ makeArrow(p1, p2, len, arg) == ... Local function definition 2
+
+ drawComplex(f, realRange, imagRange, arrows?) == ...
+ Exported function definition 4
+
Each package has a name and an abbreviation.
+For a package of the complex draw functions from Chapter
+ugIntProg ,
+we choose the name DrawComplex
+and
+abbreviation:constructor
+abbreviation DRAWCX.An abbreviation can be any string
+of
+constructor:abbreviation
+between two and seven capital letters and digits, beginning with a letter.
+See ugTypesWritingAbbr
+for more information.
+To be sure that you have not chosen a name or abbreviation already used by
+the system, issue the system command )show for both the name and
+the abbreviation.
+show
+
+
+
+
Once you have named the package and its abbreviation, you can choose any new
+filename you like with extension `` .spad'' to hold the
+definition of your package.
+We choose the name drawpak.spad.
+If your application involves more than one package, you
+can put them all in the same file.
+Axiom assumes no relationship between the name of a library file, and
+the name or abbreviation of a package.
+
+
+
+
Near the top of the `` .spad'' file, list all the
+abbreviations for the packages
+using )abbrev, each command beginning in column one.
+Macros giving names to Axiom expressions can also be placed near the
+top of the file.
+The macros are only usable from their point of definition until the
+end of the file.
+
+
+
+
Consider the definition of
+DrawComplex in
+Figure fig-pak-cdraw .
+After the macro
+macro
+definition
+
+
+
+
+
+S ==> Segment DoubleFloat
+
+
+
+
the name
+S can be used in the file as a
+shorthand for Segment DoubleFloat.The interpreter also allows
+macro for macro definitions.
+The abbreviation command for the package
+
+
+
+
+
+)abbrev package DRAWCX DrawComplex
+
+
+
+
is given after the macros (although it could precede them).
+
Recall that packages as abstract datatypes are compiled independently
+and put into the library.
+The curious reader may ask: ``How is the interpreter able to find an
+operation such as bubbleSort!?
+Also, how is a single compiled function such as bubbleSort! able
+to sort data of different types?''
+
+
+
+
After the interpreter loads the package SortPackage, the four
+operations from the package become known to the interpreter.
+Each of these operations is expressed as a modemap in which the type
+modemap
+of the operation is written in terms of symbolic domains.
+
+
+
+
See the modemaps for bubbleSort!.
+
+
+
+
)display op bubbleSort!
+
+
+
+
+
+
+There are 2 exposed functions called bubbleSort! :
+
+ [1] D1 -> D1 from SortPackage(D2,D1)
+ if D2 has ORDSET and D2 has OBJECT and D1 has
+ IndexedAggregate(Integer, D2) with
+ finiteAggregate
+ shallowlyMutable
+
+ [2] (D1,((D3,D3) -> Boolean)) -> D1 from SortPackage(D3,D1)
+ if D3 has OBJECT and D1 has
+ IndexedAggregate(Integer,D3) with
+ finiteAggregate
+ shallowlyMutable
+
+
+
+
+
What happens if you ask for bubbleSort!([1,-5,3])?
+There is a unique modemap for an operation named
+ bubbleSort! with one argument.
+Since is a list of integers, the symbolic domain
+ is defined as List(Integer).
+For some operation to apply, it must satisfy the predicate for
+some .
+What ?
+The third expression of the and requires D1 has
+IndexedAggregate(Integer, D2) with two attributes.
+So the interpreter searches for an IndexedAggregate
+among the ancestors of List (Integer) (see
+ugCategoriesHier ).
+It finds one: IndexedAggregate(Integer, Integer).
+The interpreter tries defining as Integer.
+After substituting for and , the predicate
+evaluates to true.
+An applicable operation has been found!
+
+
+
+
Now Axiom builds the package
+SortPackage(List(Integer), Integer).
+According to its definition, this package exports the required
+operation: bubbleSort!: List Integer->List
+Integer.
+The interpreter then asks the package for a function implementing
+this operation.
+The package gets all the functions it needs (for example,
+ rest and swap) from the appropriate
+domains and then it
+returns a bubbleSort! to the interpreter together with
+the local environment for bubbleSort!.
+The interpreter applies the function to the argument .
+The bubbleSort! function is executed in its local
+environment and produces the result.
+
The syntax for defining a package constructor is the same as that
+syntax
+for defining any function in Axiom.
+In practice, the definition extends over many lines so that this syntax is
+not practical.
+Also, the type of a package is expressed by the operator
+with
+followed by an explicit list of operations.
+A preferable way to write the definition of a package is with a
+where
+expression:
+
+
+
+
The definition of a package usually has the form:
+PackageForm : Exports == Implementation where
+optional type declarations
+ Exports == with
+list of exported operations
+ Implementation == add
+list of function definitions for exported operations
+
+
+
+
+
The DrawComplex package takes no parameters and exports five
+operations, each a separate item of a pile.
+Each operation is described as a declaration: a name, followed
+by a colon (:), followed by the type of the operation.
+All operations have types expressed as mappings with
+the syntax
+
A constructor as defined in Axiom is called an abstract
+datatype in the computer science literature.
+Abstract datatypes separate ``specification'' (what operations are
+provided) from ``implementation'' (how the operations are implemented).
+The Exports (specification) part of a constructor is said to be ``public'' (it
+provides the user interface to the package) whereas the Implementation
+part is ``private'' (information here is effectively hidden---programs
+cannot take advantage of it).
+
+
+
+
The Exports part specifies what operations the package provides to users.
+As an author of a package, you must ensure that
+the Implementation part provides a function for each
+operation in the Exports part.The DrawComplex
+package enhances the facility
+described in Chapter
+ugIntProgCompFuns by allowing a
+complex function to have
+arrows emanating from the surface to indicate the direction of the
+complex argument.
+
+
+
+
An important difference between interactive programming and the
+use of packages is in the handling of global variables such as
+ and .
+In interactive programming, you simply change the values of
+variables by assignment.
+With packages, such variables are local to the package---their
+values can only be set using functions exported by the package.
+In our example package, we provide two functions
+ setRealSteps and setImagSteps for
+this purpose.
+
+
+
+
Another local variable is which can be changed using
+the exported operation setClipValue.
+This value is referenced by the internal function clipFun that
+decides whether to use the computed value of the function at a point or,
+if the magnitude of that value is too large, the
+value assigned to (with the
+appropriate sign).
+
The part to the right of add in the Implementation
+add
+part of the definition is called a capsule.
+The purpose of a capsule is:
+
+
+
+
+
+
+ to define a function for each exported operation, and
+
+
to define a local environment for these functions to run.
+
+
+
+
+
+
What is a local environment?
+First, what is an environment?
+environment
+Think of the capsule as an input file that Axiom reads from top to
+bottom.
+Think of the input file as having a )clear all at the top
+so that initially no variables or functions are defined.
+When this file is read, variables such as and
+ in DrawComplex are set to initial values.
+Also, all the functions defined in the capsule are compiled.
+These include those that are exported (like ), and
+those that are not (like ).
+At the end, you get a set of name-value pairs:
+variable names (like and )
+are paired with assigned values, while
+operation names (like and )
+are paired with function values.
+
+
+
+
This set of name-value pairs is called an environment.
+Actually, we call this environment the ``initial environment'' of a package:
+it is the environment that exists immediately after the package is
+first built.
+Afterwards, functions of this capsule can
+access or reset a variable in the environment.
+The environment is called local since any changes to the value of a
+variable in this environment can be seen only by these functions.
+
+
+
+
Only the functions from the package can change the variables in the local
+environment.
+When two functions are called successively from a package,
+any changes caused by the first function called
+are seen by the second.
+
+
+
+
Since the environment is local to the package, its names
+don't get mixed
+up with others in the system or your workspace.
+If you happen to have a variable called in your
+workspace, it does not affect what the
+DrawComplex functions do in any way.
+
+
+
+
The functions in a package are compiled into machine code.
+Unlike function definitions in input files that may be compiled repeatedly
+as you use them with varying argument types,
+functions in packages have a unique type (generally parameterized by
+the argument parameters of a package) and a unique compilation residing on disk.
+
+
+
+
The capsule itself is turned into a compiled function.
+This so-called capsule function is what builds the initial environment
+spoken of above.
+If the package has arguments (see below), then each call to the package
+constructor with a distinct pair of arguments
+builds a distinct package, each with its own local environment.
+
A good question at this point would be ``Is writing a package more difficult than
+writing an input file?''
+
+
+
+
The programs in input files are designed for flexibility and ease-of-use.
+Axiom can usually work out all of your types as it reads your program
+and does the computations you request.
+Let's say that you define a one-argument function without giving its type.
+When you first apply the function to a value, this
+value is understood by Axiom as identifying the type for the
+argument parameter.
+Most of the time Axiom goes through the body of your function and
+figures out the target type that you have in mind.
+Axiom sometimes fails to get it right.
+Then---and only then---do you need a declaration to tell Axiom what
+type you want.
+
+
+
+
Input files are usually written to be read by Axiom---and by you.
+file:input:vs. package
+Without suitable documentation and declarations, your input files
+package:vs. input file
+are likely incomprehensible to a colleague---and to you some
+months later!
+
+
+
+
Packages are designed for legibility, as well as
+run-time efficiency.
+There are few new concepts you need to learn to write
+packages. Rather, you just have to be explicit about types
+and type conversions.
+The types of all functions are pre-declared so that Axiom---and the reader---
+knows precisely what types of arguments can be passed to and from
+the functions (certainly you don't want a colleague to guess or to
+have to work this out from context!).
+The types of local variables are also declared.
+Type conversions are explicit, never automatic.There
+is one exception to this rule: conversions from a subdomain to a
+domain are automatic.
+After all, the objects both have the domain as a common type.
+
+
+
+
In summary, packages are more tedious to write than input files.
+When writing input files, you can casually go ahead, giving some
+facts now, leaving others for later.
+Writing packages requires forethought, care and discipline.
+
Once you have defined the package DrawComplex,
+you need to compile and test it.
+To compile the package, issue the system command )compile drawpak.
+Axiom reads the file drawpak.spad
+and compiles its contents into machine binary.
+If all goes well, the file DRAWCX.NRLIB is created in your
+local directory for the package.
+To test the package, you must load the package before trying an
+operation.
+
+
+
+
Compile the package.
+
+
+
+
+
+
+
+)compile drawpak
+
+
+
+
+
+
Expose the package.
+
+
+
+
+
+
+
+)expose DRAWCX
+
+
+
+
+
+
Use an odd step size to avoid
+a pole at the origin.
+
+
+
+
+
+
+
+setRealSteps 51
+
+
+
+
+
+
+
+
+
+setImagSteps 51
+
+
+
+
+
+
Define f to be the Gamma function.
+
+
+
+
+
+
+
+f(z) == Gamma(z)
+
+
+
+
+
+
Clip values of function with magnitude larger than 7.
+
The power of packages becomes evident when packages have parameters.
+Usually these parameters are domains and the exported operations have types
+involving these parameters.
+
+
+
+
In Chapter ugTypes ,
+you learned that categories denote classes of domains.
+Although we cover this notion in detail in the next
+chapter, we now give you a sneak preview of its usefulness.
+
+
+
+
In ugUserBlocks ,
+we defined functions and
+ to sort a list of integers.
+If you look at the code for these functions, you see that they may be
+used to sort any structure with the right properties.
+Also, the functions can be used to sort lists of any elements---not
+just integers.
+Let us now recall the code for .
+
+
+
+
+
+
+bubbleSort(m) ==
+ n := #m
+ for i in 1..(n-1) repeat
+ for j in n..(i+1) by -1 repeat
+ if m.j < m.(j-1) then swap!(m,j,j-1)
+ m
+
+
+
+
+
What properties of ``lists of integers'' are assumed by the sorting
+algorithm?
+In the first line, the operation # computes the maximum index of
+the list.
+The first obvious property is that must have a finite number of
+elements.
+In Axiom, this is done
+by your telling Axiom that has
+the ``attribute'' finiteAggregate.
+An attribute is a property
+that a domain either has or does not have.
+As we show later in
+ugCategoriesAttributes ,
+programs can query domains as to the presence or absence of an attribute.
+
+
+
+
The operation swap swaps elements of .
+Using Browse, you find that swap requires its
+elements to come from a domain of category
+IndexedAggregate with attribute
+shallowlyMutable.
+This attribute means that you can change the internal components
+of without changing its external structure.
+Shallowly-mutable data structures include lists, streams, one- and
+two-dimensional arrays, vectors, and matrices.
+
+
+
+
The category IndexedAggregate designates the class of
+aggregates whose elements can be accessed by the notation
+ for suitable selectors .
+The category IndexedAggregate takes two arguments:
+, a domain of selectors for the aggregate, and
+, a domain of entries for the aggregate.
+Since the sort functions access elements by integers, we must
+choose Integer.
+The most general class of domains for which and
+ are defined are those of
+category IndexedAggregate(Integer,Entry) with the two
+attributes shallowlyMutable and
+ finiteAggregate.
+
+
+
+
Using Browse, you can also discover that Axiom has many kinds of domains
+with attribute shallowlyMutable.
+Those of class IndexedAggregate(Integer,Entry) include
+Bits, FlexibleArray, OneDimensionalArray,
+List, String, and Vector, and also
+HashTable and EqTable with integer keys.
+Although you may never want to sort all such structures, we
+nonetheless demonstrate Axiom's
+ability to do so.
+
+
+
+
Another requirement is that Entry has an
+operation <.
+One way to get this operation is to assume that
+Entry has category OrderedSet.
+By definition, will then export a < operation.
+A more general approach is to allow any comparison function
+ to be used for sorting.
+This function will be passed as an argument to the sorting
+functions.
+
+
+
+
Our sorting package then takes two arguments: a domain
+of objects of any type, and a domain , an aggregate
+of type IndexedAggregate(Integer, S) with the above
+two attributes.
+Here is its definition using what are close to the original
+definitions of and for
+sorting lists of integers.
+The symbol ! is added to the ends of the operation
+names.
+This uniform naming convention is used for Axiom operation
+names that destructively change one or more of their arguments.
+
+
+
+
+
+
+SortPackage(S,A) : Exports == Implementation where
+ S: Object
+ A: IndexedAggregate(Integer,S)
+ with (finiteAggregate; shallowlyMutable)
+
+ Exports == with
+ bubbleSort!: (A,(S,S) -> Boolean) -> A
+ insertionSort!: (A, (S,S) -> Boolean) -> A
+
+ Implementation == add
+ bubbleSort!(m,f) ==
+ n := #m
+ for i in 1..(n-1) repeat
+ for j in n..(i+1) by -1 repeat
+ if f(m.j,m.(j-1)) then swap!(m,j,j-1)
+ m
+ insertionSort!(m,f) ==
+ for i in 2..#m repeat
+ j := i
+ while j > 1 and f(m.j,m.(j-1)) repeat
+ swap!(m,j,j-1)
+ j := (j - 1) pretend PositiveInteger
+ m
+
When packages have parameters, you can say that an operation is or is not
+conditional
+exported depending on the values of those parameters.
+When the domain of objects has an <
+operation, we can supply one-argument versions of
+ and which use this operation
+for sorting.
+The presence of the
+operation < is guaranteed when is an ordered set.
+
+
+
+
+
+
+Exports == with
+ bubbleSort!: (A,(S,S) -> Boolean) -> A
+ insertionSort!: (A, (S,S) -> Boolean) -> A
+
+ if S has OrderedSet then
+ bubbleSort!: A -> A
+ insertionSort!: A -> A
+
+
+
+
+
In addition to exporting the one-argument sort operations
+sort:bubble
+conditionally, we must provide conditional definitions for the
+sort:insertion
+operations in the Implementation part.
+This is easy: just have the one-argument functions call the
+corresponding two-argument functions with the operation
+< from .
+
+
+
+
+
+
+ Implementation == add
+ ...
+ if S has OrderedSet then
+ bubbleSort!(m) == bubbleSort!(m,< $S)
+ insertionSort!(m) == insertionSort!(m,< $S)
+
+
+
+
+
In ugUserBlocks ,
+we give an alternative definition of
+ bubbleSort using firstfirstList and
+restrestList that is more efficient for a list (for
+which access to any element requires traversing the list from its
+first node).
+To implement a more efficient algorithm for lists, we need the
+operation setelt which allows us to destructively change
+the first and rest of a list.
+Using Browse, you find that these operations come from category
+UnaryRecursiveAggregate.
+Several aggregate types are unary recursive aggregates including
+those of List and AssociationList.
+We provide two different implementations for
+ bubbleSort! and insertionSort!: one
+for list-like structures, another for array-like structures.
+
+
+
+
+
+
+Implementation == add
+ ...
+ if A has UnaryRecursiveAggregate(S) then
+ bubbleSort!(m,fn) ==
+ empty? m => m
+ l := m
+ while not empty? (r := l.rest) repeat
+ r := bubbleSort! r
+ x := l.first
+ if fn(r.first,x) then
+ l.first := r.first
+ r.first := x
+ l.rest := r
+ l := l.rest
+ m
+ insertionSort!(m,fn) ==
+ ...
+
+
+
+
+
The ordering of definitions is important.
+The standard definitions come first and
+then the predicate
+
+
+
+
+
+A has UnaryRecursiveAggregate(S)
+
+
+
+
is evaluated.
+If true, the special definitions cover up the standard ones.
+
+
+
+
Another equivalent way to write the capsule is to use an
+ expression:
+if
+
+
+
+
+
+
+ if A has UnaryRecursiveAggregate(S) then
+ ...
+ else
+ ...
+
Once you have written the package, embed it in a file, for example,
+sortpak.spad.
+testing
+Be sure to include an )abbrev command at the top of the file:
+
+
+
+
+
+)abbrev package SORTPAK SortPackage
+
+
+
+
Now compile the file (using )compile sortpak.spad).
+
+
+
+
Expose the constructor.
+You are then ready to begin testing.
+
+
+
+
+
+
+
+)expose SORTPAK
+
+
+
+
+
+
Define a list.
+
+
+
+
+
+
+
+l := [1,7,4,2,11,-7,3,2]
+
+
+
+
+
+
Since the integers are an ordered set,
+a one-argument operation will do.
+
+
+
+
+
+
+
+bubbleSort!(l)
+
+
+
+
+
+
Re-sort it using ``greater than.''
+
+
+
+
+
+
+
+bubbleSort!(l,(x,y) +-> x > y)
+
+
+
+
+
+
Now sort it again using < on integers.
+
+
+
+
+
+
+
+bubbleSort!(l, < $Integer)
+
+
+
+
+
+
A string is an aggregate of characters so we can sort them as well.
+
+
+
+
+
+
+
+bubbleSort! "Mathematical Sciences"
+
+
+
+
+
+
Is < defined on booleans?
+
+
+
+
+
+
+
+false < true
+
+
+
+
+
+
Good! Create a bit string representing ten consecutive
+boolean values true.
+
+
+
+
+
+
+
+u : Bits := new(10,true)
+
+
+
+
+
+
Set bits 3 through 5 to false, then display the result.
+
+
+
+
+
+
+
+u(3..5) := false; u
+
+
+
+
+
+
Now sort these booleans.
+
+
+
+
+
+
+
+bubbleSort! u
+
+
+
+
+
+
Create an ``eq-table'', a
+table having integers as keys
+and strings as values.
+
This chapter unravels the mysteries of categories---what
+category
+they are, how they are related to domains and packages,
+category:constructor
+how they are defined in Axiom, and how you can extend the
+constructor:category
+system to include new categories of your own.
+
+
+
+
We assume that you have read the introductory material on domains
+and categories in ugTypesBasicDomainCons .
+There you learned that the notion of packages covered in the
+previous chapter are special cases of domains.
+While this is in fact the case, it is useful here to regard domains
+as distinct from packages.
+
+
+
+
Think of a domain as a datatype, a collection of objects (the
+objects of the domain).
+From your ``sneak preview'' in the previous chapter, you might
+conclude that categories are simply named clusters of operations
+exported by domains.
+As it turns out, categories have a much deeper meaning.
+Categories are fundamental to the design of Axiom.
+They control the interactions between domains and algorithmic
+packages, and, in fact, between all the components of Axiom.
+
+
+
+
Categories form hierarchies as shown on the inside cover pages of
+this book.
+The inside front-cover pages illustrate the basic
+algebraic hierarchy of the Axiom programming language.
+The inside back-cover pages show the hierarchy for data
+structures.
+
+
+
+
Think of the category structures of Axiom as a foundation
+for a city on which superstructures (domains) are built.
+The algebraic hierarchy, for example, serves as a foundation for
+constructive mathematical algorithms embedded in the domains of
+Axiom.
+Once in place, domains can be constructed, either independently or
+from one another.
+
+
+
+
Superstructures are built for quality---domains are compiled into
+machine code for run-time efficiency.
+You can extend the foundation in directions beyond the space
+directly beneath the superstructures, then extend selected
+superstructures to cover the space.
+Because of the compilation strategy, changing components of the
+foundation generally means that the existing superstructures
+(domains) built on the changed parts of the foundation
+(categories) have to be rebuilt---that is, recompiled.
+
+
+
+
Before delving into some of the interesting facts about categories, let's see
+how you define them in Axiom.
+
The definition starts off with the name of the
+category (SetCategory); this is
+always in column one in the source file.
+
+All parts of a category definition are then indented with respect to this
+indentation
+first line.
+
+
+
+
In Chapter ugTypes ,
+we talked about Ring as denoting the
+class of all domains that are rings, in short, the class of all
+rings.
+While this is the usual naming convention in Axiom, it is also
+common to use the word ``Category'' at the end of a category name for clarity.
+The interpretation of the name SetCategory is, then, ``the
+category of all domains that are (mathematical) sets.''
+
+
+
+
The name SetCategory is followed in the definition by its
+formal parameters enclosed in parentheses ().
+Here there are no parameters.
+As required, the type of the result of this category function is the
+distinguished name Category.
+
+
+
+
Then comes the ==.
+As usual, what appears to the right of the == is a
+definition, here, a category definition.
+A category definition always has two parts separated by the reserved word
+with
+ .
+Debugging hint: it is very easy to forget
+the !
+
+
+
+
The first part tells what categories the category extends.
+Here, the category extends two categories: Type, the
+category of all domains, and
+CoercibleTo(OutputForm).
+CoercibleTo(OutputForm)
+can also be written (and is written in the definition above) without
+parentheses.
+The operation is a system-defined operation that
+Join
+forms a single category from two or more other categories.
+
+
+
+
Every category other than Type is an extension of some other
+category.
+If, for example, SetCategory extended only the category
+Type, the definition here would read ``Type with
+...''.
+In fact, the Type is optional in this line; ``with
+...'' suffices.
+
Like domain constructors, category constructors can also have
+parameters.
+For example, category MatrixCategory is a parameterized
+category for defining matrices over a ring so that the
+matrix domains can have
+different representations and indexing schemes.
+Its definition has the form:
+
+
+
+
+
+
+MatrixCategory(R,Row,Col): Category ==
+ TwoDimensionalArrayCategory(R,Row,Col) with ...
+
+
+
+
+
The category extends TwoDimensionalArrayCategory with
+the same arguments.
+You cannot find TwoDimensionalArrayCategory in the
+algebraic hierarchy listing.
+Rather, it is a member of the data structure hierarchy,
+given inside the back cover of this book.
+In particular, TwoDimensionalArrayCategory is an extension of
+HomogeneousAggregate since its elements are all one type.
+
+
+
+
The domain Matrix(R), the class of matrices with coefficients
+from domain , asserts that it is a member of category
+MatrixCategory(R, Vector(R), Vector(R)).
+The parameters of a category must also have types.
+The first parameter to MatrixCategory
+ is required to be a ring.
+The second and third are required to be domains of category
+FiniteLinearAggregate(R).
+This is another extension of
+HomogeneousAggregate that you can see in
+the data structure hierarchy.
+In practice, examples of categories having parameters other than
+domains are rare.
+
+
+
+
Adding the declarations for parameters to the definition for
+MatrixCategory, we have:
+
+
+
+
+
+
+R: Ring
+(Row, Col): FiniteLinearAggregate(R)
+
+MatrixCategory(R, Row, Col): Category ==
+ TwoDimensionalArrayCategory(R, Row, Col) with ...
+
As categories have parameters, the actual operations exported by a
+conditional
+category can depend on these parameters.
+As an example, the operation determinantdeterminantMatrixCategory
+from category MatrixCategory is only exported when the
+underlying domain has commutative multiplication:
+
+
+
+
+
+
+if R has commutative("*") then
+ determinant: $ -> R
+
+
+
+
+
Conditionals can also define conditional extensions of a category.
+Here is a portion of the definition of QuotientFieldCategory:
+QuotientFieldCategory
+
+
+
+
+
+
+QuotientFieldCategory(R) : Category == ... with ...
+ if R has OrderedSet then OrderedSet
+ if R has IntegerNumberSystem then
+ ceiling: $ -> R
+ ...
+
+
+
+
+
Think of category QuotientFieldCategory(R) as
+denoting the domain Fraction(R), the
+class of all fractions of the form for elements of .
+The first conditional means in English:
+``If the elements of are totally ordered (
+is an OrderedSet), then so are the fractions ''.
+Fraction
+
+
+
+
The second conditional is used to conditionally export an
+operation ceiling which returns the smallest integer
+greater than or equal to its argument.
+Clearly, ``ceiling'' makes sense for integers but not for
+polynomials and other algebraic structures.
+Because of this conditional,
+the domain Fraction(Integer) exports
+an operation
+ ceiling: Fraction Integer->Integer, but
+Fraction Polynomial Integer does not.
+
+
+
+
Conditionals can also appear in the default definitions for the
+operations of a category.
+For example, a default definition for ceilingceilingField
+within the part following the reads:
+
+
+
+
+
+
+if R has IntegerNumberSystem then
+ ceiling x == ...
+
+
+
+
+
Here the predicate used is identical to the predicate in the Exports part. This need not be the case. See ugPackagesConds
+ for a more complicated example.
+
The part of a category to the right of a with is also regarded
+as a category---an ``anonymous category.'' Thus you have already seen
+a category definition category:anonymous in Chapter
+ugPackages . The Exports part
+of the package DrawComplex (ugPackagesAbstract ) is an anonymous category. This is
+not necessary. We could, instead, give this category a name:
+
+
+
+
+
+
+
+DrawComplexCategory(): Category == with
+ drawComplex: (C -> C,S,S,Boolean) -> VIEW3D
+ drawComplexVectorField: (C -> C,S,S) -> VIEW3D
+ setRealSteps: INT -> INT
+ setImagSteps: INT -> INT
+ setClipValue: DFLOAT-> DFLOAT
+
+
+
+
+
and then define DrawComplex by:
+
+
+
+
+
+
+DrawComplex(): DrawComplexCategory == Implementation
+ where
+ ...
+
+
+
+
+
+
There is no reason, however, to give this list of exports a name
+since no other domain or package exports it.
+In fact, it is rare for a package to export a named category.
+As you will see in the next chapter, however, it is very common
+for the definition of domains to mention one or more category
+before the with.
+with
+
To the right of the is a list of
+with
+all the exports of the category.
+Each exported operation has a name and a type expressed by a
+declaration of the form
+``name: type''.
+
+
+
+
Categories can export symbols, as well as
+0 and 1 which denote
+domain constants.The
+numbers 0 and 1 are operation names in Axiom.
+In the current implementation, all other exports are operations with
+types expressed as mappings with the syntax
+
+
+
+
+
+
+
+
source -> target
+
+
+
+
+
+
+
+
+
+
The category SetCategory has a single export: the operation
+ whose type is given by the mapping ($, $) -> Boolean.
+The $ in a mapping type always means ``the domain.'' Thus
+the operation takes two arguments from the domain and
+returns a value of type Boolean.
+
+
+
+
The source part of the mapping here is given by a tuple
+tuple
+consisting of two or more types separated by commas and enclosed in
+parentheses.
+If an operation takes only one argument, you can drop the parentheses
+around the source type.
+If the mapping has no arguments, the source part of the mapping is either
+left blank or written as ().
+Here are examples of formats of various operations with some
+contrived names.
+
The definition of SetCategory above is missing
+an important component: its library documentation.
+documentation
+Here is its definition, complete with documentation.
+
+
+
+
+
+
+++ Description:
+++ \bs{}axiomType\{SetCategory\} is the basic category
+++ for describing a collection of elements with
+++ \bs{}axiomOp\{=\} (equality) and a \bs{}axiomFun\{coerce\}
+++ to \bs{}axiomType\{OutputForm\}.
+
+SetCategory(): Category ==
+ Join(Type, CoercibleTo OutputForm) with
+ "=": ($, $) -> Boolean
+ ++ \bs{}axiom\{x = y\} tests if \bs{}axiom\{x\} and
+ ++ \bs{}axiom\{y\} are equal.
+
+
+
+
+
Documentary comments are an important part of constructor definitions.
+Documentation is given both for the category itself and for
+each export.
+A description for the category precedes the code.
+Each line of the description begins in column one with ++.
+The description starts with the word Description:.Other
+information such as the author's name, date of creation, and so on,
+can go in this
+area as well but are currently ignored by Axiom.
+All lines of the description following the initial line are
+indented by the same amount.
+
+
+
+
+
Surround the name of any constructor (with or without parameters) with an
+{\bf }.
+Similarly, surround an
+operator name with {\tt },
+an Axiom operation with {\bf }, and a
+variable or Axiom expression with
+$$.
+Library documentation is given in a TeX-like language so that
+it can be used both for hard-copy and for Browse.
+These different wrappings cause operations and types to have
+mouse-active buttons in Browse.
+For hard-copy output, wrapped expressions appear in a different font.
+The above documentation appears in hard-copy as:
+
+
+
+
+
+
+
+
+
+
+
+
SetCategory is the basic category
+for describing a collection of elements with =
+(equality) and a coerce to OutputForm.
+
+
+
+
+
+
+
+
+
+
and
+
+
+
+
+
+
+
+
+
+
tests if and are equal.
+
+
+
+
+
+
+
+
+
+
+
For our purposes in this chapter, we omit the documentation from further
+category descriptions.
+
This definition is as simple as that for SetCategory,
+except that there are two exported operations.
+Multiple exported operations are written as a pile,
+that is, they all begin in the same column.
+Here you see that the category mentions another type,
+PositiveInteger, in a signature.
+Any domain can be used in a signature.
+
+
+
+
Since categories extend one another, they form hierarchies.
+Each category other than Type has one or more parents given
+by the one or more categories mentioned before the part of
+the definition.
+SemiGroup extends SetCategory and
+SetCategory extends both Type and
+CoercibleTo (OutputForm).
+Since CoercibleTo (OutputForm) also extends Type,
+the mention of Type in the definition is unnecessary but
+included for emphasis.
+
We say a category designates a class of domains.
+What class of domains?
+category:membership
+That is, how does Axiom know what domains belong to what categories?
+The simple answer to this basic question is key to the design of
+Axiom:
+
+
+
+
+
+
+
+
+
Domains belong to categories by assertion.
+
+
+
+
+
+
+
+
+
When a domain is defined, it is asserted to belong to one or more
+categories.
+Suppose, for example, that an author of domain String wishes to
+use the binary operator to denote concatenation.
+Thus would produce the string
+ . Actually, concatenation of strings in
+Axiom is done by juxtaposition or by using the operation
+concatconcatString.
+The expression produces the string
+ .
+The author of String could then assert that String
+is a member of SemiGroup.
+According to our definition of SemiGroup, strings
+would then also have the operation defined automatically.
+Then would produce a string of eight dashes
+ .
+Since String is a member of SemiGroup, it also is
+a member of SetCategory and thus has an operation
+ for testing that two strings are equal.
+
+
+
+
Now turn to the algebraic category hierarchy inside the
+front cover of this book.
+Any domain that is a member of a
+category extending SemiGroup is a member of
+SemiGroup (that is, it is a semigroup).
+In particular, any domain asserted to be a Ring is a
+semigroup since Ring extends Monoid, that,
+in turn, extends SemiGroup.
+The definition of Integer in Axiom asserts that
+Integer is a member of category
+IntegerNumberSystem, that, in turn, asserts that it is
+a member of EuclideanDomain.
+Now EuclideanDomain extends
+PrincipalIdealDomain and so on.
+If you trace up the hierarchy, you see that
+EuclideanDomain extends Ring, and,
+therefore, SemiGroup.
+Thus Integer is a semigroup and also exports the
+operations and .
+
We actually omitted the last category:defaults part of the
+definition of default definitionsSemiGroup in
+ugCategoriesHier . Here now
+is its complete Axiom definition.
+
The part at the end is used to give ``default definitions'' for
+add
+exported operations.
+Once you have a multiplication operation , you can
+define exponentiation
+for positive integer exponents
+using repeated multiplication:
+
+
+
+
+
+
+
+
This definition for is called a default definition.
+In general, a category can give default definitions for any
+operation it exports.
+Since SemiGroup and all its category descendants in the hierarchy
+export , any descendant category may redefine as well.
+
+
+
+
A domain of category SemiGroup
+(such as Integer) may or may not choose to
+define its own operation.
+If it does not, a default definition that is closest (in a ``tree-distance''
+sense of the hierarchy) to the domain is chosen.
+
+
+
+
The part of the category definition following an operation
+is a capsule, as discussed in
+the previous chapter.
+The line
+
+
+
+
+
+import RepeatedSquaring($)
+
+
+
+
references the package
+RepeatedSquaring($), that is, the package
+RepeatedSquaring that takes ``this domain'' as its
+parameter.
+For example, if the semigroup Polynomial (Integer)
+does not define its own exponentiation operation, the
+definition used may come from the package
+RepeatedSquaring (Polynomial (Integer)).
+The next line gives the definition in terms of expt from that
+package.
+
+
+
+
The default definitions are collected to form a ``default
+package'' for the category.
+The name of the package is the same as the category but with an
+ampersand (&) added at the end.
+A default package always takes an additional argument relative to the
+category.
+Here is the definition of the default package SemiGroup& as
+automatically generated by Axiom from the above definition of
+SemiGroup.
+
In the previous section you saw the
+complete Axiom program defining axiom
+SemiGroup.
+According to this definition semigroups are sets with
+the operations * and
+**.
+SemiGroup
+
+
+
+
You might ask: ``Aside from the notion of default packages, isn't
+a category just a macro, that is, a shorthand
+equivalent to the two operations and with
+their types?'' If a category were a macro, every time you saw the
+word SemiGroup, you would rewrite it by its list of
+exported operations.
+Furthermore, every time you saw the exported operations of
+SemiGroup among the exports of a constructor, you could
+conclude that the constructor exported SemiGroup.
+
+
+
+
A category is not a macro and here is why.
+The definition for SemiGroup has documentation that states:
+
+
+
+
+
+
+
+
+
Category SemiGroup denotes the class of all multiplicative
+ semigroups, that is, a set with an associative operation .
+
According to the author's remarks, the mere
+exporting of an operation named and is not
+enough to qualify the domain as a SemiGroup.
+In fact, a domain can be a semigroup only if it explicitly
+exports a and
+a satisfying the associativity axiom.
+
+
+
+
In general, a category name implies a set of axioms, even mathematical
+theorems.
+There are numerous axioms from Ring, for example,
+that are well-understood from the literature.
+No attempt is made to list them all.
+Nonetheless, all such mathematical facts are implicit by the use of the
+name Ring.
+
While such statements are only comments,
+correctness
+Axiom can enforce their intention simply by shifting the burden of
+responsibility onto the author of a domain.
+A domain belongs to category only if the
+author asserts that the domain belongs to Ring or
+to a category that extends Ring.
+
+
+
+
This principle of assertion is important for large user-extendable
+systems.
+Axiom has a large library of operations offering facilities in
+many areas.
+Names such as norm and product, for example, have
+diverse meanings in diverse contexts.
+An inescapable hindrance to users would be to force those who wish to
+extend Axiom to always invent new names for operations.
+ I don't think disambiguate is really a word, though I like it
+Axiom allows you to reuse names, and then use context to disambiguate one
+from another.
+
+
+
+
Here is another example of why this is important.
+Some languages, such as APL,
+APL
+denote the Boolean constants true and
+false by the integers and .
+You may want to let infix operators and serve as the logical
+operators or and and, respectively.
+But note this: Boolean is not a ring.
+The inverse axiom for Ring states:
+
+
+
+
+
+
+
+
+
Every element has an additive inverse such that
+ .
+
+
+
+
+
+
+
+
+
Boolean is not a ring since true has
+no inverse---there is no inverse element such that
+ (in terms of booleans, (true or a) = false).
+Nonetheless, Axiom could easily and correctly implement
+Boolean this way.
+Boolean simply would not assert that it is of category
+Ring.
+Thus the ``+'' for Boolean values
+is not confused with the one for Ring.
+Since the Polynomial constructor requires its argument
+to be a ring, Axiom would then refuse to build the
+domain Polynomial(Boolean). Also, Axiom would refuse to
+wrongfully apply algorithms to Boolean elements that presume that the
+ring axioms for ``+'' hold.
+
Most axioms are not computationally useful.
+Those that are can be explicitly expressed by what Axiom calls an
+attribute.
+The attribute commutative("*"), for example, is used to assert
+that a domain has commutative multiplication.
+Its definition is given by its documentation:
+
+
+
+
+
+
+
+
+
A domain has commutative("*")
+ if it has an operation "*": (R,R)->R such that .
+
+
+
+
+
+
+
+
+
Just as you can test whether a domain has the category Ring, you
+can test that a domain has a given attribute.
+
+
+
+
+
Do polynomials over the integers
+have commutative multiplication?
+
+
+
+
+
+
+
+Polynomial Integer has commutative("*")
+
+
+
+
+
+
Do matrices over the integers
+have commutative multiplication?
+
+
+
+
+
+
+
+Matrix Integer has commutative("*")
+
+
+
+
+
+
Attributes are used to conditionally export and define operations for
+a domain (see ugDomainsAssertions ). Attributes can also be asserted
+in a category definition.
+
+
+
+
After mentioning category Ring many times in this book,
+it is high time that we show you its definition:
+Ring
+
There are only two new things here.
+First, look at the $$ on the last line.
+This is not a typographic error!
+The first $ says that the is to come from some
+domain.
+The second $ says that the domain is ``this domain.''
+If $ is Fraction(Integer), this line reads coerce(n) == n * 1$Fraction(Integer).
+
+
+
+
The second new thing is the presence of attribute `` ''.
+Axiom can always distinguish an attribute from an operation.
+An operation has a name and a type. An attribute has no type.
+The attribute unitsKnown asserts a rather subtle mathematical
+fact that is normally taken for granted when working with
+rings.With this axiom, the units of a domain are the set of
+elements that each have a multiplicative
+inverse in the domain.
+Thus and are units in domain Integer.
+Also, for Fraction Integer, the domain of rational numbers,
+all non-zero elements are units.
+Because programs can test for this attribute, Axiom can
+correctly handle rather more complicated mathematical structures (ones
+that are similar to rings but do not have this attribute).
+
We finally come to the domain constructor.
+A few subtle differences between packages and
+domains turn up some interesting issues.
+We first discuss these differences then
+describe the resulting issues by illustrating a program
+for the QuadraticForm constructor.
+After a short example of an algebraic constructor,
+ CliffordAlgebra, we show how you use domain constructors to build
+a database query facility.
+
Packages are special cases of domains.
+What is the difference between a package and a domain that is not a
+package?
+By definition, there is only one difference: a domain that is not a package
+has the symbol $ appearing
+somewhere among the types of its exported operations.
+The $ denotes ``this domain.'' If the $
+appears before the -> in the type of a signature, it means
+the operation takes an element from the domain as an argument.
+If it appears after the ->, then the operation returns an
+element of the domain.
+
+
+
+
If no exported operations mention $, then evidently there is
+nothing of interest to do with the objects of the domain. You might
+then say that a package is a ``boring'' domain! But, as you saw in
+Chapter ugPackages, packages are a
+very useful notion indeed. The exported operations of a package
+depend solely on the parameters to the package constructor and other
+explicit domains.
+
+
+
+
To summarize, domain constructors are versatile structures that serve two
+distinct practical purposes:
+Those like Polynomial and List
+describe classes of computational objects;
+others, like SortPackage, describe packages of useful
+operations.
+As in the last chapter, we focus here on the first kind.
+
Aside from the notion of where an operation is implemented,
+operation:origin
+a useful notion is the origin or ``home'' of an operation.
+When an operation (such as
+quadraticFormquadraticFormQuadraticForm) is explicitly exported by
+a domain (such as QuadraticForm), you can say that the
+origin of that operation is that domain.
+If an operation is not explicitly exported from a domain, it is inherited
+from, and has as origin, the (closest) category that explicitly exports it.
+The operations and (from AbelianMonoid) of QuadraticForm,
+for example, are inherited from AbelianMonoid.
+As it turns out, AbelianMonoid is the origin of virtually every
+ + operation in Axiom!
+
+
+
+
Again, you can use Browse to discover the origins of
+operations.
+From the Browse page on QuadraticForm, click on
+Operations, then on origins at the bottom of the page.
+
+
+
+
The origin of the operation is the only place where on-line
+documentation is given.
+However, you can re-export an operation to give it special
+documentation.
+Suppose you have just invented the world's fastest algorithm for
+inverting matrices using a particular internal representation for
+matrices.
+If your matrix domain just declares that it exports
+ MatrixCategory, it exports the inverse
+operation, but the documentation the user gets from Browse is
+the standard one from MatrixCategory.
+To give your version of inverse the attention it
+deserves, simply export the operation explicitly with new
+documentation.
+This redundancy gives inverse a new origin and tells
+Browse to present your new documentation.
+
In Axiom, a domain could be defined using only an add-domain
+and no capsule.
+Although we talk about rational numbers as quotients of integers,
+there is no type RationalNumber in Axiom.
+To create such a type, you could compile the following
+``short-form'' definition:
+
+
+
+
+
+
+RationalNumber() == Fraction(Integer)
+
+
+
+
+
The Exports part of this definition is missing and is taken
+to be equivalent to that of Fraction(Integer).
+Because of the add-domain philosophy, you get precisely
+what you want.
+The effect is to create a little stub of a domain.
+When a user asks to add two rational numbers, Axiom would
+ask RationalNumber for a function implementing this
+ +.
+Since the domain has no capsule, the domain then immediately
+sends its request to Fraction (Integer).
+
+
+
+
The short form definition for domains is used to
+define such domains as MultivariatePolynomial:
+MultivariatePolynomial
+
Now that we have QuadraticForm available,
+let's put it to use.
+Given some quadratic form described by an
+ by matrix over a field , the domain
+ CliffordAlgebra(n, K, Q) defines a vector space of
+dimension over .
+This is an interesting domain since complex numbers, quaternions,
+exterior algebras and spin algebras are all examples of Clifford
+algebras.
+
+
+
+
The basic idea is this:
+the quadratic form defines a basis
+ for the
+vector space , the direct product of
+with itself times.
+From this, the Clifford algebra generates a basis of
+ elements given by all the possible products
+of the in order without duplicates, that is,
+
+
+
+
1,
+,
+,
+,
+,
+,
+,
+,
+and so on.
+
+
+
+
The algebra is defined by the relations
+
+
+
+
+
+
+
+
+
+
+
+
Now look at the snapshot of its definition given below.
+Lines 9-10 show part of the definitions of the
+ Exports. A Clifford algebra over a field is asserted to be
+a ring, an algebra over , and a vector space over . Its
+explicit exports include which returns the -th unit
+element.
+
+
+
+
+
+
+
+
+
+NNI ==> NonNegativeInteger
+PI ==> PositiveInteger
+
+CliffordAlgebra(n,K,q): Exports == Implementation where
+ n: PI
+ K: Field
+ q: QuadraticForm(n, K)
+
+ Exports == Join(Ring,Algebra(K),VectorSpace(K)) with
+ e: PI -> $
+ ...
+
+ Implementation == add
+ Qeelist :=
+ [q.unitVector(i::PI) for i in 1..n]
+ dim := 2**n
+ Rep := PrimitiveArray K
+ New ==> new(dim, 0$K)$Rep
+ x + y ==
+ z := New
+ for i in 0..dim-1 repeat z.i := x.i + y.i
+ z
+ addMonomProd: (K, NNI, K, NNI, $) -> $
+ addMonomProd(c1, b1, c2, b2, z) == ...
+ x * y ==
+ z := New
+ for ix in 0..dim-1 repeat
+ if x.ix \notequal{} 0 then for iy in 0..dim-1 repeat
+ if y.iy \notequal{} 0
+ then addMonomProd(x.ix,ix,y.iy,iy,z)
+ z
+ ...
+
+
+
+
Part of the CliffordAlgebra domain.
+
+
+
+
+
The Implementation part begins by defining a local variable
+ to hold the list of all where
+runs over the unit vectors from 1 to the dimension .
+Another local variable is set to ,
+computed once and for all.
+The representation for the domain is
+ PrimitiveArray(K),
+which is a basic array of elements from domain .
+Line 18 defines as shorthand for the more lengthy
+expression , which computes a primitive
+array of length filled with 's from
+domain .
+
+
+
+
Lines 19-22 define the sum of two elements and
+straightforwardly.
+First, a new array of all 's is created, then filled with
+the sum of the corresponding elements.
+Indexing for primitive arrays starts at 0.
+The definition of the product of and first requires
+the definition of a local function addMonomProd.
+Axiom knows it is local since it is not an exported function.
+The types of all local functions must be declared.
+
We now turn to an entirely different kind of application,
+building a query language for a database.
+
+
+
+
Here is the practical problem to solve.
+The Browse facility of Axiom has a
+database for all operations and constructors which is
+stored on disk and accessed by HyperDoc.
+For our purposes here, we regard each line of this file as having
+eight fields:
+ class, name, type, nargs, exposed, kind, origin, and condition.
+Here is an example entry:
+
+The operation determinant: $->R with 1 argument, is
+ exposed and is exported by domain Matrix(R)
+if R has commutative("*").
+
+
+
+
+
Our task is to create a little query language that allows us
+to get useful information from this database.
+
+
+
+
+
+
+
13.13.1 A Little Query Language
+
+
+
+
+
+
First we design a simple language for accessing information from
+the database.
+We have the following simple model in mind for its design.
+Think of the database as a box of index cards.
+There is only one search operation---it
+takes the name of a field and a predicate
+predicate
+(a boolean-valued function) defined on the fields of the
+index cards.
+When applied, the search operation goes through the entire box
+selecting only those index cards for which the predicate is true.
+The result of a search is a new box of index cards.
+This process can be repeated again and again.
+
+
+
+
The predicates all have a particularly simple form: symbol
+ = pattern, where symbol designates one of the
+fields, and pattern is a ``search string''---a string
+that may contain a `` *'' as a
+wildcard.
+Wildcards match any substring, including the empty string.
+Thus the pattern `` "*ma*t'' matches
+`` "mat",'' doormat'' and `` smart''.
+
+
+
+
To illustrate how queries are given, we give you a sneak preview
+of the facility we are about to create.
+
+
+
+
Extract the database of all Axiom operations.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
How many exposed three-argument map operations involving streams?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
As usual, the arguments of elt ( .)
+associate to the left.
+The first elt produces the set of all operations with
+name map.
+The second elt produces the set of all map operations
+with three arguments.
+The third elt produces the set of all three-argument map
+operations having a type mentioning Stream.
+
+
+
+
Another thing we'd like to do is to extract one field from each of
+the index cards in the box and look at the result.
+Here is an example of that kind of request.
+
+
+
+
What constructors explicitly export a determinant operation?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
The first elt produces the set of all index cards with
+name determinant.
+The second elt extracts the origin component from
+each index card. Each origin component
+is the name of a constructor which directly
+exports the operation represented by the index card.
+Extracting a component from each index card produces what we call
+a datalist.
+The third elt, sort, causes the datalist of
+origins to be sorted in alphabetic
+order.
+The fourth, unique, causes duplicates to be removed.
+
+
+
+
Before giving you a more extensive demo of this facility,
+we now build the necessary domains and packages to implement it.
+We will introduce a few of our minor conveniences.
+
+
+
+
+
+
+
+
+
+
+
+
13.13.2 The Database Constructor
+
+
+
+
+
+
We work from the top down. First, we define a database,
+our box of index cards, as an abstract datatype.
+For sake of illustration and generality,
+we assume that an index card is some type , and
+that a database is a box of objects of type .
+Here is the Axiom program defining the Database
+domain.
+
+
+
+
+
+
+PI ==> PositiveInteger
+Database(S): Exports == Implementation where
+ S: Object with
+ elt: ( $, Symbol) -> String
+ display: $ -> Void
+ fullDisplay: $ -> Void
+
+ Exports == with
+ elt: ( $,QueryEquation) -> $ Select by an equation
+ elt: ( $, Symbol) -> DataList String Select by a field name
+ "+": ( $, $) -> $ Combine two databases
+ "-": ( $, $) -> $ Subtract one from another
+ display: $ -> Void A brief database display
+ fullDisplay: $ -> Void A full database display
+ fullDisplay: ( $,PI,PI) -> Void A selective display
+ coerce: $ -> OutputForm Display a database
+ Implementation == add
+ ...
+
+
+
+
+
The domain constructor takes a parameter , which
+stands for the class of index cards.
+We describe an index card later.
+Here think of an index card as a string which has
+the eight fields mentioned above.
+
+
+
+
First we tell Axiom what operations we are going to require
+from index cards.
+We need an elt to extract the contents of a field
+(such as name and type) as a string.
+For example,
+ returns a string that is the content of the
+ field on the index card .
+We need to display an index card in two ways:
+ display shows only the name and type of an
+operation;
+ fullDisplay displays all fields.
+The display operations return no useful information and thus have
+return type Void.
+
+
+
+
Next we tell Axiom what operations the user can apply
+to the database.
+This part defines our little query language.
+The most important operation is
+ db . field = pattern which
+returns a new database, consisting of all index
+cards of db such that the part of the index
+card is matched by the string pattern called .
+The expression field = pattern is an object of type
+ QueryEquation (defined in the next section).
+
+
+
+
Another elt is needed to produce a DataList
+object.
+Operation + is to merge two databases together;
+ - is used to subtract away common entries in a second
+database from an initial database.
+There are three display functions.
+The fullDisplay function has two versions: one
+that prints all the records, the other that prints only a fixed
+number of records.
+A coerce to OutputForm creates a display
+object.
+
+
+
+
The Implementation part of Database is straightforward.
+
+
+
+
+
+ Implementation == add
+ s: Symbol
+ Rep := List S
+ elt(db,equation) == ...
+ elt(db,key) == [x.key for x in db]::DataList(String)
+ display(db) == for x in db repeat display x
+ fullDisplay(db) == for x in db repeat fullDisplay x
+ fullDisplay(db, n, m) == for x in db for i in 1..m
+ repeat
+ if i >= n then fullDisplay x
+ x+y == removeDuplicates! merge(x,y)
+ x-y == mergeDifference(copy(x::Rep),
+ y::Rep)$MergeThing(S)
+ coerce(db): OutputForm == (#db):: OutputForm
+
+
+
+
+
The database is represented by a list of elements of (index cards).
+We leave the definition of the first elt operation
+(on line 4) until the next section.
+The second elt collects all the strings with field name
+ key into a list.
+The display function and first fullDisplay function
+simply call the corresponding functions from .
+The second fullDisplay function provides an efficient way of
+printing out a portion of a large list.
+The + is defined by using the existing
+mergemergeList operation defined on lists, then
+removing duplicates from the result.
+The - operation requires writing a corresponding
+subtraction operation.
+A package MergeThing (not shown) provides this.
+
+
+
+
The coerce function converts the database to an
+ OutputForm by computing the number of index cards.
+This is a good example of the independence of
+the representation of an Axiom object from how it presents
+itself to the user. We usually do not want to look at a database---but
+do care how many ``hits'' we get for a given query.
+So we define the output representation of a database to be simply
+the number of index cards our query finds.
+
+
+
+
+
+
+
+
+
+
+
+
13.13.3 Query Equations
+
+
+
+
+
+
The predicate for our search is given by an object of type
+ QueryEquation.
+Axiom does not have such an object yet so we
+have to invent it.
+
Axiom converts an input expression of the form
+ to .
+Our equations always have a symbol on the left and a string
+on the right.
+The Exports part thus specifies an operation
+ equation to create a query equation, and
+ variable and value to select the left- and
+right-hand sides.
+The Implementation part uses Record for a
+space-efficient representation of an equation.
+
+
+
+
Here is the missing definition for the elt function of
+ Database in the last section:
+
+
+
+
+
+
+ elt(db,eq) ==
+ field := variable eq
+ value := value eq
+ [x for x in db | matches?(value,x.field)]
+
+
+
+
+
Recall that a database is represented by a list.
+Line 4 simply runs over that list collecting all elements
+such that the pattern (that is, )
+matches the selected field of the element.
+
+
+
+
+
+
+
+
+
+
+
+
13.13.4 DataLists
+
+
+
+
+
+
Type DataList is a new type invented to hold the result
+of selecting one field from each of the index cards in the box.
+It is useful to make datalists extensions of lists---lists that
+have special elt operations defined on them for
+sorting and removing duplicates.
+
+
+
+
+
+
+DataList(S:OrderedSet) : Exports == Implementation where
+ Exports == ListAggregate(S) with
+ elt: ($,"unique") -> $
+ elt: ($,"sort") -> $
+ elt: ($,"count") -> NonNegativeInteger
+ coerce: List S -> $
+
+ Implementation == List(S) add
+ Rep := List S
+ elt(x,"unique") == removeDuplicates(x)
+ elt(x,"sort") == sort(x)
+ elt(x,"count") == #x
+ coerce(x:List S) == x :: $
+
+
+
+
+
The Exports part asserts that datalists belong to the
+category ListAggregate.
+Therefore, you can use all the usual list operations on datalists,
+such as firstfirstList, restrestList, and
+concatconcatList.
+In addition, datalists have four explicit operations.
+Besides the three elt operations, there is a
+ coerce operation that creates datalists from lists.
+
+
+
+
The Implementation part needs only to define four functions.
+All the rest are obtained from List(S).
+
+
+
+
+
+
+
+
+
+
+
+
13.13.5 Index Cards
+
+
+
+
+
+
An index card comes from a file as one long string.
+We define functions that extract substrings from the long
+string.
+Each field has a name that
+is passed as a second argument to elt.
+
We leave the Implementation part to the reader.
+All operations involve straightforward string manipulations.
+
+
+
+
+
+
+
+
+
+
+
+
13.13.6 Creating a Database
+
+
+
+
+
+
We must not forget one important operation: one that builds the database in the
+first place!
+We'll name it getDatabase and put it in a package.
+This function is implemented by calling the Common Lisp function
+ to get appropriate information from
+Browse.
+This operation takes a string indicating which lines you
+want from the database: `` o'' gives you all operation
+lines, and `` k'', all constructor lines.
+Similarly, `` c'', `` d'', and `` p'' give
+you all category, domain and package lines respectively.
+
We do not bother creating a special name for databases of index
+cards.
+ Database (IndexCard) will do.
+Notice that we used the package OperationsQuery to
+create, in effect,
+a new kind of domain: Database(IndexCard).
+
+
+
+
+
+
+
+
+
+
+
+
13.13.7 Putting It All Together
+
+
+
+
+
+
To create the database facility, you put all these constructors
+into one file.You could use separate files, but we
+are putting them all together because, organizationally, that is
+the logical thing to do.
+At the top of the file put )abbrev commands, giving the
+constructor abbreviations you created.
+
With all this in alql.spad, for example, compile it using
+compile
+
+
+
+
+
+)compile alql
+
+
+
+
and then load each of the constructors:
+
+
+
+
+
+)load ICARD QEQUAT MTHING DLIST DBASE OPQUERY
+
+
+
+
load
+You are ready to try some sample queries.
+
+
+
+
+
+
+
+
+
+
+
+
13.13.8 Example Queries
+
+
+
+
+
+
Our first set of queries give some statistics on constructors in
+the current Axiom system.
+
+
+
+
How many constructors does Axiom have?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Break this down into the number of categories, domains, and packages.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
What are all the domain constructors that take no parameters?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
How many constructors have ``Matrix'' in their name?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
What are the names of those that are domains?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
How many operations are there in the library?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Break this down into categories, domains, and packages.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
The query language is helpful in getting information about a
+particular operation you might like to apply.
+While this information can be obtained with
+Browse, the use of the query database gives you data that you
+can manipulate in the workspace.
+
+
+
+
How many operations have ``eigen'' in the name?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
What are their names?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Where do they come from?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
The operations + and - are useful for
+constructing small databases and combining them.
+However, remember that the only matching you can do is string
+matching.
+Thus a pattern such as "*Matrix*" on the type field
+matches
+any type containing Matrix, MatrixCategory,
+ SquareMatrix, and so on.
+
+
+
+
How many operations mention ``Matrix'' in their type?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
How many operations come from constructors with ``Matrix'' in
+their name?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
How many operations are in but not in ?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Display the operations that both mention ``Matrix'' in their type
+and come from a constructor having ``Matrix'' in their name.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
How many operations involve matrices?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Display 4 of them.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
How many distinct names of operations involving matrices are there?
+
The syntax for defining a domain constructor is the same as for any
+function in Axiom:
+
+
+
+
+
+ DomainForm : Exports == Implementation
+
+
+
+
As this definition usually extends over many lines, a
+ expression is generally used instead.
+where
+
+
+
+
A recommended format for the definition of a domain is:
+
+
+
+
+
+ DomainForm : Exports == Implementation where
+ optional type declarations
+Exports == [ Category Assertions] with
+ list of exported operations
+Implementation == [ Add Domain] add
+[Rep := Representation]
+ list of function definitions for exported operations
+
+
+
+
+
+
Note: The brackets [ ] here denote optionality.
+
+
+
+
A complete domain constructor definition for QuadraticForm is
+shown below.
+Interestingly, this little domain illustrates all the new concepts you
+need to learn.
+
+
+
+
+
+
+
+
+
+)abbrev domain QFORM QuadraticForm
+
+++ Description:
+++ This domain provides modest support for
+++ quadratic forms.
+QuadraticForm(n, K): Exports == Implementation where
+ n: PositiveInteger
+ K: Field
+
+ Exports == AbelianGroup with --The exports
+ quadraticForm: SquareMatrix(n,K) -> $ --export this
+ ++ \bs{}axiom\{quadraticForm(m)\} creates a quadratic
+ ++ quadratic form from a symmetric,
+ ++ square matrix \bs{}axiom\{m\}.
+ matrix: $ -> SquareMatrix(n,K) -- export matrix
+ ++ \bs{}axiom\{matrix(qf)\} creates a square matrix
+ ++ from the quadratic form \bs{}axiom\{qf\}.
+ elt: ( $, DirectProduct(n,K)) -> K -- export elt
+ ++ \bs{}axiom\{qf(v)\} evaluates the quadratic form
+ ++ \bs{}axiom\{qf\} on the vector \bs{}axiom\{v\},
+ ++ producing a scalar.
+
+ Implementation == SquareMatrix(n,K) add --The exports
+ Rep := SquareMatrix(n,K) --representation
+ quadraticForm m == --definition
+ not symmetric? m => error
+ "quadraticForm requires a symmetric matrix"
+ m :: $
+ matrix q == q :: Rep --definition
+ elt(q,v) == dot(v, (matrix q * v)) --definition
+
+
+
+
+
The QuadraticForm domain.
+
+
+
+
+
A domain constructor can take any number and type of parameters.
+ QuadraticForm takes a positive integer and a field
+ as arguments.
+Like a package, a domain has a set of explicit exports and an
+implementation described by a capsule.
+Domain constructors are documented in the same way as package constructors.
+
+
+
+
Domain QuadraticForm(n, K), for a given positive integer
+ and domain , explicitly exports three operations:
+
+
+
+
+
+
+
+ creates a quadratic form from a matrix
+.
+
+
returns the matrix used to create
+the quadratic form .
+
+
computes the scalar
+for a given vector .
+
+
+
+
+
+
Compared with the corresponding syntax given for the definition of a
+package, you see that a domain constructor has three optional parts to
+its definition: Category Assertions, Add Domain, and
+ Representation.
+
The Category Assertions part of your domain constructor
+definition lists those categories of which all domains created by the
+constructor are unconditionally members. The word ``unconditionally''
+means that membership in a category does not depend on the values of
+the parameters to the domain constructor. This part thus defines the
+link between the domains and the category hierarchies given on the
+inside covers of this book. As described in
+ugCategoriesCorrectness it is this link that makes it
+possible for you to pass objects of the domains as arguments to other
+operations in Axiom.
+
+
+
+
Every QuadraticForm domain is declared
+to be unconditionally a member of category AbelianGroup.
+An abelian group is a collection of elements closed under
+addition.
+Every object x of an abelian group has an additive inverse
+ y such that .
+The exports of an abelian group include ,
+ +, -, and scalar multiplication by an integer.
+After asserting that QuadraticForm domains are abelian
+groups, it is possible to pass quadratic forms to algorithms that
+only assume arguments to have these abelian group
+properties.
+
+
+
+
In ugCategoriesConditionals you saw that
+Fraction(R), a member of QuotientFieldCategory(R), is a member
+of OrderedSet if is a member of OrderedSet. Likewise,
+from the Exports part of the definition of ModMonic(R, S),
+
+
+
+
+
+
+UnivariatePolynomialCategory(R) with
+ if R has Finite then Finite
+ ...
+
+
+
+
you see that ModMonic(R, S) is a member of
+ Finite if is.
+
+
+
+
The Exports part of a domain definition is
+the same kind of
+expression that can appear to the right of an
+ == in a category definition.
+If a domain constructor is unconditionally a member of two or more
+categories, a form is used.
+Join
+The Exports part of the definition of
+ FlexibleArray(S) reads, for example:
+
The Browse facility of HyperDoc is useful for
+investigating
+the properties of domains, packages, and categories.
+From the main HyperDoc menu, move your mouse to Browse and
+click on the left mouse button.
+This brings up the Browse first page.
+Now, with your mouse pointer somewhere in this window, enter the
+string ``quadraticform'' into the input area (all lower case
+letters will do).
+Move your mouse to Constructors and click.
+Up comes a page describing QuadraticForm.
+
+
+
+
From here, click on Description.
+This gives you a page that includes a part labeled by ``
+Description:''.
+You also see the types for arguments and
+displayed as well as the fact that QuadraticForm
+returns an AbelianGroup.
+You can go and experiment a bit by selecting Field with
+your mouse.
+Eventually, use the ``UP'' button
+several times to return to the first page on
+ QuadraticForm.
+
+
+
+
Select Operations to get a list of operations for
+ QuadraticForm.
+You can select an operation by clicking on it
+to get an individual page with information about that operation.
+Or you can select the buttons along the bottom to see alternative
+views or get additional information on the operations.
+Then return to the page on QuadraticForm.
+
+
+
+
Select Cross Reference to get another menu.
+This menu has buttons for Parents, Ancestors, and
+others.
+Clicking on Parents, you see that QuadraticForm
+has one parent AbelianMonoid.
+
The Implementation part of an Axiom capsule for a
+domain constructor uses the special variable to
+Rep @ Rep
+identify the lower level data type used to represent the objects
+representation:of a domain
+of the domain.
+domain:representation
+The for quadratic forms is SquareMatrix(n, K).
+This means that all objects of the domain are required to be
+ by matrices with elements from K.
+
+
+
+
The code for quadraticForm in Figure figquadform
+checks that the matrix is symmetric and then converts it to
+ $, which means, as usual, ``this domain.'' Such explicit
+conversions conversion are generally required by the
+compiler.
+Aside from checking that the matrix is symmetric, the code for
+this function essentially does nothing.
+The m :: $ on line 28 coerces to a
+quadratic form.
+In fact, the quadratic form you created in step (3) of
+ugDomainsDemo
+is just the matrix you passed it in
+disguise!
+Without seeing this definition, you would not know that.
+Nor can you take advantage of this fact now that you do know!
+When we try in the next step of ugDomainsDemo to regard
+ as a matrix by asking for nrows, the number of
+its rows, Axiom gives you an error message saying, in
+effect, ``Good try, but this won't work!''
+
+
+
+
The definition for the matrixmatrixQuadraticForm
+function could hardly be simpler:
+it just returns its argument after explicitly
+coercing its argument to a matrix.
+Since the argument is already a matrix, this coercion does no computation.
+
+
+
+
Within the context of a capsule, an object of $ is
+regarded both as a quadratic form and as a
+matrix.In case each of $ and
+have the same named operation available,
+the one from $ takes precedence.
+Thus, if you want the one from Rep, you must
+package call it using a $Rep suffix.
+This makes the definition of easy---it
+just calls the dotdotDirectProduct product from
+ DirectProduct to perform the indicated operation.
+
To write functions that implement the operations of a domain, you
+want to choose the most computationally efficient
+data structure to represent the elements of your domain.
+
+
+
+
A classic problem in computer algebra is the optimal choice for an
+internal representation of polynomials.
+If you create a polynomial, say , how
+does Axiom hold this value internally?
+There are many ways.
+Axiom has nearly a dozen different representations of
+polynomials, one to suit almost any purpose.
+Algorithms for solving polynomial equations work most
+efficiently with polynomials represented one way, whereas those for
+factoring polynomials are most efficient using another.
+One often-used representation is a list of terms, each term
+consisting of exponent-coefficient records written in the order
+of decreasing exponents.
+For example, the polynomial is
+
+represented by the list .
+
+
+
+
What is the optimal data structure for a matrix?
+It depends on the application.
+For large sparse matrices, a linked-list structure of records
+holding only the non-zero elements may be optimal.
+If the elements can be defined by a simple formula
+, then a compiled function for
+ may be optimal.
+Some programmers prefer to represent ordinary matrices as vectors
+of vectors.
+Others prefer to represent matrices by one big linear array where
+elements are accessed with linearly computable indexes.
+
+
+
+
While all these simultaneous structures tend to be confusing,
+Axiom provides a helpful organizational tool for such a purpose:
+categories.
+ PolynomialCategory, for example, provides a uniform user
+interface across all polynomial types.
+Each kind of polynomial implements functions for
+all these operations, each in its own way.
+If you use only the top-level operations in
+ PolynomialCategory you usually do not care what kind
+of polynomial implementation is used.
+
+
+
+
+Within a given domain, however, you define (at most) one
+representation.You can make that representation a
+ Union type, however.
+See ugTypesUnions
+for examples of unions.
+If you want to have multiple representations (that is, several
+domains, each with its own representation), use a category to
+describe the Exports, then define separate domains for each
+representation.
+
The capsule part of Implementation defines functions that
+implement the operations exported by the domain---usually only
+some of the operations.
+In our demo in ugDomainsDemo
+we asked for the value of
+.
+Where do the operations *, +, and
+ - come from?
+There is no definition for them in the capsule!
+
+
+
+
The Implementation part of a definition can
+domain:add
+optionally specify an ``add-domain'' to the left of an add
+add
+(for QuadraticForm, defines
+ SquareMatrix(n,K) is the add-domain).
+The meaning of an add-domain is simply this: if the capsule part
+of the Implementation does not supply a function for an
+operation, Axiom goes to the add-domain to find the
+function.
+So do , and (from QuadraticForm) come from
+ SquareMatrix(n,K)?
+
In Chapter ugPackages
+we saw that categories can provide
+default implementations for their operations.
+How and when are they used?
+When Axiom finds that QuadraticForm(2, Fraction
+Integer) does not implement the operations *,
+ +, and -, it goes to
+ SquareMatrix(2,Fraction Integer) to find it.
+As it turns out, SquareMatrix(2, Fraction Integer) does
+not implement any of these operations!
+
+
+
+
What does Axiom do then?
+Here is its overall strategy.
+First, Axiom looks for a function in the capsule for the domain.
+If it is not there, Axiom looks in the add-domain for the
+operation.
+If that fails, Axiom searches the add-domain of the add-domain,
+and so on.
+If all those fail, it then searches the default packages for the
+categories of which the domain is a member.
+In the case of QuadraticForm, it searches
+ AbelianGroup, then its parents, grandparents, and
+so on.
+If this fails, it then searches the default packages of the
+add-domain.
+Whenever a function is found, the search stops immediately and the
+function is returned.
+When all fails, the system calls error to report this
+unfortunate news to you.
+To find out the actual order of constructors searched for
+ QuadraticForm, consult Browse: from the
+ QuadraticForm, click on Cross Reference, then on
+ Lineage.
+
+
+
+
Let's apply this search strategy for our example .
+The scalar multiplication comes first.
+Axiom finds a default implementation in
+ AbelianGroup&.
+Remember from ugCategoriesDefaults that
+ SemiGroup provides a default definition for
+ by repeated squaring.
+ AbelianGroup similarly provides a definition for
+ by repeated doubling.
+
+
+
+
But the search of the defaults for QuadraticForm fails
+to find any + or * in the default packages for
+the ancestors of QuadraticForm.
+So it now searches among those for SquareMatrix.
+Category MatrixCategory, which provides a uniform interface
+for all matrix domains,
+is a grandparent of SquareMatrix and
+has a capsule defining many functions for matrices, including
+matrix addition, subtraction, and scalar multiplication.
+The default package MatrixCategory& is where the
+functions for and (from QuadraticForm) come from.
+
+
+
+
You can use Browse to discover where the operations for
+ QuadraticForm are implemented.
+First, get the page describing QuadraticForm.
+With your mouse somewhere in this window, type a ``2'', press the
+ Tab key, and then enter ``Fraction
+Integer'' to indicate that you want the domain
+ QuadraticForm(2, Fraction Integer).
+Now click on Operations to get a table of operations and on
+ * to get a page describing the * operation.
+Finally, click on implementation at the bottom.
+
This chapter discusses the Browse
+Browse@Browse
+component of HyperDoc.
+HyperDoc@{HyperDoc}
+We suggest you invoke Axiom and work through this
+chapter, section by section, following our examples to gain some
+familiarity with Browse.
+
To enter Browse, click on Browse on the top level page
+of HyperDoc to get the front page of Browse.
+
+
+
+
+
+
+
+
+
+
+
The Browse front page.
+
+
+
To use this page, you first enter a search string into
+the input area at the top, then click on one of the buttons below.
+We show the use of each of the buttons by example.
+
+
+
+
+
14.1.1 Constructors
+
+
+
+
First enter the search string Matrix into the input area and
+click on Constructors.
+What you get is the constructor page for Matrix.
+We show and describe this page in detail in
+ugBrowseDomain .
+By convention, Axiom does a case-insensitive search for a
+match.
+Thus matrix is just as good as Matrix, has the same
+effect as MaTrix, and so on.
+We recommend that you generally use small letters for names
+however.
+A search string with only capital letters has a special meaning
+(see ugBrowseCapitalizationConvention ).
+
+
+
+
+
Click on to return to the Browse front page.
+
+
+
+
Use the symbol ``*'' in search strings as a wild
+card.
+A wild card matches any substring, including the empty string.
+For example, enter the search string *matrix* into the input
+area and click on Constructors.To get only
+categories, domains, or packages, rather than all constructors,
+you can click on the corresponding button to the right of
+Constructors.
+What you get is a table of all constructors whose names contain
+the string ``matrix.''
+
+
+
+
+
+
+
Table of exposed constructors matching *matrix* .
+
+
+
+
+
+
+
All constructors containing the string are listed, whether
+exposed or unexposed.
+You can hide the names of the unexposed constructors by clicking
+on the *= unexposed button in the Views panel at
+the bottom of the window.
+(The button will change to exposedonly.)
+
+
+
+
One of the names in this table is Matrix.
+Click on Matrix.
+What you get is again the constructor page for Matrix.
+As you see, Browse gives you a large network of
+information in which there are many ways to reach the same
+pages.
+Matrix
+
+
+
+
Again click on the to return to the table of constructors
+whose names contain matrix.
+
+
+
+
Below the table is a Views panel.
+This panel contains buttons that let you view constructors in different
+ways.
+To learn about views of constructors, skip to
+ugBrowseViewsOfConstructors .
+
+
+
+
Click on to return to the Browse front page.
+
+
+
+
+
+
+
+
+
+
14.1.2 Operations
+
+
+
Enter *matrix into the input area and click on
+Operations.
+This time you get a table of operations whose names end with matrix or Matrix.
+
+
+
+
+
+
+
Table of operations matching *matrix .
+
+
+
If you select an operation name, you go to a page describing all
+the operations in Axiom of that name.
+At the bottom of an operation page is another kind of Views panel,
+one for operation pages.
+To learn more about these views, skip to
+ugBrowseViewsOfOperations .
+
+
+
+
Click on to return to the Browse front page.
+
+
+
+
+
+
+
+
+
+
14.1.3 Attributes
+
+
+
This button gives you a table of attribute names that match the
+search string. Enter the search string * and click on
+ Attributes to get a list
+of all system attributes.
+
+
+
+
Click on to return to the Browse front page.
+
+
+
+
+
+
+
+
Table of Axiom attributes.
+
+
+
Again there is a Views panel at the bottom with buttons that let
+you view the attributes in different ways.
+
+
+
+
+
+
+
+
+
+
14.1.4 General
+
+
+
This button does a general search for all constructor, operation, and
+attribute names matching the search string.
+Enter the search string
+*matrix* into the input area.
+Click on General to find all constructs that have matrix as a part of their name.
+
+
+
+
+
+
+
Table of all constructs matching *matrix* .
+
+
+
The summary gives you all the names under a heading when the number of
+entries is less than 10.
+
+
+
+
+
+
+
+
Click on to return to the Browse front page.
+
+
+
+
+
+
+
+
+
+
14.1.5 Documentation
+
+
+
Again enter the search key *matrix* and this time click on
+ Documentation.
+This search matches any constructor, operation, or attribute
+name whose documentation contains a substring matching matrix.
+
+
+
+
+
+
+
Table of constructs with documentation matching *matrix* .
+
+
+
Click on to return to the Browse front page.
+
+
+
+
+
+
+
+
+
+
14.1.6 Complete
+
+
+
This search combines both General and Documentation.
+
+
+
+
+
+
+
Table summarizing complete search for pattern *matrix* .
In this section we look in detail at a constructor page for domain
+Matrix.
+Enter matrix into the input area on the main Browse page
+and click on Constructors.
+
+
+
+
+
+
+
Constructor page for Matrix.
+
+
+
The header part tells you that Matrix has abbreviation
+MATRIX and one argument called R that must be a
+domain of category Ring.
+Just what domains can be arguments of Matrix?
+To find this out, click on the R on the second line of the
+heading.
+What you get is a table of all acceptable domain parameter values
+of R, or a table of rings in Axiom.
+
+
+
+
+
+
+
Table of acceptable domain parameters to Matrix.
+
+
+
Click on to return to the constructor page for
+Matrix.
+
+
+
+
+
If you have access to the source code of Axiom, the third
+source code
+line of the heading gives you the name of the source file
+containing the definition of Matrix.
+Click on it to pop up an editor window containing the source code
+of Matrix.
+
+
+
+
+
+
+
Source code for Matrix.
+
+
+
We recommend that you leave the editor window up while working
+through this chapter as you occasionally may want to refer to it.
+
+
+
+
+
+
+
+
14.2.1 Constructor Page Buttons
+
+
+
+
+
+
We examine each button on this page in order.
+
+
+
+
+
+
+
+
+
+
+
+
14.2.1.1 Description
+
+
+
+
Click here to bring up a page with a brief description of
+constructor Matrix.
+If you have access to system source code, note that these comments
+can be found directly over the constructor definition.
+
+
+
+
+
+
+
Description page for Matrix.
+
+
+
+
+
+
+
+
+
+
+
14.2.1.2 Operations
+
+
+
+
Click here to get a table of operations exported by
+Matrix.
+You may wish to widen the window to have multiple columns as
+below.
+
+
+
+
+
+
+
Table of operations from Matrix.
+
+
+
If you click on an operation name, you bring up a description
+page for the operations.
+For a detailed description of these pages, skip to
+ugBrowseViewsOfOperations .
+
+
+
+
+
+
+
+
+
+
+
+
14.2.1.3 Attributes
+
+
+
+
Click here to get a table of the two attributes exported by
+Matrix:
+attribute
+ finiteAggregate and shallowlyMutable.
+These are two computational properties that result from
+Matrix being regarded as a data structure.
+
+
+
+
+
+
+
Attributes from Matrix.
+
+
+
+
+
+
+
+
+
+
+
14.2.1.4 Examples
+
+
+
+
Click here to get an examples page with examples of operations to
+create and manipulate matrices.
+
+
+
+
+
+
+
Example page for Matrix.
+
+
+
Read through this section.
+Try selecting the various buttons.
+Notice that if you click on an operation name, such as
+newnewMatrix, you bring up a description page for that
+operation from Matrix.
+
+
+
+
Example pages have several examples of Axiom commands.
+Each example has an active button to its left.
+Click on it!
+A pre-computed answer is pasted into the page immediately following the
+command.
+If you click on the button a second time, the answer disappears.
+This button thus acts as a toggle:
+``now you see it; now you don't.''
+
+
+
+
Note also that the Axiom commands themselves are active.
+If you want to see Axiom execute the command, then click on it!
+A new Axiom window appears on your screen and the command is
+executed.
+
+
+
+
At the end of the page is generally a menu of buttons that lead
+you to further sections.
+Select one of these topics to explore its contents.
+
+
+
+
+
+
+
+
+
+
+
+
14.2.1.5 Exports
+
+
+
+
Click here to see a page describing the exports of Matrix
+exactly as described by the source code.
+
+
+
+
+
+
+
Exports of Matrix.
+
+
+
As you see, Matrix declares that it exports all the operations
+and attributes exported by category
+MatrixCategory(R, Row, Col).
+In addition, two operations, diagonalMatrix and
+ inverse, are explicitly exported.
+
+
+
+
To learn a little about the structure of Axiom, we suggest you do
+the following exercise.
+
+
+
+
Otherwise, go on to the next section.
+
+
+
+
Matrix explicitly exports only two operations.
+The other operations are thus exports of MatrixCategory.
+In general, operations are usually not explicitly exported by a domain.
+Typically they are inherited from several
+different categories.
+Let's find out from where the operations of Matrix come.
+
+
+
+
+
+
+
+ Click on MatrixCategory, then on Exports.
+Here you see that MatrixCategory explicitly exports many matrix
+operations.
+Also, it inherits its operations from
+TwoDimensionalArrayCategory.
+
+
+
Click on TwoDimensionalArrayCategory, then on Exports.
+Here you see explicit operations dealing with rows and columns.
+In addition, it inherits operations from
+HomogeneousAggregate.
+
+
+
Click on and then
+click on Object, then on Exports, where you see
+there are no exports.
+
+
+
Click on repeatedly to return to the constructor page
+for Matrix.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
14.2.1.6 Related Operations
+
+
+
+
Click here bringing up a table of operations that are exported by
+packages but not by Matrix itself.
+
+
+
+
+
+
+
Related operations of Matrix.
+
+
+
To see a table of such packages, use the Relatives button on the
+ Cross Reference page described next.
+
+
+
+
+
+
+
+
+
+
+
+
+
14.2.2 Cross Reference
+
+
+
+
+
Click on the Cross Reference button on the main constructor page
+for Matrix.
+This gives you a page having various cross reference information stored
+under the respective buttons.
+
+
+
+
+
+
+
Cross-reference page for Matrix.
+
+
+
+
+
+
14.2.2.1 Parents
+
+
+
+
The parents of a domain are the same as the categories mentioned under
+the Exports button on the first page.
+Domain Matrix has only one parent but in general a domain can
+have any number.
+
+
+
+
+
+
+
+
+
+
+
+
14.2.2.2 Ancestors
+
+
+
+
The ancestors of a constructor consist of its parents, the
+parents of its parents, and so on.
+Did you perform the exercise in the last section under Exports?
+If so, you see here all the categories you found while ascending the
+ Exports chain for Matrix.
+
+
+
+
+
+
+
+
+
+
+
+
14.2.2.3 Relatives
+
+
+
+
The relatives of a domain constructor are package
+constructors that provide operations in addition to those
+exported by the domain.
+
+
+
+
Try this exercise.
+
+
+
+
+
+
+ Click on Relatives, bringing up a list of
+packages.
+
+
+
Click on LinearSystemMatrixPackage bringing up its
+constructor page.You may want to widen your HyperDoc
+window to make what follows more legible.
+
+
+
Click on Operations.
+Here you see rank, an operation also exported by
+Matrix itself.
+
+
+
Click on rank.
+This rankrankLinearSystemMatrixPackage has two arguments and
+thus is different from the rankrankMatrix from
+Matrix.
+
+
+
Click on to return to the list of operations for the
+package LinearSystemMatrixPackage.
+
+
+
Click on solve to bring up a
+solvesolveLinearSystemMatrixPackage for linear systems of
+equations.
+
+
+
Click on several times to return to the cross
+reference page for Matrix.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
14.2.2.4 Dependents
+
+
+
+
The dependents of a constructor are those
+domains or packages
+that mention that
+constructor either as an argument or in its exports.
+
+
+
+
If you click on Dependents two entries may surprise you:
+RectangularMatrix and SquareMatrix.
+This happens because Matrix, as it turns out, appears in
+signatures of operations exported by these domains.
+
+
+
+
+
+
+
+
+
+
+
+
14.2.2.5 Lineage
+
+
+
+
The term lineage refers to the search order for
+functions.
+If you are an expert user or curious about how the Axiom system
+works, try the following exercise.
+Otherwise, you best skip this button and go on to Clients.
+
+
+
+
Clicking on Lineage gives you a
+list of domain constructors:
+InnerIndexedTwoDimensionalArray,
+MatrixCategory&,
+TwoDimensionalArrayCategory&,
+HomogeneousAggregate&,
+Aggregate&.
+What are these constructors and how are they used?
+
+
+
+
We explain by an example.
+Suppose you create a matrix using the interpreter, then ask for its
+ rank.
+Axiom must then find a function implementing the rank
+operation for matrices.
+The first place Axiom looks for rank is in the Matrix
+domain.
+
+
+
+
If not there, the lineage of Matrix tells Axiom where
+else to look.
+Associated with the matrix domain are five other lineage domains.
+Their order is important.
+Axiom first searches the first one,
+InnerIndexedTwoDimensionalArray.
+If not there, it searches the second MatrixCategory&.
+And so on.
+
+
+
+
Where do these lineage constructors come from?
+The source code for Matrix contains this syntax for the
+function body of
+Matrix:InnerIndexedTwoDimensionalArray
+is a special domain implemented for matrix-like domains to provide
+efficient implementations of two-dimensional arrays.
+For example, domains of category TwoDimensionalArrayCategory
+can have any integer as their .
+Matrices and other members of this special ``inner'' array have their
+ defined as .
+
where the ``...'' denotes all the code that follows.
+In English, this means:
+``The functions for matrices are defined as those from
+InnerIndexedTwoDimensionalArray domain augmented by those
+defined in `...','' where the latter take precedence.
+
+
+
+
This explains InnerIndexedTwoDimensionalArray.
+The other names, those with names ending with an ampersand & are
+default packages
+for categories to which Matrix belongs.
+Default packages are ordered by the notion of ``closest ancestor.''
+
+
+
+
+
+
+
+
+
+
+
+
14.2.2.6 Clients
+
+
+
+
A client of Matrix is any constructor that uses
+Matrix in its implementation.
+For example, Complex is a client of Matrix; it
+exports several operations that take matrices as arguments or return
+matrices as values.A constructor is a client of
+Matrix if it handles any matrix.
+For example, a constructor having internal (unexported) operations
+dealing with matrices is also a client.
+
+
+
+
+
+
+
+
+
+
+
+
14.2.2.7 Benefactors
+
+
+
+
A benefactor of Matrix is any constructor that
+Matrix uses in its implementation.
+This information, like that for clients, is gathered from run-time
+structures.The benefactors exclude constructors such as
+PrimitiveArray whose operations macro-expand and so vanish
+from sight!
+
+
+
+
Cross reference pages for categories have some different buttons on
+them.
+Starting with the constructor page of Matrix, click on
+Ring producing its constructor page.
+Click on Cross Reference,
+producing the cross-reference page for Ring.
+Here are buttons Parents and Ancestors similar to the notion
+for domains, except for categories the relationship between parent and
+child is defined through category extension.
+
+
+
+
+
+
+
+
+
+
+
+
14.2.2.8 Children
+
+
+
+
Category hierarchies go both ways.
+There are children as well as parents.
+A child can have any number of parents, but always at least one.
+Every category is therefore a descendant of exactly one category:
+Object.
+
+
+
+
+
+
+
+
+
+
+
+
14.2.2.9 Descendants
+
+
+
+
These are children, children of children, and so on.
+
+
+
+
Category hierarchies are complicated by the fact that categories take
+parameters.
+Where a parameterized category fits into a hierarchy may depend on
+values of its parameters.
+In general, the set of categories in Axiom forms a directed
+acyclic graph, that is, a graph with directed arcs and no cycles.
+
+
+
+
+
+
+
+
+
+
+
+
14.2.2.10 Domains
+
+
+
+
This produces a table of all domain constructors that can possibly be
+rings (members of category Ring).
+Some domains are unconditional rings.
+Others are rings for some parameters and not for others.
+To find out which, select the conditions button in the views
+panel.
+For example, DirectProduct(n, R) is a ring if R is a
+ring.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
14.2.3 Views Of Constructors
+
+
+
+
+
+
Below every constructor table page is a Views panel.
+As an example, click on Cross Reference from
+the constructor page of Matrix,
+then on Benefactors to produce a
+short table of constructor names.
+
+
+
+
The Views panel is at the bottom of the page.
+Two items, names and conditions, are in italics.
+Others are active buttons.
+The active buttons are those that give you useful alternative views
+on this table of constructors.
+Once you select a view, you notice that the button turns
+off (becomes italicized) so that you cannot reselect it.
+
+
+
+
+
+
+
14.2.3.1 names
+
+
+
+
This view gives you a table of names.
+Selecting any of these names brings up the constructor page for that
+constructor.
+
+
+
+
+
+
+
+
+
+
+
+
14.2.3.2 abbrs
+
+
+
+
This view gives you a table of abbreviations, in the same order as the
+original constructor names.
+Abbreviations are in capitals and are limited to 7 characters.
+They can be used interchangeably with constructor names in input areas.
+
+
+
+
+
+
+
+
+
+
+
+
14.2.3.3 kinds
+
+
+
+
This view organizes constructor names into
+the three kinds: categories, domains and packages.
+
+
+
+
+
+
+
+
+
+
+
+
14.2.3.4 files
+
+
+
+
This view gives a table of file names for the source
+code of the constructors in alphabetic order after removing
+duplicates.
+
+
+
+
+
+
+
+
+
+
+
+
14.2.3.5 parameters
+
+
+
+
This view presents constructors with the arguments.
+This view of the benefactors of Matrix shows that
+Matrix uses as many as five different List domains
+in its implementation.
+
+
+
+
+
+
+
+
+
+
+
+
14.2.3.6 filter
+
+
+
+
This button is used to refine the list of names or abbreviations.
+Starting with the names view, enter m* into the input area
+and click on filter.
+You then get a shorter table with only the names beginning with m.
+
+
+
+
+
+
+
+
+
+
+
+
14.2.3.7 documentation
+
+
+
+
This gives you documentation for each of the constructors.
+
+
+
+
+
+
+
+
+
+
+
+
14.2.3.8 conditions
+
+
+
+
This page organizes the constructors according to predicates.
+The view is not available for your example page since all constructors
+are unconditional.
+For a table with conditions, return to the Cross Reference page
+for Matrix, click on Ancestors, then on
+conditions in the view panel.
+This page shows you that CoercibleTo(OutputForm) and
+SetCategory are ancestors of Matrix(R) only if R
+belongs to category SetCategory.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
14.2.4 Giving Parameters to Constructors
+
+
+
+
+
+
Notice the input area at the bottom of the constructor page.
+If you leave this blank, then the information you get is for the
+domain constructor Matrix(R), that is, Matrix for an
+arbitrary underlying domain R.
+
+
+
+
In general, however, the exports and other information do usually
+depend on the actual value of R.
+For example, Matrix exports the inverse operation
+only if the domain R is a Field.
+To see this, try this from the main constructor page:
+
+
+
+
+
+
+
+ Enter Integer into the input area at the bottom of the page.
+
+
+
Click on Operations, producing a table of operations.
+Note the number of operation names that appear at the top of the
+page.
+
+
+
Click on to return to the constructor page.
+
+
+
Use the
+ Delete
+or
+ Backspace
+keys to erase Integer from the input area.
+
+
+
Click on Operations to produce a new table of operations.
+Look at the number of operations you get.
+This number is greater than what you had before.
+Find, for example, the operation inverse.
+
+
+
Click on inverse to produce a page describing the operation
+ inverse.
+At the bottom of the description, you notice that the
+Conditions line says ``R has Field.''
+This operation is not exported by Matrix(Integer) since
+Integer is not a field.
+
+Try putting the name of a domain such as Fraction Integer
+(which is a field) into the input area, then clicking on Operations.
+As you see, the operation inverse is exported.
+
From the constructor page of Matrix,
+click on Operations to bring up the table of operations
+for Matrix.
+
+
+
+
Find the operation inverse in the table and click on it.
+This takes you to a page showing the documentation for this operation.
+
+
+
+
+
+
+
Operation inverseinverseMatrix from Matrix.
+
+
+
Here is the significance of the headings you see.
+
+
+
+
+
+
+
14.3.1.1 Arguments
+
+
+
+
This lists each of the arguments of the operation in turn, paraphrasing
+the signature of the operation.
+As for signatures, a $ is used to designate this domain,
+that is, Matrix(R).
+
+
+
+
+
+
+
+
+
+
+
+
14.3.1.2 Returns
+
+
+
+
This describes the return value for the operation, analogous to the
+Arguments part.
+
+
+
+
+
+
+
+
+
+
+
+
14.3.1.3 Origin
+
+
+
+
This tells you which domain or category explicitly exports the
+operation.
+In this example, the domain itself is the Origin.
+
+
+
+
+
+
+
+
+
+
+
+
+
14.3.1.4 Conditions
+
+
+
+
This tells you that the operation is exported by Matrix(R) only if
+``R has Field,'' that is, ``R is a member of
+category Field.''
+When no Conditions part is given, the operation is exported for
+all values of R.
+
+
+
+
+
+
+
+
+
+
+
+
14.3.1.5 Description
+
+
+
+
Here are the ++ comments
+that appear in the source code of its Origin, here Matrix.
+You find these comments in the source code for Matrix.
+
+
+
+
+
+
+
Operations map from Matrix.
+
+
+
Click on to return to the table of operations.
+Click on map.
+Here you find three different operations named map.
+This should not surprise you.
+Operations are identified by name and signature.
+There are three operations named map, each with
+different signatures.
+What you see is the descriptions view of the operations.
+If you like, select the button in the heading of one of these
+descriptions to get only that operation.
+
+
+
+
+
+
+
+
+
+
+
+
14.3.1.6 Where
+
+
+
+
This part qualifies domain parameters mentioned in the arguments to the
+operation.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
14.3.2 Views of Operations
+
+
+
+
+
+
We suggest that you go to the constructor page for Matrix
+and click on Operations to bring up a table of operations
+with a Views panel at the bottom.
+
+
+
+
+
+
+
14.3.2.1 names
+
+
+
+
This view lists the names of the operations.
+Unlike constructors, however, there may be several operations with the
+same name.
+The heading for the page tells you the number of unique names and the
+number of distinct operations when these numbers are different.
+
+
+
+
+
+
+
+
+
+
+
+
14.3.2.2 filter
+
+
+
+
As for constructors, you can use this button to cut down the list of
+operations you are looking at.
+Enter, for example, m* into the input area to the right of
+filter then click on filter.
+As usual, any logical expression is permitted.
+For example, use
+
+
+
+
+
+*! or *?
+
+
+
+
to get a list of destructive operations and predicates.
+
+
+
+
+
+
+
+
+
+
+
+
14.3.2.3 documentation
+
+
+
+
This gives you the most information:
+a detailed description of all the operations in the form you have seen
+before.
+Every other button summarizes these operations in some form.
+
+
+
+
+
+
+
+
+
+
+
+
14.3.2.4 signatures
+
+
+
+
This views the operations by showing their signatures.
+
+
+
+
+
+
+
+
+
+
+
+
14.3.2.5 parameters
+
+
+
+
This views the operations by their distinct syntactic forms with
+parameters.
+
+
+
+
+
+
+
+
+
+
+
+
14.3.2.6 origins
+
+
+
+
This organizes the operations according to the constructor that
+explicitly exports them.
+
+
+
+
+
+
+
+
+
+
+
+
14.3.2.7 conditions
+
+
+
+
This view organizes the operations into conditional and unconditional
+operations.
+
+
+
+
+
+
+
+
+
+
+
+
14.3.2.8 usage
+
+
+
+
This button is only available if your user-level is set to user-level
+development.
+The usage button produces a table of constructors that reference this
+operation.Axiom requires an especially long time to
+produce this table, so anticipate this when requesting this
+information.
+
+
+
+
+
+
+
+
+
+
+
+
14.3.2.9 implementation
+
+
+
+
This button is only available if your user-level is set to development.
+user-level
+If you enter values for all domain parameters on the constructor page,
+then the implementation button appears in place of the
+conditions button.
+This button tells you what domains or packages actually implement the
+various operations.This button often takes a long time; expect
+a delay while you wait for an answer.
+
+
+
+
With your user-level set to development, we suggest you try this
+exercise.
+Return to the main constructor page for Matrix, then enter
+Integer into the input area at the bottom as the value of R.
+Then click on Operations to produce a table of operations.
+Note that the conditions part of the Views table is
+replaced by implementation.
+Click on implementation.
+After some delay, you get a page describing what implements each of
+the matrix operations, organized by the various domains and packages.
+
+
+
+
+
+
+
Implementation domains for Matrix.
+
+
+
+
+
+
+
+
+
+
+
14.3.2.10 generalize
+
+
+
+
This button only appears for an operation page of a constructor
+involving a unique operation name.
+
+
+
+
From an operations page for Matrix, select any
+operation name, say rank.
+In the views panel, the filter button is replaced by
+ generalize.
+Click on it!
+
+What you get is a description of all Axiom operations
+named rank.If there were more than 10
+operations of the name, you get instead a page
+with a Views panel at the bottom and the message to
+Select a view below.
+To get the descriptions of all these operations as mentioned
+above, select the description button.
+
+
+
+
+
+
+
+
All operations named rank in Axiom.
+
+
+
+
+
+
+
+
+
+
+
14.3.2.11 all domains
+
+
+
+
This button only appears on an operation page resulting from a
+search from the front page of Browse or from selecting
+ generalize from an operation page for a constructor.
+
+
+
+
Note that the filter button in the Views panel is
+replaced by all domains.
+Click on it to produce a table of all domains or packages that
+export a rank operation.
+
+
+
+
+
+
+
Table of all domains that export rank.
+
+
+
We note that this table specifically refers to all the rank
+operations shown in the preceding page.
+Return to the descriptions of all the rank operations and
+select one of them by clicking on the button in its heading.
+Select all domains.
+As you see, you have a smaller table of constructors.
+When there is only one constructor, you get the
+constructor page for that constructor.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
14.3.3 Capitalization Convention
+
+
+
+
+
+
When entering search keys for constructors, you can use capital
+letters to search for abbreviations.
+For example, enter UTS into the input area and click on
+Constructors.
+Up comes a page describing UnivariateTaylorSeries
+whose abbreviation is UTS.
+
+
+
+
Constructor abbreviations always have three or more capital
+letters.
+For short constructor names (six letters or less), abbreviations
+are not generally helpful as their abbreviation is typically the
+constructor name in capitals.
+For example, the abbreviation for Matrix is
+MATRIX.
+
+
+
+
Abbreviations can also contain numbers.
+For example, POLY2 is the abbreviation for constructor
+PolynomialFunctions2.
+For default packages, the abbreviation is the same as the
+abbreviation for the corresponding category with the ``&''
+replaced by ``-''.
+For example, for the category default package
+MatrixCategory& the abbreviation is
+MATCAT- since the corresponding category
+MatrixCategory has abbreviation MATCAT.
+
If you have any private .spad files (that is, library files
+which were not shipped with Axiom) you will need to
+recompile them. For example, if you wrote the file regress.spad then you should issue )compile regress.spad
+before trying to use it.
+
+
+
+
The internal representation of Union has changed.
+This means that Axiom data saved
+with Release 1.x may not
+be readable by this Release. If you cannot recreate the saved data
+by recomputing in Release 2.0, please contact NAG for assistance.
+
A new compiler is now available for Axiom.
+The programming language is referred to as the Aldor, and
+improves upon the old Axiom language in many ways.
+The )compile command has been upgraded to be able to
+invoke the new or old compilers.
+The language and the compiler are described in the hard-copy
+documentation which came with your Axiom system.
+
+
+
+
To ease the chore of upgrading your .spad files (old
+compiler) to .as files (new compiler), the
+)compile command has been given a )translate
+option. This invokes a special version of the old compiler which
+parses and analyzes your old code and produces augmented code
+using the new syntax.
+Please be aware that the translation is not necessarily one
+hundred percent complete or correct.
+You should attempt to compile the output with the Aldor compiler
+and make any necessary corrections.
+
The Nag Library link allows you to call NAG Fortran
+routines from within Axiom, passing Axiom objects as parameters
+and getting them back as results.
+
+
+
+
The Nag Library and, consequently, the link are divided into chapters,
+which cover different areas of numerical analysis. The statistical
+and sorting chapters of the Library, however, are not included in the
+link and various support and utility routines (mainly the F06 and X
+chapters) have been omitted.
+
+
+
+
Each chapter has a short (at most three-letter) name;
+for example, the chapter devoted to the
+solution of ordinary differential equations is called D02. When
+using the link via the HyperDoc interface.
+you will be presented with a complete menu of these chapters. The
+names of individual routines within each chapter are formed by
+adding three letters to the chapter name, so for example the routine
+for solving ODEs by Adams method is called
+d02cjfd02cjfNagOrdinaryDifferentialEquationsPackage.
+
+
+
+
+
+
+
+
15.3.1 Interpreting NAG Documentation
+
+
+
nagDocumentation
+
+
+
+
+
Information about using the Nag Library in general, and about using
+individual routines in particular, can be accessed via HyperDoc.
+This documentation refers to the Fortran routines directly; the
+purpose of this subsection is to explain how this corresponds to the
+Axiom routines.
+
+
+
+
For general information about the Nag Library users should consult
+Essential Introduction to the NAG Foundation Library
+manpageXXintro.
+The documentation is in ASCII format, and a description of the conventions
+used to represent mathematical symbols is given in
+Introduction to NAG On-Line Documentation
+manpageXXonline.
+Advice about choosing a routine from a particular chapter can be found in
+the Chapter Documents FoundationLibraryDocPage.
+
+
+
+
+
+
+
+
15.3.1.1 Correspondence Between Fortran and Axiom types
+
+
+
+
+
The NAG documentation refers to the Fortran types of objects; in
+general, the correspondence to Axiom types is as follows.
+
+
+
+
+
+
+ Fortran INTEGER corresponds to Axiom Integer.
+
+
Fortran DOUBLE PRECISION corresponds to Axiom DoubleFloat.
+
+
Fortran COMPLEX corresponds to Axiom Complex DoubleFloat.
+
+
Fortran LOGICAL corresponds to Axiom Boolean.
+
+
Fortran CHARACTER*(*) corresponds to Axiom String.
+
+
+
+
+
(Exceptionally, for NAG EXTERNAL parameters -- ASPs in link parlance
+-- REAL and COMPLEX correspond to MachineFloat and MachineComplex,
+respectively; see aspSection .)
+
+
+
+
The correspondence for aggregates is as follows.
+
+
+
+
+
+
+ A one-dimensional Fortran array corresponds to an Axiom
+ Matrix with one column.
+
+
A two-dimensional Fortran ARRAY corresponds to an Axiom
+ Matrix.
+
+
A three-dimensional Fortran ARRAY corresponds to an Axiom
+ ThreeDimensionalMatrix.
+
+
+
+
+
Higher-dimensional arrays are not currently needed for the Nag Library.
+
+
+
+
Arguments which are Fortran FUNCTIONs or SUBROUTINEs correspond
+to special ASP domains in Axiom. See aspSection .
+
+
+
+
+
+
+
+
+
+
+
+
+
15.3.1.2 Classification of NAG parameters
+
+
+
+
+
NAG parameters are classified as belonging to one (or more)
+of the following categories: Input, Output, Workspace or External procedure.
+Within External procedures a similar classification is used, and parameters
+may also be Dummies, or User Workspace (data structures not used by the
+NAG routine but provided for the convenience of the user).
+
+
+
+
When calling a NAG routine via the link the user only provides values
+for Input and External parameters.
+
+
+
+
The order of the parameters is, in general, different from the order
+specified in the Nag Library documentation. The Browser description
+for each routine helps in determining the correspondence. As a rule of
+thumb, Input parameters come first followed by Input/Output
+parameters. The External parameters are always found at the end.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
15.3.1.3 IFAIL
+
+
+
+
+
NAG routines often return diagnostic information through a parameter called
+ . With a few exceptions, the principle is that on input
+ takes
+one of the values . This determines how the routine behaves when
+it encounters an error:
+
+
+
+
+
+
+ a value of 1 causes the NAG routine to return without printing an error
+message;
+
+
a value of 0 causes the NAG routine to print an error message and abort;
+
+
a value of -1 causes the NAG routine to return and print an error message.
+
+
+
+
+
+
The user is STRONGLY ADVISED to set to when using the link.
+If has been set to or on input, then its value on output
+will determine the possible cause of any error. A value of indicates
+successful completion, otherwise it provides an index into a table of
+diagnostics provided as part of the routine documentation (accessible via
+Browse).
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
15.3.2 Using the Link
+
+
+
nagLinkUsage
+
+
+
+
+
The easiest way to use the link is via the
+HyperDoc interface htxl1.
+You will be presented with a set of fill-in forms where
+you can specify the parameters for each call. Initially, the forms
+contain example values, demonstrating the use of each routine (these,
+in fact, correspond to the standard NAG example program for the
+routine in question). For some parameters, these values can provide
+reasonable defaults; others, of course, represent data. When you
+change a parameter which controls the size of an array, the data in
+that array are reset to a ``neutral'' value -- usually zero.
+
+
+
+
When you are satisfied with the values entered, clicking on the
+``Continue'' button will display the Axiom command needed to
+run the chosen NAG routine with these values. Clicking on the
+``Do It'' button will then cause Axiom to execute this command
+and return the result in the parent Axiom session, as described
+below. Note that, for some routines, multiple HyperDoc ``pages'' are
+required, due to the structure of the data. For these, returning to
+an earlier page causes HyperDoc to reset the later pages (this is a
+general feature of HyperDoc); in such a case, the simplest way to
+repeat a call, varying a parameter on an earlier page, is probably to
+modify the call displayed in the parent session.
+
+
+
+
An alternative approach is to call NAG routines directly in your
+normal Axiom session (that is, using the Axiom
+interpreter). Such calls return an
+object of type Result. As not
+all parameters in the underlying NAG routine are required in the
+AXIOM call (and the parameter ordering may be different), before
+calling a NAG routine you should consult the description of the
+Axiom operation in the Browser. (The quickest route to this
+is to type the routine name, in lower case, into the Browser's
+input area, then click on Operations.) The parameter names
+used coincide with NAG's, although they will appear here in lower
+case. Of course, it is also possible to become familiar with the
+Axiom form of a routine by first using it through the
+HyperDoc interface htxl1.
+
+
+
+
As an example of this mode of working, we can find a zero
+of a function, lying between 3 and 4, as follows:
+
By default, Result only displays the type of returned values,
+since the amount of information returned can be quite large. Individual
+components can be examined as follows:
+
+
+
+
+
+
+
+answer . x
+
+
+
+
+
+
+
+
+
+answer . ifail
+
+
+
+
+
+
In order to avoid conflict with names defined in the workspace, you can also
+get the values by using the String type (the interpreter automatically
+coerces them to Symbol)
+
+
+
+
+
+
+
+answer "x"
+
+
+
+
+
+
It is possible to have Axiom display the values of scalar or array
+results automatically. For more details, see the commands
+showScalarValuesshowScalarValuesResult
+and showArrayValuesshowArrayValuesResult.
+
+
+
+
There is also a .input file for each NAG routine, containing
+Axiom interpreter commands to set up and run the standard NAG
+example for that routine.
+
+
+
+
+
+
+
+)read c05adf.input
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
15.3.3 Providing values for Argument Subprograms
+
+
+
aspSection
+
+
+
+
+
There are a number of ways in which users can provide values for argument
+subprograms (ASPs). At the top level the user will see that NAG routines
+require
+an object from the Union of a Filename and an ASP.
+
+
+
+
For example c05adf requires an object of type
+Union(fn: FileName,fp: Asp1 F)
+
+
+
+
+
+
+
+)display operation c05adf
+
+
+
+
+
+
+
The user thus has a choice of providing the name of a file containing
+Fortran source code, or of somehow generating the ASP within Axiom.
+If a filename is specified, it is searched for in the local
+machine, i.e., the machine that Axiom is running on.
+
+
+
+
+
+
+
+
15.3.3.1 Providing ASPs via FortranExpression
+
+
+
+
+
The FortranExpression domain is used to represent expressions
+which can be translated into Fortran under certain circumstances. It is
+very similar to Expression except that only operators which exist
+in Fortran can be used, and only certain variables can occur.
+For
+example the instantiation FortranExpression([X],[M],MachineFloat)
+is the domain of expressions containing the scalar and the array
+ .
+
Those ASPs which represent expressions usually export a coerce from
+an appropriate instantiation of FortranExpression (or perhaps
+Vector FortranExpression etc.). For convenience there are also
+retractions from appropriate instantiations of Expression,
+Polynomial and Fraction Polynomial.
+
+
+
+
+
+
+
+
+
+
+
+
+
15.3.3.2 Providing ASPs via FortranCode
+
+
+
+
+
FortranCode
+FortranCode allows us to build arbitrarily complex ASPs via a
+kind of pseudo-code. It is described fully in
+generalFortran .
+
+
+
+
Every ASP exports two coerce functions: one from
+FortranCode and one from List FortranCode. There
+is also a coerce from
+Record( localSymbols: SymbolTable, code: List FortranCode)
+which is used for passing extra symbol information about the ASP.
+
+
+
+
So for example, to integrate the function abs(x) we could use the built-in
+ abs function. But suppose we want to get back to basics and define
+it directly, then we could do the following:
+
15.3.4 General Fortran-generation utilities in Axiom
+
+
+
generalFortran
+
+
+
+
+
This section describes more advanced facilities which are available to users
+who wish to generate Fortran code from within Axiom. There are
+facilities to manipulate templates, store type information, and generate
+code fragments or complete programs.
+
+
+
+
+
+
+
+
15.3.4.1 Template Manipulation
+
+
+
+
+
A template is a skeletal program which is ``fleshed out'' with data when
+it is processed. It is a sequence of active and passive parts:
+active parts are sequences of Axiom commands which are processed as if they
+had been typed into the interpreter; passive parts are simply echoed
+verbatim on the Fortran output stream.
+
+
+
+
Suppose, for example, that we have the following template, stored in
+the file ``test.tem'':
+
+
+
+
+
+-- A simple template
+beginVerbatim
+ DOUBLE PRECISION FUNCTION F(X)
+ DOUBLE PRECISION X
+endVerbatim
+outputAsFortran("F",f)
+beginVerbatim
+ RETURN
+ END
+endVerbatim
+
+
+
+
The passive parts lie between the two
+tokens beginVerbatim and endVerbatim. There
+are two active statements: one which is simply an Axiom (
+\verb+--+)
+comment, and one which produces an assignment to the current value
+of f. We could use it as follows:
+
+
+
+
+
+(4) ->f := 4.0/(1+X**2)
+
+ 4
+ (4) ------
+ 2
+ X + 1
+
+(5) ->processTemplate "test.tem"
+ DOUBLE PRECISION FUNCTION F(X)
+ DOUBLE PRECISION X
+ F=4.0D0/(X*X+1.0D0)
+ RETURN
+ END
+
+ (5) "CONSOLE"
+
+
+
+
+
(A more reliable method of specifying the filename will be introduced
+below.) Note that the Fortran assignment F=4.0D0/(X*X+1.0D0)
+automatically converted 4.0 and 1 into DOUBLE PRECISION numbers; in
+general, the Axiom Fortran generation facility will convert
+anything which should be a floating point object into either
+a Fortran REAL or DOUBLE PRECISION object.
+
+
+
+
Which alternative is used is determined by the command
+
+
+
+
+
+
+
+)set fortran precision
+
+
+
+
+
+
It is sometimes useful to end a template before the file itself ends (e.g. to
+allow the template to be tested incrementally or so that a piece of text
+describing how the template works can be included). It is of course possible
+to ``comment-out'' the remainder of the file. Alternatively, the single token
+endInput as part of an active portion of the template will cause
+processing to be ended prematurely at that point.
+
+
+
+
The processTemplate command comes in two flavours. In the first case,
+illustrated above, it takes one argument of domain FileName,
+the name of the template to be processed, and writes its output on the
+current Fortran output stream. In general, a filename can be generated
+from directory, name and extension components, using
+the operation filename, as in
+
+
+
+
+
+processTemplate filename("","test","tem")
+
+
+
+
There is an alternative version of processTemplate, which
+takes two arguments (both of domain FileName). In this case the
+first argument is the name of the template to be processed, and the
+second is the file in which to write the results. Both versions return
+the location of the generated Fortran code as their result
+(``CONSOLE'' in the above example).
+
+
+
+
It is sometimes useful to be able to mix active and passive parts of a
+line or statement. For example you might want to generate a Fortran
+Comment describing your data set. For this kind of application we
+provide three functions as follows:
+
+
fortranLiteral
writes a string on the Fortran output stream
+
+
fortranCarriageReturn
writes a carriage return on the Fortran output stream
+
+
fortranLiteralLine
writes a string followed by a return
+on the Fortran output stream
+
+
+
+
+
So we could create our comment as follows:
+
+
+
+
+
+
+m := matrix [ [1,2,3],[4,5,6] ]
+
+
+
+
+
+
+
+
+
+fortranLiteralLine concat ["C The Matrix has ", nrows(m)::String, " rows and ", ncols(m)::String, " columns"]
+
+
+
+
+
+
or, alternatively:
+
+
+
+
+
+
+fortranLiteral "C The Matrix has "
+
+
+
+
+
+
+
+
+
+fortranLiteral(nrows(m)::String)
+
+
+
+
+
+
+
+
+
+fortranLiteral " rows and "
+
+
+
+
+
+
+
+
+
+fortranLiteral(ncols(m)::String)
+
+
+
+
+
+
+
+
+
+fortranLiteral " columns"
+
+
+
+
+
+
+
+
+
+fortranCarriageReturn()
+
+
+
+
+
+
We should stress that these functions, together with the outputAsFortran
+function are the only sure ways
+of getting output to appear on the Fortran output stream. Attempts to use
+Axiom commands such as output or writeline may appear to give
+the required result when displayed on the console, but will give the wrong
+result when Fortran and algebraic output are sent to differing locations. On
+the other hand, these functions can be used to send helpful messages to the
+user, without interfering with the generated Fortran.
+
+
+
+
+
+
+
+
+
+
+
+
+
15.3.4.2 Manipulating the Fortran Output Stream
+
+
+
+
FortranOutputStackPackage
+
+
+
+
Sometimes it is useful to manipulate the Fortran output stream in a program,
+possibly without being aware of its current value. The main use of this is
+for gathering type declarations (see ``Fortran Types'' below) but it can be useful
+in other contexts as well. Thus we provide a set of commands to manipulate
+a stack of (open) output streams. Only one stream can be written to at
+any given time. The stack is never empty---its initial value is the
+console or the current value of the Fortran output stream, and can be
+determined using
+
+
+
+
+
+
+
+topFortranOutputStack()
+
+
+
+
+
+
(see below).
+The commands available to manipulate the stack are:
+
+
+
+
+
clearFortranOutputStack
resets the stack to the console
+
+
pushFortranOutputStack
pushes a FileName onto the stack
+
+
popFortranOutputStack
pops the stack
+
+
showFortranOutputStack
returns the current stack
+
+
topFortranOutputStack
returns the top element of the stack
+
+
+
+
+
These commands are all part of FortranOutputStackPackage.
+
+
+
+
+
+
+
+
+
+
+
+
+
15.3.4.3 Fortran Types
+
+
+
+
+
When generating code it is important to keep track of the Fortran types of
+the objects which we are generating. This is useful for a number of reasons,
+not least to ensure that we are actually generating legal Fortran code. The
+current type system is built up in several layers, and we shall describe each
+in turn.
+
+
+
+
+
+
+
+
+
+
+
+
+
15.3.4.4 FortranScalarType
+
+
+
+
FortranScalarType
+
+
+
+
This domain represents the simple Fortran datatypes: REAL, DOUBLE PRECISION,
+COMPLEX, LOGICAL, INTEGER, and CHARACTER.
+It is possible to coerce a String or Symbol
+into the domain, test whether two objects are equal, and also apply
+the predicate functions real?real?FortranScalarType etc.
+
+
+
+
+
+
+
+
+
+
+
+
+
15.3.4.5 FortranType
+
+
+
+
FortranType
+
+
+
+
This domain represents ``full'' types: i.e., datatype plus array dimensions
+(where appropriate) plus whether or not the parameter is an external
+subprogram. It is possible to coerce an object of
+FortranScalarType into the domain or construct one
+from an element of FortranScalarType, a list of
+Polynomial Integers (which can of course be simple integers or
+symbols) representing its dimensions, and
+a Boolean declaring whether it is external or not. The list
+of dimensions must be empty if the Boolean is true.
+The functions scalarTypeOf, dimensionsOf and
+ external? return the appropriate
+parts, and it is possible to get the various basic Fortran Types via
+functions like fortranReal.
+
This domain creates and manipulates a symbol table for generated Fortran code.
+This is used by FortranProgram to represent the types of objects in
+a subprogram. The commands available are:
+
+
+
+
+
empty
creates a new SymbolTable
+
+
declare
creates a new entry in a table
+
+
fortranTypeOf
returns the type of an object in a table
+
+
parametersOf
returns a list of all the symbols in the table
+
+
typeList
returns a list of all objects of a given type
+
+
typeLists
returns a list of lists of all objects sorted by type
This domain creates and manipulates one global symbol table to be used, for
+example, during template processing. It is
+also used when
+linking to external Fortran routines. The
+information stored for each subprogram (and the main program segment, where
+relevant) is:
+
+
+
+
+
+
+ its name;
+
+
its return type;
+
+
its argument list;
+
+
and its argument types.
+
+
+
+
+
Initially, any information provided is deemed to be for the main program
+segment.
+
+
+
+
Issuing the following command indicates that from now on all information
+refers to the subprogram .
+
+
+
+
+
+
+
+newSubProgram F
+
+
+
+
+
+
It is possible to return to processing the main program segment by issuing
+the command:
+
+
+
+
+
+
+
+endSubProgram()
+
+
+
+
+
+
The following commands exist:
+
+
+
+
+
returnType
declares the return type of the current subprogram
+
+
returnTypeOf
returns the return type of a subprogram
+
+
argumentList
declares the argument list of the current subprogram
+
+
argumentListOf
returns the argument list of a subprogram
+
+
declare
provides type declarations for parameters of the current subprogram
+
+
symbolTableOf
returns the symbol table of a subprogram
+
+
printHeader
produces the Fortran header for the current subprogram
+
+
+
+
+
In addition there are versions of these commands which are parameterised by
+the name of a subprogram, and others parameterised by both the name of a
+subprogram and by an instance of TheSymbolTable.
+
+
+
+
+
+
+
+newSubProgram F
+
+
+
+
+
+
+
+
+
+argumentList!(F,[X])
+
+
+
+
+
+
+
+
+
+returnType!(F,real)
+
+
+
+
+
+
+
+
+
+declare!(X,fortranReal(),F)
+
+
+
+
+
+
+
+
+
+printHeader F
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
15.3.4.8 Advanced Fortran Code Generation
+
+
+
+
+
This section describes facilities for representing Fortran statements, and
+building up complete subprograms from them.
+
+
+
+
+
+
+
+
+
+
+
+
+
15.3.4.9 Switch
+
+
+
+
Switch
+
+
+
+
This domain is used to represent statements like x < y. Although
+these can be represented directly in Axiom, it is a little cumbersome,
+since Axiom evaluates the last statement, for example, to true
+(since is lexicographically less than ).
+
+
+
+
Instead we have a set of operations, such as LT to represent ,
+to let us build such statements. The available constructors are:
+
+
+
+
+
+
+
+
+
+
LT
+
GT
+
LE
+
GE
+
EQ
+
AND
and
+
OR
or
+
NOT
not
+
+
+
+
+
+
+
+
+
+
So for example:
+
+
+
+
+
+
+LT(x,y)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
15.3.4.10 FortranCode
+
+
+
+
+
This domain represents code segments or operations: currently assignments,
+conditionals, blocks, comments, gotos, continues, various kinds of loops,
+and return statements.
+
+
+
+
For example we can create quite a complicated conditional statement using
+assignments, and then turn it into Fortran code:
+
The Fortran code is printed
+on the current Fortran output stream.
+
+
+
+
+
+
+
+
+
+
+
+
+
15.3.4.11 FortranProgram
+
+
+
+
FortranProgram
+
+
+
+
This domain is used to construct complete Fortran subprograms out of
+elements of FortranCode. It is parameterised by the name of the
+target subprogram (a Symbol), its return type (from
+Union(FortranScalarType,``void'')),
+its arguments (from List Symbol), and
+its symbol table (from SymbolTable). One can
+ coerce elements of either FortranCode
+or Expression into it.
+
+
+
+
+
First of all we create a symbol table:
+
+
+
+
+
+
+
+symbols := empty()$SymbolTable
+
+
+
+
+
+
Now put some type declarations into it:
+
+
+
+
+
+
+
+declare!([X,Y],fortranReal(),symbols)
+
+
+
+
+
+
Then (for convenience)
+we set up the particular instantiation of FortranProgram
+
+
+
+
+
+
+
+FP := FortranProgram(F,real,[X,Y],symbols)
+
+
+
+
+
+
Create an object of type Expression(Integer):
+
+
+
+
+
+
+
+asp := X*sin(Y)
+
+
+
+
+
+
Now coerce it into FP, and print its Fortran form:
+
+
+
+
+
+
+
+outputAsFortran(asp::FP)
+
+
+
+
+
+
We can generate a FortranProgram using . For
+example:
+
+
+
+
Augment our symbol table:
+
+
+
+
+
+
+
+declare!(Z,fortranReal(),symbols)
+
+
+
+
+
+
and transform the conditional expression we prepared earlier:
+
+
+
+
+
+
+
+outputAsFortran([c,returns()]::FP)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
15.3.5 Some technical information
+
+
+
nagTechnical
+
+
+
+
+
The model adopted for the link is a server-client configuration
+-- Axiom acting as a client via a local agent
+(a process called nagman). The server side is implemented
+by the nagd daemon process which may run on a different host.
+The nagman local agent is started by default whenever you
+start Axiom. The nagd server must be started separately.
+Instructions for installing and running the server are supplied
+in nugNagd .
+Use the )set naglink host system command
+to point your local agent to a server in your network.
+
+
+
+
+
+
On the Axiom side, one sees a set of packages
+(ask Browse for Nag*) for each chapter, each exporting
+operations with the same name as a routine in the Nag Library.
+The arguments and return value of each operation belong to
+standard Axiom types.
+
+
+
+
The man pages for the Nag Library are accessible via the description
+of each operation in Browse (among other places).
+
+
+
+
In the implementation of each operation, the set of inputs is passed
+to the local agent nagman, which makes a
+Remote Procedure Call (RPC) to the
+remote nagd daemon process. The local agent receives the RPC
+results and forwards them to the Axiom workspace where they
+are interpreted appropriately.
+
+
+
+
How are Fortran subroutines turned into RPC calls?
+For each Fortran routine in the Nag Library, a C main() routine
+is supplied.
+Its job is to assemble the RPC input (numeric) data stream into
+the appropriate Fortran data structures for the routine, call the Fortran
+routine from C and serialize the results into an RPC output data stream.
+
+
+
+
Many Nag Library routines accept ASPs (Argument Subprogram Parameters).
+These specify user-supplied Fortran routines (e.g. a routine to
+supply values of a function is required for numerical integration).
+How are they handled? There are new facilities in Axiom to help.
+A set of Axiom domains has been provided to turn values in standard
+ Axiom types (such as Expression Integer) into the appropriate
+piece of Fortran for each case (a filename pointing to Fortran source
+for the ASP can always be supplied instead).
+Ask Browse for Asp* to see these domains. The Fortran fragments
+are included in the outgoing RPC stream, but nagd intercepts them,
+compiles them, and links them with the main() C program before executing
+the resulting program on the numeric part of the RPC stream.
+
The leave keyword has been replaced by the
+break keyword for compatibility with the new Axiom
+extension language.
+See section ugLangLoopsBreak
+for more information.
+
+
+
+
Curly braces are no longer used to create sets. Instead, use
+ set followed by a bracketed expression. For example,
+
+
+
+
+
+
+
+set [1,2,3,4]
+
+
+
+
+
+
Curly braces are now used to enclose a block (see section
+ugLangBlocks
+for more information). For compatibility, a block can still be
+enclosed by parentheses as well.
+
+
+
+
``Free functions'' created by the Aldor compiler can now be
+loaded and used within the Axiom interpreter. A free
+function is a library function that is implemented outside a
+domain or category constructor.
+
+
+
+
New coercions to and from type Expression have been
+added. For example, it is now possible to map a polynomial
+represented as an expression to an appropriate polynomial type.
+
+
+
+
Various messages have been added or rewritten for clarity.
+
The FullPartialFractionExpansion
+domain has been added. This domain computes factor-free full
+partial fraction expansions.
+See section
+FullPartialFractionExpansion
+for examples.
+
+
+
+
We have implemented the Bertrand/Cantor algorithm for integrals of
+hyperelliptic functions. This brings a major speedup for some
+classes of algebraic integrals.
+
+
+
+
We have implemented a new (direct) algorithm for integrating trigonometric
+functions. This brings a speedup and an improvement in the answer
+quality.
+
+
+
+
The SmallFloat domain has been renamed
+DoubleFloat and SmallInteger has been renamed
+SingleInteger. The new abbreviations as
+DFLOAT and SINT, respectively.
+We have defined the macro SF, the old abbreviation for {\sf
+SmallFloat}, to expand to DoubleFloat and modified
+the documentation and input file examples to use the new names
+and abbreviations. You should do the same in any private Axiom
+files you have.
+
+
+
+
There are many new categories, domains and packages related to the
+NAG Library Link facility. See the file
+
+
+
+
src/algebra/exposed.lsp
+
+
+
+
for a list of constructors in the naglink Axiom exposure group.
+
+
+
+
We have made improvements to the differential equation solvers
+and there is a new facility for solving systems of first-order
+linear differential equations.
+In particular, an important fix was made to the solver for
+inhomogeneous linear ordinary differential equations that
+corrected the calculation of particular solutions.
+We also made improvements to the polynomial
+and transcendental equation solvers including the
+ability to solve some classes of systems of transcendental
+equations.
+
+
+
+
The efficiency of power series have been improved and left and right
+expansions of at a pole of
+can now be computed.
+A number of power series bugs were fixed and the GeneralUnivariatePowerSeries
+domain was added.
+The power series variable can appear in the coefficients and when this
+happens, you cannot differentiate or integrate the series. Differentiation
+and integration with respect to other variables is supported.
+
+
+
+
A domain was added for representing asymptotic expansions of a
+function at an exponential singularity.
+
+
+
+
For limits, the main new feature is the exponential expansion domain used
+to treat certain exponential singularities. Previously, such singularities
+were treated in an ad hoc way and only a few cases were covered. Now
+Axiom can do things like
+
+
+
+
+
+
+limit( (x+1)**(x+1)/x**x - x**x/(x-1)**(x-1), x = %plusInfinity)
+
+
+
+
+
in a systematic way. It only does one level of nesting, though. In other
+words, we can handle , but not
+ .
+
+
+
+
The computation of integral bases has been improved through careful
+use of Hermite row reduction. A P-adic algorithm
+for function fields of algebraic curves in finite characteristic has also
+been developed.
+
+
+
+
Miscellaneous:
+There is improved conversion of definite and indefinite integrals to
+InputForm;
+binomial coefficients are displayed in a new way;
+some new simplifications of radicals have been implemented;
+the operation complexForm for converting to rectangular coordinates
+has been added;
+symmetric product operations have been added to LinearOrdinaryDifferentialOperator.
+
The buttons on the titlebar and scrollbar have been replaced
+with ones which have a 3D effect. You can change the foreground and
+background colors of these ``controls'' by including and modifying
+the following lines in your .Xdefaults file.
+
+
+
+
+
+Axiom.hyperdoc.ControlBackground: White
+Axiom.hyperdoc.ControlForeground: Black
+
+
+
+
+
For various reasons, HyperDoc sometimes displays a
+secondary window. You can control the size and placement of this
+window by including and modifying
+the following line in your .Xdefaults file.
+
+
+
+
+
+
+Axiom.hyperdoc.FormGeometry: =950x450+100+0
+
+
+
+
+
This setting is a standard X Window System geometry specification:
+you are requesting a window 950 pixels wide by 450 deep and placed in
+the upper left corner.
+
+
+
+
Some key definitions have been changed to conform more closely
+with the CUA guidelines. Press
+F9
+to see the current definitions.
+
+
+
+
Input boxes (for example, in the Browser) now accept paste-ins from
+the X Window System. Use the second button to paste in something
+you have previously copied or cut. An example of how you can use this
+is that you can paste the type from an Axiom computation
+into the main Browser input box.
+
We describe here a few additions to the on-line
+version of the AXIOM book which you can read with
+HyperDoc.
+
+
+
+
+
A section has been added to the graphics chapter, describing
+how to build two-dimensional graphs from lists of points. An example is
+given showing how to read the points from a file.
+See section ugGraphTwoDbuild
+for details.
+
+
+
+
A further section has been added to that same chapter, describing
+how to add a two-dimensional graph to a viewport which already
+contains other graphs.
+See section
+ugGraphTwoDappend
+for details.
+
+
+
+
Chapter 3
+and the on-line HyperDoc help have been unified.
+
+
+
+
An explanation of operation names ending in ``?'' and ``!'' has
+been added to the first chapter.
+See the
+end of the section
+ugIntroCallFun
+for details.
+
+
+
+
An expanded explanation of using predicates has
+been added to the sixth chapter. See the
+example involving evenRule in the middle of the section
+ugUserRules
+for details.
+
+
+
+
Documentation for the )compile, )library and
+)load commands has been greatly changed. This reflects
+the ability of the )compile to now invoke the Aldor
+compiler, the impending deletion of the )load command
+and the new )library command.
+The )library command replaces )load and is
+compatible with the compiled output from both the old and new
+compilers.
+
This chapter describes system commands, the command-line
+facilities used to control the Axiom environment.
+The first section is an introduction and discusses the common
+syntax of the commands available.
+
System commands are used to perform Axiom environment
+management.
+Among the commands are those that display what has been defined or
+computed, set up multiple logical Axiom environments
+(frames), clear definitions, read files of expressions and
+commands, show what functions are available, and terminate
+Axiom.
+
+
+
+
Some commands are restricted: the commands
+set userlevel interpreter
+set userlevel compiler
+set userlevel development
+
+
+
+
+
+)set userlevel interpreter
+)set userlevel compiler
+)set userlevel development
+
+
+
+
set the user-access level to the three possible choices.
+All commands are available at development level and the fewest
+are available at interpreter level.
+The default user-level is interpreter.
+user-level
+In addition to the )set command (discussed in
+ugSysCmdset )
+you can use the HyperDoc settings facility to change the user-level.
+
+
+
+
+
Each command listing begins with one or more syntax pattern descriptions
+plus examples of related commands.
+The syntax descriptions are intended to be easy to read and do not
+necessarily represent the most compact way of specifying all
+possible arguments and options; the descriptions may occasionally
+be redundant.
+
+
+
+
All system commands begin with a right parenthesis which should be in
+the first available column of the input line (that is, immediately
+after the input prompt, if any).
+System commands may be issued directly to Axiom or be
+included in .input files.
+file:input
+
+
+
+
A system command argument is a word that directly
+follows the command name and is not followed or preceded by a
+right parenthesis.
+A system command option follows the system command and
+is directly preceded by a right parenthesis.
+Options may have arguments: they directly follow the option.
+This example may make it easier to remember what is an option and
+what is an argument:
+
In the system command descriptions, optional arguments and options are
+enclosed in brackets (``['' and ``]'').
+If an argument or option name is in italics, it is
+meant to be a variable and must have some actual value substituted
+for it when the system command call is made.
+For example, the syntax pattern description
+
+
+
+
+
)readfileName[)quietly]
+
+
+
+
+
would imply that you must provide an actual file name for
+fileName but need not use the )quietly option.
+Thus
+
+
+
+
+
+)read matrix.input
+
+
+
+
is a valid instance of the above pattern.
+
+
+
+
System command names and options may be abbreviated and may be in
+upper or lower case.
+The case of actual arguments may be significant, depending on the
+particular situation (such as in file names).
+System command names and options may be abbreviated to the minimum
+number of starting letters so that the name or option is unique.
+Thus
+
+
+
+
+
+)s Integer
+
+
+
+
is not a valid abbreviation for the )set command,
+because both )set and )show
+begin with the letter ``s''.
+Typically, two or three letters are sufficient for disambiguating names.
+In our descriptions of the commands, we have used no abbreviations for
+either command names or options.
+
+
+
+
In some syntax descriptions we use a vertical line ``|''
+to indicate that you must specify one of the listed choices.
+For example, in
+
+
+
+
+
+)set output fortran on | off
+
+
+
+
only on and off are acceptable words for following
+boot.
+We also sometimes use ``...'' to indicate that additional arguments
+or options of the listed form are allowed.
+Finally, in the syntax descriptions we may also list the syntax of
+related commands.
+
This command is used by Axiom
+developers to leave the Axiom system and return
+to the underlying Common Lisp system.
+To return to Axiom, issue the
+``(|spad|)''
+function call to Common Lisp.
+
+
+
+
Also See:
+)pquitugSysCmdpquit and
+)quitugSysCmdquit.
+
A frame can be thought of as a logical session within the
+physical session that you get when you start the system. You can
+have as many frames as you want, within the limits of your computer's
+storage, paging space, and so on.
+Each frame has its own step number, environment and history.
+You can have a variable named a in one frame and it will
+have nothing to do with anything that might be called a in
+any other frame.
+
+
+
+
Some frames are created by the HyperDoc program and these can
+have pretty strange names, since they are generated automatically.
+frame names
+To find out the names
+of all frames, issue
+
+
+
+
+
+)frame names
+
+
+
+
It will indicate the name of the current frame.
+
+
+
+
You create a new frame
+frame new
+`` quark'' by issuing
+
+
+
+
+
+)frame new quark
+
+
+
+
The history facility can be turned on by issuing either
+)set history on or )history )on.
+If the history facility is on and you are saving history information
+in a file rather than in the Axiom environment
+then a history file with filename quark.axh will
+be created as you enter commands.
+If you wish to go back to what
+you were doing in the
+frame next
+`` initial'' frame, use
+frame last
+
+
+
+
+
+)frame next
+
+
+
+
or
+
+
+
+
+
+)frame last
+
+
+
+
to cycle through the ring of available frames to get back to
+`` initial''.
+
+
+
+
If you want to throw
+away a frame (say `` quark''), issue
+
+
+
+
+
+)frame drop quark
+
+
+
+
If you omit the name, the current frame is dropped.
+frame drop
+
+
+
+
If you do use frames with the history facility on and writing to a file,
+you may want to delete some of the older history files.
+file:history
+These are directories, so you may want to issue a command like
+rm -r quark.axh to the operating system.
+
+
+
+
You can bring things from another frame by using
+frame import
+)frame import.
+For example, to bring the f and g from the frame `` quark''
+to the current frame, issue
+
+
+
+
+
+)frame import quark f g
+
+
+
+
If you want everything from the frame `` quark'', issue
+
+
+
+
+
+)frame import quark
+
+
+
+
You will be asked to verify that you really want everything.
+
+
+
+
There are two )set flags
+set message frame
+to make it easier to tell where you are.
+
+
+
+
+
+)set message frame on | off
+
+
+
+
will print more messages about frames when it is set on.
+By default, it is off.
+
+
+
+
+
+)set message prompt frame
+
+
+
+
will give a prompt
+set message prompt frame
+that looks like
+
+
+
+
+
+initial (1) ->
+
+
+
+
prompt:with frame name
+when you start up. In this case, the frame name and step make up the
+prompt.
+
+
+
+
Also See:
+)historyugSysCmdhistory and
+)setugSysCmdset.
+
The history facility within Axiom allows you to restore your
+environment to that of another session and recall previous
+computational results.
+Additional commands allow you to review previous
+input lines and to create an .input file of the lines typed to
+file:input
+Axiom.
+
+
+
+
Axiom saves your input and output if the history facility is
+turned on (which is the default).
+This information is saved if either of
+
+
+
+
+
+)set history on
+)history )on
+
+
+
+
has been issued.
+Issuing either
+
+
+
+
+
+)set history off
+)history )off
+
+
+
+
will discontinue the recording of information.
+history )on
+set history on
+set history off
+history )off
+
+
+
+
Whether the facility is disabled or not,
+the value of % in Axiom always
+refers to the result of the last computation.
+If you have not yet entered anything,
+% evaluates to an object of type
+Variable('%).
+The function %% may be used to refer
+to other previous results if the history facility is enabled.
+In that case,
+%%(n) is the output from step n if n > 0.
+If n < 0, the step is computed relative to the current step.
+Thus %%(-1) is also the previous step,
+%%(-2), is the step before that, and so on.
+If an invalid step number is given, Axiom will signal an error.
+
+
+
+
The environment information can either be saved in a file or entirely in
+memory (the default).
+Each frame
+(ugSysCmdframe )
+has its own history database.
+When it is kept in a file, some of it may also be kept in memory for
+efficiency.
+When the information is saved in a file, the name of the file is
+of the form FRAME.axh where `` FRAME'' is the name of the
+current frame.
+The history file is placed in the current working directory
+(see ugSysCmdcd ).
+Note that these history database files are not text files (in fact,
+they are directories themselves), and so are not in human-readable
+format.
+
+
+
+
The options to the )history command are as follows:
+
+
+
+
+
+
)changen
+
+will set the number of steps that are saved in memory to n.
+This option only has effect when the history data is maintained in a
+file.
+If you have issued )history )memory (or not changed the default)
+there is no need to use )history )change.
+history )change
+
+
)on
+
+will start the recording of information.
+If the workspace is not empty, you will be asked to confirm this
+request.
+If you do so, the workspace will be cleared and history data will begin
+being saved.
+You can also turn the facility on by issuing )set history on.
+
+
)off
+
+will stop the recording of information.
+The )history )show command will not work after issuing this
+command.
+Note that this command may be issued to save time, as there is some
+performance penalty paid for saving the environment data.
+You can also turn the facility off by issuing )set history off.
+
+
)file
+
+indicates that history data should be saved in an external file on disk.
+
+
)memory
+
+indicates that all history data should be kept in memory rather than
+saved in a file.
+Note that if you are computing with very large objects it may not be
+practical to kept this data in memory.
+
+
)reset
+
+will flush the internal list of the most recent workspace calculations
+so that the data structures may be garbage collected by the underlying
+Common Lisp system.
+Like )history )change, this option only has real effect when
+history data is being saved in a file.
+
+
)restore [savedHistoryName]
+
+completely clears the environment and restores it to a saved session, if
+possible.
+The )save option below allows you to save a session to a file
+with a given name. If you had issued
+)history )save jacobi
+the command
+)history )restore jacobi
+would clear the current workspace and load the contents of the named
+saved session. If no saved session name is specified, the system looks
+for a file called last.axh.
+
+
)savesavedHistoryName
+
+is used to save a snapshot of the environment in a file.
+This file is placed in the current working directory
+(see ugSysCmdcd ).
+Use )history )restore to restore the environment to the state
+preserved in the file.
+This option also creates an input file containing all the lines of input
+since you created the workspace frame (for example, by starting your
+Axiom session) or last did a )clear all or
+)clear completely.
+
+
)show [n] [both]
+
+can show previous input lines and output results.
+)show will display up to twenty of the last input lines
+(fewer if you haven't typed in twenty lines).
+)shown will display up to n of the last input lines.
+)show both will display up to five of the last input lines and
+output results.
+)shownboth will display up to n of the last
+input lines and output results.
+
+
)writehistoryInputFile
+
+creates an .input file with the input lines typed since the start
+of the session/frame or the last )clear all or )clear
+completely.
+If historyInputFileName does not contain a period (``.'') in the filename,
+ .input is appended to it.
+For example,
+)history )write chaos
+and
+)history )write chaos.input
+both write the input lines to a file called chaos.input in your
+current working directory.
+If you issued one or more )undo commands,
+)history )write
+eliminates all
+input lines backtracked over as a result of )undo.
+You can edit this file and then use )read to have Axiom process
+the contents.
+
+
+
+
+
+
Also See:
+)frameugSysCmdframe,
+)readugSysCmdread,
+)setugSysCmdset, and
+)undougSysCmdundo.
+
This command replaces the )load system command that
+was available in Axiom releases before version 2.0.
+The )library command makes available to Axiom the compiled
+objects in the libraries listed.
+
+
+
+
For example, if you )compile dopler.as in your home
+directory, issue )library dopler to have Axiom look
+at the library, determine the category and domain constructors present,
+update the internal database with various properties of the
+constructors, and arrange for the constructors to be
+automatically loaded when needed.
+If the )noexpose option has not been given, the
+constructors will be exposed (that is, available) in the current
+frame.
+
+
+
+
If you compiled a file with the old system compiler, you will
+have an NRLIB present, for example, DOPLER.NRLIB,
+where DOPLER is a constructor abbreviation.
+The command )library DOPLER will then do the analysis and
+database updates as above.
+
+
+
+
To tell the system about all libraries in a directory, use
+)library )dir dirName where dirName is an explicit
+directory.
+You may specify ``.'' as the directory, which means the current
+directory from which you started the system or the one you set
+via the )cd command. The directory name is required.
+
+
+
+
You may only want to tell the system about particular
+constructors within a library. In this case, use the )only
+option. The command )library dopler )only Test1 will only
+cause the Test1 constructor to be analyzed, autoloaded,
+etc..
+
+
+
+
Finally, each constructor in a library are usually automatically exposed when the
+)library command is used. Use the )noexpose
+option if you not want them exposed. At a later time you can use
+)set expose add constructor to expose any hidden
+constructors.
+
+
+
+
Note for Axiom beta testers: At various times this
+command was called )local and )with before the name
+)library became the official name.
+
+
+
+
Also See:
+)cdugSysCmdcd,
+)compileugSysCmdcompile,
+)frameugSysCmdframe, and
+)setugSysCmdset.
+
This command is used by Axiom system developers to have single
+expressions evaluated by the Common Lisp system on which
+Axiom is built.
+The lispExpression is read by the Common Lisp reader and
+evaluated.
+If this expression is not complete (unbalanced parentheses, say), the reader
+will wait until a complete expression is entered.
+
+
+
+
Since this command is only useful for evaluating single expressions, the
+)fin
+command may be used to drop out of Axiom into Common Lisp.
+
+
+
+
Also See:
+)systemugSysCmdsystem,
+)bootugSysCmdboot, and
+)finugSysCmdfin.
+
This command is used to terminate Axiom and return to the
+operating system.
+Other than by redoing all your computations or by
+using the )history )restore
+command to try to restore your working environment,
+you cannot return to Axiom in the same state.
+
+
+
+
)pquit differs from the )quit in that it always asks for
+confirmation that you want to terminate Axiom (the ``p'' is for
+``protected'').
+quit
+When you enter the )pquit command, Axiom responds
+
+
+
+
+
+
+
+
+
Please enter y or yes if you really want to leave the interactive
+environment and return to the operating system:
+
+
+
+
+
+
+
+
+
If you respond with y or yes, you will see the message
+
+
+
+
+
+
+
+
+
You are now leaving the Axiom interactive environment.
+Issue the command axiom to the operating system to start a new session.
+
+
+
+
+
+
+
+
+
and Axiom will terminate and return you to the operating
+system (or the environment from which you invoked the system).
+If you responded with something other than y or yes, then
+the message
+
+
+
+
+
+
+
+
+
You have chosen to remain in the Axiom interactive environment.
+
+
+
+
+
+
+
+
+
will be displayed and, indeed, Axiom would still be running.
+
+
+
+
Also See:
+)finugSysCmdfin,
+)historyugSysCmdhistory,
+)closeugSysCmdclose,
+)quitugSysCmdquit, and
+)systemugSysCmdsystem.
+
This command is used to terminate Axiom and return to the
+operating system.
+Other than by redoing all your computations or by
+using the )history )restore
+command to try to restore your working environment,
+you cannot return to Axiom in the same state.
+
+
+
+
)quit differs from the )pquit in that it asks for
+pquit
+confirmation only if the command
+
+
+
+
+
+)set quit protected
+
+
+
+
has been issued.
+set quit protected
+Otherwise, )quit will make Axiom terminate and return you
+to the operating system (or the environment from which you invoked the
+system).
+
+
+
+
The default setting is )set quit protected so that )quit
+and )pquit behave in the same way.
+If you do issue
+
+
+
+
+
+)set quit unprotected
+
+
+
+
we
+set quit unprotected
+suggest that you do not (somehow) assign )quit to be
+executed when you press, say, a function key.
+
+
+
+
Also See:
+)finugSysCmdfin,
+)historyugSysCmdhistory,
+)closeugSysCmdclose,
+)pquitugSysCmdpquit, and
+)systemugSysCmdsystem.
+
This command is used to query, set and remove abbreviations for category,
+domain and package constructors.
+Every constructor must have a unique abbreviation.
+This abbreviation is part of the name of the subdirectory
+under which the components of the compiled constructor are
+stored.
+
+
+
+
+
+
+
+
+
+
Furthermore, by issuing this command you
+let the system know what file to load automatically if you use a new
+constructor.
+Abbreviations must start with a letter and then be followed by
+up to seven letters or digits.
+Any letters appearing in the abbreviation must be in uppercase.
+
+
+
+
When used with the query argument,
+abbreviation query
+this command may be used to list the name
+associated with a particular abbreviation or the abbreviation for a
+constructor.
+If no abbreviation or name is given, the names and corresponding
+abbreviations for all constructors are listed.
+
+
+
+
The following shows the abbreviation for the constructor List:
+
+
+
+
+
+)abbreviation query List
+
+
+
+
The following shows the constructor name corresponding to the
+abbreviation NNI:
+
+
+
+
+
+)abbreviation query NNI
+
+
+
+
The following lists all constructor names and their abbreviations.
+
+
+
+
+
+)abbreviation query
+
+
+
+
+
To add an abbreviation for a constructor, use this command with
+category, domain or package.
+abbreviation package
+abbreviation domain
+abbreviation category
+The following add abbreviations to the system for a
+category, domain and package, respectively:
+
+
+
+
+
+)abbreviation domain SET Set
+)abbreviation category COMPCAT ComplexCategory
+)abbreviation package LIST2MAP ListToMap
+
+
+
+
+
If the )quiet option is used,
+no output is displayed from this command.
+You would normally only define an abbreviation in a library source file.
+If this command is issued for a constructor that has already been loaded, the
+constructor will be reloaded next time it is referenced. In particular, you
+can use this command to force the automatic reloading of constructors.
+
+
+
+
To remove an abbreviation, the remove argument is used.
+abbreviation remove
+This is usually
+only used to correct a previous command that set an abbreviation for a
+constructor name.
+If, in fact, the abbreviation does exist, you are prompted
+for confirmation of the removal request.
+Either of the following commands
+will remove the abbreviation VECTOR2 and the
+constructor name VectorFunctions2 from the system:
+
This command is used to read .input files into Axiom.
+file:input
+The command
+
+
+
+
+
+)read matrix.input
+
+
+
+
will read the contents of the file matrix.input into
+Axiom.
+The ``.input'' file extension is optional.
+See ugInOutIn
+for more information about .input files.
+
+
+
+
This command remembers the previous file you edited, read or compiled.
+If you do not specify a file name, the previous file will be read.
+
+
+
+
The )ifthere option checks to see whether the .input file
+exists.
+If it does not, the )read command does nothing.
+If you do not use this option and the file does not exist,
+you are asked to give the name of an existing .input file.
+
+
+
+
The )quiet option suppresses output while the file is being read.
+
+
+
+
Also See:
+)compileugSysCmdcompile,
+)editugSysCmdedit, and
+)historyugSysCmdhistory.
+
The )set command is used to view or set system variables that
+control what messages are displayed, the type of output desired, the
+status of the history facility, the way Axiom user functions are
+cached, and so on.
+Since this collection is very large, we will not discuss them here.
+Rather, we will show how the facility is used.
+We urge you to explore the )set options to familiarize yourself
+with how you can modify your Axiom working environment.
+There is a HyperDoc version of this same facility available from the
+main HyperDoc menu.
+
+
+
+
+
The )set command is command-driven with a menu display.
+It is tree-structured.
+To see all top-level nodes, issue )set by itself.
+
+
+
+
+
+)set
+
+
+
+
Variables with values have them displayed near the right margin.
+Subtrees of selections have ``...''
+displayed in the value field.
+For example, there are many kinds of messages, so issue
+)set message to see the choices.
+
+
+
+
+
+)set message
+
+
+
+
The current setting for the variable that displays
+computation timings:displaying
+whether computation times
+timings:displaying
+are displayed is visible in the menu displayed by the last command.
+To see more information, issue
+
+
+
+
+
+)set message time
+
+
+
+
This shows that time printing is on now.
+To turn it off, issue
+
+
+
+
+
+)set message time off
+
+
+
+
set message time
+
+
+
+
As noted above, not all settings have so many qualifiers.
+For example, to change the )quit command to being unprotected
+(that is, you will not be prompted for verification), you need only issue
+
Command Description:
+This command displays information about Axiom
+domain, package and category constructors.
+If no options are given, the )operations option is assumed.
+For example,
+
each display basic information about the
+Polynomial domain constructor and then provide a
+listing of operations.
+Since Polynomial requires a Ring (for example,
+Integer) as argument, the above commands all refer
+to a unspecified ring R.
+In the list of operations, $ means
+Polynomial(R).
+
+
+
+
The basic information displayed includes the signature
+of the constructor (the name and arguments), the constructor
+abbreviation, the exposure status of the constructor, and the
+name of the library source file for the constructor.
+
+
+
+
If operation information about a specific domain is wanted,
+the full or abbreviated domain name may be used.
+For example,
+
+
+
+
+
+)show POLY INT
+)show POLY INT )operations
+)show Polynomial Integer
+)show Polynomial Integer )operations
+
+
+
+
are among the combinations that will
+display the operations exported by the
+domain Polynomial(Integer) (as opposed to the general
+domain constructorPolynomial).
+Attributes may be listed by using the )attributes option.
+
+
+
+
Also See:
+)displayugSysCmddisplay,
+)setugSysCmdset, and
+)whatugSysCmdwhat.
+
This command is used to save (spool) all Axiom input and output
+file:spool
+into a file, called a spool file.
+You can only have one spool file active at a time.
+To start spool, issue this command with a filename. For example,
+
+
+
+
+
+)spool integrate.out
+
+
+
+
To stop spooling, issue )spool with no filename.
+
+
+
+
If the filename is qualified with a directory, then the output will
+be placed in that directory.
+If no directory information is given, the spool file will be placed in the
+directory:for spool files
+current directory.
+The current directory is the directory from which you started
+Axiom or is the directory you specified using the
+)cd command.
+cd
+
This command is used to create short synonyms for system command expressions.
+For example, the following synonyms might simplify commands you often
+use.
+
+
+
+
+
+)synonym save history )save
+)synonym restore history )restore
+)synonym mail system mail
+)synonym ls system ls
+)synonym fortran set output fortran
+
+
+
+
Once defined, synonyms can be
+used in place of the longer command expressions.
+Thus
+
+
+
+
+
+)fortran on
+
+
+
+
is the same as the longer
+
+
+
+
+
+)set fortran output on
+
+
+
+
To list all defined synonyms, issue either of
+
+
+
+
+
+)synonyms
+)what synonyms
+
+
+
+
To list, say, all synonyms that contain the substring
+``ap'', issue
+
+
+
+
+
+)what synonyms ap
+
+
+
+
+
Also See:
+)setugSysCmdset and
+)whatugSysCmdwhat.
+
This command may be used to issue commands to the operating system while
+remaining in Axiom.
+The cmdExpression is passed to the operating system for
+execution.
+
+
+
+
To get an operating system shell, issue, for example,
+)system sh.
+When you enter the key combination,
+ Ctrl-- D
+(pressing and holding the
+ Ctrl key and then pressing the
+ D key)
+the shell will terminate and you will return to Axiom.
+We do not recommend this way of creating a shell because
+Common Lisp may field some interrupts instead of the shell.
+If possible, use a shell running in another window.
+
+
+
+
If you execute programs that misbehave you may not be able to return to
+Axiom.
+If this happens, you may have no other choice than to restart
+Axiom and restore the environment via )history )restore, if
+possible.
+
+
+
+
Also See:
+)bootugSysCmdboot,
+)finugSysCmdfin,
+)lispugSysCmdlisp,
+)pquitugSysCmdpquit, and
+)quitugSysCmdquit.
+
This command is used to trace the execution of functions that make
+up the Axiom system, functions defined by users,
+and functions from the system library.
+Almost all options are available for each type of function but
+exceptions will be noted below.
+
+
+
+
To list all functions, constructors, domains and packages that are
+traced, simply issue
+
+
+
+
+
+)trace
+
+
+
+
To untrace everything that is traced, issue
+
+
+
+
+
+)trace )off
+
+
+
+
When a function is traced, the default system action is to display
+the arguments to the function and the return value when the
+function is exited.
+Note that if a function is left via an action such as a THROW, no
+return value will be displayed.
+Also, optimization of tail recursion may decrease the number of
+times a function is actually invoked and so may cause less trace
+information to be displayed.
+Other information can be displayed or collected when a function is
+traced and this is controlled by the various options.
+Most options will be of interest only to Axiom system
+developers.
+If a domain or package is traced, the default action is to trace
+all functions exported.
+
+
+
+
Individual interpreter, lisp or boot
+functions can be traced by listing their names after
+)trace.
+Any options that are present must follow the functions to be
+traced.
+
+
+
+
+
+)trace f
+
+
+
+
traces the function f.
+To untrace f, issue
+
+
+
+
+
+)trace f )off
+
+
+
+
Note that if a function name contains a special character, it will
+be necessary to escape the character with an underscore
+
+
+
+
+
+
+)trace _/D_,1
+
+
+
+
+
To trace all domains or packages that are or will be created from a particular
+constructor, give the constructor name or abbreviation after
+)trace.
+
+
+
+
+
+
+)trace MATRIX
+)trace List Integer
+
+
+
+
+
The first command traces all domains currently instantiated with
+Matrix.
+If additional domains are instantiated with this constructor
+(for example, if you have used Matrix(Integer) and
+Matrix(Float)), they will be automatically traced.
+The second command traces List(Integer).
+It is possible to trace individual functions in a domain or
+package.
+See the )ops option below.
+
+
+
+
The following are the general options for the )trace
+command.
+
+
+
+
+
+
+
+
+
+
)break after
+
+causes a Common Lisp break loop to be entered after
+exiting the traced function.
+
+
)break before
+
+causes a Common Lisp break loop to be entered before
+entering the traced function.
+
+
)break
+
+is the same as )break before.
+
+
+
)count
+
+causes the system to keep a count of the number of times the
+traced function is entered. The total can be displayed with
+)trace )stats and cleared with )trace )stats reset.
+
+
)countn
+
+causes information about the traced function to be displayed for
+the first n executions. After the n-th execution, the
+function is untraced.
+
+
)depthn
+
+causes trace information to be shown for only n levels of
+recursion of the traced function. The command
+
+
+
+
+
+)trace fib )depth 10
+
+
+
+will cause the display of only 10 levels of trace information for
+the recursive execution of a user function fib.
+
+
)math
+
+causes the function arguments and return value to be displayed in the
+Axiom monospace two-dimensional math format.
+
+
)nonquietly
+
+causes the display of additional messages when a function is
+traced.
+
+
)nt
+
+This suppresses all normal trace information. This option is
+useful if the )count or )timer options are used and
+you are interested in the statistics but not the function calling
+information.
+
+
)off
+
+causes untracing of all or specific functions. Without an
+argument, all functions, constructors, domains and packages are
+untraced. Otherwise, the given functions and other objects
+are untraced. To
+immediately retrace the untraced functions, issue )trace
+)restore.
+
+
)onlylistOfDataToDisplay
+
+causes only specific trace information to be shown. The items are
+listed by using the following abbreviations:
+
+
a
+
display all arguments
+
+
v
+
display return value
+
+
1
+
display first argument
+
+
2
+
display second argument
+
+
15
+
display the 15th argument, and so on
+
+
+
+
+
+
)restore
+
+causes the last untraced functions to be retraced. If additional
+options are present, they are added to those previously in effect.
+
+
)stats
+
+causes the display of statistics collected by the use of the
+)count and )timer options.
+
+
)stats reset
+
+resets to 0 the statistics collected by the use of the
+)count and )timer options.
+
+
)timer
+
+causes the system to keep a count of execution times for the
+traced function. The total can be displayed with )trace
+)stats and cleared with )trace )stats reset.
+
+
+
)varbreakvar1 [... varN]
+
+causes a Common Lisp break loop to be entered after
+the assignment to any of the listed variables in the traced
+function.
+
+
)vars
+
+causes the display of the value of any variable after it is
+assigned in the traced function.
+Note that library code must
+have been compiled (see ugSysCmdcompile )
+using the )vartrace option in order
+to support this option.
+
+
)varsvar1 [... varN]
+
+causes the display of the value of any of the specified variables
+after they are assigned in the traced function.
+Note that library code must
+have been compiled (see ugSysCmdcompile )
+using the )vartrace option in order
+to support this option.
+
+
)withinexecutingFunction
+
+causes the display of trace information only if the traced
+function is called when the given executingFunction is running.
+
+
+
+
+
+
The following are the options for tracing constructors, domains
+and packages.
+
+
+
+
+
)local[op1 [... opN]]
+
+causes local functions of the constructor to be traced. Note that
+to untrace an individual local function, you must use the fully
+qualified internal name, using the escape character
+_ before the semicolon.
+
+
+
+
+
+By default, all operations from a domain or package are traced
+when the domain or package is traced. This option allows you to
+specify that only particular operations should be traced. The
+command
+
+
+
+
+
+)trace Integer )ops min max _+ _-
+
+
+
+traces four operations from the domain Integer. Since
++ and - are special
+characters, it is necessary
+to escape them with an underscore.
+
+
+
+
+
+
Also See:
+)bootugSysCmdboot,
+)lispugSysCmdlisp, and
+)ltraceugSysCmdltrace.
+
This command is used to
+restore the state of the user environment to an earlier
+point in the interactive session.
+The argument of an )undo is an integer which must designate some
+step number in the interactive session.
+
+
+
+
+
+
+)undo n
+)undo n )after
+
+
+
+
These commands return the state of the interactive
+environment to that immediately after step n.
+If n is a positive number, then n refers to step nummber
+n. If n is a negative number, it refers to the \tt n-th
+previous command (that is, undoes the effects of the last
+commands).
+
+
+
+
A )clear all resets the )undo facility.
+Otherwise, an )undo undoes the effect of )clear with
+options properties, value, and mode, and
+that of a previous undo.
+If any such system commands are given between steps and
+ ( ), their effect is undone
+for )undo m for any ..
+
+
+
+
The command )undo is equivalent to )undo -1 (it undoes
+the effect of the previous user expression).
+The command )undo 0 undoes any of the above system commands
+issued since the last user expression.
+
+
+
+
+
+
+)undo n )before
+
+
+
+
This command returns the state of the interactive
+environment to that immediately before step n.
+Any )undo or )clear system commands
+given before step n will not be undone.
+
+
+
+
+
+
+)undo )redo
+
+
+
+
This command reads the file redo.input.
+created by the last )undo command.
+This file consists of all user input lines, excluding those
+backtracked over due to a previous )undo.
+
+
+
+
Also See:
+)historyugSysCmdhistory.
+The command )history )write will eliminate the ``undone'' command
+lines of your program.
+
This command is used to display lists of things in the system. The
+patterns are all strings and, if present, restrict the contents of the
+lists. Only those items that contain one or more of the strings as
+substrings are displayed. For example,
+
+
+
+
+
+)what synonym
+
+
+
+
displays all command synonyms,
+
+
+
+
+
+)what synonym ver
+
+
+
+
displays all command synonyms containing the substring ``ver'',
+
+
+
+
+
+)what synonym ver pr
+
+
+
+
displays all command synonyms
+containing the substring ``ver'' or the substring
+``pr''.
+Output similar to the following will be displayed
+
+
+
+
+
+---------------- System Command Synonyms -----------------
+
+user-defined synonyms satisfying patterns:
+ ver pr
+
+ )apr ........................... )what things
+ )apropos ....................... )what things
+ )prompt ........................ )set message prompt
+ )version ....................... )lisp *yearweek*
+
+
+
+
+
Several other things can be listed with the )what command:
+
+
+
+
+
categories
+
displays a list of category constructors.
+what categories
+
+
commands
+
displays a list of system commands available at your
+user-level.
+what commands
+Your user-level
+user-level
+is set via the )set userlevel command.
+set userlevel
+To get a description of a particular command, such as ``)what'', issue
+)help what.
+
+
domains
+
displays a list of domain constructors.
+what domains
+
+
operations
+
displays a list of operations in the system library.
+what operations
+It is recommended that you qualify this command with one or
+more patterns, as there are thousands of operations available. For
+example, say you are looking for functions that involve computation of
+eigenvalues. To find their names, try )what operations eig.
+A rather large list of operations is loaded into the workspace when
+this command is first issued. This list will be deleted when you
+clear the workspace via )clear all or )clear completely.
+It will be re-created if it is needed again.
+
+
packages
+
displays a list of package constructors.
+what packages
+
+
synonym
+
lists system command synonyms.
+what synonym
+
+
things
+
displays all of the above types for items containing
+what things
+the pattern strings as substrings.
+The command synonym )apropos is equivalent to
+apropos
+)what things.
+
+
+
+
+
+
Also See:
+)displayugSysCmddisplay,
+)setugSysCmdset, and
+)showugSysCmdshow.
+
This command sets the Axiom working current directory.
+The current directory is used for looking for
+input files (for )read),
+Axiom library source files (for )compile),
+saved history environment files (for )history )restore),
+compiled Axiom library files (for )library), and
+files to edit (for )edit).
+It is also used for writing
+spool files (via )spool),
+writing history input files (via )history )write) and
+history environment files (via )history )save),and
+compiled Axiom library files (via )compile).
+read
+compile
+history )restore
+edit
+spool
+history )write
+history )save
+
+
+
+
If issued with no argument, this command sets the Axiom
+current directory to your home directory.
+If an argument is used, it must be a valid directory name.
+Except for the ``)'' at the beginning of the command,
+this has the same syntax as the operating system cd command.
+
+
+
+
Also See:
+)compileugSysCmdcompile,
+)editugSysCmdedit,
+)historyugSysCmdhistory,
+)libraryugSysCmdlibrary,
+)readugSysCmdread, and
+)spoolugSysCmdspool.
+
This command is used to close down interpreter client processes.
+Such processes are started by HyperDoc to run Axiom examples
+when you click on their text. When you have finished examining or modifying the
+example and you do not want the extra window around anymore, issue
+
+
+
+
+
+)close
+
+
+
+
to the Axiom prompt in the window.
+
+
+
+
If you try to close down the last remaining interpreter client
+process, Axiom will offer to close down the entire Axiom
+session and return you to the operating system by displaying something
+like
+
+
+
+
+
+ This is the last AXIOM session. Do you want to kill AXIOM?
+
+
+
+
Type ``y'' (followed by the Return key) if this is what you had in mind.
+Type ``n'' (followed by the Return key) to cancel the command.
+
+
+
+
You can use the )quietly option to force Axiom to
+close down the interpreter client process without closing down
+the entire Axiom session.
+
+
+
+
Also See:
+)quitugSysCmdquit and
+)pquitugSysCmdpquit.
+
This command is used to remove function and variable declarations, definitions
+and values from the workspace.
+To empty the entire workspace and reset the
+step counter to 1, issue
+
+
+
+
+
+)clear all
+
+
+
+
To remove everything in the workspace but not reset the step counter, issue
+
+
+
+
+
+)clear properties all
+
+
+
+
To remove everything about the object x, issue
+
+
+
+
+
+)clear properties x
+
+
+
+
To remove everything about the objects x, y and f, issue
+
+
+
+
+
+)clear properties x y f
+
+
+
+
+
The word properties may be abbreviated to the single letter
+``p''.
+
+
+
+
+
+)clear p all
+)clear p x
+)clear p x y f
+
+
+
+
All definitions of functions and values of variables may be removed by either
+
+
+
+
+
+)clear value all
+)clear v all
+
+
+
+
This retains whatever declarations the objects had. To remove definitions and
+values for the specific objects x, y and f, issue
+
+
+
+
+
+)clear value x y f
+)clear v x y f
+
+
+
+
To remove the declarations of everything while leaving the definitions and
+values, issue
+
+
+
+
+
+)clear mode all
+)clear m all
+
+
+
+
To remove declarations for the specific objects x, y and f, issue
+
+
+
+
+
+)clear mode x y f
+)clear m x y f
+
+
+
+
The )display names and )display properties commands may be used
+to see what is currently in the workspace.
+
+
+
+
The command
+
+
+
+
+
+)clear completely
+
+
+
+
does everything that )clear all does, and also clears the internal
+system function and constructor caches.
+
+
+
+
Also See:
+)displayugSysCmddisplay,
+)historyugSysCmdhistory, and
+)undougSysCmdundo.
+
You use this command to invoke the new Axiom library compiler or
+the old Axiom system compiler.
+The )compile system command is actually a combination of
+Axiom processing and a call to the Aldor compiler.
+It is performing double-duty, acting as a front-end to
+both the Aldor compiler and the old Axiom system
+compiler.
+(The old Axiom system compiler was written in Lisp and was
+an integral part of the Axiom environment.
+The Aldor compiler is written in C and executed by the operating system
+when called from within Axiom.)
+
+
+
+
The command compiles files with file extensions .as, .ao
+and .al with the
+Aldor compiler and files with file extension .spad with the
+old Axiom system compiler.
+It also can compile files with file extension .lsp. These
+are assumed to be Lisp files genererated by the Aldor
+compiler.
+If you omit the file extension, the command looks to see if you
+have specified the )new or )old option.
+If you have given one of these options, the corresponding compiler
+is used.
+Otherwise, the command first looks in the standard system
+directories for files with extension .as, .ao and .al and then files with extension .spad.
+The first file found has the appropriate compiler invoked on it.
+If the command cannot find a matching file, an error message is
+displayed and the command terminates.
+
+
+
+
The )translate option is used to invoke a special version
+of the old system compiler that will translate a .spad file
+to a .as file. That is, the .spad file will be parsed and
+analyzed and a file using the new syntax will be created. By default,
+the .as file is created in the same directory as the
+.spad file. If that directory is not writable, the current
+directory is used. If the current directory is not writable, an
+error message is given and the command terminates.
+Note that )translate implies the )old option so the
+file extension can safely be omitted. If )translate is
+given, all other options are ignored.
+Please be aware that the translation is not necessarily one
+hundred percent complete or correct.
+You should attempt to compile the output with the Aldor compiler
+and make any necessary corrections.
+
+
+
+
We now describe the options for the new Aldor compiler.
+
+
+
+
The first thing )compile does is look for a source code
+filename among its arguments.
+Thus
+
all invoke )compiler on the file /u/jones/as/mycode.as if the current Axiom working
+directory is /u/jones/as. (Recall that you can set the
+working directory via the )cd command. If you don't set it
+explicitly, it is the directory from which you started
+Axiom.)
+
+
+
+
This is frequently all you need to compile your file.
+This simple command:
+
+
+
+
+
+
+ Invokes the Aldor compiler and produces Lisp output.
+
+
Calls the Lisp compiler if the Aldor compilation was
+successful.
+
+
Uses the )library command to tell Axiom about
+the contents of your compiled file and arrange to have those
+contents loaded on demand.
+
+
+
+
+
+
Should you not want the )library command automatically
+invoked, call )compile with the )nolibrary option.
+For example,
+
+
+
+
+
+)compile mycode.as )nolibrary
+
+
+
+
+
The general description of Aldor command line arguments is in
+the Aldor documentation.
+The default options used by the )compile command can be
+viewed and set using the )set compiler args Axiom
+system command.
+The current defaults are
+
-Flsp: generate a .lsp (Lisp)
+file,
+Lisp:code generation
+
+
-laxiom: use the axiom library libaxiom.al,
+
+
-Mno-AXL_W_WillObsolete: do not display messages
+about older generated files becoming obsolete, and
+
+
-DAxiom: define the global assertion Axiom so that the
+Aldor libraries for generating stand-alone code
+are not accidentally used with Axiom.
+
+
+
+
+
+
To supplement these default arguments, use the )moreargs option on
+)compile.
+For example,
+
+
+
+
+
+)compile mycode.as )moreargs "-v"
+
+
+
+
uses the default arguments and appends the -v (verbose)
+argument flag.
+The additional argument specification must be enclosed in
+double quotes.
+
+
+
+
To completely replace these default arguments for a particular
+use of )compile, use the )onlyargs option.
+For example,
+
+
+
+
+
+)compile mycode.as )onlyargs "-v -O"
+
+
+
+
only uses the -v (verbose) and -O (optimize)
+arguments.
+The argument specification must be enclosed in double quotes.
+In this example, Lisp code is not produced and so the compilation
+output will not be available to Axiom.
+
+
+
+
To completely replace the default arguments for all calls to )compile within your Axiom session, use )set compiler args.
+For example, to use the above arguments for all compilations, issue
+
+
+
+
+
+)set compiler args "-v -O"
+
+
+
+
Make sure you include the necessary -l and -Y
+arguments along with those needed for Lisp file creation.
+As above, the argument specification must be enclosed in double
+quotes.
+
+
+
+
By default, the )library system command exposes all
+domains and categories it processes.
+This means that the Axiom intepreter will consider those
+domains and categories when it is trying to resolve a reference
+to a function.
+Sometimes domains and categories should not be exposed.
+For example, a domain may just be used privately by another
+domain and may not be meant for top-level use.
+The )library command should still be used, though, so that
+the code will be loaded on demand.
+In this case, you should use the )nolibrary option on )compile and the )noexpose option in the )library
+command. For example,
+
Once you have established your own collection of compiled code,
+you may find it handy to use the )dir option on the
+)library command.
+This causes )library to process all compiled code in the
+specified directory. For example,
+
+
+
+
+
+)library )dir /u/jones/as/quantum
+
+
+
+
You must give an explicit directory after )dir, even if you
+want all compiled code in the current working directory
+processed, e.g.
+
+
+
+
+
+)library )dir .
+
+
+
+
+
The )compile command works with several file extensions. We saw
+above what happens when it is invoked on a file with extension .as. A .ao file is a portable binary compiled version of a
+.as file, and )compile simply passes the .ao file
+onto Aldor. The generated Lisp file is compiled and )library
+is automatically called, just as if you had specified a .as file.
+
+
+
+
A .al file is an archive file containing .ao files. The
+archive is created (on Unix systems) with the ar program. When
+)compile is given a .al file, it creates a directory whose
+name is based on that of the archive. For example, if you issue
+
+
+
+
+
+)compile mylib.al
+
+
+
+
the directory mylib.axldir is created. All
+members of the archive are unarchived into the
+directory and )compile is called on each .ao file found. It
+is your responsibility to remove the directory and its contents, if you
+choose to do so.
+
+
+
+
A .lsp file is a Lisp source file, presumably, in our context,
+generated by Aldor when called with the -Flsp option. When
+)compile is used with a .lsp file, the Lisp file is
+compiled and )library is called. You must also have present a
+.asy generated from the same source file.
+
+
+
+
The following are descriptions of options for the old system compiler.
+
+
+
+
You can compile category, domain, and package constructors
+contained in files with file extension .spad.
+You can compile individual constructors or every constructor
+in a file.
+
+
+
+
The full filename is remembered between invocations of this command and
+)edit commands.
+The sequence of commands
+
+
+
+
+
+)compile matrix.spad
+)edit
+)compile
+
+
+
+
will call the compiler, edit, and then call the compiler again
+on the file matrix.spad.
+If you do not specify a directory, the working current
+directory (see
+ugSysCmdcd )
+is searched for the file.
+If the file is not found, the standard system directories are searched.
+
+
+
+
If you do not give any options, all constructors within a file are
+compiled.
+Each constructor should have an )abbreviation command in
+the file in which it is defined.
+We suggest that you place the )abbreviation commands at the
+top of the file in the order in which the constructors are
+defined.
+The list of commands serves as a table of contents for the file.
+abbreviation
+
+
+
+
The )library option causes directories containing the
+compiled code for each constructor
+to be created in the working current directory.
+The name of such a directory consists of the constructor
+abbreviation and the .NRLIB file extension.
+For example, the directory containing the compiled code for
+the MATRIX constructor is called MATRIX.NRLIB.
+The )nolibrary option says that such files should not
+be created.
+The default is )library.
+Note that the semantics of )library and )nolibrary
+for the new Aldor compiler and for the old system compiler are
+completely different.
+
+
+
+
The )vartrace option causes the compiler to generate
+extra code for the constructor to support conditional tracing of
+variable assignments. (see
+ugSysCmdtrace ). Without
+this option, this code is suppressed and one cannot use
+the )vars option for the trace command.
+
+
+
+
The )constructor option is used to
+specify a particular constructor to compile.
+All other constructors in the file are ignored.
+The constructor name or abbreviation follows )constructor.
+Thus either
+
compiles the RectangularMatrix constructor
+defined in matrix.spad.
+
+
+
+
The )break and )nobreak options determine what
+the old system compiler does when it encounters an error.
+)break is the default and it indicates that processing
+should stop at the first error.
+The value of the )set break variable then controls what happens.
+
+
+
+
+
+
+
+
Also See:
+)abbreviationugSysCmdabbreviation,
+)editugSysCmdedit, and
+)libraryugSysCmdlibrary.
+
This command is used to display the contents of the workspace and
+signatures of functions with a given name.A
+signature gives the argument and return types of a
+function.
+
+
+
+
The command
+
+
+
+
+
+)display names
+
+
+
+
lists the names of all user-defined objects in the workspace. This is useful
+if you do not wish to see everything about the objects and need only be
+reminded of their names.
+
+
+
+
The commands
+
+
+
+
+
+)display all
+)display properties
+)display properties all
+
+
+
+
all do the same thing: show the values and types and declared modes of all
+variables in the workspace. If you have defined functions, their signatures
+and definitions will also be displayed.
+
+
+
+
To show all information about a particular variable or user functions,
+for example, something named d, issue
+
+
+
+
+
+)display properties d
+
+
+
+
To just show the value (and the type) of d, issue
+
+
+
+
+
+)display value d
+
+
+
+
To just show the declared mode of d, issue
+
+
+
+
+
+)display mode d
+
+
+
+
+
All modemaps for a given operation may be
+displayed by using )display operations.
+A modemap is a collection of information about a particular
+reference
+to an operation. This includes the types of the arguments and the return
+value, the location of the implementation and any conditions on the types.
+The modemap may contain patterns. The following displays the modemaps for the
+operation complexcomplexComplexCategory:
+
+
+
+
+
+)d op complex
+
+
+
+
+
Also See:
+)clearugSysCmdclear,
+)historyugSysCmdhistory,
+)setugSysCmdset,
+)showugSysCmdshow, and
+)whatugSysCmdwhat.
+
This command is used to edit files.
+It works in conjunction with the )read
+and )compile commands to remember the name
+of the file on which you are working.
+By specifying the name fully, you can edit any file you wish.
+Thus
+
+
+
+
+
+)edit /u/julius/matrix.input
+
+
+
+
will place you in an editor looking at the file
+/u/julius/matrix.input.
+editing files
+By default, the editor is vi,
+vi
+but if you have an EDITOR shell environment variable defined, that editor
+will be used.
+When Axiom is running under the X Window System,
+it will try to open a separate xterm running your editor if
+it thinks one is necessary.
+Korn shell
+For example, under the Korn shell, if you issue
+
+
+
+
+
+export EDITOR=emacs
+
+
+
+
then the emacs
+emacs
+editor will be used by )edit.
+
+
+
+
If you do not specify a file name, the last file you edited,
+read or compiled will be used.
+If there is no ``last file'' you will be placed in the editor editing
+an empty unnamed file.
+
+
+
+
It is possible to use the )system command to edit a file directly.
+For example,
+
+
+
+
+
+)system emacs /etc/rc.tcpip
+
+
+
+
calls emacs to edit the file.
+emacs
+
+
+
+
Also See:
+)systemugSysCmdsystem,
+)compileugSysCmdcompile, and
+)readugSysCmdread.
+
This is a listing of all categories in the Axiom library at the
+time this book was produced.
+Use the Browse facility (described in Chapter
+ugBrowse )
+to get more information about these constructors.
+
+
+
+
This sample entry will help you read the following table:
+
This is a listing of all domains in the Axiom library at the
+time this book was produced.
+Use the Browse facility (described in Chapter
+ugBrowse )
+to get more information about these constructors.
+
+
+
+
This sample entry will help you read the following table:
+
#<= alphabetic
+ alphanumeric any? bag brace cardinality charClass coerce complement construct convert copy count dictionary difference
+ digit empty empty? eq? every? extract! find hexDigit index insert! inspect intersect less? lookup lowerCase map map!
+ max member? members min more? parts random reduce remove remove! removeDuplicates select select! size size? subset?
+ symmetricDifference union universe upperCase
+
+
+
+
+
+
Abbreviation:
CHAR
+
Full name:
Character
+
Belongs to:
OrderedFinite
+
Operations:
<= alphabetic? alphanumeric? char coerce digit? escape hexDigit?
+ index lookup lowerCase lowerCase? max min ord quote random size space upperCase upperCase?
= appendPoint coerce component graphImage key makeGraphImage point
+ pointLists putColorInfo ranges units
+
+
+
+
+
+
Abbreviation:
HASHTBL
+
Full name:
HashTable
+
Belongs to:
TableAggregate
+
Operations:
#= any? bag coerce construct copy count dictionary elt empty
+ empty? entries entry? eq? every? extract! fill! find first index? indices insert! inspect key? keys less? map map!
+ maxIndex member? members minIndex more? parts qelt qsetelt! reduce remove remove! removeDuplicates search select
+ select! setelt size? swap! table
+
+
+
+
+
+
Abbreviation:
HEAP
+
Full name:
Heap
+
Belongs to:
PriorityQueueAggregate
+
Operations:
#= any? bag coerce copy count empty empty? eq? every?
+ extract! heap insert! inspect less? map map! max member? members merge merge! more? parts size?
+
+
+
+
+
+
Abbreviation:
HEXADEC
+
Full name:
HexadecimalExpansion
+
Belongs to:
QuotientFieldCategory
+
Operations:
0 1 ***+-/<
+ = D abs associates? ceiling characteristic coerce convert denom denominator differentiate divide euclideanSize
+ expressIdealMember exquo extendedEuclidean factor floor fractionPart gcd hex init inv lcm map max min multiEuclidean
+ negative? nextItem numer numerator one? patternMatch positive? prime? principalIdeal quo random recip reducedSystem rem
+ retract retractIfCan sign sizeLess? squareFree squareFreePart unit? unitCanonical unitNormal wholePart zero?
+
+
+
+
+
+
Abbreviation:
ICARD
+
Full name:
IndexCard
+
Belongs to:
OrderedSet
+
Operations:
<= coerce display elt fullDisplay max min
+
+
+
+
+
+
Abbreviation:
IBITS
+
Full name:
IndexedBits
+
Belongs to:
BitAggregate
+
Operations:
#<= And Not Or \^{} and any? coerce concat
+ construct convert copy copyInto! count delete elt empty empty? entries entry? eq? every? fill! find first index?
+ indices insert less? map map! max maxIndex member? members merge min minIndex more? nand new nor not or parts position
+ qelt qsetelt! reduce remove removeDuplicates reverse reverse! select setelt size? sort sort! sorted? swap! xor
***+-/<<==>
+ >= D SEGMENT \^{}= and assign blankSeparate box brace bracket center coerce commaSeparate differentiate div
+ dot elt empty exquo hconcat height hspace infix infix? int label left matrix message messagePrint not or outputForm
+ over overbar paren pile postfix prefix presub presuper prime print prod quo quote rarrow rem right root rspace scripts
+ semicolonSeparate slash string sub subHeight sum super superHeight supersub vconcat vspace width zag
This is a listing of all packages in the Axiom library at the
+time this book was produced.
+Use the Browse facility (described in Chapter
+ugBrowse )
+to get more information about these constructors.
+
+
+
+
This sample entry will help you read the following table:
+
Only recently have I begun to realize that the problem is not merely
+one of technical mastery or the competent application of the rules
+...
+but that there is actually something else which is guiding these
+rules. It actually involves a different level of mastery. It's quite
+a different process to do it right; and every single act that you
+do can be done in that sense well or badly. But even assuming that
+you have got the technical part clear, the creation of this quality
+is a much more complicated process of the most utterly absorbing and
+fascinating dimensions. It is in fact a major creative or artistic
+act -- every single little thing you do -- ...
+
+
+
+
-- Christopher Alexander
+
+
+
+
(from Patterns of Software by Richard Gabriel)
+
+
+
+
+
+
+
+
+
+
+
+
In this chapter we look at the key notion of type and its
+generalization mode. We show that every Axiom object has a type
+that determines what you can do with the object. In particular, we
+explain how to use types to call specific functions from particular
+parts of the library and how types and modes can be used to create new
+objects from old. We also look at Record and Union types
+and the special type Any. Finally, we give you an idea of how
+Axiom manipulates types and modes internally to resolve ambiguities.
+
The Axiom world deals with many kinds of objects. There are
+mathematical objects such as numbers and polynomials, data structure
+objects such as lists and arrays, and graphics objects such as points
+and graphic images. Functions are objects too.
+
+
+
+
Axiom organizes objects using the notion of domain of computation, or
+simply domain. Each domain denotes a class of objects. The
+class of objects it denotes is usually given by the name of the
+domain: Integer for the integers, Float for floating-point
+numbers, and so on. The convention is that the first letter of a
+domain name is capitalized. Similarly, the domain
+Polynomial(Integer) denotes ``polynomials with integer
+coefficients.'' Also, Matrix(Float) denotes ``matrices with
+floating-point entries.''
+
+
+
+
Every basic Axiom object belongs to a unique domain. The integer
+belongs to the domain Integer and the polynomial belongs
+to the domain Polynomial(Integer). The domain of an object is
+also called its type. Thus we speak of ``the type
+Integer'' and ``the type Polynomial(Integer).''
+
+
+
+
After an Axiom computation, the type is displayed toward the
+right-hand side of the page (or screen).
+
+
+
+
+
+
+-3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Integer
+
+
+
+
+
Here we create a rational number but it looks like the last result.
+The type however tells you it is different. You cannot identify the
+type of an object by how Axiom displays the object.
+
+
+
+
+
+
+-3/1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
When a computation produces a result of a simpler type, Axiom leaves
+the type unsimplified. Thus no information is lost.
+
+
+
+
+
+
+x + 3 - x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
This seldom matters since Axiom retracts the answer to the
+simpler type if it is necessary.
+
+
+
+
+
+
+factorial(%)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
When you issue a positive number, the type PositiveInteger is
+printed. Surely, also has type Integer! The curious reader
+may now have two questions. First, is the type of an object not
+unique? Second, how is PositiveInteger related to
+Integer?
+
+
+
+
+
+
+3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Any domain can be refined to a subdomain by a membership
+predicate. A predicate is a function that, when applied to an
+object of the domain, returns either true or false. For
+example, the domain Integer can be refined to the subdomain
+PositiveInteger, the set of integers such that , by giving
+the Axiom predicate . Similarly, Axiom can define
+subdomains such as ``the subdomain of diagonal matrices,'' ``the
+subdomain of lists of length two,'' ``the subdomain of monic
+irreducible polynomials in ,'' and so on. Trivially, any domain is
+a subdomain of itself.
+
+
+
+
While an object belongs to a unique domain, it can belong to any
+number of subdomains. Any subdomain of the domain of an object can be
+used as the type of that object. The type of is indeed both
+Integer and PositiveInteger as well as any other subdomain
+of integer whose predicate is satisfied, such as ``the prime
+integers,'' ``the odd positive integers between 3 and 17,'' and so on.
+
+
+
+
+
+
+
2.1.1 Domain Constructors
+
+
+
+
+
+
In Axiom, domains are objects. You can create them, pass them to
+functions, and, as we'll see later, test them for certain properties.
+
+
+
+
In Axiom, you ask for a value of a function by applying its name
+to a set of arguments.
+
+
+
+
To ask for ``the factorial of '' you enter this expression to
+Axiom. This applies the function factorial to the value to
+compute the result.
+
+
+
+
+
+
+factorial(7)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Enter the type Polynomial (Integer) as an expression to Axiom.
+This looks much like a function call as well. It is! The result is
+appropriately stated to be of type Domain, which according to
+our usual convention, denotes the class of all domains.
+
+
+
+
+
+
+Polynomial(Integer)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
The most basic operation involving domains is that of building a new
+domain from a given one. To create the domain of ``polynomials over
+the integers,'' Axiom applies the function Polynomial to the
+domain Integer. A function like Polynomial is called a
+domain constructor or, constructor:domain more simply, a
+constructor. A domain constructor is a function that creates a
+domain. An argument to a domain constructor can be another domain or,
+in general, an arbitrary kind of object. Polynomial takes a
+single domain argument while SquareMatrix takes a positive
+integer as an argument to give its dimension and a domain argument to
+give the type of its components.
+
+
+
+
What kinds of domains can you use as the argument to Polynomial
+or SquareMatrix or List? Well, the first two are
+mathematical in nature. You want to be able to perform algebraic
+operations like ``+'' and ``*'' on polynomials and square
+matrices, and operations such as determinant on square
+matrices. So you want to allow polynomials of integers and
+polynomials of square matrices with complex number coefficients and,
+in general, anything that ``makes sense.'' At the same time, you don't
+want Axiom to be able to build nonsense domains such as ``polynomials
+of strings!''
+
+
+
+
In contrast to algebraic structures, data structures can hold any kind
+of object. Operations on lists such as insertinsertList,
+deletedeleteList, and concatconcatList just
+manipulate the list itself without changing or operating on its
+elements. Thus you can build List over almost any datatype,
+including itself.
+
Evidently from our last example, Axiom has some mechanism that tells
+what a constructor can use as an argument. This brings us to the
+notion of category. As domains are objects, they too have a
+domain. The domain of a domain is a category. A category is simply a
+type whose members are domains.
+
+
+
+
A common algebraic category is Ring, the class of all domains
+that are ``rings.'' A ring is an algebraic structure with constants
+ and and operations +, -,
+and *. These operations are assumed ``closed''
+with respect to the domain, meaning that they take two objects of the
+domain and produce a result object also in the domain. The operations
+are understood to satisfy certain ``axioms,'' certain mathematical
+principles providing the algebraic foundation for rings. For example,
+the additive inverse axiom for rings states:
+
+
+
+
+
+
+
Every element has an additive inverse such that .
+
+
+
+
+
+
+
The prototypical example of a domain that is a ring is
+the integers. Keep them in mind whenever we mention Ring.
+
+
+
+
Many algebraic domain constructors such as Complex,
+Polynomial, Fraction, take rings as arguments and return rings
+as values. You can use the infix operator ``'' to ask a domain
+if it belongs to a particular category.
+
+
+
+
All numerical types are rings. Domain constructor Polynomial
+builds ``the ring of polynomials over any other ring.''
+
+
+
+
+
+
+Polynomial(Integer) has Ring
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
Constructor List never produces a ring.
+
+
+
+
+
+
+List(Integer) has Ring
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
The constructor Matrix(R) builds ``the domain of all matrices
+over the ring .'' This domain is never a ring since the operations
+``+'', ``-'', and ``*'' on matrices of arbitrary
+shapes are undefined.
+
+
+
+
+
+
+Matrix(Integer) has Ring
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
Thus you can never build polynomials over matrices.
+
+
+
+
+
+
+Polynomial(Matrix(Integer))
+
+
+
+
+
+
+
+ Polynomial Matrix Integer is not a valid type.
+
+
+
+
+
Use SquareMatrix(n,R) instead. For any positive integer , it
+builds ``the ring of by matrices over .''
+
Another common category is Field, the class of all fields.
+field A field is a ring with additional operations. For
+example, a field has commutative multiplication and a closed operation
+/ for the division of two elements. Integer
+is not a field since, for example, does not have an integer
+result. The prototypical example of a field is the rational numbers,
+that is, the domain Fraction(Integer). In general, the
+constructor Fraction takes an IntegralDomain, which is a ring
+with additional properties, as an argument and returns a field.
+Actually, the argument domain must have some additional
+so as to belong to the category IntegralDomain
+Other domain constructors, such as Complex, build fields only if their
+argument domain is a field.
+
+
+
+
The complex integers (often called the ``Gaussian integers'') do not form
+a field.
+
+
+
+
+
+
+Complex(Integer) has Field
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
But fractions of complex integers do.
+
+
+
+
+
+
+Fraction(Complex(Integer)) has Field
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
The algebraically equivalent domain of complex rational numbers is a field
+since domain constructor Complex produces a field whenever its
+argument is a field.
+
+
+
+
+
+
+Complex(Fraction(Integer)) has Field
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
The most basic category is Type. Type It denotes the
+class of all domains and subdomains. Note carefully that Type
+does not denote the class of all types. The type of all categories is
+Category. The type of Type itself is undefined. Domain
+constructor List is able to build ``lists of elements from
+domain '' for arbitrary simply by requiring that belong to
+category Type.
+
+
+
+
Now, you may ask, what exactly is a category? category Like
+domains, categories can be defined in the Axiom language. A category
+is defined by three components:
+
+
+
+
+
+
+
+ a name (for example, Ring),
+used to refer to the class of domains that the category represents;
+
+
a set of operations, used to refer to the operations that
+the domains of this class support
+(for example, ``+'', ``-'', and ``*'' for rings); and
+
+
an optional list of other categories that this category extends.
+
+
+
+
+
+
This last component is a new idea. And it is key to the design of
+Axiom! Because categories can extend one another, they form
+hierarchies. Detailed charts showing the category hierarchies
+in Axiom are displayed in Appendix (TPDHERE). There you see
+that all categories are extensions of Type and that Field
+is an extension of Ring.
+
+
+
+
The operations supported by the domains of a category are called the
+ exports of that category because these are the operations made
+available for system-wide use. The exports of a domain of a given
+category are not only the ones explicitly mentioned by the category.
+Since a category extends other categories, the operations of these
+other categories---and all categories these other categories
+extend---are also exported by the domains.
+
+
+
+
For example, polynomial domains belong to PolynomialCategory.
+This category explicitly mentions some twenty-nine operations on
+polynomials, but it extends eleven other categories (including
+Ring). As a result, the current system has over one hundred
+operations on polynomials.
+
+
+
+
If a domain belongs to a category that extends, say, Ring, it is
+convenient to say that the domain exports Ring. The name of the
+category thus provides a convenient shorthand for the list of
+operations exported by the category. Rather than listing operations
+such as + and * of Ring
+each time they are needed, the definition of a type simply asserts
+that it exports category Ring.
+
+
+
+
The category name, however, is more than a shorthand. The name
+Ring, in fact, implies that the operations exported by rings are
+required to satisfy a set of ``axioms'' associated with the name
+Ring. This subtle but important feature distinguishes Axiom from
+other abstract datatype designs.
+
+
+
+
Why is it not correct to assume that some type is a ring if it exports
+all of the operations of Ring? Here is why. Some languages
+such as APLAPL denote the Boolean constants
+true and false by the integers and respectively, then use
+``+'' and ``*'' to denote the logical operators or and
+ and. But with these definitions Boolean is not a
+ring since the additive inverse axiom is violated. That is, there is
+no inverse element such that , or, in the usual terms:
+true or a = false. This alternative definition of Boolean
+can be easily and correctly implemented in Axiom, since Boolean
+simply does not assert that it is of category Ring. This
+prevents the system from building meaningless domains such as
+Polynomial(Boolean) and then wrongfully applying algorithms that
+presume that the ring axioms hold.
+
+
+
+
Enough on categories. To learn more about them, see Chapter
+ugCategories .
+We now return to our discussion of domains.
+
+
+
+
Domains export a set of operations to make them available for
+system-wide use. Integer, for example, exports the operations
++ and = given by the
+signatures +:
+(Integer,Integer)->Integer and =:
+(Integer,Integer)->Boolean, respectively. Each of these
+operations takes two Integer arguments. The
++ operation also returns an Integer but
+= returns a Boolean: true or false.
+The operations exported by a domain usually manipulate objects of the
+domain---but not always.
+
+
+
+
The operations of a domain may actually take as arguments, and return
+as values, objects from any domain. For example, Fraction
+(Integer) exports the operations /:
+(Integer,Integer)->Fraction(Integer) and
+characteristiccharacteristicFraction:
+->NonNegativeInteger.
+
+
+
+
Suppose all operations of a domain take as arguments and return as
+values, only objects from other domains. package This
+kind of domain constructor:package is what Axiom calls a
+package.
+
+
+
+
A package does not designate a class of objects at all. Rather, a
+package is just a collection of operations. Actually the bulk of the
+Axiom library of algorithms consists of packages. The facilities for
+factorization; integration; solution of linear, polynomial, and
+differential equations; computation of limits; and so on, are all
+defined in packages. Domains needed by algorithms can be passed to a
+package as arguments or used by name if they are not ``variable.''
+Packages are useful for defining operations that convert objects of
+one type to another, particularly when these types have different
+parameterizations. As an example, the package PolynomialFunction2(R,S)
+defines operations that convert polynomials
+over a domain to polynomials over . To convert an object from
+Polynomial(Integer) to Polynomial(Float), Axiom builds the
+package PolynomialFunctions2(Integer,Float) in order to create
+the required conversion function. (This happens ``behind the scenes''
+for you: see ugTypesConvert
+for details on how to convert objects.)
+
+
+
+
Axiom categories, domains and packages and all their contained
+functions are written in the Axiom programming language and have been
+compiled into machine code. This is what comprises the Axiom
+library. We will show you how to use these
+domains and their functions and how to write your own functions.
+
In this section we briefly describe an internal process by which
+resolve Axiom determines a type to which two objects of
+possibly different types can be converted. We do this to give you
+further insight into how Axiom takes your input, analyzes it, and
+produces a result.
+
+
+
+
What happens when you enter to Axiom? Let's look at what you
+get from the two terms of this expression.
+
+
+
+
This is a symbolic object whose type indicates the name.
+
+
+
+
+
+
+x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Variable x
+
+
+
+
+
This is a positive integer.
+
+
+
+
+
+
+1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
There are no operations in PositiveInteger that add positive
+integers to objects of type Variable(x) nor are there any in
+Variable(x). Before it can add the two parts, Axiom must come
+up with a common type to which both and can be converted. We
+say that Axiom must resolve the two types into a common type.
+In this example, the common type is Polynomial(Integer).
+
+
+
+
Once this is determined, both parts are converted into polynomials,
+and the addition operation from Polynomial(Integer) is used to
+get the answer.
+
+
+
+
+
+
+x + 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
Axiom can always resolve two types: if nothing resembling the original
+types can be found, then Any is be used. Any This is
+fine and useful in some cases.
+
+
+
+
+
+
+
+["string",3.14159]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Any
+
+
+
+
+
In other cases objects of type Any can't be used by the
+operations you specified.
+
+
+
+
+
+
+"string" + 3.14159
+
+
+
+
+
+
+
+There are 11 exposed and 5 unexposed library operations named +
+ having 2 argument(s) but none was determined to be applicable.
+ Use HyperDoc Browse, or issue
+ )display op +
+ to learn more about the available operations. Perhaps
+ package-calling the operation or using coercions on the
+ arguments will allow you to apply the operation.
+
+Cannot find a definition or applicable library operation named +
+ with argument type(s)
+ String
+ Float
+
+ Perhaps you should use "@" to indicate the required return type,
+ or "$" to specify which version of the function you need.
+
+
+
+
+
Although this example was contrived, your expressions may need to be
+qualified slightly to help Axiom resolve the types involved. You may
+need to declare a few variables, do some package calling, provide some
+target type information or do some explicit conversions.
+
+
+
+
We suggest that you just enter the expression you want evaluated and
+see what Axiom does. We think you will be impressed with its ability
+to ``do what I mean.'' If Axiom is still being obtuse, give it some
+hints. As you work with Axiom, you will learn where it needs a little
+help to analyze quickly and perform your computations.
+
In this section we discuss how Axiom makes some operations available
+to you while hiding others that are meant to be used by developers or
+only in rare cases. If you are a new user of Axiom, it is likely that
+everything you need is available by default and you may want to skip
+over this section on first reading.
+
+
+
+
Every constructor:exposed domain and package in the Axiom
+library constructor:hidden is exposed:constructor
+either exposed (meaning that you can use its operations without doing
+anything special) or it is hidden (meaning you have to either
+package call (see ugTypesPkgCall) the operations it contains or
+explicitly expose it to use the operations). The initial exposure
+status for a constructor is set in the file exposed.lsp (see the
+Installer's Noteexposed.lsp @ exposed.lsp for
+Axiom file:exposed.lsp @ exposed.lsp if you need to know
+the location of this file). Constructors are collected together in
+group:exposureexposure groups. exposure:group
+Categories are all in the exposure group ``categories'' and the bulk
+of the basic set of packages and domains that are exposed are in the
+exposure group ``basic.'' Here is an abbreviated sample of the file
+(without the Lisp parentheses):
+
+
+
+
+
+
+basic
+ AlgebraicNumber AN
+ AlgebraGivenByStructuralConstants ALGSC
+ Any ANY
+ AnyFunctions1 ANY1
+ BinaryExpansion BINARY
+ Boolean BOOLEAN
+ CardinalNumber CARD
+ CartesianTensor CARTEN
+ Character CHAR
+ CharacterClass CCLASS
+ CliffordAlgebra CLIF
+ Color COLOR
+ Complex COMPLEX
+ ContinuedFraction CONTFRAC
+ DecimalExpansion DECIMAL
+ ...
+
For each constructor in a group, the full name and the abbreviation is
+given. There are other groups in exposed.lsp but initially only
+the constructors in exposure groups ``basic'' ``categories''
+``naglink'' and ``anna'' are exposed.
+
+
+
+
As an interactive user of Axiom, you do not need to modify this file.
+Instead, use )set expose to expose, hide or query the exposure
+status of an individual constructor or exposure group. set expose
+The reason for having exposure groups is to be able to expose
+or hide multiple constructors with a single command. For example, you
+might group together into exposure group ``quantum'' a number of
+domains and packages useful for quantum mechanical computations.
+These probably should not be available to every user, but you want an
+easy way to make the whole collection visible to Axiom when it is
+looking for operations to apply.
+
+
+
+
If you wanted to hide all the basic constructors available by default,
+you would issue )set expose drop group basic.
+set expose drop group We do not recommend that you do this.
+If, however, you discover that you have hidden all the basic constructors,
+you should issue )set expose add group basic to restore your default
+environment. set expose add group
+
+
+
+
It is more likely that you would want to expose or hide individual
+constructors. In ugUserTriangle we use several operations from
+OutputForm, a domain usually hidden. To avoid package calling every
+operation from OutputForm, we expose the domain and let Axiom
+conclude that those operations should be used. Use )set expose
+add constructor and )set expose drop constructor to expose and
+hide a constructor, respectively. set expose drop constructor
+You should use the constructor name, not the abbreviation. The
+)set expose command guides you through these options.
+set expose add constructor
+
+
+
+
If you expose a previously hidden constructor, Axiom exhibits new
+behavior (that was your intention) though you might not expect the
+results that you get. OutputForm is, in fact, one of the worst
+offenders in this regard. OutputForm This domain is meant to
+be used by other domains for creating a structure that Axiom knows how
+to display. It has functions like + that
+form output representations rather than do mathematical calculations.
+Because of the order in which Axiom looks at constructors when it is
+deciding what operation to apply, OutputForm might be used
+instead of what you expect.
+
+
+
+
This is a polynomial.
+
+
+
+
+
+
+x + x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
Expose OutputForm.
+
+
+
+
+
+
+)set expose add constructor OutputForm
+
+
+
+
+
+
+
+ OutputForm is now explicitly exposed in frame G82322
+
+
+
+
+
This is what we get when OutputForm is automatically available.
+
+
+
+
+
+
+x + x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: OutputForm
+
+
+
+
+
Hide OutputForm so we don't run into problems with any later examples!
+
+
+
+
+
+
+)set expose drop constructor OutputForm
+
+
+
+
+
+
+
+ OutputForm is now explicitly hidden in frame G82322
+
+
+
+
+
Finally, exposure is done on a frame-by-frame basis. A frame
+(see ugSysCmdframe )
+frame:exposure and is one of possibly several logical Axiom
+workspaces within a physical one, each having its own environment (for
+example, variables and function definitions). If you have several
+Axiom workspace windows on your screen, they are all different frames,
+automatically created for you by HyperDoc. Frames can be manually
+created, made active and destroyed by the )frame system command.
+frame They do not share exposure information, so you need to
+use )set expose in each one to add or drop constructors from
+view.
+
To conclude this chapter, we introduce you to some system commands
+that you can use for getting more information about domains, packages,
+categories, and operations. The most powerful Axiom facility for
+getting information about constructors and operations is the Browse
+component of HyperDoc. This is discussed in Chapter
+ugBrowse .
+
+
+
+
Use the )what system command to see lists of system objects
+whose name contain a particular substring (uppercase or lowercase is
+not significant). what
+
+
+
+
Issue this to see a list of all operations with ``complex'' in
+their names. what operation
+
+
+
+
+
+
+)what operation complex
+
+
+
+
+
+
+
+
+Operations whose names satisfy the above pattern(s):
+
+complex complex?
+complexEigenvalues complexEigenvectors
+complexElementary complexExpand
+complexForm complexIntegrate
+complexLimit complexNormalize
+complexNumeric complexNumericIfCan
+complexRoots complexSolve
+complexZeros createLowComplexityNormalBasis
+createLowComplexityTable doubleComplex?
+drawComplex drawComplexVectorField
+fortranComplex fortranDoubleComplex
+pmComplexintegrate
+
+To get more information about an operation such as
+complexZeros, issue the command )display op complexZeros
+
+
+
+
+
If you want to see all domains with ``matrix'' in their names,
+issue this. what domain
+
This command shows all the operations that Any provides.
+Wherever $ appears, it means ``Any''. show
+
+
+
+
+
+
+)show Any
+
+
+
+
+
+
+
+ Any is a domain constructor
+ Abbreviation for Any is ANY
+ This constructor is exposed in this frame.
+ Issue )edit /usr/local/axiom/mnt/algebra/any.spad
+ to see algebra source code for ANY
+
+--------------------- Operations ----------------------
+ ?=? : (%,%) -> Boolean
+ any : (SExpression,None) -> %
+ coerce : % -> OutputForm
+ dom : % -> SExpression
+ domainOf : % -> OutputForm
+ hash : % -> SingleInteger
+ latex : % -> String
+ obj : % -> None
+ objectOf : % -> OutputForm
+ ?~=? : (%,%) -> Boolean
+ showTypeInOutput : Boolean -> String
+
+
+
+
+
+
This displays all operations with the name complex.
+display operation
+
+
+
+
+
+
+)display operation complex
+
+
+
+
+
+
+
+There is one exposed function called complex :
+ [1] (D1,D1) -> D from D if D has COMPCAT D1 and D1 has COMRING
+
+
+
+
+
Let's analyze this output.
+
+
+
+
First we find out what some of the abbreviations mean.
+
+
+
+
+
+
+)abbreviation query COMPCAT
+
+
+
+
+
+
+
+ COMPCAT abbreviates category ComplexCategory
+
+
+
+
+
+
+
+
+)abbreviation query COMRING
+
+
+
+
+
+
+
+ COMRING abbreviates category CommutativeRing
+
+
+
+
+
So if D1 is a commutative ring (such as the integers or floats) and
+D belongs to ComplexCategory D1, then there is an operation
+called complex that takes two elements of D1 and creates an
+element of D. The primary example of a constructor implementing
+domains belonging to ComplexCategory is Complex. See
+Complex for more information on that and see
+ugUserDeclare
+for more information on function types.
+
We have already seen in the last section ugTypesBasic several examples of types. Most of these
+examples had either no arguments (for example, Integer) or one
+argument (for example, Polynomial (Integer)). In this section
+we give details about writing arbitrary types. We then define modes
+and discuss how to write them. We conclude the section with a
+discussion on constructor abbreviations.
+
+
+
+
When might you need to write a type or mode? You need to do so when
+you declare variables.
+
+
+
+
+
+
+a : PositiveInteger
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
You need to do so when you declare functions
+(See Section ugTypesDeclare ),
+
+
+
+
+
+
+f : Integer -> String
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
You need to do so when you convert an object from one type to another
+(See Section ugTypesConvert ).
+
+
+
+
+
+
+factor(2 :: Complex(Integer))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Complex Integer
+
+
+
+
+
+
+
+
+(2 = 3) $Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
You need to do so when you give computation target type information
+(See Section ugTypesPkgCall ).
+
+
+
+
+
+
+(2 = 3)@Boolean
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
2.2.1 Types with No Arguments
+
+
+
+
+
+
A constructor with no arguments can be written either
+type:using parentheses with or without
+parentheses:using with types trailing opening and closing
+parentheses ``()''.
+
+
+
+
+
+
+
+
+
Boolean() is the same as Boolean
+Integer() is the same as Integer
+String() is the same as String
+Void() is the same as Void
+
+
+
+
+
+
+
+
+
It is customary to omit the parentheses.
+
+
+
+
+
+
+
+
+
+
+
+
2.2.2 Types with One Argument
+
+
+
+
+
+
A constructor with one argument can frequently be
+type:using parentheses written with no
+parentheses:using with types parentheses. Types nest from
+right to left so that Complex Fraction Polynomial Integer
+is the same as Complex (Fraction (Polynomial (Integer))).
+You need to use parentheses to force the application of a constructor
+to the correct argument, but you need not use any more than is necessary
+to remove ambiguities.
+
+
+
+
Here are some guidelines for using parentheses (they are possibly slightly
+more restrictive than they need to be).
+
+
+
+
If the argument is an expression like
+then you must enclose the argument in parentheses.
+
+
+
+
+
+
+e : PrimeField(2 + 3)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
If the type is to be used with package calling
+then you must enclose the argument in parentheses.
+
+
+
+
+
+
+content(2) $Polynomial(Integer)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Integer
+
+
+
+
+
Alternatively, you can write the type without parentheses
+then enclose the whole type expression with parentheses.
+
A mode is a type that possibly is a question mark (?) or
+contains one in an argument position. For example, the following are
+all modes.
+
+
+
+
?
+
+
+
+
Polynomial ?
+
+
+
+
Matrix Polynomial ?
+
+
+
+
SquareMatrix(3,?)
+
+
+
+
Integer
+
+
+
+
OneDimensionalArray(Float)
+
+
+
+
As is evident from these examples, a mode is a type with a part that
+is not specified (indicated by a question mark). Only one ``?'' is
+allowed per mode and it must appear in the most deeply nested argument
+that is a type. Thus ?(Integer), Matrix(? (Polynomial)),
+SquareMatrix(?, Integer) (it requires a numeric argument)
+and SquareMatrix(?, ?) are all
+invalid. The question mark must take the place of a domain, not data.
+This rules out, for example, the two SquareMatrix expressions.
+
+
+
+
Modes can be used for declarations (See Section ugTypesDeclare
+) and conversions (Section
+ugTypesConvert ). However, you
+cannot use a mode for package calling or giving target type information.
+
+
+
+
+
+
+
+
+
+
+
+
2.2.5 Abbreviations
+
+
+
+
+
+
Every constructor has an abbreviation that
+abbreviation:constructor you can freely
+constructor:abbreviation substitute for the constructor name.
+In some cases, the abbreviation is nothing more than the capitalized
+version of the constructor name.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Aside from allowing types to be written more concisely, abbreviations
+are used by Axiom to name various system files for constructors (such
+as library filenames, test input files and example files). Here are
+some common abbreviations.
+
+
+
+
+
+
+
+
+
+
COMPLEX abbreviates Complex
+DFLOAT abbreviates DoubleFloat
+
EXPR abbreviates Expression
+FLOAT abbreviates Float
+
FRAC abbreviates Fraction
+INT abbreviates Integer
+
MATRIX abbreviates Matrix
+NNI abbreviates NonNegativeInteger
+
PI abbreviates PositiveInteger
+POLY abbreviates Polynomial
+
STRING abbreviates String
+UP abbreviates UnivariatePolynomial
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
You can combine both full constructor names and abbreviations in a
+type expression. Here are some types using abbreviations.
+
+
+
+
+
+
+
+
+
+
POLY INT
is the same as
Polynomial(INT)
+
POLY(Integer)
is the same as
Polynomial(Integer)
+
POLY(Integer)
is the same as
Polynomial(INT)
+
FRAC(COMPLEX(INT))
is the same as
Fraction Complex Integer
+
FRAC(COMPLEX(INT))
is the same as
FRAC(Complex Integer)
+
+
+
+
+
+
+
+
+
+
There are several ways of finding the names of constructors and their
+abbreviations. For a specific constructor, use )abbreviation
+query. abbreviation You can also use the )what system
+command to see the names and abbreviations of constructors.
+what For more information about )what, see
+ugSysCmdwhat .
+
+
+
+
)abbreviation query can be abbreviated (no pun intended) to
+)abb q.
+
+
+
+
+
+
+)abb q Integer
+
+
+
+
+
+
+
+ INT abbreviates domain Integer
+
+
+
+
+
The )abbreviation query command lists the constructor name if
+you give the abbreviation. Issue )abb q if you want to see the
+names and abbreviations of all Axiom constructors.
+
A declaration is an expression used to restrict the type of
+values that can be assigned to variables. A colon ``:'' is always
+used after a variable or list of variables to be declared.
+
+
+
+
+
+
+
+
+
+
+
+
+
For a single variable, the syntax for declaration is
+
+
+
+
+
+
+
+
variableName typeOrMode
+
+
+
+
+
+
+
+
+
For multiple variables, the syntax is
+
+
+
+
+
+
+
+
(, ,
+... ): typeOrMode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
You can always combine a declaration with an assignment. When you do,
+it is equivalent to first giving a declaration statement, then giving
+an assignment. For more information on assignment, see
+Section ugIntroAssign and
+Section ugLangAssign .
+To see how to declare your own functions,
+see ugUserDeclare .
+
+
+
+
This declares one variable to have a type.
+
+
+
+
+
+
+a : Integer
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
This declares several variables to have a type.
+
+
+
+
+
+
+(b,c) : Integer
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+, and can only hold integer values.
+
+
+
+
+
+
+
+a := 45
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Integer
+
+
+
+
+
If a value cannot be converted to a declared type,
+an error message is displayed.
+
+
+
+
+
+
+b := 4/5
+
+
+
+
+
+
+
+
+ Cannot convert right-hand side of assignment
+ 4
+ -
+ 5
+
+ to an object of the type Integer of the left-hand side.
+
+
+
+
+
This declares a variable with a mode.
+
+
+
+
+
+
+n : Complex ?
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
This declares several variables with a mode.
+
+
+
+
+
+
+(p,q,r) : Matrix Polynomial ?
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
This complex object has integer real and imaginary parts.
+
+
+
+
+
+
+n := -36 + 9 * %i
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Integer
+
+
+
+
+
This complex object has fractional symbolic real and imaginary parts.
+
+
+
+
+
+
+n := complex(4/(x + y),y/x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Fraction Polynomial Integer
+
+
+
+
+
This matrix has entries that are polynomials with integer
+coefficients.
+
+
+
+
+
+
+p := [ [1,2],[3,4],[5,6] ]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Polynomial Integer
+
+
+
+
+
This matrix has a single entry that is a polynomial with
+rational number coefficients.
+
+
+
+
+
+
+q := [ [x - 2/3] ]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Polynomial Fraction Integer
+
+
+
+
+
This matrix has entries that are polynomials with complex integer
+coefficients.
+
+
+
+
+
+
+
+r := [ [1-%i*x,7*y+4*%i] ]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Polynomial Complex Integer
+
+
+
+
+
Note the difference between this and the next example.
+This is a complex object with polynomial real and imaginary parts.
+
+
+
+
+
+
+
+f : COMPLEX POLY ? := (x + y*%i)**2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Polynomial Integer
+
+
+
+
+
This is a polynomial with complex integer coefficients. The objects
+are convertible from one to the other. See ugTypesConvert for more information.
+
A Record is an object composed of one or more other objects,
+Record each of which is referenced selector:record
+with record:selector a selector. Components can all
+belong to the same type or each can have a different type.
+
+
+
+
+
+
+
+
+
+
+
+
+
The syntax for writing a Record type is
+
+
+
+
+
+
+Record(:,
+:, ...,
+:)
+
+
+
+
+
+
You must be
+careful if a selector has the same name as a variable in the
+workspace. If this occurs, precede the selector name by a single
+quote quote.
+
+
+
+
+
+
+
+
+
+
Record components are implicitly ordered. All the components of a
+record can be set at once by assigning the record a bracketed
+tuple of values of the proper length. For example:
+
Selectors are evaluated. Thus you can use variables that evaluate to
+selectors instead of the selectors themselves.
+
+
+
+
+
+
+s := 'quotient
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Variable quotient
+
+
+
+
+
Be careful! A selector could have the same name as a variable in the
+workspace. If this occurs, precede the selector name by a single
+quote, as in selector:quoting u.'quotient.
+
+
+
+
+
+
+divide(5,2).s
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Here we declare that the value of has two components: a string,
+to be accessed via name, and an integer, to be accessed via
+birthdayMonth.
+
Type Union is used for objects that can be of any of a specific
+finite set of types. Union Two versions of unions are
+available, one with selectors (like records) and one without.
+union
+
+
+
+
+
+
+
2.5.1 Unions Without Selectors
+
+
+
+
+
+
The declaration states that
+can have values that are integers, strings or ``big'' floats. If, for
+example, the Union object is an integer, the object is said to
+belong to the Integerbranch of the Union. Note
+that we are being a bit careless with the language here. Technically,
+the type of is always Union(Integer, String, Float). If it
+belongs to the Integer branch, may be converted to an object
+of type Integer.
+
+
+
+
+
+
+
+
+
+
+
+
+
The syntax for writing a Union type without selectors is
+
+
+
+
+
+
+
+
Union(, ,
+..., )
+
+
+
+
+
+
+
+
The types in a union without selectors must be distinct.
+
+
+
+
+
+
+
+
+
+
It is possible to create unions like Union(Integer, PositiveInteger)
+but they are difficult to work with because of the overlap in the branch
+types. See below for the rules Axiom uses for converting something into
+a union object.
+
+
+
+
The case infix case operator returns a Boolean and can
+be used to determine the branch in which an object lies.
+
+
+
+
This function displays a message stating in which branch of the
+Union the object (defined as above) lies.
+
+
+
+
+
+
+sayBranch(x : Union(Integer,String,Float)) : Void ==
+ output
+ x case Integer => "Integer branch"
+ x case String => "String branch"
+ "Float branch"
+
+
+
+
+
This tries sayBranch with an integer.
+
+
+
+
+
+
+sayBranch 1
+
+
+
+
+
+
+
+Compiling function sayBranch with type Union(Integer,String,Float)
+ -> Void
+ Integer branch
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
This tries sayBranch with a string.
+
+
+
+
+
+
+sayBranch "hello"
+
+
+
+
+
+
+
+ String branch
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
This tries sayBranch with a floating-point number.
+
+
+
+
+
+
+sayBranch 2.718281828
+
+
+
+
+
+
+
+ Float branch
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
There are two things of interest about this particular
+example to which we would like to draw your attention.
+
+
+
+
+
+
+ Axiom normally converts a result to the target value
+before passing it to the function.
+If we left the declaration information out of this function definition
+then the sayBranch call would have been attempted with an
+Integer rather than a Union, and an error would have
+resulted.
+
+
The types in a Union are searched in the order given.
+So if the type were given as
+
+
+sayBranch(x: Union(String,Integer,Float,Any)): Void
+
+then the result would have been ``String branch'' because there
+is a conversion from Integer to String.
+
+
+
+
+
+
Sometimes Union types can have extremely long names. Axiom
+therefore abbreviates the names of unions by printing the type of the
+branch first within the Union and then eliding the remaining
+types with an ellipsis (...).
+
+
+
+
Here the Integer branch is displayed first. Use ``::'' to
+create a Union object from an object.
+
+
+
+
+
+
+78 :: Union(Integer,String)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(Integer,...)
+
+
+
+
+
Here the String branch is displayed first.
+
+
+
+
+
+
+s := "string" :: Union(Integer,String)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(String,...)
+
+
+
+
+
Use typeOf to see the full and actual Union type. typeOf
+
+
+
+
+
+
+typeOf s
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
A common operation that returns a union is exquoexquoInteger
+which returns the ``exact quotient'' if the quotient is exact,
+
+
+
+
+
+
+three := exquo(6,2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(Integer,...)
+
+
+
+
+
and "failed" if the quotient is not exact.
+
+
+
+
+
+
+exquo(5,2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union("failed",...)
+
+
+
+
+
A union with a "failed" is frequently used to indicate the failure
+or lack of applicability of an object. As another example, assign an
+integer a variable declared to be a rational number.
+
+
+
+
+
+
+r: FRAC INT := 3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
The operation retractIfCanretractIfCanFraction tries to retract
+the fraction to the underlying domain Integer. It produces a
+union object. Here it succeeds.
+
+
+
+
+
+
+retractIfCan(r)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(Integer,...)
+
+
+
+
+
Assign it a rational number.
+
+
+
+
+
+
+r := 3/2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
Here the retraction fails.
+
+
+
+
+
+
+retractIfCan(r)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union("failed",...)
+
+
+
+
+
+
+
+
+
+
+
+
+
2.5.2 Unions With Selectors
+
+
+
+
+
+
Like records (ugTypesRecords ),
+you can write Union types selector:union with selectors.
+union:selector
+
+
+
+
+
+
+
+
+
+
+
+
+
The syntax for writing a Union type with selectors is
+
+
+
+
+
+
+
+
Union(:,
+:, ...,
+:)
+
+
+
+
+
+
+
+
You must be careful if a selector has the same name as a variable in
+the workspace. If this occurs, precede the selector name by a single
+quote quote. selector:quoting It is an error to use a
+selector that does not correspond to the branch of the Union in
+which the element actually lies.
+
+
+
+
+
+
+
+
+
+
Be sure to understand the difference between records and unions with
+selectors. union:difference from record Records can have more
+than one component and the selectors are used to refer to the
+components. record:difference from union Unions always have
+one component but the type of that one component can vary. An object
+of type Record(a: Integer, b: Float, c: String) contains an
+integer and a float and a string. An object of type
+Union(a: Integer, b: Float, c: String) contains an integer
+or a float or a string.
+
+
+
+
Here is a version of the sayBranch function (cf.
+ugTypesUnionsWOSel ) that
+works with a union with selectors. It displays a message stating in
+which branch of the Union the object lies.
+
+
+
+
+
+
+sayBranch(x:Union(i:Integer,s:String,f:Float)):Void==
+ output
+ x case i => "Integer branch"
+ x case s => "String branch"
+ "Float branch"
+
+
+
+
+
Note that case uses the selector name as its right-hand argument.
+case If you accidentally use the branch type on the right-hand
+side of case, false will be returned.
+
+
+
+
Declare variable to have a union type with selectors.
+
+
+
+
+
+
+u : Union(i : Integer, s : String)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Give an initial value to .
+
+
+
+
+
+
+u := "good morning"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(s: String,...)
+
+
+
+
+
Use to determine in which branch of a Union an object lies.
+
+
+
+
+
+
+u case i
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+u case s
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
To access the element in a particular branch, use the selector.
+
With the exception of objects of type Record, all Axiom data
+structures are homogenous, that is, they hold objects all of the same
+type. Any If you need to get around this, you can use type
+Any. Using Any, for example, you can create lists whose
+elements are integers, rational numbers, strings, and even other
+lists.
+
+
+
+
Declare to have type Any.
+
+
+
+
+
+
+u: Any
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Assign a list of mixed type values to
+
+
+
+
+
+
+u := [1, 7.2, 3/2, x**2, "wally"]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Any
+
+
+
+
+
When we ask for the elements, Axiom displays these types.
+
+
+
+
+
+
+u.1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Actually, these objects belong to Any but Axiom
+automatically converts them to their natural types for you.
+
+
+
+
+
+
+u.3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
Since type Any can be anything, it can only belong to type
+Type. Therefore it cannot be used in algebraic domains.
+
+
+
+
+
+
+v : Matrix(Any)
+
+
+
+
+
+
+
+ Matrix Any is not a valid type.
+
+
+
+
+
Perhaps you are wondering how Axiom internally represents objects of
+type Any. An object of type Any consists not only of a data
+part representing its normal value, but also a type part (a
+badge) giving badge its type. For example, the value of
+type PositiveInteger as an object of type Any internally
+looks like .
+
+
+
+
When should you use Any instead of a Union type? For a
+Union, you must know in advance exactly which types you are
+going to
+allow. For Any, anything that comes along can be accommodated.
+
Conversion is the process of changing an object of one type into an
+object of another type. The syntax for conversion is:
+
+
+
+
+
+
+
+
+
+
+
By default, has the type PositiveInteger.
+
+
+
+
+
+
+3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
We can change this into an object of type Fraction Integer
+by using ``::''.
+
+
+
+
+
+
+3 :: Fraction Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
A coercion is a special kind of conversion that Axiom is allowed
+to do automatically when you enter an expression. Coercions are
+usually somewhat safer than more general conversions. The Axiom
+library contains operations called coerce and convert.
+Only the coerce operations can be used by the interpreter to
+change an object into an object of another type unless you explicitly
+use a ::.
+
+
+
+
By now you will be quite familiar with what types and modes look like.
+It is useful to think of a type or mode as a pattern for what you want
+the result to be.
+
+
+
+
Let's start with a square matrix of polynomials with complex rational
+number coefficients. SquareMatrix
+
All the entries have changed types, although in comparing the
+last two results only the entry in the lower left corner looks different.
+We did all the intermediate steps to show you what Axiom can do.
+
+
+
+
In fact, we could have combined all these into one conversion.
+
There are times when Axiom is not be able to do the conversion in one
+step. You may need to break up the transformation into several
+conversions in order to get an object of the desired type.
+
+
+
+
We cannot move either Fraction or Complex above (or to the
+left of, depending on how you look at it) SquareMatrix because
+each of these levels requires that its argument type have commutative
+multiplication, whereas SquareMatrix does not. That is because
+Fraction requires that its argument belong to the category
+IntegralDomain and categoryComplex requires that its
+argument belong to CommutativeRing.
+See ugTypesBasic for a
+brief discussion of categories. The Integer level did not move
+anywhere because it does not allow any arguments. We also did not
+move the SquareMatrix part anywhere, but we could have.
+
We have not yet used modes for any conversions. Modes are a great
+shorthand for indicating the type of the object you want. Instead of
+using the long type expression in the last example, we could have
+simply said this.
+
A subdomain S of a domain D is a domain consisting of
+
+
+
+
+
+
+ those elements of D that satisfy some
+predicate (that is, a test that returns true or false) and
+
+
a subset of the operations of D.
+
+
+
+
+Every domain is a subdomain of itself, trivially satisfying the
+membership test: true.
+
+
+
+
Currently, there are only two system-defined subdomains in Axiom that
+receive substantial use. PositiveInteger and
+NonNegativeInteger are subdomains of Integer. An element
+of NonNegativeInteger is an integer that is greater than or
+equal to zero, that is, satisfies . An element of
+PositiveInteger is a nonnegative integer that is, in fact, greater
+than zero, that is, satisfies . Not all operations from
+Integer are available for these subdomains. For example, negation
+and subtraction are not provided since the subdomains are not closed
+under those operations. When you use an integer in an expression,
+Axiom assigns to it the type that is the most specific subdomain whose
+predicate is satisfied.
+
+
+
+
This is a positive integer.
+
+
+
+
+
+
+5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
This is a nonnegative integer.
+
+
+
+
+
+
+0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: NonNegativeInteger
+
+
+
+
+
This is neither of the above.
+
+
+
+
+
+
+-5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Integer
+
+
+
+
+
Furthermore, unless you are assigning an integer to a declared variable
+or using a conversion, any integer result has as type the most
+specific subdomain.
+
+
+
+
+
+
+(-2) - (-3)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+0 :: Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Integer
+
+
+
+
+
+
+
+
+x : NonNegativeInteger := 5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: NonNegativeInteger
+
+
+
+
+
When necessary, Axiom converts an integer object into one belonging to
+a less specific subdomain. For example, in , the arguments to
+"-" are both elements of PositiveInteger,
+but this type does not provide a subtraction operation. Neither does
+NonNegativeInteger, so and are viewed as elements of
+Integer, where their difference can be calculated. The result
+is , which Axiom then automatically assigns the type
+PositiveInteger.
+
+
+
+
Certain operations are very sensitive to the subdomains to which their
+arguments belong. This is an element of PositiveInteger.
+
+
+
+
+
+
+2 ** 2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
This is an element of Fraction Integer.
+
+
+
+
+
+
+2 ** (-2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
It makes sense then that this is a list of elements of
+PositiveInteger.
+
+
+
+
+
+
+[10**i for i in 2..5]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
What should the type of [10**(i-1) for i in 2..5] be? On one hand,
+ is always an integer greater than zero as ranges from to
+ and so is also always a positive integer. On the other,
+ is a very simple function of . Axiom does not try to analyze
+every such function over the index's range of values to determine
+whether it is always positive or nowhere negative. For an arbitrary
+Axiom function, this analysis is not possible.
+
+
+
+
So, to be consistent no such analysis is done and we get this.
+
+
+
+
+
+
+[10**(i-1) for i in 2..5]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Fraction Integer
+
+
+
+
+
To get a list of elements of PositiveInteger instead, you have
+two choices. You can use a conversion.
+
+
+
+
+
+
+
+[10**((i-1) :: PI) for i in 2..5]
+
+
+
+
+
+
+
+Compiling function G82696 with type Integer -> Boolean
+Compiling function G82708 with type NonNegativeInteger -> Boolean
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
Or you can use pretend. pretend
+
+
+
+
+
+
+[10**((i-1) pretend PI) for i in 2..5]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
The operation pretend is used to defeat the Axiom type system.
+The expression object pretend D means ``make a new object
+(without copying) of type D from object.'' If
+object were an integer and you told Axiom to pretend it was a list,
+you would probably see a message about a fatal error being caught and
+memory possibly being damaged. Lists do not have the same internal
+representation as integers!
+
+
+
+
You use pretend at your peril. peril
+
+
+
+
Use with great care! Axiom trusts you that the value is of
+the specified type.
+
Axiom works hard to figure out what you mean by an expression without
+your having to qualify it with type information. Nevertheless, there
+are times when you need to help it along by providing hints (or even
+orders!) to get Axiom to do what you want.
+
+
+
+
We saw in ugTypesDeclare that
+declarations using types and modes control the type of the results
+produced. For example, we can either produce a complex object with
+polynomial real and imaginary parts or a polynomial with complex
+integer coefficients, depending on the declaration.
+
+
+
+
Package calling is how you tell Axiom to use a particular function
+from a particular part of the library.
+
+
+
+
Use the / from Fraction Integer to create
+a fraction of two integers.
+
+
+
+
+
+
+2/3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
If we wanted a floating point number, we can say ``use the
+/ in Float.''
+
+
+
+
+
+
+(2/3) $Float
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
Perhaps we actually wanted a fraction of complex integers.
+
+
+
+
+
+
+(2/3) $Fraction(Complex Integer)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
In each case, AXIOM used the indicated operations, sometimes first
+needing to convert the two integers into objects of the appropriate type.
+In these examples, ``/'' is written as an infix operator.
+
+
+
+
+
+
+
+
+
+
+
+
+
To use package calling with an infix operator, use the following syntax:
+
+
+
+
+
+
+
+
+
+
+
+
+
We used, for example, . The expression
+is equivalent to . Therefore in the expression
+ the second ``+'' comes from the Float
+domain. The first ``+'' comes from Float because the package
+call causes AXIOM to convert and to type
+ Float. Before the sum is converted, it is given a target type
+of Float by AXIOM and then evaluated. The target type causes the
+``+'' from Float to be used.
+
+
+
+
+
+
+
+
+
+
+
+
+
For an operator written before its arguments, you must use parentheses
+around the arguments (even if there is only one), and follow the closing
+parenthesis by a `` $'' and then the type.
+
+
+
+
+
+
+
+
+
+
+
For example, to call the ``minimum'' function from SmallFloat on two
+integers, you could write min(4,89) $SmallFloat. Another use of
+package calling is to tell AXIOM to use a library function rather than a
+function you defined. We discuss this in
+Section ugUserUse .
+
+
+
+
Sometimes rather than specifying where an operation comes from, you
+just want to say what type the result should be. We say that you provide a
+ target type for the expression. Instead of using a `` $'', use a ``@''
+to specify the requested target type. Otherwise, the syntax is the same.
+Note that giving a target type is not the same as explicitly doing a
+conversion. The first says ``try to pick operations so that the result has
+such-and-such a type.'' The second says ``compute the result and then convert
+to an object of such-and-such a type.''
+
+
+
+
Sometimes it makes sense, as in this expression, to say ``choose the
+operations in this expression so that the final result is Float.
+
+
+
+
+
+
+(2/3)@Float
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
Here we used ``@'' to say that the target type of the left-hand side
+was Float. In this simple case, there was no real difference
+between using `` $'' and ``@''.
+You can see the difference if you try the following.
+
+
+
+
This says to try to choose ``+'' so that the result is a string.
+Axiom cannot do this.
+
+
+
+
+
+
+(2 + 3)@String
+
+
+
+
+
+
+
+An expression involving @ String actually evaluated to one of
+ type PositiveInteger . Perhaps you should use :: String .
+
+
+
+
+
This says to get the + from String and apply it to the two
+integers. Axiom also cannot do this because there is no +
+exported by String.
+
+
+
+
+
+
+(2 + 3) $String
+
+
+
+
+
+
+
+ The function + is not implemented in String .
+
+
+
+
+
(By the way, the operation concatconcatString or juxtaposition
+is used to concatenate two strings.)
+String
+
+
+
+
When we have more than one operation in an expression, the difference
+is even more evident. The following two expressions show that Axiom
+uses the target type to create different objects.
+The ``+'', ``*'' and ``**'' operations are all
+chosen so that an object of the correct final type is created.
+
+
+
+
This says that the operations should be chosen so that the result is a
+Complex object.
+
+
+
+
+
+
+((x + y * %i)**2)@(Complex Polynomial Integer)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Polynomial Integer
+
+
+
+
+
This says that the operations should be chosen so that the result is a
+Polynomial object.
+
+
+
+
+
+
+((x + y * %i)**2)@(Polynomial Complex Integer)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Complex Integer
+
+
+
+
+
What do you think might happen if we left off all target type and
+package call information in this last example?
+
+
+
+
+
+
+(x + y * %i)**2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Complex Integer
+
+
+
+
+
We can convert it to Complex as an afterthought. But this is
+more work than just saying making what we want in the first place.
+
+
+
+
+
+
+% :: Complex ?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Polynomial Integer
+
+
+
+
+
Finally, another use of package calling is to qualify fully an
+operation that is passed as an argument to a function.
+
+
+
+
Start with a small matrix of integers.
+
+
+
+
+
+
+h := matrix [ [8,6],[-4,9] ]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Integer
+
+
+
+
+
We want to produce a new matrix that has for entries the
+multiplicative inverses of the entries of . One way to do this is
+by calling mapmapMatrixCategoryFunctions2 with the
+invinvFraction function from Fraction (Integer).
+
+
+
+
+
+
+
+map(inv $Fraction(Integer),h)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Fraction Integer
+
+
+
+
+
We could have been a bit less verbose and used abbreviations.
+
+
+
+
+
+
+map(inv $FRAC(INT),h)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Fraction Integer
+
+
+
+
+
As it turns out, Axiom is smart enough to know what we mean anyway.
+We can just say this.
+
This appendix contains the Axiom programs used to generate
+the images in the gallery color insert of this book.
+All these input files are included
+with the Axiom system.
+To produce the images
+on page 6 of the gallery insert, for example, issue the command:
+
+
+
+
+
+)read images6
+
+
+
+
+
These images were produced on an IBM RS/6000 model 530 with a
+standard color graphics adapter. The smooth shaded images
+were made from X Window System screen dumps.
+The remaining images were produced with Axiom-generated
+PostScript output. The images were reproduced from slides made on an Agfa
+ChromaScript PostScript interpreter with a Matrix Instruments QCR camera.
+
The functions in this file create generalized tubes (also known as generalized
+cylinders).
+These functions draw a 2-d curve in the normal
+planes around a 3-d curve.
+
+
+
+
+
+
+R3 := Point DFLOAT Points in 3-Space
+R2 := Point DFLOAT Points in 2-Space
+S := Segment Float Draw ranges
+ Introduce types for functions for:
+ThreeCurve := DFLOAT -> R3 --the space curve function
+TwoCurve := (DFLOAT, DFLOAT) -> R2 --the plane curve function
+Surface := (DFLOAT, DFLOAT) -> R3 --the surface function
+ Frenet frames define a
+FrenetFrame := coordinate system around a
+ Record(value:R3,tangent:R3,normal:R3,binormal:R3)
+ point on a space curve
+frame: FrenetFrame The current Frenet frame
+ for a point on a curve
+
+
+
+
+
ntubeDraw(spaceCurve, planeCurve,
+
+draws planeCurve in the normal planes of spaceCurve.
+The parameter specifies
+the parameter range for planeCurve
+and specifies the parameter range for spaceCurve.
+Additionally, the plane curve function takes
+a second parameter: the current parameter of spaceCurve.
+This allows the plane curve to change shape
+as it goes around the space curve.
+See ugFimagesFive for an example of this.
+
+
+
+
+
+
+ntubeDraw: (ThreeCurve,TwoCurve,S,S) -> VIEW3D
+ntubeDraw(spaceCurve,planeCurve,uRange,tRange) ==
+ ntubeDrawOpt(spaceCurve, planeCurve, uRange, _
+ tRange, []$List DROPT)
+
+ntubeDrawOpt: (ThreeCurve,TwoCurve,S,S,List DROPT)
+ -> VIEW3D
+ntubeDrawOpt(spaceCurve,planeCurve,uRange,tRange,l) ==
+ This function is similar
+ to ntubeDraw, but takes
+ delT:DFLOAT := (hi(tRange) - lo(tRange))/10000 optional parameters that it
+ oldT:DFLOAT := lo(tRange) - 1 passes to the draw command
+ fun := ngeneralTube(spaceCurve,planeCurve,delT,oldT)
+ draw(fun, uRange, tRange, l)
+
+
+
+
+
+
nfrenetFrame(c, t, delT)
+numerically computes the Frenet frame
+about the curve c at t.
+Parameter delT is a small number used to
+compute derivatives.
+
+
+
+
+
+nfrenetFrame(c, t, delT) ==
+ f0 := c(t)
+ f1 := c(t+delT)
+ t0 := f1 - f0 The tangent
+ n0 := f1 + f0
+ b := cross(t0, n0) The binormal
+ n := cross(b,t0) The normal
+ ln := length n
+ lb := length b
+ ln = 0 or lb = 0 =>
+ error "Frenet Frame not well defined"
+ n := (1/ln)*n Make into unit length vectors
+ b := (1/lb)*b
+ [f0, t0, n, b]$FrenetFrame
+
+
+
+
+
ngeneralTube(spaceCurve, planeCurve, delT, oltT)
+creates a function that can be passed to the system axiomFun{draw} command.
+The function is a parameterized surface for the general tube
+around spaceCurve. delT is a small number used to compute
+derivatives. oldT is used to hold the current value of the
+t parameter for spaceCurve. This is an efficiency measure
+to ensure that frames are only computed once for each value of t.
+
+
+
+
+
+ngeneralTube: (ThreeCurve, TwoCurve, DFLOAT, DFLOAT) -> Surface
+ngeneralTube(spaceCurve, planeCurve, delT, oldT) ==
+ free frame Indicate that is global
+ (v:DFLOAT, t: DFLOAT): R3 +->
+ if (t $\sim$= oldT) then If not already computed
+ frame := nfrenetFrame(spaceCurve, t, delT) compute new frame
+ oldT := t
+ p := planeCurve(v, t)
+ frame.value + p.1*frame.normal + p.2*frame.binormal
+ Project into the normal plane
+
Create affine transformations (DH matrices) that transform
+a given triangle into another.
+
+
+
+
+
+
+tri2tri: (List Point DFLOAT, List Point DFLOAT) -> DHMATRIX(DFLOAT)
+ Compute a DHMATRIX that
+tri2tri(t1, t2) == transforms to where
+ n1 := triangleNormal(t1) and are the vertices
+ n2 := triangleNormal(t2) of two triangles in 3-space
+ tet2tet(concat(t1, n1), concat(t2, n2))
+
+tet2tet: (List Point DFLOAT, List Point DFLOAT) -> DHMATRIX(DFLOAT)
+ Compute a DHMATRIX that
+tet2tet(t1, t2) == transforms to
+ m1 := makeColumnMatrix t1 where and are the
+ m2 := makeColumnMatrix t2 vertices of two tetrahedrons
+ m2 * inverse(m1) in 3-space
+
+makeColumnMatrix(t) == Put the vertices of a tetra-
+ m := new(4,4,0)$DHMATRIX(DFLOAT) hedron into matrix form
+ for x in t for i in 1..repeat
+ for j in 1..3 repeat
+ m(j,i) := x.j
+ m(4,i) := 1
+ m
+
+triangleNormal(t) == Compute a vector normal to
+ a := triangleArea t the given triangle, whose
+ p1 := t.2 - t.1 length is the square root
+ p2 := t.3 - t.2 of the area of the triangle
+ c := cross(p1, p2)
+ len := length(c)
+ len = 0 => error "degenerate triangle!"
+ c := (1/len)*c
+ t.1 + sqrt(a) * c
+
+triangleArea t == Compute the area of a
+ a := length(t.2 - t.1) triangle using Heron's
+ b := length(t.3 - t.2) formula
+ c := length(t.1 - t.3)
+ s := (a+b+c)/2
+ sqrt(s*(s-a)*(s-b)*(s-c))
+
+)set expose add con DenavitHartenbergMatrix Bring DH matrices into the
+ environment
+x1:DFLOAT := sqrt(2.0@DFLOAT/3.0@DFLOAT) Set up the coordinates of the
+x2:DFLOAT := sqrt(3.0@DFLOAT)/6 corners of the tetrahedron.
+
+p1 := point [-0.5@DFLOAT, -x2, 0.0@DFLOAT] Some needed points
+p2 := point [0.5@DFLOAT, -x2, 0.0@DFLOAT]
+p3 := point [0.0@DFLOAT, 2*x2, 0.0@DFLOAT]
+p4 := point [0.0@DFLOAT, 0.0@DFLOAT, x1]
+
+baseTriangle := [p2, p1, p3] The base of the tetrahedron
+
+mt := [0.5@DFLOAT*(p2+p1), 0.5@DFLOAT*(p1+p3), 0.5@DFLOAT*(p3+p2)]
+ The middle triangle inscribed
+ in the base of the tetrahedron
+bt1 := [mt.1, p1, mt.2] The bases of the triangles of
+bt2 := [p2, mt.1, mt.3] the subdivided tetrahedron
+bt3 := [mt.2, p3, mt.3]
+bt4 := [0.5@DFLOAT*(p2+p4), 0.5@DFLOAT*(p1+p4), 0.5@DFLOAT*(p3+p4)]
+
+tt1 := tri2tri(baseTriangle, bt1) Create the transformations
+tt2 := tri2tri(baseTriangle, bt2) that bring the base of the
+tt3 := tri2tri(baseTriangle, bt3) tetrahedron to the bases of
+tt4 := tri2tri(baseTriangle, bt4) the subdivided tetrahedron
+
+drawPyramid(n) == Draw a Sierpinsky tetrahedron
+ s := createThreeSpace() with levels of recursive
+ dh := rotatex(0.0@DFLOAT) subdivision
+ drawPyramidInner(s, n, dh)
+ makeViewport3D(s, "Sierpinsky Tetrahedron")
+
+drawPyramidInner(s, n, dh) == Recursively draw a Sierpinsky
+ n = 0 => makeTetrahedron(s, dh, n) tetrahedron
+ drawPyramidInner(s, n-1, dh * tt1) Draw the 4 recursive pyramids
+ drawPyramidInner(s, n-1, dh * tt2)
+ drawPyramidInner(s, n-1, dh * tt3)
+ drawPyramidInner(s, n-1, dh * tt4)
+
+makeTetrahedron(sp, dh, color) == Draw a tetrahedron into the
+ w1 := dh*p1 given space with the given
+ w2 := dh*p2 color, transforming it by
+ w3 := dh*p3 the given DH matrix
+ w4 := dh*p4
+ polygon(sp, [w1, w2, w4])
+ polygon(sp, [w1, w3, w4])
+ polygon(sp, [w2, w3, w4])
+ void()
+
Draw Antoine's Necklace.
+Antoine's Necklace
+Thank you to Matthew Grayson at IBM's T.J Watson Research Center for the idea.
+
+
+
+
+
+
+)set expose add con DenavitHartenbergMatrix Bring DH matrices into
+ the environment
+torusRot: DHMATRIX(DFLOAT) The transformation for
+ drawing a sub ring
+
+drawRings(n) == Draw Antoine's Necklace with
+ s := createThreeSpace() levels of recursive subdivision
+ dh:DHMATRIX(DFLOAT) := identity() The number of subrings is
+ drawRingsInner(s, n, dh) Do the real work
+ makeViewport3D(s, "Antoine's Necklace")
+
+
+
+
+
+
In order to draw Antoine rings, we take one ring, scale it down to
+a smaller size, rotate it around its central axis, translate it
+to the edge of the larger ring and rotate it around the edge to
+a point corresponding to its count (there are 10 positions around
+the edge of the larger ring). For each of these new rings we
+recursively perform the operations, each ring becoming 10 smaller
+rings. Notice how the DHMATRIX operations are used to build up
+the proper matrix composing all these transformations.
+
+
+
+
+
+
+drawRingsInner(s, n, dh) == Recursively draw Antoine's
+ n = 0 => Necklace
+ drawRing(s, dh)
+ void()
+ t := 0.0@DFLOAT Angle around ring
+ p := 0.0@DFLOAT Angle of subring from plane
+ tr := 1.0@DFLOAT Amount to translate subring
+ inc := 0.1@DFLOAT The translation increment
+ for i in 1..10 repeat Subdivide into 10 linked rings
+ tr := tr + inc
+ inc := -inc
+ dh' := dh*rotatez(t)*translate(tr,0.0@DFLOAT,0.0@DFLOAT)*
+ Transform ring in center
+ to a link
+ rotatey(p)*scale(0.35@DFLOAT, 0.48@DFLOAT, 0.4@DFLOAT)
+ drawRingsInner(s, n-1, dh')
+ t := t + 36.0@DFLOAT
+ p := p + 90.0@DFLOAT
+ void()
+
+drawRing(s, dh) == Draw a single ring into
+ free torusRot the given subspace,
+ torusRot := dh transformed by the given
+ DHMATRIX
+ makeObject(torus, 0..2*%pi, 0..2*%pi, var1Steps == 6,
+ space == s, var2Steps == 15)
+
+torus(u ,v) == Parameterization of a torus,
+ cu := cos(u)/6 transformed by the
+ DHMATRIX in .
+ torusRot*point [(1+cu)*cos(v),(1+cu)*sin(v),(sin u)/6]
+
Scherk's minimal surface, defined by:
+Scherk's minimal surface
+ .
+See: A Comprehensive Introduction to Differential Geometry, Vol. 3,
+by Michael Spivak, Publish Or Perish, Berkeley, 1979, pp. 249-252.
+
+
+
+
+
+
+(xOffset, yOffset):DFLOAT Offsets for a single piece
+ of Scherk's minimal surface
+
+drawScherk(m,n) == Draw Scherk's minimal surface
+ free xOffset, yOffset on an by patch
+ space := createThreeSpace()
+ for i in 0..m-1 repeat
+ xOffset := i*%pi
+ for j in 0 .. n-1 repeat
+ rem(i+j, 2) = 0 => 'iter Draw only odd patches
+ yOffset := j*%pi
+ drawOneScherk(space) Draw a patch
+ makeViewport3D(space, "Scherk's Minimal Surface")
+
+scherk1(u,v) == The first patch that makes
+ x := cos(u)/exp(v) up a single piece of
+ point [xOffset + acos(x), yOffset + u, v, abs(v)] Scherk's minimal surface
+
+scherk2(u,v) == The second patch
+ x := cos(u)/exp(v)
+ point [xOffset - acos(x), yOffset + u, v, abs(v)]
+
+scherk3(u,v) == The third patch
+ x := exp(v) * cos(u)
+ point [xOffset + u, yOffset + acos(x), v, abs(v)]
+
+scherk4(u,v) == The fourth patch
+ x := exp(v) * cos(u)
+ point [xOffset + u, yOffset - acos(x), v, abs(v)]
+
+drawOneScherk(s) == Draw the surface by
+ breaking it into four
+ patches and then drawing
+ the patches
+ makeObject(scherk1,-%pi/2..%pi/2,0..%pi/2,space==s,
+ var1Steps == 28, var2Steps == 28)
+ makeObject(scherk2,-%pi/2..%pi/2,0..%pi/2,space==s,
+ var1Steps == 28, var2Steps == 28)
+ makeObject(scherk3,-%pi/2..%pi/2,-%pi/2..0,space==s,
+ var1Steps == 28, var2Steps == 28)
+ makeObject(scherk4,-%pi/2..%pi/2,-%pi/2..0,space==s,
+ var1Steps == 28, var2Steps == 28)
+ void()
+
These images illustrate how Newton's method converges when computing the
+Newton iteration
+complex cube roots of 2. Each point in the -plane represents the
+complex number which is given as a starting point for Newton's
+method. The poles in these images represent bad starting values.
+The flat areas are the regions of convergence to the three roots.
+
+
+
+
+
+
+)read newton Read the programs from
+)read vectors Chapter 10
+f := newtonStep(x**3 - 2) Create a Newton's iteration
+ function for
+
+
+
+
+
The function computes steps of Newton's method.
+
+
+
+
+
+
+clipValue := 4 Clip values with magnitude > 4
+drawComplexVectorField(f**3, -3..3, -3..3) The vector field for
+drawComplex(f**3, -3..3, -3..3) The surface for
+drawComplex(f**4, -3..3, -3..3) The surface for
+
The parameterization of the Etruscan Venus is due to George Frances.
+Etruscan Venus
+
+
+
+
+
+
+venus(a,r,steps) ==
+ surf := (u:DFLOAT, v:DFLOAT): Point DFLOAT +->
+ cv := cos(v)
+ sv := sin(v)
+ cu := cos(u)
+ su := sin(u)
+ x := r * cos(2*u) * cv + sv * cu
+ y := r * sin(2*u) * cv - sv * su
+ z := a * cv
+ point [x,y,z]
+ draw(surf, 0..%pi, -%pi..%pi, var1Steps==steps,
+ var2Steps==steps, title == "Etruscan Venus")
+
+venus(5/2, 13/10, 50) The Etruscan Venus
+
+
+
+
+
The Figure-8 Klein Bottle
+Klein bottle
+parameterization is from
+``Differential Geometry and Computer Graphics'' by Thomas Banchoff,
+in Perspectives in Mathematics, Anniversary of Oberwolfasch 1984,
+Birkh\"{a}user-Verlag, Basel, pp. 43-60.
+
The next two images are examples of generalized tubes.
+
+
+
+
+
+
+)read ntube
+rotateBy(p, theta) == Rotate a point by
+ c := cos(theta) around the origin
+ s := sin(theta)
+ point [p.1*c - p.2*s, p.1*s + p.2*c]
+
+bcircle t == A circle in three-space
+ point [3*cos t, 3*sin t, 0]
+
+twist(u, t) == An ellipse that twists
+ theta := 4*t around four times as
+ p := point [sin u, cos(u)/2] revolves once
+ rotateBy(p, theta)
+
+ntubeDrawOpt(bcircle, twist, 0..2*%pi, 0..2*%pi, Twisted Torus
+ var1Steps == 70, var2Steps == 250)
+
+twist2(u, t) == Create a twisting circle
+ theta := t
+ p := point [sin u, cos(u)]
+ rotateBy(p, theta)
+
+cf(u,v) == sin(21*u) Color function with stripes
+
+ntubeDrawOpt(bcircle, twist2, 0..2*%pi, 0..2*%pi, Striped Torus
+ colorFunction == cf, var1Steps == 168,
+ var2Steps == 126)
+
+gam(x,y) == The height and color are the
+ g := Gamma complex(x,y) real and argument parts
+ point [x,y,max(min(real g, 4), -4), argument g] of the Gamma function,
+ respectively.
+
+draw(gam, -%pi..%pi, -%pi..%pi, The Gamma Function
+ title == "Gamma(x + %i*y)", _
+ var1Steps == 100, var2Steps == 100)
+
+b(x,y) == Beta(x,y)
+
+draw(b, -3.1..3, -3.1 .. 3, title == "Beta(x,y)") The Beta Function
+
+atf(x,y) ==
+ a := atan complex(x,y)
+ point [x,y,real a, argument a]
+
+draw(atf, -3.0..%pi, -3.0..%pi) The Arctangent function
+
+
+
+
function:Gamma
+function:Euler Beta
+Euler:Beta function
+
First we look at the conformal
+conformal map
+map .
+
+
+
+
+
+)read conformal Read program for drawing
+ conformal maps
+
+f z == z The coordinate grid for the
+ complex plane
+conformalDraw(f, -2..2, -2..2, 9, 9, "cartesian") Mapping 1: Source
+
+f z == z + 1/z The map
+
+conformalDraw(f, -2..2, -2..2, 9, 9, "cartesian") Mapping 1: Target
+
+
+
+
+
The map maps
+the unit disk to the right half-plane, as shown
+Riemann:sphere
+on the Riemann sphere.
+
+
+
+
+
+
+f z == z The unit disk
+
+riemannConformalDraw(f,0.1..0.99,0..2*%pi,7,11,"polar") Mapping 2: Source
+
+f z == -(z+1)/(z-1) The map
+
+riemannConformalDraw(f,0.1..0.99,0..2*%pi,7,11,"polar") Mapping 2: Target
+
+riemannSphereDraw(-4..4, -4..4, 7, 7, "cartesian") Riemann Sphere Mapping
+
The functions in this section draw conformal maps both on the
+conformal map
+plane and on the Riemann sphere.
+Riemann:sphere
+
+
+
+
+
+
+
+
+
+
+
+C := Complex DoubleFloat Complex Numbers
+S := Segment DoubleFloat Draw ranges
+R3 := Point DFLOAT Points in 3-space
+
+
+
+
+
conformalDraw(f, rRange, tRange, rSteps, tSteps, coord)
+draws the image of the coordinate grid under f in the complex plane.
+The grid may be given in either polar or Cartesian coordinates.
+Argument f is the function to draw;
+rRange is the range of the radius (in polar) or real (in Cartesian);
+tRange is the range of (in polar) or imaginary (in Cartesian);
+tSteps, rSteps, are the number of intervals in the r and
+ directions; and
+coord is the coordinate system to use (either "polar" or
+"cartesian").
+
+
+
+
+
+
+conformalDraw: (C -> C, S, S, PI, PI, String) -> VIEW3D
+conformalDraw(f,rRange,tRange,rSteps,tSteps,coord) ==
+ transformC := Function for changing an
+ coord = "polar" => polar2Complex pair into a complex number
+ cartesian2Complex
+ cm := makeConformalMap(f, transformC)
+ sp := createThreeSpace() Create a fresh space
+ adaptGrid(sp, cm, rRange, tRange, rSteps, tSteps) Plot the coordinate lines
+ makeViewport3D(sp, "Conformal Map") Draw the image
+
+
+
+
+
riemannConformalDraw(f, rRange, tRange, rSteps, tSteps, coord)
+draws the image of the coordinate grid under f on the Riemann sphere.
+The grid may be given in either polar or Cartesian coordinates.
+Its arguments are the same as those for conformalDraw.
+
+
+
+
+
+
+riemannConformalDraw:(C->C,S,S,PI,PI,String)->VIEW3D
+riemannConformalDraw(f, rRange, tRange,
+ rSteps, tSteps, coord) ==
+ transformC := Function for changing an
+ coord = "polar" => polar2Complex pair into a complex number
+ cartesian2Complex
+ sp := createThreeSpace() Create a fresh space
+ cm := makeRiemannConformalMap(f, transformC)
+ adaptGrid(sp, cm, rRange, tRange, rSteps, tSteps) Plot the coordinate lines
+ curve(sp,[point [0,0,2.0@DFLOAT,0],point [0,0,2.0@DFLOAT,0] ])
+ Add an invisible point at
+ makeViewport3D(sp,"Map on the Riemann Sphere") the north pole for scaling
+
+adaptGrid(sp, f, uRange, vRange, uSteps, vSteps) == Plot the coordinate grid
+ delU := (hi(uRange) - lo(uRange))/uSteps using adaptive plotting for
+ delV := (hi(vRange) - lo(vRange))/vSteps coordinate lines, and draw
+ uSteps := uSteps + 1; vSteps := vSteps + 1 tubes around the lines
+ u := lo uRange
+ for i in 1..uSteps repeat Draw coordinate lines in the
+ c := curryLeft(f,u) direction; curve fixes the
+ cf := (t:DFLOAT):DFLOAT +-> 0 current value of
+ makeObject(c,vRange::SEG Float,colorFunction==cf,
+ Draw the coordinate line
+ space == sp, tubeRadius == .02, tubePoints == 6)
+ u := u + delU
+ v := lo vRange
+ for i in 1..vSteps repeat Draw coodinate lines in the
+ c := curryRight(f,v) direction; curve fixes the
+ cf := (t:DFLOAT):DFLOAT +-> 1 current value of
+ makeObject(c,uRange::SEG Float,colorFunction==cf,
+ Draw the coordinate line
+ space == sp, tubeRadius == .02, tubePoints == 6)
+ v := v + delV
+ void()
+
+riemannTransform(z) == Map a point in the complex
+ r := sqrt norm z plane to the Riemann sphere
+ cosTheta := (real z)/r
+ sinTheta := (imag z)/r
+ cp := 4*r/(4+r**2)
+ sp := sqrt(1-cp*cp)
+ if r>2 then sp := -sp
+ point [cosTheta*cp, sinTheta*cp, -sp + 1]
+
+cartesian2Complex(r:DFLOAT, i:DFLOAT):C == Convert Cartesian coordinates to
+ complex(r, i) complex Cartesian form
+
+polar2Complex(r:DFLOAT, th:DFLOAT):C == Convert polar coordinates to
+ complex(r*cos(th), r*sin(th)) complex Cartesian form
+
+makeConformalMap(f, transformC) == Convert complex function
+ (u:DFLOAT,v:DFLOAT):R3 +-> to a mapping:
+ (DFLOAT,DFLOAT) R3
+ z := f transformC(u, v) in the complex plane
+ point [real z, imag z, 0.0@DFLOAT]
+
+makeRiemannConformalMap(f, transformC) == Convert a complex function
+ (u:DFLOAT, v:DFLOAT):R3 +-> to a mapping:
+ (DFLOAT,DFLOAT) R3
+ riemannTransform f transformC(u, v) on the Riemann sphere
+
+riemannSphereDraw: (S, S, PI, PI, String) -> VIEW3D
+ Draw a picture of the mapping
+ of the complex plane to
+ the Riemann sphere
+riemannSphereDraw(rRange,tRange,rSteps,tSteps,coord) ==
+ transformC :=
+ coord = "polar" => polar2Complex
+ cartesian2Complex
+ grid := (u:DFLOAT, v:DFLOAT): R3 +-> Coordinate grid function
+ z1 := transformC(u, v)
+ point [real z1, imag z1, 0]
+ sp := createThreeSpace() Create a fresh space
+ adaptGrid(sp, grid, rRange, tRange, rSteps, tSteps) Draw the flat grid
+ connectingLines(sp,grid,rRange,tRange,rSteps,tSteps)
+ makeObject(riemannSphere,0..2*%pi,0..%pi,space==sp) Draw the sphere
+ f := (z:C):C +-> z
+ cm := makeRiemannConformalMap(f, transformC)
+ adaptGrid(sp, cm, rRange, tRange, rSteps, tSteps) Draw the sphere grid
+ makeViewport3D(sp, "Riemann Sphere")
+
+connectingLines(sp,f,uRange,vRange,uSteps,vSteps) ==
+ Draw the lines that connect
+ delU := (hi(uRange) - lo(uRange))/uSteps the points in the complex
+ delV := (hi(vRange) - lo(vRange))/vSteps plane to the north pole
+ uSteps := uSteps + 1; vSteps := vSteps + 1 of the Riemann sphere
+ u := lo uRange
+ for i in 1..uSteps repeat For each u
+ v := lo vRange
+ for j in 1..vSteps repeat For each v
+ p1 := f(u,v)
+ p2 := riemannTransform complex(p1.1, p1.2) Project p1 onto the sphere
+ fun := lineFromTo(p1,p2) Create a line function
+ cf := (t:DFLOAT):DFLOAT +-> 3
+ makeObject(fun, 0..1,space==sp,tubePoints==4, Draw the connecting line
+ tubeRadius==0.01,colorFunction==cf)
+ v := v + delV
+ u := u + delU
+ void()
+
+riemannSphere(u,v) == A sphere sitting on the
+ sv := sin(v) complex plane, with radius 1
+ 0.99@DFLOAT*(point [cos(u)*sv,sin(u)*sv,cos(v),0.0@DFLOAT])+
+ point [0.0@DFLOAT, 0.0@DFLOAT, 1.0@DFLOAT, 4.0@DFLOAT]
+
+lineFromTo(p1, p2) == Create a line function
+ d := p2 - p1 that goes from p1 to p2
+ (t:DFLOAT):Point DFLOAT +->
+ p1 + t*d
+
Create a torus-knot with radius around the curve.
+The formula was derived by Larry Lambe.
+
+
+
+
+
+
+)read ntube
+torusKnot: (DFLOAT, DFLOAT, DFLOAT, PI, PI) -> VIEW3D
+torusKnot(p, q ,r, uSteps, tSteps) ==
+ knot := (t:DFLOAT):Point DFLOAT +-> Function for the torus knot
+ fac := 4/(2.2@DFLOAT-sin(q*t))
+ fac * point [cos(p*t), sin(p*t), cos(q*t)]
+ circle := (u:DFLOAT, t:DFLOAT): Point DFLOAT +-> The cross section
+ r * point [cos u, sin u]
+ ntubeDrawOpt(knot, circle, 0..2*%pi, 0..2*%pi,
+ Draw the circle around the knot
+ var1Steps == uSteps, var2Steps == tSteps)
+
+
HyperDoc is the gateway to Axiom. HyperDoc It's both an
+on-line tutorial and an on-line reference manual. It also enables you
+to use Axiom simply by using the mouse and filling in templates.
+HyperDoc is available to you if you are running Axiom under the X
+Window System.
+
+
+
+
Pages usually have active areas, marked in this font (bold
+face). As you move the mouse pointer to an active area, the pointer
+changes from a filled dot to an open circle. The active areas are
+usually linked to other pages. When you click on an active area, you
+move to the linked page.
+
Most pages have a standard set of buttons at the top of the page.
+This is what they mean:
+
+
+
+
+
Help
+
Click on this to get help. The button only appears
+if there is specific help for the page you are viewing. You can get
+general help for HyperDoc by clicking the help button on the
+home page.
+
+
Up
+
Click here to go back one page.
+By clicking on this button repeatedly, you can go back several pages and
+then take off in a new direction.
+
+
Return
+
Go back to the home page, that is, the page on
+which you started. Use HyperDoc to explore, to make forays into new
+topics. Don't worry about how to get back. HyperDoc remembers where
+you came from. Just click on this button to return.
+
+
Exit
+
From the root window (the one that is displayed
+when you start the system) this button leaves the HyperDoc program,
+and it must be restarted if you want to use it again. From any other
+HyperDoc window, it just makes that one window go away. You must
+use this button to get rid of a window. If you use the window
+manager ``Close'' button, then all of HyperDoc goes away.
+
+
+
+
+
+
The buttons are not displayed if they are not applicable to the page
+you are viewing. For example, there is no Home button on the
+top-level menu.
+
Whenever there is too much text to fit on a page, a
+scroll scroll bar bar
+automatically appears along the right side.
+
+
+
+
With a scroll bar, your page becomes an aperture, that is, a window
+into a larger amount of text than can be displayed at one time. The
+scroll bar lets you move up and down in the text to see different
+parts. It also shows where the aperture is relative to the whole
+text. The aperture is indicated by a strip on the scroll bar.
+
+
+
+
Move the cursor with the mouse to the ``down-arrow'' at the bottom of
+the scroll bar and click. See that the aperture moves down one line.
+Do it several times. Each time you click, the aperture moves down one
+line. Move the mouse to the ``up-arrow'' at the top of the scroll bar
+and click. The aperture moves up one line each time you click.
+
+
+
+
Next move the mouse to any position along the middle of the scroll bar
+and click. HyperDoc attempts to move the top of the aperture to this
+point in the text.
+
+
+
+
You cannot make the aperture go off the bottom edge. When the
+aperture is about half the size of text, the lowest you can move the
+aperture is halfway down.
+
+
+
+
To move up or down one screen at a time, use the PageUp and
+ PageDown keys on your keyboard. They move the visible part of the
+region up and down one page each time you press them.
+
+
+
+
If the HyperDoc page does not contain an input area (see
+ugHyperInput ), you can also use
+the Home and and
+arrow keys to navigate. When you press the Home key, the
+screen is positioned at the very top of the page. Use the
+ and arrow keys to move the
+screen up and down one line at a time, respectively.
+
To enter characters, first move your mouse cursor to somewhere within
+the HyperDoc page. Characters that you type are inserted in front of
+the underscore. This means that when you type characters at your
+keyboard, they go into this first input area.
+
+
+
+
The input area grows to accommodate as many characters as you type.
+Use the Backspace key to erase characters to the left. To
+modify what you type, use the right-arrow and
+left-arrow keys and the keys Insert,
+ Delete, Home and End. These keys are
+found immediately on the right of the standard IBM keyboard.
+
+
+
+
If you press the Home key, the cursor moves to the
+beginning of the line and if you press the End key, the
+cursor moves to the end of the line. Pressing
+ Ctrl-- End deletes all the text from the
+cursor to the end of the line.
+
+
+
+
A page may have more than one input area. Only one input area has an
+underscore cursor. When you first see apage, the top-most input area
+contains the cursor. To type information into another input area, use
+the Enter or Tab key to move from one input area to
+xanother. To move in the reverse order, use Shift-- Tab.
+
+
+
+
You can also move from one input area to another using your mouse.
+Notice that each input area is active. Click on one of the areas.
+As you can see, the underscore cursor moves to that window.
+
Some pages have radio buttons and toggles.
+Radio buttons are a group of buttons like those on car radios: you can
+select only one at a time.
+
+
+
+
Once you have selected a button, it appears to be inverted and
+contains a checkmark. To change the selection, move the cursor with
+the mouse to a different radio button and click.
+
+
+
+
A toggle is an independent button that displays some on/off state.
+When ``on'', the button appears to be inverted and contains a
+checkmark. When ``off'', the button is raised.
+
+
+
+
Unlike radio buttons, you can set a group of them any way you like.
+To change toggle the selection, move the cursor with the mouse to the
+button and click.
+
A search string is used for searching some database. To learn
+about search strings, we suggest that you bring up the HyperDoc
+glossary. To do this from the top-level page of HyperDoc:
+
+
+
+
+
+
+ Click on Reference, bringing up the Axiom Reference page.
+
+
Click on Glossary, bringing up the glossary.
+
+
+
+
+
+
The glossary has an input area at its bottom. We review the various
+kinds of search strings you can enter to search the glossary.
+
+
+
+
The simplest search string is a word, for example, operation. A
+word only matches an entry having exactly that spelling. Enter the
+word operation into the input area above then click on
+ Search. As you can see, operation matches only one entry,
+namely with operation itself.
+
+
+
+
Normally matching is insensitive to whether the alphabetic characters
+of your search string are in uppercase or lowercase. Thus
+operation and OperAtion both have the same effect.
+If you prefer that matching be case-sensitive, issue the command
+set HHyperName mixedCase command to the interpreter.
+
+
+
+
You will very often want to use the wildcard ``*'' in your search
+string so as to match multiple entries in the list. The search key
+``*'' matches every entry in the list. You can also use ``*''
+anywhere within a search string to match an arbitrary substring. Try
+``cat*'' for example: enter ``cat*'' into the input area and click
+on Search. This matches several entries.
+
+
+
+
You use any number of wildcards in a search string as long as they are
+not adjacent. Try search strings such as ``*dom*''. As you see,
+this search string matches ``domain'', ``domain constructor'',
+``subdomain'', and so on.
+
+
+
+
+
+
+
3.6.1 Logical Searches
+
+
+
+
+
+
For more complicated searches, you can use ``and'', ``or'', and
+``not'' with basic search strings; write logical expressions using
+these three operators just as in the Axiom language. For example,
+domain or package matches the two entries domain and
+package. Similarly, ``dom* and *con*'' matches
+``domain constructor'' and others. Also ``not *a*'' matches
+every entry that does not contain the letter ``a'' somewhere.
+
+
+
+
Use parentheses for grouping. For example, ``dom* and (not *con*)''
+matches ``domain'' but not ``domain constructor''.
+
+
+
+
There is no limit to how complex your logical expression can be.
+For example,
+
Each command has an active ``button'' along the left margin. When you
+click on this button, the output for the command is ``pasted-in.''
+Click again on the button and you see that the pasted-in output
+disappears.
+
+
+
+
Maybe you would like to run an example? To do so, just click on any
+part of its text! When you do, the example line is copied into a new
+interactive Axiom buffer for this HyperDoc page.
+
+
+
+
Sometimes one example line cannot be run before you run an earlier one.
+Don't worry---HyperDoc automatically runs all the necessary
+lines in the right order!
+
+
+
+
The new interactive Axiom buffer disappears when you leave HyperDoc.
+If you want to get rid of it beforehand, use the Cancel button
+of the X Window manager or issue the Axiom system command
+)close.close
+
You can control the appearance of HyperDoc while running under Version
+11 HyperDoc X Window System defaults of the X Window System by
+placing the following resources X Window System in the file
+ .Xdefaults in your home directory. file:.Xdefaults
+In what follows, font is any valid X11 font name
+font (for example, Rom14) and color is any valid
+X11 color color specification (for example, NavyBlue).
+For more information about fonts and colors, refer to the X Window
+documentation for your system.
+
+
+
+
+
+
Axiom.hyperdoc.RmFont:font
+
+This is the standard text font.
+The default value is Rom14
+
+
Axiom.hyperdoc.RmColor:color
+
+This is the standard text color.
+The default value is black
+
+
Axiom.hyperdoc.ActiveFont:font
+
+This is the font used for HyperDoc link buttons.
+The default value is Bld14
+
+
Axiom.hyperdoc.ActiveColor:color
+
+This is the color used for HyperDoc link buttons.
+The default value is black
+
+
Axiom.hyperdoc.AxiomFont:font
+
+This is the font used for active Axiom commands.
+The default value is Bld14
+
+
Axiom.hyperdoc.AxiomColor:color
+
+This is the color used for active Axiom commands.
+The default value is black
+
+
Axiom.hyperdoc.BoldFont:font
+
+This is the font used for bold face.
+The default value is Bld14
+
+
Axiom.hyperdoc.BoldColor:color
+
+This is the color used for bold face.
+The default value is black
+
+
Axiom.hyperdoc.TtFont:font
+
+This is the font used for Axiom output in HyperDoc.
+This font must be fixed-width.
+The default value is Rom14
+
+
Axiom.hyperdoc.TtColor:color
+
+This is the color used for Axiom output in HyperDoc.
+The default value is black
+
+
Axiom.hyperdoc.EmphasizeFont:font
+
+This is the font used for italics.
+The default value is Itl14
+
+
Axiom.hyperdoc.EmphasizeColor:color
+
+This is the color used for italics.
+The default value is black
+
+
Axiom.hyperdoc.InputBackground:color
+
+This is the color used as the background for input areas.
+The default value is black
+
+
Axiom.hyperdoc.InputForeground:color
+
+This is the color used as the foreground for input areas.
+The default value is white
+
+
Axiom.hyperdoc.BorderColor:color
+
+This is the color used for drawing border lines.
+The default value is black
+
+
Axiom.hyperdoc.Background:color
+
+This is the color used for the background of all windows.
+The default value is white
+
In this chapter we discuss how to collect Axiom statements
+and commands into files and then read the contents into the
+workspace.
+We also show how to display the results of your computations in
+several different styles including TeX, FORTRAN and
+monospace two-dimensional format.TeX is a
+trademark of the American Mathematical Society.
+
+
+
+
The printed version of this book uses the Axiom TeX output formatter.
+When we demonstrate a particular output style, we will need to turn
+TeX formatting off and the output style on so that the correct output
+is shown in the text.
+
In this section we explain what an input file is and
+file:input why you would want to know about it. We discuss
+where Axiom looks for input files and how you can direct it to look
+elsewhere. We also show how to read the contents of an input file
+into the workspace and how to use the history facility to
+generate an input file from the statements you have entered directly
+into the workspace.
+
+
+
+
An input file contains Axiom expressions and system commands.
+Anything that you can enter directly to Axiom can be put into an input
+file. This is how you save input functions and expressions that you
+wish to read into Axiom more than one time.
+
+
+
+
To read an input file into Axiom, use the )read system command.
+read For example, you can read a file in a particular
+directory by issuing
+
+
+
+
+
+)read /spad/src/input/matrix.input
+
+
+
+
+
The ``.input'' is optional; this also works:
+
+
+
+
+
+)read /spad/src/input/matrix
+
+
+
+
+
What happens if you just enter )read matrix.input or even )read matrix? Axiom looks in your current working directory for
+input files that are not qualified by a directory name. Typically,
+this directory is the directory from which you invoked Axiom.
+
+
+
+
To change the current working directory, use the )cd system
+command. The command )cd by itself shows the current working
+directory:default for searching directory. cd To
+change it to file:input:where found the src/input
+subdirectory for user ``babar'', issue
+
+
+
+
+
+)cd /u/babar/src/input
+
+
+
+
Axiom looks first in this directory for an input file. If it is not
+found, it looks in the system's directories, assuming you meant some
+input file that was provided with Axiom.
+
+
+
+
+
+
+
+
+
+
+
+
+
If you have the Axiom history facility turned on (which it is
+by default), you can save all the lines you have entered into the
+workspace by entering
+
+
+
+
)history )write
+
+
+
+
history )write
+
+
+
+
Axiom tells you what input file to edit to see your statements. The
+file is in your home directory or in the directory you specified with
+cd)cd.
+
+
+
+
+
+
+
+
+
+
In ugLangBlocks
+we discuss using indentation in input files to
+group statements into blocks.
+
When Axiom starts up, it tries to read the input file
+.axiom.input (.axiom.input used to be called
+axiom.input in the NAG version)
+from your home start-up profile file
+directory. file:start-up profile It
+there is no .axiom.input in your home directory, it reads the
+copy located in its own src/input directory.
+file:.axiom.input @.axiom.input The file usually
+contains system commands to personalize your Axiom environment. In
+the remainder of this section we mention a few things that users
+frequently place in their .axiom.input files.
+
+
+
+
In order to have FORTRAN output always produced from your
+computations, place the system command )set output fortran on in
+.axiom.input. quit If you do not want to be prompted
+for confirmation when you issue the )quit system command, place
+)set quit unprotected in .axiom.input.
+set quit unprotected
+If you then decide that you do want to be prompted, issue
+)set quit protected. set quit protected This is the
+default setting so that new users do not leave Axiom
+inadvertently.The system command )pquit always
+prompts you for confirmation.
+
+
+
+
To see the other system variables you can set, issue )set
+or use the HyperDoc Settings facility to view and change
+Axiom system variables.
+
In this section we discuss how to start and stop the display
+output formats:common features of the different output formats
+and how to send the output to the screen or to a file.
+file:sending output to To fix ideas, we use FORTRAN output
+format for most of the examples.
+
+
+
+
You can use the )set output system output
+formats:starting command to output formats:stopping toggle or
+redirect the different kinds of output. set output The name
+of the kind of output follows ``output'' in the command. The names are
+
+
+
+
+
fortran
for FORTRAN output.
+
algebra
for monospace two-dimensional mathematical output.
+
tex
for TeX output.
+
script
for IBM Script Formula Format output.
+
+
+
+
+
For example, issue )set output fortran on to turn on FORTRAN
+format and issue )set output fortran off to turn it off. By
+default, algebra is on and all others are off.
+set output fortran When output is started, it is sent to the
+screen. To send the output to a file, give the file name without
+output formats:sending to file directory or extension. Axiom
+appends a file extension depending on the kind of output being
+produced.
+
+
+
+
Issue this to redirect FORTRAN output to, for example, the file
+linalg.sfort.
+
+
+
+
+
+
+)set output fortran linalg
+
+
+
+
+
+
+
+ FORTRAN output will be written to file linalg.sfort .
+
+
+
+
+
You must also turn on the creation of FORTRAN output.
+The above just says where it goes if it is created.
+
+
+
+
+
+
+)set output fortran on
+
+
+
+
+
+
In what directory is this output placed? It goes into the directory
+from which you started Axiom, or if you have used the )cd
+system command, the one that you specified with )cd.
+cd You should use )cd before you send the output to the file.
+
+
+
+
You can always direct output back to the screen by issuing this.
+output formats:sending to screen
+
+
+
+
+
+
+)set output fortran console
+
+
+
+
+
+
Let's make sure FORTRAN formatting is off so that nothing we
+do from now on produces FORTRAN output.
+
+
+
+
+
+
+)set output fortran off
+
+
+
+
+
+
We also delete the demonstrated output file we created.
+
+
+
+
+
+
+)system rm linalg.sfort
+
+
+
+
+
+
You can abbreviate the words ``on,'' ``off,'' and
+``console'' to the minimal number of characters needed to distinguish
+them. Because of this, you cannot send output to files called
+on.sfort, off.sfort, of.sfort, console.sfort, consol.sfort and so on.
+
+
+
+
The width of the output on the page is set by output
+formats:line length)set output length for all formats except
+FORTRAN. set output length Use )set fortran fortlength
+to change the FORTRAN line length from its default value of .
+
This is the default output format for Axiom.
+It is usually on when you start the system.
+set output algebra
+output formats:monospace 2D
+monospace 2D output format
+
+
+
+
If it is not, issue this.
+
+
+
+
+
+
+)set output algebra on
+
+
+
+
+
+
Since the printed version of this book (as opposed to the HyperDoc
+version) shows output produced by the TeX output formatter, let us
+temporarily turn off TeX output.
+
+
+
+
+
+
+)set output tex off
+
+
+
+
+
+
Here is an example of what it looks like.
+
+
+
+
+
+
+matrix [ [i*x**i + j*%i*y**j for i in 1..2] for j in 3..4]
+
+
+
+
+
+
+
+
+ + 3 3 2+
+ |3%i y + x 3%i y + 2x |
+ (1) | |
+ | 4 4 2|
+ +4%i y + x 4%i y + 2x +
+
+
+
+
+
+
+Type: Matrix Polynomial Complex Integer
+
+
+
+
+
Issue this to turn off this kind of formatting.
+
+
+
+
+
+
+)set output algebra off
+
+
+
+
+
+
Turn TeX output on again.
+
+
+
+
+
+
+)set output tex on
+
+
+
+
+
+
The characters used for the matrix brackets above are rather ugly.
+You get this character set when you issue character set
+)set output characters plain. set output characters This
+character set should be used when you are running on a machine that
+does not support the IBM extended ASCII character set. If you are
+running on an IBM workstation, for example, issue
+)set output characters default to get better looking output.
+
Axiom can produce TeX output for your output formats:TeX
+@{TeX} expressions. TeX output format @{TeX} output format
+The output is produced using macros from the LaTeX document
+preparation system by Leslie Lamport\cite{1}. The printed version
+of this book was produced using this formatter.
+
+
+
+
To turn on TeX output formatting, issue this.
+set output tex
+
+
+
+
+
+
+)set output tex on
+
+
+
+
+
+
Here is an example of its output.
+
+
+
+
+
+matrix [ [i*x**i + j*%i*y**j for i in 1..2] for j in 3..4]
+
To turn TeX output formatting off, issue
+)set output tex off.
+The LaTeX macros in the output generated by Axiom
+are all standard except for the following definitions:
+
In addition to turning FORTRAN output on and off and stating where the
+output formats:FORTRAN output should be placed, there are many
+options that control the FORTRAN output format appearance of
+the generated code. In this section we describe some of the basic
+options. Issue )set fortran to see a full list with their
+current settings.
+
+
+
+
The output FORTRAN expression usually begins in column 7. If the
+expression needs more than one line, the ampersand character &
+is used in column 6. Since some versions of FORTRAN have restrictions
+on the number of lines per statement, Axiom breaks long expressions
+into segments with a maximum of 1320 characters (20 lines of 66
+characters) per segment. set fortran If you want to change
+this, say, to 660 characters, issue the system command
+set fortran explength)set fortran explength 660.
+FORTRAN output format:breaking into multiple statements
+You can turn off the line breaking by issuing )set fortran segment off.
+set fortran segment Various code optimization levels are available.
+
+
+
+
FORTRAN output is produced after you issue this.
+set output fortran
+
+
+
+
+
+
+)set output fortran on
+
+
+
+
+
+
For the initial examples, we set the optimization level to 0, which is the
+lowest level.
+set fortran optlevel
+
+
+
+
+
+
+)set fortran optlevel 0
+
+
+
+
+
+
The output is usually in columns 7 through 72, although fewer columns
+are used in the following examples so that the output
+FORTRAN output format:line length
+fits nicely on the page.
+
+
+
+
+
+
+)set fortran fortlength 60
+
+
+
+
+
+
By default, the output goes to the screen and is displayed before the
+standard Axiom two-dimensional output. In this example, an assignment
+to the variable was generated because this is the result of step 1.
+
+
+
+
+
+
+(x+y)**3
+
+
+
+
+
+
+
+ R1=y**3+3*x*y*y+3*x*x*y+x**3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
Here is an example that illustrates the line breaking.
+
Note in the above examples that integers are generally converted to
+FORTRAN output format:integers vs. floats floating point
+numbers, except in exponents. This is the default behavior but can be
+turned off by issuing )set fortran ints2floats off.
+set fortran ints2floats The rules governing when the conversion
+is done are:
+
+
+
+
+
+
+ If an integer is an exponent, convert it to a floating point
+number if it is greater than 32767 in absolute value, otherwise leave it
+as an integer.
+
+
Convert all other integers in an expression to floating point numbers.
+
+
+
+
+
These rules only govern integers in expressions. Numbers generated by
+Axiom for statements are also integers.
+
+
+
+
To set the type of generated FORTRAN data,
+FORTRAN output format:data types
+use one of the following:
+
This changes the precision to DOUBLE. set fortran
+precision double Substitute single for double
+FORTRAN output format:precision to return to single precision.
+set fortran precision single
+
+
+
+
+
+
+
+)set fortran precision double
+
+
+
+
+
+
Complex constants display the precision.
+
+
+
+
+
+
+2.3 + 5.6*%i
+
+
+
+
+
+
+
+ R5=(2.3D0,5.6D0)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Float
+
+
+
+
+
The function names that Axiom generates depend on the chosen precision.
+
+
+
+
+
+
+sin %e
+
+
+
+
+
+
+
+
+
+
+
+
+ R6=DSIN(DEXP(1))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
Reset the precision to single and look at these two examples again.
+
+
+
+
+
+
+)set fortran precision single
+
+
+
+
+
+
+
+
+
+2.3 + 5.6*%i
+
+
+
+
+
+
+
+ R7=(2.3,5.6)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Float
+
+
+
+
+
+
+
+
+sin %e
+
+
+
+
+
+
+
+
+
+
+
+
+ R8=SIN(EXP(1))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
Expressions that look like lists, streams, sets or matrices cause
+array code to be generated.
+
+
+
+
+
+
+[x+1,y+1,z+1]
+
+
+
+
+
+
+
+ T1(1)=x+1
+ T1(2)=y+1
+ T1(3)=z+1
+ R9=T1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Polynomial Integer
+
+
+
+
+
+
A temporary variable is generated to be the name of the array.
+FORTRAN output format:arrays This may have to be changed in
+your particular application.
+
In this chapter we look at some of the basic components of the Axiom
+language that you can use interactively. We show how to create a block of expressions, how to form loops and list iterations, how to
+modify the sequential evaluation of a block and how to use
+if-then-else to evaluate parts of your program conditionally. We
+suggest you first read the boxed material in each section and then
+proceed to a more thorough reading of the chapter.
+
A variable in Axiom refers to a value. A variable has a name
+beginning with an uppercase or lowercase alphabetic character,
+``%'', or ``!''. Successive characters (if any) can be any of
+the above, digits, or ``?''. Case is distinguished. The
+following are all examples of valid, distinct variable names:
+
The ``:='' operator is the immediate assignment operator.
+assignment:immediate Use it to associate a value with a
+variable. immediate assignment
+
+
+
+
+
+
+
+
+
+
+
+
+
The syntax for immediate assignment for a single variable is
+
+
+
+
+
+
+
+
variableexpression
+
+
+
+
+
+
+
+
The value returned by an immediate assignment is the value of
+expression.
+
+
+
+
+
+
+
+
+
+
The right-hand side of the expression is evaluated, yielding .
+This value is then assigned to .
+
+
+
+
+
+
+a := 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The right-hand side of the expression is evaluated, yielding .
+This value is then assigned to . Thus and both have the
+value after the sequence of assignments.
+
+
+
+
+
+
+b := a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
What is the value of if is assigned the value ?
+
+
+
+
+
+
+a := 2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
As you see, the value of is left unchanged.
+
+
+
+
+
+
+b
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
This is what we mean when we say this kind of assignment is immediate; has no dependency on after the initial assignment.
+This is the usual notion of assignment found in programming languages
+such as C, C language:assignment PASCAL
+PASCAL:assignment and FORTRAN. FORTRAN:assignment
+
+
+
+
Axiom provides delayed assignment with ``==''.
+assignment:delayed This implements a delayed
+assignment delayed evaluation of the right-hand side and dependency
+checking.
+
+
+
+
+
+
+
+
+
+
+
+
+
The syntax for delayed assignment is
+
+
+
+
+
+
+
+
variableexpression
+
+
+
+
+
+
+
+
The value returned by a delayed assignment is the unique value of Void.
+
+
+
+
+
+
+
+
+
+
Using and as above, these are the corresponding delayed assignments.
+
+
+
+
+
+
+a == 1
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+b == a
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
The right-hand side of each delayed assignment is left unevaluated
+until the variables on the left-hand sides are evaluated. Therefore
+this evaluation and ...
+
+
+
+
+
+
+a
+
+
+
+
+
+
+
+Compiling body of rule a to compute value of type PositiveInteger
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
this evaluation seem the same as before.
+
+
+
+
+
+
+b
+
+
+
+
+
+
+
+Compiling body of rule b to compute value of type PositiveInteger
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
If we change to
+
+
+
+
+
+
+a == 2
+
+
+
+
+
+
+
+ Compiled code for a has been cleared.
+ Compiled code for b has been cleared.
+ 1 old definition(s) deleted for function or rule a
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
then evaluates to , as expected, but
+
+
+
+
+
+
+a
+
+
+
+
+
+
+
+Compiling body of rule a to compute value of type PositiveInteger
+
++++ |*0;a;1;G82322| redefined
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
the value of reflects the change to .
+
+
+
+
+
+
+b
+
+
+
+
+
+
+
+Compiling body of rule b to compute value of type PositiveInteger
+
++++ |*0;b;1;G82322| redefined
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
It is possible to set several variables at the same time
+assignment:multiple immediate by using multiple
+immediate assignment a tuple of variables and a tuple of
+expressions. Note that a tuple is a collection of things
+separated by commas, often surrounded by parentheses.
+
+
+
+
+
+
+
+
+
+
+
+
+
The syntax for multiple immediate assignments is
+
+
+
+
+
+
+
+
( , , ...,
+ ) := ( , ,
+..., )
+
+
+
+
+
+
+
+
The value returned by an immediate assignment is the value of
+ .
+
+
+
+
+
+
+
+
+
+
This sets to and to .
+
+
+
+
+
+
+(x,y) := (1,2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Multiple immediate assigments are parallel in the sense that the
+expressions on the right are all evaluated before any assignments on
+the left are made. However, the order of evaluation of these
+expressions is undefined.
+
+
+
+
You can use multiple immediate assignment to swap the values held by
+variables.
+
+
+
+
+
+
+(x,y) := (y,x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
has the previous value of .
+
+
+
+
+
+
+x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
has the previous value of .
+
+
+
+
+
+
+y
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
There is no syntactic form for multiple delayed assignments. See the
+discussion in section ugUserDelay
+about how Axiom differentiates between delayed assignments and user
+functions of no arguments.
+
A block is a sequence of expressions evaluated in the order that
+they appear, except as modified by control expressions such as
+break, breakreturn, returniterate and
+iterateif-then-else constructions. The value of a block is
+the value of the expression last evaluated in the block.
+
+
+
+
To leave a block early, use ``=>''. For example, . The
+expression before the ``=>'' must evaluate to true or false.
+The expression following the ``=>'' is the return value for the block.
+
+
+
+
A block can be constructed in two ways:
+
+
+
+
+
+
+ the expressions can be separated by semicolons
+and the resulting expression surrounded by parentheses, and
+
+
the expressions can be written on succeeding lines with each line
+indented the same number of spaces (which must be greater than zero).
+indentation
+A block entered in this form is
+called a pile.
+
+
+
+
+
Only the first form is available if you are entering expressions
+directly to Axiom. Both forms are available in .input files.
+
+
+
+
+
+
+
+
+
+
+
+
+
The syntax for a simple block of expressions entered interactively is
+
+
+
+
+
+
+
+
( ; ; ...;
+ )
+
+
+
+
+
+
+
+
The value returned by a block is the value of an => expression,
+or if no => is encountered.
+
+
+
+
+
+
+
+
+
+
In .input files, blocks can also be written using piles. The
+examples throughout this book are assumed to come from .input files.
+
+
+
+
In this example, we assign a rational number to using a block
+consisting of three expressions. This block is written as a pile.
+Each expression in the pile has the same indentation, in this case two
+spaces to the right of the first line.
+
+
+
+
+
+a :=
+ i := gcd(234,672)
+ i := 3*i**5 - i + 1
+ 1 / i
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
Here is the same block written on one line. This is how you are
+required to enter it at the input prompt.
+
+
+
+
+
+
+a := (i := gcd(234,672); i := 3*i**5 - i + 1; 1 / i)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
Blocks can be used to put several expressions on one line. The value
+returned is that of the last expression.
+
+
+
+
+
+
+(a := 1; b := 2; c := 3; [a,b,c])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
Axiom gives you two ways of writing a block and the preferred way in
+an .input file is to use a pile. file:input Roughly
+speaking, a pile is a block whose constituent expressions are indented
+the same amount. You begin a pile by starting a new line for the
+first expression, indenting it to the right of the previous line. You
+then enter the second expression on a new line, vertically aligning it
+with the first line. And so on. If you need to enter an inner pile,
+further indent its lines to the right of the outer pile. Axiom knows
+where a pile ends. It ends when a subsequent line is indented to the
+left of the pile or the end of the file.
+
+
+
+
Blocks can be used to perform several steps before an assignment
+(immediate or delayed) is made.
+
+
+
+
+
+d :=
+ c := a**2 + b**2
+ sqrt(c * 1.3)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
Blocks can be used in the arguments to functions. (Here is
+assigned .)
+
+
+
+
+
+h := 2.1 +
+ 1.0
+ 3.5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
Here the second argument to eval is , where the value of
+ is computed in the first line of the block starting on the second
+line.
+
+
+
+
+
+eval(x**2 - x*y**2,
+ z := %pi/2.0 - exp(4.1)
+ x = z
+ )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Float
+
+
+
+
+
Blocks can be used in the clauses of if-then-else expressions
+(see ugLangIf ).
+
+
+
+
+
+
+
+if h > 3.1 then 1.0 else (z := cos(h); max(z,0.5))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
This is the pile version of the last block.
+
+
+
+
+
+if h > 3.1 then
+ 1.0
+ else
+ z := cos(h)
+ max(z,0.5)
+
Like many other programming languages, Axiom uses the three keywords
+ifif, thenthen and else
+else to form conditional conditional expressions. The
+else part of the conditional is optional. The expression
+between the if and then keywords is a predicate: an
+expression that evaluates to or is convertible to either true or
+false, that is, a Boolean. Boolean
+
+
+
+
+
+
+
+
+
+
+
+
+
The syntax for conditional expressions is
+
+
+
+
+
+
+
+
if predicate
+then
+else
+
+
+
+
+
+
+
+
where the else part is optional. The
+value returned from a conditional expression is
+ if the predicate evaluates to true and
+ otherwise. If no else clause is given,
+the value is always the unique value of Void.
+
+
+
+
+
+
+
+
+
+
An if-then-else expression always returns a value. If the
+else clause is missing then the entire expression returns the unique
+value of Void. If both clauses are present, the type of the
+value returned by if is obtained by resolving the types of the
+values of the two clauses. See ugTypesResolve for more information.
+
+
+
+
The predicate must evaluate to, or be convertible to, an object of
+type Boolean: true or false. By default, the equal
+sign = creates equation an equation.
+
+
+
+
This is an equation. Equation In particular, it is an object
+of type Equation Polynomial Integer.
+
+
+
+
+
+
+
+x + 1 = y
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Equation Polynomial Integer
+
+
+
+
+
However, for predicates in if expressions, Axiom equality
+testing places a default target type of Boolean on the
+predicate and equality testing is performed. Boolean Thus you
+need not qualify the ``='' in any way. In other contexts you
+may need to tell Axiom that you want to test for equality rather than
+create an equation. In those cases, use ``@'' and a target type
+of Boolean. See section ugTypesPkgCall for more information.
+
+
+
+
The compound symbol meaning ``not equal'' in Axiom is
+inequality testing ``''. _notequal@
+This can be used directly without a package call or a target
+specification. The expression is directly translated
+into not .
+
+
+
+
Many other functions have return values of type Boolean. These
+include ``<'', ``<='', ``>'', ``>='',
+``'' and ``member?''. By convention,
+operations with names ending in ``?'' return Boolean values.
+
+
+
+
The usual rules for piles are suspended for conditional expressions.
+In .input files, the then and else keywords can begin in the
+same column as the corresponding if but may also appear to the
+right. Each of the following styles of writing if-then-else
+expressions is acceptable:
+
+
+
+
+
+if i>0 then output("positive") else output("nonpositive")
+
+if i > 0 then output("positive")
+ else output("nonpositive")
+
+if i > 0 then output("positive")
+else output("nonpositive")
+
+if i > 0
+then output("positive")
+else output("nonpositive")
+
+if i > 0
+ then output("positive")
+ else output("nonpositive")
+
+
+
+
+
A block can follow the then or else keywords. In the following
+two assignments to a, the then and else clauses each are
+followed by two-line piles. The value returned in each is the value
+of the second line.
+
A loop is an expression that contains another expression,
+loop called the loop body, which is to be evaluated zero
+or more loop:body times. All loops contain the repeat
+keyword and return the unique value of Void. Loops can contain
+inner loops to any depth.
+
+
+
+
+
+
+
+
+
+
+
+
+
The most basic loop is of the form
+
+
+
+
+
+
+
+
repeat loopBody
+
+
+
+
+
+
+
+
+
Unless loopBody contains a break or return expression, the
+loop repeats forever. The value returned by the loop is the unique
+value of Void.
+
+
+
+
+
+
+
+
+
+
+
+
+
5.4.1 Compiling vs. Interpreting Loops
+
+
+
+
+
+
Axiom tries to determine completely the type of every object in a loop
+and then to translate the loop body to LISP or even to machine code.
+This translation is called compilation.
+
+
+
+
If Axiom decides that it cannot compile the loop, it issues a
+loop:compilation message stating the problem and then the
+following message:
+
+
+
+
+
+
+
+
We will attempt to step through and interpret the code.
+
+
+
+
+
+
+
+
+
It is still possible that Axiom can evaluate the loop but in interpret-code mode. See section ugUserCompInt where this is discussed in terms
+panic:avoiding of compiling versus interpreting functions.
+
+
+
+
+
+
+
+
+
+
+
+
5.4.2 return in Loops
+
+
+
+
+
+
A return expression is used to exit a function with
+loop:leaving via return a particular value. In particular, if
+a return is in a loop within the return function, the loop
+is terminated whenever the return is evaluated.
+
+
+
+
+
+
+
+
Suppose we start with this.
+
+
+
+
+
+f() ==
+ i := 1
+ repeat
+ if factorial(i) > 1000 then return i
+ i := i + 1
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
When factorial(i) is big enough, control passes from inside the loop
+all the way outside the function, returning the value of (or so we
+think).
+
+
+
+
+
+
+f()
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
What went wrong? Isn't it obvious that this function should return an
+integer? Well, Axiom makes no attempt to analyze the structure of a
+loop to determine if it always returns a value because, in general,
+this is impossible. So Axiom has this simple rule: the type of the
+function is determined by the type of its body, in this case a block.
+The normal value of a block is the value of its last expression, in
+this case, a loop. And the value of every loop is the unique value of
+Void.! So the return type of f is Void.
+
+
+
+
There are two ways to fix this. The best way is for you to tell Axiom
+what the return type of is. You do this by giving a
+declaration f:()->Integer prior to calling for its value. This
+tells Axiom: ``trust me---an integer is returned.'' We'll explain
+more about this in the next chapter. Another clumsy way is to add a
+dummy expression as follows.
+
+
+
+
Since we want an integer, let's stick in a dummy final expression that is
+an integer and will never be evaluated.
+
+
+
+
+
+f() ==
+ i := 1
+ repeat
+ if factorial(i) > 1000 then return i
+ i := i + 1
+ 0
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
When we try f again we get what we wanted. See
+ugUserBlocks for more information.
+
+
+
+
+
+
+
+f()
+
+
+
+
+
+
+
+ Compiling function f with type () -> NonNegativeInteger
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+
+
+
+
+
5.4.3 break in Loops
+
+
+
+
+
+
The break keyword is often more useful break in terminating
+loop:leaving via break a loop. A break causes control to
+transfer to the expression immediately following the loop. As loops
+always return the unique value of Void., you cannot return a
+value with break. That is, break takes no argument.
+
+
+
+
This example is a modification of the last example in the previous
+section ugLangLoopsReturn .
+Instead of using return, we'll use break.
+
+
+
+
+
+
+f() ==
+ i := 1
+ repeat
+ if factorial(i) > 1000 then break
+ i := i + 1
+ i
+
+
+
+
+
+
+ Compiled code for f has been cleared.
+ 1 old definition(s) deleted for function or rule f
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
The loop terminates when factorial(i) gets big enough, the last line
+of the function evaluates to the corresponding ``good'' value of ,
+and the function terminates, returning that value.
+
+
+
+
+
+
+
+f()
+
+
+
+
+
+
+
+ Compiling function f with type () -> PositiveInteger
+
++++ |*0;f;1;G82322| redefined
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
You can only use break to terminate the evaluation of one loop.
+Let's consider a loop within a loop, that is, a loop with a nested
+loop. First, we initialize two counter variables.
+
+
+
+
+
+
+
+(i,j) := (1, 1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Nested loops must have multiple breakloop:nested
+expressions at the appropriate nesting level. How would you rewrite
+this so (i + j) > 10 is only evaluated once?
+
+
+
+
+
+repeat
+ repeat
+ if (i + j) > 10 then break
+ j := j + 1
+ if (i + j) > 10 then break
+ i := i + 1
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+
+
+
+
+
5.4.4 break vs. => in Loop Bodies
+
+
+
+
+
+
Compare the following two loops:
+
+
+
+
+
+i := 1 i := 1
+repeat repeat
+ i := i + 1 i := i + 1
+ i > 3 => i if i > 3 then break
+ output(i) output(i)
+
+
+
+
+
In the example on the left, the values and for are
+displayed but then the ``=>'' does not allow control to reach the
+call to outputoutputOutputForm again. The loop will not
+terminate until you run out of space or interrupt the execution. The
+variable will continue to be incremented because the ``=>'' only
+means to leave the block, not the loop.
+
+
+
+
In the example on the right, upon reaching , the break will be
+executed, and both the block and the loop will terminate. This is one
+of the reasons why both ``=>'' and break are provided. Using a
+while clause (see below) with the ``=>'' while lets you
+simulate the action of break.
+
+
+
+
+
+
+
+
+
+
+
+
5.4.5 More Examples of break
+
+
+
+
+
+
Here we give four examples of repeat loops that terminate when a
+value exceeds a given bound.
+
+
+
+
First, initialize as the loop counter.
+
+
+
+
+
+
+i := 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: NonNegativeInteger
+
+
+
+
+
Here is the first loop. When the square of exceeds , the
+loop terminates.
+
+
+
+
+
+repeat
+ i := i + 1
+ if i**2 > 100 then break
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Upon completion, should have the value .
+
+
+
+
+
+
+i
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: NonNegativeInteger
+
+
+
+
+
Do the same thing except use ``=>'' instead an if-then expression.
+
+
+
+
+
+
+
+i := 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: NonNegativeInteger
+
+
+
+
+
+
+
+repeat
+ i := i + 1
+ i**2 > 100 => break
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+i
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: NonNegativeInteger
+
+
+
+
+
As a third example, we use a simple loop to compute .
+
+
+
+
+
+
+(n, i, f) := (100, 1, 1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Use as the iteration variable and to compute the factorial.
+
+
+
+
+
+repeat
+ if i > n then break
+ f := f * i
+ i := i + 1
+
Next, set row counter and column counter to . Note: if we
+were writing a function, these would all be local variables rather
+than global workspace variables.
+
+
+
+
+
+
+(r, c) := (1, 1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Also, let lastrow and lastcol be the final row and column index.
+
+
+
+
+
+
+
+(lastrow, lastcol) := (nrows(m), ncols(m))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Scan the rows looking for the first negative element. We remark that
+you can reformulate this example in a better, more concise form by
+using a for clause with repeat. See
+ugLangLoopsForIn for more
+information.
+
+
+
+
+
+
+repeat
+ if r > lastrow then break
+ c := 1
+ repeat
+ if c > lastcol then break
+ if elt(m,r,c) < 0 then
+ output [r, c, elt(m,r,c)]
+ r := lastrow
+ break -- don't look any further
+ c := c + 1
+ r := r + 1
+
+ [2,2,- 24]
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+
+
+
+
+
5.4.6 iterate in Loops
+
+
+
+
+
+
Axiom provides an iterate expression that iterate skips over
+the remainder of a loop body and starts the next loop iteration.
+
+
+
+
We first initialize a counter.
+
+
+
+
+
+
+
+i := 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: NonNegativeInteger
+
+
+
+
+
Display the even integers from to .
+
+
+
+
+
+repeat
+ i := i + 1
+ if i > 5 then break
+ if odd?(i) then iterate
+ output(i)
+
+ 2
+ 4
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+
+
+
+
+
5.4.7 while Loops
+
+
+
+
+
+
The repeat in a loop can be modified by adding one or more while
+clauses. while Each clause contains a predicate
+immediately following the while keyword. The predicate is tested
+before the evaluation of the body of the loop. The loop body is
+evaluated whenever the predicates in a while clause are all true.
+
+
+
+
+
+
+
+
+
+
+
+
+
The syntax for a simple loop using while is
+
+
+
+
+
+
+
+
whilepredicaterepeatloopBody
+
+
+
+
+
+
+
+
The predicate is evaluated before loopBody is evaluated.
+A while loop terminates immediately when predicate evaluates
+to false or when a break or return expression is evaluated in
+loopBody. The value returned by the loop is the unique value of
+Void.
+
+
+
+
+
+
+
+
+
+
Here is a simple example of using while in a loop. We first
+initialize the counter.
+
+
+
+
+
+
+i := 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The steps involved in computing this example are
+(1) set to ,
+(2) test the condition and determine that it is not true, and
+(3) do not evaluate the loop body and therefore do not display .
+
+
+
+
+
+while i < 1 repeat
+ output "hello"
+ i := i + 1
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
If you have multiple predicates to be tested use the logical and
+operation to separate them. Axiom evaluates these predicates from
+left to right.
+
+
+
+
+
+
+(x, y) := (1, 1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+while x < 4 and y < 10 repeat
+ output [x,y]
+ x := x + 1
+ y := y + 2
+
+ [1,1]
+ [2,3]
+ [3,5]
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
A break expression can be included in a loop body to terminate a
+loop even if the predicate in any while clauses are not false.
+
+
+
+
+
+
+(x, y) := (1, 1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
This loop has multiple while clauses and the loop terminates
+before any one of their conditions evaluates to false.
+
+
+
+
+
+while x < 4 while y < 10 repeat
+ if x + y > 7 then break
+ output [x,y]
+ x := x + 1
+ y := y + 2
+
+ [1,1]
+ [2,3]
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Here's a different version of the nested loops that looked for the
+first negative element in a matrix.
+
Initialized the row index to and get the number of rows and
+columns. If we were writing a function, these would all be local
+variables.
+
+
+
+
+
+
+r := 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+(lastrow, lastcol) := (nrows(m), ncols(m))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Scan the rows looking for the first negative element.
+
+
+
+
+
+while r <= lastrow repeat
+ c := 1 -- index of first column
+ while c <= lastcol repeat
+ if elt(m,r,c) < 0 then
+ output [r, c, elt(m,r,c)]
+ r := lastrow
+ break -- don't look any further
+ c := c + 1
+ r := r + 1
+
+ [2,2,- 24]
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+
+
+
+
+
5.4.8 for Loops
+
+
+
+
+
+
Axiom provides the forfor and in in keywords in
+repeat loops, allowing you to iterate across all iteration
+elements of a list, or to have a variable take on integral values from
+a lower bound to an upper bound. We shall refer to these modifying
+clauses of repeat loops as for clauses. These clauses can be
+present in addition to while clauses. As with all other types of
+repeat loops, break can break be used to prematurely
+terminate the evaluation of the loop.
+
+
+
+
+
+
+
+
+
+
+
+
+
The syntax for a simple loop using for is
+
+
+
+
+
+
+
+
foriteratorrepeatloopBody
+
+
+
+
+
+
+
+
+
The iterator has several forms. Each form has an end test which
+is evaluated before loopBody is evaluated. A for loop
+terminates immediately when the end test succeeds (evaluates to
+true) or when a break or return expression is evaluated
+in loopBody. The value returned by the loop is the unique value
+of Void.\
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
5.4.9 for i in n..m repeat
+
+
+
+
+
+
If forfor is followed by a variable name, the in
+in keyword and then an integer segment of the form ,
+segment the end test for this loop is the predicate .
+The body of the loop is evaluated times if this number is
+greater than 0. If this number is less than or equal to 0, the loop
+body is not evaluated at all.
+
+
+
+
The variable has the value for successive iterations
+of the loop body.The loop variable is a local variable
+within the loop body: its value is not available outside the loop body
+and its value and type within the loop body completely mask any outer
+definition of a variable with the same name.
+
+
+
+
This loop prints the values of
+ , , and :
+
+
+
+
+
+
+for i in 10..12 repeat output(i**3)
+
+
+
+
+
+
+
+ 1000
+ 1331
+ 1728
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Here is a sample list.
+
+
+
+
+
+
+a := [1,2,3]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
Iterate across this list, using ``.'' to access the elements of
+a list and the ``#'' operation to count its elements.
+
+
+
+
+
+
+
+for i in 1.. #a repeat output(a.i)
+
+
+
+
+
+
+
+ 1
+ 2
+ 3
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
This type of iteration is applicable to anything that uses ``.''.
+You can also use it with functions that use indices to extract elements.
+
+
+
+
Define to be a matrix.
+
+
+
+
+
+
+m := matrix [ [1,2],[4,3],[9,0] ]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Integer
+
+
+
+
+
Display the rows of .
+
+
+
+
+
+
+for i in 1..nrows(m) repeat output row(m,i)
+
+
+
+
+
+
+
+ [1,2]
+ [4,3]
+ [9,0]
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
You can use iterate with for-loops.iterate
+
+
+
+
Display the even integers in a segment.
+
+
+
+
+
+for i in 1..5 repeat
+ if odd?(i) then iterate
+ output(i)
+
+ 2
+ 4
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
See section SegmentXmpPage for
+more information about segments.
+
+
+
+
+
+
+
+
+
+
+
+
5.4.10 for i in n..m by s repeat
+
+
+
+
+
+
By default, the difference between values taken on by a variable in
+loops such as for i in n..m repeat ... is . It is possible to
+supply another, possibly negative, step value by using the by
+by keyword along with for and in . Like the upper and
+lower bounds, the step value following the by keyword must be an
+integer. Note that the loop for i in 1..2 by 0 repeat output(i)
+will not terminate by itself, as the step value does not change the
+index from its initial value of .
+
+
+
+
This expression displays the odd integers between two bounds.
+
+
+
+
+
+
+for i in 1..5 by 2 repeat output(i)
+
+
+
+
+
+
+
+ 1
+ 3
+ 5
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Use this to display the numbers in reverse order.
+
+
+
+
+
+
+for i in 5..1 by -2 repeat output(i)
+
+
+
+
+
+
+
+ 5
+ 3
+ 1
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+
+
+
+
+
5.4.11 for i in n.. repeat
+
+
+
+
+
+
If the value after the ``..'' is omitted, the loop has no end test.
+A potentially infinite loop is thus created. The variable is given
+the successive values and the loop is terminated
+only if a break or return expression is evaluated in the loop
+body. However you may also add some other modifying clause on the
+repeat (for example, a while clause) to stop the loop.
+
+
+
+
This loop displays the integers greater than or equal to
+and less than the first prime greater than .
+
+
+
+
+
+
+for i in 15.. while not prime?(i) repeat output(i)
+
+
+
+
+
+
+
+ 15
+ 16
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+
+
+
+
+
5.4.12 for x in l repeat
+
+
+
+
+
+
Another variant of the for loop has the form:
+
+
+
+
+
+
+
+
for x in list repeat loopBody
+
+
+
+
+
+
+
+
+
This form is used when you want to iterate directly over the elements
+of a list. In this form of the for loop, the variable x takes on
+the value of each successive element in l. The end test is most
+simply stated in English: ``are there no more x in l?''
+
+
+
+
If l is this list,
+
+
+
+
+
+
+l := [0,-5,3]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
display all elements of l, one per line.
+
+
+
+
+
+
+for x in l repeat output(x)
+
+
+
+
+
+
+
+ 0
+ - 5
+ 3
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Since the list constructing expression expand[n..m] creates the
+list . Note that this list is empty if . You
+might be tempted to think that the loops
+
+
+
+
+
+for i in n..m repeat output(i)
+
+
+
+
+
and
+
+
+
+
+
+for x in expand [n..m] repeat output(x)
+
+
+
+
+
are equivalent. The second form first creates the list
+expand[n..m] (no matter how large it might be) and then does
+the iteration. The first form potentially runs in much less space, as
+the index variable is simply incremented once per loop and the
+list is not actually created. Using the first form is much more
+efficient.
+
+
+
+
Of course, sometimes you really want to iterate across a specific list.
+This displays each of the factors of .
+
+
+
+
+
+
+for f in factors(factor(2400000)) repeat output(f)
+
+
A for loop can be followed by a ``|'' and then a predicate. The
+predicate qualifies the use of the values from the iterator following
+the for. Think of the vertical bar ``|'' as the phrase ``such
+that.''
+
+
+
+
This loop expression prints out the integers in the given segment
+such that is odd.
+
+
+
+
+
+
+for n in 0..4 | odd? n repeat output n
+
+
+
+
+
+
+
+ 1
+ 3
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+
+
+
+
+
+
A for loop can also be written
+
+
+
+
+
which is equivalent to:
+
+
+
+
+
+
+
+
+
+
+
The predicate need not refer only to the variable in the for clause:
+any variable in an outer scope can be part of the predicate.
+
+
+
+
In this example, the predicate on the inner for loop uses from
+the outer loop and the from the foriteration:nested
+clause that it directly modifies.
+
+
+
+
+
+for i in 1..50 repeat
+ for j in 1..50 | factorial(i+j) < 25 repeat
+ output [i,j]
+
+ [1,1]
+ [1,2]
+ [1,3]
+ [2,1]
+ [2,2]
+ [3,1]
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+
+
+
+
+
5.4.14 Parallel Iteration
+
+
+
+
+
+
The last example of the previous section
+ugLangLoopsForInPred
+gives an example of nested iteration: a loop is contained
+iteration:nested in another loop. iteration:parallel
+Sometimes you want to iterate across two lists in parallel, or perhaps
+you want to traverse a list while incrementing a variable.
+
+
+
+
+
+
+
+
+
+
+
+
+
The general syntax of a repeat loop is
+
+where each iterator is either a for or a while clause. The
+loop terminates immediately when the end test of any iterator
+succeeds or when a break or return expression is evaluated in loopBody. The value returned by the loop is the unique value of Void.
+
+
+
+
+
+
+
+
+
+
Here we write a loop to iterate across two lists, computing the sum of
+the pairwise product of elements. Here is the first list.
+
+
+
+
+
+
+l := [1,3,5,7]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
And the second.
+
+
+
+
+
+
+m := [100,200]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
The initial value of the sum counter.
+
+
+
+
+
+
+sum := 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: NonNegativeInteger
+
+
+
+
+
The last two elements of are not used in the calculation because
+ has two fewer elements than .
+
+
+
+
+
+for x in l for y in m repeat
+ sum := sum + x*y
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Display the ``dot product.''
+
+
+
+
+
+
+sum
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: NonNegativeInteger
+
+
+
+
+
Next, we write a loop to compute the sum of the products of the loop
+elements with their positions in the loop.
+
+
+
+
+
+
+l := [2,3,5,7,11,13,17,19,23,29,31,37]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
The initial sum.
+
+
+
+
+
+
+sum := 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: NonNegativeInteger
+
+
+
+
+
Here looping stops when the list is exhausted, even though
+the specifies no terminating condition.
+
+
+
+
+
+
+
+for i in 0.. for x in l repeat sum := i * x
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Display this weighted sum.
+
+
+
+
+
+
+sum
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: NonNegativeInteger
+
+
+
+
+
When ``|'' is used to qualify any of the for clauses in a parallel
+iteration, the variables in the predicates can be from an outer scope
+or from a for clause in or to the left of a modified clause.
+
+
+
+
This is correct:
+
+
+
+
+
+
+
+
+
+
+for i in 1..10 repeat
+ for j in 200..300 | odd? (i+j) repeat
+ output [i,j]
+
+
+
+
+
This is not correct since the variable has not been defined
+outside the inner loop.
+
+
+
+
+
+for i in 1..10 | odd? (i+j) repeat -- wrong, j not defined
+ for j in 200..300 repeat
+ output [i,j]
+
+
+
+
+
+
+
+
+
+
+
+
+
5.4.15 Mixing Loop Modifiers
+
+
+
+
+
+
This example shows that it is possible to mix several of the
+loop:mixing modifiers forms of repeat modifying clauses on a loop.
+
+
+
+
+
+for i in 1..10
+ for j in 151..160 | odd? j
+ while i + j < 160 repeat
+ output [i,j]
+
+ [1,151]
+ [3,153]
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Here are useful rules for composing loop expressions:
+
+
+
+
+
+
+ while predicates can only refer to variables that
+are global (or in an outer scope)
+or that are defined in for clauses to the left of the
+predicate.
+
+
A ``such that'' predicate (something following ``|'')
+must directly follow a for clause and can only refer to
+variables that are global (or in an outer scope)
+or defined in the modified for clause
+or any for clause to the left.
+
All of what we did for loops in
+ugLangLoopsiteration
+can be transformed into expressions that create lists
+list:created by iterator and streams. stream:created
+by iterator The repeat, break or iterate words are not used but
+all the other ideas carry over. Before we give you the general rule,
+here are some examples which give you the idea.
+
+
+
+
This creates a simple list of the integers from to .
+
+
+
+
+
+
+list := [i for i in 1..10]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
Create a stream of the integers greater than or equal to .
+
+
+
+
+
+
+stream := [i for i in 1..]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream PositiveInteger
+
+
+
+
+
This is a list of the prime integers between and , inclusive.
+
+
+
+
+
+
+[i for i in 1..10 | prime? i]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
This is a stream of the prime integers greater than or equal to .
+
+
+
+
+
+
+[i for i in 1.. | prime? i]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream PositiveInteger
+
+
+
+
+
This is a list of the integers between and , inclusive, whose
+squares are less than .
+
+
+
+
+
+
+[i for i in 1..10 while i*i < 700]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
This is a stream of the integers greater than or equal to
+whose squares are less than .
+
+
+
+
+
+
+[i for i in 1.. while i*i < 700]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream PositiveInteger
+
+
+
+
+
Here is the general rule.
+collection
+
+
+
+
+
+
+
+
+
+
+
+
+
The general syntax of a collection is
+
+
+
+
+
+
+
+
[ collectExpression
+ ... ]
+
+
+
+
+
+
+
+
+
where each is either a for or a while
+clause. The loop terminates immediately when the end test of any
+ succeeds or when a return expression is
+evaluated in collectExpression. The value returned by the
+collection is either a list or a stream of elements, one for each
+iteration of the collectExpression.
+
+
+
+
+
+
+
+
+
+
Be careful when you use while
+stream:using while @{using while}
+to create a stream. By default, Axiom tries to compute and
+display the first ten elements of a stream. If the while condition
+is not satisfied quickly, Axiom can spend a long (possibly infinite)
+time trying to compute stream:number of elements computed the
+elements. Use )set streams calculate to change the default to
+something else. set streams calculate This also affects the
+number of terms computed and displayed for power series. For the
+purposes of this book, we have used this system command to display
+fewer than ten terms.
+
+
+
+
Use nested iterators to create lists of iteration:nested lists
+which can then be given as an argument to matrix.
+
+
+
+
+
+
+matrix [ [x**i+j for i in 1..3] for j in 10..12]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Polynomial Integer
+
+
+
+
+
You can also create lists of streams, streams of lists and streams of
+streams. Here is a stream of streams.
+
+
+
+
+
+
+[ [i/j for i in j+1..] for j in 1..]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Stream Fraction Integer
+
+
+
+
+
You can use parallel iteration across lists and streams to create
+iteration:parallel new lists.
+
+
+
+
+
+
+[i/j for i in 3.. by 10 for j in 2..]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Fraction Integer
+
+
+
+
+
Iteration stops if the end of a list or stream is reached.
+
+
+
+
+
+
+[i**j for i in 1..7 for j in 2.. ]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Integer
+
+
+
+
+
As with loops, you can combine these modifiers to make very
+complicated conditions.
+
+
+
+
+
+
+[ [ [i,j] for i in 10..15 | prime? i] for j in 17..22 | j = squareFreePart j]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List List List PositiveInteger
+
+
+
+
+
See List
+(section ListXmpPage ) and Stream
+(section StreamXmpPage )
+for more information on creating and
+manipulating lists and streams, respectively.
+
We conclude this chapter with an example of the creation and
+manipulation of infinite streams of prime integers. This might be
+useful for experiments with numbers or other applications where you
+are using sequences of primes over and over again. As for all
+streams, the stream of primes is only computed as far out as you need.
+Once computed, however, all the primes up to that point are saved for
+future reference.
+
+
+
+
Two useful operations provided by the Axiom library are
+prime?prime?IntegerPrimesPackage and
+nextPrimenextPrimeIntegerPrimesPackage. A straight-forward way
+to create a stream of prime numbers is to start with the stream of
+positive integers and filter out those that are prime.
+
+
+
+
Create a stream of primes.
+
+
+
+
+
+
+primes : Stream Integer := [i for i in 2.. | prime? i]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Integer
+
+
+
+
+
A more elegant way, however, is to use the
+generategenerateStream operation from Stream. Given an
+initial value and a function , generategenerateStream
+constructs the stream . This function gives
+you the quickest method of getting the stream of primes.
+
+
+
+
This is how you use generategenerateStream to generate an
+infinite stream of primes.
+
+
+
+
+
+
+primes := generate(nextPrime,2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Integer
+
+
+
+
+
Once the stream is generated, you might only be interested in primes
+starting at a particular value.
+
+
+
+
+
+
+smallPrimes := [p for p in primes | p > 1000]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Integer
+
+
+
+
+
Here are the first 11 primes greater than 1000.
+
+
+
+
+
+
+[p for p in smallPrimes for i in 1..11]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Integer
+
+
+
+
+
Here is a stream of primes between 1000 and 1200.
+
+
+
+
+
+
+[p for p in smallPrimes while p < 1200]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Integer
+
+
+
+
+
To get these expanded into a finite stream, you call
+completecompleteStream on the stream.
+
+
+
+
+
+
+complete %
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Integer
+
+
+
+
+
Twin primes are consecutive odd number pairs which are prime.
+Here is the stream of twin primes.
+
+
+
+
+
+
+twinPrimes := [ [p,p+2] for p in primes | prime?(p + 2)]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream List Integer
+
+
+
+
+
Since we already have the primes computed we can avoid the call to
+prime?prime?IntegerPrimesPackage by using a double
+iteration. This time we'll just generate a stream of the first of the
+twin primes.
+
+
+
+
+
+
+firstOfTwins:= [p for p in primes for q in rest primes | q=p+2]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Integer
+
+
+
+
+
Let's try to compute the infinite stream of triplet primes, the set of
+primes such that are primes. For example,
+is a triple prime. We could do this by a triple for iteration. A
+more economical way is to use firstOfTwins. This time however,
+put a semicolon at the end of the line.
+
+
+
+
Create the stream of firstTriplets. Put a semicolon at the end so
+that no elements are computed.
+
+
+
+
+
+
+firstTriplets := [p for p in firstOfTwins for q in rest firstOfTwins | q = p+2];
+
+
+
+
+
+
+
+Type: Stream Integer
+
+
+
+
+
What happened? As you know, by default Axiom displays the first ten
+elements of a stream when you first display it. And, therefore, it
+needs to compute them! If you want no elements computed, just
+terminate the expression by a semicolon (``;''). The semi-colon
+prevents the display of the result of evaluating the expression.
+Since no stream elements are needed for display (or anything else, so
+far), none are computed.
+
+
+
+
Compute the first triplet prime.
+
+
+
+
+
+
+firstTriplets.1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
If you want to compute another, just ask for it. But wait a second!
+Given three consecutive odd integers, one of them must be divisible by
+ . Thus there is only one triplet prime. But suppose that you did not
+know this and wanted to know what was the tenth triplet prime.
+
+
+
+
+
+firstTriples.10
+
+
+
+
+
To compute the tenth triplet prime, Axiom first must compute the
+second, the third, and so on. But since there isn't even a second
+triplet prime, Axiom will compute forever. Nonetheless, this effort
+can produce a useful result. After waiting a bit, hit Ctrl-c.
+The system responds as follows.
+
+
+
+
+
+ >> System error:
+ Console interrupt.
+ You are being returned to the top level of
+ the interpreter.
+
+
+
+
+
If you want to know how many primes have been computed, type:
+
+
+
+
+
+numberOfComputedEntries primes
+
+
+
+
+
and, for this discussion, let's say that the result is .
+How big is the -th prime?
+
+
+
+
+
+
+primes.2045
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
What you have learned is that there are no triplet primes between 5
+and 17837. Although this result is well known (some might even say
+trivial), there are many experiments you could make where the result
+is not known. What you see here is a paradigm for testing of
+hypotheses. Here our hypothesis could have been: ``there is more than
+one triplet prime.'' We have tested this hypothesis for 17837 cases.
+With streams, you can let your machine run, interrupt it to see how
+far it has progressed, then start it up and let it continue from where
+it left off.
+
In this chapter we show you how to write functions and macros,
+and we explain how Axiom looks for and applies them.
+We show some simple one-line examples of functions, together
+with larger ones that are defined piece-by-piece or through the use of
+piles.
+
A function is a program to perform some function:vs. macro
+computation. macro:vs. function Most functions have names so
+that it is easy to refer to them. A simple example of a function is
+one named absabsInteger which computes the absolute value
+of an integer.
+
+
+
+
This is a use of the ``absolute value'' library function for integers.
+
+
+
+
+
+
+abs(-8)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
This is an unnamed function that does the same thing, using the
+``maps-to'' syntax +-> that we discuss in
+section ugUserAnon .
+
+
+
+
+
+
+(x +-> if x < 0 then -x else x)(-8)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Functions can be used alone or serve as the building blocks for larger
+programs. Usually they return a value that you might want to use in
+the next stage of a computation, but not always (for example, see
+ExitXmpPage and VoidXmpPage
+). They may also read data from your
+keyboard, move information from one place to another, or format and
+display results on your screen.
+
+
+
+
In Axiom, as in mathematics, functions function:parameters are
+usually parameterized. Each time you call (some people say
+apply or invoke) a function, you give parameters to a
+function values to the parameters (variables). Such a value is
+called an argument of function:arguments the function.
+Axiom uses the arguments for the computation. In this way you get
+different results depending on what you ``feed'' the function.
+
+
+
+
Functions can have local variables or refer to global variables in the
+workspace. Axiom can often compile functions so that they execute
+very efficiently. Functions can be passed as arguments to other
+functions.
+
+
+
+
Macros are textual substitutions. They are used to clarify the
+meaning of constants or expressions and to be templates for frequently
+used expressions. Macros can be parameterized but they are not
+objects that can be passed as arguments to functions. In effect,
+macros are extensions to the Axiom expression parser.
+
When possible, Axiom completely determines the type of every object in
+a function, then translates the function definition to Common Lisp or
+to machine code (see the next section). This translation,
+function:compiler called compilation, happens the first time
+you call the function and results in a computational delay.
+Subsequent function calls with the same argument types use the
+compiled version of the code without delay.
+
+
+
+
If Axiom cannot determine the type of everything, the function may
+still be executed function:interpretation but
+interpret-code mode in interpret-code mode: each statement in
+the function is analyzed and executed as the control flow indicates.
+This process is slower than executing a compiled function, but it
+allows the execution of code that may involve objects whose types
+change.
+
+
+
+
+
+
+
+
+
+
+
+
+
If Axiom decides that it cannot compile the code, it issues a message
+stating the problem and then the following message:
+
+
+
+
+
+
+
+
We will attempt to step through and interpret the code.
+
+
+
+
+
+
+
+
+
This is not a time to panic. panic:avoiding Rather, it just
+means that what you gave to Axiom is somehow ambiguous: either it is
+not specific enough to be analyzed completely, or it is beyond Axiom's
+present interactive compilation abilities.
+
+
+
+
+
+
+
+
+
+
This function runs in interpret-code mode, but it does not compile.
+
+
+
+
+
+varPolys(vars) ==
+ for var in vars repeat
+ output(1 :: UnivariatePolynomial(var,Integer))
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
For equal to , this function displays three times.
+
+
+
+
+
+
+varPolys ['x,'y,'z]
+
+
+
+
+
+
+
+Cannot compile conversion for types involving local variables.
+ In particular, could not compile the expression involving ::
+ UnivariatePolynomial(var,Integer)
+ AXIOM will attempt to step through and interpret the code.
+ 1
+ 1
+ 1
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
The type of the argument to output changes in each iteration, so
+Axiom cannot compile the function. In this case, even the inner loop
+by itself would have a problem:
+
+
+
+
+
+for var in ['x,'y,'z] repeat
+ output(1 :: UnivariatePolynomial(var,Integer))
+
+
+
+
+
+
+Cannot compile conversion for types involving local variables.
+ In particular, could not compile the expression involving ::
+ UnivariatePolynomial(var,Integer)
+ AXIOM will attempt to step through and interpret the code.
+ 1
+ 1
+ 1
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Sometimes you can help a function to compile by using an extra
+conversion or by using . pretend See
+ugTypesSubdomains for details.
+
+
+
+
When a function is compilable, you have the choice of whether it is
+compiled to Common Lisp and then interpreted by the Common Lisp
+interpreter or then further compiled from Common Lisp to machine code.
+machine code The option is controlled via
+)set functions compile.
+set function compile Issue )set functions compile on
+to compile all the way to machine code. With the default
+setting )set functions compile off, Axiom has its Common Lisp
+code interpreted because the overhead of further compilation is larger
+than the run-time of most of the functions our users have defined.
+You may find that selectively turning this option on and off will
+performance give you the best performance in your particular
+application. For example, if you are writing functions for graphics
+applications where hundreds of points are being computed, it is almost
+certainly true that you will get the best performance by issuing
+)set functions compile on.
+
To move beyond functions defined in one line, we introduce in this
+section functions that are defined piece-by-piece. That is, we say
+``use this definition when the argument is such-and-such and use this
+other definition when the argument is that-and-that.''
+
+
+
+
+
+
+
6.11.1 A Basic Example
+
+
+
+
+
+
There are many other ways to define a factorial function for
+nonnegative integers. You might
+function:piece-wise definition
+say piece-wise function definition factorial of
+ is , otherwise factorial of is times factorial of
+. Here is one way to do this in Axiom.
+
+
+
+
Here is the value for .
+
+
+
+
+
+
+fact(0) == 1
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Here is the value for . The vertical bar ``|'' means ``such
+that''. such that
+
+
+
+
+
+
+fact(n | n > 0) == n * fact(n - 1)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
What is the value for ?
+
+
+
+
+
+
+fact(3)
+
+
+
+
+
+
+
+ Compiling function fact with type Integer -> Integer
+ Compiling function fact as a recurrence relation.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
What is the value for ?
+
+
+
+
+
+
+fact(-3)
+
+
+
+
+
+
+
+ You did not define fact for argument -3 .
+
+
+
+
+
Now for a second definition. Here is the value for .
+
+
+
+
+
+
+facto(0) == 1
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Give an error message if .
+
+
+
+
+
+
+facto(n | n < 0) == error "arguments to facto must be non-negative"
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Here is the value otherwise.
+
+
+
+
+
+
+facto(n) == n * facto(n - 1)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
What is the value for ?
+
+
+
+
+
+
+facto(3)
+
+
+
+
+
+
+
+ Compiling function facto with type Integer -> Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
What is the value for ?
+
+
+
+
+
+
+facto(-7)
+
+
+
+
+
+
+
+ Error signalled from user code in function facto:
+ arguments to facto must be non-negative
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
To see the current piece-wise definition of a function, use
+)display value.
+
+
+
+
+
+
+)display value facto
+
+
+
+
+
+
+
+ Definition:
+ facto 0 == 1
+ facto (n | n < 0) ==
+ error(arguments to facto must be non-negative)
+ facto n == n facto(n - 1)
+
+
+
+
+
In general a piece-wise definition of a function consists of two
+or more parts. Each part gives a ``piece'' of the entire definition.
+Axiom collects the pieces of a function as you enter them. When you
+ask for a value of the function, it then ``glues'' the pieces together
+to form a function.
+
+
+
+
The two piece-wise definitions for the factorial function are examples
+of recursive functions, that is, functions that are defined in terms
+of themselves. Here is an interesting doubly-recursive function.
+This function returns the value for all positive integer
+arguments.
+
+
+
+
Here is the first of two pieces.
+
+
+
+
+
+
+eleven(n | n < 1) == n + 11
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
And the general case.
+
+
+
+
+
+
+eleven(m) == eleven(eleven(m - 12))
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Compute , the infinite stream of values of .
+
+
+
+
+
+
+elevens := [eleven(i) for i in 0..]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Integer
+
+
+
+
+
What is the value at ?
+
+
+
+
+
+
+elevens 200
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
What is the Axiom's definition of ?
+
+
+
+
+
+
+)display value eleven
+
+
+
+
+
+
+
+ Definition:
+ eleven (m | m < 1) == m + 11
+ eleven m == eleven(eleven(m - 12))
+
+
+
+
+
+
+
+
+
+
+
+
+
6.11.2 Picking Up the Pieces
+
+
+
+
+
+
Here are the details about how Axiom creates a function from its
+pieces. Axiom converts the -th piece of a function definition
+into a conditional expression of the form:
+ifthen .
+If any new piece has a that is
+identical (after all variables are uniformly named) to
+an earlier , the earlier piece is removed.
+Otherwise, the new piece is always added at the end.
+
+
+
+
+
+
+
+
+
+
+
+
+
If there are pieces to a function definition for , the function
+defined is:
+
+ifthenelse
+. . .
+
+ifthenelse
+
+ error "You did not define f for argument <arg>."
+
+
+
+
+
+
+
+
+
+
You can give definitions of any number of mutually recursive function
+definitions, piece-wise or otherwise. No computation is done until
+you ask for a value. When you do ask for a value, all the relevant
+definitions are gathered, analyzed, and translated into separate
+functions and compiled.
+
+
+
+
Let's recall the definition of eleven from
+the previous section.
+
+
+
+
+
+
+eleven(n | n < 1) == n + 11
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+eleven(m) == eleven(eleven(m - 12))
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
A similar doubly-recursive function below produces for all
+negative positive integers. If you haven't worked out why or how
+ eleven works, the structure of this definition gives a clue.
+
+
+
+
This definition we write as a block.
+
+
+
+
+
+minusEleven(n) ==
+ n >= 0 => n - 11
+ minusEleven (5 + minusEleven(n + 7))
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Define to be the sum of plus and minus ``eleven'' functions
+divided by . Since , we define to be .
+
+
+
+
+
+
+s(0) == 1
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
And the general term.
+
+
+
+
+
+
+s(n) == (eleven(n) + minusEleven(n))/n
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
What are the first ten values of ?
+
+
+
+
+
+
+[s(n) for n in 0..]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Fraction Integer
+
+
+
+
+
+
Axiom can create infinite streams in the positive direction (for
+example, for index values ) or negative direction (for
+example, for ). Here we would like a
+stream of values of that is infinite in both directions. The
+function below returns the -th term of the infinite stream
+
+Its definition has three pieces.
+
+
+
+
Define the initial term.
+
+
+
+
+
+
+t(1) == s(0)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
The even numbered terms are the for positive . We use
+``quo'' rather than ``/'' since we want the result to be
+an integer.
+
+
+
+
+
+
+
+t(n | even?(n)) == s(n quo 2)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Finally, the odd numbered terms are the for negative . In
+piece-wise definitions, you can use different variables to define
+different pieces. Axiom will not get confused.
+
+
+
+
+
+
+t(p) == s(- p quo 2)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Look at the definition of . In the first piece, the variable
+was used; in the second piece, . Axiom always uses your last
+variable to display your definitions back to you.
+
+
+
+
+
+
+)display value t
+
+
+
+
+
+
+
+ Definition:
+ t 1 == s(0)
+ t (p | even?(p)) == s(p quo 2)
+ t p == s(- p quo 2)
+
+
+
+
+
Create a series of values of applied to
+alternating positive and negative arguments.
+
+
+
+
+
+
+[t(i) for i in 1..]
+
+
+
+
+
+
+
+ Compiling function s with type Integer -> Fraction Integer
+ Compiling function t with type PositiveInteger -> Fraction Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Fraction Integer
+
+
+
+
+
Evidently for all . Check it at .
+
+
+
+
+
+
+
+t(100)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
6.11.3 Predicates
+
+
+
+
+
+
We have already seen some examples of function:predicate
+predicates predicate:in function definition
+(ugUserPieceBasic ).
+Predicates are Boolean-valued expressions and Axiom uses them
+for filtering collections (see ugLangIts ) and for placing constraints on function
+arguments. In this section we discuss their latter usage.
+
+
+
+
The simplest use of a predicate is one you don't see at all.
+
+
+
+
+
+
+opposite 'right == 'left
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Here is a longer way to give the ``opposite definition.''
+
+
+
+
+
+
+opposite (x | x = 'left) == 'right
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Try it out.
+
+
+
+
+
+
+for x in ['right,'left,'inbetween] repeat output opposite x
+
+
+
+
+
+
+
+Compiling function opposite with type
+ OrderedVariableList [right, left,inbetween] -> Symbol
+ left
+ right
+
+The function opposite is not defined for the given argument(s).
+
+
+
+
+
Explicit predicates tell Axiom that the given function definition
+piece is to be applied if the predicate evaluates to true for
+the arguments to the function. You can use such ``constant''
+arguments for integers, function:constant argument strings,
+and quoted symbols. constant function argument The Boolean values true and false can also be used if qualified with
+``'' or ``'' and Boolean. The following are all valid
+function definition fragments using constant arguments.
+
If a function has more than one argument, each argument can have its
+own predicate. However, if a predicate involves two or more
+arguments, it must be given after all the arguments mentioned in
+the predicate have been given. You are always safe to give a single
+predicate at the end of the argument list.
+
+
+
+
A function involving predicates on two arguments.
+
+
+
+
+
+
+inFirstHalfQuadrant(x | x > 0,y | y < x) == true
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
This is incorrect as it gives a predicate on before the argument
+ is given.
+
+
+
+
+
+
+inFirstHalfQuadrant(x | x > 0 and y < x,y) == true
+
+
+
+
+
+
+
+ 1 old definition(s) deleted for function or rule inFirstHalfQuadrant
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
It is always correct to write the predicate at the end.
+
+
+
+
+
+
+inFirstHalfQuadrant(x,y | x > 0 and y < x) == true
+
+
+
+
+
+
+
+ 1 old definition(s) deleted for function or rule inFirstHalfQuadrant
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Here is the rest of the definition.
+
+
+
+
+
+
+inFirstHalfQuadrant(x,y) == false
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Try it out.
+
+
+
+
+
+
+[inFirstHalfQuadrant(i,3) for i in 1..5]
+
+
+
+
+
+
+
+ Compiling function inFirstHalfQuadrant with type (PositiveInteger,
+ PositiveInteger) -> Boolean
+
By default, Axiom does not save the values of any function.
+function:caching values You can cause it to save values and
+not to recompute unnecessarily remembering function values by
+using )set functions cache. set functions cache This
+should be used before the functions are defined or, at least, before
+they are executed. The word following ``cache'' should be to turn
+off caching, a positive integer to save the last computed
+values or ``all'' to save all computed values. If you then give a
+list of names of functions, the caching only affects those functions.
+Use no list of names or ``all'' when you want to define the default
+behavior for functions not specifically mentioned in other
+)set functions cache statements. If you give no list of names, all
+functions will have the caching behavior. If you explicitly turn on
+caching for one or more names, you must explicitly turn off caching
+for those names when you want to stop saving their values.
+
+
+
+
This causes the functions f and g to have the last three
+computed values saved.
+
+
+
+
+
+
+)set functions cache 3 f g
+
+
+
+
+
+
+
+ function f will cache the last 3 values.
+ function g will cache the last 3 values.
+
+
+
+
+
This is a sample definition for f.
+
+
+
+
+
+
+f x == factorial(2**x)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
A message is displayed stating what f will cache.
+
+
+
+
+
+
+f(4)
+
+
+
+
+
+
+
+ Compiling function f with type PositiveInteger -> Integer
+ f will cache 3 most recently computed value(s).
+
++++ |*1;f;1;G82322| redefined
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
This causes all other functions to have all computed values saved by default.
+
+
+
+
+
+
+)set functions cache all
+
+
+
+
+
+
+
+ In general, interpreter functions will cache all values.
+
+
+
+
+
This causes all functions that have not been specifically cached in some way
+to have no computed values saved.
+
+
+
+
+
+
+)set functions cache 0
+
+
+
+
+
+
+
+ In general, functions will cache no returned values.
+
+
+
+
+
We also make f and g uncached.
+
+
+
+
+
+
+)set functions cache 0 f g
+
+
+
+
+
+
+
+ Caching for function f is turned off
+ Caching for function g is turned off
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Be careful about caching functions that have side effects. Such a
+function might destructively modify the elements of an array or issue
+a draw command, for example. A function that you expect to
+execute every time it is called should not be cached. Also, it is
+highly unlikely that a function with no arguments should be cached.
+
+
+
+
+
+
+
+
+
+
You should also be careful about caching functions that depend on free
+variables. See ugUserFreeLocal for an example.
+
One of the most useful classes of function are those defined via a
+``recurrence relation.'' A recurrence relation makes each
+successive recurrence relation value depend on some or all of
+the previous values. A simple example is the ordinary ``factorial'' function:
+
+
+
+
+
+fact(0) == 1
+fact(n | n > 0) == n * fact(n-1)
+
+
+
+
+
The value of depends on the value of ,
+on , and so on. Because it depends on only one previous
+value, it is usually called a first order recurrence relation.
+You can easily imagine a function based on two, three or more previous
+values. The Fibonacci numbers are probably the most famous function
+defined by a Fibonacci numbers second order recurrence relation.
+
+
+
+
The library function fibonacci computes Fibonacci numbers.
+It is obviously optimized for speed.
+
+
+
+
+
+
+[fibonacci(i) for i in 0..]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Integer
+
+
+
+
+
Define the Fibonacci numbers ourselves using a piece-wise definition.
+
+
+
+
+
+
+fib(1) == 1
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+fib(2) == 1
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+fib(n) == fib(n-1) + fib(n-2)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
As defined, this recurrence relation is obviously doubly-recursive.
+To compute , we need to compute and . And
+to , we need to compute and . And so on. It
+seems that to compute we need to compute once,
+ twice, three times. Look familiar? The number of
+function calls needed to compute any second order recurrence
+relation in the obvious way is exactly . These numbers grow!
+For example, if Axiom actually did this, then requires more
+than function calls. And, given all
+this, our definition of fib obviously could not be used to
+calculate the five-hundredth Fibonacci number.
+
+
+
+
Let's try it anyway.
+
+
+
+
+
+
+fib(500)
+
+
+
+
+
+
+
+ Compiling function fib with type Integer -> PositiveInteger
+ Compiling function fib as a recurrence relation.
+
+13942322456169788013972438287040728395007025658769730726410_
+8962948325571622863290691557658876222521294125
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Since this takes a short time to compute, it obviously didn't do as
+many as operations! By default, Axiom transforms any
+recurrence relation it recognizes into an iteration. Iterations are
+efficient. To compute the value of the -th term of a recurrence
+relation using an iteration requires only function calls. Note
+that if you compare the speed of our fib function to the library
+function, our version is still slower. This is because the library
+fibonaccifibonacciIntegerNumberTheoryFunctions uses a
+``powering algorithm'' with a computing time proportional to
+ to compute fibonacci(n).
+
+
+
+
To turn off this special recurrence relation compilation, issue
+set function recurrence
+
+
+
+
+
+)set functions recurrence off
+
+
+
+
To turn it back on, substitute ``on'' for ``off''.
+
+
+
+
The transformations that Axiom uses for fib caches the last two
+values. For a more general -th order recurrence relation, Axiom
+caches the last values. If, after computing a value for
+fib, you ask for some larger value, Axiom picks up the cached values
+and continues computing from there. See ugUserFreeLocal for an example of a function definition
+that has this same behavior. Also see ugUserCache for a more general discussion of how you
+can cache function values.
+
+
+
+
Recurrence relations can be used for defining recurrence relations
+involving polynomials, rational functions, or anything you like.
+Here we compute the infinite stream of Legendre polynomials.
+
There are many times when you compute a complicated expression and
+then wish to use that expression as the body of a function. Axiom
+provides an operation called function to do function:from
+an object this. function:made by function @{made by
+ function} It creates a function object and places it into the
+workspace. There are several versions, depending on how many
+arguments the function has. The first argument to function is
+always the expression to be converted into the function body, and the
+second is always the name to be used for the function. For more
+information, see section MakeFunctionXmpPage .
+
+
+
+
Start with a simple example of a polynomial in three variables.
+
+
+
+
+
+
+p := -x + y**2 - z**3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
To make this into a function of no arguments that simply returns the
+polynomial, use the two argument form of function.
+
+
+
+
+
+
+function(p,'f0)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Symbol
+
+
+
+
+
To avoid possible conflicts (see below), it is a good idea to
+quote always this second argument.
+
+
+
+
+
+
+f0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FunctionCalled f0
+
+
+
+
+
This is what you get when you evaluate the function.
+
+
+
+
+
+
+f0()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
To make a function in , use a version of function that takes
+three arguments. The last argument is the name of the variable to use
+as the parameter. Typically, this variable occurs in the expression
+and, like the function name, you should quote it to avoid possible confusion.
+
+
+
+
+
+
+function(p,'f1,'x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Symbol
+
+
+
+
+
This is what the new function looks like.
+
+
+
+
+
+
+f1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FunctionCalled f1
+
+
+
+
+
This is the value of f1 at . Notice that the return type
+of the function is Polynomial (Integer), the same as .
+
+
+
+
+
+
+f1(3)
+
+
+
+
+
+
+
+ Compiling function f1 with type PositiveInteger -> Polynomial
+ Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
To use and as parameters, use the four argument form of function.
+
+
+
+
+
+
+function(p,'f2,'x,'y)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Symbol
+
+
+
+
+
+
+
+
+f2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FunctionCalled f2
+
+
+
+
+
Evaluate at and . The return type of f2 is
+still Polynomial(Integer) because the variable is still
+present and not one of the parameters.
+
+
+
+
+
+
+f2(3,0)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
Finally, use all three variables as parameters. There is no five
+argument form of function, so use the one with three arguments,
+the third argument being a list of the parameters.
+
+
+
+
+
+
+function(p,'f3,['x,'y,'z])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Symbol
+
+
+
+
+
Evaluate this using the same values for and as above, but let
+ be . The result type of f3 is Integer.
+
+
+
+
+
+
+f3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FunctionCalled f3
+
+
+
+
+
+
+
+
+f3(3,0,-6)
+
+
+
+
+
+
+
+ Compiling function f3 with type (PositiveInteger,NonNegativeInteger,
+ Integer) -> Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The four functions we have defined via have been undeclared. To
+declare a function whose body is to be generated by
+function:declaring function, issue the declaration
+before the function is created.
+
+
+
+
+
+
+g: (Integer, Integer) -> Float
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+D(sin(x-y)/cos(x+y),x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
+
+
+
+function(%,'g,'x,'y)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Symbol
+
+
+
+
+
+
+
+
+g
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FunctionCalled g
+
+
+
+
+
It is an error to use without the quote in the penultimate
+expression since had been declared but did not have a value.
+Similarly, since it is common to overuse variable names like , ,
+and so on, you avoid problems if you always quote the variable names
+for function. In general, if has a value and you use
+without a quote in a call to function, then Axiom does not know
+what you are trying to do.
+
+
+
+
What kind of object is allowable as the first argument to
+ function? Let's use the Browse facility of HyperDoc to find out.
+Browse@Browse At the main Browse menu, enter the string
+function and then click on Operations. The exposed operations
+called function all take an object whose type belongs to
+category ConvertibleTo InputForm. What domains are those? Go
+back to the main Browse menu, erase function, enter
+ConvertibleTo in the input area, and click on categories on the
+Constructors line. At the bottom of the page, enter
+InputForm in the input area following S =. Click on
+Cross Reference and then on Domains.
+The list you see contains over forty domains that belong to the
+category ConvertibleTo InputForm. Thus you can use function
+for Integer, Float, String, Complex,
+Expression, and so on.
+
You need not restrict yourself to functions that only fit on one line
+or are written in a piece-wise manner. The body of the function can
+be a block, as discussed in ugLangBlocks .
+
+
+
+
Here is a short function that swaps two elements of a list, array or vector.
+
The significance of swap is that it has a destructive
+effect on its first argument.
+
+
+
+
+
+
+k := [1,2,3,4,5]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
+
+
+
+swap(k,2,4)
+
+
+
+
+
+
+
+ Compiling function swap with type (List PositiveInteger,
+ PositiveInteger,PositiveInteger) -> PositiveInteger
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
You see that the second and fourth elements are interchanged.
+
+
+
+
+
+
+k
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
Using this, we write a couple of different sort functions. First, a
+simple bubble sort. sort:bubble The operation
+# returns the number of elements in an aggregate.
+
+
+
+
+
+bubbleSort(m) ==
+ n := #m
+ for i in 1..(n-1) repeat
+ for j in n..(i+1) by -1 repeat
+ if m.j < m.(j-1) then swap(m,j,j-1)
+ m
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Let this be the list we want to sort.
+
+
+
+
+
+
+m := [8,4,-3,9]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
This is the result of sorting.
+
+
+
+
+
+
+bubbleSort(m)
+
+
+
+
+
+
+
+ Compiling function swap with type (List Integer,Integer,Integer) ->
+ Integer
+
++++ |*3;swap;1;G82322| redefined
+ Compiling function bubbleSort with type List Integer -> List Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
Moreover, is destructively changed to be the sorted version.
+
+
+
+
+
+
+m
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
This function implements an insertion sort. sort:insertion
+The basic idea is to traverse the list and insert the -th element
+in its correct position among the previous elements. Since we
+start at the beginning of the list, the list elements before the
+-th element have already been placed in ascending order.
+
+
+
+
+
+insertionSort(m) ==
+ for i in 2..#m repeat
+ j := i
+ while j > 1 and m.j < m.(j-1) repeat
+ swap(m,j,j-1)
+ j := j - 1
+ m
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
As with our bubble sort, this is a destructive function.
+
+
+
+
+
+
+m := [8,4,-3,9]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
+
+
+
+insertionSort(m)
+
+
+
+
+
+
+
+ Compiling function insertionSort with type List Integer -> List
+ Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
+
+
+
+m
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
Neither of the above functions is efficient for sorting large lists
+since they reference elements by asking for the -th element of the
+structure .
+
+
+
+
Here is a more efficient bubble sort for lists.
+
+
+
+
+
+bubbleSort2(m: List Integer): List Integer ==
+ null m => m
+ l := m
+ while not null (r := l.rest) repeat
+ r := bubbleSort2 r
+ x := l.first
+ if x < r.first then
+ l.first := r.first
+ r.first := x
+ l.rest := r
+ l := l.rest
+ m
+
+ Function declaration bubbleSort2 : List Integer -> List Integer has
+ been added to workspace.
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Try it out.
+
+
+
+
+
+
+bubbleSort2 [3,7,2]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
This definition is both recursive and iterative, and is tricky!
+Unless you are really curious about this definition, we suggest
+you skip immediately to the next section.
+
+
+
+
Here are the key points in the definition. First notice that if you
+are sorting a list with less than two elements, there is nothing to
+do: just return the list. This definition returns immediately if
+there are zero elements, and skips the entire while loop if there is
+just one element.
+
+
+
+
The second point to realize is that on each outer iteration, the
+bubble sort ensures that the minimum element is propagated leftmost.
+Each iteration of the while loop calls bubbleSort2 recursively
+to sort all but the first element. When finished, the minimum element
+is either in the first or second position. The conditional expression
+ensures that it comes first. If it is in the second, then a swap
+occurs. In any case, the rest of the original list must be
+updated to hold the result of the recursive call.
+
When you want to refer to a variable that is not local to your
+function, use a ``free'' declaration. free Variables
+declared to be freefree variable are assumed to be defined
+globally variable:free in the variable:global
+workspace. global variable
+
+
+
+
This is a global workspace variable.
+
+
+
+
+
+
+counter := 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: NonNegativeInteger
+
+
+
+
+
This function refers to the global .
+
+
+
+
+
+f() ==
+ free counter
+ counter := counter + 1
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
The global is incremented by .
+
+
+
+
+
+
+f()
+
+
+
+
+
+
+
+ Compiling function f with type () -> NonNegativeInteger
+
++++ |*0;f;1;G82322| redefined
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+counter
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: NonNegativeInteger
+
+
+
+
+
+
Usually Axiom can tell that you mean to refer to a global variable and
+so free isn't always necessary. However, for clarity and the sake
+of self-documentation, we encourage you to use it.
+
+
+
+
Declare a variable to be ``local'' when you do not want to refer to
+variable:local a global variable by the same name.
+local variable
+
+
+
+
This function uses as a local variable.
+
+
+
+
+
+g() ==
+ local counter
+ counter := 7
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Apply the function.
+
+
+
+
+
+
+g()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Check that the global value of is unchanged.
+
+
+
+
+
+
+counter
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: NonNegativeInteger
+
+
+
+
+
Parameters to a function are local variables in the function. Even if
+you issue a free declaration for a parameter, it is still local.
+
+
+
+
What happens if you do not declare that a variable in the body of
+your function is local or free? Well, Axiom decides on this basis:
+
+
+
+
+
+
+ Axiom scans your function line-by-line, from top-to-bottom.
+The right-hand side of an assignment is looked at before the left-hand
+side.
+
+
If is referenced before it is assigned a value, it is a
+free (global) variable.
+
+
If is assigned a value before it is referenced, it is a
+local variable.
+
+
+
+
+
+
Set two global variables to 1.
+
+
+
+
+
+
+a := b := 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Refer to before it is assigned a value, but assign a value to
+before it is referenced.
+
+
+
+
+
+h() ==
+ b := a + 1
+ a := b + a
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Can you predict this result?
+
+
+
+
+
+
+h()
+
+
+
+
+
+
+
+ Compiling function h with type () -> PositiveInteger
+
++++ |*0;h;1;G82322| redefined
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
How about this one?
+
+
+
+
+
+
+[a, b]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
What happened? In the first line of the function body for , is
+referenced on the right-hand side of the assignment. Thus is a
+free variable. The variable is not referenced in that line, but
+it is assigned a value. Thus is a local variable and is given the
+value . In the second line, the free variable is
+assigned the value which equals This is the value
+returned by the function. Since was free in h, the global
+variable has value Since was local in h, the global
+variable is unchanged---it still has the value .
+
+
+
+
It is good programming practice always to declare global variables.
+However, by far the most common situation is to have local variables
+in your functions. No declaration is needed for this situation, but
+be sure to initialize their values.
+
+
+
+
Be careful if you use free variables and you cache the value of your
+function (see ugUserCache ).
+Caching only checks if the values of the function arguments are
+the same as in a function call previously seen. It does not check if
+any of the free variables on which the function depends have changed
+between function calls.
+
+
+
+
Turn on caching for p.
+
+
+
+
+
+
+)set fun cache all p
+
+
+
+
+
+
+
+ function p will cache all values.
+
+
+
+
+
Define p to depend on the free variable .
+
+
+
+
+
+
+p(i,x) == ( free N; reduce( + , [ (x-i)**n for n in 1..N ] ) )
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Set the value of .
+
+
+
+
+
+
+N := 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Evaluate p the first time.
+
+
+
+
+
+
+p(0, x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
Change the value of .
+
+
+
+
+
+
+N := 2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Evaluate p the second time.
+
+
+
+
+
+
+p(0, x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
If caching had been turned off, the second evaluation would have
+reflected the changed value of .
+
+
+
+
Turn off caching for p.
+
+
+
+
+
+
+)set fun cache 0 p
+
+
+
+
+
+
+
+ Caching for function p is turned off
+
+
+
+
+
Axiom does not allow fluid variables, that is, variables
+variable:fluid bound by a function that can be referenced
+by functions called by . fluid variable
+
+
+
+
Values are passed to functions by reference: a pointer to the
+value is passed rather than a copy of the value or a pointer to a
+copy.
+
+
+
+
This is a global variable that is bound to a record object.
+
+
+
+
+
+
+r : Record(i : Integer) := [1]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Record(i: Integer)
+
+
+
+
+
This function first modifies the one component of its record argument
+and then rebinds the parameter to another record.
+
+
+
+
+
+resetRecord rr ==
+ rr.i := 2
+ rr := [10]
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Pass as an argument to resetRecord.
+
+
+
+
+
+
+resetRecord r
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Record(i: Integer)
+
+
+
+
+
The value of was changed by the expression but not by
+.
+
+
+
+
+
+
+r
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Record(i: Integer)
+
+
+
+
+
To conclude this section, we give an iterative definition of
+Fibonacci numbers a function that computes Fibonacci numbers.
+This definition approximates the definition into which Axiom
+transforms the recurrence relation definition of fib in
+ugUserRecur .
+
+
+
+
Global variables past and present are used to hold the last
+computed Fibonacci numbers.
+
+
+
+
+
+
+past := present := 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Global variable gives the current index of .
+
+
+
+
+
+
+index := 2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Here is a recurrence relation defined in terms of these three global
+variables.
+
+
+
+
+
+fib(n) ==
+ free past, present, index
+ n < 3 => 1
+ n = index - 1 => past
+ if n < index-1 then
+ (past,present) := (1,1)
+ index := 2
+ while (index < n) repeat
+ (past,present) := (present, past+present)
+ index := index + 1
+ present
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Compute the infinite stream of Fibonacci numbers.
+
As an exercise, we suggest you write a function in an iterative style
+that computes the value of the recurrence relation
+
+having the initial values
+.
+How would you write the function using an element OneDimensionalArray
+or Vector to hold the previously computed values?
+
An anonymous function is a function that is
+function:anonymous defined anonymous function by
+giving a list of parameters, the ``maps-to'' compound
++-> @+-> symbol ``+->''
+(from the mathematical symbol ), and
+by an expression involving the parameters, the evaluation of which
+determines the return value of the function.
+
+
+
+
+
+
+
+
+
( , , ...,
+ ) +->expression
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
You can apply an anonymous function in several ways.
+
+
+
+
+
+
+ Place the anonymous function definition in parentheses
+directly followed by a list of arguments.
+
+
Assign the anonymous function to a variable and then
+use the variable name when you would normally use a function name.
+
+
Use ``=='' to use the anonymous function definition as
+the arguments and body of a regular function definition.
+
+
Have a named function contain a declared anonymous function and
+use the result returned by the named function.
+
+
+
+
+
+
+
+
+
6.17.1 Some Examples
+
+
+
+
+
+
Anonymous functions are particularly useful for defining functions
+``on the fly.'' That is, they are handy for simple functions that are
+used only in one place. In the following examples, we show how to
+write some simple anonymous functions.
+
+
+
+
This is a simple absolute value function.
+
+
+
+
+
+
+x +-> if x < 0 then -x else x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: AnonymousFunction
+
+
+
+
+
+
+
+
+abs1 := %
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: AnonymousFunction
+
+
+
+
+
This function returns true if the absolute value of
+the first argument is greater than the absolute value of the
+second, false otherwise.
+
+
+
+
+
+
+
+(x,y) +-> abs1(x) > abs1(y)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: AnonymousFunction
+
+
+
+
+
We use the above function to ``sort'' a list of integers.
+
+
+
+
+
+
+sort(%,[3,9,-4,10,-3,-1,-9,5])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
This function returns if is even, otherwise.
+
+
+
+
+
+
+ev := ( (i,j) +-> if even?(i+j) then 1 else -1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: AnonymousFunction
+
+
+
+
+
We create a four-by-four matrix containing or depending on
+whether the row plus the column index is even or not.
+
+
+
+
+
+
+matrix([ [ev(row,col) for row in 1..4] for col in 1..4])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Integer
+
+
+
+
+
This function returns true if a polynomial in has multiple
+roots, false otherwise. It is defined and applied in the same
+expression.
+
+
+
+
+
+
+( p +-> not one?(gcd(p,D(p,x))) )(x**2+4*x+4)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
This and the next expression are equivalent.
+
+
+
+
+
+
+g(x,y,z) == cos(x + sin(y + tan(z)))
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
The one you use is a matter of taste.
+
+
+
+
+
+
+g == (x,y,z) +-> cos(x + sin(y + tan(z)))
+
+
+
+
+
+
+
+ 1 old definition(s) deleted for function or rule g
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+
+
+
+
+
6.17.2 Declaring Anonymous Functions
+
+
+
+
+
+
If you declare any of the arguments you must declare all of them. Thus,
+
+
+
+
+
+(x: INT,y): FRAC INT +-> (x + 2*y)/(y - 1)
+
+
+
+
is not legal.
+
+
+
+
This is an example of a fully declared anonymous function.
+function:declaringfunction:anonymous:declaring The
+output shown just indicates that the object you created is a
+particular kind of map, that is, function.
+
Axiom allows you to declare the arguments and not declare
+the return type.
+
+
+
+
+
+
+(x: INT,y: INT) +-> (x + 2*y)/(y - 1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: ((Integer,Integer) -> Fraction Integer)
+
+
+
+
+
The return type is computed from the types of the arguments and the
+body of the function. You cannot declare the return type if you do
+not declare the arguments. Therefore,
+
+
+
+
+
+(x,y): FRAC INT +-> (x + 2*y)/(y - 1)
+
+
+
+
+
is not legal. This and the next expression are equivalent.
+
+ Function declaration h : (Integer,Integer) -> Fraction Integer
+ has been added to workspace.
+ 1 old definition(s) deleted for function or rule h
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
When should you declare an anonymous function?
+
+
+
+
+
+
+ If you use an anonymous function and Axiom can't figure out what
+you are trying to do, declare the function.
+
+
If the function has nontrivial argument types or a nontrivial
+return type that Axiom may be able to determine eventually, but you
+are not willing to wait that long, declare the function.
+
+
If the function will only be used for arguments of specific types
+and it is not too much trouble to declare the function, do so.
+
+
If you are using the anonymous function as an argument to another
+function (such as map or sort), consider declaring the function.
+
+
If you define an anonymous function inside a named function,
+you must declare the anonymous function.
+
+
+
+
+
+
This is an example of a named function for integers that returns a
+function.
+
+
+
+
+
+
+addx x == ((y: Integer): Integer +-> x + y)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
We define g to be a function that adds to its
+argument.
+
+
+
+
+
+
+g := addx 10
+
+
+
+
+
+
+
+ Compiling function addx with type
+ PositiveInteger -> (Integer -> Integer)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: (Integer -> Integer)
+
+
+
+
+
Try it out.
+
+
+
+
+
+
+g 3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+g(-4)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
function:anonymous:restrictions
+An anonymous function cannot be recursive: since it does not have a
+name, you cannot even call it within itself! If you place an
+anonymous function inside a named function, the anonymous function
+must be declared.
+
We need some functions for computing lineage. Start with childOf.
+
+
+
+
+
+
+childOf(x,y) == member?(x,children(y))
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
To find the parentOf someone, you have to scan the database of
+people applying children.
+
+
+
+
+
+parentOf(x) ==
+ for y in people repeat
+ (if childOf(x,y) then return y)
+ "unknown"
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
And a grandparent of is just a parent of a parent of .
+
+
+
+
+
+
+grandParentOf(x) == parentOf parentOf x
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
The grandchildren of are the people such that is a
+grandparent of .
+
+
+
+
+
+
+grandchildren(x) == [y for y in people | grandParentOf(y) = x]
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Suppose you want to make a list of all great-grandparents. Well, a
+great-grandparent is a grandparent of a person who has children.
+
+
+
+
+
+
+greatGrandParents == [x for x in people |
+ reduce(_or,
+ [not empty? children(y) for y in grandchildren(x)],false)]
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Define descendants to include the parent as well.
+
+
+
+
+
+descendants(x) ==
+ kids := children(x)
+ null kids => [x]
+ concat(x,reduce(concat,[descendants(y)
+ for y in kids],[]))
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Finally, we need a list of people. Since all people are descendants
+of ``albert'', let's say so.
+
+
+
+
+
+
+people == descendants "albert"
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
We have used ``=='' to define the database and some functions to
+query the database. But no computation is done until we ask for some
+information. Then, once and for all, the functions are analyzed and
+compiled to machine code for run-time efficiency. Notice that no
+types are given anywhere in this example. They are not needed.
+
+
+
+
Who are the grandchildren of ``richard''?
+
+
+
+
+
+
+grandchildren "richard"
+
+
+
+
+
+
+
+Compiling function children with type String -> List String
+Compiling function descendants with type String -> List String
+Compiling body of rule people to compute value of type List String
+Compiling function childOf with type (String,String) -> Boolean
+Compiling function parentOf with type String -> String
+Compiling function grandParentOf with type String -> String
+Compiling function grandchildren with type String -> List String
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List String
+
+
+
+
+
Who are the great-grandparents?
+
+
+
+
+
+
+greatGrandParents
+
+
+
+
+
+
+
+Compiling body of rule greatGrandParents to compute value of
+ type List String
+
In this example we write some functions that display Pascal's
+triangle. Pascal's triangle It demonstrates the use of
+piece-wise definitions and some output operations you probably haven't
+seen before.
+
+
+
+
To make these output operations available, we have to expose the
+domain OutputForm. OutputForm See
+ugTypesExpose
+for more information about exposing domains and packages.
+
+
+
+
+
+
+)set expose add constructor OutputForm
+
+
+
+
+
+
+
+ OutputForm is now explicitly exposed in frame G82322
+
+
+
+
+
Define the values along the first row and any column .
+
+
+
+
+
+
+pascal(1,i) == 1
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Define the values for when the row and column index are equal.
+Repeating the argument name indicates that the two index values are equal.
+
+
+
+
+
+
+pascal(n,n) == 1
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+pascal(i,j | 1 < i and i < j) ==
+ pascal(i-1,j-1)+pascal(i,j-1)
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Now that we have defined the coefficients in Pascal's triangle, let's
+write a couple of one-liners to display it.
+
+
+
+
First, define a function that gives the -th row.
+
+
+
+
+
+
+pascalRow(n) == [pascal(i,n) for i in 1..n]
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Next, we write the function displayRow to display the row,
+separating entries by blanks and centering.
+
+
+
+
+
+
+displayRow(n) == output center blankSeparate pascalRow(n)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Here we have used three output operations. Operation
+outputoutputOutputForm displays the printable form of
+objects on the screen, centercenterOutputForm centers a
+printable form in the width of the screen, and
+blankSeparateblankSeparateOutputForm takes a list of nprintable
+forms and inserts a blank between successive elements.
+
+
+
+
Look at the result.
+
+
+
+
+
+
+for i in 1..7 repeat displayRow i
+
+
+
+
+
+
+
+ Compiling function pascal with type (Integer,Integer) ->
+ PositiveInteger
+ Compiling function pascalRow with type PositiveInteger -> List
+ PositiveInteger
+ Compiling function displayRow with type PositiveInteger -> Void
+
+
+ 1
+ 1 1
+ 1 2 1
+ 1 3 3 1
+ 1 4 6 4 1
+ 1 5 10 10 5 1
+ 1 6 15 20 15 6 1
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Being purists, we find this less than satisfactory. Traditionally,
+elements of Pascal's triangle are centered between the left and right
+elements on the line above.
+
+
+
+
To fix this misalignment, we go back and redefine pascalRow to
+right adjust the entries within the triangle within a width of four
+characters.
+
+
+
+
+
+
+
+pascalRow(n) == [right(pascal(i,n),4) for i in 1..n]
+
+
+
+
+
+
+
+ Compiled code for pascalRow has been cleared.
+ Compiled code for displayRow has been cleared.
+ 1 old definition(s) deleted for function or rule pascalRow
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Finally let's look at our purely reformatted triangle.
+
+
+
+
+
+
+for i in 1..7 repeat displayRow i
+
+
+
+
+
+
+
+ Compiling function pascalRow with type PositiveInteger -> List
+ OutputForm
+
++++ |*1;pascalRow;1;G82322| redefined
+ Compiling function displayRow with type PositiveInteger -> Void
+
++++ |*1;displayRow;1;G82322| redefined
+ 1
+ 1 1
+ 1 2 1
+ 1 3 3 1
+ 1 4 6 4 1
+ 1 5 10 10 5 1
+ 1 6 15 20 15 6 1
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Unexpose OutputForm so we don't get unexpected results later.
+
+
+
+
+
+
+)set expose drop constructor OutputForm
+
+
+
+
+
+
+
+ OutputForm is now explicitly hidden in frame G82322
+
A macro provides general textual substitution of macro
+an Axiom expression for a name. You can think of a macro as being a
+generalized abbreviation. You can only have one macro in your
+workspace with a given name, no matter how many arguments it has.
+
+
+
+
+
+
+
+
+
+
+
+
+
The two general forms for macros are
+
+
+
+
+
+
+
+
macroname==body
+macroname(arg1,...)==body
+
+
+
+
+
+
+
+
where the body of the macro can be any Axiom expression.
+
+
+
+
+
+
+
+
+
+
For example, suppose you decided that you like to use df for
+D. You define the macro df like this.
+
+
+
+
+
+
+macro df == D
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Whenever you type df, the system expands it to D.
+
+
+
+
+
+
+df(x**2 + x + 1,x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
Macros can be parameterized and so can be used for many different
+kinds of objects.
+
+
+
+
+
+
+macro ff(x) == x**2 + 1
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Apply it to a number, a symbol, or an expression.
+
+
+
+
+
+
+ff z
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
Macros can also be nested, but you get an error message if you
+run out of space because of an infinite nesting loop.
+
+
+
+
+
+
+macro gg(x) == ff(2*x - 2/3)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
This new macro is fine as it does not produce a loop.
+
+
+
+
+
+
+gg(1/w)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Polynomial Integer
+
+
+
+
+
This, however, loops since gg is defined in terms of ff.
+
+
+
+
+
+
+macro ff(x) == gg(-x)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
The body of a macro can be a block.
+
+
+
+
+
+
+macro next == (past := present; present := future; future := past + present)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Before entering next, we need values for present and future.
+
+
+
+
+
+
+present : Integer := 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Integer
+
+
+
+
+
+
+
+
+future : Integer := 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Integer
+
+
+
+
+
Repeatedly evaluating next produces the next Fibonacci number.
+
+
+
+
+
+
+next
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Integer
+
+
+
+
+
And the next one.
+
+
+
+
+
+
+next
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Integer
+
+
+
+
+
Here is the infinite stream of the rest of the Fibonacci numbers.
+
+
+
+
+
+
+[next for i in 1..]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Integer
+
+
+
+
+
Bundle all the above lines into a single macro.
+
+
+
+
+
+macro fibStream ==
+ present : Integer := 1
+ future : Integer := 1
+ [next for i in 1..] where
+ macro next ==
+ past := present
+ present := future
+ future := past + present
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Use concatconcatStream to start with the first two
+Fibonacci numbers Fibonacci numbers.
+
+
+
+
+
+
+concat([0,1],fibStream)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Integer
+
+
+
+
+
The library operation fibonacci is an easier way to compute
+these numbers.
+
In this section we define a function pal? that tests whether its
+palindrome argument is a palindrome, that is, something
+that reads the same backwards and forwards. For example, the string
+``Madam I'm Adam'' is a palindrome (excluding blanks and punctuation)
+and so is the number . The definition works for any
+datatype that has components that are accessed by the indices
+.
+
+
+
+
Here is the definition for pal?. It is simply a call to an
+auxiliary function called palAux?. We are following the
+convention of ending a function's name with ? if the function
+returns a Boolean value.
+
+
+
+
+
+
+pal? s == palAux?(s,1,#s)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Here is palAux?. It works by comparing elements that are
+equidistant from the start and end of the object.
+
+
+
+
+
+palAux?(s,i,j) ==
+ j > i =>
+ (s.i = s.j) and palAux?(s,i+1,i-1)
+ true
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Try pal? on some examples. First, a string.
+
+
+
+
+
+
+pal? "Oxford"
+
+
+
+
+
+
+
+ Compiling function palAux? with type (String,Integer,Integer) ->
+ Boolean
+ Compiling function pal? with type String -> Boolean
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
A list of polynomials.
+
+
+
+
+
+
+pal? [4,a,x-1,0,x-1,a,4]
+
+
+
+
+
+
+
+ Compiling function palAux? with type (List Polynomial Integer,
+ Integer,Integer) -> Boolean
+ Compiling function pal? with type List Polynomial Integer -> Boolean
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
A list of integers from the example in the last section.
+
+
+
+
+
+
+pal? [1,6,15,20,15,6,1]
+
+
+
+
+
+
+
+ Compiling function palAux? with type (List PositiveInteger,Integer,
+ Integer) -> Boolean
+ Compiling function pal? with type List PositiveInteger -> Boolean
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
To use pal? on an integer, first convert it to a string.
+
+
+
+
+
+
+pal?(1441::String)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
Compute an infinite stream of decimal numbers, each of which is an
+obvious palindrome.
+
+
+
+
+
+
+ones := [reduce(+,[10**j for j in 0..i]) for i in 1..]
+
+
A common mathematical formula is
+
+
+The presence of ``'' indicates that and can stand for
+arbitrary mathematical expressions in the above formula. You can use
+such mathematical formulas in Axiom to specify ``rewrite rules''.
+Rewrite rules are objects in Axiom that can be assigned to variables
+for later use, often for the purpose of simplification. Rewrite rules
+look like ordinary function definitions except that they are preceded
+by the reserved word . rule For example, a rewrite rule
+for the above formula is:
+
+
+
+
+
+rule log(x) + log(y) == log(x * y)
+
+
+
+
+
Like function definitions, no action is taken when a rewrite rule is
+issued. Think of rewrite rules as functions that take one argument.
+When a rewrite rule is applied to an argument , its meaning
+is: ``rewrite every subexpression of that matches by
+'' The left-hand side of a rewrite rule is called a pattern;
+its right-side side is called its substitution.
+
+
+
+
Create a rewrite rule named logrule. The generated symbol
+beginning with a ``%'' is a place-holder for any other terms that
+might occur in the sum.
+
The meaning of our example rewrite rule is: ``for all expressions
+and , rewrite by .'' Patterns
+generally have both operation names (here, log and ``+'') and
+variables (here, and ). By default, every operation name
+stands for itself. Thus log matches only ``'' and not any
+other operation such as sin. On the other hand, variables do
+not stand for themselves. Rather, a variable denotes a pattern
+variable that is free to match any expression whatsoever.
+pattern:variables
+
+
+
+
When a rewrite rule is applied, a process called
+pattern matching goes to work by systematically scanning
+pattern:matching the subexpressions of the argument. When a
+subexpression is found that ``matches'' the pattern, the subexpression
+is replaced by the right-hand side of the rule. The details of what
+happens will be covered later.
+
+
+
+
The customary Axiom notation for patterns is actually a shorthand for
+a longer, more general notation. Pattern variables can be made
+explicit by using a percent ``%'' as the first character of the
+variable name. To say that a name stands for itself, you can prefix
+that name with a quote operator ``'''. Although the current Axiom
+parser does not let you quote an operation name, this more general
+notation gives you an alternate way of giving the same rewrite rule:
+
+
+
+
+
+rule log(%x) + log(%y) == log(x * y)
+
+
+
+
+
This longer notation gives you patterns that the standard notation
+won't handle. For example, the rule
+
+
+
+
+
+rule %f(c * 'x) == c*%f(x)
+
+
+
+
means ``for all and , replace by when is
+the product of and the explicit variable .''
+
+
+
+
Thus the pattern can have several adornments on the names that appear there.
+Normally, all these adornments are dropped in the substitution on the
+right-hand side.
+
+
+
+
To summarize:
+
+
+
+
+
+
+
+
+
+
+
+
+
To enter a single rule in Axiom, use the following syntax: rule
+
+
+
+
+
+
+
+
rule leftHandSide == rightHandSide
+
+
+
+
+
+
+
+
+
The leftHandSide is a pattern to be matched and the
+rightHandSide is its substitution. The rule is an object of type
+RewriteRule that can be assigned to a variable and applied to
+expressions to transform them.
+
+
+
+
+
+
+
+
+
+
Rewrite rules can be collected
+into rulesets so that a set of rules can be applied at once.
+Here is another simplification rule for logarithms.
+
+
+If instead of giving a single rule following the reserved word
+you give a ``pile'' of rules, you create what is called a
+ruleset.ruleset Like rules, rulesets are objects in Axiom
+and can be assigned to variables. You will find it useful to group
+commonly used rules into input files, and read them in as needed.
+
Again, create an expression containing logarithms.
+
+
+
+
+
+
+f := a * log(sin x) - 2 * log x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
Apply the ruleset logrules to .
+
+
+
+
+
+
+logrules f
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
+
We have allowed pattern variables to match arbitrary expressions in
+the above examples. Often you want a variable only to match
+expressions satisfying some predicate. For example, we may want to
+apply the transformation
+
+only when is an integer.
+
+
+
+
The way to restrict a pattern variable by a predicate
+pattern:variable:predicate is by using a vertical bar ``|'',
+which means ``such that,'' in such that much the same way it
+is used in function definitions. predicate:on a pattern
+variable You do this only once, but at the earliest (meaning deepest
+and leftmost) part of the pattern.
+
+
+
+
This restricts the logarithmic rule to create integer exponents only.
+
+ Compiling body of rule sinCosProducts to compute value of type
+ Ruleset(Integer,Integer,Expression Integer)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
Another qualification you will often want to use is to allow a pattern to
+match an identity element.
+Using the pattern , for example, neither nor
+matches the expression .
+Similarly, if a pattern contains a product or an exponentiation
+, then neither or matches .
+
+
+
+
If identical elements were matched, pattern matching would generally loop.
+Here is an expansion rule for exponentials.
+
This rule would cause infinite rewriting on this if either or
+ were allowed to match .
+
+
+
+
+
+
+exprule exp x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
There are occasions when you do want a pattern variable in a sum or
+product to match or . If so, prefix its name
+with a ``?'' whenever it appears in a left-hand side of a rule.
+For example, consider the following rule for the exponential integral:
+
+This rule is valid for . One solution is to create a Ruleset with two rules, one with and one without . A better
+solution is to use an ``optional'' pattern variable.
+
+
+
+
Define rule eirule with
+a pattern variable to indicate
+that an expression may or may not occur.
+
+
+
+
+
+
+eirule := rule integral((?y + exp x)/x,x) == integral(y/x,x) + Ei x
+
+
Apply rule eirule to an integral without this term.
+
+
+
+
+
+
+eirule integral(exp u/u, u)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
Apply rule eirule to an integral with this term.
+
+
+
+
+
+
+eirule integral(sin u + exp u/u, u)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
Here is one final adornment you will find useful. When matching a
+pattern of the form to an expression containing a long sum of
+the form , there is no way to predict in advance which
+subset of the sum matches and which matches . Aside from
+efficiency, this is generally unimportant since the rule holds for any
+possible combination of matches for and . In some situations,
+however, you may want to say which pattern variable is a sum (or
+product) of several terms, and which should match only a single term.
+To do this, put a prefix colon ``:'' before the pattern variable
+that you want to match multiple terms.
+pattern:variable:matching several terms
+
+
+
+
The remaining rules involve operators and . operator
+
+
+
+
+
+
+u := operator 'u
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: BasicOperator
+
+
+
+
+
These definitions tell Axiom that and are formal operators to
+be used in expressions.
+
+
+
+
+
+
+v := operator 'v
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: BasicOperator
+
+
+
+
+
First define myRule with no restrictions on the pattern variables
+ and .
+
means that the substutution for must satisfy predicate(s) = true.
+
?x
means that can match an identity element (0 or 1).
+
:x
means that can match several terms in a sum.
+
+
+
+
+
+
+
+
+
+
+
Here are some final remarks on pattern matching. Pattern matching
+provides a very useful paradigm for solving certain classes of
+problems, namely, those that involve transformations of one form to
+another and back. However, it is important to recognize its
+limitations. pattern:matching:caveats
+
+
+
+
First, pattern matching slows down as the number of rules you have to
+apply increases. Thus it is good practice to organize the sets of
+rules you use optimally so that irrelevant rules are never included.
+
+
+
+
Second, careless use of pattern matching can lead to wrong answers.
+You should avoid using pattern matching to handle hidden algebraic
+relationships that can go undetected by other programs. As a simple
+example, a symbol such as ``J'' can easily be used to represent the
+square root of or some other important algebraic quantity. Many
+algorithms branch on whether an expression is zero or not, then divide
+by that expression if it is not. If you fail to simplify an
+expression involving powers of to algorithms may incorrectly
+assume an expression is non-zero, take a wrong branch, and produce a
+meaningless result.
+
+
+
+
Pattern matching should also not be used as a substitute for a domain.
+In Axiom, objects of one domain are transformed to objects of other
+domains using well-defined coerce operations. Pattern matching
+should be used on objects that are all the same type. Thus if your
+application can be handled by type Expression in Axiom and you
+think you need pattern matching, consider this choice carefully.
+Expression You may well be better served by extending an
+existing domain or by building a new domain of objects for your
+application.
+
Each name in your workspace can refer to a single object. This may be
+any kind of object including a function. You can use interactively
+any function from the library or any that you define in the workspace.
+In the library the same name can have very many functions, but you can
+have only one function with a given name, although it can have any
+number of arguments that you choose.
+
+
+
+
If you define a function in the workspace that has the same name and
+number of arguments as one in the library, then your definition takes
+precedence. In fact, to get the library function you must
+package-call it
+(see section ugTypesPkgCall ).
+
+
+
+
To use a function in Axiom, you apply it to its arguments. Most
+functions are applied by entering the name of the function followed by
+its argument or arguments.
+
+
+
+
+
+
+factor(12)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Integer
+
+
+
+
+
Some functions like ``+'' have infixoperators as names.
+
+
+
+
+
+
+3 + 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The function ``+'' has two arguments. When you give it more than
+two arguments, Axiom groups the arguments to the left. This
+expression is equivalent to .
+
+
+
+
+
+
+1 + 2 + 7
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
All operations, including infix operators, can be written in prefix
+form, that is, with the operation name followed by the arguments in
+parentheses. For example, can alternatively be written as
+. But is an error since + takes only two
+arguments.
+
+
+
+
Prefix operations are generally applied before the infix operation.
+Thus the form means
+producing , and means producing . An
+example of a prefix operator is prefix ``-''. For example, converts to producing the value . Any prefix
+function taking two arguments can be written in an infix manner by
+putting an ampersand ``&'' before the name. Thus can
+be written as returning .
+
+
+
+
Every function in Axiom is identified by a name and
+type. (An exception is an ``anonymous function'' discussed in
+ugUserAnon .)
+The type of a function is always a mapping of the
+form Source->Target where Source and Target are types.
+To enter a type from the keyboard, enter the arrow by using a hyphen
+``-'' followed by a greater-than sign ``>'', e.g.
+Integer -> Integer.
+
+
+
+
Let's go back to ``+''. There are many ``+'' functions in the
+Axiom library: one for integers, one for floats, another for rational
+numbers, and so on. These ``+'' functions have different types and
+thus are different functions. You've seen examples of this
+overloading before---using the same name for different functions.
+Overloading is the rule rather than the exception. You can add two
+integers, two polynomials, two matrices or two power series. These
+are all done with the same function name but with different functions.
+
In ugTypesDeclare we discussed
+how to declare a variable to restrict the kind of values that can be
+assigned to it. In this section we show how to declare a variable
+that refers to function objects.
+
+
+
+
+
+
+
+
+
+
+
+
+
A function is an object of type
+
+
+
+
+
+
+
+
{\sf Source Type}
+
+
+
+
+
+
+
+
+
where Source and Target can be any type. A common type
+for Source is Tuple(, ...,
+), usually written (, ...,
+), to indicate a function of arguments.
+
+
+
+
+
+
+
+
+
+
If takes an Integer, a Float and another Integer,
+and returns a String, the declaration is written:
+
+
+
+
+
+
+g: (Integer,Float,Integer) -> String
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
The types need not be written fully; using abbreviations, the above
+declaration is:
+
+
+
+
+
+
+g: (INT,FLOAT,INT) -> STRING
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
It is possible for a function to take no arguments. If takes no
+arguments but returns a PolynomialInteger, any of the
+following declarations is acceptable.
+
+
+
+
+
+
+h: () -> POLY INT
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+h: () -> Polynomial INT
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+h: () -> POLY Integer
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Functions can also be declared when they are being defined.
+The syntax for combined declaration/definition is:
+
+
+
+
+
+
+
+
functionName(:
+, ..., :
+): functionReturnType
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
The following definition fragments show how this can be done for
+the functions and above.
+
A current restriction on function declarations is that they must
+involve fully specified types (that is, cannot include modes involving
+explicit or implicit ``?''). For more information on declaring
+things in general, see ugTypesDeclare .
+
As you use Axiom, you will find that you will write many short
+functions function:one-line definition to codify sequences of
+operations that you often perform. In this section we write some
+simple one-line functions.
+
+
+
+
This is a simple recursive factorial function for positive integers.
+
+
+
+
+
+
+fac n == if n < 3 then n else n * fac(n-1)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+fac 10
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
This function computes .
+
+
+
+
+
+
+s n == reduce(+,[1/i for i in 1..n])
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+s 50
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
This function computes a Mersenne number, several of which are prime.
+Mersenne number
+
+
+
+
+
+
+mersenne i == 2**i - 1
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
If you type mersenne, Axiom shows you the function definition.
+
+
+
+
+
+
+mersenne
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FunctionCalled mersenne
+
+
+
+
+
Generate a stream of Mersenne numbers.
+
+
+
+
+
+
+[mersenne i for i in 1..]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Integer
+
+
+
+
+
Create a stream of those values of such that mersenne(i) is prime.
+
+
+
+
+
+
+mersenneIndex := [n for n in 1.. | prime?(mersenne(n))]
+
+
+
+
+
+
+
+ Compiling function mersenne with type PositiveInteger -> Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream PositiveInteger
+
+
+
+
+
Finally, write a function that returns the -th Mersenne prime.
+
+
+
+
+
+
+mersennePrime n == mersenne mersenneIndex(n)
+
+
If you declare the type of a function, you can apply it to any data
+that can be converted to the source type of the function.
+
+
+
+
Define f with type {\sf Integer Integer}.
+
+
+
+
+
+
+f(x: Integer): Integer == x + 1
+
+
+
+
+
+
+
+ Function declaration f : Integer -> Integer has been added to
+ workspace.
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
The function f can be applied to integers, ...
+
+
+
+
+
+
+f 9
+
+
+
+
+
+
+
+ Compiling function f with type Integer -> Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
and to values that convert to integers, ...
+
+
+
+
+
+
+f(-2.0)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Integer
+
+
+
+
+
but not to values that cannot be converted to integers.
+
+
+
+
+
+
+f(2/3)
+
+
+
+
+
+
+
+ Conversion failed in the compiled user function f .
+
+ Cannot convert from type Fraction Integer to Integer for value
+ 2
+ -
+ 3
+
+
+
+
+
To make the function over a wide range of types, do not declare its type.
+Give the same definition with no declaration.
+
+
+
+
+
+
+g x == x + 1
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
If makes sense, you can apply g to .
+
+
+
+
+
+
+g 9
+
+
+
+
+
+
+
+ Compiling function g with type PositiveInteger -> PositiveInteger
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
A version of g with different argument types get compiled for
+each new kind of argument used.
+
+
+
+
+
+
+g(2/3)
+
+
+
+
+
+
+
+ Compiling function g with type Fraction Integer -> Fraction Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
Here for makes no sense.
+
+
+
+
+
+
+g("axiom")
+
+
+
+
+
+
+
+ There are 11 exposed and 5 unexposed library operations named +
+ having 2 argument(s) but none was determined to be applicable.
+ Use HyperDoc Browse, or issue
+ )display op +
+ to learn more about the available operations. Perhaps
+ package-calling the operation or using coercions on the arguments
+ will allow you to apply the operation.
+ Cannot find a definition or applicable library operation named +
+ with argument type(s)
+ String
+ PositiveInteger
+
+ Perhaps you should use "@" to indicate the required return type,
+ or "$" to specify which version of the function you need.
+ AXIOM will attempt to step through and interpret the code.
+ There are 11 exposed and 5 unexposed library operations named +
+ having 2 argument(s) but none was determined to be applicable.
+ Use HyperDoc Browse, or issue
+ )display op +
+ to learn more about the available operations. Perhaps
+ package-calling the operation or using coercions on the arguments
+ will allow you to apply the operation.
+
+ Cannot find a definition or applicable library operation named +
+ with argument type(s)
+ String
+ PositiveInteger
+
+ Perhaps you should use "@" to indicate the required return type,
+ or "$" to specify which version of the function you need.
+
+
+
+
+
As you will see in Chapter ugCategories Axiom has a formal idea of categories for
+what ``makes sense.''
+
A function is an object that you can create, manipulate, pass to, and
+return from functions (for some interesting examples of library
+functions that manipulate functions, see MappingPackage1XmpPage
+). Yet, we often seem to use
+the term operation and function interchangeably in Axiom. What
+is the distinction?
+
+
+
+
First consider values and types associated with some variable in
+your workspace. You can make the declaration n : Integer, then
+assign an integer value. You then speak of the integer .
+However, note that the integer is not the name itself, but the
+value that you assign to .
+
+
+
+
Similarly, you can declare a variable in your workspace to have
+type Integer Integer, then assign , through a
+definition or an assignment of an anonymous function. You then speak
+of the function . However, the function is not , but the value
+that you assign to .
+
+
+
+
A function is a value, in fact, some machine code for doing something.
+Doing what? Well, performing some operation. Formally, an
+operation consists of the constituent parts of in your workspace,
+excluding the value; thus an operation has a name and a type. An
+operation is what domains and packages export. Thus Ring
+exports one operation ``+''. Every ring also exports this
+operation. Also, the author of every ring in the system is obliged
+under contract (see ugPackagesAbstract ) to provide an implementation for
+this operation.
+
+
+
+
This chapter is all about functions---how you create them
+interactively and how you apply them to meet your needs. In Chapter
+ugPackages you will learn how to
+create them for the Axiom library. Then in Chapter ugCategories
+, you will learn about categories and
+exported operations.
+
6.8 Delayed Assignments vs. Functions with No Arguments
+
+
+
+
+
+
In ugLangAssign we discussed the
+difference between immediate and function:with no arguments
+delayed assignments. In this section we show the difference between
+delayed assignments and functions of no arguments.
+
+
+
+
A function of no arguments is sometimes called a nullary function.
+
+
+
+
+
+
+sin24() == sin(24.0)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
You must use the parentheses ``()'' to evaluate it. Like a
+delayed assignment, the right-hand-side of a function evaluation is
+not evaluated until the left-hand-side is used.
+
+
+
+
+
+
+sin24()
+
+
+
+
+
+
+
+ Compiling function sin24 with type () -> Float
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
If you omit the parentheses, you just get the function definition.
+
+
+
+
+
+
+sin24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FunctionCalled sin24
+
+
+
+
+
You do not use the parentheses ``()'' in a delayed assignment...
+
+
+
+
+
+
+
+cos24 == cos(24.0)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
nor in the evaluation.
+
+
+
+
+
+
+
+cos24
+
+
+
+
+
+
+
+ Compiling body of rule cos24 to compute value of type Float
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
The only syntactic difference between delayed assignments
+and nullary functions is that you use ``()'' in the latter case.
+
What happens if you define a function that has the same name as a
+library function? Well, if your function has the same name and number
+of arguments (we sometimes say arity) as another function in the
+library, then your function covers up the library function. If you
+want then to call the library function, you will have to package-call
+it. Axiom can use both the functions you write and those that come
+from the library. Let's do a simple example to illustrate this.
+
+
+
+
Suppose you (wrongly!) define sin in this way.
+
+
+
+
+
+
+sin x == 1.0
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
The value is returned for any argument.
+
+
+
+
+
+
+sin 4.3
+
+
+
+
+
+
+
+ Compiling function sin with type Float -> Float
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
If you want the library operation, we have to package-call it
+(see ugTypesPkgCall
+for more information).
+
+
+
+
+
+
+sin(4.3) $Float
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+
+sin(34.6) $Float
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
Even worse, say we accidentally used the same name as a library
+function in the function.
+
+
+
+
+
+
+sin x == sin x
+
+
+
+
+
+
+
+ Compiled code for sin has been cleared.
+ 1 old definition(s) deleted for function or rule sin
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Then Axiom definitely does not understand us.
+
+
+
+
+
+
+sin 4.3
+
+
+
+
+
+
+
+AXIOM cannot determine the type of sin because it cannot analyze
+ the non-recursive part, if that exists. This may be remedied
+ by declaring the function.
+
+
+
+
+
Again, we could package-call the inside function.
+
+
+
+
+
+
+sin x == sin(x) $Float
+
+
+
+
+
+
+
+ 1 old definition(s) deleted for function or rule sin
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+sin 4.3
+
+
+
+
+
+
+
+ Compiling function sin with type Float -> Float
+
++++ |*1;sin;1;G82322| redefined
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
Of course, you are unlikely to make such obvious errors. It is more
+probable that you would write a function and in the body use a
+function that you think is a library function. If you had also
+written a function by that same name, the library function would be
+invisible.
+
+
+
+
How does Axiom determine what library function to call? It very much
+depends on the particular example, but the simple case of creating the
+polynomial will give you an idea.
+
+
+
+
+
+
+ The is analyzed and its default type is
+Variable(x).
+
+
The is analyzed and its default type is
+PositiveInteger.
+
+
The is analyzed and its default type is
+PositiveInteger.
+
+
Because the arguments to ``/'' are integers, Axiom
+gives the expression a default target type of
+Fraction(Integer).
+
+
Axiom looks in PositiveInteger for ``/''.
+It is not found.
+
+
Axiom looks in Fraction(Integer) for ``/''.
+It is found for arguments of type Integer.
+
+
The and are converted to objects of type
+Integer (this is trivial) and ``/'' is applied,
+creating an object of type Fraction(Integer).
+
+
No ``+'' for arguments of types Variable(x) and
+Fraction(Integer) are found in either domain.
+
This chapter shows how to use the Axiom graphics facilities
+graphics under the X Window System. Axiom has
+two-dimensional and three-dimensional drawing and
+rendering packages that allow the drawing, coloring, transforming,
+mapping, clipping, and combining of graphic output from Axiom
+computations. This facility is particularly useful for investigating
+problems in areas such as topology. The graphics package is capable
+of plotting functions of one or more variables or plotting parametric
+surfaces and curves. Various coordinate systems are also available,
+such as polar and spherical.
+
+
+
+
A graph is displayed in a viewport window and it has a
+viewport control-panel that uses interactive mouse commands.
+PostScript and other output forms are available so that Axiom
+PostScript images can be printed or used by other programs.
+
The Axiom two-dimensional graphics package provides the ability
+to graphics:two-dimensional display
+
+
+
+
+
+
+ curves defined by functions of a single real variable
+
+
curves defined by parametric equations
+
+
implicit non-singular curves defined by polynomial equations
+
+
planar graphs generated from lists of point components.
+
+
+
+
+
+
These graphs can be modified by specifying various options, such as
+calculating points in the polar coordinate system or changing the size
+of the graph viewport window.
+
+
+
+
+
+
+
7.1.1 Plotting Two-Dimensional Functions of One Variable
+
+
+
+
+
+
curve:one variable function The first kind of
+two-dimensional graph is that of a curve defined by a function
+ over a finite interval of the axis.
+
+
+
+
+
+
+
+
+
+
+
+
+
The general format for drawing a function defined by a formula is:
+
+
+
+
+
+
+
+
draw(f(x), x = a..b, options)
+
+
+
+
+
+
+
+
+
where defines the range of , and where options
+prescribes zero or more options as described in
+ugGraphTwoDOptions . An
+example of an option is An alternative
+format involving functions and is also available.
+
+
+
+
+
+
+
+
+
+
A simple way to plot a function is to use a formula. The first
+argument is the formula. For the second argument, write the name of
+the independent variable (here, ), followed by an ``='', and the
+range of values.
+
+
+
+
Display this formula over the range .
+Axiom converts your formula to a compiled function so that the
+results can be computed quickly and efficiently.
+
+
+
+
+
+
+draw(sin(tan(x)) - tan(sin(x)),x = 0..6)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Once again the formula is converted to a compiled function before any
+points were computed. If you want to graph the same function on
+several intervals, it is a good idea to define the function first so
+that the function has to be compiled only once.
+
+
+
+
This time we first define the function.
+
+
+
+
+
+
+f(x) == (x-1)*(x-2)*(x-3)
+
+
+
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
To draw the function, the first argument is its name and the second is
+just the range with no independent variable.
+
The second kind of two-dimensional graph is that of
+parametric plane curve curves produced by parametric
+equations. curve:parametric plane Let and
+ be formulas or two functions and as the parameter
+ranges over an interval . The function curve takes the
+two functions and as its parameters.
+
+
+
+
+
+
+
+
+
+
+
+
+
The general format for drawing a two-dimensional plane curve defined by
+parametric formulas and is:
+
+
+
+
+
+
+
+
draw(curve(f(t), g(t)), t = a..b, options)
+
+
+
+
+
+
+
+
+
where defines the range of the independent variable , and
+where options prescribes zero or more options as described in
+ugGraphThreeDOptions . An
+example of an option is
+
+
+
+
+
+
+
+
+
Here's an example:
+
+
+
+
Define a parametric curve using a range involving , Axiom's way
+of saying . For parametric curves, Axiom
+compiles two functions, one for each of the functions and .
+
+
+
+
+
+draw(curve(sin(t)*sin(2*t)*sin(3*t), sin(4*t)*sin(5*t)*sin(6*t)), t = 0..2*%pi)
+
+
+
+
+
+
+
The title may be an arbitrary string and is an optional argument to
+the draw command.
+
+
+
+
+
+draw(curve(cos(t), sin(t)), t = 0..2*%pi)
+
+
+
+
+
+
+
If you plan on plotting , as ranges over
+several intervals, you may want to define functions and first,
+so that they need not be recompiled every time you create a new graph.
+Here's an example:
+
+
+
+
As before, you can first define the functions you wish to draw.
+
+
+
+
+
+
+f(t:DFLOAT):DFLOAT == sin(3*t/4)
+
+
+
+
+
+
+
+ Function declaration f : DoubleFloat -> DoubleFloat has been
+ added to workspace.
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Axiom compiles them to map DoubleFloat values to DoubleFloat
+values.
+
+
+
+
+
+
+g(t:DFLOAT):DFLOAT == sin(t)
+
+
+
+
+
+
+
+ Function declaration f : DoubleFloat -> DoubleFloat has been added
+ to workspace.
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Give to curve the names of the functions, then write the range
+without the name of the independent variable.
+
+
+
+
+
+draw(curve(f,g),0..%pi)
+
+
+
+
+
+
+
Here is another look at the same curve but over a different
+range. Notice that and are not recompiled. Also note that
+Axiom provides a default title based on the first function specified
+in curve.
+
+
+
+
+
+draw(curve(f,g),-4*%pi..4*%pi)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
7.1.3 Plotting Plane Algebraic Curves
+
+
+
+
+
+
A third kind of two-dimensional graph is a non-singular
+``solution curve'' curve:plane algebraic in a rectangular
+region of the plane. A solution curve is a curve defined by a
+polynomial equation . plane algebraic curve
+Non-singular means that the curve is ``smooth'' in that it does not
+cross itself or come to a point (cusp). Algebraically, this means
+that for any point on the curve, that is, a point such that
+ , the partial derivatives
+ and
+ are not both zero.
+curve:smoothcurve:non-singularsmooth curve
+non-singular curve
+
+
+
+
+
+
+
+
+
+
+
+
+
The general format for drawing a non-singular solution curve given by
+a polynomial of the form is:
+
+
+
+
+
+
+
+
draw(p(x,y) = 0, x, y, range == [a..b, c..d], options)
+
+
+
+
+
+
+
+
+
where the second and third arguments name the first and second
+independent variables of . A range option is always given to
+designate a bounding rectangular region of the plane
+ .
+Zero or more additional options as described in
+ugGraphTwoDOptions may be given.
+
+
+
+
+
+
+
+
+
+
We require that the polynomial has rational or integral coefficients.
+Here is an algebraic curve example (``Cartesian ovals''):
+Cartesian:ovals
+
The first argument is always expressed as an equation of the form
+where is a polynomial.
+
+
+
+
+
+draw(p = 0, x, y, range == [-1..11, -7..7])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
7.1.4 Two-Dimensional Options
+
+
+
+
+
+
The draw commands take an optional list of options, such as title shown above. Each option is given by the syntax:
+name==value.
+Here is a list of the available options in the
+order that they are described below.
+
+
+
+
+
adaptive
clip
unit
+
clip
curveColor
range
+
toScale
pointColor
coordinates
+
+
+
+
+
The option turns adaptive plotting on or off.
+adaptive plotting Adaptive plotting uses an algorithm that
+traverses a graph and computes more points for those parts of the
+graph with high curvature. The higher the curvature of a region is,
+the more points the algorithm computes.
+graphics:2D options:adaptive
+
+
+
+
The adaptive option is normally on. Here we turn it off.
+
The clip option turns clipping on or off.
+graphics:2D options:clipping
+If on, large values are cut off according to
+clipPointsDefaultclipPointsDefaultGraphicsDefaults.
+
+
+
+
+
+
+draw(tan(x),x=-2*%pi..2*%pi, clip == true)
+
+
+
+
+
+
+
+
Option toScale does plotting to scale if true or uses the
+entire viewport if false. The default can be determined using
+drawToScaledrawToScaleGraphicsDefaults.
+graphics:2D options:to scale
+
+
+
+
+
+
+draw(sin(x),x=-%pi..%pi, toScale == true, unit == [1.0,1.0])
+
+
+
+
+
+
+
+
Option clip with a range sets point clipping of a graph within
+the graphics:2D options:clip in a range ranges specified in
+the list . clipping If only one range is
+specified, clipping applies to the y-axis.
+
+
+
+
+
+draw(sec(x),x=-2*%pi..2*%pi, clip == [-2*%pi..2*%pi,-%pi..%pi], unit == [1.0,1.0])
+
+
+
+
+
+
+
+
Option curveColor sets the color of the graph curves or lines to
+be the graphics:2D options:curve color indicated palette color
+curve:color (see ugGraphColor and
+ugGraphColorPalette ).
+color:curve
+
Option pointColor sets the color of the graph points to the
+indicated graphics:2D options:point color palette color (see
+ugGraphColor and
+ugGraphColorPalette ).
+color:point
+
Option unit sets the intervals at which the axis units are
+plotted graphics:2D options:set units according to the
+indicated steps [ interval, interval].
+
+
+
+
+
+draw(curve(9*sin(3*t/4),8*sin(t)), t = -4*%pi..4*%pi, unit == [2.0,1.0])
+
+
+
+
+
+
+
+
Option range sets the range of variables in a graph to be within
+the ranges graphics:2D options:range for solving plane
+algebraic curve plots.
+
+
+
+
+
+draw(y**2 + y - (x**3 - x) = 0, x, y, range == [-2..2,-2..1], unit==[1.0,1.0])
+
+
+
+
+
+
+
+
A second example of a solution plot.
+
+
+
+
+
+draw(x**2 + y**2 = 1, x, y, range == [-3/2..3/2,-3/2..3/2], unit==[0.5,0.5])
+
+
+
+
+
+
+
+
Option indicates the coordinate system in which the
+graph graphics:2D options:coordinates is plotted. The default
+is to use the Cartesian coordinate system.
+Cartesian:coordinate system For more details, see
+ugGraphCoord
+or CoordinateSystems.
+coordinate system:Cartesian
+
The domain ColorColor provides operations for
+manipulating graphics:color colors in two-dimensional
+graphs. color Colors are objects of Color. Each color
+has a hue and a weight. hue Hues are represented
+by integers that range from to the
+numberOfHues()numberOfHues()Color, normally
+graphics:color:number of hues . weight Weights
+are floats and have the value by default.
+
+
+
+
+
color(integer)
+
+creates a color of hue integer and weight .
+
+
hue(color)
+
+returns the hue of color as an integer.
+graphics:color:hue function
+
+
red()
+
+blue(),
+green(), and yellow()
+graphics:color:primary color functions
+create colors of that hue with weight .
+
+
+
+
returns the
+color that results from additively combining the indicated
+ and .
+Color addition is not commutative: changing the order of the arguments
+produces different results.
+
+
integer*color
+
+changes the weight of color by integer
+without affecting its hue.
+graphics:color:multiply function
+For example,
+ produces a color closer to yellow than to red.
+Color multiplication is not associative: changing the order of grouping
+color:multiplication
+produces different results.
+
+
+
+
+
+
These functions can be used to change the point and curve colors
+for two- and three-dimensional graphs.
+Use the pointColor option for points.
+
Domain Palette is the domain of shades of colors:
+ dark, dim, bright, pastel, and light,
+designated by the integers through , respectively.
+Palette
+
+
+
+
Colors are normally ``bright.''
+
+
+
+
+
+
+
+shade red()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
To change the shade of a color, apply the name of a shade to it.
+color:shade
+shade
+
+
+
+
+
+
+
+myFavoriteColor := dark blue()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Palette
+
+
+
+
+
The expression
+returns the value of a shade of .
+
+
+
+
+
+
+
+shade myFavoriteColor
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The expression returns its hue.
+
+
+
+
+
+
+
+hue myFavoriteColor
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Color
+
+
+
+
+
Palettes can be used in specifying colors in two-dimensional graphs.
+
+
+
+
+
+
+draw(x**2,x=-1..1,curveColor == dark blue())
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
7.1.7 Two-Dimensional Control-Panel
+
+
+
+
+
+
graphics:2D control-panel
+Once you have created a viewport, move your mouse to the viewport and click
+with your left mouse button to display a control-panel.
+The panel is displayed on the side of the viewport closest to
+where you clicked. Each of the buttons which toggle on and off show the
+current state of the graph.
+
+
+
+
+
+
+
+
7.1.7.1 Transformations
+
+
+
graphics:2D control-panel:transformations
+
+
+
+
Object transformations are executed from the control-panel by mouse-activated
+potentiometer windows.
+
+
+
+
+
Scale:
+
To scale a graph, click on a mouse button
+graphics:2D control-panel:scale
+within the Scale window in the upper left corner of the control-panel.
+The axes along which the scaling is to occur are indicated by setting the
+toggles above the arrow.
+With X On and Y On appearing, both axes are selected and scaling
+is uniform.
+If either is not selected, for example, if X Off appears, scaling is
+non-uniform.
+
+
Translate:
+
To translate a graph, click the mouse in the
+graphics:2D control-panel:translate
+ Translate window in the direction you wish the graph to move.
+This window is located in the upper right corner of the control-panel.
+Along the top of the Translate window are two buttons for selecting
+the direction of translation.
+Translation along both coordinate axes results when X On and Y
+On appear or along one axis when one is on, for example, X On and
+Y Off appear.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
7.1.7.2 Messages
+
+
+
graphics:2D control-panel:messages
+
+
+
+
The window directly below the transformation potentiometer windows is
+used to display system messages relating to the viewport and the control-panel.
+The following format is displayed:
+
+
+
+
+
+
+
+
+
[scaleX, scaleY] graph [translateX, translateY]
+
+
+
+
+
+
+
+
The two values to the left show the scale factor along the X and
+Y coordinate axes. The two values to the right show the distance of
+translation from the center in the X and Y directions. The number
+in the center shows which graph in the viewport this data pertains to.
+When multiple graphs exist in the same viewport,
+the graph must be selected (see ``Multiple Graphs,'' below) in
+order for its transformation data to be shown, otherwise the number
+is 1.
+
+
+
+
+
+
+
+
+
+
+
+
7.1.7.3 Multiple Graphs
+
+
+
+
graphics:2D control-panel:multiple graphs
+The Graphs window contains buttons that allow the placement
+of two-dimensional graphs into one of nine available slots in any other
+two-dimensional viewport.
+In the center of the window are numeral buttons from one to nine
+that show whether a graph is displayed in the viewport.
+Below each number button is a button showing whether a graph
+that is present is selected for application of some
+transformation.
+When the caret symbol is displayed, then the graph in that slot
+will be manipulated.
+Initially, the graph for which the viewport is created occupies
+the first slot, is displayed, and is selected.
+
+
+
+
+
+
Clear:
+
The Clear button deselects every viewport graph slot.
+graphics:2D control-panel:clear
+A graph slot is reselected by selecting the button below its number.
+
+
Query:
+
The Query button is used to display the scale and
+graphics:2D control-panel:query
+translate data for the indicated graph. When this button is selected the
+message ``Click on the graph to query'' appears. Select a slot
+number button from the Graphs window. The scaling factor and translation
+offset of the graph are then displayed in the message window.
+
+
Pick:
+
The Pick button is used to select a graph
+graphics:2D control-panel:pick
+to be placed or dropped into the indicated viewport. When this button is
+selected, the message ``Click on the graph to pick'' appears.
+Click on the slot with the graph number of the desired
+graph. The graph information is held waiting for
+you to execute a Drop in some other graph.
+
+
Drop:
+
Once a graph has been picked up using the Pick button,
+graphics:2D control-panel:drop
+the Drop button places it into a new viewport slot.
+The message ``Click on the graph to drop'' appears in the message
+window when the Drop button is selected.
+By selecting one of the slot number buttons in the Graphs
+window, the graph currently being held is dropped into this slot
+and displayed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
7.1.7.4 Buttons
+
+
+
graphics:2D control-panel:buttons
+
+
+
+
+
+
Axes
+
turns the coordinate axes on or off.
+graphics:2D control-panel:axes
+
+
Units
+
turns the units along the x
+and y axis on or off.
+graphics:2D control-panel:units
+
+
Box
+
encloses the area of the viewport graph
+in a bounding box, or removes the box if already enclosed.
+graphics:2D control-panel:box
+
+
Pts
+
turns on or off the display of points.
+graphics:2D control-panel:points
+
+
Lines
+
turns on or off the display
+of lines connecting points.
+graphics:2D control-panel:lines
+
+
PS
+
writes the current viewport contents to
+graphics:2D control-panel:ps
+a file axiom2D.ps or to a name specified in the user's
+graphics:.Xdefaults:PostScript file name
+.Xdefaults file.
+file:.Xdefaults @ .Xdefaults
+The file is placed in the directory from which Axiom or the
+viewAlone program was invoked.
+PostScript
+
+
Reset
+
resets the object transformation
+characteristics and attributes back to their initial states.
+graphics:2D control-panel:reset
+
+
Hide
+
makes the control-panel disappear.
+graphics:2D control-panel:hide
+
+
Quit
+
queries whether the current viewport
+graphics:2D control-panel:quit
+session should be terminated.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
7.1.8 Operations for Two-Dimensional Graphics
+
+
+
+
+
+
Here is a summary of useful Axiom operations for two-dimensional
+graphics.
+Each operation name is followed by a list of arguments.
+Each argument is written as a variable informally named according
+to the type of the argument (for example, integer).
+If appropriate, a default value for an argument is given in
+parentheses immediately following the name.
+
+
+
+
+
+
adaptive([boolean(true)])
+
+adaptive plotting
+sets or indicates whether graphs are plotted
+graphics:set 2D defaults:adaptive
+according to the adaptive refinement algorithm.
+
+
axesColorDefault([color(dark blue())])
+
+sets or indicates the default color of the
+graphics:set 2D defaults:axes color
+axes in a two-dimensional graph viewport.
+
+
clipPointsDefault([boolean(false)])
+
+sets or
+indicates whether point clipping is
+graphics:set 2D defaults:clip points
+to be applied as the default for graph plots.
+
+
drawToScale([boolean(false)])
+
+sets or
+indicates whether the plot of a graph
+graphics:set 2D defaults:to scale
+is ``to scale'' or uses the entire viewport space as the default.
+
+
lineColorDefault([color(pastel yellow())])
+
+sets or indicates the default color of the
+graphics:set 2D defaults:line color
+lines or curves in a two-dimensional graph viewport.
+
+
maxPoints([integer(500)])
+
+sets or indicates
+the default maximum number of
+graphics:set 2D defaults:max points
+possible points to be used when constructing a two-dimensional graph.
+
+
minPoints([integer(21)])
+
+sets or indicates the default minimum number of
+graphics:set 2D defaults:min points
+possible points to be used when constructing a two-dimensional graph.
+
+
pointColorDefault([color(bright red())])
+
+sets or indicates the default color of the
+graphics:set 2D defaults:point color
+points in a two-dimensional graph viewport.
+
+
pointSizeDefault([integer(5)])
+
+sets or indicates the default size of the
+graphics:set 2D defaults:point size
+dot used to plot points in a two-dimensional graph.
+
+
screenResolution([integer(600)])
+
+sets or indicates the default screen
+graphics:set 2D defaults:screen resolution
+resolution constant used in setting the computation limit of adaptively
+adaptive plotting
+generated curve plots.
+
+
unitsColorDefault([color(dim green())])
+
+sets or indicates the default color of the
+graphics:set 2D defaults:units color
+unit labels in a two-dimensional graph viewport.
+
+
viewDefaults()
+
+resets the default settings for the following
+graphics:set 2D defaults:reset viewport
+attributes: point color, line color, axes color, units color, point size,
+viewport upper left-hand corner position, and the viewport size.
+
+
viewPosDefault([list([100,100])])
+
+sets or indicates the default position of the
+graphics:set 2D defaults:viewport position
+upper left-hand corner of a two-dimensional viewport, relative to the
+display root window.
+The upper left-hand corner of the display is considered to be at the
+(0, 0) position.
+
+
viewSizeDefault([list([200,200])])
+
+sets or
+indicates the default size in which two
+graphics:set 2D defaults:viewport size
+dimensional viewport windows are shown.
+It is defined by a width and then a height.
+
+indicates the possible file types
+graphics:2D defaults:available viewport writes
+that can be created with the writewriteTwoDimensionalViewport function.
+
+
viewWriteDefault([list([])])
+
+sets or indicates the default types of files, in
+graphics:set 2D defaults:write viewport
+addition to the data file, that are created when a
+ write function is executed on a viewport.
+
+
units(viewport, integer(1), string("off"))
+
+turns the units on or off for the graph with index integer.
+
+
axes(viewport, integer(1), string("on"))
+
+turns the axes on
+graphics:2D commands:axes
+or off for the graph with index integer.
+
+
close(viewport)
+
+closes viewport.
+graphics:2D commands:close
+
+
connect(viewport, integer(1), string("on"))
+
+declares whether lines
+graphics:2D commands:connect
+connecting the points are displayed or not.
+
+
controlPanel(viewport, string("off"))
+
+declares
+whether the two-dimensional control-panel is automatically displayed
+or not.
+
+
graphs(viewport)
+
+returns a list
+graphics:2D commands:graphs
+describing the state of each graph.
+If the graph state is not being used this is shown by "undefined",
+otherwise a description of the graph's contents is shown.
+
+
graphStates(viewport)
+
+displays
+graphics:2D commands:state of graphs
+a list of all the graph states available for viewport, giving the
+values for every property.
+
+
key(viewport)
+
+returns the process
+graphics:2D commands:key
+ID number for viewport.
+
+moves viewport on the screen so that the
+graphics:2D commands:move
+upper left-hand corner of viewport is at the position (x,y).
+
+
options(viewport)
+
+returns a list
+graphics:2D commands:options
+of all the DrawOptions used by viewport.
+
+
points(viewport, integer(1), string("on"))
+
+specifies whether the graph points for graph integer are
+graphics:2D commands:points
+to be displayed or not.
+
+
region(viewport, integer(1), string("off"))
+
+declares whether graph integer is or is not to be displayed
+with a bounding rectangle.
+
+
reset(viewport)
+
+resets all the properties of viewport.
+
+
resize(viewport,
+ , )
+
+graphics:2D commands:resize
+resizes viewport with a new width and height.
+
+
scale(viewport, (1),
+ (0.9), (0.9))
+
+scales values for the
+graphics:2D commands:scale
+x and y coordinates of graph n.
+
+
show(viewport, (1),
+string("on"))
+
+indicates if graph n is shown or not.
+
+
title(viewport, string("Axiom 2D"))
+
+designates the title for viewport.
+
+
translate(viewport,
+ (1),
+ (0.0), (0.0))
+
+graphics:2D commands:translate
+causes graph n to be moved x and y units in the respective directions.
+
+
write(viewport, ,
+[strings])
+
+if no third argument is given, writes the data file onto the directory
+with extension data.
+The third argument can be a single string or a list of strings with some or
+all the entries "pixmap", "bitmap", "postscript", and
+"image".
+
+
+
+
+
+
+
+
+
+
+
+
+
+
7.1.9 Addendum: Building Two-Dimensional Graphs
+
+
+
+
+
+
In this section we demonstrate how to create two-dimensional graphs from
+lists of points and give an example showing how to read the lists
+of points from a file.
+
+
+
+
+
+
+
7.1.9.1 Creating a Two-Dimensional Viewport from a List of Points
+
+
+
+
Axiom creates lists of points in a two-dimensional viewport by utilizing
+the GraphImage and TwoDimensionalViewport domains.
+In this example, the makeGraphImagemakeGraphImageGraphImage
+function takes a list of lists of points parameter, a list of colors for
+each point in the graph, a list of colors for each line in the graph, and
+a list of sizes for each point in the graph.
+
+
+
+
+
The following expressions create a list of lists of points which will be read
+by Axiom and made into a two-dimensional viewport.
+
The makeViewport2DmakeViewport2DTwoDimensionalViewport function now
+creates a TwoDimensionalViewport for this graph according to the
+list of options specified within the brackets.
+
+
+
+
+
+
+makeViewport2D(g,[title("Lines")])$VIEW2D
+
+
+
+
+
+
+
This example demonstrates the use of the GraphImage functions
+componentcomponentGraphImage and appendPointappendPointGraphImage
+in adding points to an empty GraphImage.
+
A list of points can also be made into a GraphImage by using
+the operation coercecoerceGraphImage. It is equivalent to adding
+each point to using componentcomponentGraphImage.
+
7.1.9.2 Creating a Two-Dimensional Viewport of a List of Points from a File
+
+
+
+
The following three functions read a list of points from a
+file and then draw the points and the connecting lines. The
+points are stored in the file in readable form as floating point numbers
+(specifically, DoubleFloat values) as an alternating
+stream of - and -values. For example,
+
+drawPoints(lp:List Point DoubleFloat):VIEW2D ==
+ g := graphImage()$GRIMAGE
+ for p in lp repeat
+ component(g,p,pointColorDefault(),lineColorDefault(),
+ pointSizeDefault())
+ gi := makeGraphImage(g)$GRIMAGE
+ makeViewport2D(gi,[title("Points")])$VIEW2D
+
+drawLines(lp:List Point DoubleFloat):VIEW2D ==
+ g := graphImage()$GRIMAGE
+ component(g, lp, pointColorDefault(), lineColorDefault(),
+ pointSizeDefault())$GRIMAGE
+ gi := makeGraphImage(g)$GRIMAGE
+ makeViewport2D(gi,[title("Points")])$VIEW2D
+
+plotData2D(name, title) ==
+ f:File(DFLOAT) := open(name,"input")
+ lp:LIST(Point DFLOAT) := empty()
+ while ((x := readIfCan!(f)) case DFLOAT) repeat
+ y : DFLOAT := read!(f)
+ lp := cons(point [x,y]$(Point DFLOAT), lp)
+ lp
+ close!(f)
+ drawPoints(lp)
+ drawLines(lp)
+
+
+
+
+
This command will actually create the viewport and the graph if
+the point data is in the file .
+
+
+
+
+
+plotData2D("file.data", "2D Data Plot")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
7.1.10 Addendum: Appending a Graph to a Viewport Window Containing a Graph
+
+
+
+
+
+
This section demonstrates how to append a two-dimensional graph to a viewport
+already containing other graphs.
+The default draw command places a graph into the first
+GraphImage slot position of the TwoDimensionalViewport.
+
+
+
+
This graph is in the first slot in its viewport.
+
The Axiom three-dimensional graphics package provides the ability to
+graphics:three-dimensional
+
+
+
+
+
+
+
+ generate surfaces defined by a function of two real variables
+
+
generate space curves and tubes defined by parametric equations
+
+
generate surfaces defined by parametric equations
+
+
+
+
+
These graphs can be modified by using various options, such as calculating
+points in the spherical coordinate system or changing the polygon grid size
+of a surface.
+
+
+
+
+
+
+
7.2.1 Plotting Three-Dimensional Functions of Two Variables
+
+
+
+
+
+
surface:two variable function
+The simplest three-dimensional graph is that of a surface defined by a function
+of two variables, .
+
+
+
+
+
+
+
+
+
+
+
+
+
The general format for drawing a surface defined by a formula
+of two variables and is:
+
+
+
+
+
+
+
+
+
draw(f(x,y), x = a..b, y = c..d, options)
+
+
+
+
+
+
+
+
where and define the range of
+and , and where options prescribes zero or more
+options as described in ugGraphThreeDOptions
+.
+An example of an option is
+An alternative format involving a function is also
+available.
+
+
+
+
+
+
+
+
+
+
The simplest way to plot a function of two variables is to use a formula.
+With formulas you always precede the range specifications with
+the variable name and an = sign.
+
+
+
+
+
+
+draw(cos(x*y),x=-3..3,y=-3..3)
+
+
+
+
+
+
+
+
If you intend to use a function more than once,
+or it is long and complex, then first
+give its definition to Axiom.
+
+
+
+
+
+
+
+f(x,y) == sin(x)*cos(y)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
To draw the function, just give its name and drop the variables
+from the range specifications.
+Axiom compiles your function for efficient computation
+of data for the graph.
+Notice that Axiom uses the text of your function as a
+default title.
+
+
+
+
+
+
+draw(f,-%pi..%pi,-%pi..%pi)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
7.2.2 Plotting Three-Dimensional Parametric Space Curves
+
+
+
+
+
+
+
A second kind of three-dimensional graph is a three-dimensional space curve
+curve:parametric space
+defined by the parametric equations for , ,
+parametric space curve
+and as a function of an independent variable .
+
+
+
+
+
+
+
+
+
+
+
+
+
The general format for drawing a three-dimensional space curve defined by
+parametric formulas , , and
+ is:
+
+
+
+
+
+
+
+
+
draw(curve(f(t),g(t),h(t)), t = a..b, options)
+
+
+
+
+
+
+
+
where defines the range of the independent variable
+ , and where options prescribes zero or more options
+as described in ugGraphThreeDOptions
+.
+An example of an option is
+An alternative format involving functions , and
+ is also available.
+
+
+
+
+
+
+
+
+
+
If you use explicit formulas to draw a space curve, always precede
+the range specification with the variable name and an
+= sign.
+
+
+
+
+
+
+draw(curve(5*cos(t), 5*sin(t),t), t=-12..12)
+
+
+
+
+
+
+
+
Alternatively, you can draw space curves by referring to functions.
+
+
+
+
+
+
+
+i1(t:DFLOAT):DFLOAT == sin(t)*cos(3*t/5)
+
+
+
+
+
+
+
+ Function declaration i1 : DoubleFloat -> DoubleFloat has been added
+ to workspace.
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
This is useful if the functions are to be used more than once ...
+
+
+
+
+
+
+
+i2(t:DFLOAT):DFLOAT == cos(t)*cos(3*t/5)
+
+
+
+
+
+
+
+ Function declaration i2 : DoubleFloat -> DoubleFloat has been added
+ to workspace.
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
or if the functions are long and complex.
+
+
+
+
+
+
+
+i3(t:DFLOAT):DFLOAT == cos(t)*sin(3*t/5)
+
+
+
+
+
+
+
+ Function declaration i3 : DoubleFloat -> DoubleFloat has been added
+ to workspace.
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Give the names of the functions and
+drop the variable name specification in the second argument.
+Again, Axiom supplies a default title.
+
surface:parametric
+A third kind of three-dimensional graph is a surface defined by
+parametric surface
+parametric equations for , , and
+ of two independent variables and .
+
+
+
+
+
+
+
+
+
+
+
+
+
+
The general format for drawing a three-dimensional graph defined by
+parametric formulas , ,
+and is:
+
+
+
+
+
+
+
+
+
draw(surface(f(u,v),g(u,v),h(u,v)), u = a..b, v = c..d, options)
+
+
+
+
+
+
+
+
where and define the range of the
+independent variables and , and where
+options prescribes zero or more options as described in
+ugGraphThreeDOptions .
+An example of an option is
+An alternative format involving functions , and
+ is also available.
+
+
+
+
+
+
+
+
+
+
This example draws a graph of a surface plotted using the
+parabolic cylindrical coordinate system option.
+coordinate system:parabolic cylindrical
+The values of the functions supplied to surface are
+parabolic cylindrical coordinate system
+interpreted in coordinates as given by a coordinates option,
+here as parabolic cylindrical coordinates (see
+ugGraphCoord ).
+
Again, you can graph these parametric surfaces using functions,
+if the functions are long and complex.
+
+
+
+
Here we declare the types of arguments and values to be of type
+DoubleFloat.
+
+
+
+
+
+
+
+n1(u:DFLOAT,v:DFLOAT):DFLOAT == u*cos(v)
+
+
+
+
+
+
+
+ Function declaration n1 : DoubleFloat -> DoubleFloat has been added
+ to workspace.
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
As shown by previous examples, these declarations are necessary.
+
+
+
+
+
+
+
+n2(u:DFLOAT,v:DFLOAT):DFLOAT == u*sin(v)
+
+
+
+
+
+
+
+ Function declaration n2 : DoubleFloat -> DoubleFloat has been added
+ to workspace.
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
In either case, Axiom compiles the functions
+when needed to graph a result.
+
+
+
+
+
+
+
+n3(u:DFLOAT,v:DFLOAT):DFLOAT == u
+
+
+
+
+
+
+
+ Function declaration n3 : DoubleFloat -> DoubleFloat has been added
+ to workspace.
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Without these declarations, you have to suffix floats
+with to get a DoubleFloat result.
+However, a call here with an unadorned float produces a DoubleFloat.
+
+
+
+
+
+
+
+n3(0.5,1.0)
+
+
+
+
+
+
+
+ Compiling function n3 with type (DoubleFloat,DoubleFloat) ->
+ DoubleFloat
+
+
+
+
+
+
+Type: DoubleFloat
+
+
+
+
+
Draw the surface by referencing the function names, this time
+choosing the toroidal coordinate system.
+coordinate system:toroidal
+toroidal coordinate system
+
graphics:3D options
+The draw commands optionally take an optional list of options such
+as coordinates as shown in the last example.
+Each option is given by the syntax: == .
+Here is a list of the available options in the order that they are
+described below:
+
+
+
+
+
title
coordinates
var1Steps
+
style
tubeRadius
var2Steps
+
colorFunction
tubePoints
space
+
+
+
+
+
The option gives your graph a title.
+graphics:3D options:title
+
+
+
+
+
+
+draw(cos(x*y),x=0..2*%pi,y=0..%pi,title == "Title of Graph")
+
+
+
+
+
+
+
+
The determines which of four rendering algorithms is used for
+rendering
+the graph.
+The choices are
+"wireMesh", "solid", "shade", and "smooth".
+
In all but the wire-mesh style, polygons in a surface or tube plot
+are normally colored in a graph according to their
+ -coordinate value. Space curves are colored according to their
+parametric variable value.
+graphics:3D options:color function
+To change this, you can give a coloring function.
+function:coloring
+The coloring function is sampled across the range of its arguments, then
+normalized onto the standard Axiom colormap.
+
+
+
+
A function of one variable makes the color depend on the
+value of the parametric variable specified for a tube plot.
+
Normally the Cartesian coordinate system is used.
+Cartesian:coordinate system
+To change this, use the coordinates option.
+coordinate system:Cartesian
+For details, see ugGraphCoord .
+
+
+
+
+
+
+
+m(u:DFLOAT,v:DFLOAT):DFLOAT == 1
+
+
+
+
+
+
+
+ Function declaration m : (DoubleFloat,DoubleFloat) -> DoubleFloat
+ has been added to workspace.
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Use the spherical
+spherical coordinate system
+coordinate system.
+coordinate system:spherical
+
Space curves may be displayed as tubes with polygonal cross sections.
+tube
+Two options, tubeRadius and tubePoints, control the size and
+shape of this cross section.
+
+
+
+
+
The tubeRadius option specifies the radius of the tube that
+tube:radius
+encircles the specified space curve.
+
The tubePoints option specifies the number of vertices
+tube:points in polygon
+defining the polygon that is used to create a tube around the
+specified space curve.
+The larger this number is, the more cylindrical the tube becomes.
+
Options var1Stepsvar1StepsDrawOption and
+var2Stepsvar2StepsDrawOption specify the number of intervals into
+which the grid defining a surface plot is subdivided with respect to the
+first and second parameters of the surface function(s).
+
The space option
+of a draw command lets you build multiple graphs in three space.
+To use this option, first create an empty three-space object,
+then use the space option thereafter.
+There is no restriction as to the number or kinds
+of graphs that can be combined this way.
+
+
+
+
Create an empty three-space object.
+
+
+
+
+
+
+
+s := create3Space()$(ThreeSpace DFLOAT)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: ThreeSpace DoubleFloat
+
+
+
+
+
+
+
+
+m(u:DFLOAT,v:DFLOAT):DFLOAT == 1
+
+
+
+
+
+
+
+ Function declaration m : (DoubleFloat,DoubleFloat) -> DoubleFloat
+ has been added to workspace.
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Add a graph to this three-space object.
+The new graph destructively inserts the graph
+into .
+
+
+
+
+
+
+draw(m,0..%pi,0..2*%pi, coordinates == spherical, space == s)
+
A three-space object can also be obtained from an existing three-dimensional viewport
+using the subspacesubspaceThreeSpace command.
+You can then use makeViewport3D to create a viewport window.
+
+
+
+
Assign to the three-space object in viewport .
+
+
+
+
+
+
+
+subsp := subspace v
+
+
+
+
+
+
Reset the space component of to the value of .
+
+
+
+
+
+
+
+subspace(v, subsp)
+
+
+
+
+
+
Create a viewport window from a three-space object.
+
+
+
+
+
+
+makeViewport3D(subsp,"Graphs")
+
+
+
+
+
+
+
+
+
+
+
+
+
7.2.5 The makeObject Command
+
+
+
+
+
+
An alternate way to create multiple graphs is to use
+ makeObject.
+The makeObject command is similar to the draw
+command, except that it returns a three-space object rather than a
+ThreeDimensionalViewport.
+In fact, makeObject is called by the draw
+command to create the ThreeSpace then
+makeViewport3DmakeViewport3DThreeDimensionalViewport to create a
+viewport window.
+
+
+
+
+
+
+
+m(u:DFLOAT,v:DFLOAT):DFLOAT == 1
+
+
+
+
+
+
+
+ Function declaration m : (DoubleFloat,DoubleFloat) -> DoubleFloat
+ has been added to workspace.
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Do the last example a new way.
+First use makeObject to
+create a three-space object .
+
+ Compiling function %D with type DoubleFloat -> DoubleFloat
+ Compiling function %F with type DoubleFloat -> DoubleFloat
+ Compiling function %H with type DoubleFloat -> DoubleFloat
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: ThreeSpace DoubleFloat
+
+
+
+
+
Create and display a viewport
+containing .
+
+
+
+
+
+
+makeViewport3D(sph,"Multiple Objects")
+
+
+
+
+
Note that an undefined ThreeSpace parameter declared in a
+ makeObject or draw command results in an error.
+Use the create3Spacecreate3SpaceThreeSpace function to define a
+ThreeSpace, or obtain a ThreeSpace that has been
+previously generated before including it in a command line.
+
+
+
+
+
+
+
+
+
+
+
+
7.2.6 Building Three-Dimensional Objects From Primitives
+
+
+
+
+
+
Rather than using the draw and makeObject commands,
+graphics:advanced:build 3D objects
+you can create three-dimensional graphs from primitives.
+Operation create3Spacecreate3SpaceThreeSpace creates a
+three-space object to which points, curves and polygons
+can be added using the operations from the ThreeSpace
+domain.
+The resulting object can then be displayed in a viewport using
+makeViewport3DmakeViewport3DThreeDimensionalViewport.
+
Create and display the viewport using makeViewport3D.
+Options may also be given but here are displayed as a list with values
+enclosed in parentheses.
+
+
+
+
+
+
+makeViewport3D(space, title == "Letters")
+
+
+
+
+
+
+
+
+
+
+
7.2.6.1 Cube Example
+
+
+
+
As a second example of the use of primitives, we generate a cube using a
+polygon mesh.
+It is important to use a consistent orientation of the polygons for
+correct generation of three-dimensional objects.
+
For convenience,
+give DoubleFloat values and names.
+
+
+
+
+
+
+
+x: DFLOAT := 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DoubleFloat
+
+
+
+
+
+
+
+
+y: DFLOAT := -1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DoubleFloat
+
+
+
+
+
Define the vertices of the cube.
+
+
+
+
+
+
+
+a := point [x,x,y,1::DFLOAT]$(Point DFLOAT)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Point DoubleFloat
+
+
+
+
+
+
+
+
+b := point [y,x,y,4::DFLOAT]$(Point DFLOAT)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Point DoubleFloat
+
+
+
+
+
+
+
+
+c := point [y,x,x,8::DFLOAT]$(Point DFLOAT)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Point DoubleFloat
+
+
+
+
+
+
+
+
+d := point [x,x,x,12::DFLOAT]$(Point DFLOAT)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Point DoubleFloat
+
+
+
+
+
+
+
+
+e := point [x,y,y,16::DFLOAT]$(Point DFLOAT)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Point DoubleFloat
+
+
+
+
+
+
+
+
+f := point [y,y,y,20::DFLOAT]$(Point DFLOAT)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Point DoubleFloat
+
+
+
+
+
+
+
+
+g := point [y,y,x,24::DFLOAT]$(Point DFLOAT)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Point DoubleFloat
+
+
+
+
+
+
+
+
+h := point [x,y,x,27::DFLOAT]$(Point DFLOAT)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Point DoubleFloat
+
+
+
+
+
Add the faces of the cube as polygons to the space using a
+consistent orientation.
+
+
+
+
+
+
+
+polygon(spaceC,[d,c,g,h])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: ThreeSpace DoubleFloat
+
+
+
+
+
+
+
+
+polygon(spaceC,[d,h,e,a])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: ThreeSpace DoubleFloat
+
+
+
+
+
+
+
+
+polygon(spaceC,[c,d,a,b])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: ThreeSpace DoubleFloat
+
+
+
+
+
+
+
+
+polygon(spaceC,[g,c,b,f])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: ThreeSpace DoubleFloat
+
+
+
+
+
+
+
+
+polygon(spaceC,[h,g,f,e])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: ThreeSpace DoubleFloat
+
+
+
+
+
+
+
+
+polygon(spaceC,[e,f,b,a])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: ThreeSpace DoubleFloat
+
+
+
+
+
Create and display the viewport.
+
+
+
+
+
+
+makeViewport3D(spaceC, title == "Cube")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
7.2.7 Coordinate System Transformations
+
+
+
+
+
graphics:advanced:coordinate systems
+
+
+
+
The CoordinateSystems package provides coordinate transformation
+functions that map a given data point from the coordinate system specified
+into the Cartesian coordinate system.
+CoordinateSystems
+The default coordinate system, given a triplet , assumes
+that , and ,
+that is, reads the coordinates in order.
+
+
+
+
+
+
+
+m(u:DFLOAT,v:DFLOAT):DFLOAT == u**2
+
+
+
+
+
+
+
+ Function declaration m : (DoubleFloat,DoubleFloat) -> DoubleFloat
+ has been added to workspace.
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Graph plotted in default coordinate system.
+
+
+
+
+
+
+draw(m,0..3,0..5)
+
+
+
+
+
+
+
+
The coordinate comes first since the first argument of
+the draw command gives its values.
+In general, the coordinate systems Axiom provides, or any
+that you make up, must provide a map to an triplet in
+order to be compatible with the
+coordinatescoordinatesDrawOptionDrawOption.
+DrawOption
+Here is an example.
+
+
+
+
Define the identity function.
+
+
+
+
+
+
+
+cartesian(point:Point DFLOAT):Point DFLOAT == point
+
+
+
+
+
+
+
+ Function declaration cartesian : Point DoubleFloat -> Point
+ DoubleFloat has been added to workspace.
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Pass as the coordinatescoordinatesDrawOption
+parameter to the draw command.
+
+
+
+
+
+
+draw(m,0..3,0..5,coordinates==cartesian)
+
+
+
+
+
+
+
+
What happened? The option coordinates == cartesian directs
+Axiom to treat the dependent variable defined by as the
+ coordinate. Thus the triplet of values is transformed
+to coordinates and so we get the graph of .
+
+
+
+
Here is another example.
+The cylindricalcylindricalCoordinateSystems transform takes
+coordinate system:cylindrical
+input of the form , interprets it in the order
+cylindrical coordinate system
+( , , )
+and maps it to the Cartesian coordinates
+ , ,
+in which
+ is the radius,
+ is the angle and
+ is the z-coordinate.
+
+
+
+
An example using the cylindricalcylindricalCoordinateSystems
+coordinates for the constant .
+
+
+
+
+
+
+
+f(u:DFLOAT,v:DFLOAT):DFLOAT == 3
+
+
+
+
+
+
+
+ Function declaration f : (DoubleFloat,DoubleFloat) -> DoubleFloat
+ has been added to workspace.
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
Graph plotted in cylindrical coordinates.
+
+
+
+
+
+
+draw(f,0..%pi,0..6,coordinates==cylindrical)
+
+
+
+
+
+
+
+
Suppose you would like to specify as a function of
+ and instead of just ?
+Well, you still can use the cylindrical Axiom
+transformation but we have to reorder the triplet before
+passing it to the transformation.
+
+
+
+
First, let's create a point to
+work with and call it with some color .
+
+
+
+
+
+
+
+col := 5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+pt := point[1,2,3,col]$(Point DFLOAT)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Point DoubleFloat
+
+
+
+
+
The reordering you want is
+ to
+
+so that the first element is moved to the third element, while the second
+and third elements move forward and the color element does not change.
+
+
+
+
Define a function reorder to reorder the point elements.
+
+ Function declaration newmap : Point DoubleFloat -> Point DoubleFloat
+ has been added to workspace.
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+newmap pt
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Point DoubleFloat
+
+
+
+
+
Graph the same function using the coordinate mapping of the function
+ , so it is now interpreted as
+ :
+
+
+
+
+
+
+draw(f,0..3,0..2*%pi,coordinates==newmap)
+
+
+
+
+
+
+
+
+
+
The CoordinateSystems package exports the following
+coordinate system
+operations:
+ bipolar,
+ bipolarCylindrical,
+ cartesian,
+ conical,
+ cylindrical,
+ elliptic,
+ ellipticCylindrical,
+ oblateSpheroidal,
+ parabolic,
+ parabolicCylindrical,
+ paraboloidal,
+ polar,
+ prolateSpheroidal,
+ spherical, and
+ toroidal.
+Use Browse or the )show system command
+show
+to get more information.
+
+
+
+
+
+
+
+
+
+
+
+
7.2.8 Three-Dimensional Clipping
+
+
+
+
+
+
A three-dimensional graph can be explicitly clipped within the draw
+graphics:advanced:clip
+command by indicating a minimum and maximum threshold for the
+clipping
+given function definition.
+These thresholds can be defined using the Axiom min
+and max functions.
+
+
+
+
+
+
+gamma(x,y) ==
+ g := Gamma complex(x,y)
+ point [x, y, max( min(real g, 4), -4), argument g]
+
+
+
+
+
Here is an example that clips
+the gamma function in order to eliminate the extreme divergence it creates.
+
graphics:3D control-panel
+Once you have created a viewport, move your mouse to the viewport
+and click with your left mouse button.
+This displays a control-panel on the side of the viewport
+that is closest to where you clicked.
+
+
+
+
+
+
+
Three-dimensional control-panel.
+
+
+
+
+
+
7.2.9.1 Transformations
+
+
+
+
We recommend you first select the Bounds button while
+graphics:3D control-panel:transformations
+executing transformations since the bounding box displayed
+indicates the object's position as it changes.
+
+
+
+
+
Rotate:
+
A rotation transformation occurs by clicking the mouse
+graphics:3D control-panel:rotate
+within the Rotate window in the upper left corner of the
+control-panel.
+The rotation is computed in spherical coordinates, using the
+horizontal mouse position to increment or decrement the value of
+the longitudinal angle within the
+range of 0 to 2 and the vertical mouse position
+to increment or decrement the value of the latitudinal angle
+ within the range of -
+to .
+The active mode of rotation is displayed in green on a color
+monitor or in clear text on a black and white monitor, while the
+inactive mode is displayed in red for color display or a mottled
+pattern for black and white.
+
+
origin:
+
The origin button indicates that the
+rotation is to occur with respect to the origin of the viewing space, that is
+indicated by the axes.
+
+
object:
+
The object button indicates that the
+rotation is to occur with respect to the center of volume of the object,
+independent of the axes' origin position.
+
+
+
+
Scale:
+
A scaling transformation occurs by clicking the mouse
+graphics:3D control-panel:scale
+within the Scale window in the upper center of the
+control-panel, containing a zoom arrow.
+The axes along which the scaling is to occur are indicated by
+selecting the appropriate button above the zoom arrow window.
+The selected axes are displayed in green on a color monitor or in
+clear text on a black and white monitor, while the unselected axes
+are displayed in red for a color display or a mottled pattern for
+black and white.
+
+
uniform:
+
Uniform scaling along the x, y
+and z axes occurs when all the axes buttons are selected.
+
+
non-uniform:
+
If any of the axes buttons are
+not selected, non-uniform scaling occurs, that is, scaling occurs only in the
+direction of the axes that are selected.
+
+
+
+
Translate:
+
Translation occurs by indicating with the mouse in the
+graphics:3D control-panel:translate
+ Translate window the direction you want the graph to move.
+This window is located in the upper right corner of the
+control-panel and contains a potentiometer with crossed arrows
+pointing up, down, left and right.
+Along the top of the Translate window are three buttons
+( XY,
+ XZ, and YZ) indicating the three orthographic projection planes.
+Each orientates the group as a view into that plane.
+Any translation of the graph occurs only along this plane.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
7.2.9.2 Messages
+
+
+
+
graphics:3D control-panel:messages
+
+
+
+
The window directly below the potentiometer windows for transformations is
+used to display system messages relating to the viewport, the control-panel
+and the current graph displaying status.
+
+
+
+
+
+
+
+
+
+
+
+
7.2.9.3 Colormap
+
+
+
+
graphics:3D control-panel:color map
+
+
+
+
Directly below the message window is the colormap range indicator
+window.
+colormap
+The Axiom Colormap shows a sampling of the spectrum from
+which hues can be drawn to represent the colors of a surface.
+The Colormap is composed of five shades for each of the hues along
+this spectrum.
+By moving the markers above and below the Colormap, the range of
+hues that are used to color the existing surface are set.
+The bottom marker shows the hue for the low end of the color range
+and the top marker shows the hue for the upper end of the range.
+Setting the bottom and top markers at the same hue results in
+monochromatic smooth shading of the graph when Smooth mode is selected.
+At each end of the Colormap are + and - buttons.
+When clicked on, these increment or decrement the top or bottom
+marker.
+
+
+
+
+
+
+
+
+
+
+
+
7.2.9.4 Buttons
+
+
+
graphics:3D control-panel:buttons
+
+
+
+
Below the Colormap window and to the left are located various
+buttons that determine the characteristics of a graph.
+The buttons along the bottom and right hand side all have special
+meanings; the remaining buttons in the first row indicate the mode
+or style used to display the graph.
+The second row are toggles that turn on or off a property of the
+graph.
+On a color monitor, the property is on if green (clear text, on a
+monochrome monitor) and off if red (mottled pattern, on a
+monochrome monitor).
+Here is a list of their functions.
+
+
+
+
+
Wire
+
displays surface and tube plots as a
+graphics:3D control-panel:wire
+wireframe image in a single color (blue) with no hidden surfaces removed,
+or displays space curve plots in colors based upon their parametric variables.
+This is the fastest mode for displaying a graph.
+This is very useful when you
+want to find a good orientation of your graph.
+
+
Solid
+
displays the graph with hidden
+graphics:3D control-panel:solid
+surfaces removed, drawing each polygon beginning with the furthest
+from the viewer.
+The edges of the polygons are displayed in the hues specified by
+the range in the Colormap window.
+
+
Shade
+
displays the graph with hidden
+graphics:3D control-panel:shade
+surfaces removed and with the polygons shaded, drawing each
+polygon beginning with the furthest from the viewer.
+Polygons are shaded in the hues specified by the range in the
+Colormap window using the Phong illumination model.
+Phong:illumination model
+
+
Smooth
+
displays the graph using a
+graphics:3D control-panel:smooth
+renderer that computes the graph one line at a time.
+The location and color of the graph at each visible point on the
+screen are determined and displayed using the Phong illumination
+Phong:illumination model
+model.
+Smooth shading is done in one of two ways, depending on the range
+selected in the colormap window and the number of colors available
+from the hardware and/or window manager.
+When the top and bottom markers of the colormap range are set to
+different hues, the graph is rendered by dithering between the
+dithering
+transitions in color hue.
+When the top and bottom markers of the colormap range are set to
+the same hue, the graph is rendered using the Phong smooth shading
+model.
+Phong:smooth shading model
+However, if enough colors cannot be allocated for this purpose,
+the renderer reverts to the color dithering method until a
+sufficient color supply is available.
+For this reason, it may not be possible to render multiple Phong
+smooth shaded graphs at the same time on some systems.
+
+
Bounds
+
encloses the entire volume of the
+viewgraph within a bounding box, or removes the box if previously selected.
+graphics:3D control-panel:bounds
+The region that encloses the entire volume of the viewport graph is displayed.
+
+
Axes
+
displays Cartesian
+graphics:3D control-panel:axes
+coordinate axes of the space, or turns them off if previously selected.
+
+
Outline
+
causes
+graphics:3D control-panel:outline
+quadrilateral polygons forming the graph surface to be outlined in black when
+the graph is displayed in Shade mode.
+
+
BW
+
converts a color viewport to black and white, or vice-versa.
+graphics:3D control-panel:bw
+When this button is selected the
+control-panel and viewport switch to an immutable colormap composed of a range
+of grey scale patterns or tiles that are used wherever shading is necessary.
+
+
Light
+
takes you to a control-panel described below.
+
+
ViewVolume
+
takes you to another control-panel as described below.
+graphics:3D control-panel:save
+
+
Save
+
creates a menu of the possible file types that can
+be written using the control-panel.
+The Exit button leaves the save menu.
+The Pixmap button writes an Axiom pixmap of
+graphics:3D control-panel:pixmap
+the current viewport contents. The file is called axiom3D.pixmap and is
+located in the directory from which Axiom or viewAlone was
+started.
+The PS button writes the current viewport contents to
+graphics:3D control-panel:ps
+PostScript output rather than to the viewport window.
+By default the file is called axiom3D.ps; however, if a file
+file:.Xdefaults @ .Xdefaults
+name is specified in the user's .Xdefaults file it is
+graphics:.Xdefaults:PostScript file name
+used.
+The file is placed in the directory from which the Axiom or
+ viewAlone session was begun.
+See also the writewriteThreeDimensionalViewport
+function.
+PostScript
+
+
Reset
+
returns the object transformation
+graphics:3D control-panel:reset
+characteristics back to their initial states.
+
+
Hide
+
causes the control-panel for the
+graphics:3D control-panel:hide
+corresponding viewport to disappear from the screen.
+
+
Quit
+
queries whether the current viewport
+graphics:3D control-panel:quit
+session should be terminated.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
7.2.9.5 Light
+
+
+
+
graphics:3D control-panel:light
+
+
+
+
+
+
+
+
+
+
+
The Light button changes the control-panel into the
+ Lighting Control-Panel. At the top of this panel, the three axes
+are shown with the same orientation as the object. A light vector from
+the origin of the axes shows the current position of the light source
+relative to the object. At the bottom of the panel is an Abort
+button that cancels any changes to the lighting that were made, and a
+ Return button that carries out the current set of lighting changes
+on the graph.
+
+
+
+
+
XY:
+
The XY lighting axes window is below the
+graphics:3D control-panel:move xy
+ Lighting Control-Panel title and to the left.
+This changes the light vector within the XY view plane.
+
+
Z:
+
The Z lighting axis window is below the
+graphics:3D control-panel:move z
+ Lighting Control-Panel title and in the center. This
+changes the Z
+location of the light vector.
+
+
Intensity:
+
+Below the Lighting Control-Panel title
+graphics:3D control-panel:intensity
+and to the right is the light intensity meter.
+Moving the intensity indicator down decreases the amount of
+light emitted from the light source.
+When the indicator is at the top of the meter the light source is
+emitting at 100% intensity.
+At the bottom of the meter the light source is emitting at a level
+slightly above ambient lighting.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
7.2.9.6 View Volume
+
+
+
+
graphics:3D control-panel:view volume
+
+
+
+
The View Volume button changes the control-panel into
+the Viewing Volume Panel.
+At the bottom of the viewing panel is an Abort button that
+cancels any changes to the viewing volume that were made and a
+Return button that carries out the current set of
+viewing changes to the graph.
+
+
+
+
+
+
+
+
+
+
+
+
Eye Reference:
+
At the top of this panel is the
+graphics:3D control-panel:eye reference
+ Eye Reference window.
+It shows a planar projection of the viewing pyramid from the eye
+of the viewer relative to the location of the object.
+This has a bounding region represented by the rectangle on the
+left.
+Below the object rectangle is the Hither window.
+By moving the slider in this window the hither clipping plane sets
+hither clipping plane
+the front of the view volume.
+As a result of this depth clipping all points of the object closer
+to the eye than this hither plane are not shown.
+The Eye Distance slider to the right of the Hither
+slider is used to change the degree of perspective in the image.
+
+
Clip Volume:
+
The Clip Volume window is at the
+graphics:3D control-panel:clip volume
+bottom of the Viewing Volume Panel.
+On the right is a Settings menu.
+In this menu are buttons to select viewing attributes.
+Selecting the Perspective button computes the image using
+perspective projection.
+graphics:3D control-panel:perspective
+The Show Region button indicates whether the clipping region
+of the
+graphics:3D control-panel:show clip region
+volume is to be drawn in the viewport and the Clipping On
+button shows whether the view volume clipping is to be in effect
+when the image
+graphics:3D control-panel:clipping on
+is drawn.
+The left side of the Clip Volume window shows the clipping
+graphics:3D control-panel:clip volume
+boundary of the graph.
+Moving the knobs along the X, Y, and Z sliders
+adjusts the volume of the clipping region accordingly.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
7.2.10 Operations for Three-Dimensional Graphics
+
+
+
+
+
+
+
Here is a summary of useful Axiom operations for three-dimensional
+graphics.
+Each operation name is followed by a list of arguments.
+Each argument is written as a variable informally named according
+to the type of the argument (for example, integer).
+If appropriate, a default value for an argument is given in
+parentheses immediately following the name.
+
+
+
+
+
+
+
adaptive3D?()
+
+tests whether space curves are to be plotted
+graphics:plot3d defaults:adaptive
+according to the
+adaptive plotting
+adaptive refinement algorithm.
+
+
axes(viewport, string("on"))
+
+turns the axes on and off.
+graphics:3D commands:axes
+
+
close(viewport)
+
+closes the viewport.
+graphics:3D commands:close
+
+
colorDef(viewport,
+ (1), (27))
+
+sets the colormap
+graphics:3D commands:define color
+range to be from
+ to .
+
+
controlPanel(viewport, string("off"))
+
+declares whether the
+graphics:3D commands:control-panel
+control-panel for the viewport is to be displayed or not.
+
+
diagonals(viewport, string("off"))
+
+declares whether the
+graphics:3D commands:diagonals
+polygon outline includes the diagonals or not.
+
+
drawStyle(viewport, style)
+
+selects which of four drawing styles
+graphics:3D commands:drawing style
+are used: "wireMesh", "solid", "shade", or "smooth".
+
+
eyeDistance(viewport,float(500))
+
+sets the distance of the eye from the origin of the object
+graphics:3D commands:eye distance
+for use in the perspectiveperspectiveThreeDimensionalViewport.
+
+
key(viewport)
+
+returns the operating
+graphics:3D commands:key
+system process ID number for the viewport.
+
+
lighting(viewport,
+ (-0.5),
+ (0.5), (0.5))
+
+sets the Cartesian
+graphics:3D commands:lighting
+coordinates of the light source.
+
+
modifyPointData(viewport,integer,point)
+
+replaces the coordinates of the point with
+graphics:3D commands:modify point data
+the index integer with point.
+
+rotates the viewport by rotation angles for longitude
+() and
+latitude ().
+Angles designate radians if given as floats, or degrees if given
+graphics:3D commands:rotate
+as integers.
+
+
setAdaptive3D(boolean(true))
+
+sets whether space curves are to be plotted
+graphics:plot3d defaults:set adaptive
+according to the adaptive
+adaptive plotting
+refinement algorithm.
+
+
setMaxPoints3D(integer(1000))
+
+ sets the default maximum number of possible
+graphics:plot3d defaults:set max points
+points to be used when constructing a three-dimensional space curve.
+
+
setMinPoints3D(integer(49))
+
+sets the default minimum number of possible
+graphics:plot3d defaults:set min points
+points to be used when constructing a three-dimensional space curve.
+
+
setScreenResolution3D(integer(49))
+
+sets the default screen resolution constant
+graphics:plot3d defaults:set screen resolution
+used in setting the computation limit of adaptively
+adaptive plotting
+generated three-dimensional space curve plots.
+
+
showRegion(viewport, string("off"))
+
+declares whether the bounding
+graphics:3D commands:showRegion
+box of a graph is shown or not.
+
+
subspace(viewport)
+
+returns the space component.
+
+
subspace(viewport, subspace)
+
+resets the space component
+graphics:3D commands:subspace
+to subspace.
+
+
title(viewport, string)
+
+gives the viewport the
+graphics:3D commands:title
+title string.
+
+translates
+graphics:3D commands:translate
+the object horizontally and vertically relative to the center of the viewport.
+
+
intensity(viewport,float(1.0))
+
+resets the intensity I of the light source,
+graphics:3D commands:intensity
+
+
+
tubePointsDefault([integer(6)])
+
+sets or indicates the default number of
+graphics:3D defaults:tube points
+vertices defining the polygon that is used to create a tube around
+a space curve.
+
+
tubeRadiusDefault([float(0.5)])
+
+sets or indicates the default radius of
+graphics:3D defaults:tube radius
+the tube that encircles a space curve.
+
+
var1StepsDefault([integer(27)])
+
+sets or indicates the default number of
+graphics:3D defaults:var1 steps
+increments into which the grid defining a surface plot is subdivided with
+respect to the first parameter declared in the surface function.
+
+
var2StepsDefault([integer(27)])
+
+sets or indicates the default number of
+graphics:3D defaults:var2 steps
+increments into which the grid defining a surface plot is subdivided with
+respect to the second parameter declared in the surface function.
+
+
viewDefaults([ ,
+ , ,
+ , ,
+ ,
+ ])
+
+resets the default settings for the
+graphics:3D defaults:reset viewport defaults
+point color, line color, axes color, units color, point size,
+viewport upper left-hand corner position, and the viewport size.
+
+
viewDeltaXDefault([float(0)])
+
+resets the default horizontal offset
+graphics:3D commands:deltaX default
+from the center of the viewport, or returns the current default offset if no argument is given.
+
+
viewDeltaYDefault([float(0)])
+
+resets the default vertical offset
+graphics:3D commands:deltaY default
+from the center of the viewport, or returns the current default offset if no argument is given.
+
+
viewPhiDefault([float(- /4)])
+
+resets the default latitudinal view angle,
+or returns the current default angle if no argument is given.
+graphics:3D commands:phi default
+ is set to this value.
+
+
viewpoint(viewport, ,
+ , )
+
+sets the viewing position in Cartesian coordinates.
+
+
viewpoint(viewport,
+ ,
+ )
+
+sets the viewing position in spherical coordinates.
+
+
viewpoint(viewport,
+ ,
+ ,
+ ,
+ , )
+
+sets the viewing position in spherical coordinates,
+the scale factor, and offsets.
+graphics:3D commands:viewpoint
+ (longitude) and
+ (latitude) are in radians.
+
+
viewPosDefault([list([0,0])])
+
+sets or indicates the position of the upper
+graphics:3D defaults:viewport position
+left-hand corner of a two-dimensional viewport, relative to the display root
+window (the upper left-hand corner of the display is ).
+
+
viewSizeDefault([list([400,400])])
+
+sets or indicates the width and height dimensions
+graphics:3D defaults:viewport size
+of a viewport.
+
+
viewThetaDefault([float( /4)])
+
+resets the default longitudinal view angle,
+or returns the current default angle if no argument is given.
+graphics:3D commands:theta default
+When a parameter is specified, the default longitudinal view angle
+ is set to this value.
+
+indicates the possible file types
+graphics:3D defaults:available viewport writes
+that can be created with the writewriteThreeDimensionalViewport function.
+
+
viewWriteDefault([list([])])
+
+sets or indicates the default types of files
+that are created in addition to the data file when a
+writewriteThreeDimensionalViewport command
+graphics:3D defaults:viewport writes
+is executed on a viewport.
+
+
viewScaleDefault([float])
+
+sets the default scaling factor, or returns
+graphics:3D commands:scale default
+the current factor if no argument is given.
+
+
write(viewport, directory, [option])
+
+writes the file data for viewport
+in the directory directory.
+An optional third argument specifies a file type (one of pixmap, bitmap, postscript, or image), or a
+list of file types.
+An additional file is written for each file type listed.
+
+
scale(viewport, float(2.5))
+
+specifies the scaling factor.
+graphics:3D commands:scale
+scaling graphs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
7.2.11 Customization using .Xdefaults
+
+
+
+
+
+
graphics:.Xdefaults
+
+
+
+
Both the two-dimensional and three-dimensional drawing facilities consult
+the .Xdefaults file for various defaults.
+file:.Xdefaults @ .Xdefaults
+The list of defaults that are recognized by the graphing routines
+is discussed in this section.
+These defaults are preceded by Axiom.3D.
+for three-dimensional viewport defaults, Axiom.2D.
+for two-dimensional viewport defaults, or Axiom* (no dot) for
+those defaults that are acceptable to either viewport type.
+
+
+
+
+
+
Axiom*buttonFont: font
+
+This indicates which
+graphics:.Xdefaults:button font
+font type is used for the button text on the control-panel.
+ Rom11
+
+
Axiom.2D.graphFont: font
+
(2D only)
+This indicates
+graphics:.Xdefaults:graph number font
+which font type is used for displaying the graph numbers and
+slots in the Graphs section of the two-dimensional control-panel.
+ Rom22
+
+
Axiom.3D.headerFont: font
+
+This indicates which
+graphics:.Xdefaults:graph label font
+font type is used for the axes labels and potentiometer
+header names on three-dimensional viewport windows.
+This is also used for two-dimensional control-panels for indicating
+which font type is used for potentionmeter header names and
+multiple graph title headers.
+ Itl14
+
+
Axiom*inverse: switch
+
+This indicates whether the
+graphics:.Xdefaults:inverting background
+background color is to be inverted from white to black.
+If on, the graph viewports use black as the background
+color.
+If off or no declaration is made, the graph viewports use a
+white background.
+ off
+
+
Axiom.3D.lightingFont: font
+
(3D only)
+This indicates which font type is used for the x,
+graphics:.Xdefaults:lighting font
+ y, and z labels of the two lighting axes potentiometers, and for
+the Intensity title on the lighting control-panel.
+ Rom10
+
+
Axiom.2D.messageFont, Axiom.3D.messageFont: font
+
+These indicate the font type
+graphics:.Xdefaults:message font
+to be used for the text in the control-panel message window.
+ Rom14
+
+
Axiom*monochrome: switch
+
+This indicates whether the
+graphics:.Xdefaults:monochrome
+graph viewports are to be displayed as if the monitor is black and
+white, that is, a 1 bit plane.
+If on is specified, the viewport display is black and white.
+If off is specified, or no declaration for this default is
+given, the viewports are displayed in the normal fashion for the
+monitor in use.
+ off
+
+
Axiom.2D.postScript: filename
+
+This specifies
+graphics:.Xdefaults:PostScript file name
+the name of the file that is generated when a 2D PostScript graph
+PostScript
+is saved.
+ axiom2D.ps
+
+
Axiom.3D.postScript: filename
+
+This specifies
+graphics:.Xdefaults:PostScript file name
+the name of the file that is generated when a 3D PostScript graph
+PostScript
+is saved.
+ axiom3D.ps
+
+
Axiom*titleFont font
+
+This
+graphics:.Xdefaults:title font
+indicates which font type is used
+for the title text and, for three-dimensional graphs,
+in the lighting and viewing-volume control-panel windows.
+graphics:Xdefaults:2d
+ Rom14
+
+
Axiom.2D.unitFont: font
+
(2D only)
+This indicates
+graphics:.Xdefaults:unit label font
+which font type is used for displaying the unit labels on
+two-dimensional viewport graphs.
+ 6x10
+
+
Axiom.3D.volumeFont: font
+
(3D only)
+This indicates which font type is used for the x,
+graphics:.Xdefaults:volume label font
+ y, and z labels of the clipping region sliders; for the
+ Perspective, Show Region, and Clipping On buttons under
+ Settings, and above the windows for the Hither and
+ Eye Distance sliders in the Viewing Volume Panel of the
+three-dimensional control-panel.
+ Rom8
+
Axiom provides two basic floating-point types: Float and
+DoubleFloat. This section describes how to use numerical
+function:numeric
+operations defined on these types and the related complex types.
+numeric operations
+
+
+
+
As we mentioned in Chapter
+ugIntro , the Float type is a software
+implementation of floating-point numbers in which the exponent and the
+floating-point number
+significand may have any number of digits.
+number:floating-point
+See
+FloatXmpPage
+for detailed information about this domain.
+The DoubleFloat (see DoubleFloatXmpPage ) is usually a hardware implementation
+of floating point numbers, corresponding to machine double
+precision.
+The types Complex Float and Complex DoubleFloat are
+floating-point number:complex
+the corresponding software implementations of complex floating-point numbers.
+complex:floating-point number
+In this section the term floating-point type means any of these
+number:complex floating-point
+four types.
+
+
+
+
The floating-point types implement the basic elementary functions.
+These include (where $ means
+DoubleFloat,
+Float,
+Complex DoubleFloat, or
+Complex Float):
+
The handling of roots depends on whether the floating-point type
+root:numeric approximation
+is real or complex: for the real floating-point types,
+DoubleFloat and Float, if a real root exists
+the one with the same sign as the radicand is returned; for the
+complex floating-point types, the principal value is returned.
+principal value
+Also, for real floating-point types the inverse functions
+produce errors if the results are not real.
+This includes cases such as , ,
+ .
+
+
+
+
+
The default floating-point type is Float so to evaluate
+functions using Float or Complex Float, just use
+normal decimal notation.
+
+
+
+
+
+
+
+exp(3.1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+
+exp(3.1 + 4.5 * %i)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Float
+
+
+
+
+
To evaluate functions using DoubleFloat
+or Complex DoubleFloat,
+a declaration or conversion is required.
+
A number of special functions are provided by the package
+DoubleFloatSpecialFunctions for the machine-precision
+special functions
+floating-point types.
+DoubleFloatSpecialFunctions
+The special functions provided are listed below, where stands for
+the types DoubleFloat and Complex DoubleFloat.
+The real versions of the functions yield an error if the result is not real.
+function:special
+
+
+
+
+
Gamma:
+ is the Euler gamma function,
+function:Gamma
+ ,
+ defined by
+Euler:gamma function
+
+
+
+
+
+
+
Beta:
+ is the Euler Beta function,
+function:Euler Beta
+ , defined by
+Euler:Beta function
+
+
+ This is related to by
+
+
+
+
+
+
logGamma:
+ is the natural logarithm of
+ .
+ This can often be computed even if
+cannot.
+
+
+
+
+
digamma:
+ , also called ,
+psi @
+is the function
+function:digamma
+ defined by
+
+
+
+
+
+
polygamma:
+ is the -th derivative of
+function:polygamma
+ , written .
+
+
+
+
+
besselJ:
+ is the Bessel function of the first kind,
+function:Bessel
+ .
+ This function satisfies the differential equation
+
+
+
+
+
+
besselY:
+ is the Bessel function of the second kind,
+function:Bessel
+ .
+ This function satisfies the same differential equation as
+ besselJ.
+ The implementation simply uses the relation
+
+
+
+
+
+
besselI:
+ is the modified Bessel function of the first kind,
+function:Bessel
+ .
+ This function satisfies the differential equation
+
+
+
+
+
+
besselK:
+ is the modified Bessel function of the second kind,
+function:Bessel
+ .
+ This function satisfies the same differential equation as besselI.
+Bessel function
+ The implementation simply uses the relation
+
+
+
+
+
+
+
airyAi:
+ is the Airy function .
+function:Airy Ai
+ This function satisfies the differential equation
+
+ The implementation simply uses the relation
+
+
+
+
+
+
airyBi:
+ is the Airy function .
+function:Airy Bi
+ This function satisfies the same differential equation as airyAi.
+Airy function
+ The implementation simply uses the relation
+
+
+
+
+
+
hypergeometric0F1:
+ is the hypergeometric function
+function:hypergeometric
+.
+
+
+
+
The above special functions are defined only for small floating-point types.
+If you give Float arguments, they are converted to
+DoubleFloat by Axiom.
+
A number of additional operations may be used to compute numerical values.
+These are special polynomial functions that can be evaluated for values in
+any commutative ring , and in particular for values in any
+floating-point type.
+The following operations are provided by the package
+OrthogonalPolynomialFunctions:
+OrthogonalPolynomialFunctions
+
+
+
+
+
chebyshevT:
+ is the -th Chebyshev polynomial of the first
+ kind, . These are defined by
+
+
+
+
+
+
chebyshevU:
+ is the -th Chebyshev polynomial of the second
+ kind, . These are defined by
+
+
+
+
+
+
hermiteH:
+ is the -th Hermite polynomial,
+ .
+ These are defined by
+
+
+
+
+
+
+
laguerreL:
+ is the -th Laguerre polynomial,
+ .
+ These are defined by
+
+
+
+
+
+
+
laguerreL:
+ is the associated Laguerre polynomial
+ .
+
+ This is the -th derivative of .
+
+
+
+
+
legendreP:
+ is the -th Legendre polynomial,
+ . These are defined by
+
+
+
+
+
+
These operations require non-negative integers for the indices, but otherwise
+the argument can be given as desired.
+
+
+
+
+
+
+
+[chebyshevT(i, z) for i in 0..5]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Polynomial Integer
+
+
+
+
+
The expression evaluates to the -th Chebyshev
+polynomial:Chebyshev:of the first kind
+polynomial of the first kind.
+
+
+
+
+
+
+
+chebyshevT(3, 5.0 + 6.0*%i)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Float
+
+
+
+
+
+
+
+
+chebyshevT(3, 5.0::DoubleFloat)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DoubleFloat
+
+
+
+
+
The expression evaluates to the -th Chebyshev
+polynomial:Chebyshev:of the second kind
+polynomial of the second kind.
+
+
+
+
+
+
+
+[chebyshevU(i, z) for i in 0..5]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Polynomial Integer
+
+
+
+
+
+
+
+
+chebyshevU(3, 0.2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
The expression evaluates to the -th Hermite
+polynomial:Hermite
+polynomial.
+
+
+
+
+
+
+
+[hermiteH(i, z) for i in 0..5]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Polynomial Integer
+
+
+
+
+
+
+
+
+hermiteH(100, 1.0)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
The expression evaluates to the -th Laguerre
+polynomial:Laguerre
+polynomial.
+
+
+
+
+
+
+
+[laguerreL(i, z) for i in 0..4]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Polynomial Integer
+
+
+
+
+
+
+
+
+laguerreL(4, 1.2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+
+[laguerreL(j, 3, z) for j in 0..4]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Polynomial Integer
+
+
+
+
+
+
+
+
+laguerreL(1, 3, 2.1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
The expression
+polynomial:Legendre
+ evaluates to the -th Legendre polynomial,
+
+
+
+
+
+
+
+[legendreP(i,z) for i in 0..5]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Polynomial Fraction Integer
+
+
+
+
+
+
+
+
+legendreP(3, 3.0*%i)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Float
+
+
+
+
+
Finally, three number-theoretic polynomial operations may be evaluated.
+number theory
+The following operations are provided by the package
+NumberTheoreticPolynomialFunctions.
+NumberTheoreticPolynomialFunctions.
+
+
+
+
+
bernoulliB:
+ is the -th Bernoulli polynomial,
+polynomial:Bernoulli
+ . These are defined by
+
+
+
+
+
+
+
eulerE:
+ is the -th Euler polynomial,
+Euler:polynomial
+ . These are defined by
+polynomial:Euler
+
+
+
+
+
+
+
cyclotomic:
+ is the -th cyclotomic polynomial
+ . This is the polynomial whose
+ roots are precisely the primitive -th roots of unity.
+Euler:totient function
+ This polynomial has degree given by the Euler totient function
+function:totient
+ .
+
+
+
+
The expression evaluates to the -th Bernoulli
+polynomial:Bernouilli
+polynomial.
+
+
+
+
+
+
+
+bernoulliB(3, z)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Fraction Integer
+
+
+
+
+
+
+
+
+bernoulliB(3, 0.7 + 0.4 * %i)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Float
+
+
+
+
+
The expression
+polynomial:Euler
+ evaluates to the -th Euler polynomial.
+
+
+
+
+
+
+
+eulerE(3, z)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Fraction Integer
+
+
+
+
+
+
+
+
+eulerE(3, 0.7 + 0.4 * %i)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Float
+
+
+
+
+
The expression
+polynomial:cyclotomic
+ evaluates to the -th cyclotomic polynomial.
+cyclotomic polynomial
+
+
+
+
+
+
+
+cyclotomic(3, z)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
+
+
+
+cyclotomic(3, (-1.0 + 0.0 * %i)**(2/3))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Float
+
+
+
+
+
Drawing complex functions in Axiom is presently somewhat
+awkward compared to drawing real functions.
+It is necessary to use the draw operations that operate
+on functions rather than expressions.
+
+
+
+
This is the complex exponential function (rotated interactively).
+function:complex exponential
+When this is displayed in color, the height is the value of the real part of
+the function and the color is the imaginary part.
+Red indicates large negative imaginary values, green indicates imaginary
+values near zero and blue/violet indicates large positive imaginary values.
+
This is the complex arctangent function.
+function:complex arctangent
+Again, the height is the real part of the function value but here
+the color indicates the function value's phase.
+The position of the branch cuts are clearly visible and one can
+see that the function is real only for a real argument.
+
+
+
+
+
+
+vp := draw((x,y) +-> real atan complex(x,y), -%pi..%pi, -%pi..%pi, colorFunction==(x,y) +->argument atan complex(x,y), title=="atan(x+%i*y)", style=="shade"); rotate(vp,-160,-45); vp
+
In this section we discuss Axiom's facilities for
+equation:differential:solving solving differential
+equation differential equations in closed-form and in series.
+
+
+
+
Axiom provides facilities for closed-form solution of
+equation:differential:solving in closed-form single
+differential equations of the following kinds:
+
+
+
+
+
+
+ linear ordinary differential equations, and
+
+
non-linear first order ordinary differential equations
+when integrating factors can be found just by integration.
+
+
+
+
+
+
For a discussion of the solution of systems of linear and polynomial
+equations, see ugProblemLinPolEqn .
+
+
+
+
+
+
+
8.10.1 Closed-Form Solutions of Linear Differential Equations
+
+
+
+
+
+
A differential equation is an equation involving an unknown
+function and one or more of its derivatives.
+differential equation The equation is called ordinary
+if derivatives with respect to equation:differential only
+one dependent variable appear in the equation (it is called
+partial otherwise). The package ElementaryFunctionODESolver
+provides the top-level operation solve for finding closed-form
+solutions of ordinary differential equations.
+ElementaryFunctionODESolver
+
+
+
+
To solve a differential equation, you must first create an operator
+for operator the unknown function.
+
+
+
+
We let be the unknown function in terms of .
+
+
+
+
+
+
+
+y := operator 'y
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: BasicOperator
+
+
+
+
+
You then type the equation using D to create the
+derivatives of the unknown function where is any
+symbol you choose (the so-called dependent variable).
+
+
+
+
This is how you enter
+the equation .
+
+
+
+
+
+
+
+deq := D(y x, x, 2) + D(y x, x) + y x = 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Equation Expression Integer
+
+
+
+
+
The simplest way to invoke the solve command is with three
+arguments.
+
Since linear ordinary differential equations have infinitely many
+solutions, solve returns a particular solution and a
+basis for the solutions of the corresponding
+homogenuous equation. Any expression of the form
+
+where the do not involve the dependent variable
+is also a solution. This is similar to what you get when you solve
+systems of linear algebraic equations.
+
+
+
+
A way to select a unique solution is to specify initial
+conditions: choose a value for the dependent variable and specify
+the values of the unknown function and its derivatives at . If the
+number of initial conditions is equal to the order of the equation,
+then the solution is unique (if it exists in closed form!) and
+solve tries to find it. To specify initial conditions to
+solve, use an Equation of the form for the third
+parameter instead of the dependent variable, and add a fourth
+parameter consisting of the list of values .
+
+
+
+
To find the solution of satisfying ,
+do this.
+
+
+
+
+
+
+
+deq := D(y x, x, 2) + y x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
You can omit the when you enter the equation to be solved.
+
+
+
+
+
+
+
+solve(deq, y, x = 0, [1, 1])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(Expression Integer,...)
+
+
+
+
+
Axiom is not limited to linear differential equations with constant
+coefficients. It can also find solutions when the coefficients are
+rational or algebraic functions of the dependent variable.
+Furthermore, Axiom is not limited by the order of the equation.
+
+
+
+
Axiom can solve the following third order equations with
+polynomial coefficients.
+
On the other hand, and in contrast with the operation integrate,
+it can happen that Axiom finds no solution and that some closed-form
+solution still exists. While it is mathematically complicated to
+describe exactly when the solutions are guaranteed to be found, the
+following statements are correct and form good guidelines for linear
+ordinary differential equations:
+
+
+
+
+
+
+ If the coefficients are constants, Axiom finds a complete basis
+of solutions (i,e, all solutions).
+
+
If the coefficients are rational functions in the dependent variable,
+Axiom at least finds all solutions that do not involve algebraic
+functions.
+
+
+
+
+
+
Note that this last statement does not mean that Axiom does not find
+the solutions that are algebraic functions. It means that it is not
+guaranteed that the algebraic function solutions will be found.
+
+
+
+
This is an example where all the algebraic solutions are found.
+
+
+
+
+
+
+
+deq := (x**2 + 1) * D(y x, x, 2) + 3 * x * D(y x, x) + y x = 0
+
+
8.10.2 Closed-Form Solutions of Non-Linear Differential Equations
+
+
+
+
+
+
This is an example that shows how to solve a non-linear first order
+ordinary differential equation manually when an integrating factor can
+be found just by integration. At the end, we show you how to solve it
+directly.
+
+
+
+
Let's solve the differential equation .
+
+
+
+
Using the notation , we have and
+ .
+
+
+
+
+
+
+
+m := -y
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
+
+
+
+n := x + y * log y
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
We first check for exactness, that is, does ?
+
+
+
+
+
+
+
+D(m, y) - D(n, x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
This is not zero, so the equation is not exact. Therefore we must
+look for an integrating factor: a function such that
+ . Normally, we first search for
+depending only on or only on .
+
+
+
+
Let's search for such a first.
+
+
+
+
+
+
+
+mu := operator 'mu
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: BasicOperator
+
+
+
+
+
+
+
+
+a := D(mu(x) * m, y) - D(mu(x) * n, x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
If the above is zero for a function that does not depend on
+ , then is an integrating factor.
+
8.10.3 Power Series Solutions of Differential Equations
+
+
+
+
+
+
The command to solve differential equations in power
+equation:differential:solving in power series series
+power series around series:power a particular initial
+point with specific initial conditions is called seriesSolve.
+It can take a variety of parameters, so we illustrate its use with
+some examples.
+
+
+
+
Since the coefficients of some solutions are quite large, we reset the
+default to compute only seven terms.
+
+
+
+
+
+
+
+)set streams calculate 7
+
+
+
+
+
+
You can solve a single nonlinear equation of any order. For example,
+we solve
+ subject to
+
+
+
+
+
We first tell Axiom that the symbol denotes a new operator.
+
+
+
+
+
+
+
+y := operator 'y
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: BasicOperator
+
+
+
+
+
Enter the differential equation using like any system function.
+
You can also solve a system of nonlinear first order equations. For
+example, we solve a system that has and as
+solutions.
+
+
+
+
We tell Axiom that is also an operator.
+
+
+
+
+
+
+
+x := operator 'x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: BasicOperator
+
+
+
+
+
Enter the two equations forming our system.
+
+
+
+
+
+
+
+eq1 := D(x(t), t) = 1 + x(t)**2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Equation Expression Integer
+
+
+
+
+
+
+
+
+eq2 := D(y(t), t) = x(t) * y(t)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Equation Expression Integer
+
+
+
+
+
Solve the system around with the initial conditions
+and . Notice that since we give the unknowns in the order
+ , the answer is a list of two series in the order
+
+
+ Compiling function %BZ with type List UnivariateTaylorSeries(
+ Expression Integer,t,0) -> UnivariateTaylorSeries(Expression
+ Integer,t,0)
+ Compiling function %CA with type List UnivariateTaylorSeries(
+ Expression Integer,t,0) -> UnivariateTaylorSeries(Expression
+ Integer,t,0)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List UnivariateTaylorSeries(Expression Integer,t,0)
+
+
+
+
+
+
The order in which we give the equations and the initial conditions
+has no effect on the order of the solution.
+
A finite field (also called a Galois field) is a finite
+algebraic structure where one can add, multiply and divide under the
+same laws (for example, commutativity, associativity or
+distributivity) as apply to the rational, real or complex numbers.
+Unlike those three fields, for any finite field there exists a
+positive prime integer , called the characteristic, such that
+ for any element in the finite field. In fact, the
+number of elements in a finite field is a power of the characteristic
+and for each prime and positive integer there exists exactly
+one finite field with elements, up to isomorphism. For
+more information about the algebraic structure and properties of
+finite fields, see, for example,
+ S. Lang, Algebra, Second
+Edition, New York: Addison-Wesley Publishing Company, Inc., 1984, ISBN
+0 201 05487 6; or
+ R. Lidl, H. Niederreiter, Finite Fields,
+Encyclopedia of Mathematics and Its Applications, Vol. 20, Cambridge:
+Cambridge Univ. Press, 1983, ISBN 0 521 30240 4.
+
+
+
+
When the field has elements and is called a prime
+field, discussed in the next section. There are several ways of
+implementing extensions of finite fields, and Axiom provides quite a
+bit of freedom to allow you to choose the one that is best for your
+application. Moreover, we provide operations for converting among the
+different representations of extensions and different extensions of a
+single field. Finally, note that you usually need to package-call
+operations from finite fields if the operations do not take as an
+argument an object of the field. See
+ugTypesPkgCall for more
+information on package-calling.
+
+
+
+
+
+
+
8.11.1 Modular Arithmetic and Prime Fields
+
+
+
+
+
finite field
+Galois:field
+field:finite:prime
+field:prime
+field:Galois
+prime field
+modular arithmetic
+arithmetic:modular
+
+
+
+
Let be a positive integer. It is well known that you can get the
+same result if you perform addition, subtraction or multiplication of
+integers and then take the remainder on dividing by as if you had
+first done such remaindering on the operands, performed the arithmetic
+and then (if necessary) done remaindering again. This allows us to
+speak of arithmetic modulo or, more simply mod .
+
+
+
+
In Axiom, you use IntegerMod to do such arithmetic.
+
+
+
+
+
+
+
+(a,b) : IntegerMod 12
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+(a, b) := (16, 7)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: IntegerMod 12
+
+
+
+
+
+
+
+
+[a - b, a * b]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List IntegerMod 12
+
+
+
+
+
If is not prime, there is only a limited notion of reciprocals and
+division.
+
+
+
+
+
+
+
+a / b
+
+
+
+
+
+
+
+ There are 12 exposed and 13 unexposed library operations named /
+ having 2 argument(s) but none was determined to be applicable.
+ Use HyperDoc Browse, or issue
+ )display op /
+ to learn more about the available operations. Perhaps
+ package-calling the operation or using coercions on the arguments
+ will allow you to apply the operation.
+
+ Cannot find a definition or applicable library operation named /
+ with argument type(s)
+ IntegerMod 12
+ IntegerMod 12
+
+ Perhaps you should use "@" to indicate the required return type,
+ or "$" to specify which version of the function you need.
+
+
+
+
+
+
+
+
+recip a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union("failed",...)
+
+
+
+
+
Here and are relatively prime, so has a multiplicative
+inverse modulo .
+
+
+
+
+
+
+
+recip b
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(IntegerMod 12,...)
+
+
+
+
+
If we take to be a prime number , then taking inverses and,
+therefore, division are generally defined.
+
+
+
+
Use PrimeField instead of IntegerMod for prime.
+
+
+
+
+
+
+
+c : PrimeField 11 := 8
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PrimeField 11
+
+
+
+
+
+
+
+
+inv c
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PrimeField 11
+
+
+
+
+
You can also use and for the inverse of .
+
+
+
+
+
+
+
+9/c
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PrimeField 11
+
+
+
+
+
PrimeField (abbreviation PF) checks if its argument is
+prime when you try to use an operation from it. If you know the
+argument is prime (particularly if it is large), InnerPrimeField
+(abbreviation IPF) assumes the argument has already been
+verified to be prime. If you do use a number that is not prime, you
+will eventually get an error message, most likely a division by zero
+message. For computer science applications, the most important finite
+fields are PrimeField 2 and its extensions.
+
+
+
+
In the following examples, we work with the finite field with
+ elements.
+
+
+
+
+
+
+
+GF101 := PF 101
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
Like many domains in Axiom, finite fields provide an operation for
+returning a random element of the domain.
+
+
+
+
+
+
+
+x := random()$GF101
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PrimeField 101
+
+
+
+
+
+
+
+
+y : GF101 := 37
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PrimeField 101
+
+
+
+
+
+
+
+
+z := x/y
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PrimeField 101
+
+
+
+
+
+
+
+
+z * y - x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PrimeField 101
+
+
+
+
+
The element is a primitive element of this field,
+primitive element
+element:primitive
+
+
+
+
+
+
+
+pe := primitiveElement()$GF101
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PrimeField 101
+
+
+
+
+
in the sense that its powers enumerate all nonzero elements.
+
+
+
+
+
+
+
+[pe**i for i in 0..99]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PrimeField 101
+
+
+
+
+
If every nonzero element is a power of a primitive element, how do you
+determine what the exponent is? Use discrete logarithm
+ discreteLog. logarithm:discrete
+
+
+
+
+
+
+
+ex := discreteLog(y)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+pe ** ex
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PrimeField 101
+
+
+
+
+
The order of a nonzero element is the smallest positive
+integer such .
+
+
+
+
+
+
+
+order y
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The order of a primitive element is the defining .
+
+
+
+
+
+
+
+order pe
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+
+
+
+
+
8.11.2 Extensions of Finite Fields
+
+
+
+
+
finite field
+field:finite:extension of
+
+
+
+
When you want to work with an extension of a finite field in Axiom,
+you have three choices to make:
+
+
+
+
+
+
+ Do you want to generate an extension of the prime field
+(for example, PrimeField 2) or an extension of a given field?
+
+
Do you want to use a representation that is particularly
+efficient for multiplication, exponentiation and addition but uses a
+lot of computer memory (a representation that models the cyclic group
+structure of the multiplicative group of the field extension and uses
+a Zech logarithm table), one that Zech logarithm uses a normal
+basis for the vector space structure of the field extension, or one
+that performs arithmetic modulo an irreducible polynomial? The cyclic
+group representation is only usable up to ``medium'' (relative to your
+machine's performance) sized fields. If the field is large and the
+normal basis is relatively simple, the normal basis representation is
+more efficient for exponentiation than the irreducible polynomial
+representation.
+
+
Do you want to provide a polynomial explicitly, a root of which
+``generates'' the extension in one of the three senses in (2), or do
+you wish to have the polynomial generated for you?
+
+
+
+
+
+
This illustrates one of the most important features of Axiom: you can
+choose exactly the right data-type and representation to suit your
+application best.
+
+
+
+
We first tell you what domain constructors to use for each case above,
+and then give some examples.
+
+
+
+
Constructors that automatically generate extensions of the prime field:
+
+FiniteField
+FiniteFieldCyclicGroup
+FiniteFieldNormalBasis
+
+
+
+
Constructors that generate extensions of an arbitrary field:
+
+FiniteFieldExtension
+FiniteFieldExtensionByPolynomial
+FiniteFieldCyclicGroupExtension
+FiniteFieldCyclicGroupExtensionByPolynomial
+FiniteFieldNormalBasisExtension
+FiniteFieldNormalBasisExtensionByPolynomial
+
+
+
+
+
Constructors that use a cyclic group representation:
+
+FiniteFieldCyclicGroup
+FiniteFieldCyclicGroupExtension
+FiniteFieldCyclicGroupExtensionByPolynomial
+
+
+
+
+
Constructors that use a normal basis representation:
+
+FiniteFieldNormalBasis
+FiniteFieldNormalBasisExtension
+FiniteFieldNormalBasisExtensionByPolynomial
+
+
+
+
+
Constructors that use an irreducible modulus polynomial representation:
+
+FiniteField
+FiniteFieldExtension
+FiniteFieldExtensionByPolynomial
+
+
+
+
+
Constructors that generate a polynomial for you:
+
+FiniteField
+FiniteFieldExtension
+FiniteFieldCyclicGroup
+FiniteFieldCyclicGroupExtension
+FiniteFieldNormalBasis
+FiniteFieldNormalBasisExtension
+
+
+
+
+
Constructors for which you provide a polynomial:
+
+FiniteFieldExtensionByPolynomial
+FiniteFieldCyclicGroupExtensionByPolynomial
+FiniteFieldNormalBasisExtensionByPolynomial
+
+
+
+
These constructors are discussed in the following sections where we
+collect together descriptions of extension fields that have the same
+underlying representation.For more information on the
+implementation aspects of finite fields, see J. Grabmeier,
+A. Scheerhorn, Finite Fields in AXIOM, Technical Report, IBM
+Heidelberg Scientific Center, 1992.
+
+
+
+
If you don't really care about all this detail, just use FiniteField. As your knowledge of your application and its Axiom
+implementation grows, you can come back and choose an alternative
+constructor that may improve the efficiency of your code. Note that
+the exported operations are almost the same for all constructors of
+finite field extensions and include the operations exported by PrimeField.
+
All finite field extension constructors discussed in this
+finite field section field:finite:extension of use a
+representation that performs arithmetic with univariate (one-variable)
+polynomials modulo an irreducible polynomial. This polynomial may be
+given explicitly by you or automatically generated. The ground field
+may be the prime field or one you specify. See
+ugxProblemFiniteExtensionFinite for general information about
+finite field extensions.
+
+
+
+
For FiniteField (abbreviation FF) you provide a prime
+number and an extension degree . This degree can be 1.
+
+
+
+
Axiom uses the prime field PrimeField(p), here PrimeField 2,
+and it chooses an irreducible polynomial of degree , here 12,
+over the ground field.
+
+
+
+
+
+
+
+GF4096 := FF(2,12);
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
The objects in the generated field extension are polynomials of degree
+at most with coefficients in the prime field. The polynomial
+indeterminate is automatically chosen by Axiom and is typically
+something like or . These (strange) variables are
+only for output display; there are several ways to construct
+elements of this field.
+
+
+
+
The operation index enumerates the elements of the field
+extension and accepts as argument the integers from 1 to .
+
+
+
+
The expression always gives the indeterminate.
+
+
+
+
+
+
+
+a := index(2)$GF4096
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FiniteField(2,12)
+
+
+
+
+
You can build polynomials in and calculate in .
+
+
+
+
+
+
+
+b := a**12 - a**5 + a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FiniteField(2,12)
+
+
+
+
+
+
+
+
+b ** 1000
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FiniteField(2,12)
+
+
+
+
+
+
+
+
+c := a/b
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FiniteField(2,12)
+
+
+
+
+
Among the available operations are norm and trace.
+
+
+
+
+
+
+
+norm c
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PrimeField 2
+
+
+
+
+
+
+
+
+trace c
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PrimeField 2
+
+
+
+
+
Since any nonzero element is a power of a primitive element, how do we
+discover what the exponent is?
+
+
+
+
The operation discreteLog calculates discrete logarithm
+the exponent and, logarithm:discrete if it is called with only
+one argument, always refers to the primitive element returned by
+primitiveElement.
+
+
+
+
+
+
+
+dL := discreteLog a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+g ** dL
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
FiniteFieldExtension (abbreviation FFX) is similar to FiniteField except that the ground-field for FiniteFieldExtension
+is arbitrary and chosen by you.
+
+
+
+
In case you select the prime field as ground field, there is
+essentially no difference between the constructed two finite field
+extensions.
+
+
+
+
+
+
+
+GF16 := FF(2,4);
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
+
+
+
+GF4096 := FFX(GF16,3);
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
+
+
+
+r := (random()$GF4096) ** 20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FiniteFieldExtension(FiniteField(2,4),3)
+
+
+
+
+
+
+
+
+norm(r)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FiniteField(2,4)
+
+
+
+
+
FiniteFieldExtensionByPolynomial (abbreviation FFP)
+is similar to FiniteField and FiniteFieldExtension
+but is more general.
+
For FFP you choose both the ground field and the irreducible
+polynomial used in the representation. The degree of the extension is
+the degree of the polynomial.
+
+
+
+
+
+
+
+GF4096 := FFP(GF4,f);
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
+
+
+
+discreteLog random()$GF4096
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+
+
+
+
+
8.11.4 Cyclic Group Representations
+
+
+
+
+
finite field
+field:finite:extension of
+
+
+
+
In every finite field there exist elements whose powers are all the
+nonzero elements of the field. Such an element is called a
+primitive element.
+
+
+
+
In FiniteFieldCyclicGroup (abbreviation FFCG)
+group:cyclic the nonzero elements are represented by the
+powers of a fixed primitive element:primitive element
+primitive element of the field (that is, a generator of its
+cyclic multiplicative group). Multiplication (and hence
+exponentiation) using this representation is easy. To do addition, we
+consider our primitive element as the root of a primitive polynomial
+(an irreducible polynomial whose roots are all primitive). See
+ugxProblemFiniteUtility
+for examples of how to compute such a polynomial.
+
+
+
+
To use FiniteFieldCyclicGroup you provide a prime number and an
+extension degree.
+
+
+
+
+
+
+GF81 := FFCG(3,4);
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
Axiom uses the prime field, here PrimeField 3, as the ground
+field and it chooses a primitive polynomial of degree , here 4,
+over the prime field.
+
+
+
+
+
+
+
+a := primitiveElement()$GF81
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FiniteFieldCyclicGroup(3,4)
+
+
+
+
+
You can calculate in .
+
+
+
+
+
+
+
+b := a**12 - a**5 + a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FiniteFieldCyclicGroup(3,4)
+
+
+
+
+
In this representation of finite fields the discrete logarithm of an
+element can be seen directly in its output form.
+
+
+
+
+
+
+
+b
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FiniteFieldCyclicGroup(3,4)
+
+
+
+
+
+
+
+
+discreteLog b
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
FiniteFieldCyclicGroupExtension (abbreviation FFCGX) is
+similar to FiniteFieldCyclicGroup except that the ground field
+for FiniteFieldCyclicGroupExtension is arbitrary and chosen by
+you. In case you select the prime field as ground field, there is
+essentially no difference between the constructed two finite field
+extensions.
+
FiniteFieldCyclicGroupExtensionByPolynomial (abbreviation
+FFCGP) is similar to FiniteFieldCyclicGroup and
+FiniteFieldCyclicGroupExtension but is more general. For
+FiniteFieldCyclicGroupExtensionByPolynomial you choose both the
+ground field and the irreducible polynomial used in the
+representation. The degree of the extension is the degree of the
+polynomial.
+
+
+
+
+
+
+
+GF3 := PrimeField 3;
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
We use a utility operation to generate an irreducible primitive
+polynomial (see
+ugxProblemFiniteUtility ).
+The polynomial has one variable that is ``anonymous'':
+it displays as a question mark.
+
finite field
+field:finite:extension of
+basis:normal
+normal basis
+
+
+
+
Let be a finite extension of degree of the finite field
+and let have elements. An element of is said to be
+normal over if the elements
+
+
+
+
+
+
+
+
+
+
+
+
+
+
form a basis of as a vector space over . Such a basis is
+called a normal basis.This agrees with the general
+definition of a normal basis because the distinct powers of the
+automorphism constitute the Galois group of .
+
+
+
+
If is normal over , its minimal polynomial:minimal
+polynomial is also said to be normal over .
+minimal polynomial
+There exist normal bases for all finite extensions of arbitrary
+finite fields.
+
+
+
+
In FiniteFieldNormalBasis (abbreviation FFNB), the
+elements of the finite field are represented by coordinate vectors
+with respect to a normal basis.
+
+
+
+
You provide a prime and an extension degree .
+
+
+
+
+
+
+
+K := FFNB(3,8)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
Axiom uses the prime field PrimeField(p), here PrimeField
+3, and it chooses a normal polynomial of degree , here 8, over the
+ground field. The remainder class of the indeterminate is used as the
+normal element. The polynomial indeterminate is automatically chosen
+by Axiom and is typically something like or . These
+(strange) variables are only for output display; there are several
+ways to construct elements of this field. The output of the basis
+elements is something like
+
+
+
+
+
+
+
+a := normalElement()$K
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FiniteFieldNormalBasis(3,8)
+
+
+
+
+
You can calculate in using .
+
+
+
+
+
+
+
+b := a**12 - a**5 + a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FiniteFieldNormalBasis(3,8)
+
+
+
+
+
FiniteFieldNormalBasisExtension (abbreviation FFNBX) is
+similar to FiniteFieldNormalBasis except that the groundfield
+for FiniteFieldNormalBasisExtension is arbitrary and chosen by
+you. In case you select the prime field as ground field, there is
+essentially no difference between the constructed two finite field
+extensions.
+
FiniteFieldNormalBasisExtensionByPolynomial (abbreviation
+FFNBP) is similar to FiniteFieldNormalBasis and
+FiniteFieldNormalBasisExtension but is more general. For
+FiniteFieldNormalBasisExtensionByPolynomial you choose both the
+ground field and the irreducible polynomial used in the representation.
+The degree of the extension is the degree of the polynomial.
+
+
+
+
+
+
+
+GF3 := PrimeField 3;
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
We use a utility operation to generate an irreducible normal
+polynomial (see
+ugxProblemFiniteUtility ).
+The polynomial has
+one variable that is ``anonymous'': it displays as a question mark.
+
An extension field of degree over is a subfield of an
+extension field of degree over if and only if
+divides .
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
FiniteFieldHomomorphisms provides conversion operations between
+different extensions of one fixed finite ground field and between
+different representations of these finite fields.
+
+
+
+
Let's choose and ,
+
+
+
+
+
+
+
+(m,n) := (4,8)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
build the field extensions,
+
+
+
+
+
+
+
+Km := FiniteFieldExtension(K,m)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
and pick two random elements from the smaller field.
+
+
+
+
+
+
+
+Kn := FiniteFieldExtension(K,n)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
+
+
+
+a1 := random()$Km
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FiniteFieldExtension(PrimeField 3,4)
+
+
+
+
+
+
+
+
+b1 := random()$Km
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FiniteFieldExtension(PrimeField 3,4)
+
+
+
+
+
Since divides ,
+ is a subfield of .
+
+
+
+
+
+
+
+a2 := a1 :: Kn
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FiniteFieldExtension(PrimeField 3,8)
+
+
+
+
+
Therefore we can convert the elements of
+into elements of .
+
+
+
+
+
+
+
+b2 := b1 :: Kn
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FiniteFieldExtension(PrimeField 3,8)
+
+
+
+
+
To check this, let's do some arithmetic.
+
+
+
+
+
+
+
+a1+b1 - ((a2+b2) :: Km)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FiniteFieldExtension(PrimeField 3,4)
+
+
+
+
+
+
+
+
+a1*b1 - ((a2*b2) :: Km)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FiniteFieldExtension(PrimeField 3,4)
+
+
+
+
+
There are also conversions available for the situation, when and
+ are represented in different ways (see
+ugxProblemFiniteExtensionFinite ). For example let's choose
+ where the representation is 0 plus the cyclic multiplicative
+group and with a normal basis representation.
+
FiniteFieldPolynomialPackage (abbreviation FFPOLY)
+provides operations for generating, counting and testing polynomials
+over finite fields. Let's start with a couple of definitions:
+
+
+
+
+
+
+ A polynomial is primitive if its roots are primitive
+polynomial:primitive
+elements in an extension of the coefficient field of degree equal
+to the degree of the polynomial.
+
+
A polynomial is normal over its coefficient field
+polynomial:normal
+if its roots are linearly independent
+elements in an extension of the coefficient field of degree equal
+to the degree of the polynomial.
+
+
+
+
+
+
In what follows, many of the generated polynomials have one
+``anonymous'' variable. This indeterminate is displayed as a question
+mark (``?'').
+
+
+
+
To fix ideas, let's use the field with five elements for the first
+few examples.
+
+
+
+
+
+
+
+GF5 := PF 5;
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
You can generate irreducible polynomials of any (positive) degree
+polynomial:irreducible (within the storage capabilities of the
+computer and your ability to wait) by using
+createIrreduciblePolycreateIrreduciblePolyFiniteFieldPolynomialPackage.
+
+
+
+
+
+
+
+f := createIrreduciblePoly(8)$FFPOLY(GF5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SparseUnivariatePolynomial PrimeField 5
+
+
+
+
+
Does this polynomial have other important properties? Use
+ primitive? to test whether it is a primitive polynomial.
+
+
+
+
+
+
+
+primitive?(f)$FFPOLY(GF5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
Use normal? to test whether it is a normal polynomial.
+
+
+
+
+
+
+
+normal?(f)$FFPOLY(GF5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
Note that this is actually a trivial case, because a normal polynomial
+of degree must have a nonzero term of degree . We will refer
+back to this later.
+
+
+
+
To get a primitive polynomial of degree 8 just issue this.
+
+
+
+
+
+
+
+p := createPrimitivePoly(8)$FFPOLY(GF5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SparseUnivariatePolynomial PrimeField 5
+
+
+
+
+
+
+
+
+primitive?(p)$FFPOLY(GF5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
This polynomial is not normal,
+
+
+
+
+
+
+
+normal?(p)$FFPOLY(GF5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
but if you want a normal one simply write this.
+
+
+
+
+
+
+
+n := createNormalPoly(8)$FFPOLY(GF5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SparseUnivariatePolynomial PrimeField 5
+
+
+
+
+
This polynomial is not primitive!
+
+
+
+
+
+
+
+primitive?(n)$FFPOLY(GF5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
This could have been seen directly, as the constant term is 1 here,
+which is not a primitive element up to the factor ( ) raised to the
+degree of the polynomial.Cf. Lidl, R. & Niederreiter, H.,
+Finite Fields, Encycl. of Math. 20, (Addison-Wesley, 1983),
+p.90, Th. 3.18.
+
+
+
+
What about polynomials that are both primitive and normal? The
+existence of such a polynomial is by no means obvious.
+The existence of such polynomials is proved in
+Lenstra, H. W. & Schoof, R. J., Primitive
+Normal Bases for Finite Fields, Math. Comp. 48, 1987, pp. 217-231.
+
+
+
+
+
If you really need one use either
+createPrimitiveNormalPolycreatePrimitiveNormalPolyFiniteFieldPolynomialPackage or
+createNormalPrimitivePolycreateNormalPrimitivePolyFiniteFieldPolynomialPackage.
+
+
+
+
+
+
+
+createPrimitiveNormalPoly(8)$FFPOLY(GF5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SparseUnivariatePolynomial PrimeField 5
+
+
+
+
+
If you want to obtain additional polynomials of the various types
+above as given by the create... operations above, you can use
+the next... operations. For instance,
+nextIrreduciblePolynextIrreduciblePolyFiniteFieldPolynomialPackage yields
+the next monic irreducible polynomial with the same degree as the
+input polynomial. By ``next'' we mean ``next in a natural order using
+the terms and coefficients.'' This will become more clear in the
+following examples.
+
+
+
+
This is the field with five elements.
+
+
+
+
+
+
+
+GF5 := PF 5;
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
Our first example irreducible polynomial, say of degree 3, must be
+``greater'' than this.
+
You could also ask for the total number of these.
+
+
+
+
+
+
+
+numberOfIrreduciblePoly(5)$FFPOLY(GF5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
We hope that ``natural order'' on polynomials is now clear: first we
+compare the number of monomials of two polynomials (``more'' is
+``greater''); then, if necessary, the degrees of these monomials
+(lexicographically), and lastly their coefficients (also
+lexicographically, and using the operation lookup if our field
+is not a prime field). Also note that we make both polynomials monic
+before looking at the coefficients: multiplying either polynomial by a
+nonzero constant produces the same result.
+
+
+
+
The package FiniteFieldPolynomialPackage also provides similar
+operations for primitive and normal polynomials. With the exception of
+the number of primitive normal polynomials; we're not aware of any
+known formula for this.
+
Well, for the ordering used in
+nextPrimitivePolynextPrimitivePolyFiniteFieldPolynomialPackage we use
+as first criterion a comparison of the constant terms of the
+polynomials. Analogously, in
+nextNormalPolynextNormalPolyFiniteFieldPolynomialPackage we first
+compare the monomials of degree 1 less than the degree of the
+polynomials (which is nonzero, by an earlier remark).
+
FiniteFieldPolynomialPackage2 (abbreviation FFPOLY2)
+exports an operation rootOfIrreduciblePoly for finding one root
+of an irreducible polynomial polynomial:root of in an
+extension field of the coefficient field. The degree of the extension
+has to be a multiple of the degree of . It is not checked whether
+ actually is irreducible.
+
+
+
+
To illustrate this operation, we fix a ground field
+
Axiom provides a facility for the primary decomposition
+ideal:primary decomposition of primary decomposition of
+ideal polynomial ideals over fields of characteristic zero. The
+algorithm
+is discussed in \cite{gtz:gbpdpi} and
+works in essentially two steps:
+
+
+
+
+
+
+ the problem is solved for 0-dimensional ideals by ``generic''
+projection on the last coordinate
+
+
a ``reduction process'' uses localization and ideal quotients
+to reduce the general case to the 0-dimensional one.
+
+
+
+
+
The Axiom constructor PolynomialIdeals represents ideals with
+coefficients in any field and supports the basic ideal operations,
+including intersection, sum and quotient. IdealDecompositionPackage
+contains the specific operations for the
+primary decomposition and the computation of the radical of an ideal
+with polynomial coefficients in a field of characteristic 0 with an
+effective algorithm for factoring polynomials.
+
+
+
+
The following examples illustrate the capabilities of this facility.
+
+
+
+
First consider the ideal generated by
+
+(which defines a circle in the -plane) and the ideal
+generated by (corresponding to the
+straight lines and .
+
+
+
+
+
+
+
+(n,m) : List DMP([x,y],FRAC INT)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+m := [x**2+y**2-1]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List
+DistributedMultivariatePolynomial([x,y],Fraction Integer)
+
+
+
+
+
+
+
+
+n := [x**2-y**2]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List
+DistributedMultivariatePolynomial([x,y],Fraction Integer)
+
+
+
+
+
We find the equations defining the intersection of the two loci.
+This correspond to the sum of the associated ideals.
+
As a sample use of Axiom's algebraic number facilities,
+group:Galois
+we compute
+Galois:group
+the Galois group of the polynomial
+ .
+
+
+
+
+
+
+
+p := x**5 - 5*x + 12
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
We would like to construct a polynomial such that the splitting
+field:splitting field splitting field of is
+generated by one root of . First we construct a polynomial
+ such that one root of generates the field generated by
+two roots of the polynomial . (As it will turn out, the field
+generated by two roots of is, in fact, the splitting field of
+ .)
+
+
+
+
From the proof of the primitive element theorem we know that if
+and are algebraic numbers, then the field is equal
+to for an appropriately chosen integer . In our
+case, we construct the minimal polynomial of , where
+and are two roots of . We construct this polynomial using
+ resultant. The main result we need is the following: If
+is a polynomial with roots and is a polynomial
+with roots , then the polynomial is a polynomial of degree with roots
+ .
+
+
+
+
For we use the polynomial . For we use the
+polynomial . Thus, the polynomial we first construct is
+ .
+
The roots of are . Of course,
+there are five pairs with , so is a 5-fold root of
+ .
+
+
+
+
Let's get rid of this factor.
+
+
+
+
+
+
+
+q1 := exquo(q, x**5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(Polynomial Integer,...)
+
+
+
+
+
Factor the polynomial .
+
+
+
+
+
+
+
+factoredQ := factor q1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Polynomial Integer
+
+
+
+
+
We see that has two irreducible factors, each of degree .
+(The fact that the polynomial has two factors of degree is
+enough to show that the Galois group of is the dihedral group
+of order .See McKay, Soicher, Computing Galois Groups
+over the Rationals, Journal of Number Theory 20, 273-281 (1983). We
+do not assume the results of this paper, however, and we continue with
+the computation. Note that the type of is FR POLY
+INT, that is, Factored Polynomial Integer. Factored
+This is a special data type for recording factorizations of
+polynomials with integer coefficients.
+
+
+
+
We can access the individual factors using the operation
+nthFactornthFactorFactored.
+
+
+
+
+
+
+
+r := nthFactor(factoredQ,1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
Consider the polynomial . This is the minimal polynomial of
+the difference of two roots of . Thus, the splitting field of
+ contains a subfield of degree . We show that this subfield
+is, in fact, the splitting field of by showing that
+factors completely over this field.
+
+
+
+
First we create a symbolic root of the polynomial . (We
+replaced by in the polynomial so that our symbolic root
+would be printed as .)
+
+
+
+
+
+
+
+beta:AN := rootOf(eval(r,x,b))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: AlgebraicNumber
+
+
+
+
+
We next tell Axiom to view as a univariate polynomial in
+with algebraic number coefficients. This is accomplished with this
+type declaration.
+
+
+
+
+
+
+
+p := p::UP(x,INT)::UP(x,AN)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: UnivariatePolynomial(x,AlgebraicNumber)
+
+
+
+
+
Factor over the field .
+(This computation will take some time!)
+
When factoring over number fields, it is important to specify the
+field over which the polynomial is to be factored, as polynomials have
+different factorizations over different fields. When you use the
+operation factor, the field over which the polynomial is
+factored is the field generated by
+
+
+
+
+
+
+ the algebraic numbers that appear
+in the coefficients of the polynomial, and
+
+
the algebraic numbers that
+appear in a list passed as an optional second argument of the operation.
+
+
+
+
+
In our case, the coefficients of
+are all rational integers and only
+appears in the list, so the field is simply
+ .
+
+
+
+
It was necessary to give the list as a second argument of the
+operation because otherwise the polynomial would have been factored
+over the field generated by its coefficients, namely the rational
+numbers.
+
We have shown that the splitting field of has degree .
+Since the symmetric group of degree 5 has only one transitive subgroup
+of order , we know that the Galois group of must be this
+group, the dihedral group group:dihedral of order .
+Rather than stop here, we explicitly compute the action of the Galois
+group on the roots of .
+
+
+
+
First we assign the roots of as the values of five root
+variables.
+
+
+
+
We can obtain an individual root by negating the constant coefficient of
+one of the factors of .
+
+
+
+
+
+
+
+factor1 := nthFactor(algFactors,1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: UnivariatePolynomial(x,AlgebraicNumber)
+
+
+
+
+
+
+
+
+root1 := -coefficient(factor1,0)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: AlgebraicNumber
+
+
+
+
+
We can obtain a list of all the roots in this way.
+
+
+
+
+
+
+
+roots := [-coefficient(nthFactor(algFactors,i),0) for i in 1..5]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List AlgebraicNumber
+
+
+
+
+
The expression
+
+
+
+
+
+- coefficient(nthFactor(algFactors, i), 0)}
+
+
+
+
is the -th root of and the elements of are the
+ -th roots of as ranges from to .
+
+
+
+
Assign the roots as the values of the variables .
+
Next we express the roots of as polynomials in . We
+could obtain these roots by calling the operation factor:
+ factors over . However,
+this is a lengthy computation and we can obtain the roots of as
+differences of the roots of . Only ten of these
+differences are roots of and the other ten are roots of the
+other irreducible factor of . We can determine if a given value
+is a root of by evaluating at that particular value.
+(Of course, the order in which factors are returned by the operation
+ factor is unimportant and may change with different
+implementations of the operation. Therefore, we cannot predict in
+advance which differences are roots of and which are not.)
+
+
+
+
Let's look at four examples (two are roots of and
+two are not).
+
+
+
+
+
+
+
+eval(r,x,a1 - a2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial AlgebraicNumber
+
+
+
+
+
+
+
+
+eval(r,x,a1 - a3)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial AlgebraicNumber
+
+
+
+
+
+
+
+
+eval(r,x,a1 - a4)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial AlgebraicNumber
+
+
+
+
+
+
+
+
+eval(r,x,a1 - a5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial AlgebraicNumber
+
+
+
+
+
Take one of the differences that was a root of and assign it to
+the variable .
+
+
+
+
For example, if returned , you would enter this.
+
+
+
+
+
+
+
+bb := a1 - a4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: AlgebraicNumber
+
+
+
+
+
Of course, if the difference is, in fact, equal to the root ,
+you should choose another root of .
+
+
+
+
Automorphisms of the splitting field are given by mapping a generator
+of the field, namely , to other roots of its minimal polynomial.
+Let's see what happens when is mapped to .
+
+
+
+
We compute the images of the roots under this automorphism:
+
+
+
+
+
+
+
+aa1 := subst(a1,beta = bb)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: AlgebraicNumber
+
+
+
+
+
+
+
+
+aa2 := subst(a2,beta = bb)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: AlgebraicNumber
+
+
+
+
+
+
+
+
+aa3 := subst(a3,beta = bb)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: AlgebraicNumber
+
+
+
+
+
+
+
+
+aa4 := subst(a4,beta = bb)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: AlgebraicNumber
+
+
+
+
+
+
+
+
+aa5 := subst(a5,beta = bb)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: AlgebraicNumber
+
+
+
+
+
Of course, the values are simply a permutation of the values
+ .
+
+
+
+
Let's find the value of (execute as many of the following five commands
+as necessary).
+
+
+
+
+
+
+
+(aa1 = a1) :: Boolean
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+(aa1 = a2) :: Boolean
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+(aa1 = a3) :: Boolean
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+(aa1 = a4) :: Boolean
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+(aa1 = a5) :: Boolean
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
Proceeding in this fashion, you can find the values of
+ . You have represented the automorphism as a
+permutation of the roots . If you wish, you can repeat
+this computation for all the roots of and represent the Galois
+group of as a subgroup of the symmetric group on five letters.
+
+
+
+
Here are two other problems that you may attack in a similar fashion:
+
+
+
+
+
+
+ Show that the Galois group of
+
+is the dihedral group of order eight. group:dihedral
+(The splitting field of this polynomial is the Hilbert class field
+Hilbert class field of field:Hilbert class the quadratic field
+ .)
+
+
Show that the Galois group of
+
+has order 6 and is isomorphic to the symmetric group on three letters.
+group:symmetric (The splitting field of this polynomial is the
+splitting field of .)
+
8.14 Non-Associative Algebras and Modelling Genetic Laws
+
+
+
+
+
+
Many algebraic structures of mathematics and Axiom have a
+multiplication operation * that satisfies the associativity law
+associativity law for all , and
+ . The octonions are a well known exception. There are many other
+interesting non-associative structures, such as the class of
+Lie algebra Lie algebras.Two Axiom implementations
+of Lie algebras are LieSquareMatrix and FreeNilpotentLie.
+Lie algebras can be used, for example, to analyse Lie symmetry
+algebras of symmetry partial differential differential
+equation:partial equations. partial differential equation In
+this section we show a different application of non-associative
+algebras, non-associative algebra the modelling of genetic
+laws. algebra:non-associative
+
+
+
+
The Axiom library contains several constructors for creating
+non-associative structures, ranging from the categories
+Monad, NonAssociativeRng, and FramedNonAssociativeAlgebra,
+to the domains AlgebraGivenByStructuralConstants and
+GenericNonAssociativeAlgebra. Furthermore, the package
+AlgebraPackage provides operations for analysing the structure of
+such algebras. The interested reader can learn more about
+these aspects of the Axiom library from the paper ``Computations in
+Algebras of Finite Rank,'' by Johannes Grabmeier and Robert Wisbauer,
+Technical Report, IBM Heidelberg Scientific Center, 1992.
+
+
+
+
Mendel's genetic laws are often written in a form like
+
+
+
+
+
+
+
+
+
+
+
+
+
+
The implementation of general algebras in Axiom allows us to
+Mendel's genetic laws use this as the definition for
+multiplication in an algebra. genetics Hence, it is possible
+to study questions of genetic inheritance using Axiom. To demonstrate
+this more precisely, we discuss one example from a monograph of
+A. Wörz-Busekros, where you can also find a general setting of this
+theory. Wörz-Busekros, A., Algebras in Genetics,
+Springer Lectures Notes in Biomathematics 36, Berlin e.a. (1980). In
+particular, see example 1.3.
+
+
+
+
We assume that there is an infinitely large random mating population.
+Random mating of two gametes and gives zygotes
+zygote , which produce new gametes. gamete In
+classical Mendelian segregation we have . In general, we have
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
The segregation rates are the structural constants of
+an -dimensional algebra. This is provided in Axiom by the
+constructor AlgebraGivenByStructuralConstants (abbreviation
+ALGSC).
+
+
+
+
Consider two coupled autosomal loci with alleles , , , and
+ , building four different gametes
+and { and }. The
+zygotes produce gametes and with classical
+Mendelian segregation. Zygote undergoes transition to
+ and vice versa with probability
+ .
+
+
+
+
Define a list of four four-by-four
+matrices giving the segregation rates. We use the value for
+ .
+
Elements in this algebra whose coefficients sum to one play a
+distinguished role. They represent a population with the distribution
+of gametes reflected by the coefficients with respect to the basis of
+gametes.
+
+
+
+
Random mating of different populations and is described by
+their product .
+
+
+
+
This product is commutative only if the gametes are not sex-dependent,
+as in our example.
+
+
+
+
+
+
+
+commutative?()$A
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
In general, it is not associative.
+
+
+
+
+
+
+
+associative?()$A
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
Random mating within a population is described by . The next
+generation is .
+
+
+
+
Use decimal numbers to compare the distributions more easily.
+
Solve these equations and look at the first solution.
+
+
+
+
+
+
+
+gbs:= groebnerFactorize cI
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List List Polynomial Fraction Integer
+
+
+
+
+
+
+
+
+gbs.1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Polynomial Fraction Integer
+
+
+
+
+
+
Further analysis using the package PolynomialIdeals shows that
+there is a two-dimensional variety of equilibrium states and all other
+solutions are contained in it.
+
+
+
+
Choose one equilibrium state by setting two indeterminates to concrete
+values.
+
The Axiom polynomial factorization
+polynomial:factorization
+facilities are available for all polynomial types and a wide variety of
+coefficient domains.
+factorization
+Here are some examples.
+
+
+
+
+
+
+
8.2.1 Integer and Rational Number Coefficients
+
+
+
+
+
+
Polynomials with integer
+polynomial:factorization:integer coefficients
+coefficients can be be factored.
+
+
+
+
+
+
+
+v := (4*x**3+2*y**2+1)*(12*x**5-x**3*y+12)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
+
+
+
+factor v
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Polynomial Integer
+
+
+
+
+
Also, Axiom can factor polynomials with
+polynomial:factorization:rational number coefficients
+rational number coefficients.
+
Polynomials with coefficients in a finite field
+polynomial:factorization:finite field coefficients
+can be also be factored.
+finite field:factoring polynomial with coefficients in
+
+
+
+
+
+
+
+u : POLY(PF(19)) :=3*x**4+2*x**2+15*x+18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial PrimeField 19
+
+
+
+
+
These include the integers mod , where is prime, and
+extensions of these fields.
+
+
+
+
+
+
+
+factor u
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Polynomial PrimeField 19
+
+
+
+
+
Convert this to have coefficients in the finite
+field with elements.
+See ugProblemFinite
+for more information about finite fields.
+
8.2.3 Simple Algebraic Extension Field Coefficients
+
+
+
+
+
+
Polynomials with coefficients in simple algebraic extensions
+polynomial:factorization:algebraic extension field coefficients
+of the rational numbers can be factored.
+algebraic number
+number:algebraic
+
Note that the second argument to factor can be a list of
+algebraic extensions to factor over.
+
+
+
+
+
+
+
+factor(p,[aa])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Polynomial AlgebraicNumber
+
+
+
+
+
This factors over the integers.
+
+
+
+
+
+
+
+factor(x**2+3)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Polynomial Integer
+
+
+
+
+
Factor the same polynomial over the field obtained by adjoining
+ to the rational numbers.
+
+
+
+
+
+
+
+factor(x**2+3,[aa])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Polynomial AlgebraicNumber
+
+
+
+
+
Factor over the same field.
+
+
+
+
+
+
+
+factor(x**6+108,[aa])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Polynomial AlgebraicNumber
+
+
+
+
+
+
+
+
+bb:=rootOf(bb**3-2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: AlgebraicNumber
+
+
+
+
+
+
+
+
+factor(x**6+108,[bb])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Polynomial AlgebraicNumber
+
+
+
+
+
Factor again over the field obtained by adjoining both
+and to the rational numbers.
+
+
+
+
+
+
+
+factor(x**6+108,[aa,bb])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Polynomial AlgebraicNumber
+
+
+
+
+
+
+
+
+
+
+
+
+
8.2.4 Factoring Rational Functions
+
+
+
+
+
+
Since fractions of polynomials form a field, every element (other than zero)
+rational function:factoring
+divides any other, so there is no useful notion of irreducible factors.
+Thus the factor operation is not very useful for fractions
+of polynomials.
+
+
+
+
There is, instead, a specific operation factorFraction
+that separately factors the numerator and denominator and returns
+a fraction of the factored results.
+
+
+
+
+
+
+
+factorFraction((x**2-4)/(y**2-4))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Factored Polynomial Integer
+
+
+
+
+
You can also use map. This expression
+applies the factor operation
+to the numerator and denominator.
+
In this section we show you how to work with one root or all roots
+root:symbolic
+of a polynomial.
+These roots are represented symbolically (as opposed to being
+numeric approximations).
+See ugxProblemOnePol and
+ugxProblemPolSys for
+information about solving for the roots of one or more
+polynomials.
+
+
+
+
+
+
+
8.3.1 Using a Single Root of a Polynomial
+
+
+
+
+
+
Use rootOf to get a symbolic root of a polynomial:
+ returns a root of .
+
+
+
+
This creates an algebraic number .
+algebraic number
+number:algebraic
+
+
+
+
+
+
+
+a := rootOf(a**4+1,a)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
To find the algebraic relation that defines ,
+use definingPolynomial.
+
+
+
+
+
+
+
+definingPolynomial a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
You can use in any further expression,
+including a nested rootOf.
+
+
+
+
+
+
+
+b := rootOf(b**2-a-1,b)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
Higher powers of the roots are automatically reduced during
+calculations.
+
+
+
+
+
+
+
+a + b
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
+
+
+
+% ** 5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
The operation zeroOf is similar to rootOf,
+except that it may express the root using radicals in some cases.
+radical
+
+
+
+
+
+
+
+rootOf(c**2+c+1,c)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
+
+
+
+zeroOf(d**2+d+1,d)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
+
+
+
+rootOf(e**5-2,e)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
+
+
+
+zeroOf(f**5-2,f)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
8.3.2 Using All Roots of a Polynomial
+
+
+
+
+
+
Use rootsOf to get all symbolic roots of a polynomial:
+ returns a
+list of all the roots of .
+If has a multiple root of order , then that root
+root:multiple
+appears times in the list. Make sure these variables are x0 etc.
+
+
+
+
Compute all the roots of .
+
+
+
+
+
+
+
+l := rootsOf(x**4+1,x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Expression Integer
+
+
+
+
+
As a side effect, the variables and are bound
+to the first three roots of .
+
+
+
+
+
+
+
+%x0**5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
Although they all satisfy
+and are different algebraic numbers.
+To find the algebraic relation that defines each of them,
+use definingPolynomial.
+
+
+
+
+
+
+
+definingPolynomial %x0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
+
+
+
+definingPolynomial %x1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
+
+
+
+definingPolynomial %x2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
We can check that the sum and product of the roots of are
+its trace and norm.
+
+
+
+
+
+
+
+x3 := last l
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
+
+
+
+%x0 + %x1 + %x2 + x3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
+
+
+
+%x0 * %x1 * %x2 * x3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
Corresponding to the pair of operations
+ rootOf/ zeroOf in
+ugxProblemOnePol , there is
+an operation zerosOf that, like rootsOf,
+computes all the roots
+of a given polynomial, but which expresses some of them in terms of
+radicals.
+
+
+
+
+
+
+
+zerosOf(y**4+1,y)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Expression Integer
+
+
+
+
+
As you see, only one implicit algebraic number was created
+( ), and its defining equation is this.
+The other three roots are expressed in radicals.
+
In this section we show you
+some of Axiom's facilities for computing and
+eigenvalue
+manipulating eigenvalues and eigenvectors, also called
+eigenvector
+characteristic values and characteristic vectors,
+characteristic:value
+respectively.
+characteristic:vector
+
+
+
+
+
Let's first create a matrix with integer entries.
+
+
+
+
+
+
+
+m1 := matrix [ [1,2,1],[2,1,-2],[1,-2,4] ]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Integer
+
+
+
+
+
To get a list of the rational eigenvalues,
+use the operation eigenvalues.
+
+
+
+
+
+
+
+leig := eigenvalues(m1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Union(Fraction Polynomial Integer,SuchThat(Symbol,Polynomial Integer))
+
+
+
+
+
Given an explicit eigenvalue, eigenvector computes the eigenvectors
+corresponding to it.
+
+
+
+
+
+
+
+eigenvector(first(leig),m1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Matrix Fraction Polynomial Fraction Integer
+
+
+
+
+
The operation eigenvectors returns a list of pairs of values and
+vectors. When an eigenvalue is rational, Axiom gives you
+the value explicitly; otherwise, its minimal polynomial is given,
+(the polynomial of lowest degree with the eigenvalues as roots),
+together with a parametric representation of the eigenvector using the
+eigenvalue.
+This means that if you ask Axiom to solve
+the minimal polynomial, then you can substitute these roots
+polynomial:minimal
+into the parametric form of the corresponding eigenvectors.
+minimal polynomial
+
+
+
+
You must be aware that unless an exact eigenvalue has been computed,
+the eigenvector may be badly in error.
+
+
+
+
+
+
+
+eigenvectors(m1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Record(eigval: Union(Fraction Polynomial Integer,SuchThat(Symbol,Polynomial Integer)),eigmult: NonNegativeInteger,eigvec: List Matrix Fraction Polynomial Integer)
+
+
+
+
+
Another possibility is to use the operation
+ radicalEigenvectors
+tries to compute explicitly the eigenvectors
+in terms of radicals.
+radical
+
+
+
+
+
+
+
+radicalEigenvectors(m1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Record(radval: Expression Integer,radmult: Integer,radvect: List Matrix Expression Integer)
+
+
+
+
+
Alternatively, Axiom can compute real or complex approximations to the
+approximation
+eigenvectors and eigenvalues using the operations realEigenvectors
+or complexEigenvectors.
+They each take an additional argument
+to specify the ``precision'' required.
+precision
+In the real case, this means that each approximation will be within
+ of the actual
+result.
+In the complex case, this means that each approximation will be within
+ of the actual result
+in each of the real and imaginary parts.
+
+
+
+
The precision can be specified as a Float if the results are
+desired in floating-point notation, or as Fraction Integer if the
+results are to be expressed using rational (or complex rational) numbers.
+
+
+
+
+
+
+
+realEigenvectors(m1,1/1000)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Record(outval: Fraction Integer,outmult: Integer,outvect: List Matrix Fraction Integer)
+
+
+
+
+
If an by matrix has distinct eigenvalues (and
+therefore eigenvectors) the operation eigenMatrix
+gives you a matrix of the eigenvectors.
+
+
+
+
+
+
+
+eigenMatrix(m1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(Matrix Expression Integer,...)
+
+
+
+
+
+
+
+
+m2 := matrix [ [-5,-2],[18,7] ]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Integer
+
+
+
+
+
+
+
+
+eigenMatrix(m2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union("failed",...)
+
+
+
+
+
If a symmetric matrix
+matrix:symmetric
+has a basis of orthonormal eigenvectors, then
+basis:orthonormal
+ orthonormalBasis computes a list of these vectors.
+orthonormal basis
+
In this section we discuss the Axiom facilities for solving
+systems of linear equations, finding the roots of polynomials and
+linear equation
+solving systems of polynomial equations.
+For a discussion of the solution of differential equations, see
+ugProblemDEQ .
+
+
+
+
+
+
+
8.5.1 Solution of Systems of Linear Equations
+
+
+
+
+
+
You can use the operation solve to solve systems of linear equations.
+equation:linear:solving
+
+
+
+
The operation solve takes two arguments, the list of equations and the
+list of the unknowns to be solved for.
+A system of linear equations need not have a unique solution.
+
+
+
+
To solve the linear system:
+
+evaluate this expression.
+
+Type: List List Equation Fraction Polynomial Integer
+
+
+
+
+
Parameters are given as new variables starting with a percent sign and
+% and
+the variables are expressed in terms of the parameters.
+If the system has no solutions then the empty list is returned.
+
+
+
+
When you solve the linear system
+
+with this expression
+you get a solution involving a parameter.
+
+Type: List List Equation Fraction Polynomial Integer
+
+
+
+
+
The system can also be presented as a matrix and a vector.
+The matrix contains the coefficients of the linear equations and
+the vector contains the numbers appearing on the right-hand sides
+of the equations.
+You may input the matrix as a list of rows and the vector as a
+list of its elements.
+
+
+
+
To solve the system:
+
+in matrix form you would evaluate this expression.
+
The solutions are presented as a Record with two
+components: the component particular contains a particular solution of the given system or
+the item "failed" if there are no solutions, the component
+basis contains a list of vectors that
+are a basis for the space of solutions of the corresponding
+homogeneous system.
+If the system of linear equations does not have a unique solution,
+then the basis component contains
+non-trivial vectors.
+
+
+
+
This happens when you solve the linear system
+
+with this command.
+
When you want to solve a system of homogeneous equations (that is,
+a system where the numbers on the right-hand sides of the
+nullspace
+equations are all zero) in the matrix form you can omit the second
+argument and use the nullSpace operation.
+
+
+
+
This computes the solutions of the following system of equations:
+
+The result is given as a list of vectors and
+these vectors form a basis for the solution space.
+
+
+
+
+
+
+
+nullSpace([ [1,2,3],[2,3,4],[3,4,5] ])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Vector Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
8.5.2 Solution of a Single Polynomial Equation
+
+
+
+
+
+
Axiom can solve polynomial equations producing either approximate
+polynomial:root finding
+or exact solutions.
+equation:polynomial:solving
+Exact solutions are either members of the ground
+field or can be presented symbolically as roots of irreducible polynomials.
+
+
+
+
This returns the one rational root along with an irreducible
+polynomial describing the other solutions.
+
+
+
+
+
+
+
+solve(x**3 = 8,x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Equation Fraction Polynomial Integer
+
+
+
+
+
If you want solutions expressed in terms of radicals you would use this
+instead.
+radical
+
+
+
+
+
+
+
+radicalSolve(x**3 = 8,x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Equation Expression Integer
+
+
+
+
+
The solve command always returns a value but
+ radicalSolve returns only the solutions that it is
+able to express in terms of radicals.
+radical
+
+
+
+
If the polynomial equation has rational coefficients
+you can ask for approximations to its real roots by calling
+solve with a second argument that specifies the ``precision''
+precision
+ .
+This means that each approximation will be within
+ of the actual
+result.
+
+
+
+
Notice that the type of second argument controls the type of the result.
+
If you give a floating-point precision you get a floating-point result;
+if you give the precision as a rational number you get a rational result.
+
+
+
+
+
+
+
+solve(x**3-2,1/1000)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Equation Polynomial Fraction Integer
+
+
+
+
+
If you want approximate complex results you should use the
+approximation
+command complexSolve that takes the same precision argument
+ .
+
+
+
+
+
+
+
+complexSolve(x**3-2,.0001)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Equation Polynomial Complex Float
+
+
+
+
+
Each approximation will be within
+ of the actual result
+in each of the real and imaginary parts.
+
+
+
+
+
+
+
+complexSolve(x**2-2*%i+1,1/100)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Equation Polynomial Complex Fraction Integer
+
+
+
+
+
Note that if you omit the = from the first argument
+Axiom generates an equation by equating the first argument to zero.
+Also, when only one variable is present in the equation, you
+do not need to specify the variable to be solved for, that is,
+you can omit the second argument.
+
+
+
+
Axiom can also solve equations involving rational functions.
+Solutions where the denominator vanishes are discarded.
+
+
+
+
+
+
+
+radicalSolve(1/x**3 + 1/x**2 + 1/x = 0,x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Equation Expression Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
8.5.3 Solution of Systems of Polynomial Equations
+
+
+
+
+
+
Given a system of equations of rational functions with exact coefficients:
+equation:polynomial:solving
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Axiom can find
+numeric or symbolic solutions.
+The system is first split into irreducible components, then for
+each component, a triangular system of equations is found that reduces
+the problem to sequential solution of univariate polynomials resulting
+from substitution of partial solutions from the previous stage.
+
+
+
+
+
Symbolic solutions can be presented using ``implicit'' algebraic numbers
+defined as roots of irreducible polynomials or in terms of radicals.
+Axiom can also find approximations to the real or complex roots
+of a system of polynomial equations to any user-specified accuracy.
+
+
+
+
The operation solve for systems is used in a way similar
+to solve for single equations.
+Instead of a polynomial equation, one has to give a list of
+equations and instead of a single variable to solve for, a list of
+variables.
+For solutions of single equations see
+ugxProblemOnePol .
+
+
+
+
Use the operation solve if you want implicitly presented
+solutions.
+
+
+
+
+
+
+
+solve([3*x**3 + y + 1,y**2 -4],[x,y])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List List Equation Fraction Polynomial Integer
+
+Type: List List Equation Fraction Polynomial Integer
+
+
+
+
+
Use radicalSolve if you want your solutions expressed
+in terms of radicals.
+
+
+
+
+
+
+
+radicalSolve([3*x**3 + y + 1,y**2 -4],[x,y])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List List Equation Expression Integer
+
+
+
+
+
To get numeric solutions you only need to give the list of
+equations and the precision desired.
+The list of variables would be redundant information since there
+can be no parameters for the numerical solver.
+
+
+
+
If the precision is expressed as a floating-point number you get
+results expressed as floats.
+
+
+
+
+
+
+
+solve([x**2*y - 1,x*y**2 - 2],.01)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List List Equation Polynomial Float
+
+
+
+
+
To get complex numeric solutions, use the operation complexSolve,
+which takes the same arguments as in the real case.
+
+Type: List List Equation Polynomial Complex Fraction Integer
+
+
+
+
+
+
It is also possible to solve systems of equations in rational functions
+over the rational numbers.
+Note that is not returned as a solution since
+the denominator vanishes there.
+
+
+
+
+
+
+
+solve([x**2/a = a,a = a*x],.001)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List List Equation Polynomial Float
+
+
+
+
+
+
When solving equations with
+denominators, all solutions where the denominator vanishes are
+discarded.
+
+
+
+
+
+
+
+radicalSolve([x**2/a + a + y**3 - 1,a*y + a + 1],[x,y])
+
+
To compute a limit, you must specify a functional expression,
+limit
+a variable, and a limiting value for that variable.
+If you do not specify a direction, Axiom attempts to
+compute a two-sided limit.
+
Sometimes the limit when approached from the left is different from
+the limit from the right and, in this case, you may wish to ask for a
+one-sided limit. Also, if you have a function that is only defined on
+one side of a particular value, limit:one-sided vs. two-sided
+you can compute a one-sided limit.
+
+
+
+
The function is only defined to the right of zero, that is,
+for . Thus, when computing limits of functions involving
+ , you probably want a ``right-hand'' limit.
+
When you do not specify `` '' or `` '' as the optional fourth
+argument, limit tries to compute a two-sided limit. Here the
+limit from the left does not exist, as Axiom indicates when you try to
+take a two-sided limit.
+
A function can be defined on both sides of a particular value, but
+tend to different limits as its variable approaches that value from
+the left and from the right. We can construct an example of this as
+follows: Since is simply the absolute value of , the
+function is simply the sign ( or ) of the
+nonzero real number . Therefore, for
+and for .
+
+
+
+
This is what happens when we take the limit at .
+The answer returned by Axiom gives both a
+``left-hand'' and a ``right-hand'' limit.
+
You can take limits of functions with parameters.
+limit:of function with parameters
+As you can see, the limit is expressed in terms of the parameters.
+
However, as a function of a complex variable, is badly
+limit:real vs. complex
+behaved near (one says that has an
+essential singularity
+essential singularity at ).
+singularity:essential
+
+
+
+
When viewed as a function of a complex variable,
+does not approach any limit as tends to in the complex plane.
+Axiom indicates this when we call complexLimit.
+
+
+
+
+
+
+
+complexLimit(z * sin(1/z),z = 0)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union("failed",...)
+
+
+
+
+
Here is another example.
+As approaches along the real axis,
+tends to .
+
However, if is allowed to approach along any path in the
+complex plane, the limiting value of depends on the
+path taken because the function has an essential singularity at .
+This is reflected in the error message returned by the function.
+
+
+
+
+
+
+complexLimit(exp(-1/x**2),x = 0)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union("failed",...)
+
+
+
+
+
You can also take complex limits at infinity, that is, limits of a
+function of as approaches infinity on the Riemann sphere. Use
+the symbol to denote ``complex infinity.''
+
+
+
+
As above, to compute complex limits rather than real limits, use
+ complexLimit.
+
Axiom can compute some forward Laplace transforms, mostly
+Laplace transform of elementary function:elementary
+functions transform:Laplace not involving logarithms, although
+some cases of special functions are handled.
+
+
+
+
To compute the forward Laplace transform of with respect to
+ and express the result as , issue the command
+ .
+
Integration is the reverse process of differentiation, that is,
+integration an integral of a function with respect
+to a variable is any function such that is equal to
+ .
+
+
+
+
The package FunctionSpaceIntegration provides the top-level
+integration operation, integrateintegrateFunctionSpaceIntegration,
+for integrating real-valued elementary functions.
+FunctionSpaceIntegration
+
+
+
+
+
+
+
+integrate(cosh(a*x)*sinh(a*x), x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(Expression Integer,...)
+
+
+
+
+
Unfortunately, antiderivatives of most functions cannot be expressed in
+terms of elementary functions.
+
+
+
+
+
+
+
+integrate(log(1 + sqrt(a * x + b)) / x, x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(Expression Integer,...)
+
+
+
+
+
Given an elementary function to integrate, Axiom returns a formal
+integral as above only when it can prove that the integral is not
+elementary and not when it cannot determine the integral.
+In this rare case it prints a message that it cannot
+determine if an elementary integral exists.
+
+
+
+
Similar functions may have antiderivatives antiderivative
+that look quite different because the form of the antiderivative
+depends on the sign of a constant that appears in the function.
+
+
+
+
+
+
+
+integrate(1/(x**2 - 2),x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(Expression Integer,...)
+
+
+
+
+
+
+
+
+integrate(1/(x**2 + 2),x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(Expression Integer,...)
+
+
+
+
+
If the integrand contains parameters, then there may be several possible
+antiderivatives, depending on the signs of expressions of the parameters.
+
+
+
+
In this case Axiom returns a list of answers that cover all the
+possible cases. Here you use the answer involving the square root of
+ when and integration:result as list of real
+functions the answer involving the square root of when .
+
+
+
+
+
+
+
+integrate(x**2 / (x**4 - a**2), x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(List Expression Integer,...)
+
+
+
+
+
If the parameters and the variables of integration can be complex
+numbers rather than real, then the notion of sign is not defined. In
+this case all the possible answers can be expressed as one complex
+function. To get that function, rather than a list of real functions,
+use complexIntegratecomplexIntegrateFunctionSpaceComplexIntegration,
+which is provided by the package integration:result as a
+complex functionsFunctionSpaceComplexIntegration.
+FunctionSpaceComplexIntegration
+
+
+
+
This operation is used for integrating complex-valued elementary
+functions.
+
+
+
+
+
+
+
+complexIntegrate(x**2 / (x**4 - a**2), x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
As with the real case, antiderivatives for most complex-valued
+functions cannot be expressed in terms of elementary functions.
+
Sometimes integrate can involve symbolic algebraic numbers
+such as those returned by rootOfrootOfExpression.
+To see how to work with these strange generated symbols (such as
+ ), see
+ugxProblemSymRootAll .
+
+
+
+
Definite integration is the process of computing the area between
+integration:definite
+the -axis and the curve of a function .
+The fundamental theorem of calculus states that if is
+continuous on an interval and if there exists a function
+that is differentiable on and such that
+is equal to , then the definite integral of
+for in the interval is equal to .
+
Axiom checks beforehand that the function you are integrating is
+defined on the interval , and prints an error message if it
+finds that this is not case, as in the following example:
+
+
+
+
+
+integrate(1/(x**2-2), x = 1..2)
+
+ >> Error detected within library code:
+ Pole in path of integration
+ You are being returned to the top level
+ of the interpreter.
+
+
+
+
When parameters are present in the function, the function may or may not be
+defined on the interval of integration.
+
+
+
+
If this is the case, Axiom issues a warning that a pole might
+lie in the path of integration, and does not compute the integral.
+
+
+
+
+
+
+
+integrate(1/(x**2-a), x = 1..2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(pole: potentialPole,...)
+
+
+
+
+
If you know that you are using values of the parameter for which
+the function has no pole in the interval of integration, use the
+string ``noPole'' as a third argument to
+integrateintegrateRationalFunctionDefiniteIntegration:
+
+
+
+
The value here is, of course, incorrect if is between
+ and
+
+
+
+
+
+
+
+integrate(1/(x**2-a), x = 1..2, "noPole")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(f2: List OrderedCompletion Expression Integer,...)
+
Axiom has very sophisticated facilities for working with power
+series
+series.
+power series
+
+
+
+
Infinite series are represented by a list of the coefficients that
+have already been determined, together with a function for computing
+the additional coefficients if needed.
+
+
+
+
The system command that determines how many terms of a series is
+displayed is )set streams calculate. For the purposes of this
+book, we have used this system command to display fewer than ten
+terms. set streams calculate Series can be created from
+expressions, from functions for the series coefficients, and from
+applications of operations on existing series. The most general
+function for creating a series is called series, although you
+can also use taylor, laurent and puiseux in
+situations where you know what kind of exponents are involved.
+
+
+
+
For information about solving differential equations in terms of
+power series, see
+ugxProblemDEQSeries .
+
+
+
+
+
+
+
8.9.1 Creation of Power Series
+
+
+
+
+
+
This is the easiest way to create a power series. This tells Axiom
+that is to be treated as a power series, series:creating
+so functions of are again power series.
+
We didn't say anything about the coefficients of the power series, so
+the coefficients are general expressions over the integers. This
+allows us to introduce denominators, symbolic constants, and other
+variables as needed.
+
+
+
+
Here the coefficients are integers (note that the coefficients are the
+Fibonacci Fibonacci numbers numbers).
+
You can also convert an expression into a series expansion. This
+expression creates the series expansion of about .
+For details and more examples, see ugxProblemSeriesConversions
+.
+
You can create power series with more general coefficients. You
+normally accomplish this via a type declaration (see
+ugTypesDeclare ).
+See ugxProblemSeriesFunctions for some warnings about working with
+declared series.
+
+
+
+
We declare that is a one-variable Taylor series
+series:Taylor (UTS is the abbreviation for
+UnivariateTaylorSeries) in the variable with FLOAT
+(that is, floating-point) coefficients, centered about Then, by
+assignment, we obtain the Taylor expansion of with
+floating-point coefficients. UnivariateTaylorSeries
+
+
+
+
+
+
+
+y : UTS(FLOAT,'z,0) := exp(z)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: UnivariateTaylorSeries(Float,z,0.0)
+
+
+
+
+
You can also create a power series by giving an explicit formula for
+its -th coefficient. For details and more examples, see
+ugxProblemSeriesFormula .
+
+
+
+
To create a series about whose -th Taylor coefficient is
+ , you can evaluate this expression. This is the Taylor
+expansion of at .
+
You can extract any coefficient from a power series---even one that
+hasn't been computed yet. This is possible because in Axiom, infinite
+series are represented by a list of the coefficients that have already
+been determined, together with a function for computing the additional
+coefficients. (This is known as lazy evaluation.) When you ask
+for a series:lazy evaluation coefficient that hasn't yet been
+computed, Axiom computes lazy evaluation whatever additional
+coefficients it needs and then stores them in the representation of
+the power series.
+
+
+
+
Here's an example of how to extract the coefficients of a power series.
+series:extracting coefficients
+
Warning:
+the type of the coefficients of a power series may
+affect the kind of computations that you can do with that series.
+This can only happen when you have made a declaration to
+specify a series domain with a certain type of coefficient.
+
+
+
+
+
+
+
+
+
+
If you evaluate then you have declared that is a one variable
+Taylor series series:Taylor (UTS is the abbreviation for
+UnivariateTaylorSeries) in the variable with FRAC INT
+(that is, fractions of integer) coefficients, centered about .
+
If you wanted to apply, say, the operation exp to a power series
+with a nonzero constant coefficient , then the constant
+coefficient of the result would be , which is not a
+rational number. Therefore, evaluating would
+generate an error message.
+
+
+
+
If you want to compute the Taylor expansion of , you
+must ensure that the coefficient domain has an operation exp
+defined for it. An example of such a domain is Expression
+Integer, the type of formal functional expressions over the integers.
+
Another way to create Taylor series whose coefficients are expressions
+over the integers is to use taylor which works similarly to
+series:Taylor series.
+
+
+
+
This is equivalent to the previous computation, except that now we
+are using the variable instead of .
+
The ExpressionToUnivariatePowerSeries package provides
+operations for computing series expansions of functions.
+ExpressionToUnivariatePowerSeries
+
+
+
+
Evaluate this to compute the Taylor expansion of about
+series:Taylor . The first argument, ,
+specifies the function whose series expansion is to be computed and
+the second argument, , specifies that the series is to be
+expanded in power of , that is, in power of .
+
A more interesting function is
+
+When we expand this function as a Taylor
+series in the -th order coefficient is the -th Bernoulli
+Bernoulli:polynomial polynomial polynomial:Bernoulli
+divided by .
+
Therefore, this and the next expression produce the same result.
+
+
+
+
+
+
+
+factorial(6) * coefficient(bern,6)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
+
+
+
+bernoulliB(6,x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Fraction Integer
+
+
+
+
+
Technically, a series with terms of negative degree is not considered
+to be a Taylor series, but, rather, a series:Laurent
+Laurent series. Laurent series If you try to compute a
+Taylor series expansion of at via
+ you get an error message. The reason is that
+the function has a pole at , meaning that its series
+expansion about this point has terms of negative degree. A series
+with finitely many terms of negative degree is called a Laurent
+series.
+
+
+
+
You get the desired series expansion by issuing this.
+
Similarly, a series with terms of fractional degree is neither a
+Taylor series nor a Laurent series. Such a series is called a
+series:PuiseuxPuiseux series. Puiseux series
+The expression results in an
+error message because the series expansion about this point has terms
+of fractional degree.
+
Finally, consider the case of functions that do not have Puiseux
+expansions about certain points. An example of this is about . produces an error message because of the
+type of singularity of the function at .
+
+
+
+
The general function series can be used in this case.
+Notice that the series returned is not, strictly speaking, a power series
+because of the in the expansion.
+
The operation series returns the most general type of
+infinite series.
+The user who is not interested in distinguishing
+between various types of infinite series may wish to use this operation
+exclusively.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
8.9.6 Power Series from Formulas
+
+
+
+
+
+
The GenerateUnivariatePowerSeries package enables you to
+series:giving formula for coefficients create power series
+from explicit formulas for their -th coefficients. In what
+follows, we construct series expansions for certain transcendental
+functions by giving formulas for their coefficients. You can also
+compute such series expansions directly simply by specifying the
+function and the point about which the series is to be expanded.
+GenerateUnivariatePowerSeries See
+ugxProblemSeriesConversions for more information.
+
+
+
+
Consider the Taylor expansion of series:Taylor
+about :
+
The first argument specifies a formula for the -th coefficient by
+giving a function that maps to . The second argument
+specifies that the series is to be expanded in powers of ,
+that is, in powers of . Since we did not specify an initial
+degree, the first term in the series was the term of degree 0 (the
+constant term). Note that the formula was given as an anonymous
+function. These are discussed in ugUserAnon .
+
+
+
+
Consider the Taylor expansion of about :
+
+
+
+
+
+
+
+
+
+
+
+
+
+
If you were to evaluate the expression
+
+you would get an error message because Axiom would try to
+calculate a term of degree and therefore divide by
+
+
+
+
Instead, evaluate this.
+The third argument, , indicates that only terms of degree
+ are to be computed.
+
Next consider the Taylor expansion of an odd function, say, :
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Here every other coefficient is zero and we would like to give an
+explicit formula only for the odd Taylor coefficients.
+
+
+
+
This is one way to do it. The third argument, , specifies that
+the first term to be computed is the term of degree 1. The fourth
+argument, , specifies that we increment by to find the degrees
+of subsequent terms, that is, the next term is of degree , the
+next of degree , etc.
+
While the increment must be positive, the initial degree may be
+negative. This yields the Laurent expansion of at .
+(bernoulli(numer(n+1)) is necessary because bernoulli takes integer
+arguments.)
+
Axiom isn't sufficiently ``symbolic'' in the sense we might wish. It
+is an open problem to decide that ``x'' is the only surviving
+term. Two attacks on the problem might be:
+
+
+
+
(1) Notice that all of the higher terms are identically zero but
+Axiom can't decide that from the information it knows. Presumably
+we could attack this problem by looking at the sin function as
+a taylor series around x=0 and seeing the term cancellation occur.
+This uses a term-difference mechanism.
+
+
+
+
(2) Notice that there is no way to decide that the stream for asinx
+is actually the definition of asin(x). But we could recognize that
+the stream for asin(x) has a generator term and so will a taylor
+series expansion of sin(x). From these two generators it may be
+possible in certain cases to decide that the application of one
+generator to the other will yield only ``x''. This trick involves
+finding the correct inverse for the stream functions. If we can
+find an inverse for the ``remaining tail'' of the stream we could
+conclude cancellation and thus turn an infinite stream into a
+finite object.
+
+
+
+
In general this is the zero-equivalence problem and is undecidable.
+
+
+
+
+
+
+
+
+
+
As we discussed in ugxProblemSeriesConversions , you can also use
+the operations taylor, laurent and puiseux instead
+of series if you know ahead of time what kind of exponents a
+series has. You can't go wrong using series, though.
+
+
+
+
+
+
+
+
+
+
+
+
8.9.7 Substituting Numerical Values in Power Series
+
+
+
+
+
+
Use evalevalUnivariatePowerSeriesCategory
+approximation to substitute a numerical value for a variable
+in series:numerical approximation a power series. For
+example, here's a way to obtain numerical approximations of from
+the Taylor series expansion of .
+
Then you evaluate the series at the value .
+The result is a sequence of the partial sums.
+
+
+
+
+
+
+
+eval(f,1.0)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Expression Float
+
+
+
+
+
+
+
+
+
+
+
+
+
8.9.8 Example: Bernoulli Polynomials and Sums of Powers
+
+
+
+
+
+
Axiom provides operations for computing definite and
+summation:definite indefinite sums.
+summation:indefinite
+
+
+
+
You can compute the sum of the first ten fourth powers by evaluating
+this. This creates a list whose entries are as ranges from
+1 to 10, and then computes the sum of the entries of that list.
+
+
+
+
+
+
+
+reduce(+,[m**4 for m in 1..10])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
You can also compute a formula for the sum of the first fourth
+powers, where is an unspecified positive integer.
+
+
+
+
+
+
+
+sum4 := sum(m**4, m = 1..k)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Polynomial Integer
+
+
+
+
+
This formula is valid for any positive integer . For instance, if
+we replace by 10, summation:definite we obtain the number
+we computed earlier.
+
+
+
+
+
+
+
+eval(sum4, k = 10)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Polynomial Integer
+
+
+
+
+
You can compute a formula for the sum of the first -th powers
+in a similar fashion. Just replace the in the definition of
+ sum4 by any expression not involving . Axiom computes these
+formulas using Bernoulli polynomials; Bernoulli:polynomial we
+polynomial:Bernoulli use the rest of this section to describe
+this method.
+
+
+
+
First consider this function of and .
+
+
+
+
+
+
+
+f := t*exp(x*t) / (exp(t) - 1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
Since the expressions involved get quite large, we tell
+Axiom to show us only terms of degree up to
+
+
+
+
+
+
+
+)set streams calculate 5
+
+
+
+
+
+
set streams calculate
+
+
+
+
If we look at the Taylor expansion of about
+we see that the coefficients of the powers of are polynomials
+in .
+
In fact, the -th coefficient in this series is essentially the
+ -th Bernoulli polynomial: the -th coefficient of the series is
+ , where is the -th Bernoulli
+polynomial. Thus, to obtain the -th Bernoulli polynomial, we
+multiply the -th coefficient of the series by .
+
+
+
+
For example, the sixth Bernoulli polynomial is this.
+
+
+
+
+
+
+
+factorial(6) * coefficient(ff,6)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
We derive some properties of the function .
+First we compute .
+
+
+
+
+
+
+
+g := eval(f, x = x + 1) - f
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
If we normalize , we see that it has a particularly simple form.
+
+
+
+
+
+
+
+normalize(g)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
From this it follows that the -th coefficient in the Taylor
+expansion of at is .
+
+
+
+
If you want to check this, evaluate the next expression.
+
However, since
+
+it follows that the -th coefficient is
+ Equating
+coefficients, we see that
+
+and, therefore,
+
+
+
+
+
Let's apply this formula repeatedly, letting vary between two
+integers and , with :
+
+
+
+
+
+
+
+
+
+
+
+
+
+
When we add these equations we find that the sum of the left-hand
+sides is
+
+the sum of the
+
+powers from to . The sum of the right-hand sides is a
+``telescoping series.'' After cancellation, the sum is simply
+
+
+
+
+
Replacing by , we have shown that
+
+
+
+
+
Let's use this to obtain the formula for the sum of fourth powers.
+
+
+
+
First we obtain the Bernoulli polynomial .
+
+
+
+
+
+
+
+B5 := factorial(5) * coefficient(ff,5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
To find the sum of the first 4th powers,
+we multiply by .
+
+
+
+
+
+
+
+1/5 * (eval(B5, x = k + 1) - eval(B5, x = 1))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
This is the same formula that we obtained via .
+
+
+
+
+
+
+
+sum4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Polynomial Integer
+
+
+
+
+
At this point you may want to do the same computation, but with an
+exponent other than For example, you might try to find a formula
+for the sum of the first 20th powers.
+
The AssociationList constructor provides a general structure for
+associative storage. This type provides association lists in which
+data objects can be saved according to keys of any type. For a given
+association list, specific types must be chosen for the keys and
+entries. You can think of the representation of an association list
+as a list of records with key and entry fields.
+
+
+
+
Association lists are a form of table and so most of the operations
+available for Table are also available for AssociationList.
+They can also be viewed as lists and can be manipulated accordingly.
+
+
+
+
This is a Record type with age and gender fields.
+
Use deletedeleteAssociationList to destructively remove an
+element of the association list. Use
+deletedeleteAssociationList to return a copy of the
+association list with the element deleted. The second argument is the
+index of the element to delete.
+
On an n space, a grade p form has a dual n-p form.
+In particular, in three space the dual of a grade two element identifies
+e1*e2->e3, e2*e3->e1, e3*e1->e2.
+
+
+
+
+
+
+
+dual2 a == coefficient(a,[2,3]) * i + coefficient(a,[3,1]) * j + coefficient(a,[1,2]) * k
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
The vector cross product is then given by this.
+
+
+
+
+
+
+
+dual2(x*y)
+
+
+
+
+
+
+
+ Compiling function dual2 with type CliffordAlgebra(3,Fraction
+ Polynomial Integer,MATRIX) -> CliffordAlgebra(3,Fraction
+ Polynomial Integer,MATRIX)
+
The Complex constructor implements complex objects over a
+commutative ring R. Typically, the ring R is Integer,
+Fraction Integer, Float or DoubleFloat.
+R can also be a symbolic type, like Polynomial Integer.
+For more information about the numerical and graphical aspects of
+complex numbers, see ugProblemNumeric .
+
+
+
+
Complex objects are created by the complexcomplexComplex operation.
+
+
+
+
+
+
+
+a := complex(4/3,5/2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Fraction Integer
+
+
+
+
+
+
+
+
+b := complex(4/3,-5/2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Fraction Integer
+
+
+
+
+
The standard arithmetic operations are available.
+
+
+
+
+
+
+
+a + b
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Fraction Integer
+
+
+
+
+
+
+
+
+a - b
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Fraction Integer
+
+
+
+
+
+
+
+
+a * b
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Fraction Integer
+
+
+
+
+
If R is a field, you can also divide the complex objects.
+
The predefined macro %i is defined to be complex(0,1).
+
+
+
+
+
+
+
+3.4 + 6.7 * %i
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Float
+
+
+
+
+
You can also compute the conjugateconjugateComplex and
+normnormComplex of a complex number.
+
+
+
+
+
+
+
+conjugate a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Fraction Integer
+
+
+
+
+
+
+
+
+norm a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
The realrealComplex and imagimagComplex operations
+are provided to extract the real and imaginary parts, respectively.
+
+
+
+
+
+
+
+real a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
+
+
+
+imag a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
The domain Complex Integer is also called the Gaussian integers.
+If R is the integers (or, more generally, a EuclideanDomain),
+you can compute greatest common divisors.
+
Continued fractions have been a fascinating and useful tool in
+mathematics for well over three hundred years. Axiom implements
+continued fractions for fractions of any Euclidean domain. In
+practice, this usually means rational numbers. In this section we
+demonstrate some of the operations available for manipulating both
+finite and infinite continued fractions. It may be helpful if you
+review StreamXmpPage to remind
+yourself of some of the operations with streams.
+
+
+
+
The ContinuedFraction domain is a field and therefore you can
+add, subtract, multiply and divide the fractions.
+
+
+
+
The continuedFractioncontinuedFractionContinuedFraction operation
+converts its fractional argument to a continued fraction.
+
You can write any rational number in a similar form. The fraction
+will be finite and you can always take the ``numerators'' to be 1.
+That is, any rational number can be written as a simple, finite
+continued fraction of the form
+
The are called partial quotients and the operation
+partialQuotientspartialQuotientsContinuedFraction creates a stream of them.
+
+
+
+
+
+
+
+partialQuotients c
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Integer
+
+
+
+
+
By considering more and more of the fraction, you get the
+convergentsconvergentsContinuedFraction. For example, the first
+convergent is , the second is and so on.
+
+
+
+
+
+
+
+convergents c
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Fraction Integer
+
+
+
+
+
Since this is a finite continued fraction, the last convergent is the
+original rational number, in reduced form. The result of
+approximantsapproximantsContinuedFraction is always an infinite
+stream, though it may just repeat the ``last'' value.
+
+
+
+
+
+
+
+approximants c
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Fraction Integer
+
+
+
+
+
Inverting c only changes the partial quotients of its fraction
+by inserting a 0 at the beginning of the list.
+
+
+
+
+
+
+
+pq := partialQuotients(1/c)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Integer
+
+
+
+
+
Do this to recover the original continued fraction from this list of
+partial quotients. The three-argument form of the
+continuedFractioncontinuedFractionContinuedFraction operation takes an
+element which is the whole part of the fraction, a stream of elements
+which are the numerators of the fraction, and a stream of elements
+which are the denominators of the fraction.
+
The streams need not be finite for
+continuedFractioncontinuedFractionContinuedFraction. Can you guess
+which irrational number has the following continued fraction? See the
+end of this section for the answer.
+
We use this expansion to compute rational and floating point
+approximations of e. For this and other interesting
+expansions, see C. D. Olds, Continued Fractions, New
+Mathematical Library, (New York: Random House, 1963), pp. 134--139.
+
+
+
+
By looking at the above expansion, we see that the whole part is 0
+and the numerators are all equal to 1. This constructs the
+stream of denominators.
+
This section is based upon the paper J. H. Redfield, ``The Theory of
+Group-Reduced Distributions'', American J. Math.,49 (1927) 433-455,
+and is an application of group theory to enumeration problems. It is
+a development of the work by P. A. MacMahon on the application of
+symmetric functions and Hammond operators to combinatorial theory.
+
+
+
+
The theory is based upon the power sum symmetric functions
+ which are the sum of the -th powers of the
+variables. The cycle index of a permutation is an expression that
+specifies the sizes of the cycles of a permutation, and may be
+represented as a partition. A partition of a non-negative integer
+n is a collection of positive integers called its parts whose
+sum is n. For example, the partition will be
+used to represent and will indicate that the
+permutation has two cycles of length 3, one of length 2 and two of
+length 1. The cycle index of a permutation group is the sum of the
+cycle indices of its permutations divided by the number of
+permutations. The cycle indices of certain groups are provided.
+
+
+
+
The operation complete returns the cycle index of the
+symmetric group of order n for argument n.
+Alternatively, it is the -th complete homogeneous symmetric
+function expressed in terms of power sum symmetric functions.
+
+
+
+
+
+
+
+complete 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SymmetricPolynomial Fraction Integer
+
+
+
+
+
+
+
+
+complete 2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SymmetricPolynomial Fraction Integer
+
+
+
+
+
+
+
+
+complete 3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SymmetricPolynomial Fraction Integer
+
+
+
+
+
+
+
+
+complete 7
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SymmetricPolynomial Fraction Integer
+
+
+
+
+
The operation elementary computes the -th
+elementary symmetric function for argument n.
+
+
+
+
+
+
+
+elementary 7
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SymmetricPolynomial Fraction Integer
+
+
+
+
+
The operation alternating returns the cycle index of the alternating
+group having an even number of even parts in each cycle partition.
+
+
+
+
+
+
+
+alternating 7
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SymmetricPolynomial Fraction Integer
+
+
+
+
+
The operation cyclic returns the cycle index of the cyclic group.
+
+
+
+
+
+
+
+cyclic 7
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SymmetricPolynomial Fraction Integer
+
+
+
+
+
The operation dihedral is the cycle index of the
+dihedral group.
+
+
+
+
+
+
+
+dihedral 7
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SymmetricPolynomial Fraction Integer
+
+
+
+
+
The operation graphs for argument n returns the cycle
+index of the group of permutations on the edges of the complete graph
+with n nodes induced by applying the symmetric group to the
+nodes.
+
+
+
+
+
+
+
+graphs 5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SymmetricPolynomial Fraction Integer
+
+
+
+
+
The cycle index of a direct product of two groups is the product of
+the cycle indices of the groups. Redfield provided two operations on
+two cycle indices which will be called ``cup'' and ``cap'' here. The
+cup of two cycle indices is a kind of scalar product that
+combines monomials for permutations with the same cycles. The cap operation provides the sum of the coefficients of the result of
+the cup operation which will be an integer that enumerates what
+Redfield called group-reduced distributions.
+
+
+
+
We can, for example, represent complete 2 * complete 2 as the
+set of objects a a b b and
+complete 2 * complete 1 * complete 1 as c c d e.
+
+
+
+
This integer is the number of different sets of four pairs.
+
In this case the configurations enumerated are easily constructed,
+however the theory merely enumerates them providing little help in
+actually constructing them.
+
+
+
+
Here are the number of 6-pairs, first from a a a b b c, second
+from d d e e f g.
+
Having constructed a cycle index for a configuration we are at liberty
+to evaluate the components any way we please. For example we
+can produce enumerating generating functions. This is done by
+providing a function f on an integer i to the value
+required of , and then evaluating eval(f, cycleindex).
+
The coefficient of is the number of graphs with 5 nodes and n
+edges.
+
+
+
+
Note that there is an eval function that takes two arguments. It has the
+signature:
+
+
+
+
+
+((Integer -> D1),SymmetricPolynomial Fraction Integer) -> D1
+ from EvaluateCycleIndicators D1 if D1 has ALGEBRA FRAC INT
+
+
+
+
This function is not normally exposed (it will not normally be considered
+in the list of eval functions) as it is only useful for this particular
+domain. To use it we ask that it be considered thus:
+
The coefficient of is the number of graphs with 5 nodes and with
+integers on the edges whose sum is n. In other words, the
+enumeration is of multigraphs with 5 nodes and n edges.
+
The operation SFunction is the S-function or Schur function of a
+partition written as a descending list of integers expressed in terms
+of power sum symmetric functions.
+
+
+
+
In this case the argument partition represents a tableau shape. For
+example 3,2,2,1 represents a tableau with three boxes in the
+first row, two boxes in the second and third rows, and one box in the
+fourth row. SFunction [3,2,2,1] counts the number of different
+tableaux of shape 3, 2, 2, 1 filled with objects with an
+ascending order in the columns and a non-descending order in the rows.
+
+
+
+
+
+
+
+sf3221:= SFunction [3,2,2,1]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SymmetricPolynomial Fraction Integer
+
+
+
+
+
This is the number filled with a a b b c c d d.
+
+
+
+
+
+
+
+cap(sf3221,complete 2**4)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
The configurations enumerated above are:
+
+
+
+
+
+a a b a a c a a d
+b c b b b b
+c d c d c c
+d d d
+
+
+
+
+
This is the number of tableaux filled with 1..8.
+
+
+
+
+
+
+
+cap(sf3221, powerSum 1**8)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
The coefficient of is the number of column strict reverse plane
+partitions of n of shape 3 2 2 1.
+
The domain constructor DeRhamComplex creates the class of
+differential forms of arbitrary degree over a coefficient ring. The
+De Rham complex constructor takes two arguments: a ring, coefRing, and a list of coordinate variables.
+
+
+
+
This is the ring of coefficients.
+
+
+
+
+
+
+
+coefRing := Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
These are the coordinate variables.
+
+
+
+
+
+
+
+lv : List Symbol := [x,y,z]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Symbol
+
+
+
+
+
This is the De Rham complex of Euclidean three-space using coordinates
+x, y and z.
+
+
+
+
+
+
+
+der := DERHAM(coefRing,lv)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+This complex allows us to describe differential forms having
+expressions of integers as coefficients. These coefficients can
+involve any number of variables, for example, f(x,t,r,y,u,z).
+As we've chosen to work with ordinary Euclidean three-space,
+expressions involving these forms are treated as functions of
+x, y and z with the additional arguments t, r
+and u regarded as symbolic constants.
+
+
+
+
Here are some examples of coefficients.
+
+
+
+
+
+
+
+R := Expression coefRing
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
+
+
+
+f : R := x**2*y*z-5*x**3*y**2*z**5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
+
+
+
+g : R := z**2*y*cos(z)-7*sin(x**3*y**2)*z**2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
+
+
+
+h : R :=x*y*z-2*x**3*y*z**2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
We now define the multiplicative basis elements for the exterior
+algebra over R.
+
+
+
+
+
+
+
+dx : der := generator(1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DeRhamComplex(Integer,[x,y,z])
+
+
+
+
+
+
+
+
+dy : der := generator(2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DeRhamComplex(Integer,[x,y,z])
+
+
+
+
+
+
+
+
+dz : der := generator(3)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DeRhamComplex(Integer,[x,y,z])
+
+
+
+
+
This is an alternative way to give the above assignments.
+
+
+
+
+
+
+
+[dx,dy,dz] := [generator(i)$der for i in 1..3]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List DeRhamComplex(Integer,[x,y,z])
+
+
+
+
+
Now we define some one-forms.
+
+
+
+
+
+
+
+alpha : der := f*dx + g*dy + h*dz
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DeRhamComplex(Integer,[x,y,z])
+
+
+
+
+
+
+
+
+beta : der := cos(tan(x*y*z)+x*y*z)*dx + x*dy
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DeRhamComplex(Integer,[x,y,z])
+
+
+
+
+
A well-known theorem states that the composition of
+exteriorDifferentialexteriorDifferentialDeRhamComplex with itself is the
+zero map for continuous forms. Let's verify this theorem for alpha.
+
+
+
+
+
+
+
+exteriorDifferential alpha
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DeRhamComplex(Integer,[x,y,z])
+
+
+
+
+
We see a lengthy output of the last expression, but nevertheless, the
+composition is zero.
+
+
+
+
+
+
+
+exteriorDifferential %
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DeRhamComplex(Integer,[x,y,z])
+
+
+
+
+
Now we check that exteriorDifferentialexteriorDifferentialDeRhamComplex
+is a ``graded derivation'' D, that is, D satisfies:
+
This allows us to get formal definitions for the ``gradient'' ...
+
+
+
+
+
+
+
+totalDifferential(a(x,y,z))$der
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DeRhamComplex(Integer,[x,y,z])
+
+
+
+
+
the ``curl'' ...
+
+
+
+
+
+
+
+exteriorDifferential sigma
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DeRhamComplex(Integer,[x,y,z])
+
+
+
+
+
and the ``divergence.''
+
+
+
+
+
+
+
+exteriorDifferential theta
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DeRhamComplex(Integer,[x,y,z])
+
+
+
+
+
Note that the De Rham complex is an algebra with unity. This element
+1 is the basis for elements for zero-forms, that is, functions
+in our space.
+
+
+
+
+
+
+
+one : der := 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DeRhamComplex(Integer,[x,y,z])
+
+
+
+
+
To convert a function to a function lying in the De Rham complex,
+multiply the function by ``one.''
+
+
+
+
+
+
+
+g1 : der := a([x,t,y,u,v,z,e]) * one
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DeRhamComplex(Integer,[x,y,z])
+
+
+
+
+
A current limitation of Axiom forces you to write functions with more
+than four arguments using square brackets in this way.
+
+
+
+
+
+
+
+h1 : der := a([x,y,x,t,x,z,y,r,u,x]) * one
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DeRhamComplex(Integer,[x,y,z])
+
+
+
+
+
Now note how the system keeps track of where your coordinate functions
+are located in expressions.
+
+
+
+
+
+
+
+exteriorDifferential g1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DeRhamComplex(Integer,[x,y,z])
+
+
+
+
+
+
+
+
+exteriorDifferential h1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DeRhamComplex(Integer,[x,y,z])
+
+
+
+
+
In this example of Euclidean three-space, the basis for the De Rham complex
+consists of the eight forms: 1, dx, dy, dz,
+dx*dy, dx*dz, dy*dz, and dx*dy*dz.
+
All rationals have repeating decimal expansions. Operations to access
+the individual digits of a decimal expansion can be obtained by
+converting the value to RadixExpansion(10). More examples of
+expansions are available in
+BinaryExpansionXmpPage ,
+HexadecimalExpansionXmpPage , and
+RadixExpansionXmpPage .
+
+
+
+
The operation decimaldecimalDecimalExpansion is used to create
+this expansion of type DecimalExpansion.
+
+
+
+
+
+
+
+r := decimal(22/7)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DecimalExpansion
+
+
+
+
+
Arithmetic is exact.
+
+
+
+
+
+
+
+r + decimal(6/7)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DecimalExpansion
+
+
+
+
+
The period of the expansion can be short or long ...
+
DistributedMultivariatePolynomial which is abbreviated as DMP
+and HomogeneousDistributedMultivariatePolynomial, which is abbreviated
+as HDMP, are very similar to MultivariatePolynomial except that
+they are represented and displayed in a non-recursive manner.
+
+
+
+
+
+
+
+(d1,d2,d3) : DMP([z,y,x],FRAC INT)
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
The constructor DMP orders its monomials lexicographically while
+HDMP orders them by total order refined by reverse lexicographic
+order.
+
Note that we get a different Gröbner basis when we use the
+HDMP polynomials, as expected.
+
+
+
+
+
+
+
+groebner [n1,n2,n3]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List HomogeneousDistributedMultivariatePolynomial([z,y,x],Fraction Integer)
+
+
+
+
+
GeneralDistributedMultivariatePolynomial is somewhat
+more flexible in the sense that as well as accepting a list of
+variables to specify the variable ordering, it also takes a
+predicate on exponent vectors to specify the term ordering.
+With this polynomial type the user can experiment with the effect
+of using completely arbitrary term orderings.
+This flexibility is mostly important for algorithms such as
+Gr\"{o}bner basis calculations which can be very
+sensitive to term ordering.
+
Axiom provides two kinds of floating point numbers. The domain
+Float (abbreviation FLOAT) implements a model of arbitrary
+precision floating point numbers. The domain DoubleFloat
+(abbreviation DFLOAT) is intended to make available hardware
+floating point arithmetic in Axiom. The actual model of floating
+point DoubleFloat that provides is system-dependent. For
+example, on the IBM system 370 Axiom uses IBM double precision which
+has fourteen hexadecimal digits of precision or roughly sixteen
+decimal digits. Arbitrary precision floats allow the user to specify
+the precision at which arithmetic operations are computed. Although
+this is an attractive facility, it comes at a cost. Arbitrary-precision
+floating-point arithmetic typically takes twenty to two hundred times
+more time than hardware floating point.
+
+
+
+
The usual arithmetic and elementary functions are available for
+DoubleFloat. Use )show DoubleFloat to get a list of operations
+or the HyperDoc browse facility to get more extensive documentation
+about DoubleFloat.
+
+
+
+
By default, floating point numbers that you enter into Axiom are of
+type Float.
+
+
+
+
+
+
+
+2.71828
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
You must therefore tell Axiom that you want to use DoubleFloat
+values and operations. The following are some conservative guidelines
+for getting Axiom to use DoubleFloat.
+
+
+
+
To get a value of type DoubleFloat, use a target with @, ...
+
+
+
+
+
+
+
+2.71828@DoubleFloat
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DoubleFloat
+
+
+
+
+
a conversion, ...
+
+
+
+
+
+
+
+2.71828 :: DoubleFloat
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DoubleFloat
+
+
+
+
+
or an assignment to a declared variable. It is more efficient if you
+use a target rather than an explicit or implicit conversion.
+
+
+
+
+
+
+
+eApprox : DoubleFloat := 2.71828
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DoubleFloat
+
+
+
+
+
You also need to declare functions that work with DoubleFloat.
+
+
+
+
+
+
+
+avg : List DoubleFloat -> DoubleFloat
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+avg l ==
+ empty? l => 0 :: DoubleFloat
+ reduce(_+,l) / #l
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+avg []
+
+
+
+
+
this complains but succeeds
+
+
+
+
+
+
+
+avg [3.4,9.7,-6.8]
+
+
+
+
+
+
+
+ Compiling function avg with type List Float -> DoubleFloat
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DoubleFloat
+
+
+
+
+
Use package-calling for operations from DoubleFloat unless
+the arguments themselves are already of type DoubleFloat.
+
+
+
+
+
+
+
+cos(3.1415926)$DoubleFloat
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DoubleFloat
+
+
+
+
+
+
+
+
+cos(3.1415926 :: DoubleFloat)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DoubleFloat
+
+
+
+
+
By far, the most common usage of DoubleFloat is for functions to
+be graphed. For more information about Axiom's numerical and
+graphical facilities, see Section
+ugGraph ,
+ugProblemNumeric , and
+FloatXmpPage .
+
The EqTable domain provides tables where the keys are compared
+using eq?eq?EqTable. Keys are considered equal only if
+they are the same instance of a structure. This is useful if the keys
+are themselves updatable structures. Otherwise, all operations are
+the same as for type Table. See
+TableXmpPage for general
+information about tables.
+
+
+
+
The operation tabletableEqTable is here used to create a table
+where the keys are lists of integers.
+
The Equation domain provides equations as mathematical objects.
+These are used, for example, as the input to various
+solvesolveTransSolvePackage operations.
+
+
+
+
Equations are created using the equals symbol, =.
+
+
+
+
+
+
+
+eq1 := 3*x + 4*y = 5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Equation Polynomial Integer
+
+
+
+
+
+
+
+
+eq2 := 2*x + 2*y = 3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Equation Polynomial Integer
+
+
+
+
+
The left- and right-hand sides of an equation are accessible using
+the operations lhslhsEquation and rhsrhsEquation.
+
+
+
+
+
+
+
+lhs eq1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
+
+
+
+rhs eq1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
Arithmetic operations are supported and operate on both sides of the
+equation.
+
+
+
+
+
+
+
+eq1 + eq2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Equation Polynomial Integer
+
+
+
+
+
+
+
+
+eq1 * eq2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Equation Polynomial Integer
+
+
+
+
+
+
+
+
+2*eq2 - eq1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Equation Polynomial Integer
+
+
+
+
+
Equations may be created for any type so the arithmetic operations
+will be defined only when they make sense. For example, exponentiation
+is not defined for equations involving non-square matrices.
+
+
+
+
+
+
+
+eq1**2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Equation Polynomial Integer
+
+
+
+
+
Note that an equals symbol is also used to test for equality of
+values in certain contexts. For example, x+1 and y are
+unequal as polynomials.
+
+
+
+
+
+
+
+if x+1 = y then "equal" else "unequal"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
+
+
+
+eqpol := x+1 = y
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Equation Polynomial Integer
+
+
+
+
+
If an equation is used where a Boolean value is required, then
+it is evaluated using the equality test from the operand type.
+
+
+
+
+
+
+
+if eqpol then "equal" else "unequal"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
If one wants a Boolean value rather than an equation, all one
+has to do is ask!
+
BalancedBinaryTrees(S) is the domain of balanced binary trees
+with elements of type S at the nodes. A binary tree is either
+empty or else consists of a node having a value and
+two branches, each branch a binary tree. A balanced binary tree is
+one that is balanced with respect its leaves. One with leaves
+is perfectly ``balanced'': the tree has minimum depth, and the left and right branch of every interior node is identical in
+shape.
+
+
+
+
Balanced binary trees are useful in algebraic computation for
+so-called ``divide-and-conquer'' algorithms. Conceptually, the data
+for a problem is initially placed at the root of the tree. The
+original data is then split into two subproblems, one for each
+subtree. And so on. Eventually, the problem is solved at the leaves
+of the tree. A solution to the original problem is obtained by some
+mechanism that can reassemble the pieces. In fact, an implementation
+of the Chinese Remainder Algorithm using balanced binary trees was
+first proposed by David Y. Y. Yun at the IBM T. J. Watson Research
+Center in Yorktown Heights, New York, in 1978. It served as the
+prototype for polymorphic algorithms in Axiom.
+
+
+
+
In what follows, rather than perform a series of computations with a
+single expression, the expression is reduced modulo a number of
+integer primes, a computation is done with modular arithmetic for each
+prime, and the Chinese Remainder Algorithm is used to obtain the
+answer to the original problem. We illustrate this principle with the
+computation of .
+
+
+
+
A list of moduli.
+
+
+
+
+
+
+
+lm := [3,5,7,11]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
The expression modTree(n, lm) creates a balanced binary tree
+with leaf values n mod m for each modulus m in lm.
+
+
+
+
+
+
+
+modTree(12,lm)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
Operation modTree does this using operations on balanced binary
+trees. We trace its steps. Create a balanced binary tree t of
+zeros with four leaves.
+
+
+
+
+
+
+
+t := balancedBinaryTree( #lm, 0)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: BalancedBinaryTree NonNegativeInteger
+
+
+
+
+
The leaves of the tree are set to the individual moduli.
+
+
+
+
+
+
+
+setleaves!(t,lm)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: BalancedBinaryTree NonNegativeInteger
+
+
+
+
+
Use mapUp! to do a bottom-up traversal of t, setting each
+interior node to the product of the values at the nodes of its
+children.
+
+
+
+
+
+
+
+mapUp!(t,_*)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The value at the node of every subtree is the product of the moduli
+of the leaves of the subtree.
+
+
+
+
+
+
+
+t
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: BalancedBinaryTree NonNegativeInteger
+
+
+
+
+
Operation mapDown!(t,a,fn) replaces the value v at
+each node of t by fn(a,v).
+
+
+
+
+
+
+
+mapDown!(t,12,_rem)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: BalancedBinaryTree NonNegativeInteger
+
+
+
+
+
The operation leaves returns the leaves of the resulting tree.
+In this case, it returns the list of 12 mod m for each modulus
+m.
+
+
+
+
+
+
+
+leaves %
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List NonNegativeInteger
+
+
+
+
+
Compute the square of the images of 12 modulo each m.
+
+
+
+
+
+
+
+squares := [x**2 rem m for x in % for m in lm]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List NonNegativeInteger
+
+
+
+
+
Call the Chinese Remainder Algorithm to get the answer for .
+
A function that does not return directly to its caller has Exit
+as its return type. The operation error is an example of one
+which does not return to its caller. Instead, it causes a return to
+top-level.
+
+
+
+
+
+
+
+n := 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: NonNegativeInteger
+
+
+
+
+
The function gasp is given return type Exit since it is
+guaranteed never to return a value to its caller.
+
+
+
+
+
+
+gasp(): Exit ==
+ free n
+ n := n + 1
+ error "Oh no!"
+
+Function declaration gasp : () -> Exit has been added to workspace.
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
The return type of half is determined by resolving the types of
+the two branches of the if.
+
+
+
+
+
+
+half(k) ==
+ if odd? k then gasp()
+ else k quo 2
+
+
+
+
+
Because gasp has the return type Exit, the type of
+if in half is resolved to be Integer.
+
+
+
+
+
+
+
+half 4
+
+
+
+
+
+
+
+ Compiling function gasp with type () -> Exit
+ Compiling function half with type PositiveInteger -> Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+half 3
+
+
+
+
+
+
+
+ Error signalled from user code in function gasp:
+ Oh no!
+
+
+
+
+
+
+
+
+n
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: NonNegativeInteger
+
+
+
+
+
For functions which return no value at all, use Void. See
+ugUserPage in Section
+ugUserNumber and
+VoidXmpPage for
+more information.
+
As you can see, Expression actually takes an argument domain.
+The coefficients of the terms within the expression belong to
+the argument domain. Integer and Float, along with
+Complex Integer and Complex Float are the most common
+coefficient domains.
+
+
+
+
The choice of whether to use a Complex coefficient domain or not
+is important since Axiom can perform some simplifications on
+real-valued objects
+
+
+
+
+
+
+
+log(exp x)@Expression(Integer)
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
... which are not valid on complex ones.
+
+
+
+
+
+
+
+log(exp x)@Expression(Complex Integer)
+
+
+
+
+
+
+
+
+
+
+Type: Expression Complex Integer
+
+
+
+
+
Many potential coefficient domains, such as AlgebraicNumber, are
+not usually used because Expression can subsume them.
+
+
+
+
+
+
+
+sqrt 3 + sqrt(2 + sqrt(-5))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: AlgebraicNumber
+
+
+
+
+
+
+
+
+% :: Expression Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
Note that we sometimes talk about ``an object of type Expression.'' This is not really correct because we should say, for
+example, ``an object of type Expression Integer'' or ``an object
+of type Expression Float.'' By a similar abuse of language,
+when we refer to an ``expression'' in this section we will mean an
+object of type Expression R for some domain R.
+
+
+
+
The Axiom documentation contains many examples of the use of Expression. For the rest of this section, we'll give you some
+pointers to those examples plus give you some idea of how to
+manipulate expressions.
+
+
+
+
It is important for you to know that Expression creates domains
+that have category Field. Thus you can invert any non-zero
+expression and you shouldn't expect an operation like factor to
+give you much information. You can imagine expressions as being
+represented as quotients of ``multivariate'' polynomials where the
+``variables'' are kernels (see
+KernelXmpPage ). A kernel can
+either be a symbol such as x or a symbolic function application
+like sin(x + 4). The second example is actually a nested kernel
+since the argument to sin contains the kernel x.
+
+
+
+
+
+
+
+height mainKernel sin(x + 4)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Actually, the argument to sin is an expression, and so the
+structure of Expression is recursive.
+KernelXmpPage
+demonstrates how to extract the kernels in an expression.
+
+
+
+
Use the HyperDoc Browse facility to see what operations are applicable
+to expression. At the time of this writing, there were 262 operations
+with 147 distinct name in Expression Integer. For example,
+numernumerExpression and denomdenomExpression
+extract the numerator and denominator of an expression.
+
When an expression involves no ``symbol kernels'' (for example,
+x), it may be possible to numerically evaluate the expression.
+
+
+
+
If you suspect the evaluation will create a complex number, use
+complexNumeric.
+
+
+
+
+
+
+
+complexNumeric(cos(2 - 3*%i))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Complex Float
+
+
+
+
+
If you know it will be real, use numeric.
+
+
+
+
+
+
+
+numeric(tan 3.8)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
The numeric operation will display an error message if the
+evaluation yields a calue with an non-zero imaginary part. Both of
+these operations have an optional second argument n which
+specifies that the accuracy of the approximation be up to n
+decimal places.
+
+
+
+
When an expression involves no ``symbolic application'' kernels, it
+may be possible to convert it a polynomial or rational function in the
+variables that are present.
+
+
+
+
+
+
+
+e2 := cos(x**2 - y + 3)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
+
+
+
+e3 := asin(e2) - %pi/2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
+
+
+
+e3 :: Polynomial Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
This also works for the polynomial types where specific variables
+and their ordering are given.
+
Factored creates a domain whose objects are kept in factored
+form as long as possible. Thus certain operations like
+* (multiplication) and
+gcdgcdFactored are relatively easy to do. Others, such
+as addition, require somewhat more work, and the result may not be
+completely factored unless the argument domain R provides a
+factorfactorFactored operation. Each object consists of a
+unit and a list of factors, where each factor consists of a member of
+R (the base), an exponent, and a flag indicating what is
+known about the base. A flag may be one of ``nil'', ``sqfr'',
+``irred'' or ``prime'', which mean that nothing is known about
+the base, it is square-free, it is irreducible, or it is prime,
+respectively. The current restriction to factored objects of integral
+domains allows simplification to be performed without worrying about
+multiplication order.
+
+
+
+
+
+
+
9.22.1 Decomposing Factored Objects
+
+
+
+
In this section we will work with a factored integer.
+
+
+
+
+
+
+
+g := factor(4312)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Integer
+
+
+
+
+
Let's begin by decomposing g into pieces. The only possible
+units for integers are 1 and -1.
+
+
+
+
+
+
+
+unit(g)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
There are three factors.
+
+
+
+
+
+
+
+numberOfFactors(g)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
We can make a list of the bases, ...
+
+
+
+
+
+
+
+[nthFactor(g,i) for i in 1..numberOfFactors(g)]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
and the exponents, ...
+
+
+
+
+
+
+
+[nthExponent(g,i) for i in 1..numberOfFactors(g)]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
and the flags. You can see that all the bases (factors) are prime.
+
+
+
+
+
+
+
+[nthFlag(g,i) for i in 1..numberOfFactors(g)]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Union("nil","sqfr","irred","prime")
+
+
+
+
+
A useful operation for pulling apart a factored object into a list
+of records of the components is factorListfactorListFactored.
+
The mapmapFactored operation is used to iterate across
+the unit and bases of a factored object. See
+FactoredFunctionsTwoXmpPage for a discussion of
+mapmapFactored.
+
+
+
+
The following four operations take a base and an exponent and create a
+factored object. They differ in handling the flag component.
+
+
+
+
+
+
+
+nilFactor(24,2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Integer
+
+
+
+
+
This factor has no associated information.
+
+
+
+
+
+
+
+nthFlag(%,1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union("nil",...)
+
+
+
+
+
This factor is asserted to be square-free.
+
+
+
+
+
+
+
+sqfrFactor(30,2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Integer
+
+
+
+
+
This factor is asserted to be irreducible.
+
+
+
+
+
+
+
+irreducibleFactor(13,10)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Integer
+
+
+
+
+
This factor is asserted to be prime.
+
+
+
+
+
+
+
+primeFactor(11,5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Integer
+
+
+
+
+
A partial inverse to factorListfactorListFactored is
+makeFRmakeFRFactored.
+
+
+
+
+
+
+
+h := factor(-720)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Integer
+
+
+
+
+
The first argument is the unit and the second is a list of records as
+returned by factorListfactorListFactored.
+
+
+
+
+
+
+
+h - makeFR(unit(h),factorList(h))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
9.22.5 Factored Objects with Variables
+
+
+
+
Some of the operations available for polynomials are also available
+for factored polynomials.
+
The FactoredFunctions2 package implements one operation,
+mapmapFactoredFunctions2, for applying an operation to every
+base in a factored object and to the unit.
+
+
+
+
+
+
+
+double(x) == x + x
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+f := factor(720)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Integer
+
+
+
+
+
Actually, the mapmapFactoredFunctions2 operation used
+in this example comes from Factored itself, since double
+takes an integer argument and returns an integer result.
+
+
+
+
+
+
+
+map(double,f)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Integer
+
+
+
+
+
If we want to use an operation that returns an object that has a type
+different from the operation's argument,
+the mapmapFactoredFunctions2 in Factored
+cannot be used and we use the one in FactoredFunctions2.
+
+
+
+
+
+
+
+makePoly(b) == x + b
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
In fact, the ``2'' in the name of the package means that we might
+be using factored objects of two different types.
+
+
+
+
+
+
+
+g := map(makePoly,f)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Polynomial Integer
+
+
+
+
+
It is important to note that both versions of
+mapmapFactoredFunctions2 destroy any information known
+about the bases (the fact that they are prime, for instance).
+
+
+
+
The flags for each base are set to ``nil'' in the object returned
+by mapmapFactoredFunctions2.
+
The File(S) domain provides a basic interface to read and
+write values of type S in files.
+
+
+
+
Before working with a file, it must be made accessible to Axiom with
+the openopenFile operation.
+
+
+
+
+
+
+
+ifile:File List Integer:=open("/tmp/jazz1","output")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: File List Integer
+
+
+
+
+
The openopenFile function arguments are a FileName
+and a String specifying the mode. If a full pathname is not
+specified, the current default directory is assumed. The mode must be
+one of ``input'' or ``output''. If it is not specified,
+``input'' is assumed. Once the file has been opened, you can read or
+write data.
+
+
+
+
The operations readreadFile and writewriteFile are
+provided.
+
+
+
+
+
+
+
+write!(ifile, [-1,2,3])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
+
+
+
+write!(ifile, [10,-10,0,111])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
+
+
+
+write!(ifile, [7])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
You can change from writing to reading (or vice versa) by reopening a file.
+
+
+
+
+
+
+
+reopen!(ifile, "input")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: File List Integer
+
+
+
+
+
+
+
+
+read! ifile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
+
+
+
+read! ifile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
The readreadFile operation can cause an error if one tries
+to read more data than is in the file. To guard against this
+possibility the readIfCanreadIfCanFile operation should be
+used.
+
+
+
+
+
+
+
+readIfCan! ifile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(List Integer,...)
+
+
+
+
+
+
+
+
+readIfCan! ifile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union("failed",...)
+
+
+
+
+
You can find the current mode of the file, and the file's name.
+
+
+
+
+
+
+
+iomode ifile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
+
+
+
+name ifile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FileName
+
+
+
+
+
When you are finished with a file, you should close it.
+
+
+
+
+
+
+
+close! ifile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: File List Integer
+
+
+
+
+
+
+
+
+)system rm /tmp/jazz1
+
+
+
+
+
+
A limitation of the underlying LISP system is that not all values can
+be represented in a file. In particular, delayed values containing
+compiled functions cannot be saved.
+
+The FileName domain provides an interface to the computer's file
+system. Functions are provided to manipulate file names and to test
+properties of files.
+
+The simplest way to use file names in the Axiom interpreter is to rely
+on conversion to and from strings. The syntax of these strings
+depends on the operating system.
+
+
+
+
+
+
+
+fn: FileName
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
On Linux, this is a proper file syntax:
+
+
+
+
+
+
+
+fn := "/tmp/fname.input"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FileName
+
+
+
+
+
Although it is very convenient to be able to use string notation
+for file names in the interpreter, it is desirable to have a portable
+way of creating and manipulating file names from within programs.
+
+
+
+
A measure of portability is obtained by considering a file name
+to consist of three parts: the directory, the name,
+and the extension.
+
+
+
+
+
+
+
+directory fn
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
+
+
+
+name fn
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
+
+
+
+extension fn
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
The meaning of these three parts depends on the operating system.
+For example, on CMS the file ``SPADPROF INPUT M''
+would have directory ``M'', name ``SPADPROF'' and
+extension ``INPUT''.
+
+It is possible to create a filename from its parts.
+
When writing programs, it is helpful to refer to directories via
+variables.
+
+
+
+
+
+
+
+objdir := "/tmp"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
+
+
+
+fn := filename(objdir, "table", "spad")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FileName
+
+
+
+
+
If the directory or the extension is given as an empty string, then
+a default is used. On AIX, the defaults are the current directory
+and no extension.
+
+
+
+
+
+
+
+fn := filename("", "letter", "")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FileName
+
+
+
+
+Three tests provide information about names in the file system.
+
+
+
+
The exists?exists?FileName operation tests whether the named
+file exists.
+
+
+
+
+
+
+
+exists? "/etc/passwd"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
The operation readable?readable?FileName tells whether the named file
+can be read. If the file does not exist, then it cannot be read.
+
+
+
+
+
+
+
+readable? "/etc/passwd"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+readable? "/etc/security/passwd"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+readable? "/ect/passwd"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
Likewise, the operation writable?writable?FileName tells
+whether the named file can be written. If the file does not exist,
+the test is determined by the properties of the directory.
+
+
+
+
+
+
+
+writable? "/etc/passwd"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+writable? "/dev/null"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+writable? "/etc/DoesNotExist"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+writable? "/tmp/DoesNotExist"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+The newnewFileName operation constructs the name of a new
+writable file. The argument sequence is the same as for
+filenamefilenameFileName, except that the name part is
+actually a prefix for a constructed unique name.
+
+
+
+
The resulting file is in the specified directory
+with the given extension, and the same defaults are used.
+
The FlexibleArray domain constructor creates one-dimensional
+arrays of elements of the same type. Flexible arrays are an attempt
+to provide a data type that has the best features of both
+one-dimensional arrays (fast, random access to elements) and lists
+(flexibility). They are implemented by a fixed block of storage.
+When necessary for expansion, a new, larger block of storage is
+allocated and the elements from the old storage area are copied into
+the new block.
+
+
+
+
Flexible arrays have available most of the operations provided by
+OneDimensionalArray (see
+OneDimensionalArrayXmpPage
+and VectorXmpPage ).
+Since flexible arrays are also of category
+ExtensibleLinearAggregate, they have operations concat!,
+delete!, insert!, merge!, remove!,
+removeDuplicates!, and select!. In addition, the operations
+physicalLength and physicalLength! provide user-control
+over expansion and contraction.
+
+
+
+
A convenient way to create a flexible array is to apply the operation
+flexibleArray to a list of values.
+
+
+
+
+
+
+
+flexibleArray [i for i in 1..6]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FlexibleArray PositiveInteger
+
+
+
+
+
Create a flexible array of six zeroes.
+
+
+
+
+
+
+
+f : FARRAY INT := new(6,0)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FlexibleArray Integer
+
+
+
+
+
For set the -th element to . Display f.
+
+
+
+
+
+
+
+for i in 1..6 repeat f.i := i; f
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FlexibleArray Integer
+
+
+
+
+
Initially, the physical length is the same as the number of elements.
+
+
+
+
+
+
+
+physicalLength f
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Add an element to the end of f.
+
+
+
+
+
+
+
+concat!(f,11)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FlexibleArray Integer
+
+
+
+
+
See that its physical length has grown.
+
+
+
+
+
+
+
+physicalLength f
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Make f grow to have room for 15 elements.
+
+
+
+
+
+
+
+physicalLength!(f,15)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FlexibleArray Integer
+
+
+
+
+
Concatenate the elements of f to itself. The physical length
+allows room for three more values at the end.
+
+
+
+
+
+
+
+concat!(f,f)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FlexibleArray Integer
+
+
+
+
+
Use insert! to add an element to the front of a flexible array.
+
+
+
+
+
+
+
+insert!(22,f,1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FlexibleArray Integer
+
+
+
+
+
Create a second flexible array from f consisting of the elements
+from index 10 forward.
+
+
+
+
+
+
+
+g := f(10..)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FlexibleArray Integer
+
+
+
+
+
Insert this array at the front of f.
+
+
+
+
+
+
+
+insert!(g,f,1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FlexibleArray Integer
+
+
+
+
+
Merge the flexible array f into g after sorting each in place.
+
+
+
+
+
+
+
+merge!(sort! f, sort! g)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FlexibleArray Integer
+
+
+
+
+
Remove duplicates in place.
+
+
+
+
+
+
+
+removeDuplicates! f
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FlexibleArray Integer
+
+
+
+
+
Remove all odd integers.
+
+
+
+
+
+
+
+select!(i +-> even? i,f)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: FlexibleArray Integer
+
+
+
+
+
All these operations have shrunk the physical length of f.
+
+
+
+
+
+
+
+physicalLength f
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
To force Axiom not to shrink flexible arrays call the shrinkable
+operation with the argument false. You must package call this
+operation. The previous value is returned.
+
Axiom provides two kinds of floating point numbers. The domain
+Float (abbreviation FLOAT) implements a model of arbitrary
+precision floating point numbers. The domain DoubleFloat
+(abbreviation DFLOAT) is intended to make available hardware
+floating point arithmetic in Axiom. The actual model of floating
+point that DoubleFloat provides is system-dependent. For
+example, on the IBM system 370 Axiom uses IBM double precision which
+has fourteen hexadecimal digits of precision or roughly sixteen
+decimal digits. Arbitrary precision floats allow the user to specify
+the precision at which arithmetic operations are computed. Although
+this is an attractive facility, it comes at a cost.
+Arbitrary-precision floating-point arithmetic typically takes twenty
+to two hundred times more time than hardware floating point.
+
Scientific notation is supported for input and output of floating
+point numbers. A floating point number is written as a string of
+digits containing a decimal point optionally followed by the letter
+``E'', and then the exponent.
+
+
+
+
We begin by doing some calculations using arbitrary precision floats.
+The default precision is twenty decimal digits.
+
+
+
+
+
+
+
+1.234
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
A decimal base for the exponent is assumed, so the number
+1.234E2 denotes .
+
+
+
+
+
+
+
+1.234E2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
The normal arithmetic operations are available for floating point numbers.
+
+
+
+
+
+
+
+sqrt(1.2 + 2.3 / 3.4 ** 4.5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+
+
+
+
+
+
9.27.2 Conversion Functions
+
+
+
+
You can use conversion (ugTypesConvertPage in Section
+ugTypesConvertNumber ) to
+go back and forth between Integer, Fraction Integer and
+Float, as appropriate.
+
+
+
+
+
+
+
+i := 3 :: Float
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+
+i :: Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Integer
+
+
+
+
+
+
+
+
+i :: Fraction Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
Since you are explicitly asking for a conversion, you must take
+responsibility for any loss of exactness.
+
+
+
+
+
+
+
+r := 3/7 :: Float
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+
+r :: Fraction Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
This conversion cannot be performed: use truncatetruncateFloat
+or roundroundFloat if that is what you intend.
+
+
+
+
+
+
+
+r :: Integer
+
+
+
+
+
+
+
+ Cannot convert from type Float to Integer for value
+ 0.4285714285 7142857143
+
+
+
+
+
The operations truncatetruncateFloat and roundroundFloat
+truncate ...
+
+
+
+
+
+
+
+truncate 3.6
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
and round to the nearest integral Float respectively.
+
+
+
+
+
+
+
+round 3.6
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+
+truncate(-3.6)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+
+round(-3.6)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
The operation fractionPartfractionPartFloat computes the
+fractional part of x, that is, x - truncate x.
+
+
+
+
+
+
+
+fractionPart 3.6
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
The operation digitsdigitsFloat allows the user to set the
+precision. It returns the previous value it was using.
+
+
+
+
+
+
+
+digits 40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+sqrt 0.2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+
+pi()$Float
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
The precision is only limited by the computer memory available.
+Calculations at 500 or more digits of precision are not difficult.
+
+
+
+
+
+
+
+digits 500
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+pi()$Float
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
Reset digitsdigitsFloat to its default value.
+
+
+
+
+
+
+
+digits 20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Numbers of type Float are represented as a record of two
+integers, namely, the mantissa and the exponent where the base of the
+exponent is binary. That is, the floating point number (m,e)
+represents the number . A consequence of using a binary
+base is that decimal numbers can not, in general, be represented
+exactly.
+
+
+
+
+
+
+
+
+
+
+
+
9.27.3 Output Functions
+
+
+
+
A number of operations exist for specifying how numbers of type
+Float are to be displayed. By default, spaces are inserted every ten
+digits in the output for readability.Note that you cannot
+include spaces in the input form of a floating point number, though
+you can use underscores.
+
+
+
+
Output spacing can be modified with the outputSpacingoutputSpacingFloat
+operation. This inserts no spaces and then displays the value of x.
+
+
+
+
+
+
+
+outputSpacing 0; x := sqrt 0.2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
Issue this to have the spaces inserted every 5 digits.
+
+
+
+
+
+
+
+outputSpacing 5; x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
By default, the system displays floats in either fixed format
+or scientific format, depending on the magnitude of the number.
+
+
+
+
+
+
+
+y := x/10**10
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
A particular format may be requested with the operations
+outputFloatingoutputFloatingFloat and outputFixedoutputFixedFloat.
+
+
+
+
+
+
+
+outputFloating(); x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+
+outputFixed(); y
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
Additionally, you can ask for n digits to be displayed after the
+decimal point.
+
+
+
+
+
+
+
+outputFloating 2; y
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
+
+
+
+outputFixed 2; x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
This resets the output printing to the default behavior.
+
+
+
+
+
+
+
+outputGeneral()
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+
+
+
+
+
9.27.4 An Example: Determinant of a Hilbert Matrix
+
+
+
+
Consider the problem of computing the determinant of a 10 by
+10 Hilbert matrix. The -th entry of a Hilbert
+matrix is given by 1/(i+j+1).
+
+
+
+
First do the computation using rational numbers to obtain the
+exact result.
+
+
+
+
+
+
+
+a: Matrix Fraction Integer := matrix [ [1/(i+j+1) for j in 0..9] for i in 0..9]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Fraction Integer
+
+
+
+
+
This version of determinantdeterminantMatrix uses Gaussian elimination.
+
+
+
+
+
+
+
+d:= determinant a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
+
+
+
+d :: Float
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Float
+
+
+
+
+
Now use hardware floats. Note that a semicolon (;) is used to prevent
+the display of the matrix.
+
+
+
+
+
+
+
+b: Matrix DoubleFloat := matrix [ [1/(i+j+1$DoubleFloat) for j in 0..9] for i in 0..9];
+
+
+
+
+
+
+
+Type: Matrix DoubleFloat
+
+
+
+
+
The result given by hardware floats is correct only to four
+significant digits of precision. In the jargon of numerical analysis,
+the Hilbert matrix is said to be ``ill-conditioned.''
+
+
+
+
+
+
+
+determinant b
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: DoubleFloat
+
+
+
+
+
Now repeat the computation at a higher precision using Float.
+
+
+
+
+
+
+
+digits 40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+c: Matrix Float := matrix [ [1/(i+j+1$Float) for j in 0..9] for i in 0..9];
+
+
The Fraction domain implements quotients. The elements must
+belong to a domain of category IntegralDomain: multiplication
+must be commutative and the product of two non-zero elements must not
+be zero. This allows you to make fractions of most things you would
+think of, but don't expect to create a fraction of two matrices! The
+abbreviation for Fraction is FRAC.
+
+
+
+
Use / to create a fraction.
+
+
+
+
+
+
+
+a := 11/12
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
+
+
+
+b := 23/24
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
The standard arithmetic operations are available.
+
+
+
+
+
+
+
+3 - a*b**2 + a + b/a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
Extract the numerator and denominator by using
+numernumerFraction and denomdenomFraction,
+respectively.
+
+
+
+
+
+
+
+numer(a)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+denom(b)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Operations like maxmaxFraction,
+minminFraction, negative?negative?Fraction,
+positive?positive?Fraction and zero?zero?Fraction
+are all available if they are provided for the numerators and
+denominators.
+See IntegerXmpPage for examples.
+
+
+
+
Don't expect a useful answer from factorfactorFraction,
+gcdgcdFraction or lcmlcmFraction if you apply
+them to fractions.
+
+
+
+
+
+
+
+r := (x**2 + 2*x + 1)/(x**2 - 2*x + 1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Polynomial Integer
+
+
+
+
+
Since all non-zero fractions are invertible, these operations have trivial
+definitions.
+
+
+
+
+
+
+
+factor(r)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Fraction Polynomial Integer
+
+
+
+
+
Use mapmapFraction to apply factorfactorFraction to
+the numerator and denominator, which is probably what you mean.
+
+
+
+
+
+
+
+map(factor,r)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Factored Polynomial Integer
+
+
+
+
+
Other forms of fractions are available. Use continuedFraction
+to create a continued fraction.
+
For more information, see the paper: Bronstein, M and Salvy, B.
+``Full Partial Fraction Decomposition of Rational Functions,''
+Proceedings of ISSAC'93, Kiev, ACM Press. All see
+PartialFractionXmpPage
+for standard partial fraction decompositions.
+
A basic operator is an object that can be symbolically applied to a
+list of arguments from a set, the result being a kernel over that set
+or an expression. In addition to this section, please see
+ExpressionXmpPage and
+KernelXmpPage for additional
+information and examples.
+
+
+
+
You create an object of type BasicOperator by using the
+operatoroperatorBasicOperator operation. This first form of
+this operation has one argument and it must be a symbol. The symbol
+should be quoted in case the name has been used as an identifier to
+which a value has been assigned.
+
+
+
+
A frequent application of BasicOperator is the creation of an
+operator to represent the unknown function when solving a differential
+equation.
+
+
+
+
Let y be the unknown function in terms of x.
+
+
+
+
+
+
+
+y := operator 'y
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: BasicOperator
+
+
+
+
+
This is how you enter the equation y'' + y' + y = 0.
+
+
+
+
+
+
+
+deq := D(y x, x, 2) + D(y x, x) + y x = 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Equation Expression Integer
+
+
+
+
+
To solve the above equation, enter this.
+
+
+
+
+
+
+
+solve(deq, y, x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(Record(particular: Expression Integer,
+basis: List Expression Integer),...)
+
+
+
+
+
+
+
+
+
Use the single argument form of operatoroperatorBasicOperator
+(as above) when you intend to use the operator to create functional
+expressions with an arbitrary number of arguments
+
+
+
+
Nary means an arbitrary number of arguments can be used
+in the functional expressions.
+
+
+
+
+
+
+
+nary? y
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+unary? y
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
Use the two-argument form when you want to restrict the number of
+arguments in the functional expressions created with the operator.
+
+
+
+
This operator can only be used to create functional expressions
+with one argument.
+
+
+
+
+
+
+
+opOne := operator('opOne, 1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: BasicOperator
+
+
+
+
+
+
+
+
+nary? opOne
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+unary? opOne
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
Use arityarityBasicOperator to learn the number of arguments
+that can be used. It returns "false" if the operator is nary.
+
+
+
+
+
+
+
+arity opOne
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(NonNegativeInteger,...)
+
+
+
+
+
Use namenameBasicOperator to learn the name of an operator.
+
+
+
+
+
+
+
+name opOne
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Symbol
+
+
+
+
+
Use is?is?BasicOperator to learn if an operator has a
+particular name.
+
+
+
+
+
+
+
+is?(opOne, 'z2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
You can also use a string as the name to be tested against.
+
+
+
+
+
+
+
+is?(opOne, "opOne")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
You can attached named properties to an operator. These are rarely
+used at the top-level of the Axiom interactive environment but are
+used with Axiom library source code.
+
+
+
+
By default, an operator has no properties.
+
+
+
+
+
+
+
+properties y
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: AssociationList(String,None)
+
+
+
+
+
The interface for setting and getting properties is somewhat awkward
+because the property values are stored as values of type None.
+
+
+
+
Attach a property by using setPropertysetPropertyBasicOperator.
+
Sometimes when working with tables there is a natural value to use as
+the entry in all but a few cases. The GeneralSparseTable
+constructor can be used to provide any table type with a default value
+for entries. See TableXmpPage
+for general information about tables.
+
+
+
+
Suppose we launched a fund-raising campaign to raise fifty thousand dollars.
+To record the contributions, we want a table with strings as keys
+(for the names) and integer entries (for the amount).
+In a data base of cash contributions, unless someone
+has been explicitly entered, it is reasonable to assume they have made
+a zero dollar contribution.
+
+
+
+
This creates a keyed access file with default entry 0.
+
Solving systems of polynomial equations with the Gröbner basis
+algorithm can often be very time consuming because, in general, the
+algorithm has exponential run-time. These systems, which often come
+from concrete applications, frequently have symmetries which are not
+taken advantage of by the algorithm. However, it often happens in
+this case that the polynomials which occur during the Gröbner
+calculations are reducible. Since Axiom has an excellent polynomial
+factorization algorithm, it is very natural to combine the Gröbner
+and factorization algorithms.
+
+
+
+
GroebnerFactorizationPackage exports the
+groebnerFactorizegroebnerFactorizeGroebnerFactorizationPackage
+operation which implements a modified Gröbner basis algorithm. In
+this algorithm, each polynomial that is to be put into the partial
+list of the basis is first factored. The remaining calculation is
+split into as many parts as there are irreducible factors. Call these
+factors In the branches corresponding to the factor can be divided out, and so on. This
+package also contains operations that allow you to specify the
+polynomials that are not zero on the common roots of the final
+Gröbner basis.
+
+
+
+
Here is an example from chemistry. In a theoretical model of
+cyclohexane, , the six carbon atoms each sit in
+the center of gravity of a tetrahedron that has two hydrogen atoms and
+two carbon atoms at its corners. We first normalize and set the
+length of each edge to 1. Hence, the distances of one fixed carbon
+atom to each of its immediate neighbours is 1. We will denote the
+distances to the other three carbon atoms by , and .
+
+
+
+
A. Dress developed a theory to decide whether a set of points
+and distances between them can be realized in an -dimensional space.
+Here, of course, we have .
+
+Type: List List
+DistributedMultivariatePolynomial([x,y,z],Fraction Integer)
+
+
+
+
+
The union of the solutions of this list is the solution of our
+original problem. If we impose positivity conditions, we get two
+relevant ideals. One ideal is zero-dimensional, namely ,
+and this determines the ``boat'' form of cyclohexane. The
+other ideal is one-dimensional, which means that we have a solution
+space given by one parameter. This gives the ``chair'' form of
+cyclohexane. The parameter describes the angle of the ``back of the
+chair.''
+
+
+
+
groebnerFactorizegroebnerFactorizeGroebnerFactorizationPackage has an
+optional Boolean-valued second argument. When it is true
+partial results are displayed, since it may happen that the
+calculation does not terminate in a reasonable time. See the source
+code for GroebnerFactorizationPackage in groebf.input
+for more details about the algorithms used.
+
The domain Heap(S) implements a priority queue of objects of
+type S such that the operation extract! removes and
+returns the maximum element. The implementation represents heaps as
+flexible arrays (see
+FlexibleArrayXmpPage ).
+The representation and algorithms give complexity of
+for insertion and extractions, and for construction.
+
+
+
+
Create a heap of six elements.
+
+
+
+
+
+
+
+h := heap [-4,9,11,2,7,-7]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Heap Integer
+
+
+
+
+
Use insert! to add an element.
+
+
+
+
+
+
+
+insert!(3,h)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Heap Integer
+
+
+
+
+
The operation extract! removes and returns the maximum element.
+
+
+
+
+
+
+
+extract! h
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The internal structure of h has been appropriately adjusted.
+
+
+
+
+
+
+
+h
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Heap Integer
+
+
+
+
+
Now extract! elements repeatedly until none are left, collecting
+the elements in a list.
+
+
+
+
+
+
+
+[extract!(h) while not empty?(h)]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
Another way to produce the same result is by defining a heapsort
+function.
+
All rationals have repeating hexadecimal expansions. The operation
+hexhexHexadecimalExpansion returns these expansions of
+type HexadecimalExpansion. Operations to access the individual
+numerals of a hexadecimal expansion can be obtained by converting the
+value to RadixExpansion(16). More examples of expansions are
+available in the
+DecimalExpansionXmpPage ,
+BinaryExpansionXmpPage , and
+RadixExpansionXmpPage .
+
+
+
+
This is a hexadecimal expansion of a rational number.
+
+
+
+
+
+
+
+r := hex(22/7)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: HexadecimalExpansion
+
+
+
+
+
Arithmetic is exact.
+
+
+
+
+
+
+
+r + hex(6/7)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: HexadecimalExpansion
+
+
+
+
+
The period of the expansion can be short or long ...
+
The size of an integer in Axiom is only limited by the amount of
+computer storage you have available. The usual arithmetic operations
+are available.
+
+
+
+
+
+
+
+2**(5678 - 4856 + 2 * 17)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
There are a number of ways of working with the sign of an integer.
+Let's use this x as an example.
+
+
+
+
+
+
+
+x := -101
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Integer
+
+
+
+
+
First of all, there is the absolute value function.
+
+
+
+
+
+
+
+abs(x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The signsignInteger operation returns -1 if its argument
+is negative, 0 if zero and 1 if positive.
+
+
+
+
+
+
+
+sign(x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Integer
+
+
+
+
+
You can determine if an integer is negative in several other ways.
+
+
+
+
+
+
+
+x < 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+x <= -1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+negative?(x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
Similarly, you can find out if it is positive.
+
+
+
+
+
+
+
+x > 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+x >= 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+positive?(x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
This is the recommended way of determining whether an integer is zero.
+
+
+
+
+
+
+
+zero?(x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Use the zero?zero?Integer operation whenever you are
+testing any mathematical object for equality with zero. This is
+usually more efficient that using = (think of matrices: it is
+easier to tell if a matrix is zero by just checking term by term than
+constructing another ``zero'' matrix and comparing the two matrices
+term by term) and also avoids the problem that = is usually used
+for creating equations.
+
+
+
+
+
+
+
+
+
+
This is the recommended way of determining whether an integer is equal
+to one.
+
+
+
+
+
+
+
+one?(x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
This syntax is used to test equality using =.
+It says that you want a Boolean (true or false)
+answer rather than an equation.
+
+
+
+
+
+
+
+(x = -101)@Boolean
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
The operations odd?odd?Integer and
+even?even?Integer determine whether an integer is odd or
+even, respectively. They each return a Boolean object.
+
+
+
+
+
+
+
+odd?(x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+even?(x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
The operation gcdgcdInteger computes the greatest common
+divisor of two integers.
+
+
+
+
+
+
+
+gcd(56788,43688)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The operation lcmlcmInteger computes their least common multiple.
+
+
+
+
+
+
+
+lcm(56788,43688)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
To determine the maximum of two integers, use maxmaxInteger.
+
+
+
+
+
+
+
+max(678,567)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
To determine the minimum, use minminInteger.
+
+
+
+
+
+
+
+min(678,567)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The reduce operation is used to extend binary operations to more
+than two arguments. For example, you can use reduce to find the
+maximum integer in a list or compute the least common multiple of all
+integers in the list.
+
+
+
+
+
+
+
+reduce(max,[2,45,-89,78,100,-45])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+reduce(min,[2,45,-89,78,100,-45])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Integer
+
+
+
+
+
+
+
+
+reduce(gcd,[2,45,-89,78,100,-45])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+reduce(lcm,[2,45,-89,78,100,-45])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The infix operator ``/'' is not used to compute the quotient of
+integers. Rather, it is used to create rational numbers as described
+in FractionXmpPage .
+
+
+
+
+
+
+
+13 / 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
The infix operation quoquoInteger computes the integer
+quotient.
+
+
+
+
+
+
+
+13 quo 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The infix operation remremInteger computes the integer
+remainder.
+
+
+
+
+
+
+
+13 rem 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
One integer is evenly divisible by another if the remainder is zero.
+The operation exquoexquoInteger can also be used. See
+ugTypesUnionsPage in Section
+ugTypesUnionsNumber for an
+example.
+
+
+
+
+
+
+
+zero?(167604736446952 rem 2003644)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
The operation dividedivideInteger returns a record of the
+quotient and remainder and thus is more efficient when both are needed.
+
Records are discussed in detail in Section
+ugTypesRecords .
+
+
+
+
+
+
+
+d.remainder
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+
+
+
+
+
9.34.2 Primes and Factorization
+
+
+
+
Use the operation factorfactorInteger to factor integers.
+It returns an object of type Factored Integer.
+See FactoredXmpPage
+for a discussion of the manipulation of factored objects.
+
+
+
+
+
+
+
+factor 102400
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Integer
+
+
+
+
+
The operation prime?prime?Integer returns true or
+false depending on whether its argument is a prime.
+
+
+
+
+
+
+
+prime? 7
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+prime? 8
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
The operation nextPrimenextPrimeIntegerPrimesPackage returns the
+least prime number greater than its argument.
+
+
+
+
+
+
+
+nextPrime 100
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The operation prevPrimeprevPrimeIntegerPrimesPackage returns
+the greatest prime number less than its argument.
+
+
+
+
+
+
+
+prevPrime 100
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
To compute all primes between two integers (inclusively), use the
+operation primesprimesIntegerPrimesPackage.
+
+
+
+
+
+
+
+primes(100,175)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
You might sometimes want to see the factorization of an integer
+when it is considered a Gaussian integer.
+See ComplexXmpPage for more details.
+
The operation fibonaccifibonacciIntegerNumberTheoryFunctions
+computes the Fibonacci numbers. The algorithm has running time
+ for argument n.
+
+
+
+
+
+
+
+[fibonacci(k) for k in 0..]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Integer
+
+
+
+
+
The operation legendrelegendreIntegerNumberTheoryFunctions
+computes the Legendre symbol for its two integer arguments where the
+second one is prime. If you know the second argument to be prime, use
+jacobijacobiIntegerNumberTheoryFunctions instead where no
+check is made.
+
+
+
+
+
+
+
+[legendre(i,11) for i in 0..10]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
The operation jacobijacobiIntegerNumberTheoryFunctions
+computes the Jacobi symbol for its two integer arguments. By
+convention, 0 is returned if the greatest common divisor of the
+numerator and denominator is not 1.
+
+
+
+
+
+
+
+[jacobi(i,15) for i in 0..9]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
The operation eulerPhieulerPhiIntegerNumberTheoryFunctions
+computes the values of Euler's -function where equals
+the number of positive integers less than or equal to n that are
+relatively prime to the positive integer n.
+
+
+
+
+
+
+
+[eulerPhi i for i in 1..]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Integer
+
+
+
+
+
The operation moebiusMumoebiusMuIntegerNumberTheoryFunctions
+computes the Möbius function.
+
+
+
+
+
+
+
+[moebiusMu i for i in 1..]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Integer
+
+
+
+
+
Although they have somewhat limited utility, Axiom provides Roman numerals.
+
The elements of a module M over a ring R
+are said to be linearly dependent over R if there exist
+ in R, not all , such that . If such 's exist, they form what is called a
+linear dependence relation over R for the 's.
+
+
+
+
The package IntegerLinearDependence provides functions
+for testing whether some elements of a module over the integers are
+linearly dependent over the integers, and to find the linear
+dependence relations, if any.
+
+
+
+
Consider the domain of two by two square matrices with integer entries.
+
This means that the following linear combination should be 0.
+
+
+
+
+
+
+
+c.1 * m1 + c.2 * m2 + c.3 * m3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SquareMatrix(2,Integer)
+
+
+
+
+
When a given set of elements are linearly dependent over R, this
+also means that at least one of them can be rewritten as a linear
+combination of the others with coefficients in the quotient field of
+R.
+
+
+
+
To express a given element in terms of other elements, use the operation
+solveLinearlyOverQsolveLinearlyOverQIntegerLinearDependence.
+
The IntegerNumberTheoryFunctions package contains a variety of
+operations of interest to number theorists. Many of these operations
+deal with divisibility properties of integers. (Recall that an
+integer a divides an integer b if there is an integer
+c such that b = a * c.)
+
+
+
+
The operation divisorsdivisorsIntegerNumberTheoryFunctions
+returns a list of the divisors of an integer.
+
+
+
+
+
+
+
+div144 := divisors(144)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
You can now compute the number of divisors of 144 and the sum of
+the divisors of 144 by counting and summing the elements of the
+list we just created.
+
+
+
+
+
+
+
+ #(div144)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+reduce(+,div144)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Of course, you can compute the number of divisors of an integer
+n, usually denoted d(n), and the sum of the divisors of an
+integer n, usually denoted (n), without ever
+listing the divisors of n.
+
+
+
+
In Axiom, you can simply call the operations
+numberOfDivisorsnumberOfDivisorsIntegerNumberTheoryFunctions and
+sumOfDivisorssumOfDivisorsIntegerNumberTheoryFunctions.
+
+
+
+
+
+
+
+numberOfDivisors(144)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+sumOfDivisors(144)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The key is that d(n) and (n) are ``multiplicative
+functions.'' This means that when n and m are relatively
+prime, that is, when n and m have no prime factor in
+common, then d(nm) = d(n) d(m) and (nm) =
+ (n) (m). Note that these functions are trivial to
+compute when n is a prime power and are computed for general
+n from the prime factorization of n. Other examples of
+multiplicative functions are (n), the sum of the
+ -th powers of the divisors of n and , the
+number of integers between 1 and n which are prime to n.
+The corresponding Axiom operations are called
+sumOfKthPowerDivisorssumOfKthPowerDivisorsIntegerNumberTheoryFunctions and
+eulerPhieulerPhiIntegerNumberTheoryFunctions.
+
+
+
+
An interesting function is (n), the Möbius
+function, defined as follows: (1) = 1, (n) = 0,
+when n is divisible by a square, and , when
+n is the product of k distinct primes. The corresponding
+Axiom operation is moebiusMumoebiusMuIntegerNumberTheoryFunctions.
+This function occurs in the following theorem:
+
+
+
+
+
+
Theorem (Möbius Inversion Formula): Let f(n)
+be a function on the positive integers and let F(n) be defined
+by sum of f(n) over
+d | n where the sum is taken over the positive divisors of
+n. Then the values of f(n) can be recovered from the values of
+F(n):
+
+where again the sum is taken over the positive divisors of n.
+
+
+
+
When f(n) = 1, then F(n) = d(n). Thus, if you sum over the positive divisors d of n, you
+should always get 1.
+
+
+
+
+
+
+
+f1(n) == reduce(+,[moebiusMu(d) * numberOfDivisors(quo(n,d)) for d in divisors(n)])
+
+
+
+
+
+
+
+Void
+
+
+
+
+
+
+
+
+f1(200)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+f1(846)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Similarly, when f(n) = n, then F(n) = (n). Thus,
+if you sum (d) (n/d) over the positive
+divisors d of n, you should always get n.
+
+
+
+
+
+
+
+f2(n) == reduce(+,[moebiusMu(d) * sumOfDivisors(quo(n,d)) for d in divisors(n)])
+
+
+
+
+
+
+
+Void
+
+
+
+
+
+
+
+
+f2(200)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+f2(846)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The Fibonacci numbers are defined by and
+ for .
+
+
+
+
The operation fibonaccifibonacciIntegerNumberTheoryFunctions
+computes the -th Fibonacci number.
+
+
+
+
+
+
+
+fibonacci(25)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+[fibonacci(n) for n in 1..15]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
Fibonacci numbers can also be expressed as sums of binomial coefficients.
+
+
+
+
+
+
+
+fib(n) == reduce(+,[binomial(n-1-k,k) for k in 0..quo(n-1,2)])
+
+
+
+
+
+
+
+Void
+
+
+
+
+
+
+
+
+fib(25)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+[fib(n) for n in 1..15]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
Quadratic symbols can be computed with the operations
+legendrelegendreIntegerNumberTheoryFunctions and
+jacobijacobiIntegerNumberTheoryFunctions. The Legendre
+symbol is defined for integers and
+ with an odd prime number. By definition,
+ = +1, when is a square ,
+ = -1, when is not a square ,
+and = 0, when is divisible by .
+
+
+
+
You compute via the command legendre(a,p).
+
+
+
+
+
+
+
+legendre(3,5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Integer
+
+
+
+
+
+
+
+
+legendre(23,691)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Integer
+
+
+
+
+
The Jacobi symbol is the usual extension of
+the Legendre symbol, where n is an arbitrary integer. The most
+important property of the Jacobi symbol is the following: if K
+is a quadratic field with discriminant d and quadratic character
+ , then . Thus, you can use the Jacobi symbol
+to compute, say, the class numbers of imaginary quadratic fields from
+a standard class number formula.
+
+
+
+
This function computes the class number of the imaginary quadratic
+field with discriminant d.
+
+
+
+
+
+
+
+h(d) == quo(reduce(+, [jacobi(d,k) for k in 1..quo(-d, 2)]), 2 - jacobi(d,2))
+
+
A kernel is a symbolic function application (such as sin(x+ y))
+or a symbol (such as x). More precisely, a non-symbol
+kernel over a set S is an operator applied to a given list of
+arguments from S. The operator has type BasicOperator
+(see BasicOperatorXmpPage )
+and the kernel object is usually part of an expression object (see
+ExpressionXmpPage ).
+
+
+
+
Kernels are created implicitly for you when you create expressions.
+
+
+
+
+
+
+
+x :: Expression Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
You can directly create a ``symbol'' kernel by using the
+kernelkernelKernel operation.
+
+
+
+
+
+
+
+kernel x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Kernel Expression Integer
+
+
+
+
+
This expression has two different kernels.
+
+
+
+
+
+
+
+sin(x) + cos(x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
The operator kernelskernelsExpression returns a list of the
+kernels in an object of type Expression.
+
+
+
+
+
+
+
+kernels %
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Kernel Expression Integer
+
+
+
+
+
This expression also has two different kernels.
+
+
+
+
+
+
+
+sin(x)**2 + sin(x) + cos(x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
The sin(x) kernel is used twice.
+
+
+
+
+
+
+
+kernels %
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Kernel Expression Integer
+
+
+
+
+
An expression need not contain any kernels.
+
+
+
+
+
+
+
+kernels(1 :: Expression Integer)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Kernel Expression Integer
+
+
+
+
+
If one or more kernels are present, one of them is
+designated the main kernel.
+
+
+
+
+
+
+
+mainKernel(cos(x) + tan(x))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(Kernel Expression Integer,...)
+
+
+
+
+
Kernels can be nested. Use heightheightKernel to determine
+the nesting depth.
+
+
+
+
+
+
+
+height kernel x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
This has height 2 because the x has height 1 and then we apply
+an operator to that.
+
+
+
+
+
+
+
+height mainKernel(sin x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+height mainKernel(sin cos x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+height mainKernel(sin cos (tan x + sin x))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Use the operatoroperatorKernel operation to extract the
+operator component of the kernel. The operator has type BasicOperator.
+
+
+
+
+
+
+
+operator mainKernel(sin cos (tan x + sin x))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: BasicOperator
+
+
+
+
+
Use the namenameKernel operation to extract the name of
+the operator component of the kernel. The name has type Symbol.
+This is really just a shortcut for a two-step process of extracting
+the operator and then calling namenameBasicOperator on
+the operator.
+
+
+
+
+
+
+
+name mainKernel(sin cos (tan x + sin x))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Symbol
+
+
+
+
+
Axiom knows about functions such as sin, cos and so on and
+can make kernels and then expressions using them. To create a kernel
+and expression using an arbitrary operator, use
+operatoroperatorBasicOperator.
+
+
+
+
Now f can be used to create symbolic function applications.
+
+
+
+
+
+
+
+f := operator 'f
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: BasicOperator
+
+
+
+
+
+
+
+
+e := f(x, y, 10)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
Use the is?is?Kernel operation to learn if the
+operator component of a kernel is equal to a given operator.
+
+
+
+
+
+
+
+is?(e, f)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
You can also use a symbol or a string as the second argument to
+is?is?Kernel.
+
+
+
+
+
+
+
+is?(e, 'f)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
Use the argumentargumentKernel operation to get a list containing
+the argument component of a kernel.
+
+
+
+
+
+
+
+argument mainKernel e
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Expression Integer
+
+
+
+
+
Conceptually, an object of type Expression can be thought of a
+quotient of multivariate polynomials, where the ``variables'' are
+kernels. The arguments of the kernels are again expressions and so
+the structure recurses. See ExpressionXmpPage for examples of
+using kernels to take apart expression objects.
+
The domain KeyedAccessFile(S) provides files which can be used
+as associative tables. Data values are stored in these files and can
+be retrieved according to their keys. The keys must be strings so
+this type behaves very much like the StringTable(S) domain. The
+difference is that keyed access files reside in secondary storage
+while string tables are kept in memory. For more information on
+table-oriented operations, see the description of Table.
+
+
+
+
Before a keyed access file can be used, it must first be opened.
+A new file can be created by opening it for output.
+
Just as for vectors, tables or lists, values are saved in a keyed access file
+by setting elements.
+
+
+
+
+
+
+
+ey."Char" := 1986
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+ey."Caviness" := 1985
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+ey."Fitch" := 1984
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Values are retrieved using application, in any of its syntactic forms.
+
+
+
+
+
+
+
+ey."Char"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+ey("Char")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+ey "Char"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Attempting to retrieve a non-existent element in this way causes an error.
+If it is not known whether a key exists, you should use the
+searchsearchKeyedAccessFile operation.
+
+
+
+
+
+
+
+search("Char", ey)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(Integer,...)
+
+
+
+
+
+
+
+
+search("Smith", ey)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union("failed",...)
+
+
+
+
+
When an entry is no longer needed, it can be removed from the file.
+
+
+
+
+
+
+
+remove!("Char", ey)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(Integer,...)
+
+
+
+
+
The keyskeysKeyedAccessFile operation returns a list of all the
+keys for a given file.
+
+
+
+
+
+
+
+keys ey
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List String
+
+
+
+
+
The # #KeyedAccessFile operation gives the
+number of entries.
+
+
+
+
+
+
+
+ #ey
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The table view of keyed access files provides safe operations. That
+is, if the Axiom program is terminated between file operations, the
+file is left in a consistent, current state. This means, however,
+that the operations are somewhat costly. For example, after each
+update the file is closed.
+
+
+
+
Here we add several more items to the file, then check its contents.
+
+
+
+
+
+
+
+KE := Record(key: String, entry: Integer)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
+
+
+
+reopen!(ey, "output")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: KeyedAccessFile Integer
+
+
+
+
+
If many items are to be added to a file at the same time, then
+it is more efficient to use the writewriteKeyedAccessFile operation.
+
+
+
+
+
+
+
+write!(ey, ["van Hulzen", 1983]$KE)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Record(key: String,entry: Integer)
+
+
+
+
+
+
+
+
+write!(ey, ["Calmet", 1982]$KE)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Record(key: String,entry: Integer)
+
+
+
+
+
+
+
+
+write!(ey, ["Wang", 1981]$KE)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Record(key: String,entry: Integer)
+
+
+
+
+
+
+
+
+close! ey
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: KeyedAccessFile Integer
+
+
+
+
+
The readreadKeyedAccessFile operation is also available
+from the file view, but it returns elements in a random order. It is
+generally clearer and more efficient to use the
+keyskeysKeyedAccessFile operation and to extract elements
+by key.
+
The LexTriangularPackage package constructor provides an
+implementation of the lexTriangular algorithm (D. Lazard
+``Solving Zero-dimensional Algebraic Systems'', J. of Symbol. Comput.,
+1992). This algorithm decomposes a zero-dimensional variety into
+zero-sets of regular triangular sets. Thus the input system must have
+a finite number of complex solutions. Moreover, this system needs to
+be a lexicographical Groebner basis.
+
+
+
+
This package takes two arguments: the coefficient-ring R of the
+polynomials, which must be a GcdDomain and their set of
+variables given by ls a List Symbol. The type of the
+input polynomials must be NewSparseMultivariatePolynomial(R,V)
+where V is OrderedVariableList(ls). The abbreviation for
+LexTriangularPackage is LEXTRIPK. The main operations are
+lexTriangularlexTriangularLexTriangularPackage and
+squareFreeLexTriangularsquareFreeLexTriangularLexTriangularPackage. The
+later provide decompositions by means of square-free regular
+triangular sets, built with the SREGSET constructor, whereas the
+former uses the REGSET constructor. Note that these
+constructors also implement another algorithm for solving algebraic
+systems by means of regular triangular sets; in that case no
+computations of Groebner bases are needed and the input system may
+have any dimension (i.e. it may have an infinite number of solutions).
+
+
+
+
The implementation of the lexTriangular algorithm provided in
+the LexTriangularPackage constructor differs from that reported
+in ``Computations of gcd over algebraic towers of simple extensions'' by
+M. Moreno Maza and R. Rioboo (in proceedings of AAECC11, Paris, 1995).
+Indeed, the squareFreeLexTriangularsquareFreeLexTriangularLexTriangularPackage
+operation removes all multiplicities of the solutions (i.e. the computed
+solutions are pairwise different) and the
+lexTriangularlexTriangularLexTriangularPackage operation may keep
+some multiplicities; this later operation runs generally faster than
+the former.
+
+
+
+
The interest of the lexTriangular algorithm is due to the
+following experimental remark. For some examples, a triangular
+decomposition of a zero-dimensional variety can be computed faster via
+a lexicographical Groebner basis computation than by using a direct
+method (like that of SREGSET and REGSET). This happens
+typically when the total degree of the system relies essentially on
+its smallest variable (like in the Katsura systems). When this
+is not the case, the direct method may give better timings (like in
+the Rose system).
+
+
+
+
Of course, the direct method can also be applied to a lexicographical
+Groebner basis. However, the lexTriangular algorithm takes
+advantage of the structure of this basis and avoids many unnecessary
+computations which are performed by the direct method.
+
+
+
+
For this purpose of solving algebraic systems with a finite number of
+solutions, see also the ZeroDimensionalSolvePackage. It allows
+to use both strategies (the lexTriangular algorithm and the direct
+method) for computing either the complex or real roots of a system.
+
+
+
+
Note that the way of understanding triangular decompositions is
+detailed in the example of the RegularTriangularSet constructor.
+
+
+
+
Since the LEXTRIPK package constructor is limited to
+zero-dimensional systems, it provides a
+zeroDimensional?zeroDimensional?LexTriangularPackage operation to
+check whether this requirement holds. There is also a
+groebnergroebnerLexTriangularPackage operation to compute the
+lexicographical Groebner basis of a set of polynomials with type NewSparseMultivariatePolynomial(R,V). The elimination ordering is
+that given by ls (the greatest variable being the first element
+of ls). This basis is computed by the FLGM algorithm
+(Faugere et al. ``Efficient Computation of Zero-Dimensional Groebner
+Bases by Change of Ordering'' , J. of Symbol. Comput., 1993)
+implemented in the LinGroebnerPackage package constructor.
+Once a lexicographical Groebner basis is computed,
+then one can call the operations
+lexTriangularlexTriangularLexTriangularPackage
+and squareFreeLexTriangularsquareFreeLexTriangularLexTriangularPackage.
+Note that these operations admit an optional argument
+to produce normalized triangular sets.
+There is also a zeroSetSplitzeroSetSplitLexTriangularPackage operation
+which does all the job from the input system;
+an error is produced if this system is not zero-dimensional.
+
+
+
+
Let us illustrate the facilities of the LEXTRIPK constructor
+by a famous example, the cyclic-6 root system.
+
+Type: List NewSparseMultivariatePolynomial(Integer,OrderedVariableList [a,b,c,d,e,f])
+
+
+
+
+
Now call LEXTRIPK .
+
+
+
+
+
+
+
+lextripack := LEXTRIPK(R,ls)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
Compute the lexicographical Groebner basis of the system.
+This may take between 5 minutes and one hour, depending on your machine.
+
+
+
+
+
+
+
+lg := groebner(lp)$lextripack
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List NewSparseMultivariatePolynomial(Integer,OrderedVariableList [a,b,c,d,e,f])
+
+
+
+
+
Apply lexTriangular to compute a decomposition into regular triangular sets.
+This should not take more than 5 seconds.
+
+
+
+
+
+
+
+lexTriangular(lg,false)$lextripack
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List RegularChain(Integer,[a,b,c,d,e,f])
+
+
+
+
+
Note that the first set of the decomposition is normalized (all
+initials are integer numbers) but not the second one (normalized
+triangular sets are defined in the description of the
+NormalizedTriangularSetCategory constructor).
+
+
+
+
So apply now lexTriangular to produce normalized triangular sets.
+
+
+
+
+
+
+
+lts := lexTriangular(lg,true)$lextripack
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List RegularChain(Integer,[a,b,c,d,e,f])
+
+
+
+
+
We check that all initials are constant.
+
+
+
+
+
+
+
+[ [init(p) for p in (ts :: List(P))] for ts in lts]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List List NewSparseMultivariatePolynomial(Integer,OrderedVariableList [a,b,c,d,e,f])
+
+
+
+
+
Note that each triangular set in lts is a lexicographical
+Groebner basis. Recall that a point belongs to the variety associated
+with lp if and only if it belongs to that associated with one
+triangular set ts in lts.
+
+
+
+
By running the squareFreeLexTriangularsquareFreeLexTriangularLexTriangularPackage
+operation, we retrieve the above decomposition.
+
+Type: List Record(complexRoots: SparseUnivariatePolynomial Integer,coordinates: List Polynomial Integer)
+
+
+
+
+
Since the univariateSolveunivariateSolveZeroDimensionalSolvePackage
+operation may split a regular set, it returns a list. This explains
+the use of concatconcatList.
+
+
+
+
Look at the last item of the result. It consists of two parts. For
+any complex root ? of the univariate polynomial in the first
+part, we get a tuple of univariate polynomials (in a, ...,
+ f respectively) by replacing %A by ? in the second part.
+Each of these tuples t describes a point of the variety
+associated with lp by equaling to zero the polynomials in t.
+
+
+
+
Note that the way of reading these univariate representations is explained also
+in the example illustrating the ZeroDimensionalSolvePackage constructor.
+
+
+
+
Now, we compute the points of the variety with real coordinates.
+
+
+
+
+
+
+
+concat [realSolve(ts)$zdpack for ts in lts]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List List RealClosure Fraction Integer
+
+
+
+
+
We obtain 24 points given by lists of elements in the RealClosure
+of Fraction of R. In each list, the first value corresponds
+to the indeterminate f, the second to e and so on. See
+ZeroDimensionalSolvePackage to learn more about the
+realSolverealSolveZeroDimensionalSolvePackage operation.
+
All rational numbers have repeating binary expansions. Operations to
+access the individual bits of a binary expansion can be obtained by
+converting the value to RadixExpansion(2). More examples of
+expansions are available in
+DecimalExpansionXmpPage ,
+HexadecimalExpansionXmpPage , and
+RadixExpansionXmpPage .
+
+
+
+
The expansion (of type BinaryExpansion) of a rational number
+is returned by the binarybinaryBinaryExpansion operation.
+
+
+
+
+
+
+
+r := binary(22/7)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: BinaryExpansion
+
+
+
+
+
Arithmetic is exact.
+
+
+
+
+
+
+
+r + binary(6/7)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: BinaryExpansion
+
+
+
+
+
The period of the expansion can be short or long ...
+
The LazardSetSolvingPackage package constructor solves
+polynomial systems by means of Lazard triangular sets. However one
+condition is relaxed: Regular triangular sets whose saturated ideals
+have positive dimension are not necessarily normalized.
+
+
+
+
The decompositions are computed in two steps. First the algorithm of
+Moreno Maza (implemented in the RegularTriangularSet domain
+constructor) is called. Then the resulting decompositions are
+converted into lists of square-free regular triangular sets and the
+redundant components are removed. Moreover, zero-dimensional regular
+triangular sets are normalized.
+
+
+
+
Note that the way of understanding triangular decompositions
+is detailed in the example of the RegularTriangularSet
+constructor.
+
+
+
+
The LazardSetSolvingPackage constructor takes six arguments.
+The first one, R, is the coefficient ring of the polynomials; it
+must belong to the category GcdDomain. The second one, E,
+is the exponent monoid of the polynomials; it must belong to the
+category OrderedAbelianMonoidSup. the third one, V, is
+the ordered set of variables; it must belong to the category OrderedSet. The fourth one is the polynomial ring; it must belong to
+the category RecursivePolynomialCategory(R,E,V). The fifth one
+is a domain of the category RegularTriangularSetCategory(R,E,V,P)
+and the last one is a domain of
+the category SquareFreeRegularTriangularSetCategory(R,E,V,P).
+The abbreviation for LazardSetSolvingPackage is LAZM3PK.
+
+
+
+
N.B. For the purpose of solving zero-dimensional algebraic systems,
+see also LexTriangularPackage and ZeroDimensionalSolvePackage.
+These packages are easier to call than LAZM3PK.
+Moreover, the ZeroDimensionalSolvePackage
+package provides operations
+to compute either the complex roots or the real roots.
+
+
+
+
We illustrate now the use of the LazardSetSolvingPackage package
+constructor with two examples (Butcher and Vermeer).
+
We have obtained one regular chain (i.e. regular triangular set) with
+dimension 1. This set is in fact a characterist set of the (radical
+of) of the ideal generated by the input system lf. Thus we have
+only the generic points of the variety associated with lf
+(for the elimination ordering given by ls).
+
+
+
+
So let us get now a full description of this variety.
+
+
+
+
Hence, we solve this system in the sense of Lazard by means of the REGSET
+constructor:
+
We retrieve our regular chain of dimension 1 and we get three regular
+chains of dimension 0 corresponding to the degenerated cases.
+We want now to simplify these zero-dimensional regular chains by using
+Lazard triangular sets. Moreover, this will allow us to prove that
+the above decomposition has no redundant component. N.B.
+Generally, decompositions computed by the REGSET constructor do
+not have redundant components. However, to be sure that no redundant
+component occurs one needs to use the SREGSET or LAZM3PK
+constructors.
+
+
+
+
So let us solve the input system in the sense of Lazard by means of
+the LAZM3PK constructor:
+
Due to square-free factorization, we obtained now four
+zero-dimensional regular chains. Moreover, each of them is normalized
+(the initials are constant). Note that these zero-dimensional
+components may be investigated further with the
+ZeroDimensionalSolvePackage package constructor.
+
+The Library domain provides a simple way to store Axiom values
+in a file. This domain is similar to KeyedAccessFile but fewer
+declarations are needed and items of different types can be saved
+together in the same file.
+
+
+
+
To create a library, you supply a file name.
+
+
+
+
+
+
+
+stuff := library "/tmp/Neat.stuff"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Library
+
+
+
+
+
Now values can be saved by key in the file.
+The keys should be mnemonic, just as the field names are for records.
+They can be given either as strings or symbols.
+
+
+
+
+
+
+
+stuff.int := 32**2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+stuff."poly" := x**2 + 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
+
+
+
+stuff.str := "Hello"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
You obtain the set of available keys using the
+keyskeysLibrary operation.
+
+
+
+
+
+
+
+keys stuff
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List String
+
+
+
+
+
You extract values by giving the desired key in this way.
+
+
+
+
+
+
+
+stuff.poly
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
+
+
+
+stuff("poly")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
When the file is no longer needed, you should remove it from the
+file system.
+
LinearOrdinaryDifferentialOperator(A, diff) is the domain of
+linear ordinary differential operators with coefficients in a ring
+A with a given derivation.
+
+
+
+
+
+
+
9.44.1 Differential Operators with Series Coefficients
+
+
+
+
+
Problem:
+Find the first few coefficients of exp(x)/x**i of Dop phi where
+
+
+
+
+
+Dop := D**3 + G/x**2 * D + H/x**3 - 1
+phi := sum(s[i]*exp(x)/x**i, i = 0..)
+
+
+phi == reduce(+,[subscript(s,[i])*exp(x)/x**i for i in 0..n])
+
+
+
+
+
+
+
+Void
+
+
+
+
+
+
+
+
+phi1 == Dop(phi) / exp x
+
+
+
+
+
+
+
+Void
+
+
+
+
+
+
+
+
+phi2 == phi1 *x**(n+3)
+
+
+
+
+
+
+
+Void
+
+
+
+
+
+
+
+
+phi3 == retract(phi2)@(POLY INT)
+
+
+
+
+
+
+
+Void
+
+
+
+
+
+
+
+
+pans == phi3 ::UP(x,POLY INT)
+
+
+
+
+
+
+
+Void
+
+
+
+
+
+
+
+
+pans1 == [coefficient(pans, (n+3-i) :: NNI) for i in 2..n+1]
+
+
+
+
+
+
+
+Void
+
+
+
+
+
+
+
+
+leq == solve(pans1,[subscript(s,[i]) for i in 1..n])
+
+
+
+
+
+
+
+Void
+
+
+
+
+
Evaluate this for several values of n.
+
+
+
+
+
+
+
+leq
+
+
+
+
+
+
+
+ Compiling body of rule n to compute value of type PositiveInteger
+ Compiling body of rule phi to compute value of type Expression
+ Integer
+ Compiling body of rule phi1 to compute value of type Expression
+ Integer
+ Compiling body of rule phi2 to compute value of type Expression
+ Integer
+ Compiling body of rule phi3 to compute value of type Polynomial
+ Integer
+ Compiling body of rule pans to compute value of type
+ UnivariatePolynomial(x,Polynomial Integer)
+ Compiling body of rule pans1 to compute value of type List
+ Polynomial Integer
+ Compiling body of rule leq to compute value of type List List
+ Equation Fraction Polynomial Integer
+ Compiling function G83347 with type Integer -> Boolean
+
+
+
+
+
+
+
+
+n==4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List List Equation Fraction Polynomial Integer
+
+
+
+
+
+
+
+
+leq
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List List Equation Fraction Polynomial Integer
+
+
+
+
+
+
+
+
+n==7
+
+
+
+
+
+
+
+ Compiled code for n has been cleared.
+ Compiled code for leq has been cleared.
+ Compiled code for pans1 has been cleared.
+ Compiled code for phi2 has been cleared.
+ Compiled code for phi has been cleared.
+ Compiled code for phi3 has been cleared.
+ Compiled code for phi1 has been cleared.
+ Compiled code for pans has been cleared.
+ 1 old definition(s) deleted for function or rule n
+
+
+
+
+
+
+Void
+
+
+
+
+
+
+
+
+leq
+
+
+
+
+
+
+
+Compiling body of rule n to compute value of type PositiveInteger
+
++++ |*0;n;1;G82322| redefined
+Compiling body of rule phi to compute value of type Expression
+ Integer
+
++++ |*0;phi;1;G82322| redefined
+Compiling body of rule phi1 to compute value of type Expression
+ Integer
+
++++ |*0;phi1;1;G82322| redefined
+Compiling body of rule phi2 to compute value of type Expression
+ Integer
+
++++ |*0;phi2;1;G82322| redefined
+Compiling body of rule phi3 to compute value of type Polynomial
+ Integer
+
++++ |*0;phi3;1;G82322| redefined
+Compiling body of rule pans to compute value of type
+ UnivariatePolynomial(x,Polynomial Integer)
+
++++ |*0;pans;1;G82322| redefined
+Compiling body of rule pans1 to compute value of type List
+ Polynomial Integer
+
++++ |*0;pans1;1;G82322| redefined
+Compiling body of rule leq to compute value of type List List
+ Equation Fraction Polynomial Integer
+
++++ |*0;leq;1;G82322| redefined
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List List Equation Fraction Polynomial Integer
+
LinearOrdinaryDifferentialOperator1(A) is the domain of linear
+ordinary differential operators with coefficients in the differential ring
+A.
+
+
+
+
+
+
+
9.45.1 Differential Operators with Rational Function Coefficients
+
+
+
+
This example shows differential operators with rational function
+coefficients. In this case operator multiplication is non-commutative and,
+since the coefficients form a field, an operator division algorithm exists.
+
+
+
+
We begin by defining RFZ to be the rational functions in
+x with integer coefficients and Dx to be the differential
+operator for d/dx.
+
Operator multiplication corresponds to functional composition.
+
+
+
+
+
+
+
+p := x**2 + 1/x**2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction UnivariatePolynomial(x,Integer)
+
+
+
+
+
Since operator coefficients depend on x, the multiplication is
+not commutative.
+
+
+
+
+
+
+
+(a*b - b*a) p
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction UnivariatePolynomial(x,Integer)
+
+
+
+
+
When the coefficients of operator polynomials come from a field, as in
+this case, it is possible to define operator division. Division on
+the left and division on the right yield different results when the
+multiplication is non-commutative.
+
+
+
+
The results of
+leftDivideleftDivideLinearOrdinaryDifferentialOperator1 and
+rightDividerightDivideLinearOrdinaryDifferentialOperator1 are
+quotient-remainder pairs satisfying:
+
+
+
+
leftDivide(a,b) = [q, r] such that a = b*q + r
+rightDivide(a,b) = [q, r] such that a = q*b + r
+
+
+
+
In both cases, the
+degreedegreeLinearOrdinaryDifferentialOperator1 of the
+remainder, r, is less than the degree of b.
+
Operations
+rightQuotientrightQuotientLinearOrdinaryDifferentialOperator1 and
+rightRemainderrightRemainderLinearOrdinaryDifferentialOperator1 are
+available if only one of the quotient or remainder are of interest to
+you. This is the quotient from right division.
+
This is the remainder from right division.
+The corresponding ``left'' functions
+leftQuotientleftQuotientLinearOrdinaryDifferentialOperator1 and
+leftRemainderleftRemainderLinearOrdinaryDifferentialOperator1
+are also available.
+
For exact division, the operations
+leftExactQuotientleftExactQuotientLinearOrdinaryDifferentialOperator1 and
+rightExactQuotientrightExactQuotientLinearOrdinaryDifferentialOperator1 are supplied.
+These return the quotient but only if the remainder is zero.
+The call rightExactQuotient(a,b) would yield an error.
+
The division operations allow the computation of left and right greatest
+common divisors (leftGcdleftGcdLinearOrdinaryDifferentialOperator1 and
+rightGcdrightGcdLinearOrdinaryDifferentialOperator1) via remainder
+sequences, and consequently the computation of left and right least common
+multiples (rightLcmrightLcmLinearOrdinaryDifferentialOperator1 and
+leftLcmleftLcmLinearOrdinaryDifferentialOperator1).
+
Note that a greatest common divisor doesn't necessarily divide a
+and b on both sides. Here the left greatest common divisor does
+not divide a on the right.
+
LinearOrdinaryDifferentialOperator2(A, M) is the domain of
+linear ordinary differential operators with coefficients in the
+differential ring A and operating on M, an A-module.
+This includes the cases of operators which are polynomials in D
+acting upon scalar or vector expressions of a single variable. The
+coefficients of the operator polynomials can be integers, rational
+functions, matrices or elements of other domains.
+
+
+
+
+
+
+
9.46.1 Differential Operators with Constant Coefficients
+
+
+
+
This example shows differential operators with rational
+number coefficients operating on univariate polynomials.
+
+
+
+
We begin by making type assignments so we can conveniently refer
+to univariate polynomials in x over the rationals.
+
+
+
+
+
+
+
+Q := Fraction Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
+
+
+
+PQ := UnivariatePolynomial('x, Q)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
+
+
+
+x: PQ := 'x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: UnivariatePolynomial(x,Fraction Integer)
+
+
+
+
+
Now we assign Dx to be the differential operator
+DDLinearOrdinaryDifferentialOperator2
+corresponding to d/dx.
+
Finally, note that operator expressions may be applied directly.
+
+
+
+
+
+
+
+(a**2 - 3/4*b + c) (p + 1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: UnivariatePolynomial(x,Fraction Integer)
+
+
+
+
+
+
+
+
+
+
+
+
+
9.46.2 Differential Operators with Matrix Coefficients Operating on Vectors
+
+
+
+
This is another example of linear ordinary differential operators with
+non-commutative multiplication. Unlike the rational function case,
+the differential ring of square matrices (of a given dimension) with
+univariate polynomial entries does not form a field. Thus the number
+of operations available is more limited.
+
+
+
+
In this section, the operators have three by three
+matrix coefficients with polynomial entries.
+
+
+
+
+
+
+
+PZ := UnivariatePolynomial(x,Integer)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
+
+
+
+x:PZ := 'x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: UnivariatePolynomial(x,Integer)
+
+
+
+
+
+
+
+
+Mat := SquareMatrix(3,PZ)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
The operators act on the vectors considered as a Mat-module.
+
+
+
+
+
+
+
+Vect := DPMM(3, PZ, Mat, PZ)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
+
+
+
+Modo := LODO2(Mat, Vect)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
The matrix m is used as a coefficient and the vectors p
+and q are operated upon.
+
A list is a finite collection of elements in a specified
+order that can contain duplicates. A list is a convenient structure
+to work with because it is easy to add or remove elements and the
+length need not be constant. There are many different kinds of lists
+in Axiom, but the default types (and those used most often) are
+created by the List constructor. For example, there are objects
+of type List Integer, List Float and List Polynomial
+Fraction Integer. Indeed, you can even have List List List
+Boolean (that is, lists of lists of lists of Boolean values). You
+can have lists of any type of Axiom object.
+
+
+
+
+
+
+
9.47.1 Creating Lists
+
+
+
+
The easiest way to create a list with, for example, the elements
+2, 4, 5, 6 is to enclose the elements with square
+brackets and separate the elements with commas.
+
+
+
+
The spaces after the commas are optional, but they do improve the
+readability.
+
+
+
+
+
+
+
+[2, 4, 5, 6]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
To create a list with the single element 1, you can use
+either [1] or the operation listlistList.
+
+
+
+
+
+
+
+[1]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
+
+
+
+list(1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
Once created, two lists k and m can be concatenated by
+issuing append(k,m). appendappendList does not
+physically join the lists, but rather produces a new list with the
+elements coming from the two arguments.
+
+
+
+
+
+
+
+append([1,2,3],[5,6,7])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
Use consconsList to append an element onto the front of a
+list.
+
+
+
+
+
+
+
+cons(10,[9,8,7])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
+
+
+
+
+
+
+
+
9.47.2 Accessing List Elements
+
+
+
+
To determine whether a list has any elements, use the operation
+empty?empty?List.
+
+
+
+
+
+
+
+empty? [x+1]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
Alternatively, equality with the list constant nilnilList can
+be tested.
+
+
+
+
+
+
+
+([] = nil)@Boolean
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
We'll use this in some of the following examples.
+
+
+
+
+
+
+
+k := [4,3,7,3,8,5,9,2]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
Each of the next four expressions extracts the firstfirstList
+element of k.
+
+
+
+
+
+
+
+first k
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+k.first
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+k.1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+k(1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The last two forms generalize to k.i and k(i),
+respectively, where and n equals the length
+of k.
+
+
+
+
This length is calculated by #.
+
+
+
+
+
+
+
+n := #k
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Performing an operation such as k.i is sometimes referred to as
+indexing into k or elting into k. The latter phrase comes
+about because the name of the operation that extracts elements is
+called elteltList. That is, k.3 is just
+alternative syntax for elt(k,3). It is important to remember
+that list indices begin with 1. If we issue k := [1,3,2,9,5]
+then k.4 returns 9. It is an error to use an index that
+is not in the range from 1 to the length of the list.
+
+
+
+
The last element of a list is extracted by any of the
+following three expressions.
+
+
+
+
+
+
+
+last k
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+k.last
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
This form computes the index of the last element and then extracts the
+element from the list.
+
+
+
+
+
+
+
+k.( #k)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+
+
+
+
+
9.47.3 Changing List Elements
+
+
+
+
We'll use this in some of the following examples.
+
+
+
+
+
+
+
+k := [4,3,7,3,8,5,9,2]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
List elements are reset by using the k.i form on the left-hand
+side of an assignment. This expression resets the first element of
+k to 999.
+
+
+
+
+
+
+
+k.1 := 999
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
As with indexing into a list, it is an error to use an index that is
+not within the proper bounds. Here you see that k was modified.
+
+
+
+
+
+
+
+k
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
The operation that performs the assignment of an element to a
+particular position in a list is called seteltseteltList.
+This operation is destructive in that it changes the list. In
+the above example, the assignment returned the value 999 and
+k was modified. For this reason, lists are called
+mutable objects: it is possible to change part of a list
+(mutate it) rather than always returning a new list reflecting the
+intended modifications.
+
+
+
+
Moreover, since lists can share structure, changes to one list can
+sometimes affect others.
+
+
+
+
+
+
+
+k := [1,2]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
+
+
+
+m := cons(0,k)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
Change the second element of m.
+
+
+
+
+
+
+
+m.2 := 99
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
See, m was altered.
+
+
+
+
+
+
+
+m
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
But what about k? It changed too!
+
+
+
+
+
+
+
+k
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
+
+
+
+
+
+
+
+
9.47.4 Other Functions
+
+
+
+
An operation that is used frequently in list processing is that
+which returns all elements in a list after the first element.
+
+
+
+
+
+
+
+k := [1,2,3]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
Use the restrestList operation to do this.
+
+
+
+
+
+
+
+rest k
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
To remove duplicate elements in a list k, use
+removeDuplicatesremoveDuplicatesList.
+
+
+
+
+
+
+
+removeDuplicates [4,3,4,3,5,3,4]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
To get a list with elements in the order opposite to those in
+a list k, use reversereverseList.
+
+
+
+
+
+
+
+reverse [1,2,3,4,5,6]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
To test whether an element is in a list, use
+member?member?List: member?(a,k) returns true or
+false depending on whether a is in k or not.
+
+
+
+
+
+
+
+member?(1/2,[3/4,5/6,1/2])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+member?(1/12,[3/4,5/6,1/2])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
As an exercise, the reader should determine how to get a list
+containing all but the last of the elements in a given non-empty list
+k.reverse(rest(reverse(k))) works.
+
+
+
+
+
+
+
+
+
+
+
+
9.47.5 Dot, Dot
+
+
+
+
Certain lists are used so often that Axiom provides an easy way of
+constructing them. If n and m are integers, then
+expand [n..m] creates a list containing n, n+1, ... m. If
+n > m then the list is empty. It is actually permissible to leave
+off the m in the dot-dot construction (see below).
+
+
+
+
The dot-dot notation can be used more than once in a list construction
+and with specific elements being given. Items separated by dots are
+called segments.
+
+
+
+
+
+
+
+[1..3,10,20..23]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Segment PositiveInteger
+
+
+
+
+
Segments can be expanded into the range of items between the
+endpoints by using expandexpandSegment.
+
+
+
+
+
+
+
+expand [1..3,10,20..23]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
What happens if we leave off a number on the right-hand side of
+..?
+
+
+
+
+
+
+
+expand [1..]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Integer
+
+
+
+
+
What is created in this case is a Stream which is a
+generalization of a list. See
+StreamXmpPage for more
+information.
+
BinarySearchTree(R) is the domain of binary trees with elements
+of type R, ordered across the nodes of the tree. A non-empty
+binary search tree has a value of type R, and right and
+left binary search subtrees. If a subtree is empty, it is
+displayed as a period (``.'').
+
+
+
+
Define a list of values to be placed across the tree. The resulting
+tree has 8 at the root; all other elements are in the left
+subtree.
+
+
+
+
+
+
+
+lv := [8,3,5,4,6,2,1,5,7]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
A convenient way to create a binary search tree is to apply the
+operation binarySearchTree to a list of elements.
+
+
+
+
+
+
+
+t := binarySearchTree lv
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: BinarySearchTree PositiveInteger
+
+
+
+
+
Another approach is to first create an empty binary search tree of integers.
+
+
+
+
+
+
+
+emptybst := empty()$BSTREE(INT)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: BinarySearchTree Integer
+
+
+
+
+
Insert the value 8. This establishes 8 as the root of the
+binary search tree. Values inserted later that are less than 8
+get stored in the left subtree, others in the right subtree.
+
+
+
+
+
+
+
+t1 := insert!(8,emptybst)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: BinarySearchTree Integer
+
+
+
+
+
Insert the value 3. This number becomes the root of the left subtree of t1. For optimal retrieval, it is thus
+important to insert the middle elements first.
+
+
+
+
+
+
+
+insert!(3,t1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: BinarySearchTree Integer
+
+
+
+
+
We go back to the original tree t. The leaves of the binary
+search tree are those which have empty left and right subtrees.
+
+
+
+
+
+
+
+leaves t
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List PositiveInteger
+
+
+
+
+
The operation split(k,t) returns a record
+containing the two subtrees: one with all elements ``less'' than
+k, another with elements ``greater'' than k.
+
It is sometimes useful to be able to define a function given by
+the result of a calculation.
+
+
+
+
Suppose that you have obtained the following expression after several
+computations and that you now want to tabulate the numerical values of
+f for x between -1 and +1 with increment
+0.1.
+
+
+
+
+
+
+
+expr := (x - exp x + 1)**2 * (sin(x**2) * x + 1)**3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
You could, of course, use the function evalevalExpression
+within a loop and evaluate expr twenty-one times, but this would
+be quite slow. A better way is to create a numerical function f
+such that f(x) is defined by the expression expr above,
+but without retyping expr! The package MakeFunction
+provides the operation functionfunctionMakeFunction which does
+exactly this.
+
+
+
+
Issue this to create the function f(x) given by expr.
+
+
+
+
+
+
+
+function(expr, f, x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Symbol
+
+
+
+
+
To tabulate expr, we can now quickly evaluate f 21 times.
+
+
+
+
+
+
+
+tbl := [f(0.1 * i - 1) for i in 0..20];
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Float
+
+
+
+
+
Use the list [x1,...,xn] as the
+third argument to functionfunctionMakeFunction
+to create a multivariate function f(x1,...,xn).
+
+
+
+
+
+
+
+e := (x - y + 1)**2 * (x**2 * y + 1)**2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
+
+
+
+function(e, g, [x, y])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Symbol
+
+
+
+
+
In the case of just two variables, they can be given as arguments
+without making them into a list.
+
+
+
+
+
+
+
+function(e, h, x, y)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Symbol
+
+
+
+
+
Note that the functions created by functionfunctionMakeFunction
+are not limited to floating point numbers, but can be applied to any type
+for which they are defined.
+
Function are objects of type Mapping. In this section we
+demonstrate some library operations from the packages
+MappingPackage1, MappingPackage2, and MappingPackage3
+that manipulate and create functions. Some terminology: a
+nullary function takes no arguments, a unary function takes
+one argument, and a binary function takes two arguments.
+
+
+
+
We begin by creating an example function that raises a
+rational number to an integer exponent.
+
The curryRightcurryRightMappingPackage3 operation creates a
+unary function from a binary one by providing a constant argument on
+the right.
+
+
+
+
+
+
+
+square:= curryRight(power, 2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: (Fraction Integer -> Fraction Integer)
+
+
+
+
+
Likewise, the curryLeftcurryLeftMappingPackage3 operation
+provides a constant argument on the left.
+
+
+
+
+
+
+
+square 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
The constantRightconstantRightMappingPackage3 operation creates
+(in a trivial way) a binary function from a unary one:
+constantRight(f) is the function g such that
+g(a,b)= f(a).
+
+ Compiling function mto2ton with type (PositiveInteger,
+ PositiveInteger) -> Fraction Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Integer
+
+
+
+
+
Here shiftfib is a unary function that modifies its argument.
+
+
+
+
+
+
+shiftfib(r: List INT) : INT ==
+ t := r.1
+ r.1 := r.2
+ r.2 := r.2 + t
+ t
+
+Function declaration shiftfib : List Integer -> Integer
+ has been added to workspace.
+
+
+
+
+
+
+Void
+
+
+
+
+
By currying over the argument we get a function with private state.
+
The Matrix domain provides arithmetic operations on matrices
+and standard functions from linear algebra.
+This domain is similar to the TwoDimensionalArray domain, except
+that the entries for Matrix must belong to a Ring.
+
+
+
+
+
+
+
9.52.1 Creating Matrices
+
+
+
+
There are many ways to create a matrix from a collection of values or
+from existing matrices.
+
+
+
+
If the matrix has almost all items equal to the same value, use
+newnewMatrix to create a matrix filled with that value
+and then reset the entries that are different.
+
+
+
+
+
+
+
+m : Matrix(Integer) := new(3,3,0)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Integer
+
+
+
+
+
To change the entry in the second row, third column to 5, use
+seteltseteltMatrix.
+
+
+
+
+
+
+
+setelt(m,2,3,5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
An alternative syntax is to use assignment.
+
+
+
+
+
+
+
+m(1,2) := 10
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The matrix was destructively modified.
+
+
+
+
+
+
+
+m
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Integer
+
+
+
+
+
If you already have the matrix entries as a list of lists, use
+matrixmatrixMatrix.
+
+
+
+
+
+
+
+matrix [ [1,2,3,4],[0,9,8,7] ]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Integer
+
+
+
+
+
If the matrix is diagonal, use diagonalMatrixdiagonalMatrixMatrix.
+
Use horizConcathorizConcatMatrix to append them side to side.
+The two matrices must have the same number of rows.
+
+
+
+
+
+
+
+horizConcat(a,b)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Fraction Integer
+
+
+
+
+
Use vertConcatvertConcatMatrix to stack one upon the other.
+The two matrices must have the same number of columns.
+
+
+
+
+
+
+
+vab := vertConcat(a,b)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Fraction Integer
+
+
+
+
+
The operation transposetransposeMatrix is used to create a new
+matrix by reflection across the main diagonal.
+
+
+
+
+
+
+
+transpose vab
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Fraction Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
9.52.2 Operations on Matrices
+
+
+
+
Axiom provides both left and right scalar multiplication.
+
+
+
+
+
+
+
+m := matrix [ [1,2],[3,4] ]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Integer
+
+
+
+
+
+
+
+
+4 * m * (-5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Integer
+
+
+
+
+
You can add, subtract, and multiply matrices provided, of course, that
+the matrices have compatible dimensions. If not, an error message is
+displayed.
+
+
+
+
+
+
+
+n := matrix([ [1,0,-2],[-3,5,1] ])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Integer
+
+
+
+
+
This following product is defined but n * m is not.
+
+
+
+
+
+
+
+m * n
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Integer
+
+
+
+
+
The operations nrowsnrowsMatrix and
+ncolsncolsMatrix return the number of rows and columns of a
+matrix. You can extract a row or a column of a matrix using the
+operations rowrowMatrix and columncolumnMatrix.
+The object returned is a Vector.
+
+
+
+
Here is the third column of the matrix n.
+
+
+
+
+
+
+
+vec := column(n,3)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Vector Integer
+
+
+
+
+
You can multiply a matrix on the left by a ``row vector'' and on the right
+by a ``column vector.''
+
+
+
+
+
+
+
+vec * m
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Vector Integer
+
+
+
+
+
Of course, the dimensions of the vector and the matrix must be compatible
+or an error message is returned.
+
+
+
+
+
+
+
+m * vec
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Vector Integer
+
+
+
+
+
The operation inverseinverseMatrix computes the inverse of a
+matrix if the matrix is invertible, and returns "failed" if not.
+
+
+
+
This Hilbert matrix is invertible.
+
+
+
+
+
+
+
+hilb := matrix([ [1/(i + j) for i in 1..3] for j in 1..3])
+
+
The operation determinantdeterminantMatrix computes the
+determinant of a matrix provided that the entries of the matrix belong
+to a CommutativeRing.
+
+
+
+
The above matrix mm is not invertible and, hence, must have
+determinant 0.
+
+
+
+
+
+
+
+determinant(mm)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: NonNegativeInteger
+
+
+
+
+
The operation tracetraceSquareMatrix computes the trace of
+a square matrix.
+
+
+
+
+
+
+
+trace(mm)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The operation rankrankMatrix computes the rank of a
+matrix: the maximal number of linearly independent rows or columns.
+
+
+
+
+
+
+
+rank(mm)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The operation nullitynullityMatrix computes the nullity of
+a matrix: the dimension of its null space.
+
+
+
+
+
+
+
+nullity(mm)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The operation nullSpacenullSpaceMatrix returns a list
+containing a basis for the null space of a matrix. Note that the
+nullity is the number of elements in a basis for the null space.
+
+
+
+
+
+
+
+nullSpace(mm)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Vector Integer
+
+
+
+
+
The operation rowEchelonrowEchelonMatrix returns the row echelon
+form of a matrix. It is easy to see that the rank of this matrix is
+two and that its nullity is also two.
+
The domain Multiset(R) is similar to Set(R) except that
+multiplicities (counts of duplications) are maintained and displayed.
+Use the operation multisetmultisetMultiset to create multisets
+from lists. All the standard operations from sets are available for
+multisets. An element with multiplicity greater than one has the
+multiplicity displayed first, then a colon, and then the element.
+
The operation insert! adds an element to a multiset.
+
+
+
+
+
+
+
+insert!(3,s)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Multiset PositiveInteger
+
+
+
+
+
Use remove! to remove an element. If a third argument is
+present, it specifies how many instances to remove. Otherwise all
+instances of the element are removed. Display the resulting multiset.
+
+
+
+
+
+
+
+remove!(3,s,1); s
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Multiset PositiveInteger
+
+
+
+
+
+
+
+
+remove!(5,s); s
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Multiset PositiveInteger
+
+
+
+
+
The operation count returns the number of copies of a given value.
+
+
+
+
+
+
+
+count(5,s)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: NonNegativeInteger
+
+
+
+
+
A second multiset.
+
+
+
+
+
+
+
+t := multiset [2,2,2,-9]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Multiset Integer
+
+
+
+
+
The union of two multisets is additive.
+
+
+
+
+
+
+
+U := union(s,t)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Multiset Integer
+
+
+
+
+
The intersect operation gives the elements that are in
+common, with additive multiplicity.
+
+
+
+
+
+
+
+I := intersect(s,t)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Multiset Integer
+
+
+
+
+
The difference of s and t consists of the elements
+that s has but t does not. Elements are regarded as
+indistinguishable, so that if s and t have any element in
+common, the difference does not contain that element.
+
+
+
+
+
+
+
+difference(s,t)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Multiset Integer
+
+
+
+
+
The symmetricDifference is the union of difference(s, t)
+and difference(t, s).
+
+
+
+
+
+
+
+S := symmetricDifference(s,t)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Multiset Integer
+
+
+
+
+
Check that the union of the symmetricDifference and
+the intersect equals the union of the elements.
+
The domain constructor MultivariatePolynomial is similar to Polynomial except that it specifies the variables to be used. Polynomial are available for MultivariatePolynomial. The
+abbreviation for MultivariatePolynomial is MPOLY. The
+type expressions
+
+
+
+
MultivariatePolynomial([x,y],Integer)
+
+
+and
+
+
+
+
MPOLY([x,y],INT)
+
+
refer to the domain of
+multivariate polynomials in the variables x and y where the
+coefficients are restricted to be integers. The first variable specified
+is the main variable and the display of the polynomial reflects this.
+
+
+
+
This polynomial appears with terms in descending powers of the
+variable x.
+
Conversions can be used to re-express such polynomials in terms of
+the other variables. For example, you can first push all the
+variables into a polynomial with integer coefficients.
+
Axiom does not allow you to create types where
+MultivariatePolynomial is contained in the coefficient type of
+Polynomial. Therefore,
+MPOLY([x,y],POLY INT) is legal but
+POLY MPOLY([x,y],INT) is not.
+
+
+
+
+
+
+
+
.
+
+
+
+
+
+
+
+
+
+
Multivariate polynomials may be combined with univariate polynomials
+to create types with special structures.
+
+
+
+
+
+
+
+q : UP(x, FRAC MPOLY([y,z],INT))
+
+
+
+
+
+
+
+Void
+
+
+
+
+
This is a polynomial in x whose coefficients are quotients of
+polynomials in y and z.
+
A conversion like q :: MPOLY([x,y], FRAC UP(z,INT)) is not
+possible in this example because y appears in the denominator of
+a fraction. As you can see, Axiom provides extraordinary flexibility
+in the manipulation and display of expressions via its conversion
+facility.
+
The Octonions, also called the Cayley-Dixon algebra, defined over a
+commutative ring are an eight-dimensional non-associative algebra.
+Their construction from quaternions is similar to the construction
+of quaternions from complex numbers (see
+QuaternionXmpPage ).
+
+
+
+
As Octonion creates an eight-dimensional algebra, you have to
+give eight components to construct an octonion.
+
+
+
+
+
+
+
+oci1 := octon(1,2,3,4,5,6,7,8)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Octonion Integer
+
+
+
+
+
+
+
+
+oci2 := octon(7,2,3,-4,5,6,-7,0)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Octonion Integer
+
+
+
+
+
Or you can use two quaternions to create an octonion.
+
As with the quaternions, we have a real part, the imaginary parts i, j, k, and four additional imaginary parts E,
+I, J and K. These parts correspond to the canonical
+basis (1,i,j,k,E,I,J,K).
+
+
+
+
For each basis element there is a component operation to extract
+the coefficient of the basis element for a given octonion.
+
A basis with respect to the quaternions is given by (1,E).
+However, you might ask, what then are the commuting rules? To answer
+this, we create some generic elements.
+
+
+
+
We do this in Axiom by simply changing the ground ring from Integer to Polynomial Integer.
+
The OneDimensionalArray domain is used for storing data in a
+one-dimensional indexed data structure. Such an array is a
+homogeneous data structure in that all the entries of the array must
+belong to the same Axiom domain. Each array has a fixed length
+specified by the user and arrays are not extensible. The indexing of
+one-dimensional arrays is one-based. This means that the ``first''
+element of an array is given the index 1. See also
+VectorXmpPage and
+FlexibleArrayXmpPage .
+
+
+
+
To create a one-dimensional array, apply the operation
+oneDimensionalArray to a list.
+
+
+
+
+
+
+
+oneDimensionalArray [i**2 for i in 1..10]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: OneDimensionalArray PositiveInteger
+
+
+
+
+
Another approach is to first create a, a one-dimensional array
+of 10 0's. OneDimensionalArray has the convenient
+abbreviation ARRAY1.
+
+
+
+
+
+
+
+a : ARRAY1 INT := new(10,0)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: OneDimensionalArray Integer
+
+
+
+
+
Set each ith element to i, then display the result.
+
+
+
+
+
+
+
+for i in 1..10 repeat a.i := i; a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: OneDimensionalArray Integer
+
+
+
+
+
Square each element by mapping the function onto each
+element.
+
+
+
+
+
+
+
+map!(i +-> i ** 2,a); a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: OneDimensionalArray Integer
+
+
+
+
+
Reverse the elements in place.
+
+
+
+
+
+
+
+reverse! a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: OneDimensionalArray Integer
+
+
+
+
+
Swap the 4th and 5th element.
+
+
+
+
+
+
+
+swap!(a,4,5); a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: OneDimensionalArray Integer
+
+
+
+
+
Sort the elements in place.
+
+
+
+
+
+
+
+sort! a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: OneDimensionalArray Integer
+
+
+
+
+
Create a new one-dimensional array b containing the last 5
+elements of a.
+
+
+
+
+
+
+
+b := a(6..10)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: OneDimensionalArray Integer
+
+
+
+
+
Replace the first 5 elements of a with those of b.
+
Given any ring R, the ring of the Integer-linear operators
+over R is called Operator(R). To create an operator over
+R, first create a basic operator using the operation
+operator, and then convert it to Operator(R) for the R
+you want.
+
+
+
+
We choose R to be the two by two matrices over the integers.
+
+
+
+
+
+
+
+R := SQMATRIX(2, INT)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
Create the operator tilde on R.
+
+
+
+
+
+
+
+t := operator("tilde") :: OP(R)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Operator SquareMatrix(2,Integer)
+
+
+
+
+
Since Operator is unexposed we must either package-call operations
+from it, or expose it explicitly. For convenience we will do the latter.
+
+
+
+
Expose Operator.
+
+
+
+
+
+
+
+)set expose add constructor Operator
+
+
+
+
+
+
+
+ Operator is now explicitly exposed in frame G82322
+
+
+
+
+
To attach an evaluation function (from R to R) to an
+operator over R, use evaluate(op, f) where op is an
+operator over R and f is a function R -> R. This
+needs to be done only once when the operator is defined. Note that
+f must be Integer-linear (that is,
+f(ax+y) = a f(x) + f(y) for any integer a, and any x
+and y in R).
+
+
+
+
We now attach the transpose map to the above operator t.
+
+
+
+
+
+
+
+evaluate(t, m +-> transpose m)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Operator SquareMatrix(2,Integer)
+
+
+
+
+
Operators can be manipulated formally as in any ring: + is
+the pointwise addition and * is composition. Any element
+x of R can be converted to an operator
+ over R, and the evaluation function of
+ is left-multiplication by x.
+
+
+
+
Multiplying on the left by this matrix swaps the two rows.
+
+
+
+
+
+
+
+s : R := matrix [ [0, 1], [1, 0] ]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SquareMatrix(2,Integer)
+
+
+
+
+
Can you guess what is the action of the following operator?
+
+
+
+
+
+
+
+rho := t * s
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Operator SquareMatrix(2,Integer)
+
+
+
+
+
Hint: applying rho four times gives the identity, so
+rho**4-1 should return 0 when applied to any two by two matrix.
+
+
+
+
+
+
+
+z := rho**4 - 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Operator SquareMatrix(2,Integer)
+
+
+
+
+
Now check with this matrix.
+
+
+
+
+
+
+
+m:R := matrix [ [1, 2], [3, 4] ]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SquareMatrix(2,Integer)
+
+
+
+
+
+
+
+
+z m
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SquareMatrix(2,Integer)
+
+
+
+
+
As you have probably guessed by now, rho acts on matrices
+by rotating the elements clockwise.
+
+
+
+
+
+
+
+rho m
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SquareMatrix(2,Integer)
+
+
+
+
+
+
+
+
+rho rho m
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SquareMatrix(2,Integer)
+
+
+
+
+
+
+
+
+(rho**3) m
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SquareMatrix(2,Integer)
+
+
+
+
+
Do the swapping of rows and transposition commute? We can check by
+computing their bracket.
+
+
+
+
+
+
+
+b := t * s - s * t
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Operator SquareMatrix(2,Integer)
+
+
+
+
+
Now apply it to m.
+
+
+
+
+
+
+
+b m
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SquareMatrix(2,Integer)
+
+
+
+
+Next we demonstrate how to define a differential operator on a
+polynomial ring.
+
+
+
+
This is the recursive definition of the n-th Legendre polynomial.
+
+
+
+
+
+
+L n ==
+ n = 0 => 1
+ n = 1 => x
+ (2*n-1)/n * x * L(n-1) - (n-1)/n * L(n-2)
+
+
+
+
+
+
+Void
+
+
+
+
+
Create the differential operator on polynomials in x
+over the rational numbers.
+
+
+
+
+
+
+
+dx := operator("D") :: OP(POLY FRAC INT)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Operator Polynomial Fraction Integer
+
+
+
+
+
Now attach the map to it.
+
+
+
+
+
+
+
+evaluate(dx, p +-> D(p, 'x))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Operator Polynomial Fraction Integer
+
+
+
+
+
This is the differential equation satisfied by the n-th
+Legendre polynomial.
+
+
+
+
+
+
+
+E n == (1 - x**2) * dx**2 - 2 * x * dx + n*(n+1)
+
+
+
+
+
+
+
+Void
+
+
+
+
+
Now we verify this for n = 15. Here is the polynomial.
+
The domain OrderedVariableList provides symbols which are
+restricted to a particular list and have a definite ordering. Those
+two features are specified by a List Symbol object that is the
+argument to the domain.
+
The CardinalNumber domain can be used for values indicating the
+cardinality of sets, both finite and infinite. For example, the
+dimensiondimensionVectorSpace operation in the category
+VectorSpace returns a cardinal number.
+
+
+
+
The non-negative integers have a natural construction as cardinals
+
Subtraction is a partial operation: it is not defined
+when subtracting a larger cardinal from a smaller one, nor
+when subtracting two equal infinite cardinals.
+
+
+
+
+
+
+
+[c2-c1, c2-c2, c2-c3, A1-c2, A1-A0, A1-A1]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Union(CardinalNumber,"failed")
+
+
+
+
+
The generalized continuum hypothesis asserts that
+
+
+
+
+
+2**Aleph i = Aleph(i+1)
+
+
+
+
and is independent of the axioms of set theory. Goedel,
+The consistency of the continuum hypothesis,
+Ann. Math. Studies, Princeton Univ. Press, 1940.
+
+
+
+
The CardinalNumber domain provides an operation to assert
+whether the hypothesis is to be assumed.
+
+
+
+
+
+
+
+generalizedContinuumHypothesisAssumed true
+
+
+
+
+
+
When the generalized continuum hypothesis
+is assumed, exponentiation to a transfinite power is allowed.
+
Many systems of differential equations may be transformed to
+equivalent systems of ordinary differential equations where the
+equations are expressed polynomially in terms of the unknown
+functions. In Axiom, the domain constructors
+OrderlyDifferentialPolynomial (abbreviated ODPOL) and
+SequentialDifferentialPolynomial (abbreviation SDPOL) implement
+two domains of ordinary differential polynomials over any differential
+ring. In the simplest case, this differential ring is usually either
+the ring of integers, or the field of rational numbers. However,
+Axiom can handle ordinary differential polynomials over a field of
+rational functions in a single indeterminate.
+
+
+
+
The two domains ODPOL and SDPOL are almost identical, the
+only difference being the choice of a different ranking, which is an
+ordering of the derivatives of the indeterminates. The first domain
+uses an orderly ranking, that is, derivatives of higher order are
+ranked higher, and derivatives of the same order are ranked
+alphabetically. The second domain uses a sequential ranking, where
+derivatives are ordered first alphabetically by the differential
+indeterminates, and then by order. A more general domain constructor,
+DifferentialSparseMultivariatePolynomial (abbreviation
+DSMP) allows both a user-provided list of differential indeterminates
+as well as a user-defined ranking. We shall illustrate
+ODPOL(FRAC INT), which constructs a domain of ordinary differential
+polynomials in an arbitrary number of differential indeterminates with
+rational numbers as coefficients.
+
+
+
+
+
+
+
+dpol:= ODPOL(FRAC INT)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
A differential indeterminate w may be viewed as an infinite
+sequence of algebraic indeterminates, which are the derivatives of
+w. To facilitate referencing these, Axiom provides the
+operation makeVariablemakeVariableOrderlyDifferentialPolynomial to
+convert an element of type Symbol to a map from the natural
+numbers to the differential polynomial ring.
+
The fifth derivative of w can be obtained by applying the map
+w to the number 5. Note that the order of differentiation
+is given as a subscript (except when the order is 0).
+
The operation makeVariablemakeVariableOrderlyDifferentialPolynomial
+creates a map to facilitate referencing the derivatives of f,
+similar to the map w.
+
The operation orderorderOrderlyDifferentialPolynomial
+returns the order of a differential polynomial, or the order
+in a specified differential indeterminate.
+
+
+
+
+
+
+
+order(g)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+order(g, 'w)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The operation
+differentialVariablesdifferentialVariablesOrderlyDifferentialPolynomial returns
+a list of differential indeterminates occurring in a differential polynomial.
+
+
+
+
+
+
+
+differentialVariables(g)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Symbol
+
+
+
+
+
The operation degreedegreeOrderlyDifferentialPolynomial returns
+the degree, or the degree in the differential indeterminate specified.
+
+
+
+
+
+
+
+degree(g)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: IndexedExponents OrderlyDifferentialVariable Symbol
+
+
+
+
+
+
+
+
+degree(g, 'w)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The operation weightsweightsOrderlyDifferentialPolynomial returns
+a list of weights of differential monomials appearing in differential
+polynomial, or a list of weights in a specified differential
+indeterminate.
+
+
+
+
+
+
+
+weights(g)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List NonNegativeInteger
+
+
+
+
+
+
+
+
+weights(g,'w)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List NonNegativeInteger
+
+
+
+
+
The operation weightweightOrderlyDifferentialPolynomial returns
+the maximum weight of all differential monomials appearing in the
+differential polynomial.
+
+
+
+
+
+
+
+weight(g)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
A differential polynomial is isobaric if the weights of all
+differential monomials appearing in it are equal.
+
+
+
+
+
+
+
+isobaric?(g)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
To substitute differentially, use
+evalevalOrderlyDifferentialPolynomial. Note that we must
+coerce 'w to Symbol, since in ODPOL, differential
+indeterminates belong to the domain Symbol. Compare this result
+to the next, which substitutes algebraically (no substitution is
+done since w.0 does not appear in g).
+
Since OrderlyDifferentialPolynomial belongs to
+PolynomialCategory, all the operations defined in the latter
+category, or in packages for the latter category, are available.
+
+
+
+
+
+
+
+monomials(g)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List OrderlyDifferentialPolynomial Fraction Integer
+
+Type: List OrderlyDifferentialPolynomial Fraction Integer
+
+
+
+
+
The next three operations are essential for elimination procedures in
+differential polynomial rings. The operation
+leaderleaderOrderlyDifferentialPolynomial returns the leader
+of a differential polynomial, which is the highest ranked derivative
+of the differential indeterminates that occurs.
+
+
+
+
+
+
+
+lg:=leader(g)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: OrderlyDifferentialVariable Symbol
+
+
+
+
+
The operation separantseparantOrderlyDifferentialPolynomial returns
+the separant of a differential polynomial, which is the partial derivative
+with respect to the leader.
+
The operation initialinitialOrderlyDifferentialPolynomial returns
+the initial, which is the leading coefficient when the given differential
+polynomial is expressed as a polynomial in the leader.
+
Using these three operations, it is possible to reduce f modulo
+the differential ideal generated by g. The general scheme is to
+first reduce the order, then reduce the degree in the leader. First,
+eliminate z.3 using the derivative of g.
+
A partial fraction is a decomposition of a quotient into a sum
+of quotients where the denominators of the summands are powers of
+primes.Most people first encounter partial fractions when
+they are learning integral calculus. For a technical discussion of
+partial fractions, see, for example, Lang's Algebra. For
+example, the rational number 1/6 is decomposed into 1/2-1/3.
+You can compute partial fractions of quotients of objects from
+domains belonging to the category EuclideanDomain. For example,
+Integer, Complex Integer, and
+UnivariatePolynomial(x, Fraction Integer)
+all belong to EuclideanDomain. In the
+examples following, we demonstrate how to decompose quotients of each
+of these kinds of object into partial fractions. Issue the system
+command )show PartialFraction to display the full list of
+operations defined by PartialFraction.
+
+
+
+
It is necessary that we know how to factor the denominator when we
+want to compute a partial fraction. Although the interpreter can
+often do this automatically, it may be necessary for you to include a
+call to factor. In these examples, it is not necessary to
+factor the denominators explicitly.
+
+
+
+
The main operation for computing partial fractions is called
+partialFractionpartialFractionPartialFraction and we use this to
+compute a decomposition of 1 / 10!. The first argument to
+partialFractionpartialFractionPartialFraction is the numerator of the
+quotient and the second argument is the factored denominator.
+
+
+
+
+
+
+
+partialFraction(1,factorial 10)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PartialFraction Integer
+
+
+
+
+
Since the denominators are powers of primes, it may be possible
+to expand the numerators further with respect to those primes. Use the
+operation padicFractionpadicFractionPartialFraction to do this.
+
+
+
+
+
+
+
+f := padicFraction(%)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PartialFraction Integer
+
+
+
+
+
The operation compactFractioncompactFractionPartialFraction returns
+an expanded fraction into the usual form. The compacted version is
+used internally for computational efficiency.
+
+
+
+
+
+
+
+compactFraction(f)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PartialFraction Integer
+
+
+
+
+
You can add, subtract, multiply and divide partial fractions. In
+addition, you can extract the parts of the decomposition.
+numberOfFractionalTermsnumberOfFractionalTermsPartialFraction computes the
+number of terms in the fractional part. This does not include the
+whole part of the fraction, which you get by calling
+wholePartwholePartPartialFraction. In this example, the whole
+part is just 0.
+
+
+
+
+
+
+
+numberOfFractionalTerms(f)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The operation nthFractionalTermnthFractionalTermPartialFraction returns
+the individual terms in the decomposition. Notice that the object
+returned is a partial fraction itself.
+firstNumerfirstNumerPartialFraction and
+firstDenomfirstDenomPartialFraction extract the numerator and
+denominator of the first term of the fraction.
+
+
+
+
+
+
+
+nthFractionalTerm(f,3)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PartialFraction Integer
+
+
+
+
+
Given two gaussian integers (see
+ComplexXmpPage ), you can
+decompose their quotient into a partial fraction.
+
+
+
+
+
+
+
+partialFraction(1,- 13 + 14 * %i)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PartialFraction Complex Integer
+
+
+
+
+
To convert back to a quotient, simply use a conversion.
+
+
+
+
+
+
+
+% :: Fraction Complex Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Complex Integer
+
+
+
+
+
To conclude this section, we compute the decomposition of
+
The package Permanent provides the function
+permanentpermanentPermanent for square matrices. The
+permanentpermanentPermanent of a square matrix can be computed
+in the same way as the determinant by expansion of minors except that
+for the permanent the sign for each element is 1, rather than
+being 1 if the row plus column indices is positive and -1
+otherwise. This function is much more difficult to compute
+efficiently than the determinantdeterminantMatrix. An example of
+the use of permanentpermanentPermanent is the calculation of
+the -th derangement number, defined to be the number of
+different possibilities for n couples to dance but never with
+their own spouse.
+
+
+
+
Consider an n by n matrix with entries 0 on the
+diagonal and 1 elsewhere. Think of the rows as one-half of each
+couple (for example, the males) and the columns the other half. The
+permanent of such a matrix gives the desired derangement number.
+
+
+
+
+
+
+kn n ==
+ r : MATRIX INT := new(n,n,1)
+ for i in 1..n repeat
+ r.i.i := 0
+ r
+
+
+
+
+
+
+Void
+
+
+
+
+
Here are some derangement numbers, which you see grow quite fast.
+
+
+
+
+
+
+
+permanent(kn(5) :: SQMATRIX(5,INT))
+
+
+
+
+
+
+
+Compiling function kn with type PositiveInteger -> Matrix Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+[permanent(kn(n) :: SQMATRIX(n,INT)) for n in 1..13]
+
+
+
+
+
+
+
+Cannot compile conversion for types involving local variables.
+ In particular, could not compile the expression involving
+ :: SQMATRIX(n,INT)
+AXIOM will attempt to step through and interpret the code.
+
The domain constructor Polynomial (abbreviation: POLY)
+provides polynomials with an arbitrary number of unspecified
+variables.
+
+
+
+
It is used to create the default polynomial domains in Axiom.
+Here the coefficients are integers.
+
+
+
+
+
+
+
+x + 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
Here the coefficients have type Float.
+
+
+
+
+
+
+
+z - 2.3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Float
+
+
+
+
+
And here we have a polynomial in two variables with coefficients which
+have type Fraction Integer.
+
+
+
+
+
+
+
+y**2 - z + 3/4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Fraction Integer
+
+
+
+
+
The representation of objects of domains created by Polynomial
+is that of recursive univariate polynomials.The term
+univariate means ``one variable.'' multivariate means
+``possibly more than one variable.''
+
+
+
+
This recursive structure is sometimes obvious from the display of
+a polynomial.
+
+
+
+
+
+
+
+y **2 + x*y + y
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
In this example, you see that the polynomial is stored as a polynomial
+in y with coefficients that are polynomials in x with
+integer coefficients. In fact, you really don't need to worry about
+the representation unless you are working on an advanced application
+where it is critical. The polynomial types created from DistributedMultivariatePolynomial and
+NewDistributedMultivariatePolynomial (discussed in
+DistributedMultivariatePolynomialXmpPage ) are stored and
+displayed in a non-recursive manner.
+
+
+
+
You see a ``flat'' display of the above polynomial by converting to
+one of those types.
+
We will demonstrate many of the polynomial facilities by using two
+polynomials with integer coefficients.
+
+
+
+
By default, the interpreter expands polynomial expressions, even if they
+are written in a factored format.
+
+
+
+
+
+
+
+p := (y-1)**2 * x * z
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
See FactoredXmpPage
+to see how to create objects in factored form directly.
+
+
+
+
+
+
+
+q := (y-1) * x * (z+5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
The fully factored form can be recovered by using
+factorfactorPolynomial.
+
+
+
+
+
+
+
+factor(q)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Polynomial Integer
+
+
+
+
+
This is the same name used for the operation to factor integers. Such
+reuse of names is called overloading and makes it much easier
+to think of solving problems in general ways. Axiom facilities for
+factoring polynomials created with Polynomial are currently
+restricted to the integer and rational number coefficient cases.
+There are more complete facilities for factoring univariate
+polynomials: see ugProblemFactorPage in Section ugProblemFactorNumber
+.
+
+
+
+
The standard arithmetic operations are available for polynomials.
+
+
+
+
+
+
+
+p - q**2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
The operation gcdgcdPolynomial is used to compute the
+greatest common divisor of two polynomials.
+
+
+
+
+
+
+
+gcd(p,q)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
In the case of p and q, the gcd is obvious from their
+definitions. We factor the gcd to show this relationship better.
+
+
+
+
+
+
+
+factor %
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Factored Polynomial Integer
+
+
+
+
+
The least common multiple is computed by using lcmlcmPolynomial.
+
+
+
+
+
+
+
+lcm(p,q)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
Use contentcontentPolynomial to compute the greatest common
+divisor of the coefficients of the polynomial.
+
+
+
+
+
+
+
+content p
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Many of the operations on polynomials require you to specify a
+variable. For example, resultantresultantPolynomial requires
+you to give the variable in which the polynomials should be expressed.
+
+
+
+
This computes the resultant of the values of p and q,
+considering them as polynomials in the variable z. They do not
+share a root when thought of as polynomials in z.
+
+
+
+
+
+
+
+resultant(p,q,z)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
This value is 0 because as polynomials in x the polynomials
+have a common root.
+
+
+
+
+
+
+
+resultant(p,q,x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
The data type used for the variables created by Polynomial is
+Symbol. As mentioned above, the representation used by Polynomial is recursive and so there is a main variable for
+nonconstant polynomials.
+
+
+
+
The operation mainVariablemainVariablePolynomial returns this
+variable. The return type is actually a union of Symbol and
+"failed".
+
+
+
+
+
+
+
+mainVariable p
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(Symbol,...)
+
+
+
+
+
The latter branch of the union is be used if the polynomial has no
+variables, that is, is a constant.
+
+
+
+
+
+
+
+mainVariable(1 :: POLY INT)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union("failed",...)
+
+
+
+
+
You can also use the predicate ground?ground?Polynomial to test
+whether a polynomial is in fact a member of its ground ring.
+
+
+
+
+
+
+
+ground? p
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+ground?(1 :: POLY INT)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
The complete list of variables actually used in a particular
+polynomial is returned by variablesvariablesPolynomial. For
+constant polynomials, this list is empty.
+
+
+
+
+
+
+
+variables p
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Symbol
+
+
+
+
+
The degreedegreePolynomial operation returns the
+degree of a polynomial in a specific variable.
+
+
+
+
+
+
+
+degree(p,x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+degree(p,y)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+degree(p,z)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
If you give a list of variables for the second argument, a list
+of the degrees in those variables is returned.
+
+
+
+
+
+
+
+degree(p,[x,y,z])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List NonNegativeInteger
+
+
+
+
+
The minimum degree of a variable in a polynomial is computed using
+minimumDegreeminimumDegreePolynomial.
+
+
+
+
+
+
+
+minimumDegree(p,z)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The total degree of a polynomial is returned by
+totalDegreetotalDegreePolynomial.
+
+
+
+
+
+
+
+totalDegree p
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
It is often convenient to think of a polynomial as a leading monomial plus
+the remaining terms.
+
+
+
+
+
+
+
+leadingMonomial p
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
The reductumreductumPolynomial operation returns a polynomial
+consisting of the sum of the monomials after the first.
+
+
+
+
+
+
+
+reductum p
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
These have the obvious relationship that the original polynomial
+is equal to the leading monomial plus the reductum.
+
+
+
+
+
+
+
+p - leadingMonomial p - reductum p
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
The value returned by leadingMonomialleadingMonomialPolynomial
+includes the coefficient of that term. This is extracted by using
+leadingCoefficientleadingCoefficientPolynomial on the original
+polynomial.
+
+
+
+
+
+
+
+leadingCoefficient p
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The operation evalevalPolynomial is used to substitute a value
+for a variable in a polynomial.
+
+
+
+
+
+
+
+p
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
This value may be another variable, a constant or a polynomial.
+
+
+
+
+
+
+
+eval(p,x,w)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
+
+
+
+eval(p,x,1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
Actually, all the things being substituted are just polynomials,
+some more trivial than others.
+
+
+
+
+
+
+
+eval(p,x,y**2 - 1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
Derivatives are computed using the DDPolynomial operation.
+
+
+
+
+
+
+
+D(p,x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
The first argument is the polynomial and the second is the variable.
+
+
+
+
+
+
+
+D(p,y)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
Even if the polynomial has only one variable, you must specify it.
+
+
+
+
+
+
+
+D(p,z)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
Integration of polynomials is similar and the
+integrateintegratePolynomial operation is used.
+
+
+
+
Integration requires that the coefficients support division.
+Consequently, Axiom converts polynomials over the integers to
+polynomials over the rational numbers before integrating them.
+
+
+
+
+
+
+
+integrate(p,y)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Fraction Integer
+
+
+
+
+
It is not possible, in general, to divide two polynomials. In our
+example using polynomials over the integers, the operation
+monicDividemonicDividePolynomial divides a polynomial by a monic
+polynomial (that is, a polynomial with leading coefficient equal to
+1). The result is a record of the quotient and remainder of the
+division.
+
+
+
+
You must specify the variable in which to express the polynomial.
+
The selectors of the components of the record are quotient and
+remainder. Issue this to extract the remainder.
+
+
+
+
+
+
+
+qr.remainder
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
Now that we can extract the components, we can demonstrate the
+relationship among them and the arguments to our original expression
+qr := monicDivide(p,x+1,x).
+
+
+
+
+
+
+
+p - ((x+1) * qr.quotient + qr.remainder)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
If the / operator is used with polynomials, a
+fraction object is created. In this example, the result is an object
+of type Fraction Polynomial Integer.
+
+
+
+
+
+
+
+p/q
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Polynomial Integer
+
+
+
+
+
If you use rational numbers as polynomial coefficients, the
+resulting object is of type Polynomial Fraction Integer.
+
+
+
+
+
+
+
+(2/3) * x**2 - y + 4/5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Fraction Integer
+
+
+
+
+
This can be converted to a fraction of polynomials and back again, if
+required.
+
+
+
+
+
+
+
+% :: FRAC POLY INT
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Polynomial Integer
+
+
+
+
+
+
+
+
+% :: POLY FRAC INT
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Fraction Integer
+
+
+
+
+
To convert the coefficients to floating point, map the numeric
+operation on the coefficients of the polynomial.
+
The domain constructor Quaternion implements quaternions over
+commutative rings. For information on related topics see
+
+ComplexXmpPage and
+OctonionXmpPage .
+You can also issue the system command
+)show Quaternion to display the full list of operations
+defined by Quaternion.
+
+
+
+
The basic operation for creating quaternions is
+quaternquaternQuaternion.
+This is a quaternion over the rational numbers.
+
+
+
+
+
+
+
+q := quatern(2/11,-8,3/4,1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Quaternion Fraction Integer
+
+
+
+
+
The four arguments are the real part, the i imaginary part, the
+j imaginary part, and the k imaginary part, respectively.
+
+
+
+
+
+
+
+[real q, imagI q, imagJ q, imagK q]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Fraction Integer
+
+
+
+
+
Because q is over the rationals (and nonzero), you can invert it.
+
+
+
+
+
+
+
+inv q
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Quaternion Fraction Integer
+
+
+
+
+
The usual arithmetic (ring) operations are available
+
+
+
+
+
+
+
+q**6
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Quaternion Fraction Integer
+
+
+
+
+
+
+
+
+r := quatern(-2,3,23/9,-89); q + r
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Quaternion Fraction Integer
+
+
+
+
+
In general, multiplication is not commutative.
+
+
+
+
+
+
+
+q * r - r * q
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Quaternion Fraction Integer
+
+
+
+
+
There are no predefined constants for the imaginary i, j,
+and k parts, but you can easily define them.
+
You can expand fractions to form repeating expansions.
+
+
+
+
+
+
+
+(5/24)::RadixExpansion(2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: RadixExpansion 2
+
+
+
+
+
+
+
+
+(5/24)::RadixExpansion(3)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: RadixExpansion 3
+
+
+
+
+
+
+
+
+(5/24)::RadixExpansion(8)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: RadixExpansion 8
+
+
+
+
+
+
+
+
+(5/24)::RadixExpansion(10)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: RadixExpansion 10
+
+
+
+
+
For bases from 11 to 36 the letters A through Z are used.
+
+
+
+
+
+
+
+(5/24)::RadixExpansion(12)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: RadixExpansion 12
+
+
+
+
+
+
+
+
+(5/24)::RadixExpansion(16)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: RadixExpansion 16
+
+
+
+
+
+
+
+
+(5/24)::RadixExpansion(36)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: RadixExpansion 36
+
+
+
+
+
For bases greater than 36, the ragits are separated by blanks.
+
+
+
+
+
+
+
+(5/24)::RadixExpansion(38)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: RadixExpansion 38
+
+
+
+
+
The RadixExpansion type provides operations to obtain the
+individual ragits. Here is a rational number in base 8.
+
+
+
+
+
+
+
+a := (76543/210)::RadixExpansion(8)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: RadixExpansion 8
+
+
+
+
+
The operation wholeRagitswholeRagitsRadixExpansion returns a list of the
+ragits for the integral part of the number.
+
+
+
+
+
+
+
+w := wholeRagits a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
The operations prefixRagitsprefixRagitsRadixExpansion and
+cycleRagitscycleRagitsRadixExpansion return lists of the initial
+and repeating ragits in the fractional part of the number.
+
+
+
+
+
+
+
+f0 := prefixRagits a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
+
+
+
+f1 := cycleRagits a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
You can construct any radix expansion by giving the whole, prefix and
+cycle parts. The declaration is necessary to let Axiom know the base
+of the ragits.
+
If you are not interested in the repeating nature of the expansion,
+an infinite stream of ragits can be obtained using
+fractRagitsfractRagitsRadixExpansion.
+
+
+
+
+
+
+
+fractRagits(u)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Integer
+
+
+
+
+
Of course, it's possible to recover the fraction representation:
+
The Real Closure 1.0 package provided by Renaud Rioboo
+(Renaud.Rioboo@lip6.fr) consists of different packages, categories and
+domains :
+
+
+
+
+
+
+
+ The package RealPolynomialUtilitiesPackage which needs a
+FieldF and a UnivariatePolynomialCategory domain
+with coefficients in F. It computes some simple functions such
+as Sturm and Sylvester sequences
+(sturmSequencesturmSequenceRealPolynomialUtilitiesPackage,
+sylvesterSequencesylvesterSequenceRealPolynomialUtilitiesPackage).
+
+
+
The category RealRootCharacterizationCategory provides abstract
+functions to work with ``real roots'' of univariate polynomials. These
+resemble variables with some functionality needed to compute important
+operations.
+
+
+
The category RealClosedField provides common operations
+available over real closed fiels. These include finding all the roots
+of a univariate polynomial, taking square (and higher) roots, ...
+
+
+
The domain RightOpenIntervalRootCharacterization is the
+main code that provides the functionality of RealRootCharacterizationCategory for the case of archimedean
+fields. Abstract roots are encoded with a left closed right open
+interval containing the root together with a defining polynomial for
+the root.
+
+
+
The RealClosure domain is the end-user code. It provides
+usual arithmetic with real algebraic numbers, along with the
+functionality of a real closed field. It also provides functions to
+approximate a real algebraic number by an element of the base
+field. This approximation may either be absolute
+(approximateapproximateRealClosure) or relative
+(relativeApproxrelativeApproxRealClosure).
+
+
+
+
+
+
+
+
+
CAVEATS
+
+
+
+
Since real algebraic expressions are stored as depending on ``real
+roots'' which are managed like variables, there is an ordering on
+these. This ordering is dynamical in the sense that any new algebraic
+takes precedence over older ones. In particular every creation
+function raises a new ``real root''. This has the effect that when you
+type something like sqrt(2) + sqrt(2) you have two new variables
+which happen to be equal. To avoid this name the expression such as in
+s2 := sqrt(2) ; s2 + s2
+
+
+
+
Also note that computing times depend strongly on the ordering you
+implicitly provide. Please provide algebraics in the order which seems
+most natural to you.
+
+
+
+
+
+
LIMITATIONS
+
+
+
+
These packages use algorithms which are published in [1] and [2] which
+are based on field arithmetics, in particular for polynomial gcd
+related algorithms. This can be quite slow for high degree polynomials
+and subresultants methods usually work best. Beta versions of the
+package try to use these techniques in a better way and work
+significantly faster. These are mostly based on unpublished algorithms
+and cannot be distributed. Please contact the author if you have a
+particular problem to solve or want to use these versions.
+
+
+
+
Be aware that approximations behave as post-processing and that all
+computations are done exactly. They can thus be quite time consuming when
+depending on several ``real roots''.
+
+
+
+
+
+
REFERENCES
+
+
+
+
+
[1] R. Rioboo : Real Algebraic Closure of an ordered Field : Implementation
+ in Axiom.
+ In proceedings of the ISSAC'92 Conference, Berkeley 1992 pp. 206-215.
+
+
+
+
[2] Z. Ligatsikas, R. Rioboo, M. F. Roy : Generic computation of the real
+ closure of an ordered field.
+ In Mathematics and Computers in Simulation Volume 42, Issue 4-6,
+ November 1996.
+
+
+
+
+
+
EXAMPLES
+
+
+
+
We shall work with the real closure of the ordered field of
+rational numbers.
+
+
+
+
+
+
+
+Ran := RECLOS(FRAC INT)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
Some simple signs for square roots, these correspond to an extension
+of degree 16 of the rational numbers. Examples provided by J. Abbot.
+
The RegularTriangularSet domain constructor implements regular
+triangular sets. These particular triangular sets were introduced by
+M. Kalkbrener (1991) in his PhD Thesis under the name regular chains.
+Regular chains and their related concepts are presented in the paper
+``On the Theories of Triangular sets'' By P. Aubry, D. Lazard and
+M. Moreno Maza (to appear in the Journal of Symbolic Computation).
+The RegularTriangularSet constructor also provides a new method
+(by the third author) for solving polynomial system by means of
+regular chains. This method has two ways of solving. One has the
+same specifications as Kalkbrener's algorithm (1991) and the other is
+closer to Lazard's method (Discr. App. Math, 1991). Moreover, this
+new method removes redundant component from the decompositions when
+this is not too expensive. This is always the case with
+square-free regular chains. So if you want to obtain decompositions
+without redundant components just use the SquareFreeRegularTriangularSet domain constructor or the LazardSetSolvingPackage package constructor. See also the LexTriangularPackage and ZeroDimensionalSolvePackage for the
+case of algebraic systems with a finite number of (complex) solutions.
+
+
+
+
One of the main features of regular triangular sets is that they
+naturally define towers of simple extensions of a field.
+This allows to perform with multivariate polynomials the
+same kind of operations as one can do in an EuclideanDomain.
+
+
+
+
The RegularTriangularSet constructor takes four arguments. The
+first one, R, is the coefficient ring of the polynomials; it
+must belong to the category GcdDomain. The second one, E,
+is the exponent monoid of the polynomials; it must belong to the
+category OrderedAbelianMonoidSup. the third one, V, is
+the ordered set of variables; it must belong to the category
+OrderedSet. The last one is the polynomial ring; it must belong to
+the category RecursivePolynomialCategory(R,E,V). The
+abbreviation for RegularTriangularSet is REGSET. See also
+the constructor RegularChain which only takes two arguments, the
+coefficient ring and the ordered set of variables; in that case,
+polynomials are necessarily built with the
+NewSparseMultivariatePolynomial domain constructor.
+
+
+
+
We shall explain now how to use the constructor REGSET and how
+to read the decomposition of a polynomial system by means of regular
+sets.
+
+
+
+
Let us give some examples. We start with an easy one
+(Donati-Traverso) in order to understand the two ways of solving
+polynomial systems provided by the REGSET constructor.
+
We can see that the first decomposition is a subset of the second.
+So how can both be correct ?
+
+
+
+
Recall first that polynomials from a domain of the category
+RecursivePolynomialCategory are regarded as univariate polynomials in
+their main variable. For instance the second polynomial in the first
+set of each decomposition has main variable y and its initial
+(i.e. its leading coefficient w.r.t. its main variable) is t z.
+
+
+
+
Now let us explain how to read the second decomposition. Note that
+the non-constant initials of the first set are and .
+Then the solutions described by this first set are the common zeros of
+its polynomials that do not cancel the polynomials and .
+Now the solutions of the input system lp satisfying these
+equations are described by the second and the third sets of the
+decomposition. Thus, in some sense, they can be considered as
+degenerated solutions. The solutions given by the first set are
+called the generic points of the system; they give the general form of
+the solutions. The first decomposition only provides these generic
+points. This latter decomposition is useful when they are many
+degenerated solutions (which is sometimes hard to compute) and when
+one is only interested in general informations, like the dimension of
+the input system.
+
+
+
+
We can get the dimensions of each component
+of a decomposition as follows.
+
+
+
+
+
+
+
+[coHeight(ts) for ts in lts]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List NonNegativeInteger
+
+
+
+
+
Thus the first set has dimension one. Indeed t can take any
+value, except 0 or any third root of 1, whereas z is
+completely determined from t, y is given by z and
+ t, and finally x is given by the other three variables.
+In the second and the third sets of the second decomposition the four
+variables are completely determined and thus these sets have dimension
+zero.
+
+
+
+
We give now the precise specifications of each decomposition. This
+assume some mathematical knowledge. However, for the non-expert user,
+the above explanations will be sufficient to understand the other
+features of the RSEGSET constructor.
+
+
+
+
The input system lp is decomposed in the sense of Kalkbrener as
+finitely many regular sets T1,...,Ts such that the radical ideal
+generated by lp is the intersection of the radicals of the
+saturated ideals of T1,...,Ts. In other words, the affine
+variety associated with lp is the union of the closures
+(w.r.t. Zarisky topology) of the regular-zeros sets of
+ T1,...,Ts.
+
+
+
+
N. B. The prime ideals associated with the radical of the
+saturated ideal of a regular triangular set have all the same
+dimension; moreover these prime ideals can be given by characteristic
+sets with the same main variables. Thus a decomposition in the sense
+of Kalkbrener is unmixed dimensional. Then it can be viewed as a lazy decomposition into prime ideals (some of these prime ideals
+being merged into unmixed dimensional ideals).
+
+
+
+
Now we explain the other way of solving by means of regular triangular
+sets. The input system lp is decomposed in the sense of Lazard
+as finitely many regular triangular sets T1,...,Ts such that the
+affine variety associated with lp is the union of the
+regular-zeros sets of T1,...,Ts. Thus a decomposition in the
+sense of Lazard is also a decomposition in the sense of Kalkbrener;
+the converse is false as we have seen before.
+
+
+
+
When the input system has a finite number of solutions, both ways of
+solving provide similar decompositions as we shall see with this
+second example (Caprasse).
+
Up to the ordering of the components, both decompositions are identical.
+
+
+
+
Let us check that each component has a finite number of solutions.
+
+
+
+
+
+
+
+[coHeight(ts) for ts in lts2]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List NonNegativeInteger
+
+
+
+
+
Let us count the degrees of each component,
+
+
+
+
+
+
+
+degrees := [degree(ts) for ts in lts2]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List NonNegativeInteger
+
+
+
+
+
and compute their sum.
+
+
+
+
+
+
+
+reduce(+,degrees)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
We study now the options of the zeroSetSplit operation. As we
+have seen yet, there is an optional second argument which is a boolean
+value. If this value is true (this is the default) then the
+decomposition is computed in the sense of Kalkbrener, otherwise it is
+computed in the sense of Lazard.
+
+
+
+
There is a second boolean optional argument that can be used (in that
+case the first optional argument must be present). This second option
+allows you to get some information during the computations.
+
+
+
+
Therefore, we need to understand a little what is going on during the
+computations. An important feature of the algorithm is that the
+intermediate computations are managed in some sense like the processes
+of a Unix system. Indeed, each intermediate computation may generate
+other intermediate computations and the management of all these
+computations is a crucial task for the efficiency. Thus any
+intermediate computation may be suspended, killed or resumed,
+depending on algebraic considerations that determine priorities for
+these processes. The goal is of course to go as fast as possible
+towards the final decomposition which means to avoid as much as
+possible unnecessary computations.
+
+
+
+
To follow the computations, one needs to set to true the second
+argument. Then a lot of numbers and letters are displayed. Between a
+[ and a ] one has the state of the processes at a given
+time. Just after [ one can see the number of processes. Then
+each process is represented by two numbers between < and
+>. A process consists of a list of polynomial ps and a
+triangular set ts; its goal is to compute the common zeros of
+ ps that belong to the regular-zeros set of ts. After the
+processes, the number between pipes gives the total number of
+polynomials in all the sets ps. Finally, the number between
+braces gives the number of components of a decomposition that are
+already computed. This number may decrease.
+
+
+
+
Let us take a third example (Czapor-Geddes-Wang) to see how this
+information is displayed.
+
Between a sequence of processes, thus between a ] and a [
+you can see capital letters W, G, I and lower case letters
+i, w. Each time a capital letter appears a non-trivial computation
+has be performed and its result is put in a hash-table. Each time a
+lower case letter appears a needed result has been found in an
+hash-table. The use of these hash-tables generally speed up the
+computations. However, on very large systems, it may happen that
+these hash-tables become too big to be handle by your AXIOM
+configuration. Then in these exceptional cases, you may prefer
+getting a result (even if it takes a long time) than getting nothing.
+Hence you need to know how to prevent the RSEGSET constructor
+from using these hash-tables. In that case you will be using the
+zeroSetSplit with five arguments. The first one is the input system
+ lp as above. The second one is a boolean value hash?
+which is true iff you want to use hash-tables. The third one is
+boolean value clos? which is true iff you want to solve
+your system in the sense of Kalkbrener, the other way remaining that
+of Lazard. The fourth argument is boolean value info? which is
+true iff you want to display information during the
+computations. The last one is boolean value prep? which is
+true iff you want to use some heuristics that are performed on the
+input system before starting the real algorithm. The value of this
+flag is true when you are using zeroSetSplit with less
+than five arguments. Note that there is no available signature for
+zeroSetSplit with four arguments.
+
+
+
+
We finish this section by some remarks about both ways of solving, in
+the sense of Kalkbrener or in the sense of Lazard. For problems with
+a finite number of solutions, there are theoretically equivalent and
+the resulting decompositions are identical, up to the ordering of the
+components. However, when solving in the sense of Lazard, the
+algorithm behaves differently. In that case, it becomes more
+incremental than in the sense of Kalkbrener. That means the
+polynomials of the input system are considered one after another
+whereas in the sense of Kalkbrener the input system is treated more
+globally.
+
+
+
+
This makes an important difference in positive dimension. Indeed when
+solving in the sense of Kalkbrener, the Primeidealkettensatz of
+Krull is used. That means any regular triangular containing more
+polynomials than the input system can be deleted. This is not
+possible when solving in the sense of Lazard. This explains why
+Kalkbrener's decompositions usually contain less components than those
+of Lazard. However, it may happen with some examples that the
+incremental process (that cannot be used when solving in the sense of
+Kalkbrener) provide a more efficient way of solving than the global
+one even if the Primeidealkettensatz is used. Thus just try
+both, with the various options, before concluding that you cannot
+solve your favorite system with zeroSetSplit. There exist more
+options at the development level that are not currently available in
+this public version.
+
The Roman numeral package was added to Axiom in MCMLXXXVI for use in
+denoting higher order derivatives.
+
+
+
+
For example, let f be a symbolic operator.
+
+
+
+
+
+
+
+f := operator 'f
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: BasicOperator
+
+
+
+
+
This is the seventh derivative of f with respect to x.
+
+
+
+
+
+
+
+D(f x,x,7)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Expression Integer
+
+
+
+
+
You can have integers printed as Roman numerals by declaring variables to
+be of type RomanNumeral (abbreviation ROMAN).
+
+
+
+
+
+
+
+a := roman(1978 - 1965)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: RomanNumeral
+
+
+
+
+
This package now has a small but devoted group of followers that claim
+this domain has shown its efficacy in many other contexts. They claim
+that Roman numerals are every bit as useful as ordinary integers.
+
+
+
+
In a sense, they are correct, because Roman numerals form a ring and you
+can therefore construct polynomials with Roman numeral coefficients,
+matrices over Roman numerals, etc..
+
You can also construct fractions with Roman numeral numerators and
+denominators, as this matrix Hilberticus illustrates.
+
+
+
+
+
+
+
+m : MATRIX FRAC ROMAN
+
+
+
+
+
+
+
+Void
+
+
+
+
+
+
+
+
+m := matrix [ [1/(i + j) for i in 1..3] for j in 1..3]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Matrix Fraction RomanNumeral
+
+
+
+
+
Note that the inverse of the matrix has integral ROMAN entries.
+
+
+
+
+
+
+
+inverse m
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(Matrix Fraction RomanNumeral,...)
+
+
+
+
+
Unfortunately, the spoil-sports say that the fun stops when the
+numbers get big---mostly because the Romans didn't establish
+conventions about representing very large numbers.
+
+
+
+
+
+
+
+y := factorial 10
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
You work it out!
+
+
+
+
+
+
+
+roman y
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: RomanNumeral
+
+
+
+
+
Issue the system command )show RomanNumeral to display the full
+list of operations defined by RomanNumeral.
+
The Segment domain provides a generalized interval type.
+
+
+
+
Segments are created using the .. construct by indicating the
+(included) end points.
+
+
+
+
+
+
+
+s := 3..10
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Segment PositiveInteger
+
+
+
+
+
The first end point is called the loloSegment and the
+second is called hihiSegment.
+
+
+
+
+
+
+
+lo s
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
These names are used even though the end points might belong to an
+unordered set.
+
+
+
+
+
+
+
+hi s
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
In addition to the end points, each segment has an integer ``increment.''
+An increment can be specified using the ``by'' construct.
+
+
+
+
+
+
+
+t := 10..3 by -2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Segment PositiveInteger
+
+
+
+
+
This part can be obtained using the incrincrSegment function.
+
+
+
+
+
+
+
+incr s
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Unless otherwise specified, the increment is 1.
+
+
+
+
+
+
+
+incr t
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Integer
+
+
+
+
+
A single value can be converted to a segment with equal end points.
+This happens if segments and single values are mixed in a list.
+
+
+
+
+
+
+
+l := [1..3, 5, 9, 15..11 by -1]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Segment PositiveInteger
+
+
+
+
+
If the underlying type is an ordered ring, it is possible to perform
+additional operations. The expandexpandSegment operation
+creates a list of points in a segment.
+
+
+
+
+
+
+
+expand s
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
If k > 0, then expand(l..h by k) creates the list
+[l, l+k, ..., lN] where lN <= h < lN+k.
+If k < 0, then lN >= h > lN+k.
+
+
+
+
+
+
+
+expand t
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
It is also possible to expand a list of segments. This is equivalent
+to appending lists obtained by expanding each segment individually.
+
CartesianTensor(i0,dim,R) provides Cartesian tensors with
+components belonging to a commutative ring R. Tensors can be
+described as a generalization of vectors and matrices. This gives a
+concise tensor algebra for multilinear objects supported by the
+CartesianTensor domain. You can form the inner or outer product
+of any two tensors and you can add or subtract tensors with the same
+number of components. Additionally, various forms of traces and
+transpositions are useful.
+
+
+
+
The CartesianTensor constructor allows you to specify the
+minimum index for subscripting. In what follows we discuss in detail
+how to manipulate tensors.
+
+
+
+
Here we construct the domain of Cartesian tensors of dimension 2 over the
+integers, with indices starting at 1.
+
+
+
+
+
+
+
+CT := CARTEN(i0 := 1, 2, Integer)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
+
7.1 Forming tensors
+
+
+
+
Scalars can be converted to tensors of rank zero.
+
+
+
+
+
+
+
+t0: CT := 8
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: CartesianTensor(1,2,Integer)
+
+
+
+
+
+
+
+
+rank t0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: NonNegativeInteger
+
+
+
+
+
Vectors (mathematical direct products, rather than one dimensional array
+structures) can be converted to tensors of rank one.
+
In general, a tensor of rank k can be formed by making a list of
+rank k-1 tensors or, alternatively, a k-deep nested list
+of lists.
+
+
+
+
+
+
+
+t1: CT := [2, 3]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: CartesianTensor(1,2,Integer)
+
+
+
+
+
+
+
+
+rank t1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+t2: CT := [t1, t1]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: CartesianTensor(1,2,Integer)
+
+
+
+
+
+
+
+
+t3: CT := [t2, t2]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: CartesianTensor(1,2,Integer)
+
+
+
+
+
+
+
+
+tt: CT := [t3, t3]; tt := [tt, tt]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: CartesianTensor(1,2,Integer)
+
+
+
+
+
+
+
+
+rank tt
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+
+
+
7.2 Multiplication
+
+
+
+
Given two tensors of rank k1 and k2, the outer
+productproductCartesianTensor forms a new tensor of rank
+k1+k2. Here
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Tmn := product(Tm, Tn)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: CartesianTensor(1,2,Integer)
+
+
+
+
+
The inner product (contractcontractCartesianTensor) forms a
+tensor of rank k1+k2-2. This product generalizes the vector dot
+product and matrix-vector product by summing component products along
+two indices.
+
+
+
+
Here we sum along the second index of and the first index of
+ . Here
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Tmv := contract(Tm,2,Tv,1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: CartesianTensor(1,2,Integer)
+
+
+
+
+
The multiplication operator * is scalar
+multiplication or an inner product depending on the ranks of the arguments.
+
+
+
+
If either argument is rank zero it is treated as scalar multiplication.
+Otherwise, a*b is the inner product summing the last index of
+a with the first index of b.
+
+
+
+
+
+
+
+Tm*Tv
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: CartesianTensor(1,2,Integer)
+
+
+
+
+
This definition is consistent with the inner product on matrices
+and vectors.
+
+
+
+
+
+
+
+Tmv = m * v
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Equation CartesianTensor(1,2,Integer)
+
+
+
+
+
+
+
+
+
+
+
7.3 Selecting Components
+
+
+
+
For tensors of low rank (that is, four or less), components can be selected
+by applying the tensor to its indices.
+
+
+
+
+
+
+
+t0()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+t1(1+1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+t2(2,1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+t3(2,1,2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+Tmn(2,1,2,1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: NonNegativeInteger
+
+
+
+
+
A general indexing mechanism is provided for a list of indices.
+
+
+
+
+
+
+
+t0[]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+t1[2]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+t2[2,1]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The general mechanism works for tensors of arbitrary rank, but is
+somewhat less efficient since the intermediate index list must be created.
+
+
+
+
+
+
+
+t3[2,1,2]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+Tmn[2,1,2,1]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: NonNegativeInteger
+
+
+
+
+
+
+
+
+
+
+
7.4 Contraction
+
+
+
+
A ``contraction'' between two tensors is an inner product, as we have
+seen above. You can also contract a pair of indices of a single
+tensor. This corresponds to a ``trace'' in linear algebra. The
+expression contract(t,k1,k2) forms a new tensor by summing the
+diagonal given by indices in position k1 and k2.
+
+
+
+
This is the tensor given by
+
+
+
+
+
+
+
+
+cTmn := contract(Tmn,1,2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: CartesianTensor(1,2,Integer)
+
+
+
+
+
Since Tmn is the outer product of matrix m and matrix n,
+the above is equivalent to this.
+
+
+
+
+
+
+
+trace(m) * n
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SquareMatrix(2,Integer)
+
+
+
+
+
In this and the next few examples, we show all possible contractions
+of Tmn and their matrix algebra equivalents.
+
You can exchange any desired pair of indices using the
+transposetransposeCartesianTensor operation.
+
+
+
+
Here the indices in positions one and three are exchanged, that is,
+
+
+
+
+
+
+
+
+tTmn := transpose(Tmn,1,3)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: CartesianTensor(1,2,Integer)
+
+
+
+
+
If no indices are specified, the first and last index are exchanged.
+
+
+
+
+
+
+
+transpose Tmn
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: CartesianTensor(1,2,Integer)
+
+
+
+
+
This is consistent with the matrix transpose.
+
+
+
+
+
+
+
+transpose Tm = transpose m
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Equation CartesianTensor(1,2,Integer)
+
+
+
+
+
If a more complicated reordering of the indices is required, then the
+reindexreindexCartesianTensor operation can be used.
+This operation allows the indices to be arbitrarily permuted.
+
+
+
+
This defines
+
+
+
+
+
+
+
+rTmn := reindex(Tmn, [1,4,2,3])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: CartesianTensor(1,2,Integer)
+
+
+
+
+
+
+
+
+
+
+
+
7.6 Arithmetic
+
+
+
+
Tensors of equal rank can be added or subtracted so arithmetic
+expressions can be used to produce new tensors.
+
The Levi Civita symbol determines the sign of a permutation of indices.
+
+
+
+
+
+
+
+epsilon:CT := leviCivitaSymbol()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: CartesianTensor(1,2,Integer)
+
+
+
+
+
Here we have:
+
+
+
+
+
+epsilon(i1,...,idim)
+ = +1 if i1,...,idim is an even permutation of i0,...,i0+dim-1
+ = -1 if i1,...,idim is an odd permutation of i0,...,i0+dim-1
+ = 0 if i1,...,idim is not a permutation of i0,...,i0+dim-1
+
+
+
+
+
This property can be used to form determinants.
+
+
+
+
+
+
+
+contract(epsilon*Tm*epsilon, 1,2) = 2 * determinant m
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Equation CartesianTensor(1,2,Integer)
+
+
+
+
+
+
+
+
+
+
+
7.8 Properties of the CartesianTensor domain
+
+
+
+
GradedModule(R,E) denotes ``E-graded R-module'',
+that is, a collection of R-modules indexed by an abelian monoid
+E. An element g of G[s] for some specific s
+in E is said to be an element of G with
+degreedegreeGradedModules. Sums are defined in each
+module G[s] so two elements of G can be added if they have
+the same degree. Morphisms can be defined and composed by degree to
+give the mathematical category of graded modules.
+
+
+
+
GradedAlgebra(R,E) denotes ``E-graded R-algebra.''
+A graded algebra is a graded module together with a degree preserving
+R-bilinear map, called the productproductGradedAlgebra.
+
The domain CartesianTensor(i0, dim, R) belongs to the category
+GradedAlgebra(R, NonNegativeInteger). The non-negative integer
+degreedegreeGradedAlgebra is the tensor rank and the graded
+algebra productproductGradedAlgebra is the tensor outer
+product. The graded module addition captures the notion that only
+tensors of equal rank can be added.
+
+
+
+
If V is a vector space of dimension dim over R,
+then the tensor module T[k](V) is defined as
+
+
+
+
+
+T[0](V) = R
+T[k](V) = T[k-1](V) * V
+
+
+
+
where * denotes the R-module tensor
+productproductGradedAlgebra. CartesianTensor(i0,dim,R)
+is the graded algebra in which the degree k module is T[k](V).
+
+
+
+
+
+
+
+
+
+
7.9 Tensor Calculus
+
+
+
+
It should be noted here that often tensors are used in the context of
+tensor-valued manifold maps. This leads to the notion of covariant
+and contravariant bases with tensor component functions transforming
+in specific ways under a change of coordinates on the manifold. This
+is no more directly supported by the CartesianTensor domain than
+it is by the Vector domain. However, it is possible to have the
+components implicitly represent component maps by choosing a
+polynomial or expression type for the components. In this case, it is
+up to the user to satisfy any constraints which arise on the basis of
+this interpretation.
+
The Set domain allows one to represent explicit finite sets of values.
+These are similar to lists, but duplicate elements are not allowed.
+
+
+
+
Sets can be created by giving a fixed set of values ...
+
+
+
+
+
+
+
+s := set [x**2-1, y**2-1, z**2-1]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Set Polynomial Integer
+
+
+
+
+
or by using a collect form, just as for lists. In either case, the
+set is formed from a finite collection of values.
+
+
+
+
+
+
+
+t := set [x**i - i+1 for i in 2..10 | prime? i]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Set Polynomial Integer
+
+
+
+
+
The basic operations on sets are intersectintersectSet,
+unionunionSet, differencedifferenceSet, and
+symmetricDifferencesymmetricDifferenceSet.
+
+
+
+
+
+
+
+i := intersect(s,t)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Set Polynomial Integer
+
+
+
+
+
+
+
+
+u := union(s,t)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Set Polynomial Integer
+
+
+
+
+
The set difference(s,t) contains those members of s which
+are not in t.
+
+
+
+
+
+
+
+difference(s,t)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Set Polynomial Integer
+
+
+
+
+
The set symmetricDifference(s,t) contains those elements which are
+in s or t but not in both.
+
+
+
+
+
+
+
+symmetricDifference(s,t)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Set Polynomial Integer
+
+
+
+
+
Set membership is tested using the member?member?Set operation.
+
+
+
+
+
+
+
+member?(y, s)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+member?((y+1)*(y-1), s)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
The subset?subset?Set function determines whether one set is
+a subset of another.
+
+
+
+
+
+
+
+subset?(i, s)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+subset?(u, s)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
When the base type is finite, the absolute complement of a set is
+defined. This finds the set of all multiplicative generators of
+PrimeField 11---the integers mod 11.
+
+
+
+
+
+
+
+gs := set [g for i in 1..11 | primitive?(g := i::PF 11)]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Set PrimeField 11
+
+
+
+
+
The following values are not generators.
+
+
+
+
+
+
+
+complement gs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Set PrimeField 11
+
+
+
+
+
Often the members of a set are computed individually; in addition,
+values can be inserted or removed from a set over the course of a
+computation.
+
+
+
+
There are two ways to do this:
+
+
+
+
+
+
+
+a := set [i**2 for i in 1..5]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Set PositiveInteger
+
+
+
+
+
One is to view a set as a data structure and to apply updating operations.
+
+
+
+
+
+
+
+insert!(32, a)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Set PositiveInteger
+
+
+
+
+
+
+
+
+remove!(25, a)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Set PositiveInteger
+
+
+
+
+
+
+
+
+a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Set PositiveInteger
+
+
+
+
+
The other way is to view a set as a mathematical entity and to
+create new sets from old.
+
+
+
+
+
+
+
+b := b0 := set [i**2 for i in 1..5]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Set PositiveInteger
+
+
+
+
+
+
+
+
+b := union(b, {32})
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Set PositiveInteger
+
+
+
+
+
+
+
+
+b := difference(b, {25})
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Set PositiveInteger
+
+
+
+
+
+
+
+
+b0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Set PositiveInteger
+
+
+
+
+
For more information about lists, see ListXmpPage .
+
The SingleInteger domain is intended to provide support in Axiom
+for machine integer arithmetic. It is generally much faster than
+(bignum) Integer arithmetic but suffers from a limited range of
+values. Since Axiom can be implemented on top of various dialects of
+Lisp, the actual representation of small integers may not correspond
+exactly to the host machines integer representation.
+
+
+
+
In the CCL implementation of AXIOM (Release 2.1 onwards) the underlying
+representation of SingleInteger is the same as Integer.
+The underlying Lisp primitives treat machine-word sized computations
+specially.
+
+
+
+
You can discover the minimum and maximum values in your implementation
+by using minminSingleInteger and maxmaxSingleInteger.
+
+
+
+
+
+
+
+min()$SingleInteger
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SingleInteger
+
+
+
+
+
+
+
+
+max()$SingleInteger
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SingleInteger
+
+
+
+
+
To avoid confusion with Integer, which is the default type for
+integers, you usually need to work with declared variables
+(ugTypesDeclarePage in Section
+ugTypesDeclareNumber )
+...
+
You can add, multiply and subtract SingleInteger objects,
+and ask for the greatest common divisor (gcd).
+
+
+
+
+
+
+
+gcd(a,b)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SingleInteger
+
+
+
+
+
The least common multiple (lcm) is also available.
+
+
+
+
+
+
+
+lcm(a,b)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SingleInteger
+
+
+
+
+
Operations mulmodmulmodSingleInteger,
+addmodaddmodSingleInteger,
+submodsubmodSingleInteger, and
+invmodinvmodSingleInteger are similar---they provide
+arithmetic modulo a given small integer.
+Here is .
+
+
+
+
+
+
+
+mulmod(5,6,13)$SingleInteger
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SingleInteger
+
+
+
+
+
To reduce a small integer modulo a prime, use
+positiveRemainderpositiveRemainderSingleInteger.
+
+
+
+
+
+
+
+positiveRemainder(37,13)$SingleInteger
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SingleInteger
+
+
+
+
+
Operations
+AndAndSingleInteger,
+OrOrSingleInteger,
+xorxorSingleInteger,
+and NotNotSingleInteger
+provide bit level operations on small integers.
+
+
+
+
+
+
+
+And(3,4)$SingleInteger
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SingleInteger
+
+
+
+
+
Use shift(int,numToShift) to shift bits, where i is
+shifted left if numToShift is positive, right if negative.
+
+
+
+
+
+
+
+shift(1,4)$SingleInteger
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SingleInteger
+
+
+
+
+
+
+
+
+shift(31,-1)$SingleInteger
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SingleInteger
+
+
+
+
+
Many other operations are available for small integers, including many
+of those provided for Integer. To see the other operations, use
+the Browse HyperDoc facility (ugBrowsePage in Section
+ugBrowseNumber ).
+
These values can be retrieved as usual, but if a look up fails the
+default entry will be returned.
+
+
+
+
+
+
+
+t.3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
+
+
+
+t.2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
To see which values are explicitly stored, the
+keyskeysSparseTable and entriesentriesSparseTable
+functions can be used.
+
+
+
+
+
+
+
+keys t
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
+
+
+
+entries t
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List String
+
+
+
+
+
If a specific table representation is required, the
+GeneralSparseTable constructor should be used. The domain
+SparseTable(K, E, dflt) is equivalent to
+GeneralSparseTable(K,E,Table(K,E), dflt).
+For more information, see
+TableXmpPage and
+GeneralSparseTableXmpPage .
+
+The top level matrix type in Axiom is Matrix (see
+MatrixXmpPage ), which provides
+basic arithmetic and linear algebra functions. However, since the
+matrices can be of any size it is not true that any pair can be added
+or multiplied. Thus Matrix has little algebraic structure.
+
+Sometimes you want to use matrices as coefficients for polynomials
+or in other algebraic contexts. In this case, SquareMatrix
+should be used. The domain SquareMatrix(n,R) gives the ring of
+n by n square matrices over R.
+
+Since SquareMatrix is not normally exposed at the top level,
+you must expose it before it can be used.
+
+
+
+
+
+
+
+)set expose add constructor SquareMatrix
+
+
+
+
+
+
+
+ SquareMatrix is now explicitly exposed in frame G82322
+
+
+
+
+
Once SQMATRIX has been exposed, values can be created using the
+squareMatrixsquareMatrixSquareMatrix function.
+
+
+
+
+
+
+
+m := squareMatrix [ [1,-%i],[%i,4] ]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SquareMatrix(2,Complex Integer)
+
+
+
+
+
The usual arithmetic operations are available.
+
+
+
+
+
+
+
+m*m - m
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: SquareMatrix(2,Complex Integer)
+
+
+
+
+
Square matrices can be used where ring elements are required.
+For example, here is a matrix with matrix entries.
+
The SquareFreeRegularTriangularSet domain constructor implements
+square-free regular triangular sets. See the
+RegularTriangularSet domain constructor for general regular
+triangular sets. Let T be a regular triangular set consisting
+of polynomials t1, ..., tm ordered by increasing main variables.
+The regular triangular set T is square-free if T is empty
+or if t1, ..., tm-1 is square-free and if the polynomial
+tm is square-free as a univariate polynomial with coefficients in the
+tower of simple extensions associated with t1, ..., tm-1.
+
+
+
+
The main interest of square-free regular triangular sets is that their
+associated towers of simple extensions are product of fields.
+Consequently, the saturated ideal of a square-free regular triangular
+set is radical. This property simplifies some of the operations
+related to regular triangular sets. However, building square-free
+regular triangular sets is generally more expensive than building
+general regular triangular sets.
+
+
+
+
As the RegularTriangularSet domain constructor, the
+SquareFreeRegularTriangularSet domain constructor also implements a
+method for solving polynomial systems by means of regular triangular
+sets. This is in fact the same method with some adaptations to take
+into account the fact that the computed regular chains are
+square-free. Note that it is also possible to pass from a
+decomposition into general regular triangular sets to a decomposition
+into square-free regular triangular sets. This conversion is used
+internally by the LazardSetSolvingPackage package constructor.
+
+
+
+
N.B. When solving polynomial systems with the
+SquareFreeRegularTriangularSet domain constructor or the
+LazardSetSolvingPackage package constructor, decompositions have no
+redundant components. See also LexTriangularPackage and
+ZeroDimensionalSolvePackage for the case of algebraic systems with a
+finite number of (complex) solutions.
+
+
+
+
We shall explain now how to use the constructor
+SquareFreeRegularTriangularSet.
+
+
+
+
This constructor takes four arguments.
+The first one, R, is the coefficient ring of the polynomials;
+it must belong to the category GcdDomain.
+The second one, E, is the exponent monoid of the polynomials;
+it must belong to the category OrderedAbelianMonoidSup.
+the third one, V, is the ordered set of variables;
+it must belong to the category OrderedSet.
+The last one is the polynomial ring;
+it must belong to the category RecursivePolynomialCategory(R,E,V).
+The abbreviation for SquareFreeRegularTriangularSet is
+SREGSET.
+
+
+
+
Note that the way of understanding triangular decompositions
+is detailed in the example of the RegularTriangularSet
+constructor.
+
+
+
+
Let us illustrate the use of this constructor with one example
+(Donati-Traverso). Define the coefficient ring.
+
A Stream object is represented as a list whose last element
+contains the wherewithal to create the next element, should it ever be
+required.
+
+
+
+
Let ints be the infinite stream of non-negative integers.
+
+
+
+
+
+
+
+ints := [i for i in 0..]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream NonNegativeInteger
+
+
+
+
+
By default, ten stream elements are calculated. This number may be
+changed to something else by the system command )set streams
+calculate. For the display purposes of this book, we have chosen a
+smaller value.
+
+
+
+
More generally, you can construct a stream by specifying its initial
+value and a function which, when given an element, creates the next element.
+
+
+
+
+
+
+
+f : List INT -> List INT
+
+
+
+
+
+
+
+Void
+
+
+
+
+
+
+
+
+f x == [x.1 + x.2, x.1]
+
+
+
+
+
+
+
+Void
+
+
+
+
+
+
+
+
+fibs := [i.2 for i in [generate(f,[1,1])]]
+
+
+
+
+
+
+
+ Compiling function f with type List Integer -> List Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream Integer
+
+
+
+
+
You can create the stream of odd non-negative integers by either filtering
+them from the integers, or by evaluating an expression for each integer.
+
+
+
+
+
+
+
+[i for i in ints | odd? i]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream NonNegativeInteger
+
+
+
+
+
+
+
+
+odds := [2*i+1 for i in ints]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream NonNegativeInteger
+
+
+
+
+
You can accumulate the initial segments of a stream using the
+scanscanStreamFunctions2 operation.
+
+
+
+
+
+
+
+scan(0,+,odds)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream NonNegativeInteger
+
+
+
+
+
The corresponding elements of two or more streams can be combined in
+this way.
+
+
+
+
+
+
+
+[i*j for i in ints for j in odds]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream NonNegativeInteger
+
+
+
+
+
+
+
+
+map(*,ints,odds)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Stream NonNegativeInteger
+
+
+
+
+
Many operations similar to those applicable to lists are available for
+streams.
+
The type String provides character strings. Character strings
+provide all the operations for a one-dimensional array of characters,
+plus additional operations for manipulating text. For more
+information on related topics, see
+CharacterXmpPage and
+CharacterClassXmpPage .
+You can also issue the system command
+)show String to display the full list of operations defined
+by String.
+
+
+
+
String values can be created using double quotes.
+
+
+
+
+
+
+
+hello := "Hello AXIOM!"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
Note, however, that double quotes and underscores must be preceded by
+an extra underscore.
+
It is also possible to use newnewString to create a
+string of any size filled with a given character. Since there are
+many new functions it is necessary to indicate the desired type.
+
+
+
+
+
+
+
+gasp: String := new(32, char "x")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
The length of a string is given by #.
+
+
+
+
+
+
+
+ #gasp
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Indexing operations allow characters to be extracted or replaced in strings.
+For any string s, indices lie in the range 1.. #s.
+
+
+
+
+
+
+
+hello.2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Character
+
+
+
+
+
Indexing is really just the application of a string to a subscript,
+so any application syntax works.
+
+
+
+
+
+
+
+hello 2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Character
+
+
+
+
+
+
+
+
+hello(2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Character
+
+
+
+
+
If it is important not to modify a given string, it should be copied
+before any updating operations are used.
+
+
+
+
+
+
+
+hullo := copy hello
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
+
+
+
+hullo.2 := char "u"; [hello, hullo]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List String
+
+
+
+
+
Operations are provided to split and join strings. The
+concatconcatString operation allows several strings to be
+joined together.
+
+
+
+
+
+
+
+saidsaw := concat ["alpha","---","omega"]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
There is a version of concatconcatString that works with
+two strings.
+
+
+
+
+
+
+
+concat("hello ","goodbye")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
Juxtaposition can also be used to concatenate strings.
+
Substrings are obtained by giving an index range.
+
+
+
+
+
+
+
+hello(1..5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
+
+
+
+hello(8..)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
A string can be split into several substrings by giving a separation
+character or character class.
+
+
+
+
+
+
+
+split(hello, char " ")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List String
+
+
+
+
+
+
+
+
+other := complement alphanumeric();
+
+
+
+
+
+
+
+Type: CharacterClass
+
+
+
+
+
+
+
+
+split(saidsaw, other)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List String
+
+
+
+
+
Unwanted characters can be trimmed from the beginning or end of a string
+using the operations trimtrimString, leftTrimleftTrimString
+and rightTrimrightTrimString.
+
+
+
+
+
+
+
+trim(" # # ++ relax ++ # #", char " #")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
Each of these functions takes a string and a second argument to specify
+the characters to be discarded.
+
+
+
+
+
+
+
+trim(" # # ++ relax ++ # #", other)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
The second argument can be given either as a single character or as a
+character class.
+
+
+
+
+
+
+
+leftTrim (" # # ++ relax ++ # #", other)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
+
+
+
+rightTrim(" # # ++ relax ++ # #", other)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
Strings can be changed to upper case or lower case using the
+operations upperCaseupperCaseString,
+upperCase!upperCase!String, lowerCaselowerCaseString and
+lowerCase!lowerCase!String.
+
+
+
+
+
+
+
+upperCase hello
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
The versions with the exclamation mark change the original string,
+while the others produce a copy.
+
+
+
+
+
+
+
+lowerCase hello
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
Some basic string matching is provided. The function
+prefix?prefix?String tests whether one string is an initial
+prefix of another.
+
+
+
+
+
+
+
+prefix?("He", "Hello")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+prefix?("Her", "Hello")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
A similar function, suffix?suffix?String, tests for suffixes.
+
+
+
+
+
+
+
+suffix?("", "Hello")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+suffix?("LO", "Hello")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
The function substring?substring?String tests for a substring
+given a starting position.
+
+
+
+
+
+
+
+substring?("ll", "Hello", 3)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+substring?("ll", "Hello", 4)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
A number of positionpositionString functions locate things in strings.
+If the first argument to position is a string, then position(s,t,i)
+finds the location of s as a substring of t starting the
+search at position i.
+
+
+
+
+
+
+
+n := position("nd", "underground", 1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+n := position("nd", "underground", n+1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
If s is not found, then 0 is returned (minIndex(s)-1
+in IndexedString).
+
+
+
+
+
+
+
+n := position("nd", "underground", n+1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: NonNegativeInteger
+
+
+
+
+
To search for a specific character or a member of a character class,
+a different first argument is used.
+
This domain provides a table type in which the keys are known to be
+strings so special techniques can be used. Other than performance,
+the type StringTable(S) should behave exactly the same way as
+Table(String,S). See TableXmpPage
+for general information about tables.
+
+
+
+
This creates a new table whose keys are strings.
+
+
+
+
+
+
+
+t: StringTable(Integer) := table()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: StringTable Integer
+
+
+
+
+
The value associated with each string key is the number of characters
+in the string.
+
+
+
+
+
+
+for s in split("My name is Ian Watt.",char " ")
+ repeat
+ t.s := #s
+
+
+
+
+
+
+Void
+
+
+
+
+
+
+
+
+for key in keys t repeat output [key, t.key]
+
+
+Symbols are one of the basic types manipulated by Axiom. The
+Symbol domain provides ways to create symbols of many varieties.
+
+
+
+
The simplest way to create a symbol is to ``single quote'' an identifier.
+
+
+
+
+
+
+
+X: Symbol := 'x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Symbol
+
+
+
+
+
This gives the symbol even if x has been assigned a value. If
+x has not been assigned a value, then it is possible to omit the
+quote.
+
+
+
+
+
+
+
+XX: Symbol := x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Symbol
+
+
+
+
+
Declarations must be used when working with symbols, because otherwise
+the interpreter tries to place values in a more specialized type
+Variable.
+
+
+
+
+
+
+
+A := 'a
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Variable a
+
+
+
+
+
+
+
+
+B := b
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Variable b
+
+
+
+
+
The normal way of entering polynomials uses this fact.
+
+
+
+
+
+
+
+x**2 + 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
Another convenient way to create symbols is to convert a string.
+This is useful when the name is to be constructed by a program.
+
+
+
+
+
+
+
+"Hello"::Symbol
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Symbol
+
+
+
+
+
Sometimes it is necessary to generate new unique symbols, for example,
+to name constants of integration. The expression new()
+generates a symbol starting with %.
+
+
+
+
+
+
+
+new()$Symbol
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Symbol
+
+
+
+
+
Successive calls to newnewSymbol produce different symbols.
+
+
+
+
+
+
+
+new()$Symbol
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Symbol
+
+
+
+
+
The expression new("s") produces a symbol starting with %s.
+
+
+
+
+
+
+
+new("xyz")$Symbol
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Symbol
+
+
+
+
+
A symbol can be adorned in various ways. The most basic thing is
+applying a symbol to a list of subscripts.
+
+
+
+
+
+
+
+X[i,j]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Symbol
+
+
+
+
+
Somewhat less pretty is to attach subscripts, superscripts or arguments.
+
+
+
+
+
+
+
+U := subscript(u, [1,2,1,2])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Symbol
+
+
+
+
+
+
+
+
+V := superscript(v, [n])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Symbol
+
+
+
+
+
+
+
+
+P := argscript(p, [t])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Symbol
+
+
+
+
+
It is possible to test whether a symbol has scripts using the
+scripted?scripted?Symbol test.
+
+
+
+
+
+
+
+scripted? U
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+scripted? X
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
If a symbol is not scripted, then it may be converted to a string.
+
+
+
+
+
+
+
+string X
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
The basic parts can always be extracted using the
+namenameSymbol and scriptsscriptsSymbol
+operations.
+
+
+
+
+
+
+
+name U
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Symbol
+
+
+
+
+
+
+
+
+scripts U
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type:
+Record(
+sub: List OutputForm,
+sup: List OutputForm,
+presup: List OutputForm,
+presub: List OutputForm,
+args: List OutputForm)
+
+
+
+
+
+
+
+
+name X
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Symbol
+
+
+
+
+
+
+
+
+scripts X
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type:
+Record(
+sub: List OutputForm,
+sup: List OutputForm,
+presup: List OutputForm,
+presub: List OutputForm,
+args: List OutputForm)
+
+
+
+
+
The most general form is obtained using the
+scriptscriptSymbol operation. This operation takes an
+argument which is a list containing, in this order, lists of
+subscripts, superscripts, presuperscripts, presubscripts and arguments
+to a symbol.
+
The members of the domain Character are values
+representing letters, numerals and other text elements.
+For more information on related topics, see
+CharacterClassXmpPage and
+StringXmpPage .
+
+
+
+
Characters can be obtained using String notation.
+
Certain characters are available by name.
+This is the blank character.
+
+
+
+
+
+
+
+space()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Character
+
+
+
+
+
This is the quote that is used in strings.
+
+
+
+
+
+
+
+quote()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Character
+
+
+
+
+
This is the escape character that allows quotes and other characters
+within strings.
+
+
+
+
+
+
+
+escape()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Character
+
+
+
+
+
Characters are represented as integers in a machine-dependent way.
+The integer value can be obtained using the
+ordordCharacter operation. It is always true that char(ord c) = c and ord(char i) = i, provided that i is
+in the range 0..size()$Character-1.
+
+
+
+
+
+
+
+[ord c for c in chars]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+The lowerCaselowerCaseCharacter operation converts an upper
+case letter to the corresponding lower case letter. If the argument
+is not an upper case letter, then it is returned unchanged.
+
+
+
+
+
+
+
+[upperCase c for c in chars]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Character
+
+
+
+
+
Likewise, the upperCaseupperCaseCharacter operation converts lower
+case letters to upper case.
+
+
+
+
+
+
+
+[lowerCase c for c in chars]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Character
+
+
+
+
+
A number of tests are available to determine whether characters
+belong to certain families.
+
The Table constructor provides a general structure for
+associative storage. This type provides hash tables in which data
+objects can be saved according to keys of any type. For a given
+table, specific types must be chosen for the keys and entries.
+
+
+
+
In this example the keys to the table are polynomials with integer
+coefficients. The entries in the table are strings.
+
To save an entry in the table, the seteltseteltTable
+operation is used. This can be called directly, giving the table a
+key and an entry.
+
+
+
+
+
+
+
+setelt(t, x**2 - 1, "Easy to factor")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
Alternatively, you can use assignment syntax.
+
+
+
+
+
+
+
+t(x**3 + 1) := "Harder to factor"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
+
+
+
+t(x) := "The easiest to factor"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
Entries are retrieved from the table by calling the
+elteltTable operation.
+
+
+
+
+
+
+
+elt(t, x)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
This operation is called when a table is ``applied'' to a key using
+this or the following syntax.
+
+
+
+
+
+
+
+t.x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
+
+
+
+t x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
Parentheses are used only for grouping. They are needed if the key is
+an infixed expression.
+
+
+
+
+
+
+
+t.(x**2 - 1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
Note that the elteltTable operation is used only when the
+key is known to be in the table---otherwise an error is generated.
+
+
+
+
+
+
+
+t (x**3 + 1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: String
+
+
+
+
+
You can get a list of all the keys to a table using the
+keyskeysTable operation.
+
+
+
+
+
+
+
+keys t
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Polynomial Integer
+
+
+
+
+
If you wish to test whether a key is in a table, the
+searchsearchTable operation is used. This operation returns
+either an entry or "failed".
+
+
+
+
+
+
+
+search(x, t)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(String,...)
+
+
+
+
+
+
+
+
+search(x**2, t)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union("failed",...)
+
+
+
+
+
The return type is a union so the success of the search can be tested
+using case.
+
+
+
+
+
+
+
+search(x**2, t) case "failed"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
The removeremoveTable operation is used to delete values from a
+table.
+
+
+
+
+
+
+
+remove!(x**2-1, t)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union(String,...)
+
+
+
+
+
If an entry exists under the key, then it is returned. Otherwise
+removeremoveTable returns "failed".
+
+
+
+
+
+
+
+remove!(x-1, t)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Union("failed",...)
+
+
+
+
+
The number of key-entry pairs can be found using the
+ # #Table operation.
+
+
+
+
+
+
+
+ #t
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Just as keyskeysTable returns a list of keys to the table,
+a list of all the entries can be obtained using the
+membersmembersTable operation.
+
+
+
+
+
+
+
+members t
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List String
+
+
+
+
+
A number of useful operations take functions and map them on to the
+table to compute the result. Here we count the entries which
+have ``Hard'' as a prefix.
+
+
+
+
+
+
+
+count(s: String +-> prefix?("Hard", s), t)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Other table types are provided to support various needs.
+\indent
+
+
+
+
+
+
+ AssociationList gives a list with a table view.
+This allows new entries to be appended onto the front of the list
+to cover up old entries.
+This is useful when table entries need to be stacked or when
+frequent list traversals are required.
+See AssociationListXmpPage
+for more information.
+
+
EqTable gives tables in which keys are considered
+equal only when they are in fact the same instance of a structure.
+See EqTableXmpPage for more information.
+
+
StringTable should be used when the keys are known to
+be strings.
+See StringTableXmpPage
+for more information.
+
+
SparseTable provides tables with default
+entries, so
+lookup never fails. The GeneralSparseTable constructor
+can be used to make any table type behave this way.
+See SparseTableXmpPage
+for more information.
+
+
KeyedAccessFile allows values to be saved in a file,
+accessed as a table.
+See KeyedAccessFileXmpPage
+for more information.
+
The domain TextFile allows Axiom to read and write
+character data and exchange text with other programs.
+This type behaves in Axiom much like a File of strings,
+with additional operations to cause new lines.
+We give an example of how to produce an upper case copy of a file.
+
The TwoDimensionalArray domain is used for storing data in a
+two dimensional data structure indexed by row and by column. Such an array
+is a homogeneous data structure in that all the entries of the array
+must belong to the same Axiom domain (although see
+ugTypesAnyNonePage in Section
+ugTypesAnyNoneNumber ). Each
+array has a fixed number of rows and columns specified by the user and
+arrays are not extensible. In Axiom, the indexing of two-dimensional
+arrays is one-based. This means that both the ``first'' row of an
+array and the ``first'' column of an array are given the index
+1. Thus, the entry in the upper left corner of an array is in
+position (1,1).
+
+
+
+
The operation newnewTwoDimensionalArray creates an array
+with a specified number of rows and columns and fills the components
+of that array with a specified entry. The arguments of this operation
+specify the number of rows, the number of columns, and the entry.
+
+
+
+
This creates a five-by-four array of integers, all of whose entries are
+zero.
+
+
+
+
+
+
+
+arr : ARRAY2 INT := new(5,4,0)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: TwoDimensionalArray Integer
+
+
+
+
+
The entries of this array can be set to other integers using the
+operation seteltseteltTwoDimensionalArray.
+
+
+
+
Issue this to set the element in the upper left corner of this array to
+17.
+
+
+
+
+
+
+
+setelt(arr,1,1,17)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Now the first element of the array is 17.
+
+
+
+
+
+
+
+arr
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: TwoDimensionalArray Integer
+
+
+
+
+
Likewise, elements of an array are extracted using the operation
+elteltTwoDimensionalArray.
+
+
+
+
+
+
+
+elt(arr,1,1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Another way to use these two operations is as follows. This sets the
+element in position (3,2) of the array to 15.
+
+
+
+
+
+
+
+arr(3,2) := 15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
This extracts the element in position (3,2) of the array.
+
+
+
+
+
+
+
+arr(3,2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The operations elteltTwoDimensionalArray and
+seteltseteltTwoDimensionalArray come equipped with an error
+check which verifies that the indices are in the proper ranges. For
+example, the above array has five rows and four columns, so if you ask
+for the entry in position (6,2) with arr(6,2) Axiom
+displays an error message. If there is no need for an error check,
+you can call the operations qeltqeltTwoDimensionalArray
+and qseteltqseteltTwoDimensionalArray which provide the same
+functionality but without the error check. Typically, these
+operations are called in well-tested programs.
+
+
+
+
The operations rowrowTwoDimensionalArray and
+columncolumnTwoDimensionalArray extract rows and columns,
+respectively, and return objects of OneDimensionalArray with the
+same underlying element type.
+
+
+
+
+
+
+
+row(arr,1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: OneDimensionalArray Integer
+
+
+
+
+
+
+
+
+column(arr,1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: OneDimensionalArray Integer
+
+
+
+
+
You can determine the dimensions of an array by calling the operations
+nrowsnrowsTwoDimensionalArray and
+ncolsncolsTwoDimensionalArray, which return the number of
+rows and columns, respectively.
+
+
+
+
+
+
+
+nrows(arr)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+ncols(arr)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
To apply an operation to every element of an array, use
+mapmapTwoDimensionalArray. This creates a new array.
+This expression negates every element.
+
+
+
+
+
+
+
+map(-,arr)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: TwoDimensionalArray Integer
+
+
+
+
+
This creates an array where all the elements are doubled.
+
+
+
+
+
+
+
+map((x +-> x + x),arr)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: TwoDimensionalArray Integer
+
+
+
+
+
To change the array destructively, use
+mapmapTwoDimensionalArray instead of
+mapmapTwoDimensionalArray. If you need to make a copy of
+any array, use copycopyTwoDimensionalArray.
+
+
+
+
+
+
+
+arrc := copy(arr)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: TwoDimensionalArray Integer
+
+
+
+
+
+
+
+
+map!(-,arrc)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: TwoDimensionalArray Integer
+
+
+
+
+
+
+
+
+arrc
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: TwoDimensionalArray Integer
+
+
+
+
+
+
+
+
+arr
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: TwoDimensionalArray Integer
+
+
+
+
+
Use member?member?TwoDimensionalArray to see if a given element
+is in an array.
+
+
+
+
+
+
+
+member?(17,arr)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+member?(10317,arr)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
To see how many times an element appears in an array, use
+countcountTwoDimensionalArray.
+
+
+
+
+
+
+
+count(17,arr)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
+
+
+
+count(0,arr)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
For more information about the operations available for TwoDimensionalArray, issue )show TwoDimensionalArray. For
+information on related topics, see
+MatrixXmpPage and
+OneDimensionalArrayXmpPage .
+
The domain constructor UnivariatePolynomial (abbreviated UP) creates domains of univariate polynomials in a specified
+variable. For example, the domain UP(a1,POLY FRAC INT) provides
+polynomials in the single variable a1 whose coefficients are
+general polynomials with rational number coefficients.
+
+
+
+
+
+
+
+
+
+
+
+
+
Restriction:
+
+
+
+
+
+
+
+
Axiom does not allow you to create types where
+UnivariatePolynomial is contained in the coefficient type of
+Polynomial. Therefore,
+UP(x,POLY INT) is legal but POLY UP(x,INT) is not.
+
+
+
+
+
+
+
+
.
+
+
+
+
+
+
+
+
+
+
UP(x,INT) is the domain of polynomials in the single
+variable x with integer coefficients.
+
+
+
+
+
+
+
+(p,q) : UP(x,INT)
+
+
+
+
+
+
+
+Void
+
+
+
+
+
+
+
+
+p := (3*x-1)**2 * (2*x + 8)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: UnivariatePolynomial(x,Integer)
+
+
+
+
+
+
+
+
+q := (1 - 6*x + 9*x**2)**2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: UnivariatePolynomial(x,Integer)
+
+
+
+
+
The usual arithmetic operations are available for univariate polynomials.
+
+
+
+
+
+
+
+p**2 + p*q
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: UnivariatePolynomial(x,Integer)
+
+
+
+
+
The operation leadingCoefficientleadingCoefficientUnivariatePolynomial
+extracts the coefficient of the term of highest degree.
+
+
+
+
+
+
+
+leadingCoefficient p
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The operation degreedegreeUnivariatePolynomial returns
+the degree of the polynomial.
+Since the polynomial has only one variable, the variable is not supplied
+to operations like degreedegreeUnivariatePolynomial.
+
+
+
+
+
+
+
+degree p
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The reductum of the polynomial, the polynomial obtained by subtracting
+the term of highest order, is returned by
+reductumreductumUnivariatePolynomial.
+
+
+
+
+
+
+
+reductum p
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: UnivariatePolynomial(x,Integer)
+
+
+
+
+
The operation gcdgcdUnivariatePolynomial computes the
+greatest common divisor of two polynomials.
+
+
+
+
+
+
+
+gcd(p,q)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: UnivariatePolynomial(x,Integer)
+
+
+
+
+
The operation lcmlcmUnivariatePolynomial computes the
+least common multiple.
+
+
+
+
+
+
+
+lcm(p,q)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: UnivariatePolynomial(x,Integer)
+
+
+
+
+
The operation resultantresultantUnivariatePolynomial computes
+the resultant of two univariate polynomials. In the case of p
+and q, the resultant is 0 because they share a common
+root.
+
+
+
+
+
+
+
+resultant(p,q)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: NonNegativeInteger
+
+
+
+
+
To compute the derivative of a univariate polynomial with respect to its
+variable, use DDUnivariatePolynomial.
+
+
+
+
+
+
+
+D p
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: UnivariatePolynomial(x,Integer)
+
+
+
+
+
Univariate polynomials can also be used as if they were functions. To
+evaluate a univariate polynomial at some point, apply the polynomial
+to the point.
+
+
+
+
+
+
+
+p(2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
The same syntax is used for composing two univariate polynomials, i.e.
+substituting one polynomial for the variable in another. This
+substitutes q for the variable in p.
+
+
+
+
+
+
+
+p(q)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: UnivariatePolynomial(x,Integer)
+
+
+
+
+
This substitutes p for the variable in q.
+
+
+
+
+
+
+
+q(p)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: UnivariatePolynomial(x,Integer)
+
+
+
+
+
To obtain a list of coefficients of the polynomial, use
+coefficientscoefficientsUnivariatePolynomial.
+
+
+
+
+
+
+
+l := coefficients p
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Integer
+
+
+
+
+
From this you can use gcdgcdUnivariatePolynomial and
+reducereduceList to compute the content of the polynomial.
+
+
+
+
+
+
+
+reduce(gcd,l)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Alternatively (and more easily), you can just call
+contentcontentUnivariatePolynomial.
+
+
+
+
+
+
+
+content p
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Note that the operation
+coefficientscoefficientsUnivariatePolynomial omits the zero
+coefficients from the list. Sometimes it is useful to convert a
+univariate polynomial to a vector whose -th position contains the
+degree i-1 coefficient of the polynomial.
+
+
+
+
+
+
+
+ux := (x**4+2*x+3)::UP(x,INT)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: UnivariatePolynomial(x,Integer)
+
+
+
+
+
To get a complete vector of coefficients, use the operation
+vectorisevectoriseUnivariatePolynomial, which takes a
+univariate polynomial and an integer denoting the length of the
+desired vector.
+
+
+
+
+
+
+
+vectorise(ux,5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Vector Integer
+
+
+
+
+
It is common to want to do something to every term of a polynomial,
+creating a new polynomial in the process.
+
+
+
+
This is a function for iterating across the terms of a polynomial,
+squaring each term.
+
+
+
+
+
+
+
+squareTerms(p) == reduce(+,[t**2 for t in monomials p])
+
+
+
+
+
+
+
+Void
+
+
+
+
+
Recall what p looked like.
+
+
+
+
+
+
+
+p
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: UnivariatePolynomial(x,Integer)
+
+
+
+
+
We can demonstrate squareTerms on p.
+
+
+
+
+
+
+
+squareTerms p
+
+
+
+
+
+
+
+Compiling function squareTerms with type
+ UnivariatePolynomial(x,Integer) ->
+ UnivariatePolynomial(x,Integer)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: UnivariatePolynomial(x,Integer)
+
+
+
+
+
When the coefficients of the univariate polynomial belong to a
+field,For example, when the coefficients are rational
+numbers, as opposed to integers. The important property of a field is
+that non-zero elements can be divided and produce another element. The
+quotient of the integers 2 and 3 is not another integer. it is
+possible to compute quotients and remainders.
+
When the coefficients are rational numbers or rational expressions, the
+operation quoquoUnivariatePolynomial computes the quotient
+of two polynomials.
+
One application of univariate polynomials is to see expressions in terms
+of a specific variable.
+
+
+
+
We start with a polynomial in a1 whose coefficients
+are quotients of polynomials in b1 and b2.
+
+
+
+
+
+
+
+t : UP(a1,FRAC POLY INT)
+
+
+
+
+
+
+
+Void
+
+
+
+
+
Since in this case we are not talking about using multivariate
+polynomials in only two variables, we use Polynomial.
+We also use Fraction because we want fractions.
+
We push all the variables into a single quotient of polynomials.
+
+
+
+
+
+
+
+u : FRAC POLY INT := t
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Fraction Polynomial Integer
+
+
+
+
+
Alternatively, we can view this as a polynomial in the variable
+This is a mode-directed conversion: you indicate
+as much of the structure as you care about and let Axiom
+decide on the full type and how to do the transformation.
+
The UniversalSegment domain generalizes Segment
+by allowing segments without a ``hi'' end point.
+
+
+
+
+
+
+
+pints := 1..
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: UniversalSegment PositiveInteger
+
+
+
+
+
+
+
+
+nevens := (0..) by -2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: UniversalSegment NonNegativeInteger
+
+
+
+
+
Values of type Segment are automatically converted to
+type UniversalSegment when appropriate.
+
+
+
+
+
+
+
+useg: UniversalSegment(Integer) := 3..10
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: UniversalSegment Integer
+
+
+
+
+
The operation hasHihasHiUniversalSegment is used to test
+whether a segment has a hi end point.
+
+
+
+
+
+
+
+hasHi pints
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+hasHi nevens
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
+
+
+
+hasHi useg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Boolean
+
+
+
+
+
All operations available on type Segment apply to UniversalSegment, with the proviso that expansions produce streams
+rather than lists. This is to accommodate infinite expansions.
+
The Vector domain is used for storing data in a one-dimensional
+indexed data structure. A vector is a homogeneous data structure in
+that all the components of the vector must belong to the same Axiom
+domain. Each vector has a fixed length specified by the user; vectors
+are not extensible. This domain is similar to the
+OneDimensionalArray domain, except that when the components of a
+Vector belong to a Ring, arithmetic operations are provided.
+For more examples of operations that are defined for both Vector
+and OneDimensionalArray, see
+OneDimensionalArrayXmpPage .
+
+
+
+
As with the OneDimensionalArray domain, a Vector can
+be created by calling the operation newnewVector, its components
+can be accessed by calling the operations elteltVector and
+qeltqeltVector, and its components can be reset by calling the
+operations seteltseteltVector and
+qseteltqseteltVector.
+
+
+
+
This creates a vector of integers of length 5 all of whose
+components are 12.
+
+
+
+
+
+
+
+u : VECTOR INT := new(5,12)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Vector Integer
+
+
+
+
+
This is how you create a vector from a list of its components.
+
+
+
+
+
+
+
+v : VECTOR INT := vector([1,2,3,4,5])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Vector Integer
+
+
+
+
+
Indexing for vectors begins at 1. The last element has index
+equal to the length of the vector, which is computed by
+ #.
+
+
+
+
+
+
+
+ #(v)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
This is the standard way to use elteltVector to extract
+an element. Functionally, it is the same as if you had typed elt(v,2).
+
+
+
+
+
+
+
+v.2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
This is the standard way to use seteltseteltVector to change
+an element. It is the same as if you had typed setelt(v,3,99).
+
+
+
+
+
+
+
+v.3 := 99
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Now look at v to see the change. You can use
+qeltqeltVector and qseteltqseteltVector (instead
+of elteltVector and seteltseteltVector,
+respectively) but only when you know that the index is within
+the valid range.
+
+
+
+
+
+
+
+v
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Vector Integer
+
+
+
+
+
When the components belong to a Ring, Axiom provides arithmetic
+operations for Vector. These include left and right scalar
+multiplication.
+
+
+
+
+
+
+
+5 * v
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Vector Integer
+
+
+
+
+
+
+
+
+v * 7
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Vector Integer
+
+
+
+
+
+
+
+
+w : VECTOR INT := vector([2,3,4,5,6])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Vector Integer
+
+
+
+
+
Addition and subtraction are also available.
+
+
+
+
+
+
+
+v + w
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Vector Integer
+
+
+
+
+
Of course, when adding or subtracting, the two vectors must have the same
+length or an error message is displayed.
+
When an expression is not in a value context, it is given type
+Void. For example, in the expression
+
+
+
+
+
+ r := (a; b; if c then d else e; f)
+
+
+
+values are used only from the
+subexpressions c and f: all others are thrown away. The
+subexpressions a, b, d and e are evaluated for
+side-effects only and have type Void. There is a unique value
+of type Void.
+
+
+
+
You will most often see results of type Void when you
+declare a variable.
+
+
+
+
+
+
+
+a : Integer
+
+
+
+
+
+
+
+Void
+
+
+
+
+
Usually no output is displayed for Void results.
+You can force the display of a rather ugly object by issuing
+)set message void on.
+
+
+
+
+
+
+
+)set message void on
+
+
+
+
+
+
+
+
+
+b : Fraction Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Void
+
+
+
+
+
+
+
+
+)set message void off
+
+
+
+
+
+
All values can be converted to type Void.
+
+
+
+
+
+
+
+3::Void
+
+
+
+
+
+
+
+Void
+
+
+
+
+
Once a value has been converted to Void, it cannot be recovered.
+
+
+
+
+
+
+
+% :: PositiveInteger
+
+
+
+
+
+
+
+Cannot convert from type Void to PositiveInteger for value "()"
+
The WuWenTsunTriangularSet domain constructor implements the
+characteristic set method of Wu Wen Tsun. This algorithm computes a
+list of triangular sets from a list of polynomials such that the
+algebraic variety defined by the given list of polynomials decomposes
+into the union of the regular-zero sets of the computed triangular
+sets. The constructor takes four arguments. The first one, R,
+is the coefficient ring of the polynomials; it must belong to the
+category IntegralDomain. The second one, E, is the
+exponent monoid of the polynomials; it must belong to the category
+OrderedAbelianMonoidSup. The third one, V, is the ordered
+set of variables; it must belong to the category OrderedSet.
+The last one is the polynomial ring; it must belong to the category
+RecursivePolynomialCategory(R,E,V). The abbreviation for
+WuWenTsunTriangularSet is WUTSET.
+
The RegularTriangularSet and
+SquareFreeRegularTriangularSet domain constructors, the
+LazardSetSolvingPackage package constructors as well as,
+SquareFreeRegularTriangularSet and
+ZeroDimensionalSolvePackage package constructors also provide
+operations to compute triangular decompositions of algebraic
+varieties. These five constructor use a special kind of
+characteristic sets, called regular triangular sets. These special
+characteristic sets have better properties than the general ones.
+Regular triangular sets and their related concepts are presented in
+the paper ``On the Theories of Triangular sets'' By P. Aubry, D. Lazard
+and M. Moreno Maza (to appear in the Journal of Symbolic Computation).
+The decomposition algorithm (due to the third author) available in the
+four above constructors provide generally better timings than the
+characteristic set method. In fact, the WUTSET constructor
+remains interesting for the purpose of manipulating characteristic
+sets whereas the other constructors are more convenient for solving
+polynomial systems.
+
+
+
+
Note that the way of understanding triangular decompositions
+is detailed in the example of the RegularTriangularSet
+constructor.
+
The XPolynomial domain constructor implements multivariate
+polynomials whose set of variables is Symbol. These variables
+do not commute. The only parameter of this construtor is the
+coefficient ring which may be non-commutative. However, coefficients
+and variables commute. The representation of the polynomials is
+recursive. The abbreviation for XPolynomial is XPOLY.
+
+
+
+
Other constructors like XPolynomialRing,
+XRecursivePolynomial as well as XDistributedPolynomial,
+LiePolynomial and XPBWPolynomial implement multivariate
+polynomials in non-commutative variables.
+
+
+
+
We illustrate now some of the facilities of the
+XPOLY domain constructor.
+
+
+
+
Define a polynomial ring over the integers.
+
+
+
+
+
+
+
+poly := XPolynomial(Integer)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
Define a first polynomial,
+
+
+
+
+
+
+
+pr: poly := 2*x + 3*y-5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: XPolynomial Integer
+
+
+
+
+
and a second one.
+
+
+
+
+
+
+
+pr2: poly := pr*pr
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: XPolynomial Integer
+
+
+
+
+
Rewrite pr in a distributive way,
+
+
+
+
+
+
+
+pd := expand pr
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: XDistributedPolynomial(Symbol,Integer)
+
+
+
+
+
compute its square,
+
+
+
+
+
+
+
+pd2 := pd*pd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: XDistributedPolynomial(Symbol,Integer)
+
+
+
+
+
and checks that:
+
+
+
+
+
+
+
+expand(pr2) - pd2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: XDistributedPolynomial(Symbol,Integer)
+
+
+
+
+
We define:
+
+
+
+
+
+
+
+qr := pr**3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: XPolynomial Integer
+
+
+
+
+
and:
+
+
+
+
+
+
+
+qd := pd**3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: XDistributedPolynomial(Symbol,Integer)
+
+
+
+
+
We truncate qd at degree 3:
+
+
+
+
+
+
+
+ trunc(qd,2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: XDistributedPolynomial(Symbol,Integer)
+
+
+
+
+
The same for qr:
+
+
+
+
+
+
+
+trunc(qr,2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: XPolynomial Integer
+
+
+
+
+
We define:
+
+
+
+
+
+
+
+Word := OrderedFreeMonoid Symbol
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
and:
+
+
+
+
+
+
+
+w: Word := x*y**2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: OrderedFreeMonoid Symbol
+
+
+
+
+
The we can compute the right-quotient of qr by r:
+
The CharacterClass domain allows classes of characters to be
+defined and manipulated efficiently.
+
+Character classes can be created by giving either a string or a list
+of characters.
+
The XPolynomialRing domain constructor implements generalized
+polynomials with coefficients from an arbitrary Ring (not
+necessarily commutative) and whose exponents are words from an
+arbitrary OrderedMonoid (not necessarily commutative too). Thus
+these polynomials are (finite) linear combinations of words.
+
+
+
+
This constructor takes two arguments. The first one is a Ring
+and the second is an OrderedMonoid. The abbreviation for
+XPolynomialRing is XPR.
+
+
+
+
Other constructors like XPolynomial, XRecursivePolynomial
+XDistributedPolynomial, LiePolynomial and
+XPBWPolynomial implement multivariate polynomials in non-commutative
+variables.
+
+
+
+
We illustrate now some of the facilities of the XPR domain constructor.
+
+
+
+
Define the free ordered monoid generated by the symbols.
+
+
+
+
+
+
+
+Word := OrderedFreeMonoid(Symbol)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
Define the linear combinations of these words with integer coefficients.
+
The ZeroDimensionalSolvePackage package constructor provides
+operations for computing symbolically the complex or real roots of
+zero-dimensional algebraic systems.
+
+
+
+
The package provides no multiplicity information (i.e. some
+returned roots may be double or higher) but only distinct roots are
+returned.
+
+
+
+
Complex roots are given by means of univariate representations of
+irreducible regular chains. These representations are computed by the
+univariateSolveunivariateSolveZeroDimensionalSolvePackage operation
+(by calling the InternalRationalUnivariateRepresentationPackage
+package constructor which does the job).
+
+
+
+
Real roots are given by means of tuples of coordinates lying in the
+RealClosure of the coefficient ring. They are computed by the
+realSolverealSolveZeroDimensionalSolvePackage and
+positiveSolvepositiveSolveZeroDimensionalSolvePackage operations.
+The former computes all the solutions of the input system with real
+coordinates whereas the later concentrate on the solutions with
+(strictly) positive coordinates. In both cases, the computations are
+performed by the RealClosure constructor.
+
+
+
+
Both computations of complex roots and real roots rely on triangular
+decompositions. These decompositions can be computed in two different
+ways. First, by a applying the
+zeroSetSplitzeroSetSplitRegularTriangularSet operation from the
+REGSET domain constructor. In that case, no Groebner bases are
+computed. This strategy is used by default. Secondly, by applying
+the zeroSetSplitzeroSetSplitLexTriangularPackage from
+LEXTRIPK. To use this later strategy with the operations
+univariateSolveunivariateSolveZeroDimensionalSolvePackage,
+realSolverealSolveZeroDimensionalSolvePackage and
+positiveSolvepositiveSolveZeroDimensionalSolvePackage one just
+needs to use an extra boolean argument.
+
+
+
+
Note that the way of understanding triangular decompositions
+is detailed in the example of the RegularTriangularSet
+constructor.
+
+
+
+
The ZeroDimensionalSolvePackage constructor takes three
+arguments. The first one R is the coefficient ring; it must
+belong to the categories OrderedRing, EuclideanDomain,
+CharacteristicZero and RealConstant. This means
+essentially that R is Integer or Fraction(Integer).
+The second argument ls is the list of variables involved in the
+systems to solve. The third one MUST BE concat(ls,s) where
+ s is an additional symbol used for the univariate representations.
+The abbreviation for ZeroDimensionalSolvePackage is ZDSOLVE.
+
+
+
+
We illustrate now how to use the constructor ZDSOLVE by two
+examples: the Arnborg and Lazard system and the L-3 system
+(Aubry and Moreno Maza). Note that the use of this package is also
+demonstrated in the example of the LexTriangularPackage
+constructor.
+
+
+
+
Define the coefficient ring.
+
+
+
+
+
+
+
+R := Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Domain
+
+
+
+
+
Define the lists of variables:
+
+
+
+
+
+
+
+ls : List Symbol := [x,y,z,t]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Symbol
+
+
+
+
+
and:
+
+
+
+
+
+
+
+ls2 : List Symbol := [x,y,z,t,new()$Symbol]
+
+
We see that the zeros of our regular chain are split into three components.
+This is due to the use of univariate polynomial factorization.
+
+
+
+
Each of these components consist of two parts. The first one is an
+irreducible univariate polynomial p(?) which defines a simple
+algebraic extension of the field of fractions of R. The second
+one consists of multivariate polynomials pol1(x,%A),
+ pol2(y,%A) and pol3(z,%A). Each of these polynomials involve
+two variables: one is an indeterminate x, y or z of
+the input system lp and the other is %A which represents
+any root of p(?). Recall that this %A is the last
+element of the third parameter of ZDSOLVE. Thus any complex
+root ? of p(?) leads to a solution of the input system
+ lp by replacing %A by this ? in pol1(x,%A),
+ pol2(y,%A) and pol3(z,%A). Note that the polynomials
+ pol1(x,%A), pol2(y,%A) and pol3(z,%A) have degree
+one w.r.t. x, y or z respectively. This is always
+the case for all univariate representations. Hence the operation
+ univariateSolve replaces a system of multivariate polynomials by a
+list of univariate polynomials, what justifies its name. Another
+example of univariate representations illustrates the
+LexTriangularPackage package constructor.
+
+
+
+
We now compute the solutions with real coordinates:
+
+
+
+
+
+
+
+lr := realSolve(lp)$pack
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List List RealClosure Fraction Integer
+
+
+
+
The number of real solutions for the input system is:
+
+
+
+
+
+
+
+ # lr
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: PositiveInteger
+
+
+
+
+
Each of these real solutions is given by a list of elements in
+RealClosure(R). In these 8 lists, the first element is a value of
+ z, the second of y and the last of x. This is
+logical since by setting the list of variables of the package to
+ [x,y,z,t] we mean that the elimination ordering on the variables is
+ t < z < y < x . Note that each system treated by the
+ZDSOLVE package constructor needs only to be zero-dimensional
+w.r.t. the variables involved in the system it-self and not
+necessarily w.r.t. all the variables used to define the package.
+
+
+
+
We can approximate these real numbers as follows.
+This computation takes between 30 sec. and 5 min, depending on your machine.
+
+
+
+
+
+
+
+[ [approximate(r,1/1000000) for r in point] for point in lr]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List List Fraction Integer
+
+
+
+
+
We can also concentrate on the solutions with real (strictly) positive
+coordinates:
+
+
+
+
+
+
+
+lpr := positiveSolve(lp)$pack
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List List RealClosure Fraction Integer
+
+
+
+
+
Thus we have checked that the input system has no solution with
+strictly positive coordinates.
+
+
+
+
Let us define another polynomial system (L-3).
+
+
+
+
+
+
+
+f0 := x**3 + y + z + t- 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
+
+
+
+f1 := x + y**3 + z + t -1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
+
+
+
+f2 := x + y + z**3 + t-1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
+
+
+
+f3 := x + y + z + t**3 -1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: Polynomial Integer
+
+
+
+
+
+
+
+
+lf := [f0, f1, f2, f3]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Type: List Polynomial Integer
+
+
+
+
+
First compute a decomposition into regular chains (i.e. regular
+triangular sets).
+
+
+ What kind of limit do you want to compute?:
+
+ A real limit
+
+ The limit as the variable approaches a real value along the real axis
+
+
+ A complex limit
+
+ The limit as the variable approaches a complex value along any path in
+ the complex plane.
+
+
diff --git a/src/axiom-website/hyperdoc/bcexpand.xhtml b/src/axiom-website/hyperdoc/bcexpand.xhtml
new file mode 100644
index 0000000..8da6e83
--- /dev/null
+++ b/src/axiom-website/hyperdoc/bcexpand.xhtml
@@ -0,0 +1,135 @@
+
+
+
+
+ Axiom Documentation
+
+
+
+
+
+your basic page text goes here.
+<>
+@
+\end{verbatim}
+There are several things to observe here:
+
+
Each page lives in its own subsection and its own chunk.
+
The pagename and the chunkname are the same
+
The chunk includes the @<>
+
The chunk includes the @<>
+
The chunk includes the @<>
+
+The default page layout cannot communicate with Axiom.
+
+\subsection{Communicating with Axiom}
+If your page needs to communicate with Axiom you need to add some
+information in the header of the page.
+The default page that talks to Axiom has the form:
+\begin{verbatim}
+\subsection{pagename.xhtml}
+@<>=
+@<>
+
+
+
+@<>
+
Page subtitle goes here
+
+your text goes here
+your communication blocks go here
+@<>
+\end{verbatim}
+
+\subsection{Handling statements with no free variables}
+Use a makeRequest call with a parameter of the id.
+Note that the div with id of ``ansXX'' will get replaced
+automatically and the ``ans'' prefix is required.
+\begin{verbatim}
+
+
+
+
+\end{verbatim}
+
+\subsection{Handling statements with free variables}
+Free variables exist are used in statements but they are defined in
+other statements. To make sure the free variables have the correct
+values you need to include an explicit list of the other ids that
+need to be executed {\sl before} this statement. You do this with
+a call to ``handleFree''. It expects a list, enclosed in brackets,
+of the ids to execute in order. Be certain that the current id is
+at the end of the list.
+\begin{verbatim}
+
+
+
+
+\end{verbatim}
+
+\subsection{Handling domain database lookups}
+Use an anchor tag of the form:
+\begin{verbatim}
+Vector
+\end{verbatim}
+This will be interpreted by Axiom to mean that you want to do a
+lookup on a domain, category, or package whose name follows the
+question mark. Note that the domain name should NOT be an abbreviation.
+
+\subsection{Handling )show domain}
+Use a block containing a showcall of the form:
+\begin{verbatim}
+
+
+
+
+\end{verbatim}
+Note that the ``)show'' must be at the beginning of the line
+and that there can only be one space between the word show and
+the following argument.
+
+\subsection{Handling lisp expressions}
+Use a block containing a lispcall of the form:
+
+
+
+
+Note that this works but you can easily blow away your Axiom
+session with random statements. Let the coder beware.
+
+\subsection{Handling expressions that have no output}
+Use the CSS class=``noresult'' tag on the input form.
+This causes the item to show up in black text. It is
+still executable and is generally executed by handleFree
+calls because it contains definitions. However, things like
+function definitions in Axiom return no interesting output
+so there is no point in clicking on them.
+\begin{verbatim}
+
+
+
+
+\end{verbatim}
+
+
+\section{Defined Pages}
+Every page in this file is extracted by the Makefile. This is the list
+of pages that will be extracted. It is organized roughly in the hierarchy
+that you see in the browser pages. This is convention and is not required.
+
+The page hierarchy (used by the Makefile) is:
+<>=
+PAGES=rootpage.xhtml \
+ commandline.xhtml \
+ basiccommand.xhtml \
+ tutorial.xhtml \
+ jenks.xhtml \
+ calculus.xhtml \
+ differentiate.xhtml \
+ indefiniteintegral.xhtml \
+ definiteintegral.xhtml \
+ basiclimit.xhtml \
+ reallimit.xhtml \
+ complexlimit.xhtml \
+ summation.xhtml \
+ bcmatrix.xhtml \
+ bcexpand.xhtml \
+ draw.xhtml \
+ draw2donevariable.xhtml \
+ draw2ddefinedcurve.xhtml \
+ draw2dpolynomialequation.xhtml \
+ draw3dtwovariable.xhtml \
+ draw3ddefinedtube.xhtml \
+ draw3ddefinedsurface.xhtml \
+ series.xhtml \
+ seriesexpand.xhtml \
+ taylorseries.xhtml \
+ laurentseries.xhtml \
+ puiseuxseries.xhtml \
+ solve.xhtml \
+ solvelinearequations.xhtml \
+ solvelinearmatrix.xhtml \
+ solvesystempolynomials.xhtml \
+ solvesinglepolynomial.xhtml \
+ topreferencepage.xhtml \
+ releasenotes.xhtml \
+ usersguidepage.xhtml \
+ aldorusersguidepage.xhtml \
+ foundationlibrarydocpage.xhtml \
+ topicspage.xhtml \
+ cats.xhtml \
+ dlmf.xhtml \
+ dlmfapproximations.xhtml \
+ dlmfasymptoticexpansions.xhtml \
+ dlmfbarnesgfunction.xhtml \
+ dlmfbetafunction.xhtml \
+ dlmfcontinuedfractions.xhtml \
+ dlmfdefinitions.xhtml \
+ dlmffunctionrelations.xhtml \
+ dlmfgraphics.xhtml \
+ dlmfinequalities.xhtml \
+ dlmfinfiniteproducts.xhtml \
+ dlmfintegrals.xhtml \
+ dlmfintegralrepresentations.xhtml \
+ dlmfmathematicalapplications.xhtml \
+ dlmfmethodsofcomputation.xhtml \
+ dlmfmultidimensionalintegral.xhtml \
+ dlmfnotation.xhtml \
+ dlmfphysicalapplications.xhtml \
+ dlmfpolygammafunctions.xhtml \
+ dlmfqgammaandbetafunctions.xhtml \
+ dlmfseriesexpansions.xhtml \
+ dlmfsums.xhtml \
+ dlmfsoftware.xhtml \
+ dlmfspecialvaluesandextrema.xhtml \
+ dlmftables.xhtml \
+ uglangpage.xhtml \
+ examplesexposedpage.xhtml \
+ ugsyscmdpage.xhtml \
+ operations.xhtml \
+ dblookup.xhtml \
+ dbcharacteristic.xhtml \
+ dbcomplexcomplex.xhtml \
+ dbcomplexconjugate.xhtml \
+ dbcomplexfactor.xhtml \
+ dbcompleximag.xhtml \
+ dbcomplexnorm.xhtml \
+ dbcomplexreal.xhtml \
+ dbcomplexdoublefloat.xhtml \
+ dbcomplexfloat.xhtml \
+ dbcomplexinteger.xhtml \
+ dbexpressioninteger.xhtml \
+ dbfractioninteger.xhtml \
+ dbfractionpolynomialinteger.xhtml \
+ dbopbinary.xhtml \
+ dbopacos.xhtml \
+ dbopacosh.xhtml \
+ dbopacot.xhtml \
+ dbopacoth.xhtml \
+ dbopacsc.xhtml \
+ dbopacsch.xhtml \
+ dbopaddmod.xhtml \
+ dbopairyai.xhtml \
+ dbopairybi.xhtml \
+ dbopapproximants.xhtml \
+ dbopasin.xhtml \
+ dbopasinh.xhtml \
+ dbopasec.xhtml \
+ dbopasech.xhtml \
+ dbopatan.xhtml \
+ dbopatanh.xhtml \
+ dbopbesseli.xhtml \
+ dbopbesselj.xhtml \
+ dbopbesselk.xhtml \
+ dbopbessely.xhtml \
+ dbopbeta.xhtml \
+ dbopcardinalnumber.xhtml \
+ dbopcoefficient.xhtml \
+ dbopcoefficients.xhtml \
+ dbopcoerce.xhtml \
+ dbopcolumn.xhtml \
+ dbopcompactfraction.xhtml \
+ dbopcomplexeigenvectors.xhtml \
+ dbopcomplexelementary.xhtml \
+ dbopcomplexintegrate.xhtml \
+ dbopcomplexlimit.xhtml \
+ dbopcomplexsolve.xhtml \
+ dbopcontent.xhtml \
+ dbopcontinuedfraction.xhtml \
+ dbopconvergents.xhtml \
+ dbopcopy.xhtml \
+ dbopcos.xhtml \
+ dbopcosh.xhtml \
+ dbopcot.xhtml \
+ dbopcoth.xhtml \
+ dbopcount.xhtml \
+ dbopcountableq.xhtml \
+ dbopcsc.xhtml \
+ dbopcsch.xhtml \
+ dbopcycleragits.xhtml \
+ dbopd.xhtml \
+ dbopdecimal.xhtml \
+ dbopdefiningpolynomial.xhtml \
+ dbopdegree.xhtml \
+ dbopdenom.xhtml \
+ dbopdeterminant.xhtml \
+ dbopdiagonalmatrix.xhtml \
+ dbopdigamma.xhtml \
+ dbopdigits.xhtml \
+ dbopdimension.xhtml \
+ dbopdivide.xhtml \
+ dbopeigenmatrix.xhtml \
+ dbopeigenvalues.xhtml \
+ dbopeigenvector.xhtml \
+ dbopeigenvectors.xhtml \
+ dbopelt.xhtml \
+ dbopeval.xhtml \
+ dbopevenq.xhtml \
+ dbopexp.xhtml \
+ dbopfactor.xhtml \
+ dbopfactorfraction.xhtml \
+ dbopfiniteq.xhtml \
+ dbopfirstdenom.xhtml \
+ dbopfirstnumer.xhtml \
+ dbopfractragits.xhtml \
+ dbopgamma.xhtml \
+ dbopgcd.xhtml \
+ dbophex.xhtml \
+ dbophorizconcat.xhtml \
+ dbophtrigs.xhtml \
+ dbophypergeometric0f1.xhtml \
+ dbopinteger.xhtml \
+ dbopintegrate.xhtml \
+ dbopinverse.xhtml \
+ dbopinvmod.xhtml \
+ dboplaurent.xhtml \
+ dboplcm.xhtml \
+ dbopleadingcoefficient.xhtml \
+ dbopleadingmonomial.xhtml \
+ dboplength.xhtml \
+ dboplimit.xhtml \
+ dboplog.xhtml \
+ dboploggamma.xhtml \
+ dbopmainvariable.xhtml \
+ dbopmap.xhtml \
+ dbopmapbang.xhtml \
+ dbopmatrix.xhtml \
+ dbopmax.xhtml \
+ dbopmemberq.xhtml \
+ dbopmin.xhtml \
+ dbopminimumdegree.xhtml \
+ dbopminus.xhtml \
+ dbopmonicdivide.xhtml \
+ dbopmulmod.xhtml \
+ dbopncols.xhtml \
+ dbopnew.xhtml \
+ dbopnorm.xhtml \
+ dbopnrows.xhtml \
+ dbopnthfractionalterm.xhtml \
+ dbopnthroot.xhtml \
+ dbopnullity.xhtml \
+ dbopnullspace.xhtml \
+ dbopnumberoffractionalterms.xhtml \
+ dbopnumer.xhtml \
+ dbopnumeric.xhtml \
+ dbopoperator.xhtml \
+ dboporthonormalbasis.xhtml \
+ dboppadicfraction.xhtml \
+ dboppartialfraction.xhtml \
+ dboppartialquotients.xhtml \
+ dboppattern.xhtml \
+ dboppermanent.xhtml \
+ dboppi.xhtml \
+ dbopplus.xhtml \
+ dboppolygamma.xhtml \
+ dboppositiveremainder.xhtml \
+ dbopprefixragits.xhtml \
+ dbopprimefactor.xhtml \
+ dboppuiseux.xhtml \
+ dbopqelt.xhtml \
+ dbopqseteltbang.xhtml \
+ dbopquatern.xhtml \
+ dbopquo.xhtml \
+ dbopradicaleigenvectors.xhtml \
+ dbopradicalsolve.xhtml \
+ dboprank.xhtml \
+ dbopratdenom.xhtml \
+ dboprealeigenvectors.xhtml \
+ dboprealelementary.xhtml \
+ dbopreduce.xhtml \
+ dbopreductum.xhtml \
+ dboprem.xhtml \
+ dbopresetvariableorder.xhtml \
+ dbopresultant.xhtml \
+ dboprootof.xhtml \
+ dboprootsimp.xhtml \
+ dboprootsof.xhtml \
+ dboprow.xhtml \
+ dboprowechelon.xhtml \
+ dbopsetcolumnbang.xhtml \
+ dbopsetelt.xhtml \
+ dbopseteltbang.xhtml \
+ dbopsetrowbang.xhtml \
+ dbopsetsubmatrixbang.xhtml \
+ dbopsimplify.xhtml\
+ dbopsec.xhtml \
+ dbopsech.xhtml \
+ dbopseries.xhtml \
+ dbopseriessolve.xhtml \
+ dbopsin.xhtml \
+ dbopsingleintegerand.xhtml \
+ dbopsingleintegernot.xhtml \
+ dbopsingleintegeror.xhtml \
+ dbopsingleintegerxor.xhtml \
+ dbopsinh.xhtml \
+ dbopsetvariableorder.xhtml \
+ dbopsolve.xhtml \
+ dbopsqrt.xhtml \
+ dbopstar.xhtml \
+ dbopstarstar.xhtml \
+ dbopsubmatrix.xhtml \
+ dbopsubmatrix.xhtml \
+ dbopsubmod.xhtml \
+ dboptan.xhtml \
+ dboptanh.xhtml \
+ dboptaylor.xhtml \
+ dboptimes.xhtml \
+ dboptotaldegree.xhtml \
+ dboptrace.xhtml \
+ dboptranspose.xhtml \
+ dboptrigs.xhtml \
+ dbopvariables.xhtml \
+ dbopvectorise.xhtml \
+ dbopvectorspace.xhtml \
+ dbopvertconcat.xhtml \
+ dbopwholepart.xhtml \
+ dbopwholeragits.xhtml \
+ dbopzeroof.xhtml \
+ dbopzerosof.xhtml \
+ dbpolynomialinteger.xhtml \
+ dbpolynomialfractioninteger.xhtml \
+ systemvariables.xhtml \
+ glossarypage.xhtml \
+ htxtoppage.xhtml \
+ refsearchpage.xhtml \
+ topicspage.xhtml \
+ numberspage.xhtml \
+ numintegers.xhtml \
+ numgeneralinfo.xhtml \
+ numfactorization.xhtml \
+ numfunctions.xhtml \
+ numexamples.xhtml \
+ numproblems.xhtml \
+ numfractions.xhtml \
+ numrationalnumbers.xhtml \
+ numquotientfields.xhtml \
+ nummachinefloats.xhtml \
+ numfloat.xhtml \
+ numcomplexnumbers.xhtml \
+ numfinitefields.xhtml \
+ numnumericfunctions.xhtml \
+ numcardinalnumbers.xhtml \
+ nummachinesizedintegers.xhtml \
+ numromannumerals.xhtml \
+ numcontinuedfractions.xhtml \
+ numpartialfractions.xhtml \
+ numquaternions.xhtml \
+ numoctonions.xhtml \
+ numrepeatingdecimals.xhtml \
+ numrepeatingbinaryexpansions.xhtml \
+ numrepeatinghexexpansions.xhtml \
+ numotherbases.xhtml \
+ polynomialpage.xhtml \
+ polybasicfunctions.xhtml \
+ polysubstitutions.xhtml \
+ polyfactorization.xhtml \
+ polyfactorization1.xhtml \
+ polyfactorization2.xhtml \
+ polyfactorization3.xhtml \
+ polyfactorization4.xhtml \
+ polygcdandfriends.xhtml \
+ polyroots.xhtml \
+ polyroots1.xhtml \
+ polyroots2.xhtml \
+ polyroots3.xhtml \
+ polyroots4.xhtml \
+ polyspecifictypes.xhtml \
+ polyspecifictypes1.xhtml \
+ factored.xhtml \
+ polyspecifictypes2.xhtml \
+ polyspecifictypes3.xhtml \
+ polyspecifictypes4.xhtml \
+ functionpage.xhtml \
+ funrationalfunctions.xhtml \
+ funalgebraicfunctions.xhtml \
+ funelementaryfunctions.xhtml \
+ funsimplification.xhtml \
+ funpatternmatching.xhtml \
+ funoperatoralgebra.xhtml \
+ equationpage.xhtml \
+ equsystemlinear.xhtml \
+ equdifferential.xhtml \
+ equdifferentiallinear.xhtml \
+ equdifferentialnonlinear.xhtml \
+ equdifferentialpowerseries.xhtml \
+ calculuspage.xhtml \
+ callimits.xhtml \
+ calderivatives.xhtml \
+ calintegrals.xhtml \
+ calmoreintegrals.xhtml \
+ callaplace.xhtml \
+ calseries.xhtml \
+ calseries1.xhtml \
+ calseries2.xhtml \
+ calseries3.xhtml \
+ calseries4.xhtml \
+ calseries5.xhtml \
+ calseries6.xhtml \
+ calseries7.xhtml \
+ calseries8.xhtml \
+ linalgpage.xhtml \
+ linintro.xhtml \
+ lincreate.xhtml \
+ linoperations.xhtml \
+ lineigen.xhtml \
+ linhilbert.xhtml \
+ linpermaent.xhtml \
+ linvectors.xhtml \
+ linsquarematrices.xhtml \
+ lin1darrays.xhtml \
+ lin2darrays.xhtml \
+ linconversion.xhtml \
+ graphicspage.xhtml \
+ graphexamples.xhtml \
+ graph2d.xhtml \
+ graph3d.xhtml \
+ graphviewports.xhtml \
+ algebrapage.xhtml \
+ algnumbertheory.xhtml \
+ alggrouptheory.xhtml \
+ cryptopage.xhtml \
+ cryptoclass1.xhtml \
+ cryptoclass2.xhtml \
+ cryptoclass3.xhtml \
+ cryptoclass4.xhtml \
+ cryptoclass5.xhtml \
+ cryptoclass6.xhtml \
+ cryptoclass7.xhtml \
+ cryptoclass8.xhtml \
+ cryptoclass9.xhtml \
+ cryptoclass10.xhtml \
+ cryptoclass11.xhtml \
+ ocwmit18085.xhtml \
+ ocwmit18085lecture1.xhtml \
+ ocwmit18085lecture2.xhtml \
+ man0page.xhtml \
+ topexamplepage.xhtml \
+ topsettingspage.xhtml \
+ axiomfonts.xhtml \
+ pagelist.xhtml \
+ pagematrix.xhtml \
+ pageonedimensionalarray.xhtml \
+ pagepermanent.xhtml \
+ pageset.xhtml \
+ pagesquarematrix.xhtml \
+ pagetable.xhtml \
+ pagetwodimensionalarray.xhtml \
+ pagevector.xhtml
+
+@
+
+\section{The Standard Layout}
+Generally a page has a standard layout using a couple of chunks
+to minimize the typing. The defined chunks are:
+\begin{itemize}
+\item ``standard head'' which includes the head element, xmlns, meta, and
+title element. It also contains the ``style'' element for CSS information.
+\item ``page head'' contains the banner information
+\item ``page foot'' contains the trailing page information and the
+body-end and html-end tags
+\end{itemize}
+So the basic layout looks like
+\begin{verbatim}
+@<>
+ (local and general javascript goes here)
+
+
+@<>
+ (local page definition goes here)
+@<>
+\end{verbatim}
+So all you need to worry about are the actual page forms and the
+javascript to fetch those forms.
+
+For ``active pages'', that is those that communicate with Axiom
+they generally define a javascript function called ``commandline''
+which formats the request to be sent to the host. You also need to
+include the ``axiom talker'' chunk. Note that ``axiom talker''
+expects the ``commandline'' function to exist and calls it. Thus,
+for the page that handles differentiation calls to Axiom we add
+the local javascript:
+\begin{verbatim}
+
+
+
+\end{verbatim}
+This defined the ``commandline'' function and embeds the ``axiom talker''.
+The ``commandline'' function knows how to fetch fields from the rest of
+the page and format them into a single Axiom string. This is page
+specific code. For example, this shows a single input line which
+will be sent to the host when the ``Continue'' is pressed:
+\begin{verbatim}
+
+ @<>
+\end{verbatim}
+
+Note that the commandline function takes an argument which it gets
+from the caller, makeRequest. This argument can be used to distinguish
+which button was pressed.
+
+The {\bf div} section with {\bf id=``mathAns''} is replaced by the
+result sent from the server.
+
+\section{Cascading Style Sheet}
+This is the standard CSS style section that gets included with every
+page. We do this here but it could be a separate style sheet. It
+hardly matters either way as the style sheet is trivial.
+\begin{verbatim}
+\end{verbatim}
+<
+@
+
+\section{standard head}
+This is the standard head section. It is used on pages that do not
+include javascript. Note that it does NOT include the so
+the javascript can be added easily.
+<>=
+
+
+
+
+ Axiom Documentation
+<
+
+
+<>
+
abstract datatype
+ a programming language principle used in Axiom where a datatype is
+ defined in two parts: (1) a
public
part
+ describing a set of exports, principally operations
+ that apply to objects of that type, and (2) a
+
private
part describing the implementation of
+ the datatype usually in terms of a representation for
+ objects of the type. Programs which create and otherwise manipulate objects
+ of the type may only do so through its exports. The representation and
+ other implementation information is specifically hidden.
+
+
abstraction
+ described functionally or conceptually without regard to implementation
+
+
accuracy
+ the degree of exactness of an approximation or measurement. In computer
+ algebra systems, computations are typically carried out with complete
+ accuracy using integers or rational numbers of indefinite size. Domain
+
Float
provides a function
+
precision
from
+
Float
to change the precision for floating point
+ computations. Computations using
DoubleFloat
+ have a fixed precision but uncertain accuracy.
+
algorithm
+ a step-by-step procedure for a solution of a problem; a program
+
+
ancestor
+ (of a domain) a category which is a parent of the
+ domain, or a parent of a
+ parent and so on.
+
+
application
+
(syntax)
an expression denoting "application"
+ of a function to a set of argument parameters.
+ Applications are written as a parameterized form.
+ For example, the form
benefactor
+ (of a given domain) a domain or package that the given domain explicitly
+ references (for example, calls functions from) in its implementation
+
binding
+ the association of a variable with properties such as
+ value and type. The
+ top-level environment in the interpreter consists
+ of bindings for all user variables and functions. Every
+ function has an associated set of bindings, one
+ for each formal argument and
+ local variable.
+
+
block
+
(syntax)
a control structure where
+ expressions are sequentially evaluation.
+
built-in function
+ a function in the standard Axiom library.
+ Contrast user function.
+
+
cache
+
+
+ (noun) a mechanism for immediate retrieval of previously computed data.
+ For example, a function which does a lengthy computation might store
+ its values in a hash table using argument as a
+ key. The hash table then serves as a cache for the function (see also
+
capsule
+ the part of the function body of a
+ domain constructor that defines the functions
+ implemented by the constructor.
+
+
case
+
(syntax)
an operator used to
+ conditionally evaluate code based on the branch of a
+ Union. For example, if value
+
u
is
+
Union(Integer, "failed")
, the conditional
+ expression
if u case Integer then A else B
+ evaluate
A
if
u
is
+ an integer and
B
otherwise.
+
+
Category
+ the distinguished object denoting the type of a category; the class of
+ all categories.
+
+
category
+
(basic concept)
second-order types which
+ serve to define useful "classification worlds" for domains, such as
+ algebraic constructs (e.g. groups, rings, fields), and data structures
+ (e.g. homogeneous aggregates, collections, dictionaries). Examples of
+ categories are
Ring
("the class of all
+ rings") and
Aggregate
("the class of all
+ aggregates"). The categories of a given world are arranged in a
+ hierarchy (formally, a directed acyclic graph). Each category inherits
+ the properties of all its ancestors. Thus, for example, the category
+ of ordered rings (
OrderedRing
) inherits the
+ properties of the category of rings (
Ring
)
+ and those of the ordered sets
+ (
OrderedSet
). Categories provide a database of
+ algebraic knowledge and ensure mathematical correctness, e.g. that
+ "matrices of polynomials" is correct but "polynomials of hash tables"
+ is not, that the multiply operation for "polynomials of continued
+ fractions" is commutative, but that for "matrices of power series" is
+ not. optionally provide "default definitions" for operations they
+ export. Categories are defined in Axiom by functions called
+ category constructors. Technically, a category
+ designates a class of domains with common
+ operations and attributes but
+ usually with different functions and
+ representations for its constituent
+ objects. Categories are always defined using the
+ Axiom library language (see also
+ category extension).
+ See also file
catdef.spad
+ for definitions of basic algebraic categories in Axiom .
+
+
category constructor
+ a function that creates categories, described by an abstract
+ datatype in the Axiom programming language. For example, the category
+ constructor
Module
is a function which takes
+ a domain parameter
R
and creates the category
+ "modules over
R
".
+
+
category extension
+ created by a category definition, an expression usually of the form
+
A == B with ...
. In English, this means
+ "category A is a
B
with the new operations
+ and attributes as given by ... . See, for example, file
+
catdef.spad
for a definitions of the algebra
+ categories in Axiom ,
aggcat.spad
for data
+ structure categories.
+
+
category hierarchy
+ hierarchy formed by category extensions. The root category is
+
Object
. A category can be defined as a
+ Join of two or more categories so as to have
+ multiple parents. Categories may also have
+ parameterized so as to allow conditional inheritance.
+
+
character
+
+
+ an element of a character set, as represented by a keyboard key.
+
+
+ a component of a string. For example, the 0th element of the string
+
"hello there"
is the character
+
h
.
+
+
+
+
client
+ (of a given domain) any domain or package that explicitly calls
+ functions from the given domain
+
+
coercion
+ an automatic transformation of an object of one
+ type to an object of a similar or desired target
+ type. In the interpreter, coercions and
+ retractions are done automatically by the
+ interpreter when a type mismatch occurs. Compare
+ conversion.
+
+
comment
+ textual remarks imbedded in code. Comments are preceded by a double
+ dash (
--
). For Axiom library code,
+ stylized comments for on-line documentation are preceded by a two plus
+ signs (
++
).
+
+
Common LISP
+ A version of LISP adopted as an informal
+ standard by major users and suppliers of LISP
+
+
compile-time
+ the time when category or domain constructors are compiled. Contrast
+ run-time.
+
+
compiler
+ a program that generates low-level code from a higher-level source
+ language. Axiom has three compilers.
+
+
+ A
graphics
+ compiler
converts graphical formulas to a compiled subroutine so
+ that points can be rapidly produced for graphics commands.
+
computational object
+ In Axiom , domains are objects. This term is used to distinquish the
+ objects which are members of domains rather than domains themselves.
+
evaluates to
+ produce a value. When the value is not used,
+
else C
part can be omitted.
+
+
constant
+
(syntax)
a reserved word used in
+ signatures in Axiom programming language to signify
+ that mark an operation always returns the same value. For example, the
+ signature
0: constant -> $
in the source code
+ of
AbelianMonoid
tells the Axiom compiler
+ that
0
is a constant so that suitable
+ optimizations might be performed.
+
continuation
+ when a line of a program is so long that it must be broken into
+ several lines, then all but the first line are called
+
continuation lines
. If such a line is given
+ interactively, then each incomplete line must end with an underscore.
+
+
control structure
+ program structures which can specify a departure from normal
+ sequential execution. Axiom has four kinds of control structures:
+ blocks, case statements,
+ conditionals, and loops.
+
+
conversion
+ the transformation of an object on one type to
+ one of another type. Conversions performed automatically are called
+ coercions. These happen when the interpreter has a
+ type mismatch and a similar or declared target type is needed. In
+ general, the user must use the infix operation
+
::
to cause this transformation.
+
+
copying semantics
+ the programming language semantics used in Pascal but
+
to be of that
+ type. If a value is of a different type, the interpreter will try to
+ coerce the value to type
+
T
. Declarations are necessary in case of
+ ambiguity or when a user wants to introduce an an
+ unexposed domain.
+
+
default definition
+ a function defined by a category. Such
+ definitions appear category definitions of the form
+
C: Category == T add I
in an optional
+ implmentation part
I
to the right of the
+ keyword
add
.
+
+
default package
+ a optional package of
+ functions associated with a category. Such
+ functions are necessarily defined in terms over other functions
+ exported by the category.
+
.
+ See also macro where a similar
+ substitution is done at parse time.
+
+
+
+
delimiter
+ a character which marks the beginning or end of
+ some syntactically correct unit in the language, e.g. " for strings,
+ blanks for identifiers.
+
+
destructive operation
+ An operation which changes a component or structure of a value. In
+ Axiom , all destructive operations have names which end with an
+ exclamation mark (
!
). For example, domain
+
List
has two operations to reverse the
+ elements of a list, one named
reverse
+ from
List
which returns a copy of the
+ original list with the elements reversed, another named
+
reverse!
from
List
+ which reverses the elements
in place
thus
+ destructively changing the original list.
+
+
documentation
+
+
+ on-line or hard copy descriptions of Axiom;
+
+
+ text in library code preceded by
+
++
comments as opposed to general comments
+ preceded by
--
.
+
+
+
+
domain
+
(basic concept)
a domain corresponds to
+ the usual notion of abstract datatypes: that of a set of values and a
+ set of "exported operations" for the creation and manipulation of
+ these values. Datatypes are parameterized, dynamically constructed,
+ and can combine with others in any meaningful way, e.g. "lists of
+ floats" (
List Float
), "fractions of
+ polynomials with integer coefficients"
+ (
Fraction Polynomial Integer
),
+ "matrices of infinite streams of cardinal numbers"
+ (
Matrix Stream CardinalNumber
). The term
+
domain
is actually abbreviates
+
domain of computation
. Technically, a domain
+ denotes a class of objects, a class of
+ operations for creating and other manipulating
+ these objects, and a class of attributes
+ describing computationally useful properties. Domains also provide
+ functions for each operation often in terms of some
+ representation for the objects. A domain itself
+ is an object created by a
+ function called a domain
+ constructor.
+
+
domain constructor
+ a function that creates domains, described by an abstract datatype in
+ the Axiom programming language. Simple domains like
+
Integer
and
Boolean
are
+ created by domain constructors with no arguments. Most domain
+ constructors take one or more parameters, one usually denoting an
+ underlying domain. For example, the domain
+
Matrix(R)
denotes "matrices over
+
R"
. Domains
Mapping
,
+
Record
, and
+
Union
are primitive domains. All other domains
+ are written in the Axiom programming language and can be modified by
+ users with access to the library source code.
+
+
domain extension
+ a domain constructor
A
is said to
+
extend
a domain constructor
+
B
if
A
+
's
definition has the form
+
A == B add ...
.
+ This intuitively means "functions not defined by
A
are assumed to come from
+
B
". Successive domain extensions form
+ add-chains affecting the the
+ search order for functions not implemented directly
+ by the domain during dynamic lookup.
+
+
dot notation
+ using an infix dot (
.
) for function
+ application. If
u
is the list
+
[7, 4, -11]
then both
+
u(2)
and
u.2
return
+ 4. Dot notation nests to left. Thus
f . g . h
+ is equivalent to
(f . g) . h
.
+
+
dynamic
+ that which is done at run-time as opposed to
+ compile-time. For example, the interpreter will
+ build the domain "matrices over integers" dynamically in response to
+ user input. However, the compilation of all functions for matrices and
+ integers is done during compile-time. Constrast
+ static.
+
+
dynamic lookup
+ In Axiom , a domain may or may not explicitly
+ provide function definitions for all of its
+ exported operations. These definitions may
+ instead come from domains in the add-chain or
+ from default packages. When a
+ function call is made for an operation in the
+ domain, up to five steps are carried out.
+
+
+ If the domain itself implements a function for the operation,
+ that function is returned.
+
+
+ Each of the domains in the add-chain are searched
+ for one which implements the function; if found, the function is returned.
+
+
+ Each of the default packages for the domain are
+ searched in order of the lineage. If any of the
+ default packages implements the function, the first one found is
+ returned.
+
+
+ Each of the default packages for each of the
+ domains in the add-chain are searched in the
+ order of their lineage. If any of the default
+ packages implements the function, the first one found is returned.
+
+
If all of the above steps fail, an error message is reported.
+
evaluation
+ a systematic process which transforms an
+ expression into an object called the
+ value of the expression. Evaluation may produce
+ side effects.
+
+
exit
+
(reserved word)
an
+ operator which forces an exit from the current
+ block. For example, the block
+
(a := 1; if i > 0 then exit a; a := 2)
will
+ prematurely exit at the second statement with value 1 if the value of
+
a domain
+ which is ring where every non-zero element is
+ invertible and where
xy=yx
; a member of
+ category
Field
. For a complete list of
+ fields, click on
Domains
under
+
Cross Reference
for
+
Field
.
+
+
file
+ a program or collection of data stored on disk, tape or other medium.
+
+
float
+ a floating-point number with user-specified precision; an element of
+ domain
Float
. Floats are
+ literals which are written two ways: without an
+ exponent (e.g.
3.1416
), or with an exponent
+ (e.g.
3.12E-12
). Use function
+ precision to change the precision of the mantissage
+ (20 digits by default). See also small float.
+
+
formal parameter
+ (of a function) an identifier bound to the value
+ of an actual argument on
+ invocation. In the function definition
+
f(x, y) == u
, for example,
+
x
and
y
are the formal
+ parameter.
+
+
frame
+ the basic unit of an interactive session; each frame has its own
+ step number, environment, and
+ history. In one interactive session, users can
+ can create and drop frames, and have several active frames simultaneously.
+
+
free
+
(syntax)
A keyword used in user-defined
+ functions to declare that a variable is a
+ free variable of that function.
+ For example, the statement
+
free x
declares the variable
+
x
within the body of a function
+
f
to be a free variable in
+
f
. Without such a declaration, any variable
+
x
which appears on the left hand side of an
+ assignment is regarded as a local variable of
+ that function. If the intention of the assignment is to give an value
+ to a global variable
x
,
+ the body of that function must contain the statement
+
free x
.
+
+
free variable
+ (of a function) a variable which appears in a body of a function but
+ is not bound by that function. See
+ local variable by default.
+
+
function
+ implementation of operation; it takes zero or
+ more argument parameters and produces zero or
+ more values. Functions are objects which can be passed as parameters
+ to functions and can be returned as values of functions. Functions can
+ also create other functions (see also
+
are distinct notions in Axiom . An
+ operation is an abstraction of a function, described by declaring a
+ signature. A function is created by providing an
+ implementation of that operation by some piece of Axiom code. Consider
+ the example of defining a user-function
fact
+ to compute the
factorial
of a nonnegative
+ integer. The Axiom statement
+
fact: Integer -> Integer
+ describes the operation, whereas the statement
+
definition which is evaluated when the function
+ is called at run-time; the part of the function
+ definition to the right of the
==
.
+
+
function call
+
(syntax)
an expression denoting
+ "application" of a function to a set of argument
+ parameters. Applications are written as a
+ parameterized form. For example, the form
+
garbage collection
+ a system function that automatically recycles memory cells from the
+ heap. Axiom is built upon
+ Common LISP which provides this facility.
+
+
garbage collector
+ a mechanism for reclaiming storage in the heap.
+
+
Gaussian
+ a complex-valued expression, e.g. one with both a real and imaginary
+ part; a member of a
Complex
domain.
+
+
generic function
+ the use of one function to operate on objects of different types; One
+ might regard Axiom as supporting generic
+ operations but not generic functions. One operation
+
+: (D, D) -> D
exists for adding elements in
+ a ring; each ring however provides its own type-specific function for
+ implementing this operation.
+
+
global variable
+ A variable which can be referenced freely by functions. In Axiom ,
+ all top-level user-defined variables defined during an interactive
+ user session are global variables. Axiom does not allow
fluid variables
, that is, variables
+ bound by functions which can be referenced by
+ functions those functions call.
+
+
Groebner basis
+
(algebra)
a special basis for a
+ polynomial ideal that allows a simple test for membership. It is
+ useful in solving systems of polynomial equations.
+
+
group
+
(algebra)
a monoid
+ where every element has a multiplicative inverse.
+
+
hash table
+ A data structure that efficiency maps a given object to another. A
+ hash table consists of a set of
entries
,
+ each of which associates a
key
with a
+
value
. Finding the object stored under a key
+ can be very fast even if there are a large number of entries since
+ keys are
hashed
into numerical codes for
+ fast lookup.
+
+
heap
+ an area of storage used by data in programs. For example, AXIOM will
+ use the heap to hold the partial results of symbolic
+ computations. When cancellations occur, these results remain in the
+ heap until garbage collected.
+
+
history
+ a mechanism which records the results for an interactive
+ computation. Using the history facility, users can save computations,
+ review previous steps of a computation, and restore a previous
+ interactive session at some later time. For details, issue the system
+ command
. An
+ identifier begins with an alphabetical character or % and may be
+ followed by alphabetic characters, digits, ? or !. Certain
+ distinquished reserved words are not allowed as
+ identifiers but have special meaning in the Axiom .
+
+
immutable
+ an object is immutable if it cannot be changed by an
+ operation; not a mutable
+ object. Algebraic objects generally immutable: changing an
+ algebraic expression involves copying parts of the original
+ object. One exception is a matrix object of type
+
Matrix
. Examples of mutable objects are data
+ structures such as those of type
implicit export
+ (of a domain or category) any attribute or
+ operation which is either an explicit export or
+ else an explicit export of some category which an explicit category
+ export extends.
+
+
index
+
+
+ a variable that counts the number of times a
+ loop is repeated.
+
+
+ the "address" of an element in a data structure (see also category
+
, the class of integers with an unbounded
+ number of digits. Integer literals consist of one or more consecutive
+ digits (0-9) with no embedded blanks. Underscores can be used to
+ separate digits in long integers if desirable.
+
+
interactive
+ a system where the user interacts with the computer step-by-step
+
+
interpreter
+ the subsysystem of Axiom responsible for handling user input during
+ an interactive session. The following somewhat simplified description
+ of the typical action of the interpreter. The interpreter parsers the
+ user
's
input expression to create an
+ expression tree then does a bottom-up traversal of the tree. Each
+ subtree encountered which is not a value consists of a root node
+ denoting an operation name and one or more leaf nodes denoting
+ operands. The interpreter resolves type mismatches
+ and uses type-inferencing and a library database to determine
+ appropriate types of the operands and the result, and an operation to
+ be performed. The interpreter then builds a domain to perform the
+ indicated operation, then invokes a function from the domain to
+ compute a value. The subtree is then replaced by that value and the
+ process continues. Once the entire tree has been processed, the value
+ replacing the top node of the tree is displayed back to the user as
+ the value of the expression.
+
+
invocation
+ (of a function) the run-time process involved in
+ evaluating a function
+ application. This process has two steps. First, a
+ local environment is created where
+ formal arguments are locally
+ bound by assignment to their
+ respective actual argument. Second, the
+ function body is evaluated in that local
+ environment. The evaluation of a function is terminated either by
+ completely evaluating the function body or by the evaluation of a
+
return
expression.
+
+
iteration
+ repeated evaluation of an expression or a sequence of
+ expressions. Iterations use the reserved words
+
for
,
while
, and
+
repeat
.
+
+
Join
+ a primitive Axiom function taking two or more categories as arguments
+ and producing a category containing all of the operations and
+ attributes from the respective categories.
+
+
KCL
+ Kyoto Common LISP, a version of Common LISP
+ which features compilation of the compilation of LISP into the
+
C
Programming Language
+
+
library
+ In Axiom , a coolection of compiled modules respresenting the a
+ category or domain
+ constructor.
+
+
lineage
+ the sequence of default packages for a given
+ domain to be searched during
+ dynamic lookup.
+ This sequence is computed first by ordering the category
+ ancestors of the domain according to their
level number
, an integer equal to to the
+ minimum distance of the domain from the category. Parents have level
+ 1, parents of parents have level 2, and so on. Among categories with
+ equal level numbers, ones which appear in the left-most branches of
+
Join
s
in the
+ source code come first. See also dynamic lookup.
+
+
LISP
+ acronymn for List Processing Language, a language designed for the
+ manipulation of nonnumerical data. The Axiom library is translated
+ into LISP then compiled into machine code by an underlying LISP.
+
+
list
+ an object of a
List
domain.
+
+
literal
+ an object with a special syntax in the language. In Axiom , there are
+ five types of literals: booleans,
+ integers, floats,
+ strings, and symbols.
+
+
local
+
(syntax)
A keyword used in user-defined
+ functions to declare that a variable is a
+ local variable of that function.
+ Because of default assumptions on
+ variables, such a declaration is not necessary but is available to the
+ user for clarity when appropriate.
+
+
local variable
+ (of a function) a variable bound by that
+ function and such that its binding is invisible to any function that
+ function calls. Also called a
lexical
+ variable. By default in the interpreter:
+
+
+ any variable
x
which appears on the left hand
+ side of an assignment is regarded a local variable of that
+ function. If the intention of an assignment is to change the value of
+ a global variable
x
,
+ the body of the function must then contain the statement
+
free x
.
+
+
+ any other variable is regarded as a free variable.
+
+
+ An optional declaration
local x
is available
+ to explicitly declare a variable to be a local variable. All
+ formal parameters to the function can be regarded
+ as local variables to the function.
+
+
+
+
loop
+
+
an expression containing a
repeat
+
+
+ a collection expression having a
for
or a
+
while
, e.g.
+
[f(i) for i in S]
.
+
+
+
+
loop body
+ the part of a loop following the
repeat
+ that tells what to do each iteration. For example, the body of the
+ loop
for x in S repeat B
is
+
B
. For a collection expression, the body of the
+ loop precedes the initial
+ defines a parameterized macro expansion for a parameterized form
+
f
This macro causes a form
+
f
(
x
) to be textually
+ replaced by the expression
c
at parse time,
+ where
c
is the expression obtained by
+ replacing
a
by
x
+ everywhere in
b
. See also
+ definition where a similar substitution is done
+ during evaluation.
+
+
+
+
mode
+ a type expression containing a question-mark
+ (
?
). For example, the mode
+
P ?
designates
the class
+ of all polynomials over an arbitrary ring
.
+
+
monoid
+ is a set with a single, associative operation and an identity element
+
+
mutable
+ objects which contain pointers to other objects
+ and which have operations defined on them which alter these
+ pointers. Contrast immutable. Axiom uses
+ pointer semantics as does
+ LISP in contrast with many other languages such as
+ Pascal which use copying semantics. See
+ pointer semantics for details.
+
Object
+ a category with no operations or attributes, from which most categories
+ in Axiom are category extensions.
+
+
object
+ a data entity created or manipulated by programs. Elements of
+ domains, functions, and domains themselves are objects. Whereas
+ categories are created by functions, they cannot be dynamically
+ manipulated in the current system and are thus not considered as
+ objects. The most basic objects are literals;
+ all other objects must be created
+ functions. Objects can refer to other objects using
+ pointers. Axiom language uses
+ pointer semantics when dealing with
+ mutable objects.
+
+
object code
+ code which can be directly executed by hardware; also known as
+
machine language
.
+
+
operand
+ an argument of an operator (regarding an
+ operator as a function).
+
+
operation
+ an abstraction of a function, described by a
+ signature. For example,
+
overloading
+ the use of the same name to denote distinct functions; a function is
+ identified by a signature identifying its name,
+ the number and types of its arguments, and its return types. If two
+ functions can have identical signatures, a
+ package call must be made to distinquish the two.
+
+
package
+ a domain whose exported operations depend solely on the parameters
+ and other explicit domains, e.g. a package for solving systems of
+ equations of polynomials over any field, e.g. floats, rational
+ numbers, complex rational functions, or power series. Facilities for
+ integration, differential equations, solution of linear or polynomial
+ equations, and group theory are provided by "packages". Technically, a
+ package is a domain which has no signature
+ containing the symbol $. While domains intuitively provide
+ computational objects you can compute with, packages intuitively
+ provide functions (polymorphic functions) which
+ will work over a variety of datatypes.
+
parent
+ (of a domain) a category which is explicitly declared in the source
+ code definition for the domain to be an export
+ of the domain.
+
+
parse
+
+
+ (verb) to produce an internal representation of a user input string;
+ the resultant internal representation is then "interpreted" by Axiom
+ to perform some indicated action.
+
+
+ the transformation of a user input string representing a valid Axiom
+ expression into an internal representation as a tree-structure.
+
+
+
+
partially ordered set
+ a set with a reflexive, transitive and antisymetric
+ binary operation.
+
+
pattern
+ The left hand side of a rewrite rule is called a pattern. Rewrite rules
+ can be used to perform pattern matching, usually for simplification.
+ The right hand side of a rule is called the
+ substitution.
+
+
pattern match
+
+
+ (on expressions) Given a expression called a "subject"
+
u
, the attempt to rewrite
+
u
using a set of "rewrite rules". Each rule has
+ the form
A == B
where
+
A
indicates a expression called a "pattern" and
+
B
denotes a "replacement". The meaning of
+ this rule is "replace
A
by
+
B"
. If a given pattern
A
+ matches a subexpression of
u
, that
+ subexpression is replaced by
B
. Once
+ rewritten, pattern matching continues until no further changes occur.
+
+
+ (on strings) the attempt to match a string indicating a "pattern" to
+ another string called a "subject", for example, for the purpose of
+ identifying a list of names. In a browser, users may enter
+ search strings for the purpose of identifying
+ constructors, operations, and attributes.
+
+
+
+
pattern variable
+ In a rule a symbol which is not a recognized function acts as a
+ pattern variable and is free to match any subexpression.
+
+
pile
+ alternate syntax for a block, using indentation and column alignment
+ (see also block).
+
+
pointer
+ a reference implemented by a link directed from one object to another
+ in the computer memory. An object is said to
+
refer
to another if it has a pointer to that
+ other object. Objects can also refer to themselves (cyclic references
+ are legal). Also more than one object can refer to the same
+ object. See also pointer semantics.
+
+
pointer semantics
+ the programming language semantics used in languages such as LISP
+ which allow objects to be mutable. Consider the
+ following sequence of Axiom statements:
+
+
x : Vector Integer := [1, 4, 7]
+
+
y := x
+
+
swap!(x, 2, 3)
+
+
+ The function
swap!
from
+
Vector
is used to interchange the 2nd and 3rd
+ value in the list
x
producing the value
+
[1, 7, 4]
. What value does
+
y
have after evaluation of the third statement?
+ The answer is different in Axiom than it is in a language with
+ copying semantics. In Axiom , first the vector
+ [1, 2, 3] is created and the variable
refers to its
+ immutable components 1, 2, and 3. Next, the
+ variable
y
is made to point to
+
V
just as
x
does. Now the
+ third statement interchanges the last 2 elements of
+
V
(the
!
at the end of
+ the name
swap!
from
+
Vector
tells you that this operation is
+ destructive, that is, it changes the elements
in
+ place
). Both
x
and
+
y
perceive this change to
+
V
. Thus both
x
and
+
y
then have the value
+
[1, 7, 4]
.
+ In Pascal, the second statement causes a copy of
+
V
to be stored under
+
y
. Thus the change to
V
+ made by the third statement does not affect
+
y
.
+
+
polymorphic
+ a function parameterized by one or more
+ domains; a algorithm defined
+ categorically. Every function defined in a domain
+ or package constructor with a domain-valued parameter is
+ polymorphic. For example, the same matrix
+
*
function is used to multiply "matrices over
+ integers" as "matrices over matrices over integers"
+
+
postfix
+ an operator that follows its single
+ operand. Postfix operators are not available in
+ Axiom.
+
+
precedence
+
(syntax)
refers to the so-called
+
binding power
of an operator. For example,
+
*
has higher binding power than
+
+
so that the expression
+
a + b * c
is equivalent to
+
a + (b * c)
.
+
+
precision
+ the number of digits in the specification of a number, e.g. as set by
+
its single
+ operand. Every function of one argument can be used
+ as a prefix operator. For example, all of the following have
+ equivalent meaning in Axiom :
Record
+ (basic domain constructor) a domain constructor used to create a
+ inhomogeneous aggregate composed of pairs of "selectors" and
+ values. A Record domain is written in the form
+
Record(a1:D1, ..., an:Dn)
+ (
n
> 0) where
a1
, ...,
+
an
are identifiers called the
+
selectors
of the record, and
+
D1
, ...,
Dn
are domains
+ indicating the type of the component stored under selector
+
an
.
+
+
recurrence relation
+ A relation which can be expressed as a function
+
f
with some argument
n
+ which depends on the value of
f
at
+
k
previous values. In many cases, Axiom will
+ rewrite a recurrence relation on compilation so as to
+ cache its previous
k
values
+ and therefore make the computation significantly more efficient.
+
+
recursion
+ use of a self-reference within the body of a function. Indirect
+ recursion is when a function uses a function below it in the call
+ chain.
+
+
recursive
+
+
A function that calls itself, either directly or indirectly through
+ another function.
+
Rep
+ a special identifier used as local variable of
+ a domain constructor body to denote the representation domain for
+ objects of a domain.
+
+
representation
+ a domain providing a data structure for
+ elements of a domain; generally denoted by the special identifier
+ Rep in the Axiom programming language. As domains
+ are abstract datatypes, this representation is not
+ available to users of the domain, only to functions defined in the
+ function body for a domain constructor. Any domain
+ can be used as a representation.
+
+
reserved word
+ a special sequence of non-blank characters with special meaning in
+ the Axiom language. Examples of reserved words are names such as
+
for
,
if
, and
+
free
, operator names such as
+
+
and
mod
, special
+ character strings such as
==
and
+
:=
.
+
+
retraction
+ to move an object in a parameterized domain back to the underlying
+ domain, for example to move the object
7
from
+ a "fraction of integers"
+ (domain
Fraction Integer
) to
+ "the integers" (domain
Integer
).
+
+
return
+ when leaving a function, the value of the expression following
+
return
becomes the value of the function.
+
+
ring
+ a set with a commutative addition, associative multiplication, a unit
+ element, and multiplication distributes over addition and subtraction.
+
+
rule
+
(syntax)
1. An expression of the form
+
rule A == B
indicating a "rewrite
+ rule". 2. An expression of the form
+
run-time
+ the time of doing a computation. Contrast
+ compile-time. rather than prior to it;
+ dynamic as opposed to
+ static. For example, the decision of the intepreter
+ to build a structure such as "matrices with power series entries" in
+ response to user input is made at run-time.
+
+
run-time check
+ an error-checking which can be done only when the program receives
+ user input; for example, confirming that a value is in the proper
+ range for a computation.
+
+
search order
+ the sequence of default packages for a given
+ domain to be searched during dynamic
+ lookup. This sequence is computed first by ordering the category
+ ancestors of the domain according to their
+
level number
, an integer equal to to the
+ minimum distance of the domain from the category. Parents have level
+ 1, parents of parents have level 2, and so on. Among categories with
+ equal level numbers, ones which appear in the left-most branches of
+
Join
s
in the
+ source code come first. See also dynamic lookup.
+
+
search string
+ a string entered into an input area on a screen
+
+
selector
+ an identifier used to address a component value of a
+ Record datatype.
+
+
semantics
+ the relationships between symbols and their meanings. The rules for
+ obtaining the
meaning
of any syntactically
+ valid expression.
+
+
semigroup
+
(algebra)
a monoid
+ which need not have an identity; it is closed and associative.
+
+
side effect
+ action which changes a component or structure of a value. See
+ destructive operation for details.
+
+
signature
+
(syntax)
an expression describing an
+ operation. A signature has the form as
+
name : source -> target
, where
+
source
gives the type of the arguments of the
+ operation, and
target
gives the type of the
+ result.
+
+
small float
+ the domain for hardware floating point arithmetic as provided by the
+ computer hardware.
+
+
small integer
+ the domain for hardware integer arithmetic. as provided by the computer
+ hardware.
+
+
source
+ the type of the argument of a
+ function; the type expression before the
+
sparse
+ data structure whose elements are mostly identical (a sparse matrix
+ is one filled with mostly zeroes).
+
+
static
+ that computation done before run-time, such as compilation. Contrast
+ dynamic.
+
+
step number
+ the number which precedes user input lines in an interactive session;
+ the output of user results is also labeled by this number.
+
+
stream
+ an object of
Stream(R)
, a generalization of
+ a list to allow an infinite number of
+ elements. Elements of a stream are computed "on demand". Strings are
+ used to implement various forms of power series.
+
+
string
+ an object of domain
String
. Strings are
+ literals consisting of an arbitrary sequence of
+ characters surrounded by double-quotes
+ (
"
), e.g.
+
"Look here!"
.
+
+
subdomain
+
(basic concept)
a
+ domain together with a
+ predicate characterizing which members of the
+ domain belong to the subdomain. The exports of a subdomain are usually
+ distinct from the domain itself. A fundamental assumption however is
+ that values in the subdomain are automatically
+ coerceable to values in the domain. For example, if
+
n
and
m
are declared
+ to be members of a subdomain of the integers, then
+
. On the other
+ hand, if the result of that operation is to be assigned to, say,
+
k
, also declared to be of that subdomain, a
+ run-time check is generally necessary to ensure
+ that the result belongs to the subdomain.
+
+
substitution
+ The right hand side of a rule is called the substitution.
+ The left hand side of a rewrite rule is called a
+ pattern. Rewrite rules
+ can be used to perform pattern matching, usually for simplification.
+
+
such that clause
+ the use of
|
followed by an expression
+ to filter an iteration.
+
+
suffix
+
(syntax)
an
+ operator which placed after its operand. Suffix
+ operators are not allowed in the Axiom language.
+
+
symbol
+ objects denoted by identifier
+ literals; an element of domain
+
Symbol
. The interpreter defaultly converts a
+ symbol
x
into
+
Variable(x)
.
+
+
syntax
+ rules of grammar, punctuation etc. for forming correct expressions.
+
+
system commands
+ top-level Axiom statements that begin with
+
)
. System commands allow users to query the
+ database, read files, trace functions, and so on.
+
+
tag
+ an identifier used to discriminate a branch of a
+ Union type.
+
+
target
+ the type of the result of a
+ function; the type expression following the
+
).
+ A tuple is not a data structure, rather a
+ syntax mechanism for grouping expressions.
+
+
type
+ The type of any subdomain is the unique symbol
+
Category
. The type of a
+ domain is any category that
+ domain belongs to. The type of any other object is either the (unique)
+ domain that object belongs to or any subdomain
+ of that domain. The type of objects is in general not unique.
+
+
type checking
+ a system function which determines whether the datatype of an object is
+ appropriate for a given operation.
+
type inference
+ when the interpreter chooses the type for an object based on
+ context. For example, if the user interactively issues the definition
+
underlying domain
+ for a domain that has a single domain-valued
+ parameter, the
underlying domain
refers to
+ that parameter. For example, the domain "matrices of integers"
+ (
Matrix Integer
) has underlying domain
+
Integer
.
+
+
Union
+
(basic domain constructor)
a domain
+ constructor used to combine any set of domains into a single domain. A
+ Union domain is written in the form
+
Union(a1:D1,..., an:Dn)
+ (
n
> 0) where
+
a1
, ...,
an
are
+ identifiers called the
tags
of the union,
+ and
D1
, ...,
Dn
are
+ domains called the
branches
of the
+ union. The tags
ai
are optional, but required
+ when two of the
Di
are equal, e.g.
+
Union(inches:Integer, centimeters:Integer)
. In the
+ interpreter, values of union domains are automatically coerced to
+ values in the branches and vice-versa as appropriate. See also
+ case.
+
+
unit
+
(algebra)
an invertible element.
+
+
user function
+ a function defined by a user during an interactive session. Contrast
+ built-in function.
+
+
user variable
+ a variable created by the user at top-level during an interactive session
+
variable
+ a means of referring to an object but itself is not an object. A
+ variable has a name and an associated binding
+ created by evaluation of Axiom expressions such
+ as declarations,
+ assignments, and
+ definitions. In the top-level
+ environment of the interpreter, variables are
+ global variables. Such variables can be freely
+ referenced in user-defined functions although a
+ free declaration is needed to assign values to
+ them. See local variable for details.
+
+
Void
+ the type given when the value and type of an expression are not needed. Also used
+ when there is no guarantee at run-time that a value and predictable
+ mode will result.
+
+
wild card
+ a symbol which matches any substring including the empty string; for
+ example, the search string
*an*
matches an
+ word containing the consecutive letters
a
+ and
n
+
+
workspace
+ an interactive record of the user input and output held in an
+ interactive history file. Each user input and corresponding output
+ expression in the workspace has a corresponding step
+ number. The current output expression in the workspace is referred
+ to as
%
. The output expression associated
+ with step number
n
is referred to by
%%(n)
. The
k
-th previous
+ output expression relative to the current step number
n
is referred to by
%%(-
+ k)
. Each interactive frame has its own
+ workspace.
+
+
+<>
+@
+
+\subsection{graphexamples.xhtml}
+<>=
+<>
+
+
+<>
+ graphexamples not implemented
+<>
+@
+
+\subsection{graphicspage.xhtml}
+<>=
+<>
+
+
+<>
+Axiom can plot curves and surfaces of various types, as well as
+lists of points in the plane.
+
+ Enter the formula for the general coefficient of the series:
+
+
+
+
+
+
+
+
+
+ Enter the index variable for your formula:
+
+
+
+
+
+ Enter the power series variable:
+
+
+
+
+
+ Enter the point about which to expand:
+
+
+
+
+For Laurent Series, the exponent of the power series variable ranges
+from an initial value, an arbitrary integer value, to plus
+infinity; the step size is any positive integer.
+
+
+
+ Enter the initial value of the index (an integer):
+
+
+ Algebraic manipulations with matrices. Compute the inverse,
+ determinant, and trace of a matrix. Find the rank, nullspace,
+ and row echelon form of a matrix.
+
+
+There are many ways to create a matrix from a collection of values or
+from existing matrices.
+
+If the matrix has almost all items equal to the same value, use
+new to create a matrix filled with that value
+and then reset the entries that are different.
+
+
+
+
+
+
+To change the entry in the second row, third column to 5, use
+setelt.
+
+
+
+
+
+
+An alternative syntax is to use assignment.
+
+
+
+
+
+
+The matrix was destructively modified.
+
+
+
+
+
+
+If you already have the matrix entries as a list of lists, use
+matrix.
+
+
+In this section we show you some of Axiom's facilities for computing and
+manipulating eigenvalues and eigenvectors, also called characteristic
+values and characteristic vectors, respectively.
+
+Let's first create a matrix with integer entries.
+
+
+
+
+
+
+To get a list of the rational eigenvalues, use the operation
+eigenvalues.
+
+
+
+
+
+
+Given an explicit eigenvalue,
+eigenvector computes the eigenvectors
+corresponding to it.
+
+
+
+
+
+
+The operation eigenvectors returns a
+list of pairs of values and vectors. When an eigenvalue is rational, Axiom
+gives you the value explicitly; otherwise, its minimal polynomial is given,
+(the polynomial of lowest degree with the eigenvalues as roots), together
+with a parametric representation of the eigenvector using the eigenvalue.
+This means that if you ask Axiom to solve
+the minimal polynomial, then you can substitute these roots into the
+parametric form of the corresponding eigenvectors.
+
+You must be aware that unless an exact eigenvalue has been computed,
+the eigenvector may be badly in error.
+
+
+
+
+
+
+Another possibility is to use the operation
+radicalEigenvectors tries to
+compute explicitly the eignevectors in terms of radicals.
+
+
+
+
+
+
+Alternatively, Axiom can compute real or complex approximations to the
+eigenvectors and eigenvalues using the operations
+realEigenvectors or
+complexEigenvectors. They
+each take an additional argument epsilon to specify the "precision"
+required. In the real case, this means that each approximation will be
+within plus or minus epsilon of the actual result. In the complex case, this
+means that each approximation will be within plus or minus epsilon of the
+actual result in each of the real and imaginary parts.
+
+The precision can be specified as a Float if
+the results are desired in floating-point notation, or as
+Fraction Integer if the results are
+to be expressed using rational (or complex rational) numbers.
+
+
+
+
+
+
+If an n by n matrix has n distinct eigenvalues (and therefore n eigenvectors)
+the operation eigenMatrix gives you a
+matrix of the eigenvectors.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+If a symmetric matrix has a basis of orthonormal eigenvectors, then
+orthonormalBasis computes a list
+of these vectors.
+
+
+Consider the problem of computing the determinant of a 10 by 10 Hilbert
+matrix. The (i,j)-th entry of a Hilbert matrix is given by 1/(i+j+1).
+
+First do the computation using rational numbers to obtain the exact result.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+The result given by hardware floats is correct only to four significant digits
+of precision. In the jargon of numerical analysis, the Hilbert matrix is said
+to be "ill-conditioned".
+
+
+
+
+
+
+Now repeat the computation at a higher precision using Float.
+
+
+To get higher dimensional aggregates, you can create one-dimensional
+aggregates with elements that are themselves aggregates, for example,
+lists of list, one-dimensional arrays of list of multisets, and so on. For
+applications requiring two-dimensional homogeneous aggregates, you will
+likely find two-dimensional arrays and matrices useful.
+
+The entries in TwoDimensionalArray
+and Matrix objects are all the same type,
+except that those for Matrix must belong to a
+Ring. You create and access elements in roughly
+the same way. Since matrices have an understood algebraic structure, certain
+algebraic operations are available for matrices but not for arrays. Because
+of this, we limit our discussion here to Matrix,
+that can be regarded as an extension of
+TwoDimensionalArray. See
+TwoDimensionalArray
+For more
+information about Axiom's linear algebra facilities see
+Matrix,
+Permanent,
+SquareMatrix,
+Vector,
+
+Computation of Eigenvalues and Eigenvectors, and
+
+Solution of Linear and Polynomial Equations.
+
+You can create a matrix from a list of lists, where each of the inner
+lists represents a row of the matrix.
+
+
+Axiom provides both left and right scalar multiplication.
+
+
+
+
+
+
+
+
+
+
+You can add, subtract, and multiply matrices provided, of course, that the
+matrices have compatible dimensions. If not, an error message is displayed.
+
+
+
+
+
+
+This following product is defined but n*m is not.
+
+
+
+
+
+
+The operations nrows and
+ncols return the number of rows and
+columns of a matrix. You can extract a row or a column of a matrix using
+the operations row and
+column. The object returned ia a
+Vector. Here is the third column of the matrix n.
+
+
+
+
+
+
+You can multiply a matrix on the left by a "row vector" and on the right by
+a "column vector".
+
+
+
+
+
+
+The operation inverse computes the inverse
+of a matrix if the matrix is invertible, and returns "failed" if not. This
+Hilbert matrix invertible.
+
+
+
+
+
+
+
+
+
+
+This matrix is not invertible.
+
+
+
+
+
+
+
+
+
+
+The operation determinant computes the
+determinant of a matrix provided that the entries of the matrix belong to a
+CommutativeRing. The above matrix mm
+is not invertible and, hence, must have determinant 0.
+
+
+
+
+
+
+The operation trace computes the trace of a
+square matrix.
+
+
+
+
+
+
+The operation rank computes the rank of a matrix:
+the maximal number of linearly independent rows or columns.
+
+
+
+
+
+
+The operation nullity computes the nullity
+of a matrix: the dimension of its null space.
+
+
+
+
+
+
+The operation nullSpace returns a list
+containing a basis for the null space of a matrix. Note that the nullity is
+the number of elements in a basis for the null space.
+
+
+
+
+
+
+The operation rowEchelon returns the row
+echelon form of a matrix. It is easy to see that the rank of this matrix is
+two and that its nullity is also two.
+
+to display the full ist of operations defined by
+Matrix.
+<>
+@
+
+\subsection{linpermaent.xhtml}
+<>=
+<>
+
+
+
+<>
+
Permanent
+
+The package Permanent provides the function
+permanent for square matrices. The
+permanent of a square matrix can be
+computed in the same way as the determinant by expansion of minors except
+that for the permanent the sign for each element is 1, rather than being 1
+if the row plus column indices is positive and -1 otherwise. This function
+is much more difficult to compute efficiently than the
+determinant. An example of the use of
+permanent is the calculation of the nth
+derangement number, defined to be the number of different possibilities
+for n couples to dance but never with their own spouse. Consider an n by x
+matrix with entries 0 on the diagonal and 1 elsewhere. Think of the rows as
+one-half of each couple (for example, the males) and the columns the other
+half. The permanent of such a matrix gives the desired derangement number.
+
+
+
+
+
+
+Here are some derangement numbers, which you see grow quite fast.
+
+
+The top level matrix type in Axiom is
+Matrix, see
+(Matrix), which provides basic arithmetic
+and linear algebra functions. However, since the matrices can be of any
+size it is not true that any pair can be added or multiplied. Thus
+Matrix has little algebraic structure.
+
+Sometimes you want to use matrices as coefficients for polynomials or in
+other algebraic contexts. In this case,
+SquareMatrix should be used. The
+domain SquareMatrix(n,R) gives the
+ring of n by n square matrices over R.
+
+
+
+
+
+
+The usual arithmetic operations are available.
+
+
+
+
+
+
+Square matrices can be used where ring elements are required. For example,
+here is a matrix with matrix entries.
+
+
+
+
+
+
+Or you can construct a polynomial with square matrix coefficients.
+
+
+
+
+
+
+This value can be converted to a square matrix with polynomial coefficients.
+
+
+
+
+
+
+For more information on related topics see
+Modes and
+Matrix. Issue the system command
+
+
+
+
+
+
+to display the full list of operations defined by
+SquareMatrix.
+<>
+@
+
+\subsection{linvectors.xhtml}
+<>=
+<>
+
+
+
+<>
+
Vector
+
+The Vector domain is used for storing
+data in a one-dimensonal indexed data structure. A vector is a
+homogeneous data structure in that all the components of the vector
+must belong to the same Axiom domain. Each vector has a fixed length
+specified by the user; vectors are not extensible. This domain is
+similar to the
+OneDimensionalArray domain,
+except that when the components of a
+Vector belong to a
+Ring, arithmetic operations are provided.
+For more examples of operations that are defined for both
+Vector and
+OneDimensionalArray, see
+OneDimensionalArray.
+
+As with the OneDimensionalArray
+domain, a
+Vector can be created by calling the operation
+new, its components can be accessed by calling
+the operations elt and
+qelt, and its components can be reset by
+calling the operations
+setelt and
+setelt!. This creates a vector of
+integers of length 5 all of whose components are 12.
+
+
+
+
+
+
+This is how you create a vector from a list of its components.
+
+
+
+
+
+
+Indexing for vectors begins at 1. The last element has index equal to
+the length of the vector, which is computed by
+#.
+
+
+
+
+
+
+This is the standard way to use elt to extract
+an element.
+
+
+
+
+
+
+This is the standard way to use setelt to change an element. It is the
+same as if you had typed setelt(v,3,99).
+
+
+
+
+
+
+Now look at v to see the change. You can use
+qelt and
+qsetelt! (instead of
+elt and
+setelt, respectively) but only when you
+know that the indexis within the valid range.
+
+
+
+
+
+
+When the components belong to a
+Ring,
+Axiom provides arithmetic operations for
+Vector. These include left and right
+scalar multiplication.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Addition and subtraction are also available
+
+
+
+
+
+
+Of course, when adding or subtracting, the two vectors must have the
+same length or an error message is displayed.
+
+
+The CardinalNumber can be used for
+values indicating the cardinality of sets, both finite and infinite. For
+example, the dimension operation in the
+category VectorSpace returns a cardinal
+number.
+
+The non-negative integers have a natural construction as cardinals
+
+The fact that 0 acts as a zero for the multiplication of cardinals is
+equivalent to the axiom of choice.
+
+Cardinal numbers can be created by conversion from non-negative integers.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+The can also be obtained as the named cardinal Aleph(n)
+
+
+
+
+
+
+
+
+
+
+The finite? operation tests whether a value
+is a finite cardinal, that is, a non-negative integer.
+
+
+
+
+
+
+
+
+
+
+Similarly, the countable? operation
+determines whether a value is a countable cardinal, that is, finite or
+Aleph(0).
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Arithmetic operations are defined on cardinal numbers as follows:
+
+
+
+ x+y = #(X+Y)
+
+
+ cardinality of the disjoint union
+
+
+
+
+ x-y = #(X-Y)
+
+
+ cardinality of the relative complement
+
+
+
+
+ x*y = #(X*Y)
+
+
+ cardinality of the Cartesian product
+
+
+
+
+ x+*y = #(X**Y)
+
+
+ cardinality of the set of maps from Y to X
+
+
+
+Here are some arithmetic examples:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Subtraction is a partial operation; it is not defined when subtracting
+a larger cardinal from a smaller one, nor when subtracting two equal
+infinite cardinals.
+
+
+
+
+
+
+The generalized continuum hypothesis asserts that
+
+ 2**Aleph i = Aleph(i+1)
+
+and is independent of the axioms of set theory. (Goedel, The consistency
+of the continuum hypothesis, Ann. Math. Studies, Princeton Univ. Press,
+1940) The CardinalNumber domain
+provides an operation to assert whether the hypothesis is to be assumed.
+
+
+
+
+
+
+When the generalized continuum hypothesis is assumed, exponentiation to
+a transfinite power is allowed.
+
+
+
+
+
+
+Three commonly encountered cardinal numbers are
+
+ a = #Z countable infinity
+ c = #R the continuum
+ f = #{g|g: [0,1]->R}
+
+In this domain, these values are obtained under the generalized continuum
+hypothesis in this way:
+
+
+The Complex constructor implements
+complex objects over a commutative ring R. Typically, the ring R is
+Integer,
+Fraction Integer,
+Float,
+DoubleFloat,
+R can also be a symbolic type, like
+Polynomial Integer.
+For more information about the numerical and graphical aspects of
+complex numbers, see
+Numeric Functions
+in section 8.1.
+
+Complex objects are created by the
+complex operation
+
+
+
+
+
+
+
+
+
+
+The standard arithmetic operations are available.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+If R is a field, you can also divide the complex objects.
+
+
+
+
+
+
+Use a conversion
+(see Conversion in
+section 2.7) to view the last object as a fraction of complex
+integers.
+
+
+
+
+
+
+The predefined macro %i is defined to be complex(0,1).
+
+
+
+
+
+
+You can also compute the
+conjugate and
+norm of a complex number.
+
+
+
+
+
+
+
+
+
+
+The real and
+imag operations are provided to
+extract the real and imaginary parts, respectively.
+
+
+
+
+
+
+
+
+
+
+The domain
+Complex Integer
+is also called the Gaussian integers. If R is the integers (or, more
+generally, a
+Euclidean Domain),
+you can compute greatest common divisors.
+
+
+Continued fractions have been a fascinating and useful tool in mathematics
+for well over three hundred years. Axiom implements continued fractions
+for fractions of any Euclidean domain. In practice, this usually means
+rational numbers. In this section we demonstrate some of the operations
+available for manipulating both finite and infinite continued fractions.
+It may be helpful if you review
+Stream to remind yourself of some of the
+operations with streams.
+
+The ContinuedFraction domain is a
+field and therefore you can add, subtract, multiply, and divide the
+fractions. The
+continuedFraction operation
+converts its fractional argument to a continued fraction.
+
+
+
+
+
+
+This display is the compact form of the bulkier
+
+You can write any rational number in a similar form. The fraction will
+be finite and you can always take the "numerators" to be 1. That is, any
+rational number can be written as a simple, finite continued fraction of
+the form
+
+The a(i) are called partial quotients and the operation
+partialQuotients creates a
+stream of them.
+
+
+
+
+
+
+By considering more and more of the fraction, you get the
+convergents. For example, the
+first convergent is a(1), the second is a(1)+1/a(2) and so on.
+
+
+
+
+
+
+Since this ia a finite continued fraction, the last convergent is the
+original rational number, in reduced form. The result of
+approximants is always an infinite
+stream, though it may just repeat the "last" value.
+
+
+
+
+
+
+Inverting c only changes the partial quotients of its fraction by
+inserting a 0 at the beginning of the list.
+
+
+
+
+
+
+Do this to recover the original continued fraction from this list of
+partial quotients. The three argument form of the
+continuedFraction operation takes
+an element which is the whole part of the fraction, a stream of elements
+which are the denominators of the fraction.
+
+
+
+
+
+
+The streams need not be finite for
+continuedFraction. Can you guess
+which irrational number has the following continued fraction? See the end
+of this section for the answer.
+
+
+
+
+
+
+In 1737 Euler discovered the infinite continued fraction expansion
+
+We use this expansion to compute rational and floating point
+approximations of e. (For this and other interesting expansions,
+see C. D. Olds, Continued Fractions, New Mathematical Library,
+Random House, New York, 1963 pp.134-139).
+
+By looking at the above expansion, we see that the whole part is 0
+and the numerators are all equal to 1. This constructs the stream of
+denominators.
+
+
+
+
+
+
+Therefore this is the continued fraction expansion for (e-1)/2.
+
+
+
+
+
+
+These are the rational number convergents.
+
+
+
+
+
+
+You can get rational convergents for e by multiplying by 2 and adding 1.
+
+
+
+
+
+
+You can also compute the floating point approximations to these convergents.
+
+
+
+
+
+
+Compare this to the value of e computed by the
+exp operation in
+Float.
+
+
+
+
+
+
+In about 1658, Lord Brouncker established the following expansion for 4/pi.
+
+
+A finite field (also called a Galois field) is a finite
+algebraic structure where on can add, multiply, and divide under the same
+laws (for example, commutativity, associativity, or distributivity) as
+apply to the rational, real, or complex numbers. Unlike those three fields,
+for any finite field there exists a positive prime integer p, called the
+characteristic, such that p*x=0 for
+any element x in the finite field. In fact, the number of elements in a
+finite filed is a power of the characteristic and for each prime p and
+positive integer n there exists exactly one finite field with p**n elements,
+up to an isomorphism. (For more information about the algebraic structure and
+properties of finite fields, see for example, S. Lang Algebr,
+Second Edition, New York, Addison-Wesley Publishing Company, Inc. 1984,
+ISBN 0 201 05476 6; or R. Lidl, H. Niederreiter, Finite Fields,
+Encyclopedia of Mathematics and Its Applications, Vol. 20, Cambridge.
+Cambridge Univ. Press, 1983, ISBN 0 521 30240 4)
+
+When n=1, the field has p elements and is called a prime field,
+discussed in
+
+Modular Arithmetic and Prime Fields
+in section 8.11.1. There are several ways of implementing extensions of
+finite fields, and Axiom provides quite a bit of freedom to allow you to
+choose the one that is best for your application. Moreover, we provide
+operations for converting among the different representations of extensions
+and different extensions of a single field. Finally, note that you usually
+need to package call operations from finite fields if the operations do not
+take as an argument an object of the field. See
+Package Calling and Target Types
+in section 2.9 for more information on package calling.
+
+
+Axiom provides two kinds of floating point numbers. The domain
+Float
+(abbreviation FLOAT)
+implements a model of arbitrary precisions floating point numbers. The
+domain
+DoubleFloat
+(abbreviation DFLOAT)
+is intended to make available hardware floating point arithmetic in Axiom.
+The actual model of floating point
+DoubleFloat that Axiom
+provides is system dependent. For example, on the IBM System 370, Axiom
+uses IBM double precision which has fourteen hexadecimal digits of
+precision or roughly sixteen decimal digits. Arbitrary precision floats
+allow the user to specify the precision at which arithmetic operations
+are computed. Although this is an attractive facility, it comes at a cost.
+Arbitrary precision floating point arithmetic typically takes twenty to
+two hundred times more time than hardware floating point.
+
+For more information about Axiom's numeric and graphic facilities
+see Graphics in section 7,
+Numeric Functions
+in section 8.1, and DoubleFloat
+
+
+Axiom provides two kinds of floating point numbers. The domain
+Float
+(abbreviation FLOAT)
+implements a model of arbitrary precisions floating point numbers. The
+domain
+DoubleFloat
+(abbreviation DFLOAT)
+is intended to make available hardware floating point arithmetic in Axiom.
+The actual model of floating point
+DoubleFloat that Axiom
+provides is system dependent. For example, on the IBM System 370, Axiom
+uses IBM double precision which has fourteen hexadecimal digits of
+precision or roughly sixteen decimal digits. Arbitrary precision floats
+allow the user to specify the precision at which arithmetic operations
+are computed. Although this is an attractive facility, it comes at a cost.
+Arbitrary precision floating point arithmetic typically takes twenty to
+two hundred times more time than hardware floating point.
+
+By default, floating point numbers that you enter into Axiom are of type
+Float.
+
+
+
+
+
+
+You must therefore tell Axiom that you want to use
+DoubleFloat values and operations. The
+following are some conservative guidelines for getting Axiom to use
+DoubleFloat.
+
+To get a value of type DoubleFloat.,
+use a target with
+ "@", ...
+
+
+
+
+
+
+a conversion,...
+
+
+
+
+
+
+or an assignment to a declared variable. It is more efficient if you
+use a target rather than an explicit or implicit conversion.
+
+
+
+
+
+
+You also need to declare functions that work with
+DoubleFloat.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Use package calling for operations from
+DoubleFloat
+unless the arguments themselves are already of type
+DoubleFloat.
+
+
+
+
+
+
+
+
+
+
+By far, the most common usage of
+DoubleFloat
+is for functions to be graphied. For more information about Axiom's
+numerical and graphical facilities, see
+Graphics
+in section 7,
+Numeric Functions
+in section 8.1, and
+Float
+
+The usual arithmetic and elementary functions are available for
+DoubleFloat. Use
+
+
+
+
+
+
+to get a list of operations.
+<>
+@
+
+\subsection{nummachinesizedintegers.xhtml}
+<>=
+<>
+
+
+
+<>
+
Machine-sized Integers
+
+The SingleInteger is intended to
+provide support in Axiom for machine integer arithmetic. It is generally
+much faster than (bignum) Integer arithmetic
+but suffers from a limited range of values. Since Axiom can be implemented
+on top of various dialects of Lisp, the actual representation of small
+integers may not correspond exactly to the host machines integer
+representation.
+
+You can discover the minimum and maximum values in your implementation by
+using min and max
+
+
+
+
+
+
+
+
+
+
+To avoid confusion with Integer, which is
+the default type for integers, you usually need to work with declared
+variables (see Declarations).
+
+Operations And,
+Or,
+xor,
+and Not
+provide bit level operations on small integers.
+
+
+
+
+
+
+Use shift(int,numToShift) to shift bits, where int is shifted left if
+numToShift is positive, right if negative.
+
+
+
+
+
+
+
+
+
+
+Many other operations are available for small integers, including many of
+those provided for Integer.
+To see other operations use the system command
+
+
+Axiom provides two basic floating point types:
+Float and
+DoubleFloat. This section
+describes how to use numerical operations defined on these types and
+the related complex types. As we mentioned in
+An Overview of Axiom
+in chapter 1., the
+Float type is a software implementation of
+floating point numbers in which the exponent and the significand may have
+any number of digits. See
+Float for detailed information about this
+domain. The
+DoubleFloat is usually a hardware
+implementation of floating point numbers, corresponding to machine double
+precision. The types
+Complex Float and
+Complex DoubleFloat are the
+corresponding software implementations of complex floating point numbers.
+In this section the term floating point type means any of these four
+types. The floating point types immplement the basic elementary functions.
+These include (where $ means
+DoubleFloat,
+Float,
+Complex Float,
+Complex DoubleFloat):
+exp,
+log: $ -> $
+sin,
+cos,
+tan,
+cot,
+sec,
+csc: $ -> $
+asin,
+acos,
+atan,
+acot,
+asec,
+acsc: $ -> $
+sinh,
+cosh,
+tanh,
+coth,
+sech,
+csch: $ -> $
+asinh,
+acosh,
+atanh,
+acoth,
+asech,
+acsch: $ -> $
+pi: () -> $
+sqrt: $ -> $
+nthRoot: ($,Integer) -> $
+**: ($,Fraction Integer) -> $
+**: ($,$) -> $
+The handling of roots depends on whether the floating point type is
+real or complex: for the real floating point types,
+DoubleFloat and
+Float, if a real root exists the one with
+the same sign as the radicand is returned; for the complex floating
+point types, the principal value is returned. Also, for real floating
+point types the inverse functions produce errors if the results are not
+real. This includes cases such as asin(1.2), log(-3.2), sqrt(-1,1).
+The default floating point type is Float
+or Complex Float, just use normal
+decimal notation.
+
+A number of special functions are provided by the package
+DoubleFloatSpecialFunctions
+for the machine precision floating point types. The special functions
+provided are listed below, where F stands for the types
+Float
+or Complex Float. The real versions
+of the functions yield an error if the result is not real.
+
+
+ Gamma: F -> F
+ Gamma(z) is the Euler gamma
+ function, Gamma(Z), defined by
+ Gamma(z) = integrate(t^(z-1)*exp(-t),t=0..%infinity)
+
+
+ Beta: F -> F
+ Beta(u,v) is the Euler Beta
+ function B(u,v), defined by
+ Beta(u,v)=integrate(t^(u-1)*(1-t)^(b-1),t=0..1)
+ This is related to Gamma(z) by
+ Beta(u,v)=Gamma(u)*Gamma(v)/Gamma(u+v)
+
+
+ logGamma: F -> F
+ logGamma(z) is the natural logarithm of Gamma(z). This can often be
+ computed even if Gamma(z) cannot.
+
+
+ digamma: F -> F
+ digamma(z), also called psi(z), is the function psi(z), defined by
+ psi(z)=Gamma'(z)/Gamma(z)
+
+
+ polygamma: (NonNegativeInteger, F) -> F
+ polygamma(n,z) is the n-th derivative of digamma(z)
+
+
+ besselJ: (F, F) -> F
+ besselJ(v,z) is the Bessel function of the first kind, J(v,z). This
+ function satisfies the differential equation
+ z^(2w)''(z)+zw'(z)+(z^2-v^2)w(z)=0
+
+
+ besselY: (F, F) -> F
+ besselY(v,z) is the Bessel function of the second kind, Y(v,z). This
+ function satisfies the same differential equation as
+ besselJ. The implementation simply
+ uses the relation
+ Y(v,z)=(J(v,z)cos(v*%pi)-J(-v,z))/sin(v*%pi)
+
+
+ besselI: (F, F) -> F
+ besselI(v,z) if the modifed Bessel function of the first kind, I(v,z).
+ This function satisfies the differential equation
+ z^2w''(z)+zw'(z)-(z^2+v^2)w(z)=0
+
+
+ besselK: (F, F) -> F
+ besselK(v,z) is the modifed Bessel function of the second kind, K(v,z).
+ This function satisfies the same differential equation as
+ besselI. The implementation simply uses
+ the relation
+ K(v,z)=%pi*(I(v,z)-I(-v,z))/(2sin(v*%pi))
+
+
+ airyAi: F -> F
+ airyAi(z) is the Airy function Ai(z). This function satisfies the
+ differential equation
+ w''(z)-zw(z)=0
+ The implementation simply uses the relation
+ Ai(-z)=1/3*sqrt(z)*(J(-1/3,2/3*z^(3/2))+J(1/3,2/3*z^(3/2)))
+
+
+ airyBi: F -> F
+ airyBi(z) is the Airy function Bi(z). This function satisfies the
+ same differential equation as airyAi.
+ The implementation simply uses the relation
+ Bi(-z)=1/3*sqrt(3*z)*(J(-1/3,2/3*z^(3/2))-J(1/3,2/3*z^(3/2)))
+
+
+ hypergeometric0F1: (F, F) -> F
+ hypergeometric0F1(c,z) is the hypergeometric function 0F1(;c;z). The above
+ special functions are defined only for small floating point types. If you
+ give Float arguments, they are converted to
+ DoubleFloat by Axiom.
+
+
+The Octonions, also called the Cayley-Dixon algebra, defined over a
+commutative ring are an eight-dimensional non-associative algebra. Their
+construction from quaternions is similar to the construction of quaternions
+from complex numbers (see Quaternion).
+As Octonion creates an eight-dimensional
+algebra, you have to give eight components to construct an octonion.
+
+
+
+
+
+
+
+
+
+
+Or you can use two quaternions to create an octonion.
+
+
+
+
+
+
+You can easily demonstrate the non-associativity of multiplication.
+
+
+
+
+
+
+As with the quaternions, we have a real part, the imaginary parts i, j,
+k, and four additional imaginary parts E, I, J, and K. These parts
+correspond to the canonical basis (1,i,j,k,E,I,J,K). For each basis
+element there is a component operation to extract the coefficient of
+the basis element for a given octonion.
+
+
+
+
+
+
+A basis with respect to the quaternions is given by (1,E). However, you
+might ask, what then are the commuting rules? To answer this, we create
+some generic elements. We do this in Axim by simply changing the ground
+ring from
+Integer to
+Polynomial Integer.
+
+
+
+
+
+
+
+
+
+
+Note that quaternions are automatically converted to octonions in the
+obvious way.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Finally, we check that the norm, defined as
+the sum of the squares of the coefficients, is a multiplicative map.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Since the result is 0, the norm is multiplicative
+
+
+
+
+
+
+Issue the system command
+
+
+
+
+
+
+to display the list of operations defined by
+Octonion.
+<>
+@
+
+\subsection{numotherbases.xhtml}
+<>=
+<>
+
+
+
+<>
+
Expansions in other Bases
+
+It is possible to expand numbers in general bases. Here we expand
+111 in base 5. This means
+
+ 2 1 0 2 1 -
+ 10 +10 +10 = 4*5 +2*5 +5
+
+
+
+
+
+
+
+You can expand fractions to form repeating expansions.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+For bases from 11 to 36 the letters A through Z are used.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+For bases greater than 36, the ragits are separated by blanks.
+
+
+
+
+
+
+The RadixExpansion type provides
+operations to obtain the individual ragits. Here is a rational number
+in base 8.
+
+
+
+
+
+
+The operation wholeRagits returns
+a list of the ragits for the integral part of the number.
+
+
+
+
+
+
+The operations prefixRagits and
+cycleRagits returns lists of the
+initial and repeating ragist in the fractional part of the number.
+
+
+
+
+
+
+
+
+
+
+You can construct any radix expansion by giving the whole, prefix, and
+cycle parts. The declaration is necessary to let Axiom know the base
+of the ragits.
+
+
+
+
+
+
+If there is no repeating part, then the list [0] should be used.
+
+
+
+
+
+
+If you are not interested in the repeating nature of the expansion,
+an infinite stream of ragits can be obtained using
+fractRagits
+
+
+
+
+
+
+Of course, it's possible to recover the fraction representation:n
+
+
+A partial fraction is a decomposition of a quotient into a sum of quotients
+where the denominators of the summand are powers of primes. (Most people
+first encounter partial fractions when they are learning integral calculus.
+For a technical discussion of partial fractions see, for example, Lang's
+Algebra.) For example, the rational number 1/6 is decomposed into 1/2-1/3.
+You can compute partial fractions of quotients of objects from domains
+belonging to the category
+EuclideanDomain. For example,
+Integer,
+Complex Integer, and
+
+UnivariatePolynomial(x,Fraction Integer)
+all belong to
+EuclideanDomain.
+In the examples following, we demonstrate how to decompose quotients of
+each of these kinds of objects into partial fractions.
+
+It is necessary that we know how to factor the denominator when we want to
+compute a partial fraction. Although the interpreter can often do this
+automatically, it may be necessary for you to include a call to
+factor. In these examples, it is not
+necessary to factor the denominators explicitly. The main operation for
+computing partial fractions is called
+partialFraction and we use this
+to compute a decomposition of 1/10!. The first argument top
+partialFraction is the numerator
+of the quotient and the second argument is the factored denominator.
+
+
+
+
+
+
+Since the denominators are powers of primes, it may be possible to expand
+the numerators further with respect to those primes. Use the operation
+padicFraction to do this.
+
+
+
+
+
+
+The operation compactFraction
+returns an expanded fraction into the usual form. The compacted version
+is used internally for computational efficiency.
+
+
+
+
+
+
+You can add, subtract, multiply, and divide partial fractions. In addition,
+you can extract the parts of the decomposition.
+numberOfFractionalTerms
+computes the number of terms in the fractional part. This does not include
+the whole part of the fraction, which you get by calling
+wholePart. In this example, the whole part
+is 0.
+
+
+
+
+
+
+The operation
+nthFractionalTerm
+returns the individual terms in the decomposition. Notice that the object
+returned is a partial fraction itself.
+firstNumer and
+firstDenom extract the numerator and
+denominator of the first term of the fraction.
+
+
+
+
+
+
+Given two gaussian integers (see Complex),
+you can decompose their quotient into a partial fraction.
+
+
+
+
+
+
+To convert back to a quotient, simply use the conversion
+
+
+
+
+
+
+To conclude this section, we compute the decomposition of
+
+These are the compact and expanded partial fractions for the quotient.
+
+
+
+
+
+
+
+
+
+
+Also see
+
+FullPartialFractionExpansion for examples of factor-free conversion of
+quotients to full partial fractions.
+
+Issue the system
+command
+
+
+
+
+
+
+to display the full list of operations defined by
+PartialFraction.
+
+<>
+@
+
+\subsection{numproblems.xhtml}
+<>=
+<>
+
+
+<>
+ numproblems not implemented
+<>
+@
+
+\subsection{numquaternions.xhtml}
+<>=
+<>
+
+
+
+<>
+
Quaternions
+
+The domain contructor Quaternion
+implements quaternions over commutative rings.
+
+The basic operation for creating quaternions is
+quatern. This is a quaternion
+over the rational numbers.
+
+
+
+
+
+
+The four arguments are the real part, the i imaginary part,
+the j imaginary part, and the k imaginary part, respectively.
+
+
+
+
+
+
+Because q is over the rationals (and nonzero), you can invert it.
+
+
+
+
+
+
+The usual arithmetic (ring) operations are available.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+In general, multiplication is not commutative.
+
+
+
+
+
+
+There are no predefined constants for the imaginary i, j, and k parts,
+but you can easily define them
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+These satisfy the normal identities.
+
+
+
+
+
+
+The norm is the quaternion times its conjugate.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+For information on
+related topics, see Complex and
+Octonion. You can also issue the
+system command
+
+
+
+
+
+
+to display the full list of operations defined by
+Quaternion.
+<>
+@
+
+\subsection{numquotientfields.xhtml}
+<>=
+<>
+
+
+<>
+ numquotientfields not implemented
+<>
+@
+
+\subsection{numrationalnumbers.xhtml}
+<>=
+<>
+
+
+<>
+ numrationalnumbers not implemented
+<>
+@
+
+\subsection{numrepeatingbinaryexpansions.xhtml}
+<>=
+<>
+
+
+
+<>
+
Repeating Binary Expansions
+
+All rational numbers have repeating binary expansions. Operations to
+access the individual bits of a binary expansion can be obtained by
+converting the value to
+RadixExpansion(2). More examples
+of expansions are available in
+DecimalExpansion,
+HexadecimalExpansion, and
+RadixExpansion.
+
+The expansion (of type
+BinaryExpansion)
+of a rational number is returned by the
+binary operation.
+
+
+
+
+
+
+Arithmetic is exact.
+
+
+
+
+
+
+The period of the expansion can be short or long...
+
+
+All rationals have repeating decimal expansions. Operations to access
+the individual digits of a decimal expansion can be obtained by converting
+the value to RadixExpansion(10).
+
+The operation decimal is used to create
+this expansion of type
+DecimalExpansion.
+
+
+
+
+
+
+Arithmetic is exact.
+
+
+
+
+
+
+The period of the expansion can be short or long...
+
+to display the full list of operations defined by
+RadixExpansion.
+<>
+@
+
+\subsection{numrepeatinghexexpansions.xhtml}
+<>=
+<>
+
+
+
+<>
+
Repeating Hexadecimal Expansions
+
+All rationals have repeating hexadecimals expansions. The operation
+hex returns these expansions of type
+HexadecimalExpansion.
+Operations to access the individual numerals of a hexadecimal expansion
+can be obtained by converting the value to
+RadixExpansion(16). More examples of
+expansions are available in
+DecimalExpansion,
+BinaryExpansion, and
+RadixExpansion.
+
+This is a hexadecimal expansion of a rational number.
+
+
+
+
+
+
+Arithmetic is exact.
+
+
+
+
+
+
+The period of the expansion can be short or long...
+
+
+
+
+
+
+or very long.
+.
+
+
+
+
+
+These numbers are bona fide algebraic objects.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Issue the system command
+
+
+
+
+
+
+to display the full list of operations defined by
+HexadecimalExpansion.
+
+<>
+@
+
+\subsection{numromannumerals.xhtml}
+<>=
+<>
+
+
+
+<>
+
Roman Numerals
+
+The Roman numeral package was added to Axiom in MCMLXXXVI for use in
+denoting higher order derivatives.
+
+For example, let f be a symbolic operator.
+
+
+
+
+
+
+This is the seventh derivative of f with respect to x
+
+
+
+
+
+
+You can have integers printed as Roman numerals by declaring variables
+to be of type
+RomanNumeral
+(abbreviation ROMAN).
+
+
+
+
+
+
+This package now has a small but devoted group of followers that claim
+this domain has shown its efficacy in many other contexts. They claim
+that Roman numerals are every bit as useful as ordinary integers.
+In a sense, they are correct, because Roman numerals form a ring and
+you can therefore construct polynomials with Roman numeral
+coefficients, matrices over Roman numerals,etc..
+
+
+
+
+
+
+Was Fibonacci Italian or ROMAN?
+
+
+
+
+
+
+You can also construct fractions with Roman numeral numerators and
+denominators, as this matrix Hilberticus illustrates.
+
+
+
+
+
+
+
+
+
+
+Note that the inverse of the matrix has integral
+ROMAN entries.
+
+
+
+
+
+
+Unfortunately, the spoil-sports say that the fun stops when the
+numbers get big -- mostly because the Romans didn't establish
+conventions about representing very large numbers.
+
+
+
+
+
+
+You work it out!
+
+
+
+
+
+
+Issue the system command
+
+
+
+
+
+
+to display the full list of operations defined by
+RomanNumeral).
+<>
+@
+
+%%O
+\subsection{ocwmit18085.xhtml}
+<>=
+<>
+
+
+<>
+18.085 Mathematical Methods for Engineers I Course Notes
+
+These are course notes based on the
+
+ M.I.T. Open Courseware lectures by Gilbert Strang.
+
+
+These matrices are similar and can be generalized to square matrices
+of order N, with n x n elements. All of these matrices have the same
+element along the diagonal. T (aka Top) differs from K in the first row.
+B (aka Both) differs from K in the first and last row. These represent
+different boundary conditions in the problem.
+
+We can create K(n), T(n) and B(n) with the following commands:
+
+k(n) ==
+ M := diagonalMatrix([2 for i in 1..n])
+ for i in 1..n-1 repeat M(i,i+1):=-1
+ for i in 1..n-1 repeat M(i+1,i):=-1
+ M::SquareMatrix(n,Fraction(Integer))
+
+Notice that these are all integers because the determinant of
+this matrix is 1
+
+determinant T
+
+ 1
+ Type: Fraction Integer
+
+
+We can check that this matrix is the inverse of T.
+
+When computing the inverse the row pattern [-1 2 -1] is a
+``second difference''. The first column of the inverse matrix
+is [3 2 1] which is linear. When we take the second difference
+of a linear object we should get 0. Thus,
+
+So these simple checks show that we're getting the correct
+row and column values for the identity matrix by multiplying
+T times its inverse.
+
+
+
The inverse of B
+If we look for the inverse of the B matrix we can observe
+that the rows sum to zero which implies that it is not
+invertible. Thus it is singular.
+
+K and T are positive definite. B is only positive semi-definite.
+
+If we can find a vector that it takes to zero, that is if we can
+solve for x,y,z in:
+
+The constant vector [1 1 1] solves this equation. When
+the rows sum to zero we are adding each row by a constant
+and thus we add each row times the constant one and we
+get zeros. If the matrix takes some vector to zero it
+cannot have an inverse since if
+
+ B x = 0
+
+and x is not zero. If B had an inverse only x=0 would
+solve the equation. Since x=1 solves the equation B has
+no inverse. The vector x is in the nullspace of B. In
+fact any constant vector, e.g. [3 3 3] is in the nullspace.
+Thus the nullspace of B is cx for any constant c.
+
+When doing matrix multiplication one way to think about the
+work is to consider the problem by columns. Thus in the
+multiplication
+
+and for the constant vector [1 1 1] this means that we
+just need to sum the columns.
+
+Alternatively this can be computed by thinking of the
+multiplication as
+
+Notice that the inverse is a symmetric matrix but not tri-diagonal.
+The inverse is not a sparse matrix so much more computation would
+be involved when using the inverse.
+
+In order to solve the system
+
+ K u = f
+
+by elimination which implies multiplying and subtracting rows.
+
+By multiplying row1 by 1/2 and adding it to row2 we create an
+upper triangular matrix U. Since we chose K(1,1), the number 2
+is called the first pivot. K(2,2), the number 3/2, is called
+the second pivot.
+
+For K 2x2 above is symmetric and invertible (since the pivots
+are all non-zero).
+
+For the K 3x3 case the pivots are 2, 3/2, and 4/3. (The next pivots
+would be 5/4, 6/5, etc. for larger matrices).
+
+For the T 3x3 case the pivots are 1, 1, and 1.
+
+For the B 3x3 case the third pivot would be zero.
+
+
+
Generalizing the matrix pivot operations
+For the 2x2 case we see contruct an elimination matrix E which we can use
+to pre-multipy by K to give us the upper triangular matrix U
+
+
+Each of these operations is described by a factorization of K.
+Elimination is written
+
+ K = L U
+
+where L is lower triangular and U is upper triangular.
+Thus we need a matrix L which when multiplied by U gives K.
+The required matrix is the inverse of the E matrix above since
+
+
+1) E K = U
+
+ -1 -1
+2) E E K = E U
+
+ -1
+3) I K = E U
+
+ -1
+4) but L = E
+
+5) so K = L U
+
+So now we have 3 matrices; L is the lower triangular,
+D is symmetric and contains the pivots, and U' is upper triangular and
+is the transpose of the lower. So the real form we have is
+
+ T
+ L D L
+
+This result will always be symmetric. We can check this by taking
+its transpose. If we get the same matrix we must have a symmetric
+matrix. So the transpose of
+
+ T T TT T T T T T
+ ( L D L ) = L D L = L D L = L D L
+
+
+
Positive Definite Matrices
+There are several ways to recognize a positive definite matrix.
+First, it must be symmetric. The "positive" aspect comes from
+the pivots, all of which must be positive. Note that T is also
+positive definite. B is positive semi-definite because one of
+the pivots is zero. So
+
+ positive definite == all pivots > 0
+ positive semi-definite == all pivots >= 0
+
+When all the pivots are positive then all the eigenvalues are positive.
+
+So a positive definite matrix K and any non-zero vector X
+
+ T
+ X K X > 0
+
+X transpose is just a row and X is just a column.
+
+<>
+@
+
+\subsection{ocwmit18085lecture2.xhtml}
+<>=
+<>
+
+
+<>
+ One-dimensional Applications: A = Difference Matrix
+
+