Artificial Intelligence Applications in Chemistry - American Chemical

MACSYMA is a large, interactive computer system designed to assist engineers, scientists, and mathematicians in solving mathematical problems. A user ...
0 downloads 13 Views 776KB Size
8 Computer Algebra: Capabilities and Applications to Problems in Engineering and the Sciences Downloaded by NORTH CAROLINA STATE UNIV on December 26, 2017 | http://pubs.acs.org Publication Date: April 30, 1986 | doi: 10.1021/bk-1986-0306.ch008

Richard Pavelle M A C S Y M A Group, Symbolics, Inc., Cambridge, M A 02142

MACSYMA is a large, interactive computer system designed to assist engineers, scientists, and mathematicians in solving mathematical problems. A user supplies symbolic inputs and MACSYMA yields symbolic, numeric or graphic results. This paper provides an introduction to MACSYMA and provides the motivation for using the system. Many examples are given of MACSYMA's capabilities with actual computer input and output.

My purpose i n t h i s paper i s t o p r o v i d e a broad i n t r o d u c t i o n t o t h e c a p a b i l i t i e s o f MACSYMA. I t i s my hope t h a t t h i s i n f o r m a t i o n w i l l c r e a t e new u s e r s o f Computer A l g e b r a systems by s h o v i n g what one might e x p e c t t o g a i n by u s i n g them and what one w i l l l o s e by n o t u s i n g them* MACSYMA output i s used and CPU times a r e o f t e n g i v e n . I n some cases I have m o d i f i e d t h e output s l i g h t l y t o make i t more p r e s e n t a b l e . The CPU times c o r r e s p o n d t o a S y m b o l i c s 3600 and t o t h e MACSYMA C o n s o r t i u m machine (MIT-MC) w h i c h i s a D i g i t a l Equipment K L 1 0 . These a r e about e q u a l i n speed and about t w i c e as f a s t as a D i g i t a l Equipment VAX 11/780 f o r MACSYMA c o m p u t a t i o n s . When CPU times a r e n o t g i v e n one may assume the c a l c u l a t i o n r e q u i r e s a t most 10 CPU s e c o n d s . What i s MACSYMA. The development o f the Computer A l g e b r a s y s t e m , MACSYMA» began a t MIT i n the l a t e 60s» and i t s h i s t o r y has been d e s c r i b e d e l s e w h e r e Q . ) . A few f a c t s w o r t h r e p e a t i n g a r e t h a t a g r e a t d e a l o f e f f o r t and expense v e n t i n t o MACSYMA. There a r e e s t i m a t e s t h a t 100 man-years o f d e v e l o p i n g and debugging have gone i n t o t h e program. W h i l e t h i s i s a l a r g e number, l e t us c o n s i d e r t h e even l a r g e r number o f man-years u s i n g and t e s t i n g MACSYMA. A t MIT, betveen 1972 and 1982, we had about 1000 MACSYMA u s e r s . I f v e had 50 s e r i o u s u s e r s u s i n g MACSYMA f o r 50% o f t h e i r t i m e , 250 c a s u a l u s e r s a t 10% and 700 i n f r e q u e n t u s e r s a t 2% then the t o t a l i s over 600 man-years. MACSYMA has been a t 50 s i t e s f o r f o u r y e a r s and i s a t 0097-6156/ 86/ 0306-0100506.00/ 0 © 1986 American Chemical Society

Pierce and Hohne; Artificial Intelligence Applications in Chemistry ACS Symposium Series; American Chemical Society: Washington, DC, 1986.

8. PAVELLE

Computer Algebra: Capabilities and Applications

101

Downloaded by NORTH CAROLINA STATE UNIV on December 26, 2017 | http://pubs.acs.org Publication Date: April 30, 1986 | doi: 10.1021/bk-1986-0306.ch008

