TeXmacs with CAS

 Chu-Ching Huang

 Email: cchuang@mail.cgu.edu.tw

 November 5, 2007

 Some famous computer algebra systems (CAS) will be integrated into the Linux-based platform as CAI tools for the higher Mathematical courses. The mini memo will cover some topics as follows: Maxima: This software is famous for its "Symbolic calculation", including finding limit of functions, differentiation, integration of functions, series expansion etc; Octave: This software has full features about "Numerical calculation" and simple syntax to be programmed. Gnuplot: The powerful plotting package, it almost has no problem to deal with the scientific or data plotting especially for 2D plots. TeXmacs: Certainly, you have known if you can see this article. Word processing and "GUI" of CAS. It is the simplest way for you to make mathematical document from input to output, I think. All the packages will be integrated into bootable Linux CDROM. In other words, you can continue your paper work in any place with this platform ( and disk for storing data) even in net-coffee store. Now, let us explore the journey and hope you enjoy it!

# 1.Preliminary

In this chapter, the individual basic introductions about TeXmacs, core of this book, and the tools about computer algebra systems, CAS, and graph will be given.

## 1.Ahead navigation with TeXmacs

This is not only introduction for the people who want to learn how to use TeXmacs, but a note for TeXmacs newbie with some TeX experiences. We try to follow the TeX rules to describe how to making documents. From now on, [content] means the option, content, in the menu bar.

### 1.1.Presume setup

While you execute the TeXmacs from X-terminal, you will see the TeXmacs window. If you are first use this application, the "help" document is also opened in the worksheet windows. Press the button in the menu bar, [File] → [New], to open a new buffer for writing document directly or just as LaTeX doing something "presume document setting":

1. [Document] → [style] → [format that you want to write], almost styles generally used in LaTeX, for example: article, letter etc., can be found in this menu.
2. [Text] → [Title] → [Make title] → [Abstract], author, date and address can also be added.
3. [Text] → [Section] and so on. The content part of article can be manipulated just as any work processing programs do.

Generally, part 1 and 2 can be omitted if your do not hear about TeX or simply type a document. For TeXers, the document uses "letter" style.

### 1.2.Content Cooking

If you do not care about how to make content with any mathematical symbols, now stop reading. If text input can not satisfy you, just go continuously. The philosophy for TeXmacs to manipulate the contents is very similar to LaTeX does ( but not equal to). Content inputs are divided into three types: text, math and display modes.

1. Type text as any WYSIWYG editors do.
2. Math content, i.e. mathematical symbols together with text content in one line. Then:

1. Press the menu bar [ ∑mr], or [Text] → [Mathematics] → [Formula] or press US dollar sign, to change the mode from text mode into math mode. The third line of menu bar changes for suitable mathematical choice icons. But the usages are still functional mostly.
2. Press [→] or US dollar sign back to the text mode after inputting mathematical content.

The symbols are just like these of usages in TeX. For example: \backslash produces \.

3. Display Math content, i.e. independent line or lines for Mathematical symbols.

1. Choose [∑mr] → [Equation], for one-line mathematical input, corresponding TeX command is double US dollar sign;
2. choose [∑mr] → [Equations], multi-line mathematical input, corresponding TeX command is eqnarray environment. Use [→] to change next cell and [Enter] to change new line. The exact cell position is shown at the right-down corner.
4. How do I know at which is in "text" mode or in "math" mode? The same environment is enclosed by a light blue rectangle. Yor can move by the mouse or the "right arrow", [], and "left arrow", [], keys to change the mode.

Now, let us show some examples:

Example 1. (Riemann Integral) [Text]→[Environment] → [Example], just like LaTeX, it is auto-numbered. Press [Enter] to input the following:

Let f be defined on the closed interval [a,b], and let Δ be a partition of [a,b] given that

a = x0<x1<x2<⋯<xn - 1<xn = b

where Δxi is the width of the ith subinterval. If ci is any point in the ith subinterval, then the sum

 n i = 1
