Dear Marik,
> Burcin wrote:
> I really dislike the idea of adding a new function for each
> functionality of this kind. This makes it very hard for users to
> figure out the function name they need for a specific task.
>
> We should be able to provide an interface to all these "rewriting"
> tasks through a few conceptually defined methods like rewrite(), expand
> () and combine()( or contract()?).
>
> Francois Maltey had a proposal for a possible interface to all this.
> Maybe he can comment here, or we can discuss his proposal on sage-
> devel.
> ------------------------------
>
>
> It would be great to find some simple and clean solution which gives
> access to many posibilities included in Maxima or/and other CAS. I
> think that if we take into account the many possibilities how to
> simplify expressions, it will be difficult to do this job.
>   
I dislike simplify word.

Look at theses 2 examples : what is the simplified formula .

2*cos(x)^2-1 : you wait the combined formula cos(2*x)
cos(2*x)+1 : you wait the expanded formula 2*cos(x)^2

a simplify function must have a purpose.
This purpose is only in the user mind, not in any computer algebra 
algorithms.

But expand has a clean description :
An expand formula has more transcendent function calls with smaller 
arguments.
sin (x+y) == sin(x)*cos(y)+cos(x)*sin(y)

The opposite way may be a combine or a contract function :
less transcendent call but larger arguments : 
combine(exp(a)^3/exp(b))=exp(3*a-b).
> I do not like the approach in Maple and Mathematica, where
> user has one big command for many simplifications and it is not easy
> to find out, what to do, if we do not want to use some of
> simplifications and rewriting rules included in this big command.
>   
Please, let me have the opposite taste.
I can only record a very small number of functions in my mind.
I also can explain a little number of theory to my students.
So I prefer choose a complete theory or a large transform and then 
refine it by options or examples.

In your case, it may be possible to add optional parameters to expand 
functions.
By example you may  choose a target :  only logarithms or trigonometric 
functions.

Burcin proposed a target parameter.

So imagine a Sage 4.xyz with

y = log(2)+log(3)+exp(2)*exp(3)
contract (y)                                             # log(6)+exp(5)
contract(y, target=log)                           # log(6)+exp(2)*exp(3)
contract(y, target=exp)                           # log(2)+log(3)+exp(5)

An other option may be a predicate select in order to restrain the 
tested subexpression.

contract (exp(x+1)*exp(x-1)*exp(y), target=exp, select=lambda subexpr : 
has(subexpr, x))
# the answer will be exp(2*x)*exp(y)

And the last option may add a mainBranchCut option.
In a normal (complex) calculus it's impossible to simplify log(x)+log(y) 
to log(x*y). Try with x=y=-1.
But a mainBranchCut option overwrite the general rule and suppose the 
right hypothesis to  get
log(x*y), and 1/2*log(x) give log(sqrt(x)).

> I think that it is better to have small functions which do their small
> job - they do what the user wants. I think that this is Maxima
> approach. 
>   
It's very difficult to have an complete view of maxima rules. There are 
too many functions.
With only one function, the help docstring can explains all the 
refinement options.
And options in a main functions can make the (only one) little 
transforms you want to apply.
You don't like maple way because I don't think that maple has this 
ability to restrain the convert transform.

> If such a complete solution for rewriting tasks appears, it would be
> great to give to the users enough power for fine tunning, like current
> expand_trig().
>   
An other question :

How theses rewriting rules may be coded :

1/ With maxima kernel call ?
2/ In Ginac library ?
3/ By a sage interpreter call ?

My vote goes to the number-3/. I don't like maxima method with its 
numerous flags.
Look at the previous mail in sage-support about integrate 
(sqrt(sin(x)^2+cos(x)^2), x, 0, 2*pi) = only pi
because there was a little change to an inner flag of maxima.

The 2/ way is the longer method. If I want to code it I must learn sage 
and also the ginac code. This method looks like to the axiom(s) 
language. A function can be right for the interpreter language, but it 
takes hours and hours to code it in the axiom kernel with other compiled 
rules.(1)

The 3/ is the easiest way to read and to understand the code. When you 
read sage files then you understand its functions. It's almost the maple 
way with "the verbose option and print the function" and it was the 
mupad way. Bug are easiest to find. Interpreted code isn't so slow, you 
may wait 1 second more, and there is less wasted time than in (1).
 





--~--~---------~--~----~------------~-------~--~----~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to