
        SymbMath 2.1: A Symbolic Calculator with Learning

		by Dr. Weiguang HUANG
	5/6 Cara Road, Geelong, Vic. 3216, Australia
	Phone: 61-52-443282,	Email: huang@deakin.oz.au

        SymbMath (an abbreviation for Symbolic Mathematics) is not
only a symbolic calculator but also an expert system that can solve 
symbolical math problems. SymbMath will also perform exact numeric 
computation. It can manipulate complicated formulas and return answers 
in terms of symbols, formulas and exact numbers. 
	SymbMath is different from other software:
        (1) It is able to learn from users.  If users only input one 
	    formula (e.g. one derivative) without writing any code, 
            it will automatically learn many problems (e.g. 
	    derivatives, indefinite and definite integrals) related 
	    to this formula.
        (2) Users edit the library (e.g. integral tables) in "formula 
	    format" by any text editor. 
        (3) It runs on small IBM PCs (8086) with 640 KB under MS-DOS. 
        Its capabilities include facilities to provide analytical and 
numerical answers for:
         o  Differentiation: regular or higher order, partial or
            total, mixed and even implicit differentiation,
	    one-sided derivatives.
         o  Integration: indefinite or definite integration, 
            multiple integration, infinity as a bound, parametric
            integration, iterated integration, line or surface 
            integrals, discontinuous or implicit integration.
         o  Solution of equations: roots of a polynomial, systems of
            algebraic or differential equations.
         o  Manipulation of expressions: simplification, factoring or 
	    expansion, substitution, evaluation, built-in standard or 
	    user-defined functions.
         o  Calculation: exact and floating-point numerical 
            computation of integer, rational, real and complex
            numbers in the range from minus to plus infinity, even
            with different units.
         o  Limits: real or complex limits, one-sided limits, 
            indeterminate forms.
	 o  Complex: calculation, functions, derivatives, integration.
	 o  Sum and product: finite or infinite, partial.
         o  Chemical calculation: molecular and atomic weights,
            concentrations (all by entering the symbols of the
            chemical elements).
         o  Chemical reactions: inorganic and organic. 
         o  Other: series, lists, arrays, vectors, matrices, tables, etc.
	Also included are:
         o  Pull-down and pop-up menus, resizable and colourable windows.
         o  Twin screen text editor with syntax check.
         o  Programming in integrated edit-interpret-debug environment.
         o  Reading and generating BASIC and FORTRAN codes.
         o  Displaying two-dimensional math notation.
         o  On-line help, and on-line manual.
         o  Interface with other software (e.g. with PlotData for graph).
	It has three versions: Shareware, Student, and Advanced. The 
shareware version is available from SIMTEL20 archives on anonymous FTP sites 
(wsmr-simtel20.army.mil as /calculator/sm21a.zip, rana.cc.deakin.oz.au as 
/huang/sm21a.zip, etc) or by e-mail from listserv@ndsuvm1.bitnet. 

		    15.17 Learning from Users

	The most important feature of SymbMath is that SymbMath can
learn from users to deduce and expand its knowledge. If users provide
the necessary facts, then SymbMath can solve many problems it could 
not do before.


	15.17.1 Learning indefinite and definite integrals from
		derivatives

	If users provide derivatives, SymbMath can deduce indefinite 
and definite integrals from derivatives. 

	Example 15.17.1. 
First check SymbMath wether or not it had already known indefinite and 
definite integrals of exp(x)/x^2 or exp(x)/x^3.
	Input:
inte(exp(x)/x^2*d(x))
inte(exp(x)/x^3*d(x))
inte(exp(x)/x^2, x from 1 to 2)
	Output:
inte(exp(x)/x^2*d(x))
inte(exp(x)/x^3*d(x))
inte(exp(x)/x^2, x from 1 to 2)

Teach SymbMath derivative of Ei(x) on the first line, and then run again.
	Input:
d(Ei(x)/d(x))=exp(x)/x
inte(exp(x)/x^2*d(x))
inte(exp(x)/x^3*d(x))
inte(exp(x)/x^2, x from 1 to 2)
	Output:
d(Ei(x)/d(x)) = exp(x)/x
constant - exp(x)/x + Ei(x)
constant - 1/2*(x^(-2)*exp(x) + exp(x)/x - Ei(x))
e + Ei(2) - Ei(1) - 1/2*exp(2)

	Users only tell SymbMath a derivative of Ei(x), did not say 
anything about indefinite or definite integrals, about the functions 
exp(x)/x^2 or exp(x)/x^3, did not write any code (a function, 
procedure or subroutine), did not load any file, did not call any 
subroutine. Ei(x) is the exponential integral function, instead of 
a standard function nor the built-in function in SymbMath.
	Why does SymbMath become to have these knowledge ? Because
SymbMath logically deduces these integrals from d(Ei(x)/d(x)).
This is learning from users.

	Example 15.17.2. 
Users want to do integration on sin(x)/x^3. First check if 
integral of sin(x)/x^3 or derivative of Si(x) had already been stored 
in SymbMath.
	Input:
d(Si(x)/d(x))
inte(sin(x)/x^3*d(x))
	Output:
d(Si(x)/d(x))
inte(sin(x)/x^3*d(x))

Users enter a derivative, then ask the integral of sin(x)/x^3.
On this time, only change the first line, and then run again.
	Input:
d(Si(x)/d(x))=sin(x)/x
inte(sin(x)/x^3*d(x))
	Output:
d(Si(x)/d(x)) = sin(x)/x
-1/2*(Si(x) + cos(x)/x + x^(-2)*sin(x)) + constant

		
	15.17.2 Learning complicated indefinite integrals from a
		simple indefinite integral

	Users supply a simple indefinite integral, and then ask many
complicated indefinite integrals.

	Example 15.17.3. 
Check whether SymbMath had already known the following
integrals or not (i.e. to check if these integrals had already been
stored in the data base or knowledge base, these checking would be
omitted if users trust SymbMath without these predefined knowledge).
	Input:
inte(tan(x)^2*d(x))
inte((2*tan(x)^2+x)*d(x))
inte(inte(tan(x)^2+y)*d(x))*d(y))
	Output:
inte(tan(x)^2*d(x))
inte((2*tan(x)^2+x)*d(x))
inte(inte(tan(x)^2+y)*d(x))*d(y))

Users show that an indefinite integral of tan(x)^2 is tan(x)-x, then 
ask indefinite integral of 2*tan(x)^2+x, and a double indefinite 
integral of tan(x)^2+y respect with both x and y. On this time, only 
change the first line, and then run again.

	Input:
inte(tan(x)^2*d(x)) = tan(x) - x
inte((2*tan(x)^2+x)*d(x))
inte(inte(tan(x)^2+y)*d(x))*d(y))

The first input line is to teach SymbMath the indefinite integral of
tan(x)^2. The second and third input lines are to ask the indefinite
integral of 2*tan(x)^2+x and the double indefinite integral of
tan(x)^2+y.

	Output:
inte(tan(x)^2*d(x)) = tan(x) - x
2 (tan(x) - x) + 1/2*x^2
tan(x)*y - x*y + x*y^2

Users will ask inte(inte(tan(x)^2+y^2)*d(x))*d(y)),
inte(inte(tan(x)^2*y)*d(x))*d(y)), inte(x*tan(x)^2*d(x)),
triple integral of tan(x)^2-y+z, or others.


	15.17.3 Learning definite integral from indefinite integral

	Users continue to ask definite integrals as well.

	Input:
inte(inte(tan(x)^2+y, x from 0 to 1), y from 0 to 2)
	Output:
2 tan(1)

	Notice that SymbMath has not had knowledge of all of these
integrals before. Users did nothing, except for only telling SymbMath
one simple indefinite integral of tan(x)^2, did not tell SymbMath
anything about other indefinite integral (e.g. tan(x)^2+y, tan(x)^2+x,
etc.), any indefinite double integral, definite integral, or definite
double integral.


	15.17.4 Learning complicated derivative from simple
		derivative

	SymbMath can learn complicated derivatives from a simple 
derivative, even thought the function to be differentiated is any 
function, not only a standard function.

	Example 15.17.4. 
Users want to differentiate Ci(x)^6, where Ci(x) is a cosine integral 
function instead of a standard function.
	Input:
d(Ci(x)/d(x))
d((Ci(x)^6)/d(x))
	Output:
d(Ci(x)/d(x))
d((Ci(x)^6)/d(x))

Now, alter the first line only, and then run again.
	Input:
d(Ci(x)/d(x))=cos(x)/x
d((Ci(x)^6)/d(x))
	Output:
d(Ci(x)/d(x)) = cos(x)/x
6 Ci(x)^5*cos(x)/x


		15.17.5 Learning integration from algebra

	If users tell SymbMath algebra, SymbMath can learn integrals
from algebra. 

	Example 15.17.5. 
Users input sin(x)^2=1/2-1/2*cos(2*x), then ask integral of sin(x)^2.
	Input:
sin(x)^2=1/2-1/2*cos(2*x)
inte(sin(x)^2*d(x))
	Output:
sin(x)^2 = 1/2 - 1/2*cos(2*x)
1/2*x - 1/4*sin(2*x)

	SymbMath have learned to solve these problems, even though 
the types of problems are different, e.g. learning integrals from 
derivatives or algebra.


	15.17.6 Learning complicated algebra from simple algebra

	SymbMath has the ability to learn complicated algebra from
simple algebra.

	Example 15.17.6. 
Transform sin(x)/cos(x) into tan(x) in an expression.
	Input:
sin(x)/cos(x)=tan(x)
x+sin(x)/cos(x)+a
	Output:
sin(x)/cos(x) = tan(x)
a + x + tan(x)

	Learning is different from programming. On learning, although
users only input one formula, SymbMath will learn many knowledge.
SymbMath is able to learn, as a student does. On programming, users 
have many things to do. First, users define many subroutines for the
individual integrands (e.g. tan(x)^2, tan(x)^2+y^2, 2*tan(x)^2+x, 
x*tan(x)^2, etc.), and for individual integrals (e.g. the indefinite 
integral, definite integral, the indefinite double integrals, 
indefinite triple integrals, definite double integrals, definite 
triple integrals, etc.), second, write many lines of program for the
individual subroutines, (i.e. to tell the computer how to calculate
these integrals), third, load these subroutines, finally, call these
subroutines.
	In one word, programming means that programmers must
provide step-by-step procedures telling the computer how to solve
each problems. By contrast, learning means that users need only supply
the necessary facts, SymbMath will determine how to go about
solutions.
	If the learning is saved into a disk as a disk file or library, 
SymbMath will never forget it. 

-----------------

	Here are some problems that Maple and Mathematica cannot 
solve, but SymbMath can do. 
	The following examples came from news on the sci.math.symbolic 
newsgroup in 1991, and were run in Maple V, Mathematica 2.0, or  
SymbMath 2.1. 

************************ Example 1 ******************************
	Maple:
> int(exp(-a * x^2), x=0..infinity);

                             infinity
                                /
                               |               2
                               |      exp(- a x ) dx
                               |
                              /
                              0

# unevaluated.
# Declare 'a' non-negative:

> signum(a) := 1;

                                 signum(a) := 1

# The same integral is now evaluated fully:

> int(exp(-a * x^2), x=0..infinity);

                                         1/2
                                       Pi
                                   1/2 -----
                                         1/2
                                        a

	SymbMath :
	Input:
inte(exp(-a*x^2), x from 0 to inf)
assume(sqrt(a) > 0)
inte(exp(-a*x^2), x from 0 to inf)
	Output:
1/2*a^(-0.5)*sqrt(pi)*erf(inf*sgn(sqrt(a)))
assumed
1/2*a^(-0.5)*sqrt(pi)

************************** Example 2 *********************************
	Maple:
# Despite the fact that 'n' is declared non-negative...
> signum(n) := 1;
                                 signum(n) := 1

# ...this simple proper definite integral (that any freshman calculus 
# student can evaluate!) is left unevaluated:
> int(x^n, x=0..1);

                                     1
                                     /
                                    |   n
                                    |  x  dx
                                    |
                                   /
                                   0


	SymbMath :
	Input:
assume(n > -1)
inte(x^n, x from 0 to 1)
	Output:
assumed
1/(1 + n)

************************** Example 3 *****************************
	Maple:
> int(x^n, x=eps..1);

                                          (n + 1)
                                 1     eps
                               ----- - ----------
                               n + 1      n + 1

# ...but the one-sided limit...

> limit(", eps=0, right);

                                               (n + 1)
                                      1     eps
                          limit     ----- - ----------
                          eps -> 0+ n + 1      n + 1

# ...remains unevaluated...

> simplify(");

                                               (n + 1)
                                      - 1 + eps
                          limit     - ----------------
                          eps -> 0+         n + 1


# ...no matter what we do!

> eval(");

                                               (n + 1)
                                      - 1 + eps
                          limit     - ----------------
                          eps -> 0+         n + 1

	SymbMath:
	Input:
assume(n > -1)
inte(x^n, x from eps to 1)
subs(eps=0 to last)
	Output:
assumed
1/(1 + n) - eps^(1 + n)/(1 + n)
1/(1 + n)


*************************** Example 4 ***************************
	Maple:
> 0^n;
            0

# Maple flags the error only when 'n' is replaced by the constant 0:

> 0^0;
Error, 0^0 is undefined

	SymbMath:
	Input:
assume(n > 0)
0^n
0^-n
0^0
	Output:
assumed
0
discont
undefined

**************************** Example 5 ******************************
	Maple:
> int(x^k, x);

                                     (k + 1)
                                    x
                                    --------
                                      k + 1

	SymbMath:
	Input:
inte(x^k*d(x))
subs(k=-1 to last)
	Output:
constant + x^(1 + k)/(1 + k)
discont

**************************** Example 6 *****************************
	Maple:
# The following limit is left unevaluated:
> limit(x^k/exp(x), x=infinity);

                                               k
                                              x
                              limit         ------
                              x -> infinity exp(x)


# We might ask if Maple knows this result for specific (constant) values 
# of the symbolic parameter 'k'.  The answer is a QUALIFIED "yes".
# Maple knows the result for 'k' equal to 10^8...

> limit(x^(10^8)/exp(x), x=infinity);

                                       0


# ...and Maple knows the result for 'k' equal to 10^9...

> limit(x^(10^9)/exp(x), x=infinity);

                                       0

# ...BUT, Maple seems to FORGET the result when 'k' equals 10^10...

> limit(x^(10^10)/exp(x), x=infinity);

                                          10000000000       
                                         x                 
                           limit         ------------       
                           x -> infinity    exp(x)         

	SymbMath:
	Input:
lim(x=inf, x^k/exp(x))
lim(x=inf, x^(10^10)/exp(x))
lim(x=inf, x^(10^10000)/exp(x))
	Output:
0
0
0

****************************** Example 7 ****************************
	Maple:
> int(x^m * exp (-b * x), x=0..infinity);

                            infinity
                               /
                              |       m
                              |      x  exp(- b x) dx
                              |
                             /
                             0


# As expected, the integral remains unevaluated.  Now declare the signs 
# of the symbolic parameters:

> signum(b) := 1;

                                 signum(b) := 1

> signum(m) := 1;

                                 signum(m) := 1


# Upon attempting to compute the integral a second time...

> int(x^m * exp (-b * x), x=0..infinity);

                            infinity                        
                               /                            
                              |       m                     
                              |      x  exp(- b x) dx       
                              |                             
                             /
                             0                              

# ...THE INTEGRAL CONTINUES TO REMAIN UNEVALUATED, despite the fact that
# the signs of the parameters 'b' and 'm' were declared PRIOR to the second
# attempt at computation.

	SymbMath:
	Input:
inte(x^n*exp(-a*x), x from 0 to inf)
	Output:
inte(x^n*exp(-a*x), x, 0, inf)


************************ Example 8 *********************************
	Mathematica:
In[1]:= Integrate[1/x,{x,-1,1}]
Out[1]= -Log[-1]

	Maple:
has the same problem.

	SymbMath:
	Input:
inte(1/x, x from -1 to 1)
inte(1/x, x from -1 to 2)
	Output:
0
ln(2)


*************************** Example 9 *******************************
	Maple:
has a problem for int(tan(x), x=0..pi).

	SymbMath:
	Input:
inte(tan(x), x from 0 to pi)
	Output:
0

**************************** Example 10 ****************************
	Mathematica:
cannot evaluate integral of sgn(x).

	Maple:
# cannot evaluate inegral of signum(x) by int(). Help with a procedure:
# Load the procedure into Maple:

> read `pvint.txt`;

pvint := proc(f,x,a,b,s)
         local i1,i2,eps;
             signum(eps) := 1;
             i1 := int(f,x = a .. s-eps);
             i2 := int(f,x = s+eps .. b);
             simplify(i1+i2);
             limit(",eps = 0,right)
         end


> pvint(signum(x), x, -1, 1, 0);

                          - eps                   1
                            /                     /
                           |                     |
               limit       |    signum(x) dx +   |  signum(x) dx
               eps -> 0+   |                     |
                          /                     /
                          -1                   eps

# Maple refuses to evaluate this P.V. integral:

> simplify(");

                          - eps                   1
                            /                     /
                           |                     |
               limit       |    signum(x) dx +   |  signum(x) dx
               eps -> 0+   |                     |
                          /                     /
                          -1                   eps

> eval(");

                          - eps                   1
                            /                     /
                           |                     |
               limit       |    signum(x) dx +   |  signum(x) dx
               eps -> 0+   |                     |
                          /                     /
                          -1                   eps

	SymbMath:
	Input:
inte(sgn(x), x from -1 to 1)
inte(sgn(x), x from -1 to 2)
	Output:
0
1

************************* Example 11 ********************************
Implicit diff. gives 1+y'[x](1+1/y[x])==0; y'[x]==-y[x]/(y[x]+1).

	Mathematica:
 given this eq. as input to DSolve says that built-in 
 procedure can't solve it.

	 MACSYMA:
(c1) depends(y,x)$

(c2) ode2(diff(y,x) = -y/(y+1),y,x);

(d2)                   - log(y) - y = x + %c

(c3) method;

(d3)                         separable


	SymbMath:
solve the differential equation by integration inte() or by dsolve().
	Input:
d(y)/d(x)*(1+1/y) === -1
inte(last*d(x))
Expand=On
dsolve(d(y)/d(x) === -y/(y+1), y)
	Output:
(1 + 1/y)*d(y)/d(x) === -1
y + ln(y*sgn(y)) === constant - x
Expand = On
-y - ln(y*sgn(y)) === constant + x


************************* Example 12 ********************************
	Mathematica:
                 y'[x] = y[x]^(1/2)
                  y[0] = 0

DSolve could not handle it. (It rarely solves anything!!), and the 
RungeKutta package only gave me the solution
             
                    y[x]=0

Obviously, there is another solution viz.

                   y[x] = (x/2)^2   

	SymbMath:
	Input:
dsolve(d(y)/d(x) === sqrt(y), y)
(last/2)^2
	Output:
2*sqrt(y) === constant + x
y === 1/4*(constant + x)^2

************************* Example 13 ********************************
	Maple:	
> sqrt(x*x);
      x 

	Mathematica:
 Sqrt[a^2] evaluates to Sqrt[a^2].

	SymbMath:
	Input:
sqrt(x^2)
assume(a > 0)
sqrt(a^2)
assume(b <0 )
sqrt(b^2)
	Output:
x*sgn(x)
assumed
a
assumed
-b

********************** Example 14 **********************************
	Maple and Mathematica cannot find the integrals of abs(x).

	SymbMath:
	Input:
inte(abs(x), x from -1 to 1)
inte(abs(x)^5*d(x))
	Output:
1
constant + 1/6*abs(x)^6*sgn(x)

---------------------------------------------------------------------

	The following problems are taken from Swokowski's Calculus 
book.  They cause Mathematica to fail because of a singularity in 
the interior of the interval of integration:

        Section 10.4 Problems 3, 12, 15, 16, 23, 29.

The comments "INTEGRAL IS DIVERGENT" and "Principal Value" come from
Macsyma.  Mma gives no indication that anything is amiss.

************************ Problem3 *********************************
	Mathematica:
In[4]:= Integrate[1/x^2,{x,-3,1}]

          4
Out[4]= -(-)                            (* INTEGRAL IS DIVERGENT *)
          3

	SymbMath:
	Input:
inte(1/x^2, x from -3 to 1)
	Output:
inf

************************** Problem12 ***************************
	Mathemtica:
In[6]:= Integrate[x^(-4/3),{x,-1,1}]

Out[6]= -6                              (* INTEGRAL IS DIVERGENT *)

	SymbMath:
	Input:
inte(x^(-4/3), x from -1 to 1)
        Output:
inf

**************************** Problem15  ************************
	Mathematica:
In[7]:= Integrate[1/x,{x,-1,2}]

Out[7]= -Log[-1] + Log[2]

	Maple:
has the same problem.
	
	Macsyma:
	(c7) integrate(1/x,x,-1,2);
	Principal Value
	(d7)                                log(2)

	SymbMath:
	Input:
inte(1/x, x from -1 to 2)
	Output:
ln(2)


********************** Problem16 ************************************
	Mathematica:
In[8]:= Integrate[1/(x^2-x-2),{x,0,4}]

        -Log[-2]   Log[2]   Log[5]
Out[8]= -------- + ------ - ------
           3         3        3

	Macsyma:
	(c8) integrate(1/(x^2-x-2),x,0,4);
	Principal Value
	                                     log(5)
	(d8)                               - ------
	                                       3


	SymbMath:
	Input:
inte(1/(x^2-x-2), x from 0 to 4)
	Output:
-1/3*ln(2) + 1/3*ln(2/5)

***************************** Problem23 **********************
	Mathematica:
In[10]:= Integrate[(1/x^2)Cos[1/x],{x,-1,2}]

                       1
Out[10]= Sin[-1] - Sin[-]              (* INTEGRAL IS DIVERGENT *)
		       2

	SymbMath:
	Input:
y=1/x^2*cos(1/x)
inte(y, x from -1 to 0-zero) + inte(y, x from 0+zero to 2)
	Output:
y = x^(-2)*cos(1/x)
sin(-1) - sin(1/2) + 2*sin(inf)

************************** Problem29 ********************************
	Mathematica:
In[12]:= Integrate[1/(x-4)^2,{x,0,Infinity}]

           1
Out[12]= -(-)                          (* INTEGRAL IS DIVERGENT *)
           4

	SymbMath:
	Input:
y=1/(x-4)^2
inte(y, x from 0 to 4-zero) + inte(y, x from 4+zero to inf)
	Output:
y = (-4 + x)^(-2)
inf

