⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch37.htm

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTM
📖 第 1 页 / 共 2 页
字号:


where you installed Scilab. It contains a PostScript document called <TT>intro.ps</TT>



which contains the user's manual titled Introduction to Scilab. Take time to read



this manual carefully.</P>



<P>For a list of all the available functions in Scilab, you can look in the <TT>man/LaTex-doc</TT>



directory for a PostScript file called <TT>Docu.ps</TT>. (Yes, the file names are



cryptic!) Print this file for a handy paper list of all the available functions.



All these functions are still accessible from the help buttons in the front panel.



<H3 ALIGN="CENTER"><A NAME="Heading6<FONT COLOR="#000077">Pari</FONT></H3>



<P>The Pari package is useful for doing symbolic mathematical operations. Its primary



features include an arbitrary precision calculator, its own programming facilities,



and interfaces to C libraries.



<H4 ALIGN="CENTER"><A NAME="Heading7<FONT COLOR="#000077">Where to Get Pari</FONT></H4>



<P>To get Pari, use the FTP site <TT>megrez.math.u-bordeaux.fr</TT>, and from the



<TT>/pub/pari/unix</TT> directory get the <TT>gplinux.tar.gz</TT> file. The binaries



may not work with a later version of Linux because the binaries are built with older



versions of shared libraries. If you have a newer version of Linux than the one supported



by Pari, either you can edit the sources yourself or wait until the authors of Pari



catch up. Sorry.</P>



<P>With the version of Linux on the CD-ROM at the back of this book, you need to



compile your own version of Pari. The source files are in the <TT>pari-1.39.03.tar.gz</TT>



file. The source <TT>tar</TT> file unpacks into three directories: <TT>src</TT>,



<TT>doc</TT>, and <TT>samples</TT>. You will find the samples very useful indeed.</P>



<P>To compile the sources, run the <TT>Makemakefile</TT> command in the <TT>src</TT>



directory. When creating this version, remove the definition of the option <TT>-DULONG_NOT_DEFINED</TT>



from the <TT>CFLAGS</TT> macro in the newly created <TT>Makefile</TT>. Then type



<TT>make</TT> at the prompt. Be prepared to wait a while for this package to compile.



<H4 ALIGN="CENTER"><A NAME="Heading8<FONT COLOR="#000077">Running Pari</FONT></H4>



<P>After you have installed the source files for Pari, type <TT>gp</TT> at the console



prompt. Your prompt will be a question mark (<TT>?</TT>). Start by typing simple



arithmetic expressions at this prompt. You should be rewarded with answers immediately.



Let's look at the following sample session:<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">? 4*8



%1=32



? 4/7*5/6



%2=10/21



</FONT></PRE>



<P>The answer was returned to us in fractions. To get real numbers, introduce just



one real number in the equation. You will then get the answer as a real number. The



percent signs identify the returned line numbers.<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">? 4.0/7 * 5/6



%3=0.476190476190476190476190



</FONT></PRE>



<P>To set the precision in number of digits, you use the <TT>?\precision</TT> command.



The maximum number of digits is 315,623, a large number for just about all users.



For a modest precision of 10 digits to the right of the decimal point, use this:<FONT



COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">?\precision=10



? 4.0/7*5/6



%4=0.476190047



</FONT></PRE>



<P>You can even work with expressions, as shown in the following example:<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">? (x+2)*(x+3)



%5=x^2+5*x+6



</FONT></PRE>



<P>You can assign values to variables to get the correct answer from evaluating an



expression:<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">? x=3



%6=3



? eval(%5)



%7=60



</FONT></PRE>



<P>This is not where the power of Pari ends, though. You can factor numbers, solve



differential equations, and even factor polynomials. The FTP site for Pari contains



a wealth of information and samples. See <TT>megrez.math.u-bordeaux.fr</TT>. Also,



the <TT>docs</TT> directory contains samples and the manual to help you get started.



<H3 ALIGN="CENTER"><A NAME="Heading9<FONT COLOR="#000077">Using LISP-STAT</FONT></H3>



<P>For statistical computing, consider using LISP-STAT. Written by Luke Tierney at



the University of Minnesota, LISP-STAT is a very powerful, interactive, object-oriented



LISP package.



<H4 ALIGN="CENTER"><A NAME="Heading10<FONT COLOR="#000077">Where to Get LISP-STAT</FONT></H4>



<P>The LISP-STAT package is available from <TT>ftp.stat.umn.edu</TT> in the <TT>/pub/xlispstat</TT>



directory. Get the latest <TT>tar</TT> file version you can--currently, <TT>xlispstat-3-44.tar.gz</TT>.



In order to build this file you need the <TT>dld</TT> library for Linux. This <TT>dld</TT>



library is found in <TT>tsx-11.mit.edu</TT> in the <TT>/pub/linux/binaries/libs</TT>



directory as <TT>dld-3.2.5.bin.tar.gz</TT>. Install this <TT>dld</TT> library in



the <TT>/lib</TT> directory first.



<H4 ALIGN="CENTER"><A NAME="Heading11<FONT COLOR="#000077">Running xlispstat</FONT></H4>



<P>At the command prompt in an Xterm, type <TT>xlispstat</TT>. You will be presented