f(cixi,
xi - 1cixi

is called the Riemann sum of f for the partition of Δ.

The parts in blue color are in math mode (press US dollar sign and then [] back to the text mode again) and the parts in red are in display Math mode ( press [∑mr] → [Equation] and move cursor by mouse into next line back to the text mode). The messages shown at the bottom line of TeXmacs may help you at which mode you are and what you have done.

Example 2. As above, if the limit

lim‖Δ‖ →0
 n i = 1
f(cixi
(1)

exists where ‖Δ‖ = below (max, 1⩽in)|xi - xi - 1| then f is integrable on [a,b] and the limit is denoted by

lim‖Δ‖ →0
 n i = 1
f(cixi = ∫
 b a
f(x) d x.
(2)

The limit is call the definite integral.

The number of equation is produced by [Mathematics] →[Number equation] in display Math mode.

In these two examples, just type as you do in TeX environment, for example means upper script input and - means lower script input, but not all same.

Example 3. (Gauss Law)

In Math or display Math mode, we can adjust the script by:

• Press [Mathematics] → [Script] →[Script below] or [Script above], to add new line below or above the math symbol. This is as like the effect of \limit TeX command after normal mathematical command.
• Input symbols under or above other symbols in display math mode, as above adding script space ahead,

 below (∫∫, S)B⋅N d S = 4πq (3)

After working, choose [File] →[Save] and give a filename, for example filename.tm. This will create a file named as filename.tm in your home directory. If you work on Knoppix Linux, everything will be disappeared after turning off the power since it works on RAM. You had better to use the following command to backup worksheet:

> mcopy filename.tm a:

Now you can turn off the system. Then you can fire up your TeXmacs and enjoy!

## 2.CAS's and Graph softwares

Not only the powerful ability of publishing text and math documents, CAS applications can be executed within session of TeXmacs, solving problems and making graphs. The computation ability of CAS will be introduced later and how-to making graphs will be introduced first. Some CAS sessions allow to produce in-line postscript graph in worksheets, i.e. Gnuplot, Octave, but some are not, for example Maxima. For the latter case, users have to embed the result graphs into the worksheet.

Example 4. How can TeXmacs do with CAS?

The answer is very simple: calculation, including symbolic calculation, for example Maxima and Yacas, numerical calculation, for example Octave, and plotting utility.

Note 5. Remember, Before quit out from the CAS session, remember to close session by pressing the third icon in the third line of menu bars.

## 3.Functions

Here, we will give a brief introduction for CAS working within TeXmacs.

Definition 6. f(x) is called a function of D, subset of real numbers, if there is only unique yR for each point, x in D.

Example 7. Maxima session: [Text] →[Session] → [Maxima]

GCL (GNU Common Lisp) Version(2.5.0) űgďŋ 2ďë 7 19:50:19 CST 2003

Licensed under GNU Library General Public License

Contains Enhancements by W. Schelter

Maxima 5.9.0rc3 http://maxima.sourceforge.net

Distributed under the GNU Public License. See the file COPYING.

Dedicated to the memory of William Schelter.

This is a development version of Maxima. The function bug_report()

provides bug reporting information.

 (C1) f(x):=x^3+sin(x)
(D1) f(x): = x3 + sin x
 (C2) f(%pi)
(D2) π3
 (C3) h(x):=block([u:x,w], if (u>0) then w:sin(x) else w:-sin(x), u+w)
(D3) h(x): = block([u:x,w],ifu>0thenw:sin xelsew: - sin x,u + w)
 (C4) h(1)
(D4) sin 1 + 1
 (C5) h(-2.0)
(D5) - 1.090702573174318
 (C6) integrate(x*((x-1)/(x+1))**(1/2),x);
(D6) 4 (
log (sqrt (
 x - 1 x + 1
) + 1)
8
-
log (sqrt (
 x - 1 x + 1
) - 1)
8
+
3 (
 x - 1 x + 1
)
 3 2
- sqrt (
 x - 1 x + 1
)
-
 8 (x - 1) x + 1
+
 4 (x - 1)2 (x + 1)2
+ 4
)
 (C7) diff(d6,x)
(D7) 4 ( -
( -
 8 x + 1
+
 16 (x - 1) (x + 1)2
-
 8 (x - 1)2 (x + 1)3
) (3 (
 x - 1 x + 1
)
 3 2
- sqrt (
 x - 1 x + 1
))
( -
 8 (x - 1) x + 1
+
 4 (x - 1)2 (x + 1)2
+ 4)2
+
 1 x + 1
-
 x - 1 (x + 1)2
16 sqrt (
 x - 1 x + 1
) (sqrt (
 x - 1 x + 1
) + 1)
-
 1 x + 1
-
 x - 1 (x + 1)2
16 sqrt (
 x - 1 x + 1
) (sqrt (
 x - 1 x + 1
) - 1)
+
9 sqrt (
 x - 1 x + 1
) (
 1 x + 1
-
 x - 1 (x + 1)2
)
2
-
 1 x + 1
-
 x - 1 (x + 1)2
2 sqrt (
 x - 1 x + 1
)
-
 8 (x - 1) x + 1
+
 4 (x - 1)2 (x + 1)2
+ 4
)
 (C8) plot2d(x+sin(x),[x,0,%pi]);
(D8) 0
 (C9)

Here, you can directly define functions or use block structure to define complicate function as (C3). Here, h(x) is defined as x + sin(x) if x>0 and as x - sin(x) if x⩽0. Plotting graph is the best way to understand function. Maxima also applies plot functions, polt2d. The graph is produced in another X-terminal but not in the TeXmacs worksheet. Use another KDE applications to produce the graph and embed the graph into the worksheet by:

1. Press [KDE] → [graph] → [ksnapshot] to catch the graph and save it,
2. Press [Insert] → [Image] → [Insert Image] to embed the picture file and scale the sizes of height and width if necessary.

Example 8. (3D Brownian Motion Particle's Trajectory) Although the graphs of produced by Octave can be embedded into worksheet in general, but it does not always work. example, the following Octave code is is used to simulated Brownian motion within 1 second with time interval, 1/500 sec. Then output the 3D trajectory of particle in encapsulated postscript format:

1. Prepare the image file in the one of following formats: PS, EPS, pdf, fig, png, tif, xpm, fig etc. Or,
2. Make graph from CAS and save the screen-shot or store it directly into storage. For

1. Open [Text] →[Session] →[shell], execute the following octave code to make graph:

GNU Octave, version 2.1.45 (i686-pc-linux-gnu).

Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 John W. Eaton.

This is free software; see the source code for copying conditions.

There is ABSOLUTELY NO WARRANTY; not even for MERCHANTIBILITY or

FITNESS FOR A PARTICULAR PURPOSE.

Report bugs to <bug-octave@bevo.che.wisc.edu>.

 octave> t_total=1;
 octave> t_step=500;
 octave> dim=3;
 octave> init_po=[0,0,0];
 octave> increment=sqrt(t_total/t_step)*randn(t_step,dim);
 octave> po=[init_po;increment]; b(1,:)=zeros(1,dim);
 octave> gset parametric;
 octave> gset xrange [-2:2];
 octave> gset yrange [-2:2];
 octave> gset zrange [-2:2];
 octave> for i=2:t_step b(i,:)=po(i,:)+b(i-1,:); endfor
 octave> gset set term postscript enhanced color eps;
 octave> gset xtics 1;gset ytics 1; gset ztics 1;
 octave> gset output '/home/cchuang/texmacs/brownian.eps';
 octave> gsplot b title "3D Brownian Motion";
 octave>

2. After executing the code, brownian.eps is created. Terminate the session and back to the TeXmacs environment. Now choose [Insert] →[Image] → [Insert image] to embed the result graph as follows:

Octave can use the gnuplot syntax to generate graph, but cannot interpreter the resulted PostScript code. Theirfore output the graph and embed it back.

If the effect is not good-looking enough, you can consider another application session, Gnuplot. Gnuplot is more flexible since it applies many utility functions to manipulate graph, including the off-line modification. For example, press [Text] →[Sessions] →[Gnuplot] enters the session. Some simple examples as follows:

This is a TeXmacs interface for GNUplot.
 GNUplot] plot [-pi/2:pi/2][-2:2] x+sin(x)
 GNUplot] set noclip ~set yrange[-30:10] ~plot x*(abs((x-4)/(x+4)))**(1./2.)
 GNUplot]

 GNUplot] set key left ~set xlabel 'x:[cm]' ~ plot [-pi/2:pi/2] x+sin(x)
 GNUplot] set xlabel 'x:[cm]' ~ plot sin(x)
 GNUplot] set pm3d hidden 100 ~set style line 100 lt 3 ~set nosurface ~set size 0.7,1 ~set view 80,180,1,1 ~set noborder ~set noxtics ~set noytics ~set noztics ~set parametric ~set samples 36 ~set isosamples 20,36 ~set ticslevel 0 ~set nocolorbox ~set urange [0:pi] ~set vrange [0:2*pi] ~splot sin(u)*cos(v),sin(u)*sin(v),cos(u)
 GNUplot] set xrange[-5:5] ~set yrange[-2:2] ~f(x)=x<0?-1:1 ~plot f(x)
 GNUplot]

Due to the auto-scaling effect, not all the range of domain of x + sin(x) is shown in the first graph. After given the range of variable of x, we can observe the graph more explicitly. But how about "set xlabel '[x]'" in single line with other plotting command lines? Due to bug interpretation of the interface of gnuplot, tm_gnuplot, gnuplot cannot handle this code with ghostscript. Instead of inputting plot and set option in different lines, input "set options ~ plot ⋯" to add the set option in normal plotting command. Try directly execute the above code to see what about the differences between two statements. Almost CAS's have their plotting philosophy. For example, Octave, the other famous one, not only has its built-in command, plot, but also fully supports the Gnuplot functions, only by adding a pre "g" before the relative plotting commands.

GNU Octave, version 2.1.45 (i686-pc-linux-gnu).

Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 John W. Eaton.

This is free software; see the source code for copying conditions.

There is ABSOLUTELY NO WARRANTY; not even for MERCHANTIBILITY or

FITNESS FOR A PARTICULAR PURPOSE.

Report bugs to <bug-octave@bevo.che.wisc.edu>.

 octave> x=linspace(-10,10,1000);
 octave> y=x+sin(x);
 octave> plot(x,y,";Function y=x+sin(x);");

 octave> gset term postscript enhanced eps color;
 octave> gset output "demo.eps"
 octave> plot(x,y,";Function y=x+sin(x);")

 octave>

