Discussion:
[fricas-devel] Factor a polynomial in the argument of an exponential
Marduk
2018-11-08 11:04:34 UTC
Permalink
Dear all,

I would like to convert exp(-a^2*x^2 - a^2*y^2) into exp(-a^2*(x^2 + y^2)).
However,
it seems that exp converts its argument presumably to Expression Integer,
and
since FriCAS always expands products the factorization is lost.

For more general expressions, I would like to write a rule that matches
%c*exp(x/y)
and rewrites it as %c*exp(factorFraction x/y).

Thank you in advance.

Best regards,
Marduk
--
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+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Ralf Hemmecke
2018-11-08 12:01:52 UTC
Permalink
Hi Marduk,
Post by Marduk
I would like to convert exp(-a^2*x^2 - a^2*y^2) into exp(-a^2*(x^2 + y^2)).
I don't know either. Maybe it would be easier to help if you explain the
actual problem you want to solve. Perhaps this factorization is not
really necessary.

It might even be that your rule (whatever it is) does not even apply.

(1) -> E ==> Expression Integer
Type: Void
(2) -> p:E := a*(x+y)

(2) a y + a x
Type: Expression(Integer)
(8) -> f := factor p

(8) a y + a x
Type: Factored(Expression(Integer))
(9) -> factors factor p

(9) []
Type: List(Record(factor: Expression(Integer),exponent:
NonNegativeInteger))
(10) -> unit f

(10) a y + a x
Type: Expression(Integer)
As you can see, factoring in the domain Expression considers p as an
expression, not as a polynomial.
Post by Marduk
However, it seems that exp converts its argument presumably to
Expression Integer, and since FriCAS always expands products the
factorization is lost.
Yes. That is another the problem. You must understand that FriCAS is
fundamentally different than other CAS like Maple or Mathematica. They
basically have only an expression tree as their data structure. So for
any transformation there is a function.

FriCAS, however, maintains a whole pool of different data structures,
one for each specific task. Elements of such "domains" are kept
internally in a canonical form (as much as this is possible). That is
why in FriCAS, there is no "simplify".

Well, usually Expression(X) is for manipulating expressions, but (unless
somebody else here on the list comes up with a solution for you) I would
say, Expression(X) doesn't allow what you want to achieve.

Ralf
--
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+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Marduk
2018-11-08 13:03:40 UTC
Permalink
Hi Ralf,

Thank you for your prompt reply. I understand that FriCAS works different
from
other CA systems. To me it is like using Haskell for doing computer
algebra.
And I think that is a very interesting approach.

I am not a computer scientist, but I think it should be possible to do the
same things
using a type-based and a list-based CA system. In particular, there must be
a way of
defining a type for an exponential of a factored polynomial.

I am not interested in factorizing the exponential for doing a calculation,
it is just for
inserting the resulting expression in TeXmacs.
--
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+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Ralf Hemmecke
2018-11-08 13:30:33 UTC
Permalink
In particular, there must be a way of defining a type for an
exponential of a factored polynomial.
Of course, there is. However, I guess, you don't want to program this
just for the following.
I am not interested in factorizing the exponential for doing a
calculation, it is just for inserting the resulting expression in
TeXmacs.
And I cannot even suggest you what to do, because how complicated that
programming will be depends very much on what you want to do with such a
type. If you don't want to compute with such expressions then one can
simply take

Factored Polynomial Integer

as a representation domain and modify the output routine

coerce: % -> OutputForm

in such a way that is displays

exp( ... )

and the factored polynomial where I have put the dots. But I guess, you
don't really want just that.

Ralf

PS: BTW, what does have TeXmacs have to do with this FriCAS question?
--
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+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Marduk
2018-11-08 14:04:19 UTC
Permalink
Post by Ralf Hemmecke
PS: BTW, what does have TeXmacs have to do with this FriCAS question?
I use TeXmacs as a frontend for FriCAS. I would like to be able to use the
expressions
generated by the CAS directly in my notes, papers, etc. But apparently, it
takes some
work to get that done.

Thanks anyway for your time and your comments.

Marduk
--
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+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
oldk1331
2018-11-08 14:37:28 UTC
Permalink
I was also having some thoughs about factoring Expression.

I think it's doable, especially for displaying purpose.

We can use "paren"/"box" to keep the factors.

A quick sketch:

(25) -> exp map(x+->box(x::EXPR INT),factor numer first argument
mainKernel exp(-a^2*x^2 - a^2*y^2))

2 2 2
- a (y + x )
(25) %e
Post by Ralf Hemmecke
PS: BTW, what does have TeXmacs have to do with this FriCAS question?
I use TeXmacs as a frontend for FriCAS. I would like to be able to use the expressions
generated by the CAS directly in my notes, papers, etc. But apparently, it takes some
work to get that done.
Thanks anyway for your time and your comments.
Marduk
--
You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Ralf Hemmecke
2018-11-08 15:03:34 UTC
Permalink
Post by oldk1331
We can use "paren"/"box" to keep the factors.
I was thinking about "box", but not in such a sophisticated way as you
did. Comes probably from my dislike of Expression(X). ;-)

Ralf
Post by oldk1331
(25) -> exp map(x+->box(x::EXPR INT),factor numer first argument
mainKernel exp(-a^2*x^2 - a^2*y^2))
2 2 2
- a (y + x )
(25) %e
--
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+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Loading...