Using Octave sessions inside TeXmacs

GNU Octave is a free clone of Matlab, which can be downloaded from

    http://octave.sf.net

An Octave session is started using TextSessionOctave. Below, it is shown how to do linear algebra operations with Octave, such as matrix multiplication, inversion and diagonalization. Notice that you need to use the tmdisp command (at the moment) in order to display the output in mathematical form.

GNU Octave, version 2.1.40 (i386-redhat-linux-gnu).

Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 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>

A=[1 0 0 0;2 2 0 0;-1 0 2 0;0 -1 2 2]

A =

1 0 0 0

2 2 0 0

-1 0 2 0

0 -1 2 2

octave>

tmdisp(A^2)

(
1 0 0 0
6 4 0 0
- 3 0 4 0
- 4 - 4 8 4
)
octave>

tmdisp(A.^2)

(
1 0 0 0
4 4 0 0
1 0 4 0
0 1 4 4
)
octave>

[u,v]=eig(A)

u =

0.00000 0.00000 0.00000 0.21320

0.00000 0.00000 0.00000 -0.42640

0.00000 0.00000 0.00000 0.21320

1.00000 1.00000 -1.00000 -0.85280

v =

2 0 0 0

0 2 0 0

0 0 2 0

0 0 0 1

octave>

Q=[1 0 0 0;-2 2 1 0;1 1 0 0;-4 0 0 -1]

Q =

1 0 0 0

-2 2 1 0

1 1 0 0

-4 0 0 -1

octave>

P=inv(Q)

P =

1 -0 0 0

-1 0 1 0

4 1 -2 0

-4 0 0 -1

octave>

P*A*Q

ans =

1 0 0 0

0 2 0 0

0 0 2 0

0 0 1 2

octave>

The second part shows the graph capacity of Octave, 2D and 3D graphs. 2D graphs can be automatically embedded into the worksheet but 3D graphs are not yet.

octave>

x=linspace(-10,10,1000);

octave>

y=x+sin(x);

octave>

plot(x,y,";Function y=x+sin(x);");

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>

gset set term postscript enhanced color eps;

octave>

gset xtics 10;gset ytics 10; gset ztics 10;

octave>

gset out "/tmp/butterfly.eps";

octave>

gsplot y title "Butterfly Effect"

octave>

In order to embed the 3D graph, we first save it as butterfly.eps in /tmp directory. Then we can embed this EPS file into the worksheet using InsertImage.

Figure 1. Embedded 3D graph from Octave.

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".