400 s i t e s t o d a y . W e l l , we c o u l d conclude t h a t a t l e a s t 1000 man-years have been spent i n u s i n g MACSYMA. MACSYMA i s now v e r y l a r g e and c o n s i s t s of about 3000 l i s p s u b r o u t i n e s o r about 300,000 l i n e s of c o m p i l e d l i s p code j o i n e d t o g e t h e r i n one g i a n t package f o r performing symbolic mathematics. W h i l e t h i s paper i s d i r e c t e d towards MACSYMA, the development of MACSYMA and o t h e r Computer A l g e b r a systems has r e a l l y been the r e s u l t o f an i n t e r n a t i o n a l e f f o r t (.2). There a r e many systems, w o r l d - w i d e , of v a r i o u s s i z e s and d e s i g n s w h i c h have been developed over the p a s t f i f t e e n t o twenty y e a r s ( 3 , 4 ) . Research r e l a t e d t o the development of these systems has l e a d t o many new r e s u l t s i n mathematics and the c o n s t r u c t i o n of new a l g o r i t h m s . These r e s u l t s i n t u r n h e l p e d the development of MACSYMA as w e l l as o t h e r systems. These systems a r e now b e i n g r e c o g n i z e d as i m p o r t a n t t o o l s a l l o w i n g r e s e a r c h e r s t o make s i g n i f i c a n t d i s c o v e r i e s i n many f i e l d s o f interest (5). Why MACSYMA i s U s e f u l or N e c e s s a r y . Here a r e some of the more i m p o r t a n t reasons f o r u s i n g MACSYMA: 1. The answers one o b t a i n s a r e e x a c t and can o f t e n be checked by independent p r o c e d u r e s . F o r example, one can compute an i n d e f i n i t e i n t e g r a l and check the answer by d i f f e r e n t i a t i n g ; the d i f f e r e n t i a t i o n a l g o r i t h m i s independent of the i n t e g r a t i o n a l g o r i t h m . S i n c e e x a c t answers a r e g i v e n , the s t a t i s t i c a l e r r o r a n a l y s i s a s s o c i a t e d w i t h n u m e r i c a l c o m p u t a t i o n i s u n n e c e s s a r y . One o b t a i n s answers t h a t a r e r e l i a b l e to a h i g h l e v e l of c o n f i d e n c e . 2 . The user can g e n e r a t e FORTRAN e x p r e s s i o n s t h a t a l l o w numeric computers to r u n f a s t e r and more e f f i c i e n t l y . T h i s saves CPU c y c l e s and makes computing more e c o n o m i c a l * The user can g e n e r a t e FORTRAN e x p r e s s i o n s from MACSYMA e x p r e s s i o n s * The FORTRAN c a p a b i l i t y i s an e x t r e m e l y i m p o r t a n t f e a t u r e combining s y m b o l i c and numeric capabilities. The t r e n d i s c l e a r , and i n a few y e a r s we w i l l have p o w e r f u l , i n e x p e n s i v e desktop o r notebook computers t h a t merge the s y m b o l i c , numeric and g r a p h i c c a p a b i l i t i e s i n a s c i e n t i f i c workstation. 3 . The user can e x p l o r e e x t r e m e l y complex problems t h a t cannot be s o l v e d i n any o t h e r manner. T h i s c a p a b i l i t y i s o f t e n thought of as the major use of Computer A l g e b r a systems. However, one s h o u l d not l o s e s i g h t of the f a c t t h a t MACSYMA i s o f t e n used as an advanced c a l c u l a t o r to perform everyday s y m b o l i c and numeric p r o b l e m s . I t a l s o complements c o n v e n t i o n a l t o o l s such as r e f e r e n c e t a b l e s or numeric p r o c e s s o r s . 4 . A g r e a t d e a l of knowledge has gone i n t o the MACSYMA knowledge base. T h e r e f o r e the user has a c c e s s t o m a t h e m a t i c a l t e c h n i q u e s t h a t a r e not a v a i l a b l e from any o t h e r r e s o u r c e s , and the user can s o l v e problems even though he may not know o r understand the t e c h n i q u e s t h a t the system uses to a r r i v e a t an answer. 5 . A user can t e s t m a t h e m a t i c a l c o n j e c t u r e s

e a s i l y and p a i n l e s s l y .

Pierce and Hohne; Artificial Intelligence Applications in Chemistry ACS Symposium Series; American Chemical Society: Washington, DC, 1986.

102

ARTIFICIAL INTELLIGENCE APPLICATIONS IN CHEMISTRY

Downloaded by NORTH CAROLINA STATE UNIV on December 26, 2017 | http://pubs.acs.org Publication Date: April 30, 1986 | doi: 10.1021/bk-1986-0306.ch008

One f r e q u e n t l y encounters m a t h e m a t i c a l r e s u l t s i n the l i t e r a t u r e and q u e s t i o n s t h e i r v a l i d i t y . O f t e n MACSYMA can be used t o check t h e s e r e s u l t s u s i n g a l g e b r a i c or numeric t e c h n i q u e s or a c o m b i n a t i o n of these. S i m i l a r l y one can use the system to show t h a t some problems do not have a s o l u t i o n . 6 . MACSYMA i s easy t o u s e . I n d i v i d u a l s w i t h o u t p r i o r computing e x p e r i e n c e can l e a r n t o s o l v e f a i r l y d i f f i c u l t problems w i t h MACSYMA i n a few hours or l e s s . W h i l e MACSYMA i s w r i t t e n i n a d i a l e c t of L I S P , the user need never see t h i s base l a n g u a g e . MACSYMA i t s e l f i s a f u l l programming language, almost m a t h e m a t i c a l i n n a t u r e , whose syntax resembles ALGOL. There a r e two a d d i t i o n a l reasons f o r u s i n g MACSYMA t h a t more i m p o r t a n t than the o t h e r s .

are

7 . One can c o n c e n t r a t e on the i n t e l l e c t u a l c o n t e n t of a problem l e a v i n g c o m p u t a t i o n a l d e t a i l s t o the computer. This often r e s u l t s i n a c c i d e n t a l d i s c o v e r i e s and, owing t o the power of the program, these o c c u r a t a f a r g r e a t e r r a t e than when c a l c u l a t i o n s a r e done by hand. 8. But the most i m p o r t a n t r e a s o n i s t h a t , t o quote R.W. Hamming, "The purpose of computing i s i n s i g h t , not numbers." T h i s e x e m p l i f i e s the major b e n e f i t of u s i n g MACSYMA, and I w i l l demonstrate the v a l i d i t y of t h i s statement by showing n o t o n l y how one g a i n s i n s i g h t but a l s o how one uses MACSYMA f o r t h e o r y b u i l d i n g . However, a second q u o t a t i o n r e p u t e d t o be by Hamming i s c o r r e c t as w e l l , namely t h a t "The purpose of computing i s not y e t i n s i g h t . " C a p a b i l i t i e s and uses o £ MACSYMA

Capabilities. I t i s not p o s s i b l e to f u l l y i n d i c a t e the c a p a b i l i t i e s of MACSYMA i n a few l i n e s s i n c e the r e f e r e n c e manual i t s e l f o c c u p i e s more than 500 pages (6.). However, some o f the more i m p o r t a n t c a p a b i l i t i e s i n c l u d e ( i n a d d i t i o n to the b a s i c a r i t h m e t i c a l operations) f a c i l i t i e s to provide a n a l y t i c a l t o o l s f o r Limits Derivatives Indefinite Integration Definite Integration Ordinary D i f f e r e n t i a l Equations Systems o f E q u a t i o n s ( N o n - L i n e a r ) Simplification Factorization

Taylor Series (Several Variables) Poisson Series Laplace Transformations I n d e f i n i t e Summation Matrix Manipulation Vector Manipulation Tensor M a n i p u l a t i o n Fortran Generation

There a r e o t h e r r o u t i n e s f o r c a l c u l a t i o n s i n number t h e o r y , c o m b i n a t o r i c s , c o n t i n u e d f r a c t i o n s , s e t t h e o r y and complex

Pierce and Hohne; Artificial Intelligence Applications in Chemistry ACS Symposium Series; American Chemical Society: Washington, DC, 1986.

8. PAVELLE

Computer Algebra: Capabilities and Applications

103

Downloaded by NORTH CAROLINA STATE UNIV on December 26, 2017 | http://pubs.acs.org Publication Date: April 30, 1986 | doi: 10.1021/bk-1986-0306.ch008

arithmetic. There i s also a share l i b r a r y currently containing about 80 subroutines. Some of these perform computations such as asymptotic analysis and optimization while others manipulate many of the higher transcendental functions. In addition one can evaluate expressions numerically at most stages of a computation. MACSYMA also provides extensive graphic c a p a b i l i t i e s to the user. To put the c a p a b i l i t i e s of MACSYMA i n perspective we could say that MACSYMA knows a large percentage of the mathematical techniques used i n engineering and the sciences. I do not mean to imply that MACSYMA can do everything. I t i s easy to come up with examples that MACSYMA cannot handle, and I w i l l present some of these. Perhaps the following quotation w i l l add the necessary balance. I t i s an e x i t message from some MIT computers that often flashes on our screens when logging out. I t states: " I am a computer. I am dumber than any human and smarter than any administrator." MACSYMA i s remarkable i n both the questions i t can and cannot answer. I t w i l l be many years before i t evolves into a system that r i v a l s the human i n more than a few areas. But u n t i l then, i t i s the most useful t o o l that any engineer or s c i e n t i s t can have at h i s disposal. Uses. I t i s d i f f i c u l t to l i s t the a p p l i c a t i o n f i e l d s of MACSYMA because users often do not state the tools that helped them perform t h e i r research. However, from Computer Algebra conferences (7, &, 9) we do know that MACSYMA has been used i n the following f i e l d s : Acoustics Algebraic Geometry Antenna Theory C e l e s t i a l Mechanics Computer-Aided Design Control Theory Deformation Analysis Econometrics Experimental Mathematics

F l u i d Dynamics General R e l a t i v i t y Number Theory Numerical Analysis P a r t i c l e Physics Plasma Physics Solid-State Physics Structural Mechanics Thermodynamics

Researchers have reported using MACSYMA to explore problems i n : A i r f o i l Design Nuclear Magnetic Resonance Atomic Scattering Cross Sections Optimal Control Theory B a l l i s t i c M i s s i l e Defense Systems Polymer Modeling Decision Analysis i n Medicine Propeller Design Electron Microscope Design Robotics Emulsion Chemistry Ship H u l l Design F i n i t e Element Analysis Spectral Analysis Helicopter Blade Motion underwater Shock Waves Maximum Likelihood Estimation Genetic Studies of Family Resemblance Large Scale Integrated C i r c u i t Design Resolving Closely Spaced Optical Targets Examples of MACSYMA Polynomial Equations. Here i s an elementary example that

Pierce and Hohne; Artificial Intelligence Applications in Chemistry ACS Symposium Series; American Chemical Society: Washington, DC, 1986.

104

ARTIFICIAL INTELLIGENCE APPLICATIONS IN CHEMISTRY

demonstrates the a b i l i t y of MACSYMA t o s o l v e e q u a t i o n s . I n MACSYMA, as w i t h most systems, one has user i n p u t l i n e s and computer output lines. Below, i n the i n p u t l i n e ( C I ) , we have w r i t t e n an e x p r e s s i o n i n an ALGOL l i k e s y n t a x , t e r m i n a t e d i t w i t h a s e m i - c o l o n , and i n ( D l ) the computer echos the e x p r e s s i o n by d i s p l a y i n g i t i n a two d i m e n s i o n a l format i n a form s i m i l a r t o hand n o t a t i o n . Terminating an i n p u t s t r i n g w i t h $ i n h i b i t s the d i s p l a y of the D l i n e s .

Downloaded by NORTH CAROLINA STATE UNIV on December 26, 2017 | http://pubs.acs.org Publication Date: April 30, 1986 | doi: 10.1021/bk-1986-0306.ch008

(CI)

Λ

Λ

Λ

Χ 3+B*X~2+Α 2*X~2-9*Α*Χ 2+A~2*B*X-2*A*B*XS

9*A~3*X+14*A~2*X-2*A' 3*B+14*A~4=0;

(Dl)

3 2 2 2 2 2 Χ + B X +A X - 9 A X +A B X - 2 A B X - 9 A

3 X

2 3 4 + 14 A X - 2 A B + 1 4 A « 0

In (C2) we now ask MACSYMA t o s o l v e the e x p r e s s i o n ( D l ) f o r X and the t h r e e r o o t s appear i n a l i s t i n ( D 2 ) .

(C2)

(D2)

S0LVE(D1,X);

[X - 7 A - Β,

2 X « - A ,

X » 2 A]

N o t i c e t h a t MACSYMA has o b t a i n e d the r o o t s a n a l y t i c a l l y and t h a t numeric a p p r o x i m a t i o n s have not been made. T h i s demonstrates a fundamental d i f f e r e n c e between a Computer A l g e b r a system and an o r d i n a r y numeric e q u a t i o n s o l v e r , namely the a b i l i t y t o o b t a i n a s o l u t i o n without approximations. I c o u l d have g i v e n MACSYMA a " n u m e r i c " c u b i c e q u a t i o n i n X by s p e c i f y i n g numeric v a l u e s f o r A and B . MACSYMA then would have s o l v e d the e q u a t i o n and g i v e n the numeric r o o t s a p p r o x i m a t e l y or e x a c t l y depending upon the s p e c i f i e d command. MACSYMA can a l s o s o l v e q u a d r a t i c , c u b i c and q u a r t i c e q u a t i o n s as w e l l as some c l a s s e s o f h i g h e r degree e q u a t i o n s . However, i t o b v i o u s l y cannot s o l v e e q u a t i o n s a n a l y t i c a l l y i n c l o s e d form when methods are not known, e . g . a g e n e r a l f i f t h degree ( o r h i g h e r ) equation. D i f f e r e n t i a l C a l c u l u s . MACSYMA knows about c a l c u l u s . I n ( D l ) we have an e x p o n e n t i a t e d f u n c t i o n t h a t i s o f t e n used as an example i n a f i r s t course i n d i f f e r e n t i a l c a l c u l u s .

(Dl)

X X X

Pierce and Hohne; Artificial Intelligence Applications in Chemistry ACS Symposium Series; American Chemical Society: Washington, DC, 1986.

PAVELLE

8.

Computer Algebra: Capabilities and Applications

105

We now ask MACSYMA t o d i f f e r e n t i a t e ( D l ) w i t h r e s p e c t t o X t o o b t a i n t h i s c l a s s i c textbook r e s u l t of d i f f e r e n t i a t i o n . N o t i c e how f a s t , 3/100 CPU seconds, MACSYMA computes t h i s d e r i v a t i v e . (C2) D I F F ( D 1 , X ) ; Time= 30 msec. X X Χ

Downloaded by NORTH CAROLINA STATE UNIV on December 26, 2017 | http://pubs.acs.org Publication Date: April 30, 1986 | doi: 10.1021/bk-1986-0306.ch008

(D2)

X (X

X- 1 LOG(X) (LOG(X) + 1) + X )

Below i s a more c o m p l i c a t e d f u n c t i o n , the e r r o r f u n c t i o n of the tangent of the a r c - c o s i n e of the n a t u r a l l o g a r i t h m of X . N o t i c e t h a t MACSYMA does not d i s p l a y the i d e n t i c a l i n p u t . T h i s i s because the i n p u t i n ( C I ) passes through MACSYMA's s i m p l i f i e r . MACSYMA r e c o g n i z e s t h a t the tangent o f the a r c - c o s i n e of a f u n c t i o n s a t i s f i e s a t r i g o n o m e t r i c i d e n t i t y , namely TAN(AC0S(X)) • SQRT(1-X"2)/X. I t t a k e s t h i s i n t o account b e f o r e d i s p l a y i n g ( D l ) . (CI)

ERF(TAN(ACOS(LOG(X)))); 2 SQRT(1 - LOG ( X ) ) ERF( ) LOG(X)

(Dl)

Now when MACSYMA i s asked t o d i f f e r e n t i a t e ( D l ) w i t h r e s p e c t t o X , i t does so i n a s t r a i g h t f o r w a r d manner and s i m p l i f i e s the r e s u l t u s i n g the r a t i o n a l c a n o n i c a l s i m p l i f i e r RATSIMP. T h i s command p u t s the e x p r e s s i o n i n a n u m e r a t o r - o v e r - d e n o m i n a t o r form c a n c e l i n g any common d i v i s o r s . I n (D2) the symbols %E and %PI a r e MACSYMA's r e p r e s e n t a t i o n s f o r the base of the n a t u r a l l o g a r i t h m s and p i , respectively. (C2) DIFF(D1,X),RATSIMP; Time= 1585 msec. 1 1 2 LOG (X) 2 %E

( ) D2

2 2 SQRT(%PI) X LOG (X) SQRT(1 - LOG ( X ) )

Factorization MACSYMA can f a c t o r e x p r e s s i o n s . i n four v a r i a b l e s . 2 7 4 8 ( D l ) - 36 W Χ Υ Ζ

Below i s a m u l t i v a r i a t e p o l y n o m i a l

2 6 3 8 + 3 W X Y Z

3 7 4 6 - 24 W Χ Υ Ζ

Pierce and Hohne; Artificial Intelligence Applications in Chemistry ACS Symposium Series; American Chemical Society: Washington, DC, 1986.

ARTIFICIAL INTELLIGENCE APPLICATIONS IN CHEMISTRY

106

Downloaded by NORTH CAROLINA STATE UNIV on December 26, 2017 | http://pubs.acs.org Publication Date: April 30, 1986 | doi: 10.1021/bk-1986-0306.ch008

+ 2W

3 6 3 6 Χ Υ Ζ

+96W

2 8 6 5 Χ Y Ζ

-168W

2 7 6 5 + 12 W Χ Υ Ζ

2 10 5 5 - 216 W Χ Υ Ζ

4 6 5 5 + 14 W Χ Υ Ζ

-W

2 6 3 5 - 3 W Χ Υ Ζ

2 6 5 5 Χ Υ Ζ

7 5 3 + 6WX Υ Ζ

4 7 6 5 Χ Υ Ζ

2 7 5 5 - 8 W Χ Υ Ζ

+18W

2 9 4 5 Χ Υ Ζ

+58WX

+87

7 3 3 Υ Ζ

- 2W

8 7 2 2 7 7 2 7 7 2 - 2 4 X Y Z + 4 2 W X Y Z - 3 X Y Z + 5 4 X

8 5 2 - 232 Χ Υ Ζ

2 6 5 2 + W X Y Z +

2 7 5 2 + 4 1 4 W X Y Z

10 522 X

7 5 2 - 29 Χ Υ Ζ

7 5 5 9 Χ Υ Ζ

+

10

Χ

7 3 5 Υ Ζ

3 6 3 3 Χ Υ Ζ

6 2 Υ Ζ

4 6 5 2 - 14 W Χ Υ Ζ

4 2 2 9 4 2 Y Z - 1 8 W X Y Z

We now c a l l the f u n c t i o n FACTOR on ( D l ) and (C2) FACTOR(Dl); Time= 111998 msec.

(D2)

6 3 2 3 - Χ Υ Ζ (3 Ζ

2 + 2 W Z - 8 X Y

2 +14W

2 2 Y - Y

3 +18X

Y)

2 3 2 3 2 2 (12 W X Y Z - W Ζ - 3 X Y - 29 X + W ) MACSYMA f a c t o r s t h i s m a s s i v e e x p r e s s i o n i n about two CPU m i n u t e s . One can a l s o extend the f i e l d of f a c t o r i z a t i o n t o the G a u s s i a n i n t e g e r s or o t h e r a l g e b r a i c f i e l d s ( 1 0 ) .

Simplification. A v e r y i m p o r t a n t f e a t u r e of MACSYMA i s i t s a b i l i t y t o s i m p l i f y e x p r e s s i o n s . When I s t u d i e d plane-wave m e t r i c s f o r a new g r a v i t a t i o n t h e o r y ( 1 1 , 12)» one p a r t i c u l a r c a l c u l a t i o n produced an e x p r e s s i o n w i t h s e v e r a l hundred thousand t e r m s . From g e o m e t r i c a l arguments I knew the e x p r e s s i o n must s i m p l i f y and i n d e e d , u s i n g MACSYMA, the e x p r e s s i o n c o l l a p s e d t o a s m a l l number of pages of o u t p u t . The f o l l o w i n g e x p r e s s i o n o c c u r r e d r e p e a t e d l y i n the course of the c a l c u l a t i o n and caused the c o l l a p s e of the l a r g e r e x p r e s s i o n during s i m p l i f i c a t i o n .

Pierce and Hohne; Artificial Intelligence Applications in Chemistry ACS Symposium Series; American Chemical Society: Washington, DC, 1986.

8.

PAVELLE

Computer Algebra: Capabilities and Applications

2 2 2 2 (SQRT(R + A ) + A) (SQRT(R + Β ) + B) ( ) D l

2 R 2

2 2 2 + Β ) + SQRT(R + A ) + Β + A

2

2 2 2 + Β ) + SQRT(R + A ) - Β - A

