I am curious how others feel about having a Symbolic toolbox for
Octave. I would like to see this happen. I have done some work in this
respect and I would like to here how others feel about putting some of
my work into Octave when it is a bit more stable.
I have used a recently developed symbolic library known as
GiNaC.(http://www.ginac.de) GiNaC is written in C++. What I have done
is a fairly simple extension of GiNaC. GiNaC has a number of classes
that it uses to manipulate equations: ex(e.g. x+y, 2*x^2),symbol(e.g.
x,y),numeric(arbitrary precision) relationals(e.g. x==y,x<=y). I have
created wrapper classes for ex,symbol and numeric that can be installed
in Octave with a .oct file. Here is some examples of what I can do
with what I have written so far(with comments):
********************************************************************
## This installs the classes as well as operators for the classes
## currently this must be executed before any thing else will work.
octave:1> symbols
installing ex type at type-id = 18
installing sym type at type-id = 19
installing numeric type at type-id = 20
## Defines a symbolic variable
octave:2> x = sym("x")
x =
x
## creates an expression from the symbolic variable
octave:3> a = x^2+2*x+1
a =
1.0+(2.0)*x+x^(2.0)
## calculate the deriviative of a with respect to x.
octave:4> differentiate(a,x)
ans =
2.0+(2.0)*x
## set the precision of the numeric calculations.
octave:6> digits(1000)
## calculate Pi to 1000 digits.
octave:7> Pi
ans =
3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273724587006606315588174881520920962829254091715364367892590360011330530548820466521384146951941511609433057270365759591953092186117381932611793105118548074462379962749567351885752724891227938183011949129833673362440656643086021394946395224737190702179860943702770539217176293176752384674818467669405132000568127145263560827785771342757789609173637178721468440901224953430146549585371050792279689258923542019956112129021960864034418159813629774771309960518707211349999998372978049951059731732816096318595024459455346908302642522308253344685035261931188171010003137838752886587533208381420617177669147303598253490428755468731159562863882353787593751957781857780532171226806613001927876611195
90!
9216420198938095257201
## Convert my numeric type approximation of Pi to a double.
octave:8> numeric_to_double(Pi)
ans = 3.1416
octave:9>
******************************************************
Not all the things that need to be implemented have been implemented
and, all of the things that have been implemented are not as stable as
they will need to be. However, this is a start. You can get the
package at http://www.neutrino.lanl.gov/~bsapp/octave/symbolic.tar.gz
GiNaC requires Bruno Haible's Class Library for Numbers package. Both
CLN and GiNaC are under the GNU GPL. I do not think it would be wise to
require Octave to have GiNaC to compile. It would make Octave too big
to include both of these packages also. I think configure should check
for GiNaC and build the toolbox if it finds it otherwise leave it out.
To help configure there should probably be a --with-ginac flag. The
GiNaC maintainers have made this fairly easy. They have created a macro
designed to be used by autoconf.
Please let me know what you think of all this. Thanks.
--
Ben Sapp Los Alamos National Laboratory
email: <mailto:address@hidden> Phone: (505)667-3277
Fax: (505)665-7920 URL: http://www.neutrino.lanl.gov/
--