In the octave generic terminal, the graph will not appear instead of demo.eps being created. By the way, note that its syntax is similar to Matlab but not similar to Maple.

Maxima applies many functions for mathematical calculation, for example, it can be also used to solve the algebra equations:

GCL (GNU Common Lisp) Version(2.5.0) űgďŋ 2ďë 7 19:50:19 CST 2003

Licensed under GNU Library General Public License

Contains Enhancements by W. Schelter

Maxima 5.9.0rc3 http://maxima.sourceforge.net

Distributed under the GNU Public License. See the file COPYING.

Dedicated to the memory of William Schelter.

This is a development version of Maxima. The function bug_report()

provides bug reporting information.

 (C1) linsolve([a*x+b*y=m,c*x+d*y=n],[x,y]);
(D7) [ x = -
 d m - b n b C - a d
, y =
 C m - a n b C - a d
]
 (C8) solve(x^3-x=0,x);
(D8) [x = - 1,x = 1,x = 0]
 (C9) diff((x^2+a)^(1/2),x);
(D9)
 x sqrt (x2 + a)
 (C10) integrate((x^2+a)^(1/2),x);
 Is a positive or negative? positive
(D10)
a ASINH(
 x sqrt (a)
)
2
+
 x sqrt (x2 + a) 2
 (C11) integrate((x^2+a)^(1/2),x,0,1);
 Is a positive or negative? negative
(D11)
 a log (2 sqrt (a + 1) + 2) + sqrt (a + 1) 2
-
 log (2 sqrt (a)) a 2
 (C12) limit((x^2+a)^(1/2),x,0);
(D12) sqrt (a)
 (C13)

The symbolic calculation of Maxima has shown above, including solving equations, evaluating limit, differentiation and integration. In the examples of integration, maxima will ask the user more conditions if necessarily.

Now let us introduce Yacas (yes, another CAS). The following is mini demo:

 yacas] Solve(x^3+b+1==0,x);
sqrt3 (b + 1)
 yacas] D(x) (x^2+a)^(1/2);
(x2 + a)
 - 1 2
2x
2
 yacas] Limit(x,0) (1-Cos(x))/x^2;
 1 2
 yacas] Integrate(x,0,pi) x+Sin(x);
 π2 2
- (cos π) + 1
 yacas] f(x):= x+sin(x);
True
 yacas] GnuPlot(-Pi/2,Pi/2,80,f(x));
GnuPlot( -
 π 2
,
 π 2
,80, f ( x ))
 yacas]

The last command of plotting will not have any correspondence here.

Exercise 1. Plot the graphs of the following functions: a) x2 + 3x - 2 b)

 x2 + 1 x4 + x + 1
c) sqrt (s2 + 1)

d)

 sin(πx/2) - 1 1 - x2
e) x3 +
 3 x2
f) (x + 1)1/3

Exercise 2. Plot the graph of the function:

f ( x ) = {
 (x + 1)2 if x> - 1, x + 1 otherwise
.

Exercise 3. Solve 3x + 4y = 5, 9x + 10y = 11 for x,y.

Exercise 4. Differentiate the functions in Exercise 1.

Which application with plotting ability is excellent? This answer will be different for different persons. From my view, Maxima or Gnuplot is better one if the solutions of functions are in explicit form. But if the solution are in implicit form, consider the tools with numerical utility, for example Octave.

Example 9. (Butterfly Effect) Remember what the crazy physician said about this in movie "Jurassic Park". This is one phenomenon about atmosphere and named by its solution curve. This effect depends on the differential equations:

 d x1(t) d t
= - 10(x1(t) - x2(t))
 d x2(t) d t
= 28x1(t) - x2(t) - x1(t)x3(t)
 d x3(t) d t
=
 8 3
( x1(t)x2(t) - x3(t) )
Initial condition: x1(0) = 2, x2(0) = 5, x3(0) = 10

Solve this initial value problem by Octave:

GNU Octave, version 2.1.45 (i686-pc-linux-gnu).

Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 John W. Eaton.

This is free software; see the source code for copying conditions.

There is ABSOLUTELY NO WARRANTY; not even for MERCHANTIBILITY or

FITNESS FOR A PARTICULAR PURPOSE.

Report bugs to <bug-octave@bevo.che.wisc.edu>.

 octave> x0=[2;5;10];
 octave> t = linspace (0,10,800);
 octave> function dx = butter (x ,t) dx(1) = -10.0*(x(1)-x(2)); dx(2) = 28.0*x(1)-x(2)-x(1)*x(3); dx(3) = 8.0/3.0*( x(1)*x(2) -x(3) ); end;
 octave> y=lsode("butter",x0,t);
 octave> gset parametric;
 octave> plot(y(:,1),y(:,3))

 octave> plot(y(:,2),y(:,3))

 octave> plot(y(:,1),y(:,2))

 octave> gset set term postscript enhanced color eps;
 octave> gset out "/home/cchuang/texmacs/butterfly.eps";
 octave> gset xtics 10;gset ytics 10; gset ztics 10;
 octave> gsplot y title "Butterfly Effect"
 octave>

At the last part of Octave code, we want to save the 3D trajectory as butterfly.eps. Then we can embed this EPS file:

Certainly, we can also save the data of y and plot with Gnuplot.

Before the end of this topic, don't forget to save the result, [File]→[Saved as]. You can choose the default file-extension, tm, then all the data will be stored in XML-like format. If you want to output the data, press "printer" or export as postscript file since the postscript format is full supported in any Linux systems and this format is the default output format in Linux box.

## 4.Graph Gallery

Just as mentioned before, gnuplot is a very professional software for maintaining scientific data. Here, we collect some interesting plots:

This is a TeXmacs interface for GNUplot.
 GNUplot] f(x,y)=x**6+3*y**2*x**4+(3*y**4-4*y**2)*x**2+y**6 ~set pm3d hidden 100 ~set style line 100 lt 6 ~set nokey ~set xrange[-1:1] ~set yrange[-1:1] ~set isosamples 30,30 ~set hidden3d ~set contour ~set cntrparam levels discrete 0.05,0,-0.05,-0.5 ~set size 0.7,1 ~splot -f(x,y) w dots lt 2
 GNUplot] set pm3d at s ~set palette rgb 3,3,3 ~set nocolorbox ~set parametric ~set nokey ~set noztics ~set urange[-5:5] ~set vrange[0:10] ~set yrange[0:10] ~set zrange[0:1] ~set isosamples 100,100 ~set view 0,0,1.5,1 ~set multiplot ~set size 1,1 ~set origin 0,0 ~set nosurface ~splot u, v, (v< u**2)? 1:0.8 ~set size 1,1 ~set origin ~set surface ~splot u, u**2, 1 with lines lt 1 lw 3 ~unset multiplot
 GNUplot] set pm3d ~set palette rgbform 9,8,9 ~set parametric ~set hidden3d ~set urange [0:2*pi] ~set vrange [-pi:pi] ~set isosamples 24,16 ~set size 0.8,1 ~set view 60,20,1,1 ~set ticslevel 0 ~x1(u,v)=cos(u)+.5*cos(u)*cos(v) ~y1(u,v)=sin(u)+.5*sin(u)*cos(v) ~z1(u,v)=.5*sin(v) ~x2(u,v)=1+cos(u)+.5*cos(u)*cos(v) ~y2(u,v)=.5*sin(v) ~z2(u,v)=sin(u)+.5*sin(u)*cos(v) ~splot x1(u,v), y1(u,v), z1(u,v) lt 3, x2(u,v), y2(u,v), z2(u,v) lt 5
 GNUplot] ~set pm3d at s solid ~set palette rgb -7,-15,-6 ~set nocolorbox ~set ticslevel 0 ~set nosurface ~set noztics ~set hidden3d ~set isosamples 70,70 ~complex(x,y)=x*{1,0}+y*{0,1} ~mandel(x,y,z,n) = (abs(z)>2.0 || n>1000)?log(n):mandel(x,y,z*z+complex(x,y),n+1) ~a=-0.37 ~b=-0.612 ~set multiplot ~set origin 0,0 ~set size 0.5,0.7 ~splot [-0.5:0.5][-0.5:0.5] mandel(a,b,complex(x,y),0) ~set origin 0.35,-0.15 ~set size 0.7,1.05 ~set view 0,0,,, ~splot [-0.5:0.5][-0.5:0.5] mandel(a,b,complex(x,y),0) ~set nomultiplot
GNUplot]

set pm3d ~set pal rgb 15,7,5 ~set nocolorbox ~set noxtics ~set noytics~ set noztics ~Order=13 ~Range=2**Order ~br=0.4616 ~bi=0.4616 ~cr=0.6200 ~ci=-0.197~ ~set parametric ~Fx(x,y,n,c)= c>0? n%2==0 ? Fx(br*x+bi*y, bi*x-br*y, n/2, c-1): Fx(cr*x-ci*y-cr+1, ci*x+cr*y-ci,n/2,c-1) : x ~Fy(x,y,n,c)= c>0? n%2==0 ? Fy(br*x+bi*y, bi*x-br*y, n/2, c-1): Fy(cr*x-ci*y-cr+1, ci*x+cr*y-ci,n/2,c-1) : y ~set samples 2 ~set isosamples Range,2 ~set urange[1:Range] ~set border 0 ~set view 0,0,1.8, ~set label "b=0.4616+0.4616i, c=0.62-0.197i" at 0.1,-0.02 ~splot Fx(0,0,int(u),Order), Fy(0,0,int(u),Order), int(u)%64 notitle w dots lt pal

 GNUplot]

 GNUplot] ~set pm3d at s; ~set pal rgb 9,9,3 ~set nocolorbox ~set parametric ~set hidden3d ~set ticslevel 0 ~set noxtics ~set noytics ~set noztics ~set border 0 ~set nokey ~set isosamples 48,18 ~set size 0.6,1 ~set view 70,190,1.4,1 ~set urange[0:2*pi] ~set vrange[0:2*pi] ~f(u)=1/(1+exp(u-pi)**10) ~r(u)=f(u)*sin(u/2)**4*exp(-2*u)*u**3+0.01 ~x(u,v)=r(u)*cos(v)+0.003*sin(u/2)**4*exp(-2*(pi-u))*(pi-u)**3 ~y(u,v)=r(u)*sin(v) ~z(u)=sin(u) ~splot x(u,v),y(u,v),z(u) lt 6

 GNUplot] ~set pm3d at s solid ~set palette rgb 7,0,0 ~set nocolorbox ~set parametric ~set border 0 ~set hidden3d ~set nokey ~set noxtics ~set noytics ~set noztics ~set isosamples 30,18 ~set view ,,1.2,1 ~set ticslevel 0 ~set urange[0:pi] ~set vrange[-pi:pi] ~splot sin(u)*cos(v),sin(u)*sin(v),cos(u)+sin(u) lt 6
 GNUplot] ~set pm3d at s solid ~set palette rgb 7,8,3 ~set nocolorbox ~set parametric ~set border 0 ~set hidden3d; set nokey ~set noxtics ~set noytics ~set noztics ~set ticslevel 0 ~set isosamples 48,48 ~set view 70,330,1.5,1 ~set urange[0:pi] ~set vrange[-pi:pi] ~r(u,v,a) = abs(sin(u*2)*cos(v*2))**a ~x(u,v,a) = r(u,v,a)*sin(u)*cos(v) ~y(u,v,a) = r(u,v,a)*sin(u)*sin(v) ~z(u,v,a) = r(u,v,a)*cos(u) ~a=0.7; ~splot x(u,v,a),y(u,v,a),z(u,v,a) w lines 6
 GNUplot]

## 5. Conclusions

From user's view, plenty of packages can be used is a good news. But in practical, users are not necessary to learn all the syntaxes of different tools. Just focus on how to solve the problems. For example, there are maxima, octave and Scilab etc. many CAS softwares famous for their facilities to solve mathematical problems. Maxima and Yacas are known due to symbolic computing ability but only supports few basic function, and others are famous for their portable syntaxes (like propriety software, Matlab or Maple) and many, many functions but without symbolic ability. With the help of TeXmacs, we can solve right problems by using suitable tools. We will introduce other softwares in the latter chapters.

Among the tools packages in Linux we introduce in TeXmacs environment here, some experiences have to be kept in mind:

1. Maxima and Yacas are the powerful softwares for symbolic calculation;
2. Gnuplot and other CAS's can used to plot the graphs in 2D, 3D and scientific data plots. But the Gnuplot is the best recommended software since the graph that it generates can be directly embedded into the worksheet in TeXmacs.
3. Also there are many powerful softwares with numerical abilities in Linux world, for example: Octave, Lab, Scilab and R (check your "session options" or the TeXmacs_INSTALL/lib exec). But Scilab owns its "terminal session" which is not easily embedded into the TeXmacs, Octave is the best choice due to its full accessibility.
4. Output format: Postscript format is the best choice as above mentioned. For the Windows user and not heard about this format, HTML format may be the suitable one. But for mathematical document, it is may be a bad news that directly output the HTML from TeXmacs is generally non-satisfied. If you want to generate HTML files, LaTeX2html maybe have some help. Consider to export LaTeX format from TeXmacs and use the following latex2html command to translate TeX file into HTML and picture files:

> latex2html -nonavigation -split 0 filename.tex

if you want only one HTML file with picture files without navigation icons. Suppose that there are plenty of pictures generated by CAS's in your TeXmacs file, some modifications have to be made by your hand. The reason is that no PS Tricks implement yet in latex2html and this is just the TeX package used by TeXmacs to make in-line Postscript graphs. First capture the pictures by picture capture program, e.g. ksnapshot or GIMP, by CAS's in another xterm and save it as eps format. Then edit the LaTeX file, removing all lines including "cat code ⋯" in presume part and adding the eps graphs as follows :

\document[12pt]{article}
\package[dvips]{graphics}
⋯
% remove all the line beginning with "catcode"
⋯
\begin{document}
⋯
\begin{center}
\resizebox{150mm}{!}{\includegraphics{picture.eps}}
\end{center}
⋯
\end{document}

Mainly, add the graphics package and use \include graphics{} to put the graph. And use above latex2html commands to translate the contents. The directory named by its filename will be created with HTML file, and png files.

Hope this mini introduction help everybody. Any question or comment email:

Resources:

1. TeXmacs: There is a excellent on-line document in [Help] option.
2. Maxima: After installing maxima, maxima with text-based interface and Maxima with graphical user interface will be installed. And the full documents and demo's will be put in the directory, /usr/local/share/maxima/.
3. Gnuplot: No document has been installed after installing this package. Reference the official web-site: HTTP://www.gnuplot.info for more relative topics and also visit the graph gallary: http://ayapin.firm.s.dendai.ac.jp/~matuda/Gnuplot/pm3d.html
4. Octave: download site at http://octave.sf.net
5. LaTeX2html: download site at http://www.latex2html.org

Note 10. Solutions for the exercises:

This is a TeXmacs interface for GNUplot.
 GNUplot] plot x**2+3*x-2
 GNUplot] plot (x**2+1)/(x**4+x**2+1)
 GNUplot] plot sqrt(x**2+1)
 GNUplot] set xrange[-5:5] ~set yrange[-5:5] ~set grid ~set xtics 1 ~set ytics 1 ~plot (sin(x*pi/2)-1)/(x**2-1)
 GNUplot] set xrange[-5:5] ~set yrange[-100:100] ~set noclip ~plot x**3+3/x**2
 GNUplot] plot (x+1)**(1./3.)
 GNUplot]

Note that gnuplot is sensible for the type of number, integer or real number. If the square is written as 1/2, quotient of integers, instead of the original 1./2., quotient of real numbers, an error will occur due to the rational power. Turn to the Maxima session:

GCL (GNU Common Lisp) Version(2.4.4) űgď@ 2ďë 17 15:25:31 CST 2003

Licensed under GNU Library General Public License

Contains Enhancements by W. Schelter

Maxima 5.9.0 http://maxima.sourceforge.net

Distributed under the GNU Public License. See the file COPYING.

Dedicated to the memory of William Schelter.

This is a development version of Maxima. The function bug_report()

provides bug reporting information.

 (C1) plot2d((1+x)^(1/3),[x,-5,4]);
(D1) 0
 (C2)

The result is:

This is a TeXmacs interface for GNUplot.
 GNUplot] set key left ~set xrange[-5:5] ~f(x)=x>-1?(x+1)**2:x+1 ~plot f(x)
 GNUplot]

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".