Constantine Frangos wrote:
> 
> %I was not aware of this behaviour. However, I believe that fricas should not
> %automatically expand expressions that the user inputs. If this can be
> %modified then it would be very helpful.
> %Note that another public domain CAS called Maxima does not expand the above
> %expression. In addition, the user can perform the above simplification 
> %by using a built-in Maxima function called trigreduce().
> %Maybe fricas should consider having such a built-in function. This will 
> %only add to the strong points that it has.

One question is why you want to stop automatic transformation
of expressions.  As Ralf wrote automatic transformations are
build quite deeply into FriCAS.  And they have substantial
benefits. For example, on Maxima list there was example of
relatively simple 8x8 symbolic system of linear equations
that Maxima was unable to solve.  FriCAS had no problem with
this system.  AFAICS the reason is that during solving there
are hundreds of arithmetic operations.  Without aggresive
automatic simplification there is enormous growth of
size of intermediate expression.  Automatic simplification
means that growth is under control and system is easy to
solve.

For the purpose of rewriting trigonometrics it is better
to use a bit different rules than given by Kurt.  For
example:

(3) -> rs:=rule cos(x)*sin(y) == (sin(y-x) + sin(y + x))/2

                           %D sin(y + x) + %D sin(y - x)
   (3)  %D cos(x)sin(y) == -----------------------------
                                         2
                       Type: RewriteRule(Integer,Integer,Expression(Integer))
(4) -> rs (-sin(x1)*cos(y) + sin(y)*cos(x1))

   (4)  sin(y - x1)
                                                    Type: Expression(Integer)
(5) -> rs(sin(x)*cos(2*x))

        sin(3x) - sin(x)
   (5)  ----------------
                2
                                                    Type: Expression(Integer)

The point of rule above is that we do not try to match minus
sign, which is quite unreliable due to possible rearrangement
but we simply transform each product.  The rule works also
for multiple products:

(8) -> rs(a*sin(x)*cos(y)*cos(z))

   (8)
   a sin(z + y + x) - a sin(z + y - x) + a sin(z - y + x) - a sin(z - y - x)
   -------------------------------------------------------------------------
                                       4
                                                    Type: Expression(Integer)


Note however, that separate trigonometics works against the way
FriCAS operates.  They may result in messier expressions in
further calculations or FriCAS may decide that it needs to
convert back:

(6) -> integrate(%, x)

                 3
        - 2cos(x)  + 3cos(x)
   (6)  --------------------
                  3
                                         Type: Union(Expression(Integer),...)


Some people want to stop transformation of expressions to get
desired output for printing expressions.  In FriCAS you can
use box and paren:

(9) -> x*(y + x)

               2
   (9)  x y + x
                                                    Type: Polynomial(Integer)
(10) -> x*box(x+z)

   (10)  xz + x
                                                    Type: Expression(Integer)
(11) -> x*paren(x+z)

   (11)  x(z + x)
                                                    Type: Expression(Integer)

FriCAS will keep content of box (or paren) together.  Box prints without
parenthesis which is appropriate for sums, but as (10) above shows
is confusing for products.  Note: if you want to do computations
with then note that in most cases you need to remove them by
hand if you want to combine content with what is outside.

-- 
                              Waldek Hebisch

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fricas-devel+unsubscr...@googlegroups.com.
To post to this group, send email to fricas-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to