SQRT(R

Downloaded by NORTH CAROLINA STATE UNIV on December 26, 2017 | http://pubs.acs.org Publication Date: April 30, 1986 | doi: 10.1021/bk-1986-0306.ch008

SQRT(R (C2) RATSIMP(Dl); Tim€= 138 msec. (D2)

0

When the canonical s i m p l i f i e r RATSIMP i s c a l l e d on (Dl) above i t returns zero. At f i r s t I did not believe that (Dl) i s zero, and I spent 14 minutes v e r i f y i n g i t by hand (almost exceeding my 15 minute l i m i t ) . I t i s not easy to prove. Combining the expressions over a common denominator r e s u l t s i n a numerator that contains 20 terms when f u l l y expanded, and one must be very c a r e f u l to assure c a n c e l l a t i o n . Try i t by hand! I n d e f i n i t e Integration. MACSYMA can handle i n t e g r a l s involving r a t i o n a l functions and combinations of r a t i o n a l , algebraic functions, and the elementary transcendental functions. I t also has knowledge about error functions and some of the higher transcendental functions. Below i s an i n t e g r a l that i s quite d i f f i c u l t to do by hand. I t i s not found i n standard tables i n i t s given form although i t may transform to a recognized case. I t i s e s p e c i a l l y d i f f i c u l t to do by hand unless one notices a t r i c k that involves performing a p a r t i a l f r a c t i o n decomposition of the integrand with respect to LOG(X). However, MACSYMA handles i t r e a d i l y .

/ [ LOG(X) - 1 I dX ] 2 2 / LOG (X) - X

(Dl)

(C2) INTEGRATE(Dl,X); Time= 744 msec. L0G(L0G(X) + X)

L0G(L0G(X) - X)

2

2

(D2) D e f i n i t e Integration. D e f i n i t e i n t e g r a t i o n i s f a r more d i f f i c u l t to code than i n d e f i n i t e i n t e g r a t i o n because the number of known techniques i s much larger. One has the added complication of taking l i m i t s at the endpoints of the i n t e g r a l . MACSYMA has impressive c a p a b i l i t i e s for d e f i n i t e i n t e g r a t i o n . Here i s an example of a

Pierce and Hohne; Artificial Intelligence Applications in Chemistry ACS Symposium Series; American Chemical Society: Washington, DC, 1986.

107

ARTIFICIAL INTELLIGENCE APPLICATIONS IN CHEMISTRY

108

f u n c t i o n whose d e f i n i t e i n t e g r a l does not appear to be t a b u l a t e d : 2 2 - U X X %E LOG(X)

(Dl)

(C2) INTEGRATE(Dl,X,0,INF),FACTOR; Time 138442 msec. 55

SQRT(%PI) (LOG(U) + 2 LOG(2) + %GAMMA - 2) ( ) Downloaded by NORTH CAROLINA STATE UNIV on December 26, 2017 | http://pubs.acs.org Publication Date: April 30, 1986 | doi: 10.1021/bk-1986-0306.ch008

D2

3/2 8 U I n (C2) above we have asked MACSYMA t o i n t e g r a t e ( D l ) w i t h r e s p e c t t o X from 0 t o i n f i n i t y . I n the answer, %GAMMA i s the MACSYMA s y n t a x f o r the E u l e r - M a s c h e r o n i c o n s t a n t 0.577215664.· s

·

I n a d d i t i o n t o d e f i n i t e i n t e g r a t i o n , MACSYMA can perform numeric i n t e g r a t i o n u s i n g the Romberg numeric i n t e g r a t i o n p r o c e d u r e . There a r e a number of o t h e r numeric t e c h n i q u e s a v a i l a b l e . A n d , one has the a b i l i t y t o e v a l u a t e e x p r e s s i o n s n u m e r i c a l l y t o a r b i t r a r y precision. Taylor/Laurent Series. v e r y i m p r e s s i v e . Below of ( D l ) about the p o i n t e x p r e s s i o n i n l e s s than

The T a y l o r ( L a u r e n t ) s e r i e s c a p a b i l i t y i s we ask f o r the f i r s t 15 terms of the s e r i e s X « 0 . N o t i c e t h a t MACSYMA computes t h i s 1/2 CPU second. 2 3

(Dl)

Β L0G(X

- X + 1)

A SIN(X ) + 5

X (C2) T A Y L O R ( D 1 , X , 0 , 1 5 ) ; Time 365 msec. 53

Β (D2)/T/

2B

+ 4 Χ

4 5 (2 Β) Χ 9 10 (2 Β) Χ 15

Β

Β

+ 3 2 Χ

Β

2 Β Χ

Β Χ

+ 2

3 (Β + 8 A) Χ +

4

X

5

3

7

8

3 Χ

6

7

ΒΧ

ΒΧ

10

11 11

8 ΒΧ

9 (3 Β - 7 A) Χ

ΒΧ

6

13

12

42

13

14

ΒΧ

ΒΧ

ΒΧ

ΒΧ

16

17

9

19

15 (6 Β + A) Χ 120

Pierce and Hohne; Artificial Intelligence Applications in Chemistry ACS Symposium Series; American Chemical Society: Washington, DC, 1986.

8. PAVELLE

Computer Algebra: Capabilities and Applications

109

The program can a l s o compute T a y l o r ( L a u r e n t ) s e r i e s i n s e v e r a l variables.

Downloaded by NORTH CAROLINA STATE UNIV on December 26, 2017 | http://pubs.acs.org Publication Date: April 30, 1986 | doi: 10.1021/bk-1986-0306.ch008

O r d i n a r y D i f f e r e n t i a l E q u a t i o n s . Another p o w e r f u l f e a t u r e i s the MACSYMA program ODE. ODE i s a c o l l e c t i o n of a l g o r i t h m s f o r s o l v i n g o r d i n a r y d i f f e r e n t i a l e q u a t i o n s . I t was b u i l t over s e v e r a l y e a r s by E . L . L a f f e r t y , J . P . G o l d e n , R . A . Bogen and B . K u i p e r s , and i t s c a p a b i l i t i e s a r e d e s c r i b e d i n the MACSYMA Reference Manual (6) i n V2-4-14. In ( C I ) , we f i r s t d e c l a r e t h a t Y i s a f u n c t i o n of X . T h i s a s s u r e s t h a t the d e r i v a t i v e (2nd) of Y w i t h r e s p e c t t o X w i l l not v a n i s h when (C2) i s e v a l u a t e d . (CI)

DEPENDS(Y,X)$

(C2)

(1+X"2)*DIFF(Y,X,2)-2*Y=0;

(D2)

2 ( X + 1 ) Y

- 2 Y = 0 X X

We now ask the system to s o l v e (D2) f o r Y as a f u n c t i o n of X u s i n g the ODE command. The g e n e r a l s o l u t i o n w i t h the two i n t e g r a t i o n c o n s t a n t s , %K1 and %K2 i s g i v e n i n (D3) i n about two CPU seconds. The program can a l s o f i n d p o w e r s e r i e s s o l u t i o n s f o r some d i f f e r e n t i a l e q u a t i o n s when i t can s o l v e the r e c u r r e n c e r e l a t i o n . I t does t h i s i n ( D 4 ) . MACSYMA can be used t o check the answer ( D 3 ) . I n (C5) we t e l l the system t o s u b s t i t u t e (D3) i n t o ( D 2 ) , d i f f e r e n t i a t e the r e s u l t and s i m p l i f y . (C3) 0 D E ( D 2 , Y , X ) ; Time- 2068 msec. 2 ATAN(X) Y = %K2 (X + 1) ( 2

(D3)

X

2 ) + %K1 (X + 1)

+ 2 2 X

+2

(C4) 0 D E ( D 2 , Y , X , S E R I E S ) ; T i m e 8766 msec. 2

(D4)

INF ==== 1 2 1 2 \ ( - 1) X Y = %K1 (X + 1) - %K2 X > / 1 1 = (I - -) (I + -) 0 2 2

(C5) D2,D3,DIFF,RATSIMP; Time= 2051 msec. (D5)

0=0

Pierce and Hohne; Artificial Intelligence Applications in Chemistry ACS Symposium Series; American Chemical Society: Washington, DC, 1986.

ARTIFICIAL INTELLIGENCE APPLICATIONS IN CHEMISTRY

110

MACSYMA i s a computer system which performs many highly sophisticated computations that w i l l amaze people who use mathematical t o o l s . For many types of c a l c u l a t i o n s MACSYMA offers enormous advantages over numeric systems. In t h i s paper I have shown but a few of the c a p a b i l i t i e s of MACSYMA. I t i s d i f f i c u l t to present many c a p a b i l i t i e s i n a few pages. References (j>, 13) provide many more examples as w e l l as motivating the use of MACSYMA i n several f i e l d s of research and development.

Downloaded by NORTH CAROLINA STATE UNIV on December 26, 2017 | http://pubs.acs.org Publication Date: April 30, 1986 | doi: 10.1021/bk-1986-0306.ch008

Literature Cited 1. 2. 3.

4. J.; 5. 6. 7. 8. 9. 10. 11. 12. 13.

Moses, J . MACSYMA - the fifth year. Proceedings Eurosam 74 Conference. Aug. 1974, Stockholm. Pavelle, R.; Rothstein, M.; Fitch, J . P . Computer Algebra. Scientific American 1981, 245. van Hulzen, J . Α . ; Calmet, J . Computer Algebra Systems. In "Computer Algebra, Symbolic and Algebraic Manipulation"; Buchberger, B.; Collins, G . E . ; Loos, R., Eds.; Springer-Verlag: Wien - New York, 1983, p. 220. Yun, D.Y.Y.; Stoutemyer, D. Symbolic Mathematical Computation. In "Encyclopedia of Computer Science and Technology" 15; Belzer, Holzman, A . G . , Eds.; Marcel Dekker: New York - Basel, 1980, p. 235. Pavelle, R., E d . , "Applications of Computer Algebra"; Kluwer: Boston, 1985. "The MACSYMA Reference Manual (Version 10)"; Massachusetts Institute of Technology and Symbolics, Inc.: Cambridge, MA, Dec. 1984. Proceedings of the 1977 MACSYMA users' Conference. R . J . Fateman, Ed., Berkeley, CA, July 1977. NASA: CP-2012, Washington, D.C. Proceedings of the 1979 MACSYMA users' Conference. V.E. Lewis, Ed., June 1979, Washington, D.C. Proceedings of the 1984 MACSYMA users' Conference. V.E. Golden, Ed., July 1984, General Electric Corporate Research and Development, Schenectady, NY. Wang, P.S. Math. Comp., 1978, 32, 1215. Mansouri, F . ; Chang, L.N. Phvs. Rev. D 1976, 13, 3192. Pavelle, R. Phvs. Rev. Lett. 1978, 40, 267. Pavelle, R.; Wang, P.S. J. Symbolic Computation. 1985, 1, 69-100.

RECEIVED January 24, 1986

Pierce and Hohne; Artificial Intelligence Applications in Chemistry ACS Symposium Series; American Chemical Society: Washington, DC, 1986.