> During integration FriCAS tries as much as it can preserve structure of 
user input.

I think that this is not true with respect to polynomials: these are always 
expanded, right?

sage: fricas("(x+y)^5")
 5        4       2 3       3 2      4     5
y  + 5 x y  + 10 x y  + 10 x y  + 5 x y + x
sage: fricas("(x+sin(y))^5")
      5             4       2      3       3      2      4          5
sin(y)  + 5 x sin(y)  + 10 x sin(y)  + 10 x sin(y)  + 5 x sin(y) + x
sage: fricas("(1+x+sin(y))^3")
      3                  2       2                     3      2
sin(y)  + (3 x + 3)sin(y)  + (3 x  + 6 x + 3)sin(y) + x  + 3 x  + 3 x + 1

Best wishes and thank you for all your work on FriCAS!

Martin

On Thursday, 9 March 2023 at 12:54:00 UTC+1 Waldek Hebisch wrote:

> On Wed, Mar 08, 2023 at 06:42:40PM -0800, 'Nasser M. Abbasi' via FriCAS - 
> computer algebra system wrote:
> > How does one tell Fricas to simplify sin(x)/cos(x) to tan(x)?
> > 
> > simplify(sin(x)/cos(x)) does not do the trick.
> > 
> > I noticed this when integrating 1/cos(x)^2 
> > which should return tan(x) but Fricas returned sin(x)/cos(x) 
> > (Ofcourse Fricas answer is correct), but tan(x) is simpler.
> > 
> > Should not this be an automatic simplification?
>
> No. Transformations of this sort are very undesirable when doing
> computations which depend on structure of expressions. Basicaly,
> when such transformations fire in automatic way it is not
> possible to usefuly predict form of final result.
>
>
> During integration FriCAS tries as much as it can preserve structure
> of user input. This means using 'tan' in answer when user input
> contains 'tan', using 'sin' and 'cos' when user input is in terms
> of 'sin' and 'cos'. Compare:
>
> (3) -> integrate(1 + tan(x)^2, x)
>
> (3) tan(x)
> Type: Union(Expression(Integer),...)
>
> Note: FriCAS performs rather drastic transformations during
> integration. Without effort to preserve user input result
> would look quite different. And sometimes this preservation
> effort fails.
>
> > Mathematica does it without even calling Simplify.
>
> In FriCAS we have:
>
> (11) -> simplify(tan(x))
>
> sin(x)
> (11) ------
> cos(x)
> Type: Expression(Integer)
>
> Many folks consider expression in terms of 'sin' and 'cos' simpler
> than expression in terms of 'tan'. If you are concerned only
> with lone 'sin(x)/cos(x)', then rewrite rule can transform it
> to 'tan'. In general, it is easy to replace 'tan(x)' by
> 'sin(x)/cos(x)', but transformation in opposite direction
> is more complicated. Consider
>
> (cos(x)^2*sin(x)+(6*cos(x)^3+cos(x)))/(sin(x)+2*cos(x)^3)
>
> (which was obtained from '(7 + tan(x) + tan(x)^2)/(2 + tan(x) + 
> tan(x)^3)').
> In version 12 of Matematica Simplify and FullSimplify leave
> this unchanged. I am not sure if Matematica can not transform
> this back to 'tan' form or maybe it considers version in terms
> of 'sin' and 'cos' as simpler.
>
> -- 
> 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/2801ea6b-e0ae-40c0-85bc-ea5028aa2188n%40googlegroups.com.

Reply via email to