with a <TT>&gt;</TT> prompt. Type commands at this prompt. For example, to multiply



two matrices together, use the following command:<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">&gt; (def a (matrix `(3 3) `(2 5 7 1 2 3 1 1 2)))



A



&gt; (def b (matrix `(3 1) `(4 5 6)))



B



&gt; (matmult a b)



#2A((75.0) (32.0) (21))



</FONT></PRE>



<P>The variables in LISP-STAT are not case sensitive. Note the single quote (<TT>`</TT>)



before the list of numbers for the matrix. If you omit the quote, the list will be



evaluated and replaced with the result of the evaluation. By leaving the single quote



in there, you are forcing the interpreter to leave the list in its place.</P>



<P>Let's try solving a simple set of linear equations using LISP-STAT. The following



would be a simple example to solve:<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">3.8x + 7.2y = 16.5



1.3x - 0.9y = -22.1



</FONT></PRE>



<P>The following script would set up and solve this linear equation problem:<FONT



COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">&gt; (def a (matrix `(2 2) `(3.8 7.2 1.3 -0.9)))



A



&gt; (def b (matrix `(2 1) `(16.5 -22.1)))



B



&gt; (matmult (inverse a) b)



#2A((-11.288732394366198) (8.249608763693271))



</FONT></PRE>



<P>You can do other math operations on lists of numbers as well. See the following



example for calculating the mean of a list of numbers:<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">&gt; (def sm (list 1.1 2.3 4.1 5.7 2.1))



SM



&gt; (mean SM)



3.06



</FONT></PRE>



<P>There are many plotting functions available for LISP-STAT. For plotting one variable,



try the function <TT>plot-function</TT>. For (x,y) pairs of numbers, use the <TT>plot-lines</TT>



function. For a function of two variables, use the <TT>spin-function</TT>. For 3-D



plots, use the <TT>spin-plot</TT> function.</P>



<P>Plots are not limited to lines. You can do histograms, planar plots, and so on.



(See Figure 37.2.) See the help pages for details on specifics of how to generate



these plots. Two or more plots can be linked together so that changes in one set



of data can be reflected in another. You can add points to a plot using the <TT>add-points</TT>



function. For reconfiguring how the points are displayed, you can <TT>send</TT> commands



to the plot windows. Plots can be linked together to enable more than one view of



the same data. <BR>



<BR>







<A HREF="../art/37/36fig02.gif"><B>Figure 37.2.</B></a> <I>A histogram sample.</I> <BR>



<BR>



Each plot is displayed in an X window. You can move the mouse cursor over a point,



and it will echo back a value for you.</P>



<P>To get help on this system, use the <TT>help</TT> command. The help documentation



for this command should be visible. If nothing shows up, check the environment variables



to see if the binaries are in the PATH. For example, the command to get help on EIGENVALUES



and its invocation is shown in Figure 37.3. <BR>



<BR>







<A HREF="../art/37/36fig03.gif"><B>Figure 37.3.</B></a> <I>Sample of using EIGENVALUES.</I>



<H4 ALIGN="CENTER"><A NAME="Heading12<FONT COLOR="#000077">Where to Get More



Information About LISP-STAT</FONT></H4>



<P>You can get a considerable amount of information from the documents available



online at the FTP site <TT>ftp.stat.ucla.edu</TT> (in directory <TT>/pub/lisp/xlisp/xlisp-stat/docs</TT>)



or in the Web page at <TT>http://euler.bd.psu.edu</TT>. For more information, read



the book LISP-STAT by Luke Tierney (John Wiley).



<H3 ALIGN="CENTER"><A NAME="Heading13<FONT COLOR="#000077">A Last Note</FONT></H3>



<P>For simple math operations involving spreadsheets, you can always use the <TT>xspread</TT>



program provided with the X package. (The CD-ROM at the back of the book has version



2.1.) For more powerful spreadsheet functions, you might want to resort to a commercial



spreadsheet package and take advantage of its support, too. The XESS spreadsheet



is available for Linux from Applied Information systems, (919) 842-7801 or <TT>info@ais.com</TT>.



You can share data between spreadsheets, or use the API to develop and have access



to a full suite of math functions available on spreadsheets that run under DOS or



UNIX.</P>



<P>Wolfram Research has released its Mathematica program for Linux. The Mathematica



package has extensive numeric and symbolic capabilities, 2-D and 3-D graphics, and



a very large library of application programs. With an additional feature called MathLink,



you can exchange information between other applications on a network. You can get



more information about Mathematica from <TT>info@wri.com</TT> or <TT>http://www.wri.com</TT>.



<H3 ALIGN="CENTER"><A NAME="Heading14<FONT COLOR="#000077">Summary</FONT></H3>



<P>You have several options when it comes to performing mathematical operations or



writing such applications under Linux. You can either write the code yourself using



C, FORTRAN, or other available languages--or you can use a package. If you are familiar



with MATLAB, consider using Scilab. For regular expressions and polynomials, try



using Pari. If you are a LISP user or want to do vector operations or statistics,



consider using the LISP-STAT package.



















</td>
</tr>
</table>

<!-- begin footer information -->



</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -