simplify



Hi!

I've tried doing some (simple) Fraunhofer integrals (physics -  
optics) with Maxima, namely something like this ->

integrate( exp(-%i*kx*ksi) *
integrate(exp(-%i*ky*eta),eta,ksi*K,ksi*K+2*b),
ksi, -a, a  );

While the integral was computed correctly (it's trivial really), but  
the output was rather disastrous in a sense, the resulting expression  
was many times longer than done by hand.
I've tried the same integral with Mathematica and the output was very  
near to, what a person would do by hand.

Yes, integrate() does not try to find the best form of result - so I  
tried various commands Maxima has for simplification/manipulation.  
None of them gave any usable results really - at least not anywhere  
near Mathematica.

What I noticed while doing this is - that maxima is lacking a very  
used CAS feature - 'simplify'. What Simplify[] in Mathematica does is  
- perform various expression transformations and return the  
'simplest' result. Yes - 'simplest' is always debatable, however  
consider this:
* computer time is more valuable than users - a computer program can  
afford to employ large number of transformations and compare their  
results, do a search for the best, while the user - even if  
knowledgeable, has to type many commands to get the result he wants.  
It's nicer to call a function and wait a second or two, than to  
manually type in transformations..
* to newbies (which includes me apparently) the multitude of  
simplifying commands in Maxima is rather frightening. To make the  
situation worse - they all have rather cryptic names (except perhaps  
factor, expand..) and it's hard to remember which to use. A command  
that does the work for you and gets the result you want in 80% of  
cases (or at least near the result you want) is invaluable. If the  
result is not satisfactory - the option of doing specific operations  
on the expression remains.
* true - the meaning of 'simplify' is rather vague compared to expand  
or factor - but - in practice, when manipulating expressions by hand,  
there are a lot of common things we all do the same way (or at least  
mostly).. usualy we prefer 1 + a*(b + c + d) to 1 + a*b + a*c + a*d  
and sin(x)^2 + cos(x)^2 is usually simplified to 1 whenever we  
encounter it, the same goes for tan(x) * cos(x) -> sin(x).. Yes,  
Maxima has commands to do some of that. But I (for instance) don't  
want to be bothered using a multitude of different commands for some  
transforms that are perhaps obvious.
* note, that simplify does not need to be 'a perfect solution' that  
works on everything, but perhaps a timesaver for experienced users  
and a much needed tool for newbie Maixima users


So I propose we implement a 'simplify' command into Maxima. I'm not  
very experienced with maxima expression transforming capabilities,  
but as far as I know there is no simple way to transform
1 + a*b + a*c + a*d -> 1 + a*(b + c + d)
Yes there are ways to do it, but it has to be specifically stated -  
however on paper we mostly do it automatically.
That's what I would like 'simplify' to do - to automatically apply  
transformations that are usually done, when doing math by hand... but  
instead of the user typing in various transformations, the work can  
be done by the computer in a second. Again - the goal is to come  
remotely close to how math is done by hand, of course specific  
expressions require specific manipulations, depending on how we want  
it to look. The program can guess nevertheless.

I've attached a 'simplify.lisp' where I implement a really dumb  
'simplify' function. It consist of two parts - a $cost function which  
determines how 'beautiful' the expression is to the human eye, and  
$simplify function, which tries various transformations and returns  
the expression with the lowest 'cost'. I guess this is the main idea  
of 'simplify'. I'm hoping some of you, CAS experts, could provide  
some guidance how such a function should be done.

Particularly I would like the function to be able to do this  
transformation:
1 + a*b + a*c + a*d -> 1 + a*(b + c + d)
however calling $factor or some other function on the 'mplus'  
expression doesn't work of course. Somehow parts of mplus list should  
be searched for such factorable expressions...

Again I'm not very familiar with maxima internals neither with it's  
transforming capabilities nor do I know, how to do a 'proper'  
simplify function. This is just an idea.

It's a really dumb and brute force function right now, but already it  
handles various expressions quite well for a single function...
One part of the problem is tweaking the $cost function to be good at  
guessing what is a nice expression to us, but the bigger problem is  
the $simplify function, which should be smarter about applying rules  
(to parts of expression) and so on...

So any ideas how to get a nice 'simplify' into maxima? Any interest  
from the developers?

Regards,
Ziga

-------------- next part --------------
A non-text attachment was scrubbed...
Name: simplify.lisp
Type: application/octet-stream
Size: 1334 bytes
Desc: not available
Url : http://www.math.utexas.edu/pipermail/maxima/attachments/20090911/d93026ef/attachment.obj 
-------------- next